From: Oleksandr Kozaruk <oleksandr.kozaruk@ti.com>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: "tony@atomide.com" <tony@atomide.com>,
"benoit.cousson@linaro.org" <benoit.cousson@linaro.org>,
"Nayak, Rajendra" <rnayak@ti.com>,
"Ujfalusi, Peter" <peter.ujfalusi@ti.com>,
"ABRAHAM, KISHON VIJAY" <kishon@ti.com>,
"jic23@cam.ac.uk" <jic23@cam.ac.uk>,
"grant.likely@linaro.org" <grant.likely@linaro.org>,
"rob.herring@calxeda.com" <rob.herring@calxeda.com>,
"sameo@linux.intel.com" <sameo@linux.intel.com>,
"ch.naveen@samsung.com" <ch.naveen@samsung.com>,
"poeschel@lemonage.de" <poeschel@lemonage.de>,
"Kim, Milo" <Milo.Kim@ti.com>,
"Krishnamoorthy, Balaji T" <balajitk@ti.com>,
"gg@slimlogic.co.uk" <gg@slimlogic.co.uk>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
"devicetree-discuss@lists.ozlabs.org"
<devicetree-discuss@lists.ozlabs.org>,
"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>
Subject: Re: [PATCH v3 2/2] iio: twl6030-gpadc: TWL6030, TWL6032 GPADC driver
Date: Wed, 17 Jul 2013 16:45:57 +0300 [thread overview]
Message-ID: <51E6A015.8040705@ti.com> (raw)
In-Reply-To: <51E3DE21.9060105@metafoo.de>
On Mon, Jul 15, 2013 at 01:33:53PM +0200, Lars-Peter Clausen wrote:
> On 07/15/2013 01:09 PM, Kozaruk, Oleksandr wrote:
> [...]
> >
> >>> + ret = devm_request_threaded_irq(dev, irq, NULL,
> >>> + twl6030_gpadc_irq_handler,
> >>> + IRQF_ONESHOT, "twl6030_gpadc", gpadc);
> >>
> >> You access memory in the interrupt handler which is freed before
the interrupt
> >> handler is freed.
> > Thanks for pointing this. devm_* will free memory for irq after the
driver
> > is removed and memory for the device is freed. I took me awhile to
understand
> > this. Is there going to be something like devm_iio_device_alloc?
whould it be helpfull?
> >
>
> Yes, I think it certainly makes sense to add a
devm_iio_device_alloc(), care
> to send a patch?
Anything like this? (of course it's not a patch)
struct iio_dev *devm_iio_device_alloc(struct device *dev, int sizeof_priv)
{
struct iio_dev *indio_dev;
size_t alloc_size;
alloc_size = sizeof(struct iio_dev);
if (sizeof_priv) {
alloc_size = ALIGN(alloc_size, IIO_ALIGN);
alloc_size += sizeof_priv;
}
/* ensure 32-byte alignment of whole construct ? */
alloc_size += IIO_ALIGN - 1;
indio_dev = devm_kzalloc(dev, alloc_size, GFP_KERNEL);
if (indio_dev) {
indio_dev->dev.groups = indio_dev->groups;
indio_dev->dev.type = &iio_device_type;
indio_dev->dev.bus = &iio_bus_type;
device_initialize(&indio_dev->dev);
dev_set_drvdata(&indio_dev->dev, (void *)indio_dev);
mutex_init(&indio_dev->mlock);
mutex_init(&indio_dev->info_exist_lock);
INIT_LIST_HEAD(&indio_dev->channel_attr_list);
indio_dev->id = ida_simple_get(&iio_ida, 0, 0, GFP_KERNEL);
if (indio_dev->id < 0) {
/* cannot use a dev_err as the name isn't available */
printk(KERN_ERR "Failed to get id\n");
kfree(dev);
return NULL;
}
dev_set_name(&indio_dev->dev, "iio:device%d", indio_dev->id);
INIT_LIST_HEAD(&indio_dev->buffer_list);
}
return indio_dev;
}
EXPORT_SYMBOL(devm_iio_device_alloc);
Regards,
OK
WARNING: multiple messages have this Message-ID (diff)
From: Oleksandr Kozaruk <oleksandr.kozaruk-l0cyMroinI0@public.gmane.org>
To: Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
Cc: "tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org"
<tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>,
"benoit.cousson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org"
<benoit.cousson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
"Nayak, Rajendra" <rnayak-l0cyMroinI0@public.gmane.org>,
"Ujfalusi, Peter" <peter.ujfalusi-l0cyMroinI0@public.gmane.org>,
"ABRAHAM, KISHON VIJAY" <kishon-l0cyMroinI0@public.gmane.org>,
"jic23-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org"
<jic23-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org>,
"grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org"
<grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
"rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org"
<rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>,
"sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org"
<sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
"ch.naveen-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org"
<ch.naveen-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>,
"poeschel-Xtl8qvBWbHwb1SvskN2V4Q@public.gmane.org"
<poeschel-Xtl8qvBWbHwb1SvskN2V4Q@public.gmane.org>,
"Kim, Milo" <Milo.Kim-l0cyMroinI0@public.gmane.org>,
"Krishnamoorthy,
Balaji T" <balajitk-l0cyMroinI0@public.gmane.org>,
"gg-kDsPt+C1G03kYMGBc/C6ZA@public.gmane.org"
<gg-kDsPt+C1G03kYMGBc/C6ZA@public.gmane.org>,
"linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org"
<devicetree-dis>
Subject: Re: [PATCH v3 2/2] iio: twl6030-gpadc: TWL6030, TWL6032 GPADC driver
Date: Wed, 17 Jul 2013 16:45:57 +0300 [thread overview]
Message-ID: <51E6A015.8040705@ti.com> (raw)
In-Reply-To: <51E3DE21.9060105-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
On Mon, Jul 15, 2013 at 01:33:53PM +0200, Lars-Peter Clausen wrote:
> On 07/15/2013 01:09 PM, Kozaruk, Oleksandr wrote:
> [...]
> >
> >>> + ret = devm_request_threaded_irq(dev, irq, NULL,
> >>> + twl6030_gpadc_irq_handler,
> >>> + IRQF_ONESHOT, "twl6030_gpadc", gpadc);
> >>
> >> You access memory in the interrupt handler which is freed before
the interrupt
> >> handler is freed.
> > Thanks for pointing this. devm_* will free memory for irq after the
driver
> > is removed and memory for the device is freed. I took me awhile to
understand
> > this. Is there going to be something like devm_iio_device_alloc?
whould it be helpfull?
> >
>
> Yes, I think it certainly makes sense to add a
devm_iio_device_alloc(), care
> to send a patch?
Anything like this? (of course it's not a patch)
struct iio_dev *devm_iio_device_alloc(struct device *dev, int sizeof_priv)
{
struct iio_dev *indio_dev;
size_t alloc_size;
alloc_size = sizeof(struct iio_dev);
if (sizeof_priv) {
alloc_size = ALIGN(alloc_size, IIO_ALIGN);
alloc_size += sizeof_priv;
}
/* ensure 32-byte alignment of whole construct ? */
alloc_size += IIO_ALIGN - 1;
indio_dev = devm_kzalloc(dev, alloc_size, GFP_KERNEL);
if (indio_dev) {
indio_dev->dev.groups = indio_dev->groups;
indio_dev->dev.type = &iio_device_type;
indio_dev->dev.bus = &iio_bus_type;
device_initialize(&indio_dev->dev);
dev_set_drvdata(&indio_dev->dev, (void *)indio_dev);
mutex_init(&indio_dev->mlock);
mutex_init(&indio_dev->info_exist_lock);
INIT_LIST_HEAD(&indio_dev->channel_attr_list);
indio_dev->id = ida_simple_get(&iio_ida, 0, 0, GFP_KERNEL);
if (indio_dev->id < 0) {
/* cannot use a dev_err as the name isn't available */
printk(KERN_ERR "Failed to get id\n");
kfree(dev);
return NULL;
}
dev_set_name(&indio_dev->dev, "iio:device%d", indio_dev->id);
INIT_LIST_HEAD(&indio_dev->buffer_list);
}
return indio_dev;
}
EXPORT_SYMBOL(devm_iio_device_alloc);
Regards,
OK
WARNING: multiple messages have this Message-ID (diff)
From: oleksandr.kozaruk@ti.com (Oleksandr Kozaruk)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 2/2] iio: twl6030-gpadc: TWL6030, TWL6032 GPADC driver
Date: Wed, 17 Jul 2013 16:45:57 +0300 [thread overview]
Message-ID: <51E6A015.8040705@ti.com> (raw)
In-Reply-To: <51E3DE21.9060105@metafoo.de>
On Mon, Jul 15, 2013 at 01:33:53PM +0200, Lars-Peter Clausen wrote:
> On 07/15/2013 01:09 PM, Kozaruk, Oleksandr wrote:
> [...]
> >
> >>> + ret = devm_request_threaded_irq(dev, irq, NULL,
> >>> + twl6030_gpadc_irq_handler,
> >>> + IRQF_ONESHOT, "twl6030_gpadc", gpadc);
> >>
> >> You access memory in the interrupt handler which is freed before
the interrupt
> >> handler is freed.
> > Thanks for pointing this. devm_* will free memory for irq after the
driver
> > is removed and memory for the device is freed. I took me awhile to
understand
> > this. Is there going to be something like devm_iio_device_alloc?
whould it be helpfull?
> >
>
> Yes, I think it certainly makes sense to add a
devm_iio_device_alloc(), care
> to send a patch?
Anything like this? (of course it's not a patch)
struct iio_dev *devm_iio_device_alloc(struct device *dev, int sizeof_priv)
{
struct iio_dev *indio_dev;
size_t alloc_size;
alloc_size = sizeof(struct iio_dev);
if (sizeof_priv) {
alloc_size = ALIGN(alloc_size, IIO_ALIGN);
alloc_size += sizeof_priv;
}
/* ensure 32-byte alignment of whole construct ? */
alloc_size += IIO_ALIGN - 1;
indio_dev = devm_kzalloc(dev, alloc_size, GFP_KERNEL);
if (indio_dev) {
indio_dev->dev.groups = indio_dev->groups;
indio_dev->dev.type = &iio_device_type;
indio_dev->dev.bus = &iio_bus_type;
device_initialize(&indio_dev->dev);
dev_set_drvdata(&indio_dev->dev, (void *)indio_dev);
mutex_init(&indio_dev->mlock);
mutex_init(&indio_dev->info_exist_lock);
INIT_LIST_HEAD(&indio_dev->channel_attr_list);
indio_dev->id = ida_simple_get(&iio_ida, 0, 0, GFP_KERNEL);
if (indio_dev->id < 0) {
/* cannot use a dev_err as the name isn't available */
printk(KERN_ERR "Failed to get id\n");
kfree(dev);
return NULL;
}
dev_set_name(&indio_dev->dev, "iio:device%d", indio_dev->id);
INIT_LIST_HEAD(&indio_dev->buffer_list);
}
return indio_dev;
}
EXPORT_SYMBOL(devm_iio_device_alloc);
Regards,
OK
next prev parent reply other threads:[~2013-07-17 13:47 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-12 7:18 [PATCH v3 0/2] TWL6030, TWL6032 GPADC driver Oleksandr Kozaruk
2013-07-12 7:18 ` Oleksandr Kozaruk
2013-07-12 7:18 ` Oleksandr Kozaruk
2013-07-12 7:18 ` [PATCH v3 1/2] ARM: dts: twl: Add GPADC data to device tree Oleksandr Kozaruk
2013-07-12 7:18 ` Oleksandr Kozaruk
2013-07-12 7:18 ` Oleksandr Kozaruk
2013-07-12 7:18 ` [PATCH v3 2/2] iio: twl6030-gpadc: TWL6030, TWL6032 GPADC driver Oleksandr Kozaruk
2013-07-12 7:18 ` Oleksandr Kozaruk
2013-07-12 7:18 ` Oleksandr Kozaruk
2013-07-12 19:42 ` Jonathan Cameron
2013-07-12 19:42 ` Jonathan Cameron
2013-07-12 19:42 ` Jonathan Cameron
2013-07-15 13:30 ` Kozaruk, Oleksandr
2013-07-15 13:30 ` Kozaruk, Oleksandr
2013-07-15 13:30 ` Kozaruk, Oleksandr
2013-07-15 13:30 ` Kozaruk, Oleksandr
2013-07-15 14:05 ` Graeme Gregory
2013-07-15 14:05 ` Graeme Gregory
2013-07-15 14:05 ` Graeme Gregory
2013-07-15 14:05 ` Graeme Gregory
2013-07-12 19:56 ` Lars-Peter Clausen
2013-07-12 19:56 ` Lars-Peter Clausen
2013-07-12 19:56 ` Lars-Peter Clausen
2013-07-15 11:09 ` Kozaruk, Oleksandr
2013-07-15 11:09 ` Kozaruk, Oleksandr
2013-07-15 11:09 ` Kozaruk, Oleksandr
2013-07-15 11:09 ` Kozaruk, Oleksandr
2013-07-15 11:33 ` Lars-Peter Clausen
2013-07-15 11:33 ` Lars-Peter Clausen
2013-07-15 11:33 ` Lars-Peter Clausen
2013-07-15 11:33 ` Lars-Peter Clausen
2013-07-17 13:45 ` Oleksandr Kozaruk [this message]
2013-07-17 13:45 ` Oleksandr Kozaruk
2013-07-17 13:45 ` Oleksandr Kozaruk
2013-07-17 13:45 ` Oleksandr Kozaruk
2013-07-17 14:47 ` Lars-Peter Clausen
2013-07-17 14:47 ` Lars-Peter Clausen
2013-07-17 14:47 ` Lars-Peter Clausen
2013-07-17 14:47 ` Lars-Peter Clausen
2013-07-15 11:56 ` Grygorii Strashko
2013-07-15 11:56 ` Grygorii Strashko
2013-07-15 11:56 ` Grygorii Strashko
2013-07-15 12:33 ` Lars-Peter Clausen
2013-07-15 12:33 ` Lars-Peter Clausen
2013-07-15 12:33 ` Lars-Peter Clausen
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=51E6A015.8040705@ti.com \
--to=oleksandr.kozaruk@ti.com \
--cc=Milo.Kim@ti.com \
--cc=balajitk@ti.com \
--cc=benoit.cousson@linaro.org \
--cc=ch.naveen@samsung.com \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=gg@slimlogic.co.uk \
--cc=grant.likely@linaro.org \
--cc=jic23@cam.ac.uk \
--cc=kishon@ti.com \
--cc=lars@metafoo.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=peter.ujfalusi@ti.com \
--cc=poeschel@lemonage.de \
--cc=rnayak@ti.com \
--cc=rob.herring@calxeda.com \
--cc=sameo@linux.intel.com \
--cc=tony@atomide.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 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.