linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: composite: Inform controller driver of self-powered
@ 2020-02-01  2:50 Thinh Nguyen
  2020-02-01  3:17 ` Thinh Nguyen
  2020-02-01 10:36 ` Felipe Balbi
  0 siblings, 2 replies; 3+ messages in thread
From: Thinh Nguyen @ 2020-02-01  2:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Felipe Balbi, Sebastian Andrzej Siewior
  Cc: Thinh Nguyen, linux-usb

Different configuration may draw different power. Inform the controller
driver of the change so it can respond properly (e.g. GET_STATUS
request). This fixes an issue with setting MaxPower from configfs. The
composite driver doesn't check this value when setting self-powered.

Fixes: 88af8bbe4ef7 ("usb: gadget: the start of the configfs interface")
Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
---
 drivers/usb/gadget/composite.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 223f72d4d9ed..2fbeb2c19665 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -861,6 +861,11 @@ static int set_config(struct usb_composite_dev *cdev,
 	else
 		power = min(power, 900U);
 done:
+	if (power <= USB_SELF_POWER_VBUS_MAX_DRAW)
+		usb_gadget_set_selfpowered(gadget);
+	else
+		usb_gadget_clear_selfpowered(gadget);
+
 	usb_gadget_vbus_draw(gadget, power);
 	if (result >= 0 && cdev->delayed_status)
 		result = USB_GADGET_DELAYED_STATUS;
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: gadget: composite: Inform controller driver of self-powered
  2020-02-01  2:50 [PATCH] usb: gadget: composite: Inform controller driver of self-powered Thinh Nguyen
@ 2020-02-01  3:17 ` Thinh Nguyen
  2020-02-01 10:36 ` Felipe Balbi
  1 sibling, 0 replies; 3+ messages in thread
From: Thinh Nguyen @ 2020-02-01  3:17 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Felipe Balbi, Sebastian Andrzej Siewior
  Cc: linux-usb@vger.kernel.org

++ Felipe (correct email address)

Thinh Nguyen wrote:
> Different configuration may draw different power. Inform the controller
> driver of the change so it can respond properly (e.g. GET_STATUS
> request). This fixes an issue with setting MaxPower from configfs. The
> composite driver doesn't check this value when setting self-powered.
>
> Fixes: 88af8bbe4ef7 ("usb: gadget: the start of the configfs interface")
> Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
> ---
>   drivers/usb/gadget/composite.c | 5 +++++
>   1 file changed, 5 insertions(+)
>
> diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
> index 223f72d4d9ed..2fbeb2c19665 100644
> --- a/drivers/usb/gadget/composite.c
> +++ b/drivers/usb/gadget/composite.c
> @@ -861,6 +861,11 @@ static int set_config(struct usb_composite_dev *cdev,
>   	else
>   		power = min(power, 900U);
>   done:
> +	if (power <= USB_SELF_POWER_VBUS_MAX_DRAW)
> +		usb_gadget_set_selfpowered(gadget);
> +	else
> +		usb_gadget_clear_selfpowered(gadget);
> +
>   	usb_gadget_vbus_draw(gadget, power);
>   	if (result >= 0 && cdev->delayed_status)
>   		result = USB_GADGET_DELAYED_STATUS;

The get_maintainer.pl script returned the email balbi@ti.com when it 
should be balbi@kernel.org due to git blamed fixes.

Is this a bug or intentional?

Thinh

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: gadget: composite: Inform controller driver of self-powered
  2020-02-01  2:50 [PATCH] usb: gadget: composite: Inform controller driver of self-powered Thinh Nguyen
  2020-02-01  3:17 ` Thinh Nguyen
@ 2020-02-01 10:36 ` Felipe Balbi
  1 sibling, 0 replies; 3+ messages in thread
From: Felipe Balbi @ 2020-02-01 10:36 UTC (permalink / raw)
  To: Thinh Nguyen, Greg Kroah-Hartman, Felipe Balbi,
	Sebastian Andrzej Siewior
  Cc: Thinh Nguyen, linux-usb

[-- Attachment #1: Type: text/plain, Size: 515 bytes --]

Thinh Nguyen <Thinh.Nguyen@synopsys.com> writes:

> Different configuration may draw different power. Inform the controller
> driver of the change so it can respond properly (e.g. GET_STATUS
> request). This fixes an issue with setting MaxPower from configfs. The
> composite driver doesn't check this value when setting self-powered.
>
> Fixes: 88af8bbe4ef7 ("usb: gadget: the start of the configfs interface")
> Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>

we need a Cc stable here

-- 
balbi

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-02-01 10:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-01  2:50 [PATCH] usb: gadget: composite: Inform controller driver of self-powered Thinh Nguyen
2020-02-01  3:17 ` Thinh Nguyen
2020-02-01 10:36 ` Felipe Balbi

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).