* [PATCH 04/27] [media] Export I2C module alias information in missing drivers
2015-07-30 16:18 [PATCH 00/27] Export I2C and OF module aliases in missing drivers Javier Martinez Canillas
@ 2015-07-30 16:18 ` Javier Martinez Canillas
2015-07-30 16:18 ` [PATCH 11/27] [media] staging: media: lirc: Export I2C module alias information Javier Martinez Canillas
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Javier Martinez Canillas @ 2015-07-30 16:18 UTC (permalink / raw)
To: linux-kernel; +Cc: Javier Martinez Canillas, Mauro Carvalho Chehab, linux-media
The I2C core always reports the MODALIAS uevent as "i2c:<client name"
regardless if the driver was matched using the I2C id_table or the
of_match_table. So the driver needs to export the I2C table and this
be built into the module or udev won't have the necessary information
to auto load the correct module when the device is added.
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
---
drivers/media/i2c/ir-kbd-i2c.c | 1 +
drivers/media/i2c/s5k6a3.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c
index 175a76114953..728d2cc8a3e7 100644
--- a/drivers/media/i2c/ir-kbd-i2c.c
+++ b/drivers/media/i2c/ir-kbd-i2c.c
@@ -478,6 +478,7 @@ static const struct i2c_device_id ir_kbd_id[] = {
{ "ir_rx_z8f0811_hdpvr", 0 },
{ }
};
+MODULE_DEVICE_TABLE(i2c, ir_kbd_id);
static struct i2c_driver ir_kbd_driver = {
.driver = {
diff --git a/drivers/media/i2c/s5k6a3.c b/drivers/media/i2c/s5k6a3.c
index bc389d5e42ae..b1b1574dfb95 100644
--- a/drivers/media/i2c/s5k6a3.c
+++ b/drivers/media/i2c/s5k6a3.c
@@ -363,6 +363,7 @@ static int s5k6a3_remove(struct i2c_client *client)
static const struct i2c_device_id s5k6a3_ids[] = {
{ }
};
+MODULE_DEVICE_TABLE(i2c, s5k6a3_ids);
#ifdef CONFIG_OF
static const struct of_device_id s5k6a3_of_match[] = {
--
2.4.3
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 11/27] [media] staging: media: lirc: Export I2C module alias information
2015-07-30 16:18 [PATCH 00/27] Export I2C and OF module aliases in missing drivers Javier Martinez Canillas
2015-07-30 16:18 ` [PATCH 04/27] [media] Export I2C module alias information " Javier Martinez Canillas
@ 2015-07-30 16:18 ` Javier Martinez Canillas
2015-07-30 16:18 ` [PATCH 24/27] [media] smiapp: Export OF " Javier Martinez Canillas
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Javier Martinez Canillas @ 2015-07-30 16:18 UTC (permalink / raw)
To: linux-kernel; +Cc: Javier Martinez Canillas, Mauro Carvalho Chehab, linux-media
The I2C core always reports the MODALIAS uevent as "i2c:<client name"
regardless if the driver was matched using the I2C id_table or the
of_match_table. So the driver needs to export the I2C table and this
be built into the module or udev won't have the necessary information
to auto load the correct module when the device is added.
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
---
drivers/staging/media/lirc/lirc_zilog.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/staging/media/lirc/lirc_zilog.c b/drivers/staging/media/lirc/lirc_zilog.c
index 261e27d6b054..bebfc3b093bc 100644
--- a/drivers/staging/media/lirc/lirc_zilog.c
+++ b/drivers/staging/media/lirc/lirc_zilog.c
@@ -1364,6 +1364,7 @@ static const struct i2c_device_id ir_transceiver_id[] = {
{ "ir_rx_z8f0811_hdpvr", ID_FLAG_HDPVR },
{ }
};
+MODULE_DEVICE_TABLE(i2c, ir_transceiver_id);
static struct i2c_driver driver = {
.driver = {
--
2.4.3
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 24/27] [media] smiapp: Export OF module alias information
2015-07-30 16:18 [PATCH 00/27] Export I2C and OF module aliases in missing drivers Javier Martinez Canillas
2015-07-30 16:18 ` [PATCH 04/27] [media] Export I2C module alias information " Javier Martinez Canillas
2015-07-30 16:18 ` [PATCH 11/27] [media] staging: media: lirc: Export I2C module alias information Javier Martinez Canillas
@ 2015-07-30 16:18 ` Javier Martinez Canillas
2015-07-30 16:18 ` [PATCH 27/27] i2c: (RFC, don't apply) report OF style modalias when probing using DT Javier Martinez Canillas
2015-07-30 16:35 ` [PATCH 00/27] Export I2C and OF module aliases in missing drivers Dmitry Torokhov
4 siblings, 0 replies; 8+ messages in thread
From: Javier Martinez Canillas @ 2015-07-30 16:18 UTC (permalink / raw)
To: linux-kernel
Cc: Javier Martinez Canillas, Sakari Ailus, Mauro Carvalho Chehab,
linux-media
The I2C core always reports the MODALIAS uevent as "i2c:<client name"
regardless if the driver was matched using the I2C id_table or the
of_match_table. So technically there's no need for a driver to export
the OF table since currently it's not used.
In fact, the I2C device ID table is mandatory for I2C drivers since
a i2c_device_id is passed to the driver's probe function even if the
I2C core used the OF table to match the driver.
And since the I2C core uses different tables, OF-only drivers needs to
have duplicated data that has to be kept in sync and also the dev node
compatible manufacturer prefix is stripped when reporting the MODALIAS.
To avoid the above, the I2C core behavior may be changed in the future
to not require an I2C device table for OF-only drivers and report the
OF module alias. So, it's better to also export the OF table to prevent
breaking module autoloading if that happens.
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
---
drivers/media/i2c/smiapp/smiapp-core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index 636ebd6fe5dc..fb39dfd55e75 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -3131,6 +3131,7 @@ static const struct of_device_id smiapp_of_table[] = {
{ .compatible = "nokia,smia" },
{ },
};
+MODULE_DEVICE_TABLE(of, smiapp_of_table);
static const struct i2c_device_id smiapp_id_table[] = {
{ SMIAPP_NAME, 0 },
--
2.4.3
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 27/27] i2c: (RFC, don't apply) report OF style modalias when probing using DT
2015-07-30 16:18 [PATCH 00/27] Export I2C and OF module aliases in missing drivers Javier Martinez Canillas
` (2 preceding siblings ...)
2015-07-30 16:18 ` [PATCH 24/27] [media] smiapp: Export OF " Javier Martinez Canillas
@ 2015-07-30 16:18 ` Javier Martinez Canillas
2015-07-30 16:35 ` [PATCH 00/27] Export I2C and OF module aliases in missing drivers Dmitry Torokhov
4 siblings, 0 replies; 8+ messages in thread
From: Javier Martinez Canillas @ 2015-07-30 16:18 UTC (permalink / raw)
To: linux-kernel
Cc: Javier Martinez Canillas, alsa-devel, Mark Brown, linux-iio,
linux-fbdev, linux-i2c, linux-leds, Sebastian Reichel,
Chanwoo Choi, Tomi Valkeinen, lm-sensors, Alexandre Belloni,
linux-input, Greg Kroah-Hartman, Jean Delvare, Jonathan Cameron,
linux-media, rtc-linux, linux-pm, Mauro Carvalho Chehab,
Guenter Roeck, Benjamin Herrenschmidt, Wolfram Sang, Takashi Iwai,
Liam Girdwood, Sjoerd Simons, Lee Jones, Bryan Wu, linux-omap,
Sakari Ailus, linux-usb, linux-spi, Dmitry Torokhov,
Tony Lindgren, MyungJoo Ham, linuxppc-dev
An I2C driver that supports both OF and legacy platforms, will have
both a OF and I2C ID table. This means that when built as a module,
the aliases will be filled from both tables but currently always an
alias of the form i2c:<deviceId> is reported, e.g:
$ cat /sys/class/i2c-adapter/i2c-8/8-004b/modalias
i2c:maxtouch
So if a device is probed by matching its compatible string, udev can
get a MODALIAS uevent env var that doesn't match with one of the valid
aliases so the module won't be auto-loaded.
This patch changes the I2C core to report a OF related MODALIAS uevent
(of:N*T*C) env var instead so the module can be auto-loaded and also
report the correct alias using sysfs:
$ cat /sys/class/i2c-adapter/i2c-8/8-004b/modalias
of:NtrackpadT<NULL>Catmel,maxtouch
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
---
drivers/i2c/i2c-core.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 92dddfeb3f39..c0668c2ed9da 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -489,6 +489,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;
@@ -726,6 +730,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_get_modalias(dev, buf, PAGE_SIZE - 1);
+ if (len != -ENODEV)
+ return len;
+
len = acpi_device_modalias(dev, buf, PAGE_SIZE -1);
if (len != -ENODEV)
return len;
--
2.4.3
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH 00/27] Export I2C and OF module aliases in missing drivers
2015-07-30 16:18 [PATCH 00/27] Export I2C and OF module aliases in missing drivers Javier Martinez Canillas
` (3 preceding siblings ...)
2015-07-30 16:18 ` [PATCH 27/27] i2c: (RFC, don't apply) report OF style modalias when probing using DT Javier Martinez Canillas
@ 2015-07-30 16:35 ` Dmitry Torokhov
2015-07-30 16:37 ` Dmitry Torokhov
4 siblings, 1 reply; 8+ messages in thread
From: Dmitry Torokhov @ 2015-07-30 16:35 UTC (permalink / raw)
To: Javier Martinez Canillas
Cc: linux-kernel, alsa-devel, Mark Brown, linux-iio, linux-fbdev,
linux-i2c, linux-leds, Alexandre Belloni, Chanwoo Choi,
Tomi Valkeinen, lm-sensors, Sebastian Reichel, linux-input,
Greg Kroah-Hartman, Jean Delvare, Jonathan Cameron, linux-media,
rtc-linux, linux-pm, Mauro Carvalho Chehab, Guenter Roeck,
Benjamin Herrenschmidt, Wolfram Sang, Takashi Iwai, Liam Girdwood,
Sjoerd Simons, Lee Jones, Bryan Wu, linux-omap, Sakari Ailus,
linux-usb, linux-spi, Tony Lindgren, MyungJoo Ham, linuxppc-dev
Hi Javier,
On Thu, Jul 30, 2015 at 06:18:25PM +0200, Javier Martinez Canillas wrote:
> Hello,
>
> Short version:
>
> This series add the missing MODULE_DEVICE_TABLE() for OF and I2C tables
> to export that information so modules have the correct aliases built-in
> and autoloading works correctly.
>
> Longer version:
>
> Currently it's mandatory for I2C drivers to have an I2C device ID table
> regardless if the device was registered using platform data or OF. This
> is because the I2C core needs an I2C device ID table for two reasons:
>
> 1) Match the I2C client with a I2C device ID so a struct i2c_device_id
> is passed to the I2C driver probe() function.
>
> 2) Export the module aliases from the I2C device ID table so userspace
> can auto-load the correct module. This is because i2c_device_uevent
> always reports a MODALIAS of the form i2c:<client->name>.
Why are we not fixing this? We emit specially carved uevent for
ACPI-based devices, why not the same for OF? Platform bus does this...
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH 00/27] Export I2C and OF module aliases in missing drivers
2015-07-30 16:35 ` [PATCH 00/27] Export I2C and OF module aliases in missing drivers Dmitry Torokhov
@ 2015-07-30 16:37 ` Dmitry Torokhov
2015-07-30 17:13 ` Javier Martinez Canillas
0 siblings, 1 reply; 8+ messages in thread
From: Dmitry Torokhov @ 2015-07-30 16:37 UTC (permalink / raw)
To: Javier Martinez Canillas
Cc: linux-kernel, alsa-devel, Mark Brown, linux-iio, linux-fbdev,
linux-i2c, linux-leds, Alexandre Belloni, Chanwoo Choi,
Tomi Valkeinen, lm-sensors, Sebastian Reichel, linux-input,
Greg Kroah-Hartman, Jean Delvare, Jonathan Cameron, linux-media,
rtc-linux, linux-pm, Mauro Carvalho Chehab, Guenter Roeck,
Benjamin Herrenschmidt, Wolfram Sang, Takashi Iwai, Liam Girdwood,
Sjoerd Simons, Lee Jones, Bryan Wu, linux-omap, Sakari Ailus,
linux-usb, linux-spi, Tony Lindgren, MyungJoo Ham, linuxppc-dev
On Thu, Jul 30, 2015 at 09:35:17AM -0700, Dmitry Torokhov wrote:
> Hi Javier,
>
> On Thu, Jul 30, 2015 at 06:18:25PM +0200, Javier Martinez Canillas wrote:
> > Hello,
> >
> > Short version:
> >
> > This series add the missing MODULE_DEVICE_TABLE() for OF and I2C tables
> > to export that information so modules have the correct aliases built-in
> > and autoloading works correctly.
> >
> > Longer version:
> >
> > Currently it's mandatory for I2C drivers to have an I2C device ID table
> > regardless if the device was registered using platform data or OF. This
> > is because the I2C core needs an I2C device ID table for two reasons:
> >
> > 1) Match the I2C client with a I2C device ID so a struct i2c_device_id
> > is passed to the I2C driver probe() function.
> >
> > 2) Export the module aliases from the I2C device ID table so userspace
> > can auto-load the correct module. This is because i2c_device_uevent
> > always reports a MODALIAS of the form i2c:<client->name>.
>
> Why are we not fixing this? We emit specially carved uevent for
> ACPI-based devices, why not the same for OF? Platform bus does this...
Ah, now I see the 27/27 patch. I think it is exactly what we need. And
probably for SPI bus as well.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 00/27] Export I2C and OF module aliases in missing drivers
2015-07-30 16:37 ` Dmitry Torokhov
@ 2015-07-30 17:13 ` Javier Martinez Canillas
0 siblings, 0 replies; 8+ messages in thread
From: Javier Martinez Canillas @ 2015-07-30 17:13 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: linux-kernel, alsa-devel, Mark Brown, linux-iio, linux-fbdev,
linux-i2c, linux-leds, Alexandre Belloni, Chanwoo Choi,
Tomi Valkeinen, lm-sensors, Sebastian Reichel, linux-input,
Greg Kroah-Hartman, Jean Delvare, Jonathan Cameron, linux-media,
rtc-linux, linux-pm, Mauro Carvalho Chehab, Guenter Roeck,
Benjamin Herrenschmidt, Wolfram Sang, Takashi Iwai, Liam Girdwood,
Sjoerd Simons, Lee Jones, Bryan Wu, linux-omap, Sakari Ailus,
linux-usb, linux-spi, Tony Lindgren, MyungJoo Ham, linuxppc-dev
Hello Dmitry,
Thanks a lot for your feedback.
On 07/30/2015 06:37 PM, Dmitry Torokhov wrote:
> On Thu, Jul 30, 2015 at 09:35:17AM -0700, Dmitry Torokhov wrote:
>> Hi Javier,
>>
>> On Thu, Jul 30, 2015 at 06:18:25PM +0200, Javier Martinez Canillas wrote:
>>> Hello,
>>>
>>> Short version:
>>>
>>> This series add the missing MODULE_DEVICE_TABLE() for OF and I2C tables
>>> to export that information so modules have the correct aliases built-in
>>> and autoloading works correctly.
>>>
>>> Longer version:
>>>
>>> Currently it's mandatory for I2C drivers to have an I2C device ID table
>>> regardless if the device was registered using platform data or OF. This
>>> is because the I2C core needs an I2C device ID table for two reasons:
>>>
>>> 1) Match the I2C client with a I2C device ID so a struct i2c_device_id
>>> is passed to the I2C driver probe() function.
>>>
>>> 2) Export the module aliases from the I2C device ID table so userspace
>>> can auto-load the correct module. This is because i2c_device_uevent
>>> always reports a MODALIAS of the form i2c:<client->name>.
>>
>> Why are we not fixing this? We emit specially carved uevent for
>> ACPI-based devices, why not the same for OF? Platform bus does this...
>
> Ah, now I see the 27/27 patch. I think it is exactly what we need. And
Yes, patch 27/27 is needed but the problem is as I explained before that
there are drivers relying on the current behavior. The item c) in the list
of issues that I mentioned. So those drivers need to be fixed before that
patch is merged...
> probably for SPI bus as well.
>
Yes, I didn't mention SPI because the cover letter became too long
already but it does indeed have the same issue and I discussed this
with Mark already some time ago [0].
Once I2C uevent report is fixed, I plan to do the same for SPI.
> Thanks.
>
[0]: https://lkml.org/lkml/2014/9/11/458
Best regards,
--
Javier Martinez Canillas
Open Source Group
Samsung Research America
^ permalink raw reply [flat|nested] 8+ messages in thread