staging:iio:ad7606: Remove redundant name field from ad7606_chip_info
authorLars-Peter Clausen <lars@metafoo.de>
Wed, 19 Oct 2016 17:06:57 +0000 (19:06 +0200)
committerJonathan Cameron <jic23@kernel.org>
Sun, 23 Oct 2016 18:34:12 +0000 (19:34 +0100)
The name field in the ad7606_chip_info struct is set to the same value as
the as the name field in the corresponding {platform,spi}_device_id table
entry. Remove it from the ad7606_chip_info struct and pass the name from
the ID to the probe function. This slightly reduces the size of the
chip_info table and adding new entries requires less boilerplate.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/staging/iio/adc/ad7606.h
drivers/staging/iio/adc/ad7606_core.c
drivers/staging/iio/adc/ad7606_par.c
drivers/staging/iio/adc/ad7606_spi.c

index b7e59a6c4b05a4bef2055a86f36285448924744b..380c56ae6570f1ea4230155dcbd2ad65958687fb 100644 (file)
@@ -48,7 +48,6 @@ struct ad7606_platform_data {
  */
 
 struct ad7606_chip_info {
-       const char                      *name;
        const struct iio_chan_spec      *channels;
        unsigned int                    num_channels;
 };
@@ -84,7 +83,8 @@ struct ad7606_bus_ops {
 };
 
 struct iio_dev *ad7606_probe(struct device *dev, int irq,
-                             void __iomem *base_address, unsigned int id,
+                             void __iomem *base_address,
+                             const char *name, unsigned int id,
                              const struct ad7606_bus_ops *bops);
 int ad7606_remove(struct iio_dev *indio_dev, int irq);
 int ad7606_reset(struct ad7606_state *st);
index a1f18d412cb05bb7c75343a00c2f424261be886d..109364750ac75b83b5f179bc9f5ca01a419d6ee9 100644 (file)
@@ -260,17 +260,14 @@ static const struct ad7606_chip_info ad7606_chip_info_tbl[] = {
         * More devices added in future
         */
        [ID_AD7606_8] = {
-               .name = "ad7606",
                .channels = ad7606_channels,
                .num_channels = 9,
        },
        [ID_AD7606_6] = {
-               .name = "ad7606-6",
                .channels = ad7606_channels,
                .num_channels = 7,
        },
        [ID_AD7606_4] = {
-               .name = "ad7606-4",
                .channels = ad7606_channels,
                .num_channels = 5,
        },
@@ -438,7 +435,7 @@ static const struct iio_info ad7606_info_range = {
 
 struct iio_dev *ad7606_probe(struct device *dev, int irq,
                             void __iomem *base_address,
-                            unsigned int id,
+                            const char *name, unsigned int id,
                             const struct ad7606_bus_ops *bops)
 {
        struct ad7606_platform_data *pdata = dev->platform_data;
@@ -491,7 +488,7 @@ struct iio_dev *ad7606_probe(struct device *dev, int irq,
                        indio_dev->info = &ad7606_info_no_os_or_range;
        }
        indio_dev->modes = INDIO_DIRECT_MODE;
-       indio_dev->name = st->chip_info->name;
+       indio_dev->name = name;
        indio_dev->channels = st->chip_info->channels;
        indio_dev->num_channels = st->chip_info->num_channels;
 
@@ -505,8 +502,8 @@ struct iio_dev *ad7606_probe(struct device *dev, int irq,
        if (ret)
                dev_warn(st->dev, "failed to RESET: no RESET GPIO specified\n");
 
-       ret = request_irq(irq, ad7606_interrupt,
-                         IRQF_TRIGGER_FALLING, st->chip_info->name, indio_dev);
+       ret = request_irq(irq, ad7606_interrupt, IRQF_TRIGGER_FALLING, name,
+                         indio_dev);
        if (ret)
                goto error_free_gpios;
 
index 84d23930fdde1b351381c314a3755babf2ef4b4c..0a23cd923415f77f9dbe903b7c93ac79255276ca 100644 (file)
@@ -49,6 +49,7 @@ static const struct ad7606_bus_ops ad7606_par8_bops = {
 
 static int ad7606_par_probe(struct platform_device *pdev)
 {
+       const struct platform_device_id *id = platform_get_device_id(pdev);
        struct resource *res;
        struct iio_dev *indio_dev;
        void __iomem *addr;
@@ -69,7 +70,7 @@ static int ad7606_par_probe(struct platform_device *pdev)
        remap_size = resource_size(res);
 
        indio_dev = ad7606_probe(&pdev->dev, irq, addr,
-                                platform_get_device_id(pdev)->driver_data,
+                                id->name, id->driver_data,
                                 remap_size > 1 ? &ad7606_par16_bops :
                                 &ad7606_par8_bops);
 
index 9587fa86dc69589fc34aa0105584ef3b24add210..f69db597d6e0fce96761e9f306451f01432611c6 100644 (file)
@@ -42,10 +42,11 @@ static const struct ad7606_bus_ops ad7606_spi_bops = {
 
 static int ad7606_spi_probe(struct spi_device *spi)
 {
+       const struct spi_device_id *id = spi_get_device_id(spi);
        struct iio_dev *indio_dev;
 
        indio_dev = ad7606_probe(&spi->dev, spi->irq, NULL,
-                                spi_get_device_id(spi)->driver_data,
+                                id->name, id->driver_data,
                                 &ad7606_spi_bops);
 
        if (IS_ERR(indio_dev))