Commit bf54a2b3c0dbf76136f00ff785bf6d8f6291311d

Authored by Geert Uytterhoeven
1 parent 0b7f1a7efb

m68k: amiga - Zorro bus modalias support

Add Amiga Zorro bus modalias and uevent support

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>

Showing 12 changed files with 66 additions and 12 deletions Side-by-side Diff

... ... @@ -674,6 +674,7 @@
674 674 { ZORRO_PROD_AMERISTAR_A2065 },
675 675 { 0 }
676 676 };
  677 +MODULE_DEVICE_TABLE(zorro, a2065_zorro_tbl);
677 678  
678 679 static struct zorro_driver a2065_driver = {
679 680 .name = "a2065",
drivers/net/ariadne.c
... ... @@ -145,6 +145,7 @@
145 145 { ZORRO_PROD_VILLAGE_TRONIC_ARIADNE },
146 146 { 0 }
147 147 };
  148 +MODULE_DEVICE_TABLE(zorro, ariadne_zorro_tbl);
148 149  
149 150 static struct zorro_driver ariadne_driver = {
150 151 .name = "ariadne",
... ... @@ -71,6 +71,7 @@
71 71 { ZORRO_PROD_HYDRA_SYSTEMS_AMIGANET },
72 72 { 0 }
73 73 };
  74 +MODULE_DEVICE_TABLE(zorro, hydra_zorro_tbl);
74 75  
75 76 static struct zorro_driver hydra_driver = {
76 77 .name = "hydra",
drivers/net/zorro8390.c
... ... @@ -102,6 +102,7 @@
102 102 { ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF, },
103 103 { 0 }
104 104 };
  105 +MODULE_DEVICE_TABLE(zorro, zorro8390_zorro_tbl);
105 106  
106 107 static struct zorro_driver zorro8390_driver = {
107 108 .name = "zorro8390",
drivers/scsi/zorro7xx.c
... ... @@ -69,6 +69,7 @@
69 69 },
70 70 { 0 }
71 71 };
  72 +MODULE_DEVICE_TABLE(zorro, zorro7xx_zorro_tbl);
72 73  
73 74 static int __devinit zorro7xx_init_one(struct zorro_dev *z,
74 75 const struct zorro_device_id *ent)
drivers/video/cirrusfb.c
... ... @@ -299,6 +299,7 @@
299 299 },
300 300 { 0 }
301 301 };
  302 +MODULE_DEVICE_TABLE(zorro, cirrusfb_zorro_table);
302 303  
303 304 static const struct {
304 305 zorro_id id2;
drivers/video/fm2fb.c
... ... @@ -219,6 +219,7 @@
219 219 { ZORRO_PROD_HELFRICH_RAINBOW_II },
220 220 { 0 }
221 221 };
  222 +MODULE_DEVICE_TABLE(zorro, fm2fb_devices);
222 223  
223 224 static struct zorro_driver fm2fb_driver = {
224 225 .name = "fm2fb",
drivers/zorro/zorro-driver.c
... ... @@ -137,10 +137,34 @@
137 137 return 0;
138 138 }
139 139  
  140 +static int zorro_uevent(struct device *dev, struct kobj_uevent_env *env)
  141 +{
  142 +#ifdef CONFIG_HOTPLUG
  143 + struct zorro_dev *z;
140 144  
  145 + if (!dev)
  146 + return -ENODEV;
  147 +
  148 + z = to_zorro_dev(dev);
  149 + if (!z)
  150 + return -ENODEV;
  151 +
  152 + if (add_uevent_var(env, "ZORRO_ID=%08X", z->id) ||
  153 + add_uevent_var(env, "ZORRO_SLOT_NAME=%s", dev_name(dev)) ||
  154 + add_uevent_var(env, "ZORRO_SLOT_ADDR=%04X", z->slotaddr) ||
  155 + add_uevent_var(env, "MODALIAS=" ZORRO_DEVICE_MODALIAS_FMT, z->id))
  156 + return -ENOMEM;
  157 +
  158 + return 0;
  159 +#else /* !CONFIG_HOTPLUG */
  160 + return -ENODEV;
  161 +#endif /* !CONFIG_HOTPLUG */
  162 +}
  163 +
