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

Andy Shevchenko andy at smile.org.ua
Mon Feb 25 04:11:17 PST 2008


---
 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..e1e1763 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> (int)
+              </entry>
+              <entry>example: SDIO</entry>
+              <entry>Yes</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