mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1] staging: iio: hmc5843: Set iio name dynamically based on i2c name
@ 2015-08-12  8:20 sdliyong
  2015-08-12  8:28 ` Lars-Peter Clausen
  0 siblings, 1 reply; 3+ messages in thread
From: sdliyong @ 2015-08-12  8:20 UTC (permalink / raw)
  To: jic23, knaack.h, lars, pmeerw, gregkh, cristina.opriceana,
	tolga.ceylan, k.kozlowski, sdliyong, linux-iio, devel,
	linux-kernel

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_i2c.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/iio/magnetometer/hmc5843_i2c.c b/drivers/staging/iio/magnetometer/hmc5843_i2c.c
index ff08667..3b03644 100644
--- a/drivers/staging/iio/magnetometer/hmc5843_i2c.c
+++ b/drivers/staging/iio/magnetometer/hmc5843_i2c.c
@@ -59,6 +59,7 @@ static const struct regmap_config hmc5843_i2c_regmap_config = {
 static int hmc5843_i2c_probe(struct i2c_client *cli,
 			     const struct i2c_device_id *id)
 {
+	cli->dev.driver->name = id->name;
 	return hmc5843_common_probe(&cli->dev,
 			devm_regmap_init_i2c(cli, &hmc5843_i2c_regmap_config),
 			id->driver_data);
-- 
2.1.0


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

* Re: [PATCH v1] staging: iio: hmc5843: Set iio name dynamically based on i2c name
  2015-08-12  8:20 [PATCH v1] staging: iio: hmc5843: Set iio name dynamically based on i2c name sdliyong
@ 2015-08-12  8:28 ` Lars-Peter Clausen
  2015-08-12  8:37   ` LIYONG
  0 siblings, 1 reply; 3+ messages in thread
From: Lars-Peter Clausen @ 2015-08-12  8:28 UTC (permalink / raw)
  To: sdliyong, jic23, knaack.h, pmeerw, gregkh, cristina.opriceana,
	tolga.ceylan, k.kozlowski, linux-iio, devel, linux-kernel

On 08/12/2015 10:20 AM, 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>
> ---
>  drivers/staging/iio/magnetometer/hmc5843_i2c.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/staging/iio/magnetometer/hmc5843_i2c.c b/drivers/staging/iio/magnetometer/hmc5843_i2c.c
> index ff08667..3b03644 100644
> --- a/drivers/staging/iio/magnetometer/hmc5843_i2c.c
> +++ b/drivers/staging/iio/magnetometer/hmc5843_i2c.c
> @@ -59,6 +59,7 @@ static const struct regmap_config hmc5843_i2c_regmap_config = {
>  static int hmc5843_i2c_probe(struct i2c_client *cli,
>  			     const struct i2c_device_id *id)
>  {
> +	cli->dev.driver->name = id->name;

You are overwriting a the name of the driver, which is a struct that is
shared between all instances of the device which specific data from one
device. That is most certainly not correct.

Update hmc5843_common_probe() and add a parameter that takes the name for
the device and then pass the id->name when the function is called.

>  	return hmc5843_common_probe(&cli->dev,
>  			devm_regmap_init_i2c(cli, &hmc5843_i2c_regmap_config),
>  			id->driver_data);
> 


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

* Re: [PATCH v1] staging: iio: hmc5843: Set iio name dynamically based on i2c name
  2015-08-12  8:28 ` Lars-Peter Clausen
@ 2015-08-12  8:37   ` LIYONG
  0 siblings, 0 replies; 3+ messages in thread
From: LIYONG @ 2015-08-12  8:37 UTC (permalink / raw)
  To: Lars-Peter Clausen
  Cc: jic23, knaack.h, pmeerw, gregkh, cristina.opriceana,
	tolga.ceylan, k.kozlowski, linux-iio, devel, linux-kernel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb2312", Size: 1831 bytes --]

thanks for your comments. let me submit another one

·¢×ÔÎÒµÄ iPhone

> ÔÚ 2015Äê8ÔÂ12ÈÕ£¬16:28£¬Lars-Peter Clausen <lars@metafoo.de> дµÀ£º
> 
>> On 08/12/2015 10:20 AM, 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>
>> ---
>> drivers/staging/iio/magnetometer/hmc5843_i2c.c | 1 +
>> 1 file changed, 1 insertion(+)
>> 
>> diff --git a/drivers/staging/iio/magnetometer/hmc5843_i2c.c b/drivers/staging/iio/magnetometer/hmc5843_i2c.c
>> index ff08667..3b03644 100644
>> --- a/drivers/staging/iio/magnetometer/hmc5843_i2c.c
>> +++ b/drivers/staging/iio/magnetometer/hmc5843_i2c.c
>> @@ -59,6 +59,7 @@ static const struct regmap_config hmc5843_i2c_regmap_config = {
>> static int hmc5843_i2c_probe(struct i2c_client *cli,
>>                 const struct i2c_device_id *id)
>> {
>> +    cli->dev.driver->name = id->name;
> 
> You are overwriting a the name of the driver, which is a struct that is
> shared between all instances of the device which specific data from one
> device. That is most certainly not correct.
> 
> Update hmc5843_common_probe() and add a parameter that takes the name for
> the device and then pass the id->name when the function is called.
> 
>>    return hmc5843_common_probe(&cli->dev,
>>            devm_regmap_init_i2c(cli, &hmc5843_i2c_regmap_config),
>>            id->driver_data);
>> 
> 
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

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

end of thread, other threads:[~2015-08-12  8:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-12  8:20 [PATCH v1] staging: iio: hmc5843: Set iio name dynamically based on i2c name sdliyong
2015-08-12  8:28 ` Lars-Peter Clausen
2015-08-12  8:37   ` LIYONG

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®