Commit d9ca676bcb26e1fdff9265a3e70f697cd381c889
Committed by
David S. Miller
1 parent
fb890ae7d6
Exists in
master
and in
4 other branches
atm: correct sysfs 'device' link creation and parent relationships
The ATM subsystem was incorrectly creating the 'device' link for ATM nodes in sysfs. This led to incorrect device/parent relationships exposed by sysfs and udev. Instead of rolling the 'device' link by hand in the generic ATM code, pass each ATM driver's bus device down to the sysfs code and let sysfs do this stuff correctly. Signed-off-by: Dan Williams <dcbw@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 19 changed files with 41 additions and 42 deletions Side-by-side Diff
- drivers/atm/adummy.c
- drivers/atm/ambassador.c
- drivers/atm/atmtcp.c
- drivers/atm/eni.c
- drivers/atm/firestream.c
- drivers/atm/fore200e.c
- drivers/atm/he.c
- drivers/atm/horizon.c
- drivers/atm/idt77252.c
- drivers/atm/iphase.c
- drivers/atm/lanai.c
- drivers/atm/nicstar.c
- drivers/atm/solos-pci.c
- drivers/atm/zatm.c
- drivers/usb/atm/usbatm.c
- include/linux/atmdev.h
- net/atm/atm_sysfs.c
- net/atm/resources.c
- net/atm/resources.h
drivers/atm/adummy.c
... | ... | @@ -154,7 +154,7 @@ |
154 | 154 | err = -ENOMEM; |
155 | 155 | goto out; |
156 | 156 | } |
157 | - atm_dev = atm_dev_register(DEV_LABEL, &adummy_ops, -1, NULL); | |
157 | + atm_dev = atm_dev_register(DEV_LABEL, NULL, &adummy_ops, -1, NULL); | |
158 | 158 | if (!atm_dev) { |
159 | 159 | printk(KERN_ERR DEV_LABEL ": atm_dev_register() failed\n"); |
160 | 160 | err = -ENODEV; |
drivers/atm/ambassador.c
... | ... | @@ -2244,7 +2244,8 @@ |
2244 | 2244 | goto out_reset; |
2245 | 2245 | } |
2246 | 2246 | |
2247 | - dev->atm_dev = atm_dev_register (DEV_LABEL, &amb_ops, -1, NULL); | |
2247 | + dev->atm_dev = atm_dev_register (DEV_LABEL, &pci_dev->dev, &amb_ops, -1, | |
2248 | + NULL); | |
2248 | 2249 | if (!dev->atm_dev) { |
2249 | 2250 | PRINTD (DBG_ERR, "failed to register Madge ATM adapter"); |
2250 | 2251 | err = -EINVAL; |
drivers/atm/atmtcp.c
... | ... | @@ -366,7 +366,7 @@ |
366 | 366 | if (!dev_data) |
367 | 367 | return -ENOMEM; |
368 | 368 | |
369 | - dev = atm_dev_register(DEV_LABEL,&atmtcp_v_dev_ops,itf,NULL); | |
369 | + dev = atm_dev_register(DEV_LABEL,NULL,&atmtcp_v_dev_ops,itf,NULL); | |
370 | 370 | if (!dev) { |
371 | 371 | kfree(dev_data); |
372 | 372 | return itf == -1 ? -ENOMEM : -EBUSY; |
drivers/atm/eni.c
... | ... | @@ -2244,7 +2244,7 @@ |
2244 | 2244 | &zeroes); |
2245 | 2245 | if (!cpu_zeroes) goto out1; |
2246 | 2246 | } |
2247 | - dev = atm_dev_register(DEV_LABEL,&ops,-1,NULL); | |
2247 | + dev = atm_dev_register(DEV_LABEL, &pci_dev->dev, &ops, -1, NULL); | |
2248 | 2248 | if (!dev) goto out2; |
2249 | 2249 | pci_set_drvdata(pci_dev, dev); |
2250 | 2250 | eni_dev->pci_dev = pci_dev; |
drivers/atm/firestream.c
... | ... | @@ -1911,7 +1911,7 @@ |
1911 | 1911 | fs_dev, sizeof (struct fs_dev)); |
1912 | 1912 | if (!fs_dev) |
1913 | 1913 | goto err_out; |
1914 | - atm_dev = atm_dev_register("fs", &ops, -1, NULL); | |
1914 | + atm_dev = atm_dev_register("fs", &pci_dev->dev, &ops, -1, NULL); | |
1915 | 1915 | if (!atm_dev) |
1916 | 1916 | goto err_out_free_fs_dev; |
1917 | 1917 |
drivers/atm/fore200e.c
... | ... | @@ -2567,14 +2567,14 @@ |
2567 | 2567 | |
2568 | 2568 | |
2569 | 2569 | static int __devinit |
2570 | -fore200e_register(struct fore200e* fore200e) | |
2570 | +fore200e_register(struct fore200e* fore200e, struct device *parent) | |
2571 | 2571 | { |
2572 | 2572 | struct atm_dev* atm_dev; |
2573 | 2573 | |
2574 | 2574 | DPRINTK(2, "device %s being registered\n", fore200e->name); |
2575 | 2575 | |
2576 | - atm_dev = atm_dev_register(fore200e->bus->proc_name, &fore200e_ops, -1, | |
2577 | - NULL); | |
2576 | + atm_dev = atm_dev_register(fore200e->bus->proc_name, parent, &fore200e_ops, | |
2577 | + -1, NULL); | |
2578 | 2578 | if (atm_dev == NULL) { |
2579 | 2579 | printk(FORE200E "unable to register device %s\n", fore200e->name); |
2580 | 2580 | return -ENODEV; |
2581 | 2581 | |
... | ... | @@ -2594,9 +2594,9 @@ |
2594 | 2594 | |
2595 | 2595 | |
2596 | 2596 | static int __devinit |
2597 | -fore200e_init(struct fore200e* fore200e) | |
2597 | +fore200e_init(struct fore200e* fore200e, struct device *parent) | |
2598 | 2598 | { |
2599 | - if (fore200e_register(fore200e) < 0) | |
2599 | + if (fore200e_register(fore200e, parent) < 0) | |
2600 | 2600 | return -ENODEV; |
2601 | 2601 | |
2602 | 2602 | if (fore200e->bus->configure(fore200e) < 0) |
... | ... | @@ -2662,7 +2662,7 @@ |
2662 | 2662 | |
2663 | 2663 | sprintf(fore200e->name, "%s-%d", bus->model_name, index); |
2664 | 2664 | |
2665 | - err = fore200e_init(fore200e); | |
2665 | + err = fore200e_init(fore200e, &op->dev); | |
2666 | 2666 | if (err < 0) { |
2667 | 2667 | fore200e_shutdown(fore200e); |
2668 | 2668 | kfree(fore200e); |
... | ... | @@ -2740,7 +2740,7 @@ |
2740 | 2740 | |
2741 | 2741 | sprintf(fore200e->name, "%s-%d", bus->model_name, index); |
2742 | 2742 | |
2743 | - err = fore200e_init(fore200e); | |
2743 | + err = fore200e_init(fore200e, &pci_dev->dev); | |
2744 | 2744 | if (err < 0) { |
2745 | 2745 | fore200e_shutdown(fore200e); |
2746 | 2746 | goto out_free; |
drivers/atm/he.c
drivers/atm/horizon.c
... | ... | @@ -2733,7 +2733,8 @@ |
2733 | 2733 | PRINTD(DBG_INFO, "found Madge ATM adapter (hrz) at: IO %x, IRQ %u, MEM %p", |
2734 | 2734 | iobase, irq, membase); |
2735 | 2735 | |
2736 | - dev->atm_dev = atm_dev_register(DEV_LABEL, &hrz_ops, -1, NULL); | |
2736 | + dev->atm_dev = atm_dev_register(DEV_LABEL, &pci_dev->dev, &hrz_ops, -1, | |
2737 | + NULL); | |
2737 | 2738 | if (!(dev->atm_dev)) { |
2738 | 2739 | PRINTD(DBG_ERR, "failed to register Madge ATM adapter"); |
2739 | 2740 | err = -EINVAL; |
drivers/atm/idt77252.c
... | ... | @@ -3698,7 +3698,8 @@ |
3698 | 3698 | goto err_out_iounmap; |
3699 | 3699 | } |
3700 | 3700 | |
3701 | - dev = atm_dev_register("idt77252", &idt77252_ops, -1, NULL); | |
3701 | + dev = atm_dev_register("idt77252", &pcidev->dev, &idt77252_ops, -1, | |
3702 | + NULL); | |
3702 | 3703 | if (!dev) { |
3703 | 3704 | printk("%s: can't register atm device\n", card->name); |
3704 | 3705 | err = -EIO; |
drivers/atm/iphase.c
... | ... | @@ -3172,7 +3172,7 @@ |
3172 | 3172 | ret = -ENODEV; |
3173 | 3173 | goto err_out_free_iadev; |
3174 | 3174 | } |
3175 | - dev = atm_dev_register(DEV_LABEL, &ops, -1, NULL); | |
3175 | + dev = atm_dev_register(DEV_LABEL, &pdev->dev, &ops, -1, NULL); | |
3176 | 3176 | if (!dev) { |
3177 | 3177 | ret = -ENOMEM; |
3178 | 3178 | goto err_out_disable_dev; |
drivers/atm/lanai.c
... | ... | @@ -2591,7 +2591,7 @@ |
2591 | 2591 | return -ENOMEM; |
2592 | 2592 | } |
2593 | 2593 | |
2594 | - atmdev = atm_dev_register(DEV_LABEL, &ops, -1, NULL); | |
2594 | + atmdev = atm_dev_register(DEV_LABEL, &pci->dev, &ops, -1, NULL); | |
2595 | 2595 | if (atmdev == NULL) { |
2596 | 2596 | printk(KERN_ERR DEV_LABEL |
2597 | 2597 | ": couldn't register atm device!\n"); |
drivers/atm/nicstar.c
... | ... | @@ -771,7 +771,8 @@ |
771 | 771 | } |
772 | 772 | |
773 | 773 | /* Register device */ |
774 | - card->atmdev = atm_dev_register("nicstar", &atm_ops, -1, NULL); | |
774 | + card->atmdev = atm_dev_register("nicstar", &card->pcidev->dev, &atm_ops, | |
775 | + -1, NULL); | |
775 | 776 | if (card->atmdev == NULL) { |
776 | 777 | printk("nicstar%d: can't register device.\n", i); |
777 | 778 | error = 17; |
drivers/atm/solos-pci.c
... | ... | @@ -166,7 +166,7 @@ |
166 | 166 | static struct atm_vcc* find_vcc(struct atm_dev *dev, short vpi, int vci); |
167 | 167 | static int list_vccs(int vci); |
168 | 168 | static void release_vccs(struct atm_dev *dev); |
169 | -static int atm_init(struct solos_card *); | |
169 | +static int atm_init(struct solos_card *, struct device *); | |
170 | 170 | static void atm_remove(struct solos_card *); |
171 | 171 | static int send_command(struct solos_card *card, int dev, const char *buf, size_t size); |
172 | 172 | static void solos_bh(unsigned long); |
... | ... | @@ -1210,7 +1210,7 @@ |
1210 | 1210 | if (db_firmware_upgrade) |
1211 | 1211 | flash_upgrade(card, 3); |
1212 | 1212 | |
1213 | - err = atm_init(card); | |
1213 | + err = atm_init(card, &dev->dev); | |
1214 | 1214 | if (err) |
1215 | 1215 | goto out_free_irq; |
1216 | 1216 | |
... | ... | @@ -1233,7 +1233,7 @@ |
1233 | 1233 | return err; |
1234 | 1234 | } |
1235 | 1235 | |
1236 | -static int atm_init(struct solos_card *card) | |
1236 | +static int atm_init(struct solos_card *card, struct device *parent) | |
1237 | 1237 | { |
1238 | 1238 | int i; |
1239 | 1239 | |
... | ... | @@ -1244,7 +1244,7 @@ |
1244 | 1244 | skb_queue_head_init(&card->tx_queue[i]); |
1245 | 1245 | skb_queue_head_init(&card->cli_queue[i]); |
1246 | 1246 | |
1247 | - card->atmdev[i] = atm_dev_register("solos-pci", &fpga_ops, -1, NULL); | |
1247 | + card->atmdev[i] = atm_dev_register("solos-pci", parent, &fpga_ops, -1, NULL); | |
1248 | 1248 | if (!card->atmdev[i]) { |
1249 | 1249 | dev_err(&card->dev->dev, "Could not register ATM device %d\n", i); |
1250 | 1250 | atm_remove(card); |
drivers/atm/zatm.c
drivers/usb/atm/usbatm.c
... | ... | @@ -951,7 +951,9 @@ |
951 | 951 | * condition: callbacks we register can be executed at once, before we have |
952 | 952 | * initialized the struct atm_dev. To protect against this, all callbacks |
953 | 953 | * abort if atm_dev->dev_data is NULL. */ |
954 | - atm_dev = atm_dev_register(instance->driver_name, &usbatm_atm_devops, -1, NULL); | |
954 | + atm_dev = atm_dev_register(instance->driver_name, | |
955 | + &instance->usb_intf->dev, &usbatm_atm_devops, | |
956 | + -1, NULL); | |
955 | 957 | if (!atm_dev) { |
956 | 958 | usb_err(instance, "%s: failed to register ATM device!\n", __func__); |
957 | 959 | return -1; |
... | ... | @@ -966,14 +968,6 @@ |
966 | 968 | /* temp init ATM device, set to 128kbit */ |
967 | 969 | atm_dev->link_rate = 128 * 1000 / 424; |
968 | 970 | |
969 | - ret = sysfs_create_link(&atm_dev->class_dev.kobj, | |
970 | - &instance->usb_intf->dev.kobj, "device"); | |
971 | - if (ret) { | |
972 | - atm_err(instance, "%s: sysfs_create_link failed: %d\n", | |
973 | - __func__, ret); | |
974 | - goto fail_sysfs; | |
975 | - } | |
976 | - | |
977 | 971 | if (instance->driver->atm_start && ((ret = instance->driver->atm_start(instance, atm_dev)) < 0)) { |
978 | 972 | atm_err(instance, "%s: atm_start failed: %d!\n", __func__, ret); |
979 | 973 | goto fail; |
... | ... | @@ -992,8 +986,6 @@ |
992 | 986 | return 0; |
993 | 987 | |
994 | 988 | fail: |
995 | - sysfs_remove_link(&atm_dev->class_dev.kobj, "device"); | |
996 | - fail_sysfs: | |
997 | 989 | instance->atm_dev = NULL; |
998 | 990 | atm_dev_deregister(atm_dev); /* usbatm_atm_dev_close will eventually be called */ |
999 | 991 | return ret; |
... | ... | @@ -1329,7 +1321,6 @@ |
1329 | 1321 | |
1330 | 1322 | /* ATM finalize */ |
1331 | 1323 | if (instance->atm_dev) { |
1332 | - sysfs_remove_link(&instance->atm_dev->class_dev.kobj, "device"); | |
1333 | 1324 | atm_dev_deregister(instance->atm_dev); |
1334 | 1325 | instance->atm_dev = NULL; |
1335 | 1326 | } |
include/linux/atmdev.h
... | ... | @@ -427,8 +427,10 @@ |
427 | 427 | |
428 | 428 | #define ATM_SKB(skb) (((struct atm_skb_data *) (skb)->cb)) |
429 | 429 | |
430 | -struct atm_dev *atm_dev_register(const char *type,const struct atmdev_ops *ops, | |
431 | - int number,unsigned long *flags); /* number == -1: pick first available */ | |
430 | +struct atm_dev *atm_dev_register(const char *type, struct device *parent, | |
431 | + const struct atmdev_ops *ops, | |
432 | + int number, /* -1 == pick first available */ | |
433 | + unsigned long *flags); | |
432 | 434 | struct atm_dev *atm_dev_lookup(int number); |
433 | 435 | void atm_dev_deregister(struct atm_dev *dev); |
434 | 436 |
net/atm/atm_sysfs.c
... | ... | @@ -143,12 +143,13 @@ |
143 | 143 | .dev_uevent = atm_uevent, |
144 | 144 | }; |
145 | 145 | |
146 | -int atm_register_sysfs(struct atm_dev *adev) | |
146 | +int atm_register_sysfs(struct atm_dev *adev, struct device *parent) | |
147 | 147 | { |
148 | 148 | struct device *cdev = &adev->class_dev; |
149 | 149 | int i, j, err; |
150 | 150 | |
151 | 151 | cdev->class = &atm_class; |
152 | + cdev->parent = parent; | |
152 | 153 | dev_set_drvdata(cdev, adev); |
153 | 154 | |
154 | 155 | dev_set_name(cdev, "%s%d", adev->type, adev->number); |
net/atm/resources.c
... | ... | @@ -74,8 +74,9 @@ |
74 | 74 | } |
75 | 75 | EXPORT_SYMBOL(atm_dev_lookup); |
76 | 76 | |
77 | -struct atm_dev *atm_dev_register(const char *type, const struct atmdev_ops *ops, | |
78 | - int number, unsigned long *flags) | |
77 | +struct atm_dev *atm_dev_register(const char *type, struct device *parent, | |
78 | + const struct atmdev_ops *ops, int number, | |
79 | + unsigned long *flags) | |
79 | 80 | { |
80 | 81 | struct atm_dev *dev, *inuse; |
81 | 82 | |
... | ... | @@ -115,7 +116,7 @@ |
115 | 116 | goto out_fail; |
116 | 117 | } |
117 | 118 | |
118 | - if (atm_register_sysfs(dev) < 0) { | |
119 | + if (atm_register_sysfs(dev, parent) < 0) { | |
119 | 120 | pr_err("atm_register_sysfs failed for dev %s\n", type); |
120 | 121 | atm_proc_dev_deregister(dev); |
121 | 122 | goto out_fail; |
net/atm/resources.h