Skip to content

Commit 11346db

Browse files
andy-shevbroonie
authored andcommitted
spi: pxa2xx: Provide num-cs for Sharp PDAs via device properties
Since driver can parse num-cs device property, replace platform data with this new approach. This pursues the following objectives: - getting rid of the public header that barely used outside of the SPI subsystem (more specifically the SPI PXA2xx drivers) - making a trampoline for the driver to support non-default number of the chip select pins in case the original code is going to be converted to Device Tree model It's not expected to have more users in board files except this one. Signed-off-by: Andy Shevchenko <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 2c54754 commit 11346db

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

arch/arm/mach-pxa/spitz.c

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
#include <linux/i2c.h>
1919
#include <linux/platform_data/i2c-pxa.h>
2020
#include <linux/platform_data/pca953x.h>
21+
#include <linux/property.h>
2122
#include <linux/spi/spi.h>
2223
#include <linux/spi/ads7846.h>
2324
#include <linux/spi/corgi_lcd.h>
24-
#include <linux/spi/pxa2xx_spi.h>
2525
#include <linux/mtd/sharpsl.h>
2626
#include <linux/mtd/physmap.h>
2727
#include <linux/input-event-codes.h>
@@ -569,10 +569,6 @@ static struct spi_board_info spitz_spi_devices[] = {
569569
},
570570
};
571571

572-
static struct pxa2xx_spi_controller spitz_spi_info = {
573-
.num_chipselect = 3,
574-
};
575-
576572
static struct gpiod_lookup_table spitz_spi_gpio_table = {
577573
.dev_id = "spi2",
578574
.table = {
@@ -583,10 +579,20 @@ static struct gpiod_lookup_table spitz_spi_gpio_table = {
583579
},
584580
};
585581

582+
static const struct property_entry spitz_spi_properties[] = {
583+
PROPERTY_ENTRY_U32("num-cs", 3),
584+
{ }
585+
};
586+
587+
static const struct software_node spitz_spi_node = {
588+
.properties = spitz_spi_properties,
589+
};
590+
586591
static void __init spitz_spi_init(void)
587592
{
588593
struct platform_device *pd;
589594
int id = 2;
595+
int err;
590596

591597
if (machine_is_akita())
592598
gpiod_add_lookup_table(&akita_lcdcon_gpio_table);
@@ -601,8 +607,13 @@ static void __init spitz_spi_init(void)
601607
if (pd == NULL) {
602608
pr_err("pxa2xx-spi: failed to allocate device id %d\n", id);
603609
} else {
604-
pd->dev.platform_data = &spitz_spi_info;
605-
platform_device_add(pd);
610+
err = device_add_software_node(&pd->dev, &spitz_spi_node);
611+
if (err) {
612+
platform_device_put(pd);
613+
pr_err("pxa2xx-spi: failed to add software node\n");
614+
} else {
615+
platform_device_add(pd);
616+
}
606617
}
607618

608619
spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices));

0 commit comments

Comments
 (0)