lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1595916283.21478.3.camel@mhfsdcap03>
Date:   Tue, 28 Jul 2020 14:04:43 +0800
From:   Chunfeng Yun <chunfeng.yun@...iatek.com>
To:     Paul Cercueil <paul@...pouillou.net>
CC:     Andy Shevchenko <andy.shevchenko@...il.com>,
        Chanwoo Choi <cw00.choi@...sung.com>,
        MyungJoo Ham <myungjoo.ham@...sung.com>,
        "Greg Kroah-Hartman" <gregkh@...uxfoundation.org>, <od@...c.me>,
        USB <linux-usb@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [RESEND PATCH] usb: common: usb-conn-gpio: Register optional
 charger

On Mon, 2020-07-27 at 17:02 +0200, Paul Cercueil wrote:
> 
> Le lun. 27 juil. 2020 à 13:42, Chunfeng Yun 
> <chunfeng.yun@...iatek.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@...il.com> a écrit :
> >>  > On Mon, Jun 22, 2020 at 1:51 AM Paul Cercueil 
> >> <paul@...pouillou.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
> >> 
> >> 
> > 
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