diff --git a/spi/pn5180.c b/spi/pn5180.c new file mode 100644 index 000000000..17f27ac53 --- /dev/null +++ b/spi/pn5180.c @@ -0,0 +1,60 @@ +#include +#include +#include + +#define IS_USE_STATIC_PLATFORM_DATA 0 + +struct CHIP { + struct spi_device *spi; +}; + +#if IS_USE_STATIC_PLATFORM_DATA +struct CHIP_platform_data { + int spi_ch; +}; +#endif // IS_USE_STATIC_PLATFORM_DATA + +static int CHIP_probe(struct spi_device *spi) +{ + struct CHIP *chip; +#if IS_USE_STATIC_PLATFORM_DATA + struct CHIP_platform_data *pdata; + + /* assuming the driver requires board-specific data: */ + pdata = (struct CHIP_platform_data *)&spi->dev.platform_data; + if (!pdata) + return -ENODEV; +#endif // IS_USE_STATIC_PLATFORM_DATA + + /* get memory for driver's per-chip state */ + chip = kzalloc(sizeof *chip, GFP_KERNEL); + if (!chip) + return -ENOMEM; + + spi_set_drvdata(spi, chip); + + return 0; +} + +int CHIP_remove(struct spi_device *spi) +{ + struct CHIP *chip = NULL; + + chip = (struct CHIP *)spi_get_drvdata(spi); + + kfree(chip); + + return 0; +} + +static struct spi_driver CHIP_driver = { + .driver = { + .name = "CHIP", + .owner = THIS_MODULE, + }, + + .probe = CHIP_probe, + .remove = CHIP_remove, +}; + +module_spi_driver(CHIP_driver);