spi/pl022: Fix chipselects pointer computation
[deliverable/linux.git] / drivers / spi / spi-pl022.c
index 959f2acff2d301c04a6ffad0916e6b8af3166db4..827ad5152d8b9fc53b6bc2226851f375325c0107 100644 (file)
@@ -2053,8 +2053,7 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id)
        }
 
        /* Allocate master with space for data */
-       master = spi_alloc_master(dev, sizeof(struct pl022) + sizeof(int) *
-                                 num_cs);
+       master = spi_alloc_master(dev, sizeof(struct pl022));
        if (master == NULL) {
                dev_err(&adev->dev, "probe - cannot alloc SPI master\n");
                status = -ENOMEM;
@@ -2066,8 +2065,8 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id)
        pl022->master_info = platform_info;
        pl022->adev = adev;
        pl022->vendor = id->data;
-       /* Point chipselects to allocated memory beyond the main struct */
-       pl022->chipselects = (int *) pl022 + sizeof(struct pl022);
+       pl022->chipselects = devm_kzalloc(dev, num_cs * sizeof(int),
+                                         GFP_KERNEL);
 
        /*
         * Bus Number Which has been Assigned to this SSP controller
This page took 0.031613 seconds and 5 git commands to generate.