Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754137AbcDKLTS (ORCPT ); Mon, 11 Apr 2016 07:19:18 -0400 Received: from mga09.intel.com ([134.134.136.24]:13521 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752636AbcDKLTR convert rfc822-to-8bit (ORCPT ); Mon, 11 Apr 2016 07:19:17 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,462,1455004800"; d="scan'208";a="782404086" From: "Du, Changbin" To: Felipe Balbi CC: "gregkh@linuxfoundation.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH v3 1/2] usb: dwc3: make dwc3_debugfs_init return value be void Thread-Topic: [PATCH v3 1/2] usb: dwc3: make dwc3_debugfs_init return value be void Thread-Index: AQHRkXtvOGw23YfLWUyQ22+PaN9B8J+D6z8AgAC3HNA= Date: Mon, 11 Apr 2016 11:19:11 +0000 Message-ID: <0C18FE92A7765D4EB9EE5D38D86A563A05CFE237@shsmsx102.ccr.corp.intel.com> References: <1460108062-31398-1-git-send-email-changbin.du@intel.com> <1460108062-31398-2-git-send-email-changbin.du@intel.com> <878u0kpnod.fsf@intel.com> In-Reply-To: <878u0kpnod.fsf@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYTVjYmI5ZTEtNTc4OC00ODcyLTk5MWUtN2JlOGFkZTc4MmQwIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IjRHZGxlMjArQUFiUzE5MzNuWnVSR0JcL29qcm9CcmE1a3hnNmZXc0x4M3hrPSJ9 x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1334 Lines: 54 > > root = debugfs_create_dir(dev_name(dwc->dev), NULL); > > - if (!root) { > > - ret = -ENOMEM; > > - goto err0; > > - } > > + if (IS_ERR_OR_NULL(root)) > > + return; > > We can definitely keep on going, but I'd still like to know that we > enabled CONFIG_DEBUG_FS but failed to create a file or a > directory. Seems like this should read as follows: > > if (IS_ERR_OR_NULL(root)) { > if (!root) > dev_err(dwc->dev, "Can't create debugfs root\n"); > return; > } > > ditto to all bellow. > Balbi, so you mean we should not let the failure go silent, right? > > dwc->root = root; > > > > dwc->regset = kzalloc(sizeof(*dwc->regset), GFP_KERNEL); > > if (!dwc->regset) { > > - ret = -ENOMEM; > > - goto err1; > > + debugfs_remove_recursive(root); > > you're now duplicating debugfs_remove_recursive(root) in all braches and > that's error prone. It's probably better to keep our gotos, but change > them so they read as follows: > > if (!dwc->regset) > goto err1; > > [...] > > return; /* this is our successful exit point */ > > err1: > debugfs_remove_recursive(root); > kfree(dwc->regset); > > > -- > Balbi No, no need anymore. Because no branch share this code now. Then remove the goto would make code a little clear. Thanks, Du, Changbin