public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Russell King <rmk+lkml@arm.linux.org.uk>
To: Dmitry Torokhov <dtor_core@ameritech.net>
Cc: Greg KH <greg@kroah.com>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] Add platform_device_register_simple
Date: Thu, 10 Jun 2004 11:16:23 +0100	[thread overview]
Message-ID: <20040610111623.D20006@flint.arm.linux.org.uk> (raw)
In-Reply-To: <200406100143.53381.dtor_core@ameritech.net>; from dtor_core@ameritech.net on Thu, Jun 10, 2004 at 01:43:51AM -0500

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

  parent reply	other threads:[~2004-06-10 10:16 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-09  7:21 [PATCH 0/3] Couple of sysfs patches Dmitry Torokhov
2004-06-09  7:22 ` [PATCH 1/3] whitespace fixes in drivers/base Dmitry Torokhov
2004-06-09  7:24   ` [PATCH 2/3] Suppress platform device suffixes Dmitry Torokhov
2004-06-09  7:25     ` [PATCH 3/3] Add platform_device_simple_release Dmitry Torokhov
2004-06-09 22:13 ` [PATCH 0/3] Couple of sysfs patches Greg KH
     [not found]   ` <200406091732.28684.dtor_core@ameritech.net>
2004-06-09 22:45     ` Greg KH
     [not found]       ` <200406091754.23303.dtor_core@ameritech.net>
2004-06-09 23:19         ` Greg KH
2004-06-10  6:40           ` Dmitry Torokhov
2004-06-10  6:42             ` [PATCH 1/3] Suppress platform device suffixes - take 2 Dmitry Torokhov
2004-06-10  6:43               ` [PATCH 2/3] Add platform_device_register_simple Dmitry Torokhov
2004-06-10  6:44                 ` [PATCH 3/3] Whitespace fixes Dmitry Torokhov
2004-06-10  6:46                   ` [PATCH 4/3] Allow registering device without taking bus lock Dmitry Torokhov
2004-06-10 10:14                     ` Russell King
2004-06-10 16:02                     ` Greg KH
2004-06-10 16:26                   ` [PATCH 3/3] Whitespace fixes Greg KH
2004-06-10 10:16                 ` Russell King [this message]
     [not found]                   ` <200406100755.59943.dtor_core@ameritech.net>
2004-06-10 13:56                     ` [PATCH 2/3] Add platform_device_register_simple Russell King
2004-06-10 16:04                 ` Greg KH
2004-06-10 16:19               ` [PATCH 1/3] Suppress platform device suffixes - take 2 Greg KH

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=20040610111623.D20006@flint.arm.linux.org.uk \
    --to=rmk+lkml@arm.linux.org.uk \
    --cc=dtor_core@ameritech.net \
    --cc=greg@kroah.com \
    --cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox