From: Dan Carpenter <dan.carpenter@oracle.com>
To: Daeseok Youn <daeseok.youn@gmail.com>
Cc: lidza.louina@gmail.com, gregkh@linuxfoundation.org,
markh@compro.net, driverdev-devel@linuxdriverproject.org,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 8/9] staging: dgap: cleanup dgap_firmware_load() function
Date: Fri, 13 Jun 2014 11:32:00 +0300 [thread overview]
Message-ID: <20140613083200.GD5015@mwanda> (raw)
In-Reply-To: <20140613074337.GA31632@devel.8.8.4.4>
On Fri, Jun 13, 2014 at 04:43:37PM +0900, Daeseok Youn wrote:
> @@ -583,8 +585,51 @@ static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
> if (rc)
> return rc;
>
> - dgap_numboards++;
> - return dgap_firmware_load(pdev, ent->driver_data);
> + brd = dgap_board[dgap_numboards++];
I don't like the way the current code uses dgap_numboards and hiding
the ++ in here makes it even worse.
My thinking is that dgap_found_board() shouldn't touch dgap_board[] but
instead of instead it should return a pointer to "brd". Then the code
in dgap_init_one() does:
brd = dgap_found_board();
if (!brd)
return -ENODEV;
/* code until the end of the function */
dgap_board[dgap_numboards++] = brd;
return 0;
tty_free:
/* error path */
This could be done in a follow on patch.
TODO-list: 2014-06-13: dgap: make dgap_found_board() return a brd pointer.
> + rc = dgap_firmware_load(pdev, ent->driver_data, brd);
> + if (rc)
> + goto free_brd;
> +
> + rc = dgap_alloc_flipbuf(brd);
> + if (rc)
> + goto free_brd;
> +
> + rc = dgap_tty_register(brd);
> + if (rc)
> + goto free_flipbuf;
> +
> + rc = dgap_request_irq(brd);
> + if (rc)
> + goto unregister_tty;
> +
> + /*
> + * Do tty device initialization.
> + */
> + rc = dgap_tty_init(brd);
> + if (rc < 0)
> + goto free_irq;
> +
> + rc = dgap_tty_register_ports(brd);
> + if (rc)
> + goto tty_free;
> +
> + brd->state = BOARD_READY;
> + brd->dpastatus = BD_RUNNING;
> +
> + return 0;
> +
> +tty_free:
> + dgap_tty_free(brd);
> +free_irq:
> + dgap_free_irq(brd);
> +unregister_tty:
> + dgap_tty_unregister(brd);
> +free_flipbuf:
> + dgap_free_flipbuf(brd);
> +free_brd:
> + kfree(brd);
This isn't complete. We need a dgap_unfound_board() which frees brd
and calls the inverse of dgap_do_remap(). Obviously "found" and
"unfound" are not the smartest names in the universe.
That said, I'm inclined to say that we can fix this up in a later patch.
This patch is clearly an improvement on the existing code and I'm not
sure it's possible to fix *everything* in one go.
TODO-list: 2014-06-13: dgap: call dgap_unfound_board() on error in dgap_init_one()
> + dgap_board[--dgap_numboards] = NULL;
> + return rc;
> }
regards,
dan carpenter
prev parent reply other threads:[~2014-06-13 8:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-13 7:43 [PATCH 8/9] staging: dgap: cleanup dgap_firmware_load() function Daeseok Youn
2014-06-13 8:32 ` Dan Carpenter [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140613083200.GD5015@mwanda \
--to=dan.carpenter@oracle.com \
--cc=daeseok.youn@gmail.com \
--cc=devel@driverdev.osuosl.org \
--cc=driverdev-devel@linuxdriverproject.org \
--cc=gregkh@linuxfoundation.org \
--cc=lidza.louina@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=markh@compro.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).