goto err_no_pdata;
}
+ if (platform_info->num_chipselect) {
+ num_cs = platform_info->num_chipselect;
+ } else if (IS_ENABLED(CONFIG_OF)) {
+ of_property_read_u32(np, "num-cs", &num_cs);
+ } else {
+ dev_err(&adev->dev, "probe: no chip select defined\n");
+ status = -ENODEV;
+ goto err_no_pdata;
+ }
+
/* 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;
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