Re: [PATCH] sparc64: modalias support for of_device

From: Kyle McMartin
Date: Mon Apr 16 2007 - 02:26:09 EST


On Mon, Apr 16, 2007 at 12:19:33AM -0400, Kyle McMartin wrote:
>

Updated patch to rename modalias_show to of_modalias_show, and
add the same code to arch/sparc. (Amusingly enough, just edited
sparc64 to sparc in the diff and it re-applied. :)

Cheers,
Kyle

diff --git a/arch/sparc/kernel/of_device.c b/arch/sparc/kernel/of_device.c
index 48c24f7..fd4585e 100644
--- a/arch/sparc/kernel/of_device.c
+++ b/arch/sparc/kernel/of_device.c
@@ -148,6 +148,19 @@ struct of_device *of_find_device_by_node(struct device_node *dp)
}
EXPORT_SYMBOL(of_find_device_by_node);

+static ssize_t of_modalias_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ ssize_t len;
+ struct of_device *d = to_of_device(dev);
+ struct device_node *node = d->node;
+
+ len = sprintf(buf, "of:N%sT%sC%s\n",
+ node->name, node->type, "*");
+
+ return len;
+}
+
#ifdef CONFIG_PCI
struct bus_type ebus_bus_type = {
.name = "ebus",
@@ -172,9 +185,15 @@ struct bus_type sbus_bus_type = {
EXPORT_SYMBOL(sbus_bus_type);
#endif

+static struct device_attribute of_dev_attrs[] = {
+ __ATTR(modalias, 0444, of_modalias_show, NULL),
+ __ATTR_NULL
+};
+
struct bus_type of_bus_type = {
.name = "of",
.match = of_platform_bus_match,
+ .dev_attrs = of_dev_attrs,
.probe = of_device_probe,
.remove = of_device_remove,
.suspend = of_device_suspend,
diff --git a/arch/sparc64/kernel/of_device.c b/arch/sparc64/kernel/of_device.c
index fb9bf1e..ab5c6dc 100644
--- a/arch/sparc64/kernel/of_device.c
+++ b/arch/sparc64/kernel/of_device.c
@@ -173,6 +173,19 @@ struct of_device *of_find_device_by_node(struct device_node *dp)
}
EXPORT_SYMBOL(of_find_device_by_node);

+static ssize_t of_modalias_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ ssize_t len;
+ struct of_device *d = to_of_device(dev);
+ struct device_node *node = d->node;
+
+ len = sprintf(buf, "of:N%sT%sC%s\n",
+ node->name, node->type, "*");
+
+ return len;
+}
+
#ifdef CONFIG_PCI
struct bus_type isa_bus_type = {
.name = "isa",
@@ -207,9 +220,15 @@ struct bus_type sbus_bus_type = {
EXPORT_SYMBOL(sbus_bus_type);
#endif

+static struct device_attribute of_dev_attrs[] = {
+ __ATTR(modalias, 0444, of_modalias_show, NULL),
+ __ATTR_NULL
+};
+
struct bus_type of_bus_type = {
.name = "of",
.match = of_platform_bus_match,
+ .dev_attrs = of_dev_attrs,
.probe = of_device_probe,
.remove = of_device_remove,
.suspend = of_device_suspend,
-
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/