iio: imu: st_lsm6dsx: use i2c/spi device name for iio_dev name
authorLorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Mon, 3 Apr 2017 17:27:39 +0000 (19:27 +0200)
committerJonathan Cameron <jic23@kernel.org>
Sat, 8 Apr 2017 17:09:40 +0000 (18:09 +0100)
Use the correct chip name (e.g. lsm6dsm) as suffix for iio_dev name
instead of a generic one (lsm6dsx)

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c

index 6a9849e6b30ad97e11e8cec12c8c9eb09f4bbf8e..4839db7b9690ca60c365acb9a79ade5bbb2c242f 100644 (file)
@@ -71,6 +71,7 @@ enum st_lsm6dsx_fifo_mode {
 
 /**
  * struct st_lsm6dsx_sensor - ST IMU sensor instance
+ * @name: Sensor name.
  * @id: Sensor identifier.
  * @hw: Pointer to instance of struct st_lsm6dsx_hw.
  * @gain: Configured sensor sensitivity.
@@ -83,6 +84,7 @@ enum st_lsm6dsx_fifo_mode {
  * @ts: Latest timestamp from the interrupt handler.
  */
 struct st_lsm6dsx_sensor {
+       char name[32];
        enum st_lsm6dsx_sensor_id id;
        struct st_lsm6dsx_hw *hw;
 
@@ -133,7 +135,7 @@ struct st_lsm6dsx_hw {
 #endif /* CONFIG_SPI_MASTER */
 };
 
-int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
+int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, const char *name,
                     const struct st_lsm6dsx_transfer_function *tf_ops);
 int st_lsm6dsx_sensor_enable(struct st_lsm6dsx_sensor *sensor);
 int st_lsm6dsx_sensor_disable(struct st_lsm6dsx_sensor *sensor);
index f80a3d4ff977bd5d26f695897fc21a3889fabd13..98b51d754a0c5f542a7482769a1f7cc70959d5ca 100644 (file)
@@ -642,7 +642,8 @@ static int st_lsm6dsx_init_device(struct st_lsm6dsx_hw *hw)
 }
 
 static struct iio_dev *st_lsm6dsx_alloc_iiodev(struct st_lsm6dsx_hw *hw,
-                                              enum st_lsm6dsx_sensor_id id)
+                                              enum st_lsm6dsx_sensor_id id,
+                                              const char *name)
 {
        struct st_lsm6dsx_sensor *sensor;
        struct iio_dev *iio_dev;
@@ -666,27 +667,30 @@ static struct iio_dev *st_lsm6dsx_alloc_iiodev(struct st_lsm6dsx_hw *hw,
        case ST_LSM6DSX_ID_ACC:
                iio_dev->channels = st_lsm6dsx_acc_channels;
                iio_dev->num_channels = ARRAY_SIZE(st_lsm6dsx_acc_channels);
-               iio_dev->name = "lsm6dsx_accel";
                iio_dev->info = &st_lsm6dsx_acc_info;
 
                sensor->decimator_mask = ST_LSM6DSX_REG_ACC_DEC_MASK;
+               scnprintf(sensor->name, sizeof(sensor->name), "%s_accel",
+                         name);
                break;
        case ST_LSM6DSX_ID_GYRO:
                iio_dev->channels = st_lsm6dsx_gyro_channels;
                iio_dev->num_channels = ARRAY_SIZE(st_lsm6dsx_gyro_channels);
-               iio_dev->name = "lsm6dsx_gyro";
                iio_dev->info = &st_lsm6dsx_gyro_info;
 
                sensor->decimator_mask = ST_LSM6DSX_REG_GYRO_DEC_MASK;
+               scnprintf(sensor->name, sizeof(sensor->name), "%s_gyro",
+                         name);
                break;
        default:
                return NULL;
        }
+       iio_dev->name = sensor->name;
 
        return iio_dev;
 }
 
-int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
+int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, const char *name,
                     const struct st_lsm6dsx_transfer_function *tf_ops)
 {
        struct st_lsm6dsx_hw *hw;
@@ -710,7 +714,7 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
                return err;
 
        for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) {
-               hw->iio_devs[i] = st_lsm6dsx_alloc_iiodev(hw, i);
+               hw->iio_devs[i] = st_lsm6dsx_alloc_iiodev(hw, i, name);
                if (!hw->iio_devs[i])
                        return -ENOMEM;
        }
index 2e4ed26fcbbd29bfbd9edce2ff6f123848f023ca..09a51cfb9b5e4bc75d98e3110e197e47b730efdf 100644 (file)
@@ -61,7 +61,7 @@ static int st_lsm6dsx_i2c_probe(struct i2c_client *client,
                                const struct i2c_device_id *id)
 {
        return st_lsm6dsx_probe(&client->dev, client->irq,
-                               (int)id->driver_data,
+                               (int)id->driver_data, id->name,
                                &st_lsm6dsx_transfer_fn);
 }
 
index 1bf4a582e6cfaccc1efa1b103c5cb820d0b828c9..f765a5058488ccbdf12b8f76eb0d814c0304eba9 100644 (file)
@@ -78,7 +78,7 @@ static int st_lsm6dsx_spi_probe(struct spi_device *spi)
        const struct spi_device_id *id = spi_get_device_id(spi);
 
        return st_lsm6dsx_probe(&spi->dev, spi->irq,
-                               (int)id->driver_data,
+                               (int)id->driver_data, id->name,
                                &st_lsm6dsx_transfer_fn);
 }