Skip to contentSkip to conversation

Add modalias to macio sysfs attributes

PATCH In review Olaf Hering 2 participants 4 messages Oct 10, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add modalias to macio sysfs attributes

Provide a "compatible" entry in /sys/bus/macio/devices/*/ This can be used to load drivers via the modules.alias file.

Author: <[email protected]>

drivers/macintosh/macio_sysfs.c renamed from drivers/macintosh/macio_sysfs.c.~1~ +26 -0
@@ -39,6 +39,31 @@ compatible_show (struct device *dev, str
 	return length;
 }
 
+static ssize_t modalias_show (struct device *dev, struct device_attribute *attr,
+			      char *buf)
+{
+	struct of_device *of;
+	char *compat;
+	int cplen;
+	int length;
+
+	of = &to_macio_device (dev)->ofdev;
+	compat = (char *) get_property (of->node, "compatible", &cplen);
+	if (!compat) compat = "", cplen = 1;
+	length = sprintf (buf, "of:N%sT%s", of->node->name, of->node->type);
+	buf += length;
+	while (cplen > 0) {
+		int l;
+		length += sprintf (buf, "C%s", compat);
+		buf += length;
+		l = strlen (compat) + 1;
+		compat += l;
+		cplen -= l;
+	}
+
+	return length;
+}
+
 macio_config_of_attr (name, "%s\n");
 macio_config_of_attr (type, "%s\n");
 
@@ -46,5 +71,6 @@ struct device_attribute macio_dev_attrs[
 	__ATTR_RO(name),
 	__ATTR_RO(type),
 	__ATTR_RO(compatible),
+	__ATTR_RO(modalias),
 	__ATTR_NULL
 };
Signature · 2 lines
short story of a lazy sysadmin:
 alias appserv=wotan
#1 lore raw

PATCH 1/1 Add modalias for pmac network drivers

mesh, mac53c94 and airport already have an entry.
Add the network drivers for pmac.

 drivers/net/bmac.c                   |    1 +
 drivers/net/mace.c                   |    1 +
drivers/net/bmac.c +1 -0
Index: linux-2.6.12/drivers/net/bmac.c
===================================================================
@@ -1658,6 +1658,7 @@ static struct of_device_id bmac_match[] 
 	},
 	{},
 };
+MODULE_DEVICE_TABLE (of, bmac_match);
 
 static struct macio_driver bmac_driver = 
 {
drivers/net/mace.c +1 -0
Index: linux-2.6.12/drivers/net/mace.c
===================================================================
@@ -1016,6 +1016,7 @@ static struct of_device_id mace_match[] 
 	},
 	{},
 };
+MODULE_DEVICE_TABLE (of, mace_match);
 
 static struct macio_driver mace_driver = 
 {
Signature · 2 lines
short story of a lazy sysadmin:
 alias appserv=wotan
Acked-by on v1 1/1
#2 lore raw

Re: [PATCH] Add modalias for pmac network drivers

Quoted 4 lines · Olaf Hering

mesh, mac53c94 and airport already have an entry.
Add the network drivers for pmac.

Quoted 28 lines
 drivers/net/bmac.c                   |    1 +
 drivers/net/mace.c                   |    1 +

Index: linux-2.6.12/drivers/net/bmac.c
===================================================================

drivers/net/bmac.c +1 -0
@@ -1658,6 +1658,7 @@ static struct of_device_id bmac_match[] 
 	},
 	{},
 };
+MODULE_DEVICE_TABLE (of, bmac_match);
 
 static struct macio_driver bmac_driver = 
 {

Index: linux-2.6.12/drivers/net/mace.c
===================================================================

drivers/net/mace.c +1 -0
@@ -1016,6 +1016,7 @@ static struct of_device_id mace_match[] 
 	},
 	{},
 };
+MODULE_DEVICE_TABLE (of, mace_match);
 
 static struct macio_driver mace_driver = 
 {
Acked-by on v1 1/1
#3 lore raw
In reply to Olaf Hering
Quoted 5 lines · Olaf Hering

Provide a "compatible" entry in /sys/bus/macio/devices/*/ This can be used to load drivers via the modules.alias file.

Author: <[email protected]>

Quoted 41 lines
drivers/macintosh/macio_sysfs.c renamed from drivers/macintosh/macio_sysfs.c.~1~ +26 -0
@@ -39,6 +39,31 @@ compatible_show (struct device *dev, str
 	return length;
 }
 
+static ssize_t modalias_show (struct device *dev, struct device_attribute *attr,
+			      char *buf)
+{
+	struct of_device *of;
+	char *compat;
+	int cplen;
+	int length;
+
+	of = &to_macio_device (dev)->ofdev;
+	compat = (char *) get_property (of->node, "compatible", &cplen);
+	if (!compat) compat = "", cplen = 1;
+	length = sprintf (buf, "of:N%sT%s", of->node->name, of->node->type);
+	buf += length;
+	while (cplen > 0) {
+		int l;
+		length += sprintf (buf, "C%s", compat);
+		buf += length;
+		l = strlen (compat) + 1;
+		compat += l;
+		cplen -= l;
+	}
+
+	return length;
+}
+
 macio_config_of_attr (name, "%s\n");
 macio_config_of_attr (type, "%s\n");
 
@@ -46,5 +71,6 @@ struct device_attribute macio_dev_attrs[
 	__ATTR_RO(name),
 	__ATTR_RO(type),
 	__ATTR_RO(compatible),
+	__ATTR_RO(modalias),
 	__ATTR_NULL
 };