From: Chunfeng Yun <chunfeng.yun@mediatek.com>
To: Paul Cercueil <paul@crapouillou.net>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>,
Chanwoo Choi <cw00.choi@samsung.com>,
MyungJoo Ham <myungjoo.ham@samsung.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>, <od@zcrc.me>,
USB <linux-usb@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [RESEND PATCH] usb: common: usb-conn-gpio: Register optional charger
Date: Tue, 28 Jul 2020 14:04:43 +0800 [thread overview]
Message-ID: <1595916283.21478.3.camel@mhfsdcap03> (raw)
In-Reply-To: <Z4V4EQ.I8UQ5TF3SBJ61@crapouillou.net>
On Mon, 2020-07-27 at 17:02 +0200, Paul Cercueil wrote:
>
> Le lun. 27 juil. 2020 à 13:42, Chunfeng Yun
> <chunfeng.yun@mediatek.com> a écrit :
> > On Sun, 2020-07-26 at 12:27 +0200, Paul Cercueil wrote:
> >>
> >> Le dim. 26 juil. 2020 à 13:14, Andy Shevchenko
> >> <andy.shevchenko@gmail.com> a écrit :
> >> > On Mon, Jun 22, 2020 at 1:51 AM Paul Cercueil
> >> <paul@crapouillou.net>
> >> > wrote:
> >> >>
> >> >> Register a power supply charger, if the Kconfig option
> >> >> USB_CONN_GPIO_CHARGER is set, whose online state depends on
> >> whether
> >> >> the USB role is set to device or not.
> >> >>
> >> >> This is useful when the USB role is the only way to know if the
> >> >> device
> >> >> is charging from USB. The API is the standard power supply
> >> charger
> >> >> API,
> >> >> you get a /sys/class/power_supply/xxx/online node which tells
> >> you
> >> >> the
> >> >> state of the charger.
> >> >>
> >> >> The sole purpose of this is to give userspace applications a
> >> way to
> >> >> know whether or not the charger is plugged.
[...]
> >> >> + switch (psp) {
> >> >> + case POWER_SUPPLY_PROP_ONLINE:
> >> >> + val->intval = info->last_role ==
> >> USB_ROLE_DEVICE;
> > What will happen if you not change info->last_role here?
> > I prefer it's only changed by usb_conn_isr(), if it's changed by other
> > drivers, for example, through power_supply_get_property(), may skip
> > role
> > switch.
>
> If you read carefully, info->last_role is not modified here :)
Sorry, my bad
>
> -Paul
>
> >
> >> >> + break;
> >> >> + default:
> >> >> + return -EINVAL;
> >> >> + }
> >> >> +
> >> >> + return 0;
> >> >> +}
> >> >> +
> >> >> static int usb_conn_probe(struct platform_device *pdev)
> >> >> {
> >> >> struct device *dev = &pdev->dev;
> >> >> + struct power_supply_desc *desc;
> >> >> struct usb_conn_info *info;
> >> >> + struct power_supply_config cfg = {
> >> >> + .of_node = dev->of_node,
> >> >> + };
> >> >> int ret = 0;
> >> >>
> >> >> info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
> >> >> @@ -203,6 +234,22 @@ static int usb_conn_probe(struct
> >> >> platform_device *pdev)
> >> >> }
> >> >> }
> >> >>
> >> >> + if (IS_ENABLED(CONFIG_USB_CONN_GPIO_CHARGER)) {
> >> >> + desc = &info->desc;
> >> >> + desc->name = "usb-charger";
> >> >> + desc->properties = usb_charger_properties;
> >> >> + desc->num_properties =
> >> >> ARRAY_SIZE(usb_charger_properties);
> >> >> + desc->get_property = usb_charger_get_property;
> >> >> + desc->type = POWER_SUPPLY_TYPE_USB;
> >> >> + cfg.drv_data = info;
> >> >> +
> >> >> + info->charger = devm_power_supply_register(dev,
> >> >> desc, &cfg);
> >> >> + if (IS_ERR(info->charger)) {
> >> >> + dev_err(dev, "Unable to register
> >> >> charger\n");
> >> >> + return PTR_ERR(info->charger);
> >> >> + }
> >> >> + }
> >> >> +
> >> >> platform_set_drvdata(pdev, info);
> >> >>
> >> >> /* Perform initial detection */
> >> >> --
> >> >> 2.27.0
> >> >>
> >> >
> >> >
> >> > --
> >> > With Best Regards,
> >> > Andy Shevchenko
> >>
> >>
> >
>
>
prev parent reply other threads:[~2020-07-28 6:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-21 22:48 [RESEND PATCH] usb: common: usb-conn-gpio: Register optional charger Paul Cercueil
2020-07-21 11:41 ` Greg Kroah-Hartman
2020-07-25 17:51 ` Paul Cercueil
2020-07-26 8:39 ` Greg Kroah-Hartman
2020-07-26 10:07 ` Paul Cercueil
2020-07-26 10:14 ` Andy Shevchenko
2020-07-26 10:27 ` Paul Cercueil
2020-07-27 5:42 ` Chunfeng Yun
2020-07-27 15:02 ` Paul Cercueil
2020-07-28 6:04 ` Chunfeng Yun [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=1595916283.21478.3.camel@mhfsdcap03 \
--to=chunfeng.yun@mediatek.com \
--cc=andy.shevchenko@gmail.com \
--cc=cw00.choi@samsung.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=myungjoo.ham@samsung.com \
--cc=od@zcrc.me \
--cc=paul@crapouillou.net \
/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