linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: i2c: core: report OF style module alias for devices registered via OF
@ 2018-01-16 13:55 Dmitry Mastykin
  2018-01-16 14:11 ` Javier Martinez Canillas
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Mastykin @ 2018-01-16 13:55 UTC (permalink / raw)
  To: Javier Martinez Canillas
  Cc: Dmitry Mastykin, Linux Kernel Mailing List, Wolfram Sang, linux-i2c

On Sun, 3 Dec 2017 22:40:50 +0100, Javier Martinez Canillas
<javierm@redhat.com> wrote:

> The buses should honor the firmware interface used to register the device,
> but the I2C core reports a MODALIAS of the form i2c:<device> even for I2C
> devices registered via OF.
>
> This means that user-space will never get an OF stype uevent MODALIAS even
> when the drivers modules contain aliases exported from both the I2C and OF
> device ID tables. For example, an Atmel maXTouch Touchscreen registered by
> a DT node with compatible "atmel,maxtouch" has the following module alias:
>
> $ cat /sys/class/i2c-adapter/i2c-8/8-004b/modalias
> i2c:maxtouch
>
> So udev won't be able to auto-load a module for an OF-only device driver.
> Many OF-only drivers duplicate the OF device ID table entries in an I2C ID
> table only has a workaround for how the I2C core reports the module alias.
>
> This patch changes the I2C core to report an OF related MODALIAS uevent if
> the device was registered via OF. So for the previous example, after this
> patch, the reported MODALIAS for the Atmel maXTouch will be the following:
>
> $ cat /sys/class/i2c-adapter/i2c-8/8-004b/modalias
> of:NtrackpadT<NULL>Catmel,maxtouch
>
> NOTE: This patch may break out-of-tree drivers that were relying on this
>       behavior, and only had an I2C device ID table even when the device
>       was registered via OF. There are no remaining drivers in mainline
>       that do this, but out-of-tree drivers have to be fixed and define
>       a proper OF device ID table to have module auto-loading working.
>

Hello Javier,
thank you for your patch!

I had problem with auto-loading max9611 module, because it has no I2C
device ID table:
$ cat /sys/class/i2c-adapter/i2c-0/0-0070/modalias
of:Nmax9611_0_70T<NULL>Cmaxim,max9611

With your patch it has been auto-loaded well:
[    0.796180] i2c i2c-0: of_i2c: register /ocp/i2c@44e0b000/max9611_0_70@70
[    0.796431] i2c i2c-0: client [max9611] registered with bus id 0-0070
[    6.260710] i2c-core: driver [max9611] registered

Additionally I use several modules with both I2C and OF device ID tables,
they work well with or without the patch (max1363, pinctrl_mcp23s08).

Regards,
Dmitry

Tested-by: Dmitry Mastykin <mastichi@gmail.com>

> Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
> ---
>  drivers/i2c/i2c-core-base.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
> index bf52cca87363..1596aa718bc8 100644
> --- a/drivers/i2c/i2c-core-base.c
> +++ b/drivers/i2c/i2c-core-base.c
> @@ -124,6 +124,10 @@ static int i2c_device_uevent(struct device *dev,
> struct kobj_uevent_env *env)
>      struct i2c_client *client = to_i2c_client(dev);
>      int rc;
>
> +    rc = of_device_uevent_modalias(dev, env);
> +    if (rc != -ENODEV)
> +        return rc;
> +
>      rc = acpi_device_uevent_modalias(dev, env);
>      if (rc != -ENODEV)
>          return rc;
> @@ -416,6 +420,10 @@ show_modalias(struct device *dev, struct
> device_attribute *attr, char *buf)
>      struct i2c_client *client = to_i2c_client(dev);
>      int len;
>
> +    len = of_device_modalias(dev, buf, PAGE_SIZE);
> +    if (len != -ENODEV)
> +        return len;
> +
>      len = acpi_device_modalias(dev, buf, PAGE_SIZE -1);
>      if (len != -ENODEV)
>          return len;

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

* Re: i2c: core: report OF style module alias for devices registered via OF
  2018-01-16 13:55 i2c: core: report OF style module alias for devices registered via OF Dmitry Mastykin
@ 2018-01-16 14:11 ` Javier Martinez Canillas
  2018-02-09 17:22   ` Javier Martinez Canillas
  0 siblings, 1 reply; 3+ messages in thread
From: Javier Martinez Canillas @ 2018-01-16 14:11 UTC (permalink / raw)
  To: Dmitry Mastykin; +Cc: Linux Kernel Mailing List, Wolfram Sang, linux-i2c

Hello Dmitry,

On 01/16/2018 02:55 PM, Dmitry Mastykin wrote:
> On Sun, 3 Dec 2017 22:40:50 +0100, Javier Martinez Canillas
> <javierm@redhat.com> wrote:
> 
>> The buses should honor the firmware interface used to register the device,
>> but the I2C core reports a MODALIAS of the form i2c:<device> even for I2C
>> devices registered via OF.
>>
>> This means that user-space will never get an OF stype uevent MODALIAS even
>> when the drivers modules contain aliases exported from both the I2C and OF
>> device ID tables. For example, an Atmel maXTouch Touchscreen registered by
>> a DT node with compatible "atmel,maxtouch" has the following module alias:
>>
>> $ cat /sys/class/i2c-adapter/i2c-8/8-004b/modalias
>> i2c:maxtouch
>>
>> So udev won't be able to auto-load a module for an OF-only device driver.
>> Many OF-only drivers duplicate the OF device ID table entries in an I2C ID
>> table only has a workaround for how the I2C core reports the module alias.
>>
>> This patch changes the I2C core to report an OF related MODALIAS uevent if
>> the device was registered via OF. So for the previous example, after this
>> patch, the reported MODALIAS for the Atmel maXTouch will be the following:
>>
>> $ cat /sys/class/i2c-adapter/i2c-8/8-004b/modalias
>> of:NtrackpadT<NULL>Catmel,maxtouch
>>
>> NOTE: This patch may break out-of-tree drivers that were relying on this
>>       behavior, and only had an I2C device ID table even when the device
>>       was registered via OF. There are no remaining drivers in mainline
>>       that do this, but out-of-tree drivers have to be fixed and define
>>       a proper OF device ID table to have module auto-loading working.
>>
> 
> Hello Javier,
> thank you for your patch!
>

Thanks a lot for testing!

Hopefully Wolfram will review/merge this soon, otherwise in the meantime drivers
are going to add I2C device ID tables just as a workaround or new drivers won't
include a OF device ID tables since these aren't really required today.

I made sure that all the drivers in mainline were fixed before posting this, but
haven't checked since then.

Best regards,
-- 
Javier Martinez Canillas
Software Engineer - Desktop Hardware Enablement
Red Hat

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

* Re: i2c: core: report OF style module alias for devices registered via OF
  2018-01-16 14:11 ` Javier Martinez Canillas
