[PATCH 1/1] mmc: add MODALIAS linkage for MMC/SD devices

From: Andy Whitcroft
Date: Tue Jan 27 2009 - 07:12:20 EST


[Here is an updated patch which only uses information already exported in
the ABI.]

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. Following discussion it was decided to
expose the textual types, and so I have followed the example set by
the dmi: aliases for handling text. The aliases are of the following
form:

mmc:t<type>:

For example:

mmc:tMMC:

The entry ends with a separator (:) in order to allow simple differentiation
between common prefixes such as SD and SDIO in MODULE_ALIAS declarations.

Signed-off-by: Andy Whitcroft <apw@xxxxxxxxxxxxx>
---
drivers/mmc/card/block.c | 3 +++
drivers/mmc/core/bus.c | 5 +++++
2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 3d067c3..9799273 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -41,6 +41,9 @@

#include "queue.h"

+MODULE_ALIAS("mmc:tMMC:*");
+MODULE_ALIAS("mmc:tSD:*");
+
/*
* max 8 partitions per card
*/
diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
index f210a8e..7b34c00 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:t%s:",
+ (type) ? type : "UNKNOWN");

return retval;
}
--
1.6.1.258.g7ff14.dirty

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/