Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753882AbbGXHjF (ORCPT ); Fri, 24 Jul 2015 03:39:05 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:25570 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752995AbbGXHjA (ORCPT ); Fri, 24 Jul 2015 03:39:00 -0400 X-AuditID: cbfec7f5-f794b6d000001495-99-55b1eb9102e1 Message-id: <55B1EB8C.2080303@samsung.com> Date: Fri, 24 Jul 2015 09:38:52 +0200 From: Andrzej Pietrasiewicz User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0 MIME-version: 1.0 To: "Du, Changbin" , Felipe Balbi Cc: Greg Kroah-Hartman , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] usb/gadget: make composite gadget meet usb compliance for vbus draw References: <0C18FE92A7765D4EB9EE5D38D86A563A01D14FD5@SHSMSX103.ccr.corp.intel.com> <55B0FA29.5080402@samsung.com> <0C18FE92A7765D4EB9EE5D38D86A563A01D49C90@SHSMSX103.ccr.corp.intel.com> In-reply-to: <0C18FE92A7765D4EB9EE5D38D86A563A01D49C90@SHSMSX103.ccr.corp.intel.com> Content-type: text/plain; charset=windows-1252; format=flowed Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrNLMWRmVeSWpSXmKPExsVy+t/xy7oTX28MNVh83cTi4P16i40XjzNZ NC9ez2ZxedccNotFy1qZHVg9Fu95yeSxf+4ado/jN7YzeXzeJBfAEsVlk5Kak1mWWqRvl8CV 8WS7RMF6sYrbE5vZGxg/CXYxcnJICJhInN22gR3CFpO4cG89WxcjF4eQwFJGibftfewQzgtG iccP9jOBVPEKaElM3HybpYuRg4NFQFVi9hRJkDCbgLHE3oMdjCC2qECExPLVJxkhygUlfky+ xwJiiwi4S/QfmMwEMpNZYD2jxOkrT5hA5ggLREm8/SUNsesAo8Sqk2eYQRo4BcIkpu4+CbaX WcBWYsH7dSwQtrzE5jVvmScwCsxCsmMWkrJZSMoWMDKvYhRNLU0uKE5KzzXSK07MLS7NS9dL zs/dxAgJ4q87GJceszrEKMDBqMTDe2DSxlAh1sSy4srcQ4wSHMxKIrwMx4BCvCmJlVWpRfnx RaU5qcWHGKU5WJTEeWfueh8iJJCeWJKanZpakFoEk2Xi4JRqYKy1FOr8LRY25+I2/449KYsP n7i1srKRZX5TyfyKM/r5y9mee5lu51tW6Vv36czCy2+mlz/1ZbuxtPnfxOLtE3uUXONm3Iw0 vqjOHnX6QnPm2RS5qDOV6+OFdZrtSz/93t+9UXH+37kXBHXyAotUe/8febvk37PyGEETiQsZ cu9PuBnwLrRI+qrEUpyRaKjFXFScCAC8+MFxXgIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3027 Lines: 86 Hi, W dniu 24.07.2015 o 06:11, Du, Changbin pisze: > Thanks, Pietrasiewicz. >> From: Andrzej Pietrasiewicz [mailto:andrzej.p@samsung.com] >> W dniu 23.07.2015 o 14:34, Du, Changbin pisze: >>> >From 0a8e0d63a9887735c6782d7b0c15c2c1fdf1952a Mon Sep 17 00:00:00 >>> void composite_disconnect(struct usb_gadget *gadget) >>> { >>> struct usb_composite_dev *cdev = get_gadget_data(gadget); >>> @@ -2095,7 +2119,7 @@ void composite_suspend(struct usb_gadget >> *gadget) >>> >>> cdev->suspended = 1; >>> >>> - usb_gadget_vbus_draw(gadget, 2); >>> + usb_gadget_vbus_draw(gadget, USB_VBUS_DRAW_SUSPEND); >>> } >> >> This looks like an unrelated change. I think it should go first >> in a separate patch which eliminates usage of "magic" numbers. >> > This change does make sense. As you know, when device is reset, it is in a 'unconfigured' > state. Compliance Test equipment may also measure vbus current at this moment. I am not questioning the change itself. What I mean is that in my opinion it should be done in a separate patch, because the newly introduced USB_VBUS_DRAW_SUSPEND is not used anywhere else in your patch. The meaning of this change is "use a symbolic name rather than an explicit number" and it is unrelated to making composite gadget meet usb compliance for vbus draw. In other words, if you don't do this change at all the compliance is still maintained, because the value of USB_VBUS_DRAW_SUSPEND is 2 anyway, so what the compiler eventually sees is the same whether the change is made or not. My idea: [PATCHv2 0/2] usb gadget vbus draw compilance [PATCHv2 1/2] usb: gadget: composite: avoid using a magic number >> substituting an explicit "2" with USB_VBUS_DRAW_SUSPEND goes here << [PATCHv2 2/2] usb: gadget: composite: meet usb compliance for vbus draw >> the rest of your changes go here << > >>> } >>> @@ -2132,7 +2157,7 @@ static const struct usb_gadget_driver >> composite_driver_template = { >>> .unbind = composite_unbind, >>> >>> .setup = composite_setup, >>> - .reset = composite_disconnect, >>> + .reset = composite_reset, >>> .disconnect = composite_disconnect, >>> >> >> A similar "template" is in drivers/usb/gadget/configfs.c. Shouldn't the "reset" >> method be changed there as well? >> > Yes, it also need to change. I will change it as well. > >> >>> >>> +/* USB2 compliance requires that un-configured current draw <= 100mA, >>> + * USB3 requires it <= 150mA, OTG requires it <= 2.5mA. >>> + */ >>> +#define USB2_VBUS_DRAW_UNCONF 100 >>> +#define USB3_VBUS_DRAW_UNCONF 150 >>> +#define USB_OTG_VBUS_DRAW_UNCONF 2 >> >> >>> +#define USB_VBUS_DRAW_SUSPEND 2 >> >> separate patch >> > Sorry, I didn't get your idea. Why separate these macros definition? Please see above. Andrzej -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/