From: Jonathan Cameron <jic23-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org>
To: Ben Dooks <ben-i2c-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>
Cc: anish <anish198519851985-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
gregkh-l3A5Bk7waGM@public.gmane.org,
manuel.stahl-GeUHRtUQU7nSyEMIgutvibNAH6kLmebB@public.gmane.org,
lucas.demarchi-Y3ZbgMPKUGA34EUeqzHoZw@public.gmane.org,
devel-gWbeCf7V1WCQmaza687I9mD2FQJk+8+b@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Linux I2C <linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH] staging iio: Replace kmalloc with local variable
Date: Tue, 07 Jun 2011 14:54:05 +0100 [thread overview]
Message-ID: <4DEE2D7D.6070506@cam.ac.uk> (raw)
In-Reply-To: <20110607134135.GD15795-SMNkleLxa3Z6Wcw2j4pizdi2O/JbrIOy@public.gmane.org>
On 06/07/11 14:41, Ben Dooks wrote:
> On Tue, Jun 07, 2011 at 02:00:23PM +0100, Jonathan Cameron wrote:
>> On 06/07/11 13:39, anish wrote:
>>> From: anish kumar <anish198519851985-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>>>
>>> replaced kmalloc with local variable as I2C(in this case) doesn't require
>>> kmalloc memory it can do with stack memory.
>> I've cc'd linux-i2c just to check I'm right about the whole i2c doesn't need
>> dma safe buffers bit...
>
> No, it is down to the i2c driver, and from recollection dma from stack is
> not recommended, due to things like cache line alignment. Please do not
> do this.
Then lets drop this. Sorry Anish, seems I led you down the garden path.
I'll check all my i2c drivers don't do this...
>
>>> Signed-off-by: anish kumar <anish198519851985-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>> Acked-by: Jonathan Cameron <jic23-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org>
>>> ---
>>> drivers/staging/iio/adc/max1363_core.c | 5 +----
>>> 1 files changed, 1 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c
>>> index 1037087..9462230 100644
>>> --- a/drivers/staging/iio/adc/max1363_core.c
>>> +++ b/drivers/staging/iio/adc/max1363_core.c
>>> @@ -207,15 +207,12 @@ 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;
>>> tx_buf[0] = d1;
>>> tx_buf[1] = d2;
>>>
>>> ret = i2c_master_send(client, tx_buf, 2);
>>> - kfree(tx_buf);
>>>
>>> return (ret > 0) ? 0 : ret;
>>> }
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
>> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
WARNING: multiple messages have this Message-ID (diff)
From: Jonathan Cameron <jic23@cam.ac.uk>
To: Ben Dooks <ben-i2c@fluff.org>
Cc: anish <anish198519851985@gmail.com>,
gregkh@suse.de, manuel.stahl@iis.fraunhofer.de,
lucas.demarchi@profusion.mobi, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
Linux I2C <linux-i2c@vger.kernel.org>
Subject: Re: [PATCH] staging iio: Replace kmalloc with local variable
Date: Tue, 07 Jun 2011 14:54:05 +0100 [thread overview]
Message-ID: <4DEE2D7D.6070506@cam.ac.uk> (raw)
In-Reply-To: <20110607134135.GD15795@trinity.fluff.org>
On 06/07/11 14:41, Ben Dooks wrote:
> On Tue, Jun 07, 2011 at 02:00:23PM +0100, Jonathan Cameron wrote:
>> On 06/07/11 13:39, anish wrote:
>>> From: anish kumar <anish198519851985@gmail.com>
>>>
>>> replaced kmalloc with local variable as I2C(in this case) doesn't require
>>> kmalloc memory it can do with stack memory.
>> I've cc'd linux-i2c just to check I'm right about the whole i2c doesn't need
>> dma safe buffers bit...
>
> No, it is down to the i2c driver, and from recollection dma from stack is
> not recommended, due to things like cache line alignment. Please do not
> do this.
Then lets drop this. Sorry Anish, seems I led you down the garden path.
I'll check all my i2c drivers don't do this...
>
>>> Signed-off-by: anish kumar <anish198519851985@gmail.com>
>> Acked-by: Jonathan Cameron <jic23@cam.ac.uk>
>>> ---
>>> drivers/staging/iio/adc/max1363_core.c | 5 +----
>>> 1 files changed, 1 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c
>>> index 1037087..9462230 100644
>>> --- a/drivers/staging/iio/adc/max1363_core.c
>>> +++ b/drivers/staging/iio/adc/max1363_core.c
>>> @@ -207,15 +207,12 @@ 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;
>>> tx_buf[0] = d1;
>>> tx_buf[1] = d2;
>>>
>>> ret = i2c_master_send(client, tx_buf, 2);
>>> - kfree(tx_buf);
>>>
>>> return (ret > 0) ? 0 : ret;
>>> }
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2011-06-07 13:54 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-07 12:39 [PATCH] staging iio: Replace kmalloc with local variable anish
2011-06-07 13:00 ` Jonathan Cameron
2011-06-07 13:00 ` Jonathan Cameron
[not found] ` <4DEE20E7.4020008-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org>
2011-06-07 13:41 ` Ben Dooks
2011-06-07 13:41 ` Ben Dooks
[not found] ` <20110607134135.GD15795-SMNkleLxa3Z6Wcw2j4pizdi2O/JbrIOy@public.gmane.org>
2011-06-07 13:54 ` Jonathan Cameron [this message]
2011-06-07 13:54 ` Jonathan Cameron
[not found] ` <4DEE2D7D.6070506-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org>
2011-06-07 14:04 ` Hennerich, Michael
2011-06-07 14:04 ` Hennerich, Michael
2011-06-07 14:04 ` Hennerich, Michael
2011-06-07 14:02 ` Jean Delvare
2011-06-07 14:02 ` Jean Delvare
2011-06-08 5:11 ` anish singh
2011-06-09 8:23 ` anish singh
[not found] ` <BANLkTi=e0A2G-d+t4VF5V0gj+eNoh3KRnQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-06-09 8:29 ` Jean Delvare
2011-06-09 8:29 ` Jean Delvare
2011-06-09 8:34 ` anish singh
[not found] ` <BANLkTimq_5rmB+UkaxZwrOtV-ZF3+fEOgQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-06-09 8:48 ` Jonathan Cameron
2011-06-09 8:48 ` Jonathan Cameron
[not found] ` <4DF088E5.5000408-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org>
2011-06-09 10:46 ` Jonathan Cameron
2011-06-09 10:46 ` Jonathan Cameron
2011-06-09 14:29 ` anish singh
[not found] ` <BANLkTik4Tfd73iKcDsXK-sfy6_ADVX4oYA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-06-09 14:51 ` Jonathan Cameron
2011-06-09 14:51 ` Jonathan Cameron
2011-06-09 15:03 ` anish singh
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=4DEE2D7D.6070506@cam.ac.uk \
--to=jic23-kwpb1pkirijaa/9udqfwiw@public.gmane.org \
--cc=anish198519851985-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=ben-i2c-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org \
--cc=devel-gWbeCf7V1WCQmaza687I9mD2FQJk+8+b@public.gmane.org \
--cc=gregkh-l3A5Bk7waGM@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=lucas.demarchi-Y3ZbgMPKUGA34EUeqzHoZw@public.gmane.org \
--cc=manuel.stahl-GeUHRtUQU7nSyEMIgutvibNAH6kLmebB@public.gmane.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.