From: Chance Yang <chance.yang@kneron.us>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Chunfeng Yun <chunfeng.yun@mediatek.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
morgan.chang@kneron.us
Subject: Re: [PATCH] usb: common: usb-conn-gpio: use a unique names for usb connector devices
Date: Fri, 11 Apr 2025 14:45:59 +0800 [thread overview]
Message-ID: <83tt6v2o2g.fsf@kneron.us> (raw)
In-Reply-To: <2025041131-datebook-tumble-a759@gregkh> (Greg Kroah-Hartman's message of "Fri, 11 Apr 2025 07:55:09 +0200")
Greg Kroah-Hartman <gregkh@linuxfoundation.org> writes:
> On Fri, Apr 11, 2025 at 11:27:33AM +0800, Chance Yang wrote:
>> The current implementation uses "usb-charger" as a generic name for
>> usb connector. This prevents us to have two usb connector devices
>> attached as the power system will complain about the name which is
>> already registered.
>>
>> Use an incremental name for each usb connector attached.
>>
>> Fixes: 880287910b189 ("usb: common: usb-conn-gpio: fix NULL pointer dereference of charger")
>> Signed-off-by: Chance Yang <chance.yang@kneron.us>
>> ---
>> This patch addresses an issue in the usb-conn-gpio driver where the
>> generic "usb-charger" name is used for all USB connector devices. This
>> causes conflicts in the power supply subsystem when multiple USB
>> connectors are present, as duplicate names are not allowed.
>>
>> The fix introduces an incremental naming scheme (e.g., usb-charger-0,
>> usb-charger-1) for each USB connector device, ensuring uniqueness and
>> preventing registration errors.
>> ---
>> drivers/usb/common/usb-conn-gpio.c | 8 +++++++-
>> 1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/usb/common/usb-conn-gpio.c b/drivers/usb/common/usb-conn-gpio.c
>> index 1e36be2a28fd5ca5e1495b7923e4d3e25d7cedef..2702e1a26634770500febd567f9d0891e63a8c4c 100644
>> --- a/drivers/usb/common/usb-conn-gpio.c
>> +++ b/drivers/usb/common/usb-conn-gpio.c
>> @@ -155,13 +155,19 @@ static int usb_charger_get_property(struct power_supply *psy,
>>
>> static int usb_conn_psy_register(struct usb_conn_info *info)
>> {
>> + static atomic_t usb_conn_no = ATOMIC_INIT(0);
>
> Please use a proper data structure for this (hint, not an atomic_t, but
> rather a idr, or is it ida?)
>
> thanks,
>
> greg k-h
Thanks for the feedback !
I will use ida to genrate unique name (e.g., usb-charger-0,
usb-charger-1) and send v2 version of this patch.
--
Sincerely,
Chance Yang
prev parent reply other threads:[~2025-04-11 6:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-11 3:27 [PATCH] usb: common: usb-conn-gpio: use a unique names for usb connector devices Chance Yang
2025-04-11 5:55 ` Greg Kroah-Hartman
2025-04-11 6:45 ` Chance Yang [this message]
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=83tt6v2o2g.fsf@kneron.us \
--to=chance.yang@kneron.us \
--cc=chunfeng.yun@mediatek.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=morgan.chang@kneron.us \
/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 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).