Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754548AbcDNKw1 (ORCPT ); Thu, 14 Apr 2016 06:52:27 -0400 Received: from relmlor4.renesas.com ([210.160.252.174]:48984 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751879AbcDNKwZ convert rfc822-to-8bit (ORCPT ); Thu, 14 Apr 2016 06:52:25 -0400 X-IronPort-AV: E=Sophos;i="5.22,559,1449500400"; d="scan'208";a="208943005" From: Yoshihiro Shimoda To: Sudip Mukherjee , Greg Kroah-Hartman , Felipe Balbi CC: "linux-kernel@vger.kernel.org" , "linux-usb@vger.kernel.org" Subject: RE: [PATCH] usb: renesas_usbhs: fix signed-unsigned return Thread-Topic: [PATCH] usb: renesas_usbhs: fix signed-unsigned return Thread-Index: AQHRkahAywuzvvwSGkWasTrUpa0czp+JUJkA Date: Thu, 14 Apr 2016 10:52:20 +0000 Message-ID: References: <1460127918-27400-1-git-send-email-sudipm.mukherjee@gmail.com> In-Reply-To: <1460127918-27400-1-git-send-email-sudipm.mukherjee@gmail.com> Accept-Language: ja-JP, en-US Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=renesas.com; x-originating-ip: [211.11.155.144] x-ms-office365-filtering-correlation-id: b38f9cfd-bef7-4158-2464-08d36452daa9 x-microsoft-exchange-diagnostics: 1;SG2PR06MB0917;5:kGAbnyuNmnsfjR/fiIsCE29r6LEGvFAp5Vnvc4mWsPyk/ZTfpppErZji8idoHwBB3PUck/Pzsw2HbN8eOtu5p1SevJVrHJEhm/MUCeS/T3H40FQfAqQqhcnUDKIEfxY69ZfKw3x6be2mSMHB3h1nOg==;24:9BgMKKwE23YRTX1SueRvOePa0kw0Ut6gxYHEe4XNorelLFcDjvz4MkpU1+qposxBXqbM3wV/GBAWnu1mIISYYEwvwQ4KDd2qFFglIeUjI3A=;20:VzO3v0RUn8EMo4+VGTgZJrW+pKTYYTVb/eEKYFlf+B8nq4rGmGwiJ96n1bgEEZ15eiuOJN+NjwM7eUoD5YfIAhfOh34PfoDjcvzrmJQ1dtazqSeEfpGEelzmpAHxg3w9zCSZ1pCgvoekBumhYDvi0egKt/7Ay2MlH0bFxGytglM= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SG2PR06MB0917; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026);SRVR:SG2PR06MB0917;BCL:0;PCL:0;RULEID:;SRVR:SG2PR06MB0917; x-forefront-prvs: 0912297777 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(377454003)(9686002)(33656002)(66066001)(5008740100001)(2900100001)(2950100001)(74316001)(2906002)(87936001)(77096005)(15975445007)(5001770100001)(5003600100002)(92566002)(76576001)(86362001)(10400500002)(3846002)(11100500001)(102836003)(6116002)(586003)(1220700001)(1096002)(5002640100001)(122556002)(76176999)(4326007)(81166005)(3660700001)(19580395003)(106116001)(345774005)(54356999)(50986999)(3280700002)(19580405001)(5004730100002)(189998001)(422495003);DIR:OUT;SFP:1102;SCL:1;SRVR:SG2PR06MB0917;H:SG2PR06MB0919.apcprd06.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Apr 2016 10:52:20.6733 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR06MB0917 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3295 Lines: 114 Hi, > From: Sudip Mukherjee > Sent: Saturday, April 09, 2016 12:05 AM > > The return type of usbhsp_setup_pipecfg() was u16 but it was returning > a negative value (-EINVAL). Instead lets return a pointer to u16 which > will hold the value to be returned or in case of error, return the > error code in ERR_PTR. Thank you for the patch! I also think this usbhsp_setup_pipecfg() should return error code using correct variable type. However, I would like to avoid to use ERR_PTR and kmalloc() somehow because I feel this patch is complex a little. How about the usbhsp_setup_pipecfg() prototype is changed like the following? static int usbhsp_setup_pipecfg(struct usbhs_pipe *pipe, int is_host, int dir_in, u16 *pipecfg); Best regards, Yoshihiro Shimoda > Signed-off-by: Sudip Mukherjee > --- > drivers/usb/renesas_usbhs/pipe.c | 38 +++++++++++++++++++++++++------------- > 1 file changed, 25 insertions(+), 13 deletions(-) > > diff --git a/drivers/usb/renesas_usbhs/pipe.c b/drivers/usb/renesas_usbhs/pipe.c > index 78e9dba..00d595c 100644 > --- a/drivers/usb/renesas_usbhs/pipe.c > +++ b/drivers/usb/renesas_usbhs/pipe.c > @@ -391,9 +391,9 @@ void usbhs_pipe_set_trans_count_if_bulk(struct usbhs_pipe *pipe, int len) > /* > * pipe setup > */ > -static u16 usbhsp_setup_pipecfg(struct usbhs_pipe *pipe, > - int is_host, > - int dir_in) > +static u16 *usbhsp_setup_pipecfg(struct usbhs_pipe *pipe, > + int is_host, > + int dir_in) > { > u16 type = 0; > u16 bfre = 0; > @@ -407,9 +407,13 @@ static u16 usbhsp_setup_pipecfg(struct usbhs_pipe *pipe, > [USB_ENDPOINT_XFER_INT] = TYPE_INT, > [USB_ENDPOINT_XFER_ISOC] = TYPE_ISO, > }; > + u16 *result; > > if (usbhs_pipe_is_dcp(pipe)) > - return -EINVAL; > + return ERR_PTR(-EINVAL); > + result = kmalloc(sizeof(u16), GFP_KERNEL); > + if (!result) > + return ERR_PTR(-ENOMEM); > > /* > * PIPECFG > @@ -451,14 +455,14 @@ static u16 usbhsp_setup_pipecfg(struct usbhs_pipe *pipe, > > /* EPNUM */ > epnum = 0; /* see usbhs_pipe_config_update() */ > - > - return type | > - bfre | > - dblb | > - cntmd | > - dir | > - shtnak | > - epnum; > + *result = type | > + bfre | > + dblb | > + cntmd | > + dir | > + shtnak | > + epnum; > + return result; > } > > static u16 usbhsp_setup_pipebuff(struct usbhs_pipe *pipe) > @@ -683,6 +687,7 @@ struct usbhs_pipe *usbhs_pipe_malloc(struct usbhs_priv *priv, > int is_host = usbhs_mod_is_host(priv); > int ret; > u16 pipecfg, pipebuf; > + u16 *result; > > pipe = usbhsp_get_pipe(priv, endpoint_type); > if (!pipe) { > @@ -702,7 +707,14 @@ struct usbhs_pipe *usbhs_pipe_malloc(struct usbhs_priv *priv, > return NULL; > } > > - pipecfg = usbhsp_setup_pipecfg(pipe, is_host, dir_in); > + result = usbhsp_setup_pipecfg(pipe, is_host, dir_in); > + if (IS_ERR(result)) { > + dev_err(dev, "can't setup pipe\n"); > + return NULL; > + } > + pipecfg = *result; > + kfree(result); > + > pipebuf = usbhsp_setup_pipebuff(pipe); > > usbhsp_pipe_select(pipe); > -- > 1.9.1 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-usb" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html