All of lore.kernel.org
 help / color / mirror / Atom feed
From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.arm.linux.org.uk,
	linux-omap@vger.kernel.org
Subject: Re: [PATCH 3/6] omap iommu: omap3 iommu device registration
Date: Sat, 17 Jan 2009 16:21:39 +0000	[thread overview]
Message-ID: <20090117162139.GB12341@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <20090116083719.18344.28959.stgit@oreo.research.nokia.com>

On Fri, Jan 16, 2009 at 10:37:20AM +0200, Hiroshi DOYU wrote:
> +#include <linux/io.h>

Is linux/io.h needed, or will a more specific include be better?

> +#include <linux/platform_device.h>
> +
> +#include <mach/iommu.h>
> +
> +#define DEVNAME "omap-iommu"

I'm not sure this DEVNAME definition really helps anything.

> +static void omap3_iommu_release(struct device *dev)
> +{
> +}

Err, no.  Never ever ever provide a NULL release function.  Providing
such a function is a screaming message that what you're doing is buggy.

And if you get a warning through not providing such a function, it's
telling you that what your overall approach with the driver API is
buggy (and you haven't understood the implications of refcounted
object management.)

> +
> +static struct platform_device omap3_iommu_pdev[] = {
> +	{
> +		.name		= DEVNAME,
> +		.id		= 1,
> +		.num_resources	= ARRAY_SIZE(iommu1_res),
> +		.resource	= iommu1_res,
> +		.dev		= {
> +			.release = omap3_iommu_release,
> +			.platform_data = &omap3_iommu_pdata[0],
> +		},
> +	},
> +	{
> +		.name		= DEVNAME,
> +		.id		= 2,
> +		.num_resources	= ARRAY_SIZE(iommu2_res),
> +		.resource	= iommu2_res,
> +		.dev		= {
> +			.release = omap3_iommu_release,
> +			.platform_data = &omap3_iommu_pdata[1],
> +		},
> +	},
> +};
> +
> +static int __init omap3_iommu_init(void)
> +{
> +	int i;
> +	for (i = 0; i < ARRAY_SIZE(omap3_iommu_pdev); i++)
> +		platform_device_register(&omap3_iommu_pdev[i]);
> +	return 0;
> +}
> +module_init(omap3_iommu_init);
> +
> +static void __exit omap3_iommu_exit(void)
> +{
> +	int i;
> +	for (i = 0; i < ARRAY_SIZE(omap3_iommu_pdev); i++)
> +		platform_device_unregister(&omap3_iommu_pdev[i]);

So... this can never be bug free - you can _never_ unregister statically
allocated devices.  Not even if you provide an empty release function.

If you want to register and unregister device structures, it must be
done using the correct APIs, and in the case of platform devices, that's
the platform_device_alloc(), platform_device_add() and
platform_device_unregister() APIs.

  reply	other threads:[~2009-01-17 16:22 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-16  8:37 [PATCH 0/6] arm: omap iommu: add initial support Hiroshi DOYU
2009-01-16  8:37 ` [PATCH 1/6] omap iommu: tlb and pagetable primitives Hiroshi DOYU
2009-01-17 16:06   ` Russell King - ARM Linux
2009-01-17 20:48     ` David Brownell
2009-01-17 20:48       ` David Brownell
2009-01-19  9:44       ` Hiroshi DOYU
2009-01-19  9:44         ` Hiroshi DOYU
2009-01-19 21:58         ` Russell King - ARM Linux
2009-01-19 21:58           ` Russell King - ARM Linux
2009-01-19 22:42           ` David Brownell
2009-01-26 13:41     ` Hiroshi DOYU
2009-01-27 21:31     ` Hiroshi DOYU
2009-01-16  8:37 ` [PATCH 2/6] omap iommu: omap2 architecture specific functions Hiroshi DOYU
2009-01-16  8:37 ` [PATCH 3/6] omap iommu: omap3 iommu device registration Hiroshi DOYU
2009-01-17 16:21   ` Russell King - ARM Linux [this message]
2009-01-27 21:29     ` Hiroshi DOYU
2009-01-28 10:41       ` Russell King - ARM Linux
2009-01-28 11:37         ` Hiroshi DOYU
2009-01-16  8:37 ` [PATCH 4/6] omap iommu: simple virtual address space management Hiroshi DOYU
2009-01-17 16:57   ` Russell King - ARM Linux
2009-01-27 21:29     ` Hiroshi DOYU
2009-01-16  8:37 ` [PATCH 5/6] omap iommu: entries for Kconfig and Makefile Hiroshi DOYU
2009-01-16  8:37 ` [PATCH 6/6] omap2 " Hiroshi DOYU
2009-01-17 16:59   ` Russell King - ARM Linux
2009-01-22 15:02     ` Hiroshi DOYU
2009-05-05 12:46 [PATCH 0/6] Initial support for omap iommu driver Hiroshi DOYU
2009-05-05 12:47 ` [PATCH 3/6] omap iommu: omap3 iommu device registration Hiroshi DOYU
2009-05-05 19:32   ` Felipe Contreras
2009-05-06  6:00     ` Hiroshi DOYU
2009-05-07 20:02       ` Felipe Contreras
2009-05-07 20:05   ` Felipe Contreras
2009-05-08  4:10     ` Hiroshi DOYU
2009-05-08  7:32       ` Felipe Contreras
2009-05-08 17:21         ` Aguirre Rodriguez, Sergio Alberto
2009-05-08 22:27           ` Felipe Contreras
2009-05-16  9:20   ` Russell King - ARM Linux
2009-05-16  9:38     ` Felipe Contreras
2009-05-16  9:54       ` Russell King - ARM Linux
2009-05-16  9:56         ` Felipe Contreras
2009-05-16  9:55     ` Russell King - ARM Linux
2009-05-18  5:36       ` Hiroshi DOYU
2009-05-18  9:39       ` Hiroshi DOYU
2009-05-18 14:26       ` Hiroshi DOYU
2009-05-18  5:22     ` Hiroshi DOYU

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=20090117162139.GB12341@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=Hiroshi.DOYU@nokia.com \
    --cc=linux-arm-kernel@lists.arm.linux.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.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.