[lkml]   [2005]   [Jul]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] MMC host class
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 <>
> (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

> 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

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 -
maintainer of: 2.6 Serial core
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-07-15 10:35    [W:0.098 / U:0.648 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site