mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "anish kumar" <anish198519851985@gmail.com>
To: "Jonathan Cameron" <jic23@cam.ac.uk>
Cc: "Greg KH" <gregkh@suse.de>, "Joe Perches" <joe@perches.com>,
	<devel@driverdev.osuosl.org>, <arnd@arndb.de>,
	<lucas.demarchi@profusion.mobi>, <linux-kernel@vger.kernel.org>,
	<manuel.stahl@iis.fraunhofer.de>
Subject: Re: [PATCH 1/2] staging: iio replaced kmalloc with local variables.
Date: Tue, 7 Jun 2011 16:02:16 +0530	[thread overview]
Message-ID: <235574A8AA3344EF9A7F9D1D3B128B70@your6c359a3bdc> (raw)
In-Reply-To: <4DEDF2B8.5020502@cam.ac.uk>

Jonathan Cameron wrote:
> On 06/07/11 05:56, anish singh wrote:
>>
>>
>> On Tue, Jun 7, 2011 at 4:11 AM, Greg KH <gregkh@suse.de
>> <mailto:gregkh@suse.de>> wrote:
>>
>>     On Mon, Jun 06, 2011 at 03:28:29PM -0700, Joe Perches wrote:
>>     > On Mon, 2011-06-06 at 15:21 -0700, Greg KH wrote:
>>     > > On Mon, Jun 06, 2011 at 03:10:57PM -0700, Joe Perches wrote:
>>     > > > On Mon, 2011-06-06 at 14:55 -0700, Greg KH wrote:
>>     > > > > On Tue, Jun 07, 2011 at 12:37:37AM +0530, anish wrote:
>>     > > > > > From: anish kumar <anish198519851985@gmail.com
>>     <mailto:anish198519851985@gmail.com>> > > > > > Replace kmalloc with
>>     local variables as it was un-necessary and > > > > > also removed the
>>     redudant code after this change. > > > > SPI data, like USB data, has to
>>     come from kmalloced data, not from the > > > > stack, or bad things can,
>>     and will, happen. > > > Perhaps just add a comment like:
>>     > > > +       u8 *tx = kmalloc(2, GFP_KERNEL);  /* can't be on stack */
>>     > > You really want to do to that for _EVERY_ SPI and USB driver?  I
>>     don't > > think so.
>>     >
>>     > Nope, only the ones that look especially odd because
>>     >       kmalloc(sizeof(struct foo), ...)
>>     > or
>>     >       kmalloc(sizeof("type), ...)
>>     > is not used.
>>     >
>>     > It might be better to just declare a 2 byte struct.
>>
>>     No, this is a very common thing for all USB and SPI drivers.  It's so
>>     obvious that once I saw the Subject: line, I knew this patch was going
>>     to be wrong.
>>
>>     This is something that the USB and SPI developers know all about, it's
>>     the way things work, and this driver works, so why are people trying to
>>     "clean" it up in ways that will break it, or cause extra work with
>>     structures where they are not needed at all?
>>
>> Sorry for noise as i didn't the SPI requirements,thought it is similar to
>> I2C and
>> in cleaning up below part i wrongly cleaned SPI part also.Below was also part
>> of patch.
> Not to worry, you are far from the first person to fall into this issue!
> Also, you have highlighted a weird corner in that driver, that could do with
> tidying up (just not quite the fix you had in mind!).
>> static int max1363_write_basic_config(struct i2c_client *client,
>>                                      unsigned char d2)
>>  {
>>        int ret;
>> -       u8 *tx_buf = kmalloc(2, GFP_KERNEL);
>> +       u8 tx_buf[2];
>>        if (!tx_buf)
>>                return -ENOMEM;
>> @@ -215,7 +215,6 @@ static int max1363_write_basic_config(struct i2c_client
>>        *client, tx_buf[1] = d2;
>>        ret = i2c_master_send(client, tx_buf, 2);
>> -       kfree(tx_buf);
>>        return (ret > 0) ? 0 : ret;
>>  }
>> I think above patch is ok as it is I2C and I2C doesn't have that requirement.
> Yes.  I2C bus drivers that do dma do the copy into dma safe memory internally.
> Makes for more bouncing around of data, but i2c is slow anyway so it doesn't
> matter. Also, based on a quick look this morning, the dma buffers tend to
> require various headers to be in place etc which isn't typically the case for
> spi (a much more 'raw' bus).
I couldn't understand this comment.Specifically "various headers"?
Will appreciate it if you kindly explain.
>
> Can you cc linux-iio@vger.kernel.org on that patch when you send it out
> please.
Sure.Sorry for not sending it there.
>
> Jonathan 


  reply	other threads:[~2011-06-07 10:32 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-06 19:07 anish
2011-06-06 19:13 ` Geert Uytterhoeven
2011-06-06 19:49   ` Dan Carpenter
2011-06-06 19:20 ` Peter Hüwe
2011-06-06 21:55 ` Greg KH
2011-06-06 22:10   ` Joe Perches
2011-06-06 22:21     ` Greg KH
2011-06-06 22:28       ` Joe Perches
2011-06-06 22:41         ` Greg KH
2011-06-06 22:49           ` Joe Perches
     [not found]           ` <BANLkTimZP1=tOdsn9eNiERr0Up0xHrr=3g@mail.gmail.com>
2011-06-07  9:43             ` Jonathan Cameron
2011-06-07 10:32               ` anish kumar [this message]
2011-06-07 11:23                 ` Jonathan Cameron
2011-06-07  9:35     ` Jonathan Cameron

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=235574A8AA3344EF9A7F9D1D3B128B70@your6c359a3bdc \
    --to=anish198519851985@gmail.com \
    --cc=arnd@arndb.de \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@suse.de \
    --cc=jic23@cam.ac.uk \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lucas.demarchi@profusion.mobi \
    --cc=manuel.stahl@iis.fraunhofer.de \
    /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

all inboxes | Powered by JetHome®