* [PATCH 0/3] i2c: Relax requirement for I2C Device ID tables @ 2014-06-02 13:41 Lee Jones 2014-06-02 13:41 ` [PATCH 1/3] i2c: Provide 'device type' to 'OF device node' look-up Lee Jones ` (2 more replies) 0 siblings, 3 replies; 13+ messages in thread From: Lee Jones @ 2014-06-02 13:41 UTC (permalink / raw) To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-kernel-u79uwXL29TY76Z2rM5mHXA, wsa-z923LK4zBo2bacvFa/9K2g Cc: linus.walleij-QSEj5FYQhm4dnm+yROfE0A, grant.likely-QSEj5FYQhm4dnm+yROfE0A, linux-i2c-u79uwXL29TY76Z2rM5mHXA Hi Wolfram, After this patch-set, it should become possible to start stripping out those unnecessary I2C Device ID tables that are currently lurking around, mostly redundantly. Firstly, we create a look-up function whose job it is to match I2C device name to a Device Tree node. Then we add some extra protection in i2c_match_id(), so that we can call the function with a NULL parameter. This in turn aids to the elegance of the final change which relaxes the requirement of a populated .id_table. Kind regards, Lee ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 1/3] i2c: Provide 'device type' to 'OF device node' look-up 2014-06-02 13:41 [PATCH 0/3] i2c: Relax requirement for I2C Device ID tables Lee Jones @ 2014-06-02 13:41 ` Lee Jones [not found] ` <1401716463-23457-2-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2014-06-02 13:41 ` [PATCH 2/3] i2c: Add pointer dereference protection to i2c_match_id() Lee Jones [not found] ` <1401716463-23457-1-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2 siblings, 1 reply; 13+ messages in thread From: Lee Jones @ 2014-06-02 13:41 UTC (permalink / raw) To: linux-arm-kernel, linux-kernel, wsa Cc: linus.walleij, grant.likely, linux-i2c, Lee Jones We have a problem. There are lots of I2C device ID tables scattered around the kernel which are redundant in all Device Tree and/or ACPI only supported device drivers. After recent discussions it has become apparent that the only thing blocking the complete removal of these tables is the continued support of 'register an I2C device via sysfs' functionality. As the sysfs method doesn't know anything about Device Tree or ACPI, we can not pass any nodes in. This patch searches all known Device Tree nodes and attempts to acquire a match from the device name provided via sysfs. It can not fail, but if found assigns the matching of_node to i2c_board_info prior to registering. Signed-off-by: Lee Jones <lee.jones@linaro.org> --- drivers/i2c/i2c-core.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 7c7f4b8..2e47641 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -64,6 +64,7 @@ static DEFINE_IDR(i2c_adapter_idr); static struct device_type i2c_client_type; static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver); +static struct device_node *of_i2c_type_to_node(char *type); static struct static_key i2c_trace_msg = STATIC_KEY_INIT_FALSE; @@ -863,6 +864,8 @@ i2c_sysfs_new_device(struct device *dev, struct device_attribute *attr, return -EINVAL; } + info.of_node = of_i2c_type_to_node(info.type); + client = i2c_new_device(adap, &info); if (!client) return -EINVAL; @@ -1088,8 +1091,36 @@ struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node *node) return i2c_verify_adapter(dev); } EXPORT_SYMBOL(of_find_i2c_adapter_by_node); + +static struct device_node *of_i2c_type_to_node(char *type) +{ + struct device_node *np; + const char *compatible, *name; + int len; + + if (!type) + return NULL; + + for_each_of_allnodes(np) { + compatible = of_get_property(np, "compatible", &len); + if (!compatible) + continue; + + name = strchr(compatible, ','); + if (!name) + name = compatible; + else + name++; + + if (!strncmp(name, type, len - (name - compatible))) + return np; + } + + return NULL; +} #else static void of_i2c_register_devices(struct i2c_adapter *adap) { } +static struct device_node *of_i2c_type_to_node(char *type) { return NULL; } #endif /* CONFIG_OF */ /* ACPI support code */ -- 1.8.3.2 ^ permalink raw reply related [flat|nested] 13+ messages in thread
[parent not found: <1401716463-23457-2-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>]
* Re: [PATCH 1/3] i2c: Provide 'device type' to 'OF device node' look-up [not found] ` <1401716463-23457-2-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> @ 2014-06-02 13:57 ` Lee Jones 2014-06-02 16:06 ` Grant Likely 1 sibling, 0 replies; 13+ messages in thread From: Lee Jones @ 2014-06-02 13:57 UTC (permalink / raw) To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-kernel-u79uwXL29TY76Z2rM5mHXA, wsa-z923LK4zBo2bacvFa/9K2g Cc: linus.walleij-QSEj5FYQhm4dnm+yROfE0A, grant.likely-QSEj5FYQhm4dnm+yROfE0A, linux-i2c-u79uwXL29TY76Z2rM5mHXA > We have a problem. There are lots of I2C device ID tables scattered > around the kernel which are redundant in all Device Tree and/or ACPI > only supported device drivers. After recent discussions it has become > apparent that the only thing blocking the complete removal of these > tables is the continued support of 'register an I2C device via sysfs' > functionality. As the sysfs method doesn't know anything about Device > Tree or ACPI, we can not pass any nodes in. This patch searches all > known Device Tree nodes and attempts to acquire a match from the > device name provided via sysfs. It can not fail, but if found assigns > the matching of_node to i2c_board_info prior to registering. > > Signed-off-by: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> > --- > drivers/i2c/i2c-core.c | 31 +++++++++++++++++++++++++++++++ > 1 file changed, 31 insertions(+) [...] > +static struct device_node *of_i2c_type_to_node(char *type) > +{ > + struct device_node *np; > + const char *compatible, *name; > + int len; > + > + if (!type) > + return NULL; > + > + for_each_of_allnodes(np) { > + compatible = of_get_property(np, "compatible", &len); > + if (!compatible) > + continue; > + > + name = strchr(compatible, ','); > + if (!name) > + name = compatible; > + else > + name++; > + > + if (!strncmp(name, type, len - (name - compatible))) > + return np; > + } > + > + return NULL; > +} Ah, this _might_ not work if there are more than one devices of the same type. I guess I need to check the 'reg' property too. -- Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/3] i2c: Provide 'device type' to 'OF device node' look-up [not found] ` <1401716463-23457-2-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2014-06-02 13:57 ` Lee Jones @ 2014-06-02 16:06 ` Grant Likely [not found] ` <20140602160631.F2F6DC40476-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org> 1 sibling, 1 reply; 13+ messages in thread From: Grant Likely @ 2014-06-02 16:06 UTC (permalink / raw) To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-kernel-u79uwXL29TY76Z2rM5mHXA, wsa-z923LK4zBo2bacvFa/9K2g Cc: linus.walleij-QSEj5FYQhm4dnm+yROfE0A, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Lee Jones On Mon, 2 Jun 2014 14:41:01 +0100, Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> wrote: > We have a problem. There are lots of I2C device ID tables scattered > around the kernel which are redundant in all Device Tree and/or ACPI > only supported device drivers. After recent discussions it has become > apparent that the only thing blocking the complete removal of these > tables is the continued support of 'register an I2C device via sysfs' > functionality. As the sysfs method doesn't know anything about Device > Tree or ACPI, we can not pass any nodes in. This patch searches all > known Device Tree nodes and attempts to acquire a match from the > device name provided via sysfs. It can not fail, but if found assigns > the matching of_node to i2c_board_info prior to registering. Ummm... blech! :-) It shouldn't actually be necessary to have a node when instantiating an i2c_device... in fact, there /shouldn't/ be a node if the device is getting instantiated by had via sysfs. If there was a node, then I would expect a device to have been created at the same time. I think panto's overlays solve the problem where a node actually is required to instantiate the device by actually adding a node and letting the i2c subsystem create the associated device automatically. g. > > Signed-off-by: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> > --- > drivers/i2c/i2c-core.c | 31 +++++++++++++++++++++++++++++++ > 1 file changed, 31 insertions(+) > > diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c > index 7c7f4b8..2e47641 100644 > --- a/drivers/i2c/i2c-core.c > +++ b/drivers/i2c/i2c-core.c > @@ -64,6 +64,7 @@ static DEFINE_IDR(i2c_adapter_idr); > > static struct device_type i2c_client_type; > static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver); > +static struct device_node *of_i2c_type_to_node(char *type); > > static struct static_key i2c_trace_msg = STATIC_KEY_INIT_FALSE; > > @@ -863,6 +864,8 @@ i2c_sysfs_new_device(struct device *dev, struct device_attribute *attr, > return -EINVAL; > } > > + info.of_node = of_i2c_type_to_node(info.type); > + > client = i2c_new_device(adap, &info); > if (!client) > return -EINVAL; > @@ -1088,8 +1091,36 @@ struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node *node) > return i2c_verify_adapter(dev); > } > EXPORT_SYMBOL(of_find_i2c_adapter_by_node); > + > +static struct device_node *of_i2c_type_to_node(char *type) > +{ > + struct device_node *np; > + const char *compatible, *name; > + int len; > + > + if (!type) > + return NULL; > + > + for_each_of_allnodes(np) { > + compatible = of_get_property(np, "compatible", &len); > + if (!compatible) > + continue; > + > + name = strchr(compatible, ','); > + if (!name) > + name = compatible; > + else > + name++; > + > + if (!strncmp(name, type, len - (name - compatible))) > + return np; > + } > + > + return NULL; > +} > #else > static void of_i2c_register_devices(struct i2c_adapter *adap) { } > +static struct device_node *of_i2c_type_to_node(char *type) { return NULL; } > #endif /* CONFIG_OF */ > > /* ACPI support code */ > -- > 1.8.3.2 > ^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <20140602160631.F2F6DC40476-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org>]
* Re: [PATCH 1/3] i2c: Provide 'device type' to 'OF device node' look-up [not found] ` <20140602160631.F2F6DC40476-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org> @ 2014-06-02 16:19 ` Lee Jones 0 siblings, 0 replies; 13+ messages in thread From: Lee Jones @ 2014-06-02 16:19 UTC (permalink / raw) To: Grant Likely Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-kernel-u79uwXL29TY76Z2rM5mHXA, wsa-z923LK4zBo2bacvFa/9K2g, linus.walleij-QSEj5FYQhm4dnm+yROfE0A, linux-i2c-u79uwXL29TY76Z2rM5mHXA > > We have a problem. There are lots of I2C device ID tables scattered > > around the kernel which are redundant in all Device Tree and/or ACPI > > only supported device drivers. After recent discussions it has become > > apparent that the only thing blocking the complete removal of these > > tables is the continued support of 'register an I2C device via sysfs' > > functionality. As the sysfs method doesn't know anything about Device > > Tree or ACPI, we can not pass any nodes in. This patch searches all > > known Device Tree nodes and attempts to acquire a match from the > > device name provided via sysfs. It can not fail, but if found assigns > > the matching of_node to i2c_board_info prior to registering. > > Ummm... blech! :-) > > It shouldn't actually be necessary to have a node when instantiating an > i2c_device... in fact, there /shouldn't/ be a node if the device is > getting instantiated by had via sysfs. If there was a node, then I would > expect a device to have been created at the same time. You're right. I realised that about 10 mins after I sent the patch! > I think panto's overlays solve the problem where a node actually is > required to instantiate the device by actually adding a node and letting > the i2c subsystem create the associated device automatically. This looks like it's exactly what I need. Pulling the code now. > > Signed-off-by: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> > > --- > > drivers/i2c/i2c-core.c | 31 +++++++++++++++++++++++++++++++ > > 1 file changed, 31 insertions(+) > > > > diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c > > index 7c7f4b8..2e47641 100644 > > --- a/drivers/i2c/i2c-core.c > > +++ b/drivers/i2c/i2c-core.c > > @@ -64,6 +64,7 @@ static DEFINE_IDR(i2c_adapter_idr); > > > > static struct device_type i2c_client_type; > > static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver); > > +static struct device_node *of_i2c_type_to_node(char *type); > > > > static struct static_key i2c_trace_msg = STATIC_KEY_INIT_FALSE; > > > > @@ -863,6 +864,8 @@ i2c_sysfs_new_device(struct device *dev, struct device_attribute *attr, > > return -EINVAL; > > } > > > > + info.of_node = of_i2c_type_to_node(info.type); > > + > > client = i2c_new_device(adap, &info); > > if (!client) > > return -EINVAL; > > @@ -1088,8 +1091,36 @@ struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node *node) > > return i2c_verify_adapter(dev); > > } > > EXPORT_SYMBOL(of_find_i2c_adapter_by_node); > > + > > +static struct device_node *of_i2c_type_to_node(char *type) > > +{ > > + struct device_node *np; > > + const char *compatible, *name; > > + int len; > > + > > + if (!type) > > + return NULL; > > + > > + for_each_of_allnodes(np) { > > + compatible = of_get_property(np, "compatible", &len); > > + if (!compatible) > > + continue; > > + > > + name = strchr(compatible, ','); > > + if (!name) > > + name = compatible; > > + else > > + name++; > > + > > + if (!strncmp(name, type, len - (name - compatible))) > > + return np; > > + } > > + > > + return NULL; > > +} > > #else > > static void of_i2c_register_devices(struct i2c_adapter *adap) { } > > +static struct device_node *of_i2c_type_to_node(char *type) { return NULL; } > > #endif /* CONFIG_OF */ > > > > /* ACPI support code */ > -- Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 2/3] i2c: Add pointer dereference protection to i2c_match_id() 2014-06-02 13:41 [PATCH 0/3] i2c: Relax requirement for I2C Device ID tables Lee Jones 2014-06-02 13:41 ` [PATCH 1/3] i2c: Provide 'device type' to 'OF device node' look-up Lee Jones @ 2014-06-02 13:41 ` Lee Jones 2014-06-02 16:07 ` Grant Likely [not found] ` <1401716463-23457-1-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2 siblings, 1 reply; 13+ messages in thread From: Lee Jones @ 2014-06-02 13:41 UTC (permalink / raw) To: linux-arm-kernel, linux-kernel, wsa Cc: linus.walleij, grant.likely, linux-i2c, Lee Jones Here we're providing dereference protection for i2c_match_id(), which saves us having to do it each time it's called. We're also stripping out the (now) needless check in i2c_device_match(). This patch paves the way for other, similar code trimming. Signed-off-by: Lee Jones <lee.jones@linaro.org> --- drivers/i2c/i2c-core.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 2e47641..d0c7180 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -83,6 +83,9 @@ void i2c_transfer_trace_unreg(void) static const struct i2c_device_id *i2c_match_id(const struct i2c_device_id *id, const struct i2c_client *client) { + if (!id) + return NULL; + while (id->name[0]) { if (strcmp(client->name, id->name) == 0) return id; @@ -108,9 +111,10 @@ static int i2c_device_match(struct device *dev, struct device_driver *drv) return 1; driver = to_i2c_driver(drv); - /* match on an id table if there is one */ - if (driver->id_table) - return i2c_match_id(driver->id_table, client) != NULL; + + /* Finally an I2C match */ + if (i2c_match_id(driver->id_table, client)) + return 1; return 0; } -- 1.8.3.2 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 2/3] i2c: Add pointer dereference protection to i2c_match_id() 2014-06-02 13:41 ` [PATCH 2/3] i2c: Add pointer dereference protection to i2c_match_id() Lee Jones @ 2014-06-02 16:07 ` Grant Likely 0 siblings, 0 replies; 13+ messages in thread From: Grant Likely @ 2014-06-02 16:07 UTC (permalink / raw) To: linux-arm-kernel, linux-kernel, wsa; +Cc: linus.walleij, linux-i2c, Lee Jones On Mon, 2 Jun 2014 14:41:02 +0100, Lee Jones <lee.jones@linaro.org> wrote: > Here we're providing dereference protection for i2c_match_id(), which > saves us having to do it each time it's called. We're also stripping > out the (now) needless check in i2c_device_match(). This patch paves > the way for other, similar code trimming. > > Signed-off-by: Lee Jones <lee.jones@linaro.org> Seems reasonable. Acked-by: Grant Likely <grant.likely@linaro.org> > --- > drivers/i2c/i2c-core.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c > index 2e47641..d0c7180 100644 > --- a/drivers/i2c/i2c-core.c > +++ b/drivers/i2c/i2c-core.c > @@ -83,6 +83,9 @@ void i2c_transfer_trace_unreg(void) > static const struct i2c_device_id *i2c_match_id(const struct i2c_device_id *id, > const struct i2c_client *client) > { > + if (!id) > + return NULL; > + > while (id->name[0]) { > if (strcmp(client->name, id->name) == 0) > return id; > @@ -108,9 +111,10 @@ static int i2c_device_match(struct device *dev, struct device_driver *drv) > return 1; > > driver = to_i2c_driver(drv); > - /* match on an id table if there is one */ > - if (driver->id_table) > - return i2c_match_id(driver->id_table, client) != NULL; > + > + /* Finally an I2C match */ > + if (i2c_match_id(driver->id_table, client)) > + return 1; > > return 0; > } > -- > 1.8.3.2 > ^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <1401716463-23457-1-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>]
* [PATCH 3/3] i2c: Make I2C ID tables non-mandatory for DT'ed and/or ACPI'ed devices [not found] ` <1401716463-23457-1-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> @ 2014-06-02 13:41 ` Lee Jones [not found] ` <1401716463-23457-4-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 0 siblings, 1 reply; 13+ messages in thread From: Lee Jones @ 2014-06-02 13:41 UTC (permalink / raw) To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-kernel-u79uwXL29TY76Z2rM5mHXA, wsa-z923LK4zBo2bacvFa/9K2g Cc: linus.walleij-QSEj5FYQhm4dnm+yROfE0A, grant.likely-QSEj5FYQhm4dnm+yROfE0A, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Lee Jones Currently the I2C framework insists on devices supplying an I2C ID table. Many of the devices which do so unnecessarily adding quite a few wasted lines to kernel code. This patch allows drivers a means to 'not' supply the aforementioned table and match on either DT and/or ACPI match tables instead. Signed-off-by: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> --- drivers/i2c/i2c-core.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index d0c7180..811b78f 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -271,7 +271,18 @@ static int i2c_device_probe(struct device *dev) return 0; driver = to_i2c_driver(dev->driver); - if (!driver->probe || !driver->id_table) + if (!driver->probe) + return -EINVAL; + + /* + * An I2C ID table is not madatory, if and only if, a suitable Device + * Tree and/or ACPI match table entry is supplied for the probing + * device. + * + * TODO: Provide 'device type' to 'ACPI node' call and match here. + */ + if (!driver->id_table && + !of_match_device(dev->driver->of_match_table, dev)) return -ENODEV; if (!device_can_wakeup(&client->dev)) -- 1.8.3.2 ^ permalink raw reply related [flat|nested] 13+ messages in thread
[parent not found: <1401716463-23457-4-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>]
* Re: [PATCH 3/3] i2c: Make I2C ID tables non-mandatory for DT'ed and/or ACPI'ed devices [not found] ` <1401716463-23457-4-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> @ 2014-06-02 14:34 ` One Thousand Gnomes [not found] ` <20140602153417.2065c1a5-mUKnrFFms3BCCTY1wZZT65JpZx93mCW/@public.gmane.org> 2014-06-02 16:08 ` Grant Likely 1 sibling, 1 reply; 13+ messages in thread From: One Thousand Gnomes @ 2014-06-02 14:34 UTC (permalink / raw) To: Lee Jones Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-kernel-u79uwXL29TY76Z2rM5mHXA, wsa-z923LK4zBo2bacvFa/9K2g, linus.walleij-QSEj5FYQhm4dnm+yROfE0A, grant.likely-QSEj5FYQhm4dnm+yROfE0A, linux-i2c-u79uwXL29TY76Z2rM5mHXA On Mon, 2 Jun 2014 14:41:03 +0100 Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> wrote: > Currently the I2C framework insists on devices supplying an I2C ID > table. Many of the devices which do so unnecessarily adding quite a > few wasted lines to kernel code. This patch allows drivers a means > to 'not' supply the aforementioned table and match on either DT > and/or ACPI match tables instead. > > Signed-off-by: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> > --- > drivers/i2c/i2c-core.c | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > > diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c > index d0c7180..811b78f 100644 > --- a/drivers/i2c/i2c-core.c > +++ b/drivers/i2c/i2c-core.c > @@ -271,7 +271,18 @@ static int i2c_device_probe(struct device *dev) > return 0; > > driver = to_i2c_driver(dev->driver); > - if (!driver->probe || !driver->id_table) > + if (!driver->probe) > + return -EINVAL; > + > + /* > + * An I2C ID table is not madatory, if and only if, a suitable Device typo "madatory".. > + * Tree and/or ACPI match table entry is supplied for the probing > + * device. > + * > + * TODO: Provide 'device type' to 'ACPI node' call and match here. > + */ > + if (!driver->id_table && > + !of_match_device(dev->driver->of_match_table, dev)) > return -ENODEV; > Looks sensible to me other than that. > if (!device_can_wakeup(&client->dev)) ^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <20140602153417.2065c1a5-mUKnrFFms3BCCTY1wZZT65JpZx93mCW/@public.gmane.org>]
* Re: [PATCH 3/3] i2c: Make I2C ID tables non-mandatory for DT'ed and/or ACPI'ed devices [not found] ` <20140602153417.2065c1a5-mUKnrFFms3BCCTY1wZZT65JpZx93mCW/@public.gmane.org> @ 2014-06-03 8:11 ` Lee Jones 0 siblings, 0 replies; 13+ messages in thread From: Lee Jones @ 2014-06-03 8:11 UTC (permalink / raw) To: One Thousand Gnomes Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-kernel-u79uwXL29TY76Z2rM5mHXA, wsa-z923LK4zBo2bacvFa/9K2g, linus.walleij-QSEj5FYQhm4dnm+yROfE0A, grant.likely-QSEj5FYQhm4dnm+yROfE0A, linux-i2c-u79uwXL29TY76Z2rM5mHXA On Mon, 02 Jun 2014, One Thousand Gnomes wrote: > On Mon, 2 Jun 2014 14:41:03 +0100 > Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> wrote: > > > Currently the I2C framework insists on devices supplying an I2C ID > > table. Many of the devices which do so unnecessarily adding quite a > > few wasted lines to kernel code. This patch allows drivers a means > > to 'not' supply the aforementioned table and match on either DT > > and/or ACPI match tables instead. > > > > Signed-off-by: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> > > --- > > drivers/i2c/i2c-core.c | 13 ++++++++++++- > > 1 file changed, 12 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c > > index d0c7180..811b78f 100644 > > --- a/drivers/i2c/i2c-core.c > > +++ b/drivers/i2c/i2c-core.c > > @@ -271,7 +271,18 @@ static int i2c_device_probe(struct device *dev) > > return 0; > > > > driver = to_i2c_driver(dev->driver); > > - if (!driver->probe || !driver->id_table) > > + if (!driver->probe) > > + return -EINVAL; > > + > > + /* > > + * An I2C ID table is not madatory, if and only if, a suitable Device > > typo "madatory".. > > > + * Tree and/or ACPI match table entry is supplied for the probing > > + * device. > > + * > > + * TODO: Provide 'device type' to 'ACPI node' call and match here. > > + */ > > + if (!driver->id_table && > > + !of_match_device(dev->driver->of_match_table, dev)) > > return -ENODEV; > > > > Looks sensible to me other than that. Can I add your Ack once the typo is fixed? > > if (!device_can_wakeup(&client->dev)) -- Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 3/3] i2c: Make I2C ID tables non-mandatory for DT'ed and/or ACPI'ed devices [not found] ` <1401716463-23457-4-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2014-06-02 14:34 ` One Thousand Gnomes @ 2014-06-02 16:08 ` Grant Likely [not found] ` <20140602160829.F3519C40476-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org> 1 sibling, 1 reply; 13+ messages in thread From: Grant Likely @ 2014-06-02 16:08 UTC (permalink / raw) To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-kernel-u79uwXL29TY76Z2rM5mHXA, wsa-z923LK4zBo2bacvFa/9K2g Cc: linus.walleij-QSEj5FYQhm4dnm+yROfE0A, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Lee Jones On Mon, 2 Jun 2014 14:41:03 +0100, Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> wrote: > Currently the I2C framework insists on devices supplying an I2C ID > table. Many of the devices which do so unnecessarily adding quite a > few wasted lines to kernel code. This patch allows drivers a means > to 'not' supply the aforementioned table and match on either DT > and/or ACPI match tables instead. > > Signed-off-by: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> Looks reasonable. g. > --- > drivers/i2c/i2c-core.c | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > > diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c > index d0c7180..811b78f 100644 > --- a/drivers/i2c/i2c-core.c > +++ b/drivers/i2c/i2c-core.c > @@ -271,7 +271,18 @@ static int i2c_device_probe(struct device *dev) > return 0; > > driver = to_i2c_driver(dev->driver); > - if (!driver->probe || !driver->id_table) > + if (!driver->probe) > + return -EINVAL; > + > + /* > + * An I2C ID table is not madatory, if and only if, a suitable Device > + * Tree and/or ACPI match table entry is supplied for the probing > + * device. > + * > + * TODO: Provide 'device type' to 'ACPI node' call and match here. > + */ > + if (!driver->id_table && > + !of_match_device(dev->driver->of_match_table, dev)) > return -ENODEV; > > if (!device_can_wakeup(&client->dev)) > -- > 1.8.3.2 > ^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <20140602160829.F3519C40476-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org>]
* Re: [PATCH 3/3] i2c: Make I2C ID tables non-mandatory for DT'ed and/or ACPI'ed devices [not found] ` <20140602160829.F3519C40476-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org> @ 2014-06-03 8:11 ` Lee Jones 2014-06-03 9:18 ` Grant Likely 0 siblings, 1 reply; 13+ messages in thread From: Lee Jones @ 2014-06-03 8:11 UTC (permalink / raw) To: Grant Likely Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-kernel-u79uwXL29TY76Z2rM5mHXA, wsa-z923LK4zBo2bacvFa/9K2g, linus.walleij-QSEj5FYQhm4dnm+yROfE0A, linux-i2c-u79uwXL29TY76Z2rM5mHXA On Mon, 02 Jun 2014, Grant Likely wrote: > On Mon, 2 Jun 2014 14:41:03 +0100, Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> wrote: > > Currently the I2C framework insists on devices supplying an I2C ID > > table. Many of the devices which do so unnecessarily adding quite a > > few wasted lines to kernel code. This patch allows drivers a means > > to 'not' supply the aforementioned table and match on either DT > > and/or ACPI match tables instead. > > > > Signed-off-by: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> > > Looks reasonable. Can I add your Ack? > g. > > > --- > > drivers/i2c/i2c-core.c | 13 ++++++++++++- > > 1 file changed, 12 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c > > index d0c7180..811b78f 100644 > > --- a/drivers/i2c/i2c-core.c > > +++ b/drivers/i2c/i2c-core.c > > @@ -271,7 +271,18 @@ static int i2c_device_probe(struct device *dev) > > return 0; > > > > driver = to_i2c_driver(dev->driver); > > - if (!driver->probe || !driver->id_table) > > + if (!driver->probe) > > + return -EINVAL; > > + > > + /* > > + * An I2C ID table is not madatory, if and only if, a suitable Device > > + * Tree and/or ACPI match table entry is supplied for the probing > > + * device. > > + * > > + * TODO: Provide 'device type' to 'ACPI node' call and match here. > > + */ > > + if (!driver->id_table && > > + !of_match_device(dev->driver->of_match_table, dev)) > > return -ENODEV; > > > > if (!device_can_wakeup(&client->dev)) > -- Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 3/3] i2c: Make I2C ID tables non-mandatory for DT'ed and/or ACPI'ed devices 2014-06-03 8:11 ` Lee Jones @ 2014-06-03 9:18 ` Grant Likely 0 siblings, 0 replies; 13+ messages in thread From: Grant Likely @ 2014-06-03 9:18 UTC (permalink / raw) To: Lee Jones Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-kernel-u79uwXL29TY76Z2rM5mHXA, wsa-z923LK4zBo2bacvFa/9K2g, linus.walleij-QSEj5FYQhm4dnm+yROfE0A, linux-i2c-u79uwXL29TY76Z2rM5mHXA On Tue, 3 Jun 2014 09:11:09 +0100, Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> wrote: > On Mon, 02 Jun 2014, Grant Likely wrote: > > On Mon, 2 Jun 2014 14:41:03 +0100, Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> wrote: > > > Currently the I2C framework insists on devices supplying an I2C ID > > > table. Many of the devices which do so unnecessarily adding quite a > > > few wasted lines to kernel code. This patch allows drivers a means > > > to 'not' supply the aforementioned table and match on either DT > > > and/or ACPI match tables instead. > > > > > > Signed-off-by: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> > > > > Looks reasonable. > > Can I add your Ack? Acked-by: Grant Likely <grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> > > > g. > > > > > --- > > > drivers/i2c/i2c-core.c | 13 ++++++++++++- > > > 1 file changed, 12 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c > > > index d0c7180..811b78f 100644 > > > --- a/drivers/i2c/i2c-core.c > > > +++ b/drivers/i2c/i2c-core.c > > > @@ -271,7 +271,18 @@ static int i2c_device_probe(struct device *dev) > > > return 0; > > > > > > driver = to_i2c_driver(dev->driver); > > > - if (!driver->probe || !driver->id_table) > > > + if (!driver->probe) > > > + return -EINVAL; > > > + > > > + /* > > > + * An I2C ID table is not madatory, if and only if, a suitable Device > > > + * Tree and/or ACPI match table entry is supplied for the probing > > > + * device. > > > + * > > > + * TODO: Provide 'device type' to 'ACPI node' call and match here. > > > + */ > > > + if (!driver->id_table && > > > + !of_match_device(dev->driver->of_match_table, dev)) > > > return -ENODEV; > > > > > > if (!device_can_wakeup(&client->dev)) > > > > -- > Lee Jones > Linaro STMicroelectronics Landing Team Lead > Linaro.org â Open source software for ARM SoCs > Follow Linaro: Facebook | Twitter | Blog ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2014-06-03 9:18 UTC | newest] Thread overview: 13+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-06-02 13:41 [PATCH 0/3] i2c: Relax requirement for I2C Device ID tables Lee Jones 2014-06-02 13:41 ` [PATCH 1/3] i2c: Provide 'device type' to 'OF device node' look-up Lee Jones [not found] ` <1401716463-23457-2-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2014-06-02 13:57 ` Lee Jones 2014-06-02 16:06 ` Grant Likely [not found] ` <20140602160631.F2F6DC40476-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org> 2014-06-02 16:19 ` Lee Jones 2014-06-02 13:41 ` [PATCH 2/3] i2c: Add pointer dereference protection to i2c_match_id() Lee Jones 2014-06-02 16:07 ` Grant Likely [not found] ` <1401716463-23457-1-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2014-06-02 13:41 ` [PATCH 3/3] i2c: Make I2C ID tables non-mandatory for DT'ed and/or ACPI'ed devices Lee Jones [not found] ` <1401716463-23457-4-git-send-email-lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2014-06-02 14:34 ` One Thousand Gnomes [not found] ` <20140602153417.2065c1a5-mUKnrFFms3BCCTY1wZZT65JpZx93mCW/@public.gmane.org> 2014-06-03 8:11 ` Lee Jones 2014-06-02 16:08 ` Grant Likely [not found] ` <20140602160829.F3519C40476-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org> 2014-06-03 8:11 ` Lee Jones 2014-06-03 9:18 ` Grant Likely
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).