lkml.org 
[lkml]   [2009]   [Jan]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/1] mmc: add MODALIAS linkage for MMC/SD devices
Date
Currently we are using an explicit udev rule to trigger loading of the
mmc-block module when an MMC or SD card is detected:

SUBSYSTEM=="mmc", RUN+="/sbin/modprobe -Qba mmc-block"

It makes much more sense for the mmc bus driver and the mmc-block module to
share MODALIAS information so that they are linked automatically.

Add MODALIAS attributes to the uevents as generated, and add the
corresponding MODULE_ALIAS marks to the mmc-block module so that it is
automatically loaded by udev. I have followed the example set by the
SCSI subsystem in pushing out numeric typed aliases:

mmc:t-0xNN

Where NN is the MMC type as defined in include/linux/mmc/card.h.
Numeric types are used to allow automatic handling of new unknown types
in the core. The matches are open on the right to allow additional
fields to be added as required in the future.

Signed-off-by: Andy Whitcroft <apw@canonical.com>
---
drivers/mmc/card/block.c | 3 +++
drivers/mmc/core/bus.c | 5 +++++
include/linux/mmc/card.h | 10 +++++++---
3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 45b1f43..5d1c5ad 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -41,6 +41,9 @@

#include "queue.h"

+MODULE_ALIAS_MMC_DEVICE(MMC_TYPE_MMC);
+MODULE_ALIAS_MMC_DEVICE(MMC_TYPE_SD);
+
/*
* max 8 partitions per card
*/
diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
index f210a8e..35ec7c3 100644
--- a/drivers/mmc/core/bus.c
+++ b/drivers/mmc/core/bus.c
@@ -84,6 +84,11 @@ mmc_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
}

retval = add_uevent_var(env, "MMC_NAME=%s", mmc_card_name(card));
+ if (retval)
+ return retval;
+
+ retval = add_uevent_var(env, "MODALIAS=" MMC_DEVICE_MODALIAS_FMT,
+ card->type);

return retval;
}
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
index 403aa50..97a461e 100644
--- a/include/linux/mmc/card.h
+++ b/include/linux/mmc/card.h
@@ -86,9 +86,9 @@ struct mmc_card {
struct device dev; /* the device */
unsigned int rca; /* relative card address of device */
unsigned int type; /* card type */
-#define MMC_TYPE_MMC 0 /* MMC card */
-#define MMC_TYPE_SD 1 /* SD card */
-#define MMC_TYPE_SDIO 2 /* SDIO card */
+#define MMC_TYPE_MMC 0x00 /* MMC card */
+#define MMC_TYPE_SD 0x01 /* SD card */
+#define MMC_TYPE_SDIO 0x02 /* SDIO card */
unsigned int state; /* (our) card state */
#define MMC_STATE_PRESENT (1<<0) /* present in sysfs */
#define MMC_STATE_READONLY (1<<1) /* card is read-only */
@@ -150,4 +150,8 @@ struct mmc_driver {
extern int mmc_register_driver(struct mmc_driver *);
extern void mmc_unregister_driver(struct mmc_driver *);

+#define MODULE_ALIAS_MMC_DEVICE(type) \
+ MODULE_ALIAS("mmc:t-" __stringify(type) "*")
+#define MMC_DEVICE_MODALIAS_FMT "mmc:t-0x%02x"
+
#endif
--
1.6.0.4.911.gc990


\
 
 \ /
  Last update: 2009-01-06 19:59    [W:0.094 / U:0.776 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site