All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Alan Cox <alan@linux.intel.com>
Cc: arve@android.com, x86@kernel.org, linux-kernel@vger.kernel.org,
	mikechan@google.com
Subject: Re: [PATCH 02/10] goldfish: add the goldfish virtual bus
Date: Wed, 9 Jan 2013 22:30:40 +0000	[thread overview]
Message-ID: <201301092230.40331.arnd@arndb.de> (raw)
In-Reply-To: <20130109142305.9239.37581.stgit@bob.linux.org.uk>

On Wednesday 09 January 2013, Alan Cox wrote:
> From: Jun Nakajima <jnakajim@gmail.com>
> 
> This imports the current Google code and cleans it up slightly to use pr_ and
> to properly request its resources.
> 
> Goldfish is an emulator used for Android development. It has a virtual bus where
> the emulator passes platform device information to the guest which then creates
> the appropriate devices.
> 
> This part of the emulation is not architecture specific so should not be hiding
> in architecture trees as it does in the Google Android tree. The constants it
> uses do depend on the platform and so live in arch/goldfish.h

Ah, quite nice.

>  drivers/platform/Makefile            |    1 
>  drivers/platform/goldfish/Makefile   |    4 +
>  drivers/platform/goldfish/pdev_bus.c |  265 ++++++++++++++++++++++++++++++++++
>  3 files changed, 270 insertions(+)

Maybe drivers/bus would be more appropriate though. Every platform
handles platforms differently, and x86 seems to be the only one that
likes the model of putting stuff under drivers/platform.

> +static int __devexit goldfish_pdev_bus_remove(struct platform_device *pdev)
> +{
> +	free_irq(pdev_bus_irq, pdev);
> +	release_region(pdev_bus_addr, GOLDFISH_IO_SIZE);
> +	return 0;
> +}
> +
> +static struct platform_driver goldfish_pdev_bus_driver = {
> +	.probe = goldfish_pdev_bus_probe,
> +	.remove = __devexit_p(goldfish_pdev_bus_remove),
> +	.driver = {
> +		.name = "goldfish_pdev_bus"
> +	}
> +};

__devinit/__devexit are going away, so you can skip adding them
for new code.

> +
> +static int __init goldfish_pdev_bus_init(void)
> +{
> +	return platform_driver_register(&goldfish_pdev_bus_driver);
> +}
> +
> +static void __exit goldfish_pdev_bus_exit(void)
> +{
> +	platform_driver_unregister(&goldfish_pdev_bus_driver);
> +}
> +
> +module_init(goldfish_pdev_bus_init);
> +module_exit(goldfish_pdev_bus_exit);

The module_platform_driver() macro takes care of this.

> +static struct resource goldfish_pdev_bus_resources[] = {
> +	{
> +		.start  = GOLDFISH_PDEV_BUS_BASE,
> +		.end    = GOLDFISH_PDEV_BUS_BASE + GOLDFISH_PDEV_BUS_END - 1,
> +		.flags  = IORESOURCE_IO,
> +	},
> +	{
> +		.start	= GOLDFISH_PDEV_BUS_IRQ,
> +		.end	= GOLDFISH_PDEV_BUS_IRQ,
> +		.flags	= IORESOURCE_IRQ,
> +	}
> +};
> +
> +struct platform_device goldfish_pdev_bus_device = {
> +	.name = "goldfish_pdev_bus",
> +	.id = -1,
> +	.num_resources = ARRAY_SIZE(goldfish_pdev_bus_resources),
> +	.resource = goldfish_pdev_bus_resources
> +};
> +
> +static int __init goldfish_init(void)
> +{
> +	return platform_device_register(&goldfish_pdev_bus_device);
> +}
> +device_initcall(goldfish_init);

This is the part that I think should actually be part of the architecture
tree. That way, no architecture specific header files will be necessary,
and it's possible to create the platform device differently, e.g. from
devicetree on architectures that support it, or from ACPI.

Note that statically declaring a platform device is not recommended any
more, a call to platform_device_register_simple() makes this code
simpler and smaller, and allows proper reference counting on the device.

	Arnd

  reply	other threads:[~2013-01-09 22:30 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-09 14:22 [PATCH 00/10] goldfish: rebase/resend versus current -next Alan Cox
2013-01-09 14:22 ` [PATCH 01/10] goldfish: definitions for Goldfish on x86 platforms Alan Cox
2013-01-09 14:23 ` [PATCH 02/10] goldfish: add the goldfish virtual bus Alan Cox
2013-01-09 22:30   ` Arnd Bergmann [this message]
2013-01-10 15:54     ` Alan Cox
2013-01-09 14:23 ` [PATCH 03/10] goldfish: tty driver Alan Cox
2013-01-09 22:33   ` Arnd Bergmann
2013-01-09 14:24 ` [PATCH 04/10] goldfish: virtual input event driver Alan Cox
2013-01-09 14:24 ` [PATCH 05/10] goldfish: framebuffer Alan Cox
2013-01-09 14:24 ` [PATCH 06/10] goldfish: emulated MMC device Alan Cox
2013-01-09 14:25 ` [PATCH 07/10] goldfish: power device Alan Cox
2013-01-09 14:25 ` [PATCH 08/10] goldfish: real time clock Alan Cox
2013-01-09 14:25 ` [PATCH 09/10] goldfish: add QEMU pipe driver Alan Cox
2013-01-09 14:26 ` [PATCH 10/10] goldfish: NAND flash driver Alan Cox
2014-03-10 15:39 ` [PATCH 00/10] goldfish: rebase/resend versus current -next Guennadi Liakhovetski
  -- strict thread matches above, loose matches on Subject: below --
2013-01-16 16:58 [PATCH 00/10] goldfish: still swimming Alan Cox
2013-01-16 16:58 ` [PATCH 02/10] goldfish: add the goldfish virtual bus Alan Cox
2013-01-16 16:57   ` Felipe Balbi
2013-01-17 17:53 [PATCH 00/10] goldish: onwards, upwards 8) Alan Cox
2013-01-17 17:54 ` [PATCH 02/10] goldfish: add the goldfish virtual bus Alan Cox

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=201301092230.40331.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=alan@linux.intel.com \
    --cc=arve@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mikechan@google.com \
    --cc=x86@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.