public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@gmail.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: LKML <linux-kernel@vger.kernel.org>,
	spi-devel-general@lists.sourceforge.net,
	LM Sensors <lm-sensors@lm-sensors.org>
Subject: Re: [Patch 3/4] ST LIS3L02DQ accelerometer
Date: Wed, 23 Jul 2008 18:44:21 +0100	[thread overview]
Message-ID: <48876DF5.5060302@gmail.com> (raw)
In-Reply-To: <20080723180726.6fc0ef6e@lxorguk.ukuu.org.uk>

Dear Alan,
>> +
>> + xfer.rx_buf = kmalloc(4, GFP_KERNEL);
>> + if (xfer.rx_buf == NULL) {
>> + ret = -ENOMEM;
>> + goto error_free_tx;
>> + }
>
> Do these really need to be two kmallocs
Sorry about that, legacy of a much older version. I definitely didn't clean
this driver up properly (iio core is still a fair way off going anywhere so
I'll admit I didn't didn't check the drivers using it as thoroughly as I
should
have)
>
>> + if (ret) {
>> + dev_err(&st->us->dev, "problem with get x offset");
>> + goto error_free_rx;
>> + }
>> + *val = ((unsigned char *)(xfer.rx_buf))[0];
>> + kfree(xfer.rx_buf);
>> + kfree(xfer.tx_buf);
>> + return ret;
>> +error_free_rx:
>> + kfree(xfer.rx_buf);
>> +error_free_tx:
>> + kfree(xfer.tx_buf);
>> +error_ret:
>> + return ret;
>
> That lot makes no sense. You could just drop through..
Oops.
>> +{
>> + uint8_t val;
>> + int8_t ret;
>
> Kernel types (u8, s8 etc)
To used to userspace programming! I'll fix them.
>
>> + local_rx_buf = kmalloc(4, GFP_KERNEL);
>> + local_tx_buf = kmalloc(4, GFP_KERNEL);
>> +
>> + local_tx_buf[1] = LIS3L02DQ_READ_REG(reg_address);
>
> OOPS on out of memory case
Good point.
>

>
> You seem to have a lot of almost identical routines here. It looks like
> with a few helpers this driver could be vastly shorter.
Again a good point. I'll clean it up and repost.

Thanks for the hints,

--
Jonathan Cameron



  reply	other threads:[~2008-07-23 17:44 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-23 17:00 [Patch 0/4] IndustrialIO subsystem (ADCs, accelerometers etc) Jonathan Cameron
2008-07-23 17:08 ` [Patch 1/4] Industrialio Core Jonathan Cameron
2008-07-23 18:31   ` Anton Vorontsov
2008-07-24 10:12     ` [spi-devel-general] " Jonathan Cameron
2008-07-23 19:42   ` Ben Dooks
2008-07-24 10:33     ` Jonathan Cameron
2008-07-24  9:01   ` Eric Piel
2008-07-24 11:56     ` [spi-devel-general] " Jonathan Cameron
2008-07-23 17:11 ` [Patch 2/4] Max1363 (and similar) ADCs Jonathan Cameron
2008-07-23 17:14 ` [Patch 3/4] ST LIS3L02DQ accelerometer Jonathan Cameron
2008-07-23 17:07   ` Alan Cox
2008-07-23 17:44     ` Jonathan Cameron [this message]
2008-07-23 17:17 ` [Patch 4/4] VTI SCA3000 Series accelerometer driver Jonathan Cameron
2008-07-23 17:48 ` [Patch 0/4] IndustrialIO subsystem (ADCs, accelerometers etc) Henrique de Moraes Holschuh
2008-07-24  9:44   ` Eric Piel
2008-07-24 10:08     ` Ben Dooks
2008-07-24 12:20       ` [spi-devel-general] " Jonathan Cameron
2008-07-24 12:13     ` Jonathan Cameron
2008-07-24 12:37       ` Eric Piel
2008-07-24 12:45         ` Jonathan Cameron
2008-07-24 13:26           ` Dmitry Torokhov
2008-07-24 13:39             ` Jonathan Cameron
2008-07-23 18:36 ` David Brownell
2008-07-23 19:19 ` [spi-devel-general] " Ben Dooks
2008-07-24  7:41   ` Hans J. Koch
2008-07-24  9:19     ` Alan Cox
2008-07-24 12:28       ` Jonathan Cameron
2008-07-24 10:01     ` Ben Dooks
2008-07-24 15:38       ` Hans J. Koch
2008-07-24 16:11         ` Jonathan Cameron
2008-07-24 12:32   ` Jonathan Cameron
2008-07-23 19:33 ` Ben Dooks
2008-07-24 17:57 ` [Patch 5/4] IndustrialIO subsystem very early cut of documentation + userspace demo Jonathan Cameron
2008-07-24 22:25 ` [Patch 0/4] IndustrialIO subsystem (ADCs, accelerometers etc) Jan Engelhardt
2008-07-25 11:12   ` Jonathan Cameron
2008-07-25 11:28     ` Anton Vorontsov

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=48876DF5.5060302@gmail.com \
    --to=jonathan.cameron@gmail.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lm-sensors@lm-sensors.org \
    --cc=spi-devel-general@lists.sourceforge.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