@ 2018-02-09 17:22   ` Javier Martinez Canillas
  0 siblings, 0 replies; 3+ messages in thread
From: Javier Martinez Canillas @ 2018-02-09 17:22 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Dmitry Mastykin, Linux Kernel Mailing List, Linux I2C,
	Javier Martinez Canillas

Hi Wolfram,

On Tue, Jan 16, 2018 at 3:11 PM, Javier Martinez Canillas
<javierm@redhat.com> wrote:
> Hello Dmitry,
>
> On 01/16/2018 02:55 PM, Dmitry Mastykin wrote:
>> On Sun, 3 Dec 2017 22:40:50 +0100, Javier Martinez Canillas
>> <javierm@redhat.com> wrote:
>>
>>> The buses should honor the firmware interface used to register the device,
>>> but the I2C core reports a MODALIAS of the form i2c:<device> even for I2C
>>> devices registered via OF.
>>>
>>> This means that user-space will never get an OF stype uevent MODALIAS even
>>> when the drivers modules contain aliases exported from both the I2C and OF
>>> device ID tables. For example, an Atmel maXTouch Touchscreen registered by
>>> a DT node with compatible "atmel,maxtouch" has the following module alias:
>>>
>>> $ cat /sys/class/i2c-adapter/i2c-8/8-004b/modalias
>>> i2c:maxtouch
>>>
>>> So udev won't be able to auto-load a module for an OF-only device driver.
>>> Many OF-only drivers duplicate the OF device ID table entries in an I2C ID
>>> table only has a workaround for how the I2C core reports the module alias.
>>>
>>> This patch changes the I2C core to report an OF related MODALIAS uevent if
>>> the device was registered via OF. So for the previous example, after this
>>> patch, the reported MODALIAS for the Atmel maXTouch will be the following:
>>>
>>> $ cat /sys/class/i2c-adapter/i2c-8/8-004b/modalias
>>> of:NtrackpadT<NULL>Catmel,maxtouch
>>>
>>> NOTE: This patch may break out-of-tree drivers that were relying on this
>>>       behavior, and only had an I2C device ID table even when the device
>>>       was registered via OF. There are no remaining drivers in mainline
>>>       that do this, but out-of-tree drivers have to be fixed and define
>>>       a proper OF device ID table to have module auto-loading working.
>>>
>>
>> Hello Javier,
>> thank you for your patch!
>>
>
> Thanks a lot for testing!
>
> Hopefully Wolfram will review/merge this soon, otherwise in the meantime drivers
> are going to add I2C device ID tables just as a workaround or new drivers won't
> include a OF device ID tables since these aren't really required today.
>

Another gentle ping for this.

Best regards,
Javier

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

end of thread, other threads:[~2018-02-09 17:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-16 13:55 i2c: core: report OF style module alias for devices registered via OF Dmitry Mastykin
2018-01-16 14:11 ` Javier Martinez Canillas
2018-02-09 17:22   ` Javier Martinez Canillas

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).