linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] staging: iio: hmc5843: Set iio name dynamically
@ 2015-08-12 13:25 sdliyong
  2015-08-12 15:21 ` Lars-Peter Clausen
  0 siblings, 1 reply; 3+ messages in thread
From: sdliyong @ 2015-08-12 13:25 UTC (permalink / raw)
  To: jic23, knaack.h, lars, pmeerw, gregkh, cristina.opriceana,
	tolga.ceylan, k.kozlowski, sdliyong, linux-iio, devel,
	linux-kernel, marek

From: Yong Li <sdliyong@gmail.com>

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>
---
 drivers/staging/iio/magnetometer/hmc5843.h      | 2 +-
 drivers/staging/iio/magnetometer/hmc5843_core.c | 4 ++--
 drivers/staging/iio/magnetometer/hmc5843_i2c.c  | 2 +-
 drivers/staging/iio/magnetometer/hmc5843_spi.c  | 3 ++-
 4 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/iio/magnetometer/hmc5843.h b/drivers/staging/iio/magnetometer/hmc5843.h
index f3d0da2..06f35d3 100644
--- a/drivers/staging/iio/magnetometer/hmc5843.h
+++ b/drivers/staging/iio/magnetometer/hmc5843.h
@@ -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);
diff --git a/drivers/staging/iio/magnetometer/hmc5843_core.c b/drivers/staging/iio/magnetometer/hmc5843_core.c
index fffca3a..4aab022 100644
--- a/drivers/staging/iio/magnetometer/hmc5843_core.c
+++ b/drivers/staging/iio/magnetometer/hmc5843_core.c
@@ -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;
diff --git a/drivers/staging/iio/magnetometer/hmc5843_i2c.c b/drivers/staging/iio/magnetometer/hmc5843_i2c.c
index ff08667..3e06ceb 100644
--- a/drivers/staging/iio/magnetometer/hmc5843_i2c.c
+++ b/drivers/staging/iio/magnetometer/hmc5843_i2c.c
@@ -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)
diff --git a/drivers/staging/iio/magnetometer/hmc5843_spi.c b/drivers/staging/iio/magnetometer/hmc5843_spi.c
index 8e658f7..8a80d01 100644
--- a/drivers/staging/iio/magnetometer/hmc5843_spi.c
+++ b/drivers/staging/iio/magnetometer/hmc5843_spi.c
@@ -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)
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] staging: iio: hmc5843: Set iio name dynamically
  2015-08-12 13:25 [PATCH v2] staging: iio: hmc5843: Set iio name dynamically sdliyong
@ 2015-08-12 15:21 ` Lars-Peter Clausen
  2015-08-15 19:49   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Lars-Peter Clausen @ 2015-08-12 15:21 UTC (permalink / raw)
  To: sdliyong, jic23, knaack.h, pmeerw, gregkh, cristina.opriceana,
	tolga.ceylan, k.kozlowski, linux-iio, devel, linux-kernel, marek

On 08/12/2015 03:25 PM, sdliyong@gmail.com wrote:
> From: Yong Li <sdliyong@gmail.com>
> 
> 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>

Looks good.

Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] staging: iio: hmc5843: Set iio name dynamically
  2015-08-12 15:21 ` Lars-Peter Clausen
@ 2015-08-15 19:49   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2015-08-15 19:49 UTC (permalink / raw)
  To: Lars-Peter Clausen, sdliyong, knaack.h, pmeerw, gregkh,
	cristina.opriceana, tolga.ceylan, k.kozlowski, linux-iio, devel,
	linux-kernel, marek

On 12/08/15 16:21, Lars-Peter Clausen wrote:
> On 08/12/2015 03:25 PM, sdliyong@gmail.com wrote:
>> From: Yong Li <sdliyong@gmail.com>
>>
>> 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>
> 
> Looks good.
> 
> Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git - initially pushed out as testing
for the autobuilders to play with it.

Thanks,

Jonathan
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-08-15 19:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-12 13:25 [PATCH v2] staging: iio: hmc5843: Set iio name dynamically sdliyong
2015-08-12 15:21 ` Lars-Peter Clausen
2015-08-15 19:49   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).