From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752873AbbCINHJ (ORCPT ); Mon, 9 Mar 2015 09:07:09 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:41727 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751778AbbCINHH (ORCPT ); Mon, 9 Mar 2015 09:07:07 -0400 Date: Mon, 9 Mar 2015 16:06:45 +0300 From: Dan Carpenter To: Giedrius =?utf-8?Q?Statkevi=C4=8Dius?= , Matteo Semenzato Cc: lidza.louina@gmail.com, markh@compro.net, devel@driverdev.osuosl.org, gregkh@linuxfoundation.org, driverdev-devel@linuxdriverproject.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] dgnc: move more repeating code under 'failed' label Message-ID: <20150309130645.GF10964@mwanda> References: <1425836797-3632-1-git-send-email-giedrius.statkevicius@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1425836797-3632-1-git-send-email-giedrius.statkevicius@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: acsinet22.oracle.com [141.146.126.238] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Added Matteo to the CC list because he was working on this function as well and I remembered something I wanted to tell him. On Sun, Mar 08, 2015 at 07:46:37PM +0200, Giedrius Statkevičius wrote: > Currently the label is only used to return a error code to the caller but more > repeating code is before each "goto failed;" thus we can move that code to the > label. Also, remove some empty unneeded lines together with this patch in those > if's and at the end of dgnc_found_board(). > This function totally sucks. This patch is useless because we will never use the brd->state in the cases where we fail. We shouldn't be saving inconsistent crap into dgnc_Board[] because that is barf inducing ugly even though it's not a bug given that we don't use it. Only do: dgnc_Board[dgnc_NumBoards] = brd; when the brd is fully configured at the end of the dgnc_found_board() function. regards, dan carpenter > Signed-off-by: Giedrius Statkevičius > --- > drivers/staging/dgnc/dgnc_driver.c | 12 ++---------- > 1 file changed, 2 insertions(+), 10 deletions(-) > > diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c > index fa1ee79..73ee667 100644 > --- a/drivers/staging/dgnc/dgnc_driver.c > +++ b/drivers/staging/dgnc/dgnc_driver.c > @@ -574,17 +574,12 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) > if (rc < 0) { > dgnc_tty_uninit(brd); > pr_err(DRVSTR ": Can't register tty devices (%d)\n", rc); > - brd->state = BOARD_FAILED; > - brd->dpastatus = BD_NOFEP; > goto failed; > } > > rc = dgnc_finalize_board_init(brd); > if (rc < 0) { > pr_err(DRVSTR ": Can't finalize board init (%d)\n", rc); > - brd->state = BOARD_FAILED; > - brd->dpastatus = BD_NOFEP; > - > goto failed; > } > > @@ -592,9 +587,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) > if (rc < 0) { > dgnc_tty_uninit(brd); > pr_err(DRVSTR ": Can't init tty devices (%d)\n", rc); > - brd->state = BOARD_FAILED; > - brd->dpastatus = BD_NOFEP; > - > goto failed; > } > > @@ -628,9 +620,9 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) > return 0; > > failed: > - > + brd->state = BOARD_FAILED; > + brd->dpastatus = BD_NOFEP; > return -ENXIO; > - > } > > > -- > 2.3.2 > > _______________________________________________ > devel mailing list > devel@linuxdriverproject.org > http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel