Re: [PATCH] MMC host class

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <[email protected]>
> 
> (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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]
  Powered by Linux