fix module autoloading for ACPI enumerated devices
Subsystems (4)
PATCH 3/4 fix module autoloading for ACPI enumerated devices
ACPI enumerated devices has ACPI style _HID and _CID strings, all of these strings can be used for both driver loading and matching.
But currently, in Platform, I2C and SPI bus, only the ACPI style driver matching is supported by invoking acpi_driver_match_device() in bus .match() callback.
This patch fixes module autoloading on those buses for ACPI enumerated devices.
--- drivers/base/platform.c | 12 +++++++++++- drivers/i2c/i2c-core.c | 11 +++++++++++ drivers/spi/spi.c | 10 ++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-)
drivers/base/platform.c +11 -1
@@ -677,7 +677,13 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *a, char *buf) {struct platform_device *pdev =to_platform_device (dev); -int len =snprintf (buf,PAGE_SIZE ,"platform:%s\n" , pdev->name); +int len; + + len =acpi_device_modalias (dev, buf,PAGE_SIZE -1 ); +if (len != -ENODEV ) +return len; + + len =snprintf (buf,PAGE_SIZE ,"platform:%s\n" , pdev->name);return (len >=PAGE_SIZE ) ? (PAGE_SIZE -1 ) : len; }
@@ -699,6 +705,10 @@ static int platform_uevent(struct device *dev, struct kobj_uevent_env *env)if (rc != -ENODEV )return rc; + rc =acpi_device_uevent_modalias (dev, env); +if (rc != -ENODEV ) +return rc; +add_uevent_var (env,"MODALIAS=%s%s" ,PLATFORM_MODULE_PREFIX , pdev->name);return 0 ;
drivers/i2c/i2c-core.c +11 -0
@@ -104,6 +104,11 @@ static int i2c_device_match(struct device *dev, struct device_driver *drv)static int i2c_device_uevent (struct device *dev,struct kobj_uevent_env *env) {struct i2c_client *client =to_i2c_client (dev); +int rc; + + rc =acpi_device_uevent_modalias (dev, env); +if (rc != -ENODEV ) +return rc;if (add_uevent_var (env,"MODALIAS=%s%s" ,I2C_MODULE_PREFIX , client->name))
@@ -409,6 +414,12 @@ static ssize_t show_modalias(struct device *dev, struct device_attribute *attr, char *buf) { struct i2c_client *client = to_i2c_client(dev); +int len; + + len =acpi_device_modalias (dev, buf,PAGE_SIZE -1 ); +if (len != -ENODEV ) +return len; +return sprintf (buf,"%s%s\n" ,I2C_MODULE_PREFIX , client->name); }
drivers/spi/spi.c +10 -0
@@ -58,6 +58,11 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *a, char *buf) { const struct spi_device *spi = to_spi_device(dev); +int len; + + len =acpi_device_modalias (dev, buf,PAGE_SIZE ); +if (len != -ENODEV ) +return len;return sprintf (buf,"%s%s\n" ,SPI_MODULE_PREFIX , spi->modalias); }
@@ -114,6 +119,11 @@ static int spi_match_device(struct device *dev, struct device_driver *drv)static int spi_uevent (struct device *dev,struct kobj_uevent_env *env) {const struct spi_device *spi =to_spi_device (dev); +int rc; + + rc =acpi_device_uevent_modalias (dev, env); +if (rc != -ENODEV ) +return rc;add_uevent_var (env,"MODALIAS=%s%s" ,SPI_MODULE_PREFIX , spi->modalias);return 0 ;
Signature · 6 lines
1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Mark Brown
maintainerQuoted 6 lines · Zhang Rui
ACPI enumerated devices has ACPI style
_HIDand_CIDstrings, all of these strings can be used for both driver loading and matching.But currently, in Platform, I2C and SPI bus, only the ACPI style driver matching is supported by invoking
acpi_driver_match_device()in bus .match() callback.
I don't understand what this means, sorry. As far as I can tell "ACPI style _HID and _CID strings" are something different to "ACPI style driver matching" but what that actually means is not at all clear to me so I don't know what problem this is intended to fix.
Please also always remember to CC maintainers on patches.
Quoted 6 lines
drivers/spi/spi.c +0
-0@@ -58,6 +58,11 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *a, char *buf)
drivers/spi/spi.c static ssize_t · line 68
Quoted 10 lines
drivers/spi/spi.c +5
-0{const struct spi_device *spi =to_spi_device (dev); +int len; + + len =acpi_device_modalias (dev, buf,PAGE_SIZE ); +if (len != -ENODEV ) +return len;return sprintf (buf,"%s%s\n" ,SPI_MODULE_PREFIX , spi->modalias); }
What does this do and why can't acpi_driver_match_device() handle this like it does for other ACPI devices? We don't need to add such code for other firmware interfaces...
Quoted 9 lines · Mark Brown
Quoted 6 lines · Zhang Rui
ACPI enumerated devices has ACPI style
_HIDand_CIDstrings, all of these strings can be used for both driver loading and matching.But currently, in Platform, I2C and SPI bus, only the ACPI style driver matching is supported by invoking
acpi_driver_match_device()in bus .match() callback.I don't understand what this means, sorry.
sorry, I should be clearer about this.
Quoted 5 lines
As far as I can tell "ACPI
style_HIDand_CIDstrings" are something different to "ACPI style driver matching" but what that actually means is not at all clear to me so I don't know what problem this is intended to fix.
I gave a more detailed description about the problem in the changelog of patch 2/4.
Take the following piece of code for example,
static const struct acpi_device_id xxx_acpi_match[] = {
{ "INTABCD", 0 },
{ }
};MODULE_DEVICE_TABLE(acpi, xxx_acpi_match);
this can be seen in a platform/I2C/SPI driver that supports an ACPI enumerated device, right?
If this piece of code is used in a platform driver for
an ACPI enumerated platform device, the platform DRIVER module_alias is "acpi:INTABCD", but the uevent attribute of its platform device node is "platform:INTABCD:00" (PREFIX:platform_device->name).
If this piece of code is used in an I2C driver for an ACPI enumerated i2c device, the i2c driver module_alias is "acpi:INTABCD", but the uevent of its i2c device node is
"i2c:INTABCD:00" (PREFIX:i2c_client->name).
If this piece of code is used in an *SPI* driver for an ACPI enumerated spi device, the spi driver module_alias is "acpi:INTABCD", but the uevent of its spi device node is
"spi:INTABCD" (PREFIX:spi_device->modalias).
thus when the device node is created, the driver will not be loaded automatically because their modalias do not match.
Quoted 2 lines
Please also always remember to CC maintainers on patches.
okay, will resend the patches later.
thanks,
rui
Quoted 20 lines
Quoted 6 lines
drivers/spi/spi.c +0
-0@@ -58,6 +58,11 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *a, char *buf)drivers/spi/spi.c static ssize_t · line 68
Quoted 10 lines
drivers/spi/spi.c +5
-0{const struct spi_device *spi =to_spi_device (dev); +int len; + + len =acpi_device_modalias (dev, buf,PAGE_SIZE ); +if (len != -ENODEV ) +return len;return sprintf (buf,"%s%s\n" ,SPI_MODULE_PREFIX , spi->modalias); }What does this do and why can't
acpi_driver_match_device()handle this like it does for other ACPI devices? We don't need to add such code for other firmware interfaces...
Mark Brown
maintainerQuoted 9 lines · Zhang Rui
Quoted 3 lines · Mark Brown
Quoted 2 lines · Zhang Rui
ACPI enumerated devices has ACPI style
_HIDand_CIDstrings, all of these strings can be used for both driver loading and matching.If this piece of code is used in an *SPI* driver for an ACPI enumerated spi device, the spi driver
module_aliasis "acpi:INTABCD", but the uevent of its spi device node is
"spi:INTABCD" (PREFIX:spi_device->modalias).
OK that makes sense, but what does this have to do with the _HID and _CID methods? Surely we're just replacing spi: with acpi: in the uevent?
Quoted 6 lines · Mark Brown
Quoted 4 lines · Zhang Rui
Quoted 3 lines · Mark Brown
Quoted 2 lines · Zhang Rui
ACPI enumerated devices has ACPI style
_HIDand_CIDstrings, all of these strings can be used for both driver loading and matching.
Quoted 7 lines
Quoted 4 lines
If this piece of code is used in an *SPI* driver for an ACPI enumerated spi device, the spi driver
module_aliasis "acpi:INTABCD", but the uevent of its spi device node is
"spi:INTABCD" (PREFIX:spi_device->modalias).OK that makes sense, but what does this have to do with the
_HIDand_CIDmethods?
If an ACPI enumerated SPI device has a _HID and a _CID, both of them need to be exposed in 'uevent', so that a driver that matches _CID can also have a chance to be probed. This can not be done by the current code, thus we need special handling of ACPI enumerated SPI devices.
Quoted 1 line
Surely we're just replacing spi: with acpi: in the uevent?
yes.
thanks,
rui