[PATCH] add support of the 'mmc.type' parameter

Andy Shevchenko andy at smile.org.ua
Tue Feb 26 06:39:00 PST 2008


In the recent Linux kernel (starting from 2.6.24) the MMC support stuff
contains new sysfs file. This file represents the type of the MMC card
including SDIO cards. The goal of the patch is to add this field to the mmc
namespace in the HAL.
---
 doc/spec/hal-spec-properties.xml |    8 ++++++++
 hald/linux/device.c              |   20 +++++++++++++++-----
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/doc/spec/hal-spec-properties.xml b/doc/spec/hal-spec-properties.xml
index f3e5752..4e4ccf3 100644
--- a/doc/spec/hal-spec-properties.xml
+++ b/doc/spec/hal-spec-properties.xml
@@ -1833,6 +1833,14 @@ org.freedesktop.Hal.Device.Volume.method_signatures = {'ssas', 'as', 'as'}
               <entry>Yes</entry>
               <entry>Firmware revision</entry>
             </row>
+            <row>
+              <entry>
+                <literal>mmc.type</literal> (string)
+              </entry>
+              <entry>example: SDIO</entry>
+              <entry>No</entry>
+              <entry>Card type</entry>
+            </row>
           </tbody>
         </tgroup>
       </informaltable>
diff --git a/hald/linux/device.c b/hald/linux/device.c
index c566914..6651794 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -2253,7 +2253,7 @@ mmc_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_de
 	HalDevice *d;
 	const gchar *bus_id;
 	gint host_num, rca, manfid, oemid;
-	gchar *scr;
+	gchar *scr, *type;
 
 	if (parent_dev == NULL) {
 		d = NULL;
@@ -2275,6 +2275,11 @@ mmc_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_de
 	hal_util_set_string_from_file (d, "mmc.cid", sysfs_path, "cid");
 	hal_util_set_string_from_file (d, "mmc.csd", sysfs_path, "csd");
 	
+	type = hal_util_get_string_from_file (sysfs_path, "type");
+	if (type != NULL)
+		/* Possible MMC/SD/SDIO */
+		hal_device_property_set_string (d, "mmc.type", type);
+
 	scr = hal_util_get_string_from_file (sysfs_path, "scr");
 	if (scr != NULL) {
 		if (strcmp (scr, "0000000000000000") == 0)
@@ -2284,12 +2289,17 @@ mmc_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_de
 	}
 
 	if (!hal_util_set_string_from_file (d, "info.product", sysfs_path, "name")) {
-		if (scr != NULL) {
-			hal_device_property_set_string (d, "info.product", "SD Card");
-			hal_device_property_set_string (d, "mmc.product", "SD Card");
+		gchar buf[64];
+		if (type != NULL) {
+			g_snprintf(buf, sizeof(buf), "%s Card", type);
+			hal_device_property_set_string (d, "info.product", buf);
+		} else if (scr != NULL) {
+			g_snprintf(buf, sizeof(buf), "SD Card");
+			hal_device_property_set_string (d, "info.product", buf);
 		} else {
-			hal_device_property_set_string (d, "mmc.product", "MMC Card");
+			g_snprintf(buf, sizeof(buf), "MMC Card");
                 }
+		hal_device_property_set_string (d, "mmc.product", buf);
 	}
 	
 	if (hal_util_get_int_from_file (sysfs_path, "manfid", &manfid, 16)) {
-- 
1.5.2.5



More information about the hal mailing list