diff options
author | Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> | 2017-04-03 13:27:39 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2017-04-08 13:09:40 -0400 |
commit | 510c01063085b5dc7788d9953f9bf58e16b631e8 (patch) | |
tree | 6521a8be24d96f50a828445b7dee3c5a7345b7a0 | |
parent | 63c3ecd946d4ae2879ec0d8c6dcb90132a74d831 (diff) |
iio: imu: st_lsm6dsx: use i2c/spi device name for iio_dev name
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>
-rw-r--r-- | drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 4 | ||||
-rw-r--r-- | drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 14 | ||||
-rw-r--r-- | drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c | 2 | ||||
-rw-r--r-- | drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c | 2 |
4 files changed, 14 insertions, 8 deletions
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h index 6a9849e6b30a..4839db7b9690 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | |||
@@ -71,6 +71,7 @@ enum st_lsm6dsx_fifo_mode { | |||
71 | 71 | ||
72 | /** | 72 | /** |
73 | * struct st_lsm6dsx_sensor - ST IMU sensor instance | 73 | * struct st_lsm6dsx_sensor - ST IMU sensor instance |
74 | * @name: Sensor name. | ||
74 | * @id: Sensor identifier. | 75 | * @id: Sensor identifier. |
75 | * @hw: Pointer to instance of struct st_lsm6dsx_hw. | 76 | * @hw: Pointer to instance of struct st_lsm6dsx_hw. |
76 | * @gain: Configured sensor sensitivity. | 77 | * @gain: Configured sensor sensitivity. |
@@ -83,6 +84,7 @@ enum st_lsm6dsx_fifo_mode { | |||
83 | * @ts: Latest timestamp from the interrupt handler. | 84 | * @ts: Latest timestamp from the interrupt handler. |
84 | */ | 85 | */ |
85 | struct st_lsm6dsx_sensor { | 86 | struct st_lsm6dsx_sensor { |
87 | char name[32]; | ||
86 | enum st_lsm6dsx_sensor_id id; | 88 | enum st_lsm6dsx_sensor_id id; |
87 | struct st_lsm6dsx_hw *hw; | 89 | struct st_lsm6dsx_hw *hw; |
88 | 90 | ||
@@ -133,7 +135,7 @@ struct st_lsm6dsx_hw { | |||
133 | #endif /* CONFIG_SPI_MASTER */ | 135 | #endif /* CONFIG_SPI_MASTER */ |
134 | }; | 136 | }; |
135 | 137 | ||
136 | int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, | 138 | int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, const char *name, |
137 | const struct st_lsm6dsx_transfer_function *tf_ops); | 139 | const struct st_lsm6dsx_transfer_function *tf_ops); |
138 | int st_lsm6dsx_sensor_enable(struct st_lsm6dsx_sensor *sensor); | 140 | int st_lsm6dsx_sensor_enable(struct st_lsm6dsx_sensor *sensor); |
139 | int st_lsm6dsx_sensor_disable(struct st_lsm6dsx_sensor *sensor); | 141 | int st_lsm6dsx_sensor_disable(struct st_lsm6dsx_sensor *sensor); |
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index f80a3d4ff977..98b51d754a0c 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | |||
@@ -642,7 +642,8 @@ static int st_lsm6dsx_init_device(struct st_lsm6dsx_hw *hw) | |||
642 | } | 642 | } |
643 | 643 | ||
644 | static struct iio_dev *st_lsm6dsx_alloc_iiodev(struct st_lsm6dsx_hw *hw, | 644 | static struct iio_dev *st_lsm6dsx_alloc_iiodev(struct st_lsm6dsx_hw *hw, |
645 | enum st_lsm6dsx_sensor_id id) | 645 | enum st_lsm6dsx_sensor_id id, |
646 | const char *name) | ||
646 | { | 647 | { |
647 | struct st_lsm6dsx_sensor *sensor; | 648 | struct st_lsm6dsx_sensor *sensor; |
648 | struct iio_dev *iio_dev; | 649 | struct iio_dev *iio_dev; |
@@ -666,27 +667,30 @@ static struct iio_dev *st_lsm6dsx_alloc_iiodev(struct st_lsm6dsx_hw *hw, | |||
666 | case ST_LSM6DSX_ID_ACC: | 667 | case ST_LSM6DSX_ID_ACC: |
667 | iio_dev->channels = st_lsm6dsx_acc_channels; | 668 | iio_dev->channels = st_lsm6dsx_acc_channels; |
668 | iio_dev->num_channels = ARRAY_SIZE(st_lsm6dsx_acc_channels); | 669 | iio_dev->num_channels = ARRAY_SIZE(st_lsm6dsx_acc_channels); |
669 | iio_dev->name = "lsm6dsx_accel"; | ||
670 | iio_dev->info = &st_lsm6dsx_acc_info; | 670 | iio_dev->info = &st_lsm6dsx_acc_info; |
671 | 671 | ||
672 | sensor->decimator_mask = ST_LSM6DSX_REG_ACC_DEC_MASK; | 672 | sensor->decimator_mask = ST_LSM6DSX_REG_ACC_DEC_MASK; |
673 | scnprintf(sensor->name, sizeof(sensor->name), "%s_accel", | ||
674 | name); | ||
673 | break; | 675 | break; |
674 | case ST_LSM6DSX_ID_GYRO: | 676 | case ST_LSM6DSX_ID_GYRO: |
675 | iio_dev->channels = st_lsm6dsx_gyro_channels; | 677 | iio_dev->channels = st_lsm6dsx_gyro_channels; |
676 | iio_dev->num_channels = ARRAY_SIZE(st_lsm6dsx_gyro_channels); | 678 | iio_dev->num_channels = ARRAY_SIZE(st_lsm6dsx_gyro_channels); |
677 | iio_dev->name = "lsm6dsx_gyro"; | ||
678 | iio_dev->info = &st_lsm6dsx_gyro_info; | 679 | iio_dev->info = &st_lsm6dsx_gyro_info; |
679 | 680 | ||
680 | sensor->decimator_mask = ST_LSM6DSX_REG_GYRO_DEC_MASK; | 681 | sensor->decimator_mask = ST_LSM6DSX_REG_GYRO_DEC_MASK; |
682 | scnprintf(sensor->name, sizeof(sensor->name), "%s_gyro", | ||
683 | name); | ||
681 | break; | 684 | break; |
682 | default: | 685 | default: |
683 | return NULL; | 686 | return NULL; |
684 | } | 687 | } |
688 | iio_dev->name = sensor->name; | ||
685 | 689 | ||
686 | return iio_dev; | 690 | return iio_dev; |
687 | } | 691 | } |
688 | 692 | ||
689 | int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, | 693 | int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, const char *name, |
690 | const struct st_lsm6dsx_transfer_function *tf_ops) | 694 | const struct st_lsm6dsx_transfer_function *tf_ops) |
691 | { | 695 | { |
692 | struct st_lsm6dsx_hw *hw; | 696 | struct st_lsm6dsx_hw *hw; |
@@ -710,7 +714,7 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, | |||
710 | return err; | 714 | return err; |
711 | 715 | ||
712 | for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) { | 716 | for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) { |
713 | hw->iio_devs[i] = st_lsm6dsx_alloc_iiodev(hw, i); | 717 | hw->iio_devs[i] = st_lsm6dsx_alloc_iiodev(hw, i, name); |
714 | if (!hw->iio_devs[i]) | 718 | if (!hw->iio_devs[i]) |
715 | return -ENOMEM; | 719 | return -ENOMEM; |
716 | } | 720 | } |
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c index 2e4ed26fcbbd..09a51cfb9b5e 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c | |||
@@ -61,7 +61,7 @@ static int st_lsm6dsx_i2c_probe(struct i2c_client *client, | |||
61 | const struct i2c_device_id *id) | 61 | const struct i2c_device_id *id) |
62 | { | 62 | { |
63 | return st_lsm6dsx_probe(&client->dev, client->irq, | 63 | return st_lsm6dsx_probe(&client->dev, client->irq, |
64 | (int)id->driver_data, | 64 | (int)id->driver_data, id->name, |
65 | &st_lsm6dsx_transfer_fn); | 65 | &st_lsm6dsx_transfer_fn); |
66 | } | 66 | } |
67 | 67 | ||
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c index 1bf4a582e6cf..f765a5058488 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c | |||
@@ -78,7 +78,7 @@ static int st_lsm6dsx_spi_probe(struct spi_device *spi) | |||
78 | const struct spi_device_id *id = spi_get_device_id(spi); | 78 | const struct spi_device_id *id = spi_get_device_id(spi); |
79 | 79 | ||
80 | return st_lsm6dsx_probe(&spi->dev, spi->irq, | 80 | return st_lsm6dsx_probe(&spi->dev, spi->irq, |
81 | (int)id->driver_data, | 81 | (int)id->driver_data, id->name, |
82 | &st_lsm6dsx_transfer_fn); | 82 | &st_lsm6dsx_transfer_fn); |
83 | } | 83 | } |
84 | 84 | ||