From: Chanwoo Choi <cw00.choi@samsung.com>
To: Hans de Goede <hdegoede@redhat.com>,
Sebastian Reichel <sre@kernel.org>, Chen-Yu Tsai <wens@csie.org>,
MyungJoo Ham <myungjoo.ham@samsung.com>
Cc: "russianneuromancer @ ya . ru" <russianneuromancer@ya.ru>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 01/14] extcon: Add extcon_get_extcon_dev_by_cable_id function
Date: Mon, 19 Dec 2016 20:57:06 +0900 [thread overview]
Message-ID: <5857CB12.8070105@samsung.com> (raw)
In-Reply-To: <de06e6f7-8e13-0b69-d1dc-12a26d58ebee@redhat.com>
Hi,
On 2016년 12월 19일 20:42, Hans de Goede wrote:
> Hi,
>
> On 19-12-16 11:12, Chanwoo Choi wrote:
>> Hi Hans,
>>
>> On 2016년 12월 19일 09:07, Hans de Goede wrote:
>>> extcon_register_notifier() allows passing in a NULL pointer for the
>>> extcon_device, so that extcon consumers which want extcon events of a
>>> certain type, but do not know the extcon device name (e.g. because
>>> there are different implementation depending on the board), can still
>>> get such events.
>>>
>>> But most drivers will also want to know the initial state of the cable.
>>> Rather then adding NULL edev argument support to extcon_get_state, which
>>> would require looking up the right edev each call, this commit allows
>>> drivers to get the first extcon device with a requested cable-id through
>>> a new extcon_get_extcon_dev_by_cable_id function.
>>>
>>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>>> ---
>>> drivers/extcon/extcon.c | 24 ++++++++++++++++++++++++
>>> include/linux/extcon.h | 1 +
>>> 2 files changed, 25 insertions(+)
>>>
>>> diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
>>> index 7829846..505c272 100644
>>> --- a/drivers/extcon/extcon.c
>>> +++ b/drivers/extcon/extcon.c
>>> @@ -890,6 +890,30 @@ struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name)
>>> EXPORT_SYMBOL_GPL(extcon_get_extcon_dev);
>>>
>>> /**
>>> + * extcon_get_extcon_dev_by_cable_id() - Get an extcon device by a cable id
>>> + * @id: the unique id of each external connector in extcon enumeration.
>>> + */
>>> +struct extcon_dev *extcon_get_extcon_dev_by_cable_id(unsigned int id)
>>> +{
>>> + struct extcon_dev *extd;
>>> + int idx = -EINVAL;
>>> +
>>> + mutex_lock(&extcon_dev_list_lock);
>>> + list_for_each_entry(extd, &extcon_dev_list, entry) {
>>> + idx = find_cable_index_by_id(extd, id);
>>> + if (idx >= 0)
>>> + break;
>>> + }
>>> + mutex_unlock(&extcon_dev_list_lock);
>>> +
>>> + if (idx < 0)
>>> + return NULL;
>>> +
>>> + return extd;
>>> +}
>>> +EXPORT_SYMBOL_GPL(extcon_get_extcon_dev_by_cable_id);
>>
>> This function do not guarantee the same operation on all of case.
>>
>> For example,
>> The h/w board has multiple extcon provider which support the same external connector. When using this function, this function don't get the correct extcon instance. Just, this function returns the first extcon instance in the registered extcon list.
>>
>> This function has the potential problem.
>
> True, I wanted this function because I'm afraid that on some
> boards using the axp288_charger.c driver the USB_HOST extcon
> cable may be provided by a different extcon device then the
> "intel-int3496" device, but as you said in your reply to
>
> "[PATCH 08/14] power: supply: axp288_charger: Actually get and use the USB_HOST extcon device"
>
> If that happens we can add an array of extcon names to try,
> in axp288_charger.c.
>
> So I'll modify this patch to use the existing
> extcon_get_extcon_dev with a name argument of "intel-int3496".
>
> Note that currently extcon_register_notifier accepts a NULL
> edev argument and in that case does pick the first edev with
> a matching cable-id, which has the same problem as you pointed
> out. So perhaps see if anyone actually passes in NULL, and if
> not drop support for a NULL edev argument passed to
> extcon_register_notifier ?
Right. To remove the potential problem,
I'll remove the code in the extcon_register_notfier() function when first parameter is NULL.
--
Regards,
Chanwoo Choi
next prev parent reply other threads:[~2016-12-19 11:57 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-19 0:07 [PATCH 00/14] extcon api extension + axp288_charger fixes Hans de Goede
2016-12-19 0:07 ` [PATCH 01/14] extcon: Add extcon_get_extcon_dev_by_cable_id function Hans de Goede
2016-12-19 10:12 ` Chanwoo Choi
2016-12-19 11:42 ` Hans de Goede
2016-12-19 11:57 ` Chanwoo Choi [this message]
2016-12-19 0:07 ` [PATCH 02/14] extcon: Make extcon_register_notifier use extcon_get_extcon_dev_by_cable_id Hans de Goede
2016-12-19 0:07 ` [PATCH 03/14] power: supply: axp288_charger: Make charger_init_hw_regs propagate i2c errors Hans de Goede
2016-12-19 0:07 ` [PATCH 04/14] power: supply: axp288_charger: Drop platform_data dependency Hans de Goede
2016-12-19 0:07 ` [PATCH 05/14] power: supply: axp288_charger: use devm extcon / supply register Hans de Goede
2016-12-19 8:03 ` Chanwoo Choi
2016-12-19 8:42 ` Hans de Goede
2016-12-19 0:07 ` [PATCH 06/14] power: supply: axp288_charger: Register extcon notifers after power_supply Hans de Goede
2016-12-19 0:07 ` [PATCH 07/14] power: supply: axp288_charger: Move init_hw_regs call before supply registration Hans de Goede
2016-12-19 0:07 ` [PATCH 08/14] power: supply: axp288_charger: Actually get and use the USB_HOST extcon device Hans de Goede
2016-12-19 10:16 ` Chanwoo Choi
2016-12-19 0:07 ` [PATCH 09/14] power: supply: axp288_charger: Handle charger type changing without disconnect Hans de Goede
2016-12-19 0:07 ` [PATCH 10/14] power: supply: axp288_charger: Some minor cleanups Hans de Goede
2016-12-19 0:07 ` [PATCH 11/14] power: supply: axp288_charger: Get and process initial hardware-state Hans de Goede
2016-12-19 0:07 ` [PATCH 12/14] power: supply: axp288_charger: Fix wrong regmap_update_bits Hans de Goede
2016-12-19 0:07 ` [PATCH 13/14] power: supply: axp288_charger: Remove unnecessary irq?_en register writes Hans de Goede
2016-12-19 0:07 ` [PATCH 14/14] power: supply: axp288_charger: Fix the module not auto-loading Hans de Goede
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5857CB12.8070105@samsung.com \
--to=cw00.choi@samsung.com \
--cc=hdegoede@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=myungjoo.ham@samsung.com \
--cc=russianneuromancer@ya.ru \
--cc=sre@kernel.org \
--cc=wens@csie.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.