public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Russell King <rmk+lkml@arm.linux.org.uk>
To: Pierre Ossman <drzeus-list@drzeus.cx>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] MMC host class
Date: Fri, 15 Jul 2005 09:31:15 +0100	[thread overview]
Message-ID: <20050715093114.B25428@flint.arm.linux.org.uk> (raw)
In-Reply-To: <42D538D4.7050803@drzeus.cx>; from drzeus-list@drzeus.cx on Wed, Jul 13, 2005 at 05:52:52PM +0200

On Wed, Jul 13, 2005 at 05:52:52PM +0200, Pierre Ossman wrote:
> Create a mmc_host class to allow enumeration of MMC host controllers
> even though they have no card(s) inserted.
> 
> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
> 
> (This will also allow cards to be enumerated by being able to find the
> hosts.)

> +static void mmc_host_class_dev_release(struct class_device *dev)
> +{
> +}
> +
> +static struct class mmc_host_class = {
> +	.name =		"mmc_host",
> +	.release =	&mmc_host_class_dev_release,
> +};

No no no no no.  Repeat after me ten times.  Empty or non-existant release
functions are bad and cause oopsen.  I will not create code which does
this.

> Index: linux-wbsd/include/linux/mmc/host.h
> ===================================================================
> --- linux-wbsd/include/linux/mmc/host.h	(revision 153)
> +++ linux-wbsd/include/linux/mmc/host.h	(working copy)
> @@ -69,6 +69,7 @@
>  
>  struct mmc_host {
>  	struct device		*dev;
> +	struct class_device	class_dev;
>  	struct mmc_host_ops	*ops;
>  	unsigned int		f_min;
>  	unsigned int		f_max;

What this means is that mmc_host itself becomes a refcounted sysfs
object which needs to follow the lifetime rules associated therewith.

Luckily, I thought about this earlier on, so there's a core mmc function
to allocate the beast, register it, unregister it, and finally free it.

The allocation function should initialise class_dev as much as possible.
The registration function should add the class device with the class
model.  The unregistration should remove the class device from the class
model, but _not_ free it.  The free function should drop the last
reference to the class device, which results in the remove function
(eventually) being called.  Finally, the remove function can free the
mmc_host.

Also note that since we have a class_dev, the mmc_host 'dev' field can
be removed.  However, we'll probably have to update the host drivers
to do this, so it should be a separate patch.

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 Serial core

  reply	other threads:[~2005-07-15  8:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-13 15:52 [PATCH] MMC host class Pierre Ossman
2005-07-15  8:31 ` Russell King [this message]
2005-07-15 12:26   ` Pierre Ossman
2005-07-15 20:21   ` Pierre Ossman
2005-07-18 17:45     ` Russell King
2005-07-18 18:22       ` Pierre Ossman
2005-08-08 11:38       ` Pierre Ossman
2005-08-18 23:09         ` Russell King
2005-08-19  6:14           ` Pierre Ossman
2005-08-19  7:49             ` Russell King

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=20050715093114.B25428@flint.arm.linux.org.uk \
    --to=rmk+lkml@arm.linux.org.uk \
    --cc=drzeus-list@drzeus.cx \
    --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