From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: ashishj3 <ashish.jangam@kpitcummins.com>
Cc: arnd@arndb.de, sameo@openedhand.com,
linux-kernel@vger.kernel.org, Dajun <dajun.chen@diasemi.com>,
linaro-dev@lists.linaro.org
Subject: Re: [PATCH 1/11] MFD: DA9052 MFD core module v1
Date: Tue, 28 Jun 2011 20:20:35 -0700 [thread overview]
Message-ID: <20110629032033.GC22472@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1309270609.376.226.camel@L-0532.kpit.com>
On Tue, Jun 28, 2011 at 07:46:49PM +0530, ashishj3 wrote:
> +static int da9052_add_subdevs(struct da9052 *da9052)
> +{
> + struct da9052_pdata *pdata = da9052->dev->platform_data;
> + int ret;
> +
> + static struct mfd_cell __initdata da9052_subdev_info[] = {
> + {"da9052-onkey", .resources = &da9052_onkey_resource,
> + .num_resources = 1},
It seems a bit odd that this is embedded into the function?
> + {"da9052-gpio", .resources = NULL, .num_resources = 0},
No need to explicitly initialize static data to zero.
> +int da9052_device_init(struct da9052 *da9052)
> +{
> + struct da9052_pdata *pdata = da9052->dev->platform_data;
> + int ret;
> +
> + mutex_init(&da9052->io_lock);
> + mutex_init(&da9052->auxadc_lock);
> + pdata->init(da9052);
This will crash if no init() function is provided which seems wrong,
especially when I'd expect people wouldn't have any need to use such a
callback normally.
> +
> + ret = da9052_add_subdevs(da9052);
> + if (ret != 0)
> + return ret;
> +
> + ret = da9052_irq_init(da9052, pdata);
> + if (ret != 0)
> + return ret;
> +
> + return 0;
> +}
This doesn't remove things it added when it failed.
> + for (raddr = reg ; raddr < reg + bytes; raddr++) {
> + raddr = (raddr << 1);
> +
> + spi_message_init(&message);
> + memset(&xfer, 0, sizeof(xfer));
> +
> + xfer.len = 2;
> + xfer.tx_buf = da9052->spi_tx_buf;
> + xfer.rx_buf = da9052->spi_rx_buf;
> +
> + da9052->spi_tx_buf[0] = raddr;
> + da9052->spi_tx_buf[1] = *val++;
> +
> + spi_message_add_tail(&xfer, &message);
> +
> + spi_sync(da9052->spi_dev, &message);
> + }
This looks like an open coded spi_write().
> + for (raddr = reg ; raddr < reg + bytes; raddr++) {
> + reg = ((raddr << 1) | da9052->rw_pol);
> +
> + spi_message_init(&message);
> + memset(&xfer, 0, sizeof(xfer));
> +
> + xfer.len = 2;
> + xfer.tx_buf = da9052->spi_tx_buf;
> + xfer.rx_buf = da9052->spi_rx_buf;
> +
> + da9052->spi_tx_buf[0] = raddr;
> + da9052->spi_tx_buf[1] = 0xff;
> +
> + da9052->spi_rx_buf[0] = 0;
> + da9052->spi_rx_buf[1] = 0;
> +
> + spi_message_add_tail(&xfer, &message);
> +
> + ret = spi_sync(da9052->spi_dev, &message);
> +
> + if (ret == 0) {
> + *val = da9052->spi_rx_buf[1];
> + val++;
> + return 0;
> + }
This looks like an open coded spi_write_then_read(), or even better
spi_w8r8().
> + da9052_spi->spi_tx_buf = kmalloc(2, GFP_KERNEL | GFP_DMA);
> + if (!da9052_spi->spi_tx_buf) {
> + ret = -ENOMEM;
> + goto err_spi_rx_buf;
> + }
It would be better to just allocate the array as part of the structure,
a separate allocation just uses more memory for both the pointer and the
blocks that are used for the allocation.
> +static struct spi_driver da9052_spi_driver = {
> + .probe = da9052_spi_probe,
> + .remove = __devexit_p(da9052_spi_remove),
> + . driver = {
> + .name = "da9052_spi",
Why the _spi?
> index 0000000..c005a28
> --- /dev/null
> +++ b/include/linux/mfd/da9052/da9052.h
> +static const int32_t tbat_lookup[255] = {
This shouldn't be in a header file. If it needs to be shared between
multiple modules define it in one place and add the prototype in the
header file.
next prev parent reply other threads:[~2011-06-29 3:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-28 14:16 [PATCH 1/11] MFD: DA9052 MFD core module v1 ashishj3
2011-06-29 3:20 ` Mark Brown [this message]
2011-06-29 12:27 ` Arnd Bergmann
2011-07-05 11:37 ` Ashish Jangam
2011-07-05 12:33 ` Arnd Bergmann
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=20110629032033.GC22472@opensource.wolfsonmicro.com \
--to=broonie@opensource.wolfsonmicro.com \
--cc=arnd@arndb.de \
--cc=ashish.jangam@kpitcummins.com \
--cc=dajun.chen@diasemi.com \
--cc=linaro-dev@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sameo@openedhand.com \
/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