Re: [PATCH v2 05/13] extcon: extcon-class: improve extcon client API
On 04/22/2014 05:03 PM, Aaro Koskinen wrote: Hi, On Tue, Apr 22, 2014 at 08:21:35AM +0200, Robert Baldyga wrote: On 04/19/2014 12:52 PM, Aaro Koskinen wrote: On Mon, Apr 14, 2014 at 01:46:16PM +0200, Robert Baldyga wrote: dev_info(pdev-dev, - OMAP USB OTG controller rev %d.%d (%s, id=%d, vbus=%d)\n, - (rev 4) 0xf, rev 0xf, config-extcon, otg_dev-id, + OMAP USB OTG controller rev %d.%d (id=%d, vbus=%d)\n, + (rev 4) 0xf, rev 0xf, otg_dev-id, otg_dev-vbus); This change is unrelated to the patch and not needed. It's related because we no longer use config-extcon since we have cable-oriented API. We can keep displaying it, but this value is actually meaningless. It's not completely meaningless, as the cable is searched using that name. Yes, I see, you're right. I have forgot that this driver doesn't use devicetree. I will restore displaying extcon name. Thanks! Robert Baldyga Samsung RD Institute Poland -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 05/13] extcon: extcon-class: improve extcon client API
On 04/19/2014 12:52 PM, Aaro Koskinen wrote: Hi, On Mon, Apr 14, 2014 at 01:46:16PM +0200, Robert Baldyga wrote: dev_info(pdev-dev, - OMAP USB OTG controller rev %d.%d (%s, id=%d, vbus=%d)\n, - (rev 4) 0xf, rev 0xf, config-extcon, otg_dev-id, + OMAP USB OTG controller rev %d.%d (id=%d, vbus=%d)\n, + (rev 4) 0xf, rev 0xf, otg_dev-id, otg_dev-vbus); This change is unrelated to the patch and not needed. It's related because we no longer use config-extcon since we have cable-oriented API. We can keep displaying it, but this value is actually meaningless. Best regards Robert Baldyga Samsung RD Institute Poland -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 05/13] extcon: extcon-class: improve extcon client API
On Tue, Apr 22, 2014 at 08:21:35AM +0200, Robert Baldyga wrote: On 04/19/2014 12:52 PM, Aaro Koskinen wrote: Hi, On Mon, Apr 14, 2014 at 01:46:16PM +0200, Robert Baldyga wrote: dev_info(pdev-dev, - OMAP USB OTG controller rev %d.%d (%s, id=%d, vbus=%d)\n, - (rev 4) 0xf, rev 0xf, config-extcon, otg_dev-id, + OMAP USB OTG controller rev %d.%d (id=%d, vbus=%d)\n, + (rev 4) 0xf, rev 0xf, otg_dev-id, otg_dev-vbus); This change is unrelated to the patch and not needed. It's related because we no longer use config-extcon since we have cable-oriented API. We can keep displaying it, but this value is actually meaningless. can you just add some note in the commit log ? while at that, also remove config-extconf from debugging print because it won't contain valid data anymore or something like that. Other than that: Acked-by: Felipe Balbi ba...@ti.com -- balbi signature.asc Description: Digital signature
Re: [PATCH v2 05/13] extcon: extcon-class: improve extcon client API
Hi, On Tue, Apr 22, 2014 at 08:21:35AM +0200, Robert Baldyga wrote: On 04/19/2014 12:52 PM, Aaro Koskinen wrote: On Mon, Apr 14, 2014 at 01:46:16PM +0200, Robert Baldyga wrote: dev_info(pdev-dev, - OMAP USB OTG controller rev %d.%d (%s, id=%d, vbus=%d)\n, - (rev 4) 0xf, rev 0xf, config-extcon, otg_dev-id, + OMAP USB OTG controller rev %d.%d (id=%d, vbus=%d)\n, + (rev 4) 0xf, rev 0xf, otg_dev-id, otg_dev-vbus); This change is unrelated to the patch and not needed. It's related because we no longer use config-extcon since we have cable-oriented API. We can keep displaying it, but this value is actually meaningless. It's not completely meaningless, as the cable is searched using that name. A. -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 05/13] extcon: extcon-class: improve extcon client API
Hi, On Mon, Apr 14, 2014 at 01:46:16PM +0200, Robert Baldyga wrote: dev_info(pdev-dev, - OMAP USB OTG controller rev %d.%d (%s, id=%d, vbus=%d)\n, - (rev 4) 0xf, rev 0xf, config-extcon, otg_dev-id, + OMAP USB OTG controller rev %d.%d (id=%d, vbus=%d)\n, + (rev 4) 0xf, rev 0xf, otg_dev-id, otg_dev-vbus); This change is unrelated to the patch and not needed. A. -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 05/13] extcon: extcon-class: improve extcon client API
This patch improves extcon client API to get rid of ugly functions operating on name strings. It gives independency from naming convention in extcon provider drivers. Names given at provider registration are now used only for sysfs, debugs, and to support platforms using legacy devicetree bindings. From now individual cables are specified in devicetree, so client API has changed from extcon_dev oriented to extcon_cable oriented. Added also some minor modifications to simplify interest registration. The extcon_specific_cable_nb structure has been changed to extcon_cable_nb. Now this is the only struct which has to be supplied by client. Pointer to user_nb has been changed to extcon_notifier_fn_t to simplify interest registation process. Each single cable is represented by struct extcon_cable. Pointer to extcon_cable is returned from functions: of_extcon_get_cable_by_index() - Return cable of given index. of_extcon_get_cable() - Return cable by name defined in devicetree. extcon_get_cable() - Similar to of_extcon_get_cable_by_name(), but it takes struct device instead of struct device_node. extcon_get_cable_by_name() - return specified cable form extcon device found by name. It's for use in drivers without devicetree support, and shouldn't be used in new drivers. Function extcon_register_interest() has been changed. Registration is now not based on cable name string, but on pointer to struct extcon_cable. Also extcon_get_cable_state() function has been changed. Now it takes pointer to struct extcon_cable. This patch modifies all client drivers to make it using new extcon API. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/extcon/extcon-class.c | 246 +++-- drivers/power/charger-manager.c | 36 +++-- drivers/usb/dwc3/dwc3-omap.c | 68 - drivers/usb/phy/phy-omap-otg.c| 70 +- include/linux/extcon.h| 104 -- include/linux/power/charger-manager.h |6 +- 6 files changed, 331 insertions(+), 199 deletions(-) diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c index b0d9c90..cd830b0 100644 --- a/drivers/extcon/extcon-class.c +++ b/drivers/extcon/extcon-class.c @@ -324,15 +324,14 @@ EXPORT_SYMBOL_GPL(extcon_get_cable_state_); /** * extcon_get_cable_state() - Get the status of a specific cable. - * @edev: the extcon device that has the cable. - * @cable_name:cable name. - * - * Note that this is slower than extcon_get_cable_state_. + * @cable: the cable. */ -int extcon_get_cable_state(struct extcon_dev *edev, const char *cable_name) +int extcon_get_cable_state(struct extcon_cable *cable) { - return extcon_get_cable_state_(edev, extcon_find_cable_index - (edev, cable_name)); + if (!cable) + return -ENODEV; + + return !!(cable-edev-state (1 cable-cable_index)); } EXPORT_SYMBOL_GPL(extcon_get_cable_state); @@ -358,28 +357,27 @@ int extcon_set_cable_state_(struct extcon_dev *edev, EXPORT_SYMBOL_GPL(extcon_set_cable_state_); /** - * extcon_get_extcon_dev() - Get the extcon device instance from the name + * extcon_get_extcon_dev_by_name() - Get the extcon device instance from the name * @extcon_name: The extcon name provided with extcon_dev_register() */ -struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name) +struct extcon_dev *extcon_get_extcon_dev_by_name(const char *extcon_name) { - struct extcon_dev *sd; + struct extcon_dev *edev; mutex_lock(extcon_dev_list_lock); - list_for_each_entry(sd, extcon_dev_list, entry) { - if (!strcmp(sd-name, extcon_name)) + list_for_each_entry(edev, extcon_dev_list, entry) { + if (!strcmp(edev-name, extcon_name)) goto out; } - sd = NULL; + edev = NULL; out: mutex_unlock(extcon_dev_list_lock); - return sd; + return edev; } -EXPORT_SYMBOL_GPL(extcon_get_extcon_dev); /** * of_extcon_get_extcon_dev() - Get the extcon device instance from the name - * @np: The node of extcon device + * @np:The node of extcon device */ struct extcon_dev *of_extcon_get_extcon_dev(const struct device_node *np) { @@ -396,24 +394,158 @@ out: return edev; } +/** + * of_extcon_get_cable() - Get specified extcon cable instance from devicetree + * @np:The node of extcon device + */ +struct extcon_cable *of_extcon_get_cable_by_index(struct device_node *np, int index) +{ + struct of_phandle_args extcon_spec; + struct extcon_dev *edev; + struct extcon_cable *cable; + int ret; + + if (index 0) + return ERR_PTR(-EINVAL); + + ret = of_parse_phandle_with_args(np, extcon-cables, #extcon-cells, + index, extcon_spec); + if (ret) + return