141 164 struct bus_type zorro_bus_type = {
142 165 .name = "zorro",
143 166 .match = zorro_bus_match,
  167 + .uevent = zorro_uevent,
144 168 .probe = zorro_device_probe,
145 169 .remove = zorro_device_remove,
146 170 };
drivers/zorro/zorro-sysfs.c
... ... @@ -77,6 +77,16 @@
77 77 .read = zorro_read_config,
78 78 };
79 79  
  80 +static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
  81 + char *buf)
  82 +{
  83 + struct zorro_dev *z = to_zorro_dev(dev);
  84 +
  85 + return sprintf(buf, ZORRO_DEVICE_MODALIAS_FMT "\n", z->id);
  86 +}
  87 +
  88 +static DEVICE_ATTR(modalias, S_IRUGO, modalias_show, NULL);
  89 +
80 90 int zorro_create_sysfs_dev_files(struct zorro_dev *z)
81 91 {
82 92 struct device *dev = &z->dev;
... ... @@ -89,6 +99,7 @@
89 99 (error = device_create_file(dev, &dev_attr_slotaddr)) ||
90 100 (error = device_create_file(dev, &dev_attr_slotsize)) ||
91 101 (error = device_create_file(dev, &dev_attr_resource)) ||
  102 + (error = device_create_file(dev, &dev_attr_modalias)) ||
92 103 (error = sysfs_create_bin_file(&dev->kobj, &zorro_config_attr)))
93 104 return error;
94 105  
include/linux/mod_devicetable.h
... ... @@ -474,5 +474,14 @@
474 474 __attribute__((aligned(sizeof(kernel_ulong_t))));
475 475 };
476 476  
  477 +struct zorro_device_id {
  478 + __u32 id; /* Device ID or ZORRO_WILDCARD */
  479 + kernel_ulong_t driver_data; /* Data private to the driver */
  480 +};
  481 +
  482 +#define ZORRO_WILDCARD (0xffffffff) /* not official */
  483 +
  484 +#define ZORRO_DEVICE_MODALIAS_FMT "zorro:i%08X"
  485 +
477 486 #endif /* LINUX_MOD_DEVICETABLE_H */
include/linux/zorro.h
... ... @@ -38,8 +38,6 @@
38 38 typedef __u32 zorro_id;
39 39  
40 40  
41   -#define ZORRO_WILDCARD (0xffffffff) /* not official */
42   -
43 41 /* Include the ID list */
44 42 #include <linux/zorro_ids.h>
45 43  
... ... @@ -116,6 +114,7 @@
116 114  
117 115 #include <linux/init.h>
118 116 #include <linux/ioport.h>
  117 +#include <linux/mod_devicetable.h>
119 118  
120 119 #include <asm/zorro.h>
121 120  
... ... @@ -152,16 +151,6 @@
152 151  
153 152 extern struct zorro_bus zorro_bus; /* single Zorro bus */
154 153 extern struct bus_type zorro_bus_type;
155   -
156   -
157   - /*
158   - * Zorro device IDs
159   - */
160   -
161   -struct zorro_device_id {
162   - zorro_id id; /* Device ID or ZORRO_WILDCARD */
163   - unsigned long driver_data; /* Data private to the driver */
164   -};
165 154  
166 155  
167 156 /*
scripts/mod/file2alias.c
... ... @@ -796,6 +796,16 @@
796 796 return 1;
797 797 }
798 798  
  799 +/* Looks like: zorro:iN. */
  800 +static int do_zorro_entry(const char *filename, struct zorro_device_id *id,
  801 + char *alias)
  802 +{
  803 + id->id = TO_NATIVE(id->id);
  804 + strcpy(alias, "zorro:");
  805 + ADD(alias, "i", id->id != ZORRO_WILDCARD, id->id);
  806 + return 1;
  807 +}
  808 +
799 809 /* Ignore any prefix, eg. some architectures prepend _ */
800 810 static inline int sym_is(const char *symbol, const char *name)
801 811 {
... ... @@ -943,6 +953,10 @@
943 953 do_table(symval, sym->st_size,
944 954 sizeof(struct platform_device_id), "platform",
945 955 do_platform_entry, mod);
  956 + else if (sym_is(symname, "__mod_zorro_device_table"))
  957 + do_table(symval, sym->st_size,
  958 + sizeof(struct zorro_device_id), "zorro",
  959 + do_zorro_entry, mod);
946 960 free(zeros);
947 961 }
948 962