lkml.org 
[lkml]   [2004]   [Jun]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/3] Add platform_device_register_simple
On Thu, Jun 10, 2004 at 01:43:51AM -0500, Dmitry Torokhov wrote:
> ChangeSet@1.1767, 2004-06-09 23:58:52-05:00, dtor_core@ameritech.net
> sysfs: add platform_device_register_simple() that creates a simple
> platform device that does not manage any resources. Modules
> using such platform devices can be unloaded without waiting
> for the device to me released (but any additional resources
> allocated by module should be freed beforehand).

What about platform devices which have resources associated with them?

> +struct platform_device *platform_device_register_simple(char *name, unsigned int id)
> +{
> + struct platform_device *pdev;
> + int retval;
> +
> + pdev = kmalloc(sizeof(*pdev), GFP_KERNEL);
> + if (!pdev) {
> + retval = -ENOMEM;
> + goto error;
> + }
> +
> + memset(pdev, 0, sizeof(*pdev));
> + pdev->name = name;
> + pdev->id = id;
> + pdev->dev.release = platform_device_release_simple;
> +
> + retval = platform_device_register(pdev);
> + if (retval)
> + goto error;
> +
> + return pdev;
> +
> +error:
> + kfree(pdev);
> + return ERR_PTR(retval);

As this currently stands, you have no chance to add resources to the
platform device before it's made available to the driver. It's likely
that any attached resources will have the same lifetime as the
device itself, so it makes sense to allocate them together with the
platform device.

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 PCMCIA - http://pcmcia.arm.linux.org.uk/
2.6 Serial core
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:03    [W:0.076 / U:0.120 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site