]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
staging: iio: hmc5843: Set iio name dynamically
authorYong Li <sdliyong@gmail.com>
Wed, 12 Aug 2015 13:25:46 +0000 (21:25 +0800)
committerJonathan Cameron <jic23@kernel.org>
Sun, 16 Aug 2015 09:51:27 +0000 (10:51 +0100)
Load the driver using the below command:
echo hmc5983 0x1e > /sys/bus/i2c/devices/i2c-?/new_device

In sysfs, the iio name is hmc5843, however the i2c name is hmc5983,
they are inconsistent.

With this patch, the iio name will be the same as the i2c device name

Signed-off-by: Yong Li <sdliyong@gmail.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/staging/iio/magnetometer/hmc5843.h
drivers/staging/iio/magnetometer/hmc5843_core.c
drivers/staging/iio/magnetometer/hmc5843_i2c.c
drivers/staging/iio/magnetometer/hmc5843_spi.c

index f3d0da2fe4589c29c9ff318cb64555f05ab46e1a..06f35d3828e48be6b0b93014e8a6fc56ab69e8be 100644 (file)
@@ -48,7 +48,7 @@ struct hmc5843_data {
 };
 
 int hmc5843_common_probe(struct device *dev, struct regmap *regmap,
-                        enum hmc5843_ids id);
+                        enum hmc5843_ids id, const char *name);
 int hmc5843_common_remove(struct device *dev);
 
 int hmc5843_common_suspend(struct device *dev);
index fffca3a9f637b868b00ec57126b84f4c72c64d7e..4aab0228a1955ac9a3f095dd585370b44861db16 100644 (file)
@@ -577,7 +577,7 @@ int hmc5843_common_resume(struct device *dev)
 EXPORT_SYMBOL(hmc5843_common_resume);
 
 int hmc5843_common_probe(struct device *dev, struct regmap *regmap,
-                        enum hmc5843_ids id)
+                        enum hmc5843_ids id, const char *name)
 {
        struct hmc5843_data *data;
        struct iio_dev *indio_dev;
@@ -597,7 +597,7 @@ int hmc5843_common_probe(struct device *dev, struct regmap *regmap,
        mutex_init(&data->lock);
 
        indio_dev->dev.parent = dev;
-       indio_dev->name = dev->driver->name;
+       indio_dev->name = name;
        indio_dev->info = &hmc5843_info;
        indio_dev->modes = INDIO_DIRECT_MODE;
        indio_dev->channels = data->variant->channels;
index ff08667fa2f60071ab6a5dd800830db2ae03b224..3e06ceb32059663d1f62ce0daa209108c228d942 100644 (file)
@@ -61,7 +61,7 @@ static int hmc5843_i2c_probe(struct i2c_client *cli,
 {
        return hmc5843_common_probe(&cli->dev,
                        devm_regmap_init_i2c(cli, &hmc5843_i2c_regmap_config),
-                       id->driver_data);
+                       id->driver_data, id->name);
 }
 
 static int hmc5843_i2c_remove(struct i2c_client *client)
index 8e658f736e1f6278d33eb13ec3ae256e1ad2c1d7..8a80d0187ca623f71b3b39d3e02d0b8d5e173300 100644 (file)
@@ -59,6 +59,7 @@ static const struct regmap_config hmc5843_spi_regmap_config = {
 static int hmc5843_spi_probe(struct spi_device *spi)
 {
        int ret;
+       const struct spi_device_id *id = spi_get_device_id(spi);
 
        spi->mode = SPI_MODE_3;
        spi->max_speed_hz = 8000000;
@@ -69,7 +70,7 @@ static int hmc5843_spi_probe(struct spi_device *spi)
 
        return hmc5843_common_probe(&spi->dev,
                        devm_regmap_init_spi(spi, &hmc5843_spi_regmap_config),
-                       HMC5983_ID);
+                       id->driver_data, id->name);
 }
 
 static int hmc5843_spi_remove(struct spi_device *spi)