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 0/3] Couple of sysfs patches
Date: Thu, 10 Jun 2004 17:06:07 +0100	[thread overview]
Message-ID: <20040610170607.A5830@flint.arm.linux.org.uk> (raw)
In-Reply-To: <20040610144658.31403.qmail@web81309.mail.yahoo.com>; from dtor_core@ameritech.net on Thu, Jun 10, 2004 at 07:46:58AM -0700

On Thu, Jun 10, 2004 at 07:46:58AM -0700, Dmitry Torokhov wrote:
> Russell King wrote:
> > On Thu, Jun 10, 2004 at 07:55:59AM -0500, Dmitry Torokhov wrote:
> > > On Thursday 10 June 2004 05:16 am, Russell King wrote:
> > > >
> > > > 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.
> > > >
> > >
> > > Are you suggesting adding pointer to resources as a 3rd argument and
> > > automotically release it for the user? It probably could be done but users
> > > will be tempted to use static module data and bad things would happen.
> > 
> > Please read my second sentence again.  It implies a copy of the resources
> > is kept with the platform device, so both have the same lifetime.
> > 
> 
> Ok, so function pointer to allocate resources and associate with the
> device? You can't just allocate memory for resources structure, you
> need to populate it with data if you want it to be used by a driver
> immediately after registration... And have actually release all
> resources, not only memory? It is getting beyond the "*_simple"
> approach though.
> 
> Or do I still misunderstand you?

Something like:

struct platform_object {
	struct platform_device pdev;
	struct resource resources[0];
};

struct platform_device *platform_device_register_simple(char *name, unsigned int id, struct resource *res, int num)
{
	struct platform_object *pobj;
	int retval;

	pobj = kmalloc(sizeof(struct platform_object) + sizeof(struct resource) * num, GFP_KERNEL);
	if (!pobj) {
		retval = -ENOMEM;
		goto error;
	}

	memset(pobj, 0, sizeof(*pdev));
	pobj->pdev.name = name;
	pobj->pdev.id = id;
	pobj->pdev.dev.release = platform_device_release_simple;

	if (num) {
		memcpy(pobj->resources, res, sizeof(struct resource) * num);
		pobj->pdev.resource = pobj->resources;
		pobj->pdev.num_resources = num;
	}

ARM is going very much down this route, and we're also going to need these
things dynamically allocated as you do, but with the resource stuff.  So
rather than putting in something which only satisfies your problem, and
then adding yet more interfaces to cover the extra resources, we should
be thinking about something sane from the beginning.

Now that I can see the platform device interfaces multipling like rabbits,
(to GregKH) I think that the patch I submitted for platform_add_device
suffers from this problem as well, and I should've thrown that code
into platform_register_device itself.

Greg - comments?  Would you like a new patch which does that, or do you
think that's too risky?

-- 
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

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

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-10 14:46 [PATCH 0/3] Couple of sysfs patches Dmitry Torokhov
2004-06-10 16:06 ` Russell King [this message]
2004-06-10 16:14   ` Greg KH
2004-06-10 18:17     ` Russell King
2004-06-10 20:25       ` Russell King
2004-06-16 22:51         ` Dmitry Torokhov
2004-06-18 19:29           ` Russell King
2004-06-18 20:39             ` Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2004-06-18 19:59 Dmitry Torokhov
2004-06-09  7:21 Dmitry Torokhov
2004-06-09 22:13 ` 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

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=20040610170607.A5830@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