Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ieee1394: convert ieee1394 from "struct class_device" to "struct device"

Here is a straightforward conversion to "struct device". The "struct
class_device" will be removed from the kernel.

It seems to work fine for me with and without CONFIG_SYSFS_DEPRECATED
set.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>

authored by

Kay Sievers and committed by
Stefan Richter
dd7f2928 59337087

+86 -84
+4 -4
drivers/ieee1394/dv1394.c
··· 2280 2280 } while (video); 2281 2281 2282 2282 if (found_ohci_card) 2283 - class_device_destroy(hpsb_protocol_class, MKDEV(IEEE1394_MAJOR, 2283 + device_destroy(hpsb_protocol_class, MKDEV(IEEE1394_MAJOR, 2284 2284 IEEE1394_MINOR_BLOCK_DV1394 * 16 + (host->id << 2))); 2285 2285 } 2286 2286 ··· 2295 2295 2296 2296 ohci = (struct ti_ohci *)host->hostdata; 2297 2297 2298 - class_device_create(hpsb_protocol_class, NULL, MKDEV( 2299 - IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)), 2300 - NULL, "dv1394-%d", id); 2298 + device_create(hpsb_protocol_class, NULL, MKDEV( 2299 + IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)), 2300 + "dv1394-%d", id); 2301 2301 2302 2302 dv1394_init(ohci, DV1394_NTSC, MODE_RECEIVE); 2303 2303 dv1394_init(ohci, DV1394_NTSC, MODE_TRANSMIT);
+5 -5
drivers/ieee1394/hosts.c
··· 156 156 h->device.parent = dev; 157 157 snprintf(h->device.bus_id, BUS_ID_SIZE, "fw-host%d", h->id); 158 158 159 - h->class_dev.dev = &h->device; 160 - h->class_dev.class = &hpsb_host_class; 161 - snprintf(h->class_dev.class_id, BUS_ID_SIZE, "fw-host%d", h->id); 159 + h->host_dev.parent = &h->device; 160 + h->host_dev.class = &hpsb_host_class; 161 + snprintf(h->host_dev.bus_id, BUS_ID_SIZE, "fw-host%d", h->id); 162 162 163 163 if (device_register(&h->device)) 164 164 goto fail; 165 - if (class_device_register(&h->class_dev)) { 165 + if (device_register(&h->host_dev)) { 166 166 device_unregister(&h->device); 167 167 goto fail; 168 168 } ··· 202 202 host->driver = &dummy_driver; 203 203 highlevel_remove_host(host); 204 204 205 - class_device_unregister(&host->class_dev); 205 + device_unregister(&host->host_dev); 206 206 device_unregister(&host->device); 207 207 } 208 208
+1 -1
drivers/ieee1394/hosts.h
··· 57 57 struct hpsb_host_driver *driver; 58 58 struct pci_dev *pdev; 59 59 struct device device; 60 - struct class_device class_dev; 60 + struct device host_dev; 61 61 62 62 struct delayed_work delayed_reset; 63 63 unsigned config_roms:31;
+60 -58
drivers/ieee1394/nodemgr.c
··· 154 154 }; 155 155 156 156 static int nodemgr_bus_match(struct device * dev, struct device_driver * drv); 157 - static int nodemgr_uevent(struct class_device *cdev, char **envp, int num_envp, 157 + static int nodemgr_uevent(struct device *dev, char **envp, int num_envp, 158 158 char *buffer, int buffer_size); 159 159 static void nodemgr_resume_ne(struct node_entry *ne); 160 160 static void nodemgr_remove_ne(struct node_entry *ne); ··· 165 165 .match = nodemgr_bus_match, 166 166 }; 167 167 168 - static void host_cls_release(struct class_device *class_dev) 168 + static void host_cls_release(struct device *dev) 169 169 { 170 - put_device(&container_of((class_dev), struct hpsb_host, class_dev)->device); 170 + put_device(&container_of((dev), struct hpsb_host, host_dev)->device); 171 171 } 172 172 173 173 struct class hpsb_host_class = { 174 174 .name = "ieee1394_host", 175 - .release = host_cls_release, 175 + .dev_release = host_cls_release, 176 176 }; 177 177 178 - static void ne_cls_release(struct class_device *class_dev) 178 + static void ne_cls_release(struct device *dev) 179 179 { 180 - put_device(&container_of((class_dev), struct node_entry, class_dev)->device); 180 + put_device(&container_of((dev), struct node_entry, node_dev)->device); 181 181 } 182 182 183 183 static struct class nodemgr_ne_class = { 184 184 .name = "ieee1394_node", 185 - .release = ne_cls_release, 185 + .dev_release = ne_cls_release, 186 186 }; 187 187 188 - static void ud_cls_release(struct class_device *class_dev) 188 + static void ud_cls_release(struct device *dev) 189 189 { 190 - put_device(&container_of((class_dev), struct unit_directory, class_dev)->device); 190 + put_device(&container_of((dev), struct unit_directory, unit_dev)->device); 191 191 } 192 192 193 193 /* The name here is only so that unit directory hotplug works with old 194 - * style hotplug, which only ever did unit directories anyway. */ 194 + * style hotplug, which only ever did unit directories anyway. 195 + */ 195 196 static struct class nodemgr_ud_class = { 196 197 .name = "ieee1394", 197 - .release = ud_cls_release, 198 - .uevent = nodemgr_uevent, 198 + .dev_release = ud_cls_release, 199 + .dev_uevent = nodemgr_uevent, 199 200 }; 200 201 201 202 static struct hpsb_highlevel nodemgr_highlevel; ··· 731 730 732 731 static void nodemgr_remove_uds(struct node_entry *ne) 733 732 { 734 - struct class_device *cdev; 733 + struct device *dev; 735 734 struct unit_directory *tmp, *ud; 736 735 737 - /* Iteration over nodemgr_ud_class.children has to be protected by 738 - * nodemgr_ud_class.sem, but class_device_unregister() will eventually 736 + /* Iteration over nodemgr_ud_class.devices has to be protected by 737 + * nodemgr_ud_class.sem, but device_unregister() will eventually 739 738 * take nodemgr_ud_class.sem too. Therefore pick out one ud at a time, 740 739 * release the semaphore, and then unregister the ud. Since this code 741 740 * may be called from other contexts besides the knodemgrds, protect the ··· 745 744 for (;;) { 746 745 ud = NULL; 747 746 down(&nodemgr_ud_class.sem); 748 - list_for_each_entry(cdev, &nodemgr_ud_class.children, node) { 749 - tmp = container_of(cdev, struct unit_directory, 750 - class_dev); 747 + list_for_each_entry(dev, &nodemgr_ud_class.devices, node) { 748 + tmp = container_of(dev, struct unit_directory, 749 + unit_dev); 751 750 if (tmp->ne == ne) { 752 751 ud = tmp; 753 752 break; ··· 756 755 up(&nodemgr_ud_class.sem); 757 756 if (ud == NULL) 758 757 break; 759 - class_device_unregister(&ud->class_dev); 758 + device_unregister(&ud->unit_dev); 760 759 device_unregister(&ud->device); 761 760 } 762 761 mutex_unlock(&nodemgr_serialize_remove_uds); ··· 773 772 774 773 HPSB_DEBUG("Node removed: ID:BUS[" NODE_BUS_FMT "] GUID[%016Lx]", 775 774 NODE_BUS_ARGS(ne->host, ne->nodeid), (unsigned long long)ne->guid); 776 - 777 775 nodemgr_remove_uds(ne); 778 776 779 - class_device_unregister(&ne->class_dev); 777 + device_unregister(&ne->node_dev); 780 778 device_unregister(dev); 781 779 782 780 put_device(dev); ··· 783 783 784 784 static int __nodemgr_remove_host_dev(struct device *dev, void *data) 785 785 { 786 - nodemgr_remove_ne(container_of(dev, struct node_entry, device)); 786 + if (dev->bus == &ieee1394_bus_type) 787 + nodemgr_remove_ne(container_of(dev, struct node_entry, 788 + device)); 787 789 return 0; 788 790 } 789 791 ··· 852 850 snprintf(ne->device.bus_id, BUS_ID_SIZE, "%016Lx", 853 851 (unsigned long long)(ne->guid)); 854 852 855 - ne->class_dev.dev = &ne->device; 856 - ne->class_dev.class = &nodemgr_ne_class; 857 - snprintf(ne->class_dev.class_id, BUS_ID_SIZE, "%016Lx", 858 - (unsigned long long)(ne->guid)); 853 + ne->node_dev.parent = &ne->device; 854 + ne->node_dev.class = &nodemgr_ne_class; 855 + snprintf(ne->node_dev.bus_id, BUS_ID_SIZE, "%016Lx", 856 + (unsigned long long)(ne->guid)); 859 857 860 858 if (device_register(&ne->device)) 861 859 goto fail_devreg; 862 - if (class_device_register(&ne->class_dev)) 860 + if (device_register(&ne->node_dev)) 863 861 goto fail_classdevreg; 864 862 get_device(&ne->device); 865 863 ··· 887 885 888 886 static struct node_entry *find_entry_by_guid(u64 guid) 889 887 { 890 - struct class_device *cdev; 888 + struct device *dev; 891 889 struct node_entry *ne, *ret_ne = NULL; 892 890 893 891 down(&nodemgr_ne_class.sem); 894 - list_for_each_entry(cdev, &nodemgr_ne_class.children, node) { 895 - ne = container_of(cdev, struct node_entry, class_dev); 892 + list_for_each_entry(dev, &nodemgr_ne_class.devices, node) { 893 + ne = container_of(dev, struct node_entry, node_dev); 896 894 897 895 if (ne->guid == guid) { 898 896 ret_ne = ne; ··· 908 906 static struct node_entry *find_entry_by_nodeid(struct hpsb_host *host, 909 907 nodeid_t nodeid) 910 908 { 911 - struct class_device *cdev; 909 + struct device *dev; 912 910 struct node_entry *ne, *ret_ne = NULL; 913 911 914 912 down(&nodemgr_ne_class.sem); 915 - list_for_each_entry(cdev, &nodemgr_ne_class.children, node) { 916 - ne = container_of(cdev, struct node_entry, class_dev); 913 + list_for_each_entry(dev, &nodemgr_ne_class.devices, node) { 914 + ne = container_of(dev, struct node_entry, node_dev); 917 915 918 916 if (ne->host == host && ne->nodeid == nodeid) { 919 917 ret_ne = ne; ··· 937 935 snprintf(ud->device.bus_id, BUS_ID_SIZE, "%s-%u", 938 936 ne->device.bus_id, ud->id); 939 937 940 - ud->class_dev.dev = &ud->device; 941 - ud->class_dev.class = &nodemgr_ud_class; 942 - snprintf(ud->class_dev.class_id, BUS_ID_SIZE, "%s-%u", 938 + ud->unit_dev.parent = &ud->device; 939 + ud->unit_dev.class = &nodemgr_ud_class; 940 + snprintf(ud->unit_dev.bus_id, BUS_ID_SIZE, "%s-%u", 943 941 ne->device.bus_id, ud->id); 944 942 945 943 if (device_register(&ud->device)) 946 944 goto fail_devreg; 947 - if (class_device_register(&ud->class_dev)) 945 + if (device_register(&ud->unit_dev)) 948 946 goto fail_classdevreg; 949 947 get_device(&ud->device); 950 948 ··· 1161 1159 1162 1160 #ifdef CONFIG_HOTPLUG 1163 1161 1164 - static int nodemgr_uevent(struct class_device *cdev, char **envp, int num_envp, 1162 + static int nodemgr_uevent(struct device *dev, char **envp, int num_envp, 1165 1163 char *buffer, int buffer_size) 1166 1164 { 1167 1165 struct unit_directory *ud; ··· 1171 1169 /* ieee1394:venNmoNspNverN */ 1172 1170 char buf[8 + 1 + 3 + 8 + 2 + 8 + 2 + 8 + 3 + 8 + 1]; 1173 1171 1174 - if (!cdev) 1172 + if (!dev) 1175 1173 return -ENODEV; 1176 1174 1177 - ud = container_of(cdev, struct unit_directory, class_dev); 1175 + ud = container_of(dev, struct unit_directory, unit_dev); 1178 1176 1179 1177 if (ud->ne->in_limbo || ud->ignore_driver) 1180 1178 return -ENODEV; ··· 1209 1207 1210 1208 #else 1211 1209 1212 - static int nodemgr_uevent(struct class_device *cdev, char **envp, int num_envp, 1210 + static int nodemgr_uevent(struct device *dev, char **envp, int num_envp, 1213 1211 char *buffer, int buffer_size) 1214 1212 { 1215 1213 return -ENODEV; ··· 1380 1378 1381 1379 static void nodemgr_suspend_ne(struct node_entry *ne) 1382 1380 { 1383 - struct class_device *cdev; 1381 + struct device *dev; 1384 1382 struct unit_directory *ud; 1385 1383 1386 1384 HPSB_DEBUG("Node suspended: ID:BUS[" NODE_BUS_FMT "] GUID[%016Lx]", ··· 1390 1388 WARN_ON(device_create_file(&ne->device, &dev_attr_ne_in_limbo)); 1391 1389 1392 1390 down(&nodemgr_ud_class.sem); 1393 - list_for_each_entry(cdev, &nodemgr_ud_class.children, node) { 1394 - ud = container_of(cdev, struct unit_directory, class_dev); 1391 + list_for_each_entry(dev, &nodemgr_ud_class.devices, node) { 1392 + ud = container_of(dev, struct unit_directory, unit_dev); 1395 1393 if (ud->ne != ne) 1396 1394 continue; 1397 1395 ··· 1406 1404 1407 1405 static void nodemgr_resume_ne(struct node_entry *ne) 1408 1406 { 1409 - struct class_device *cdev; 1407 + struct device *dev; 1410 1408 struct unit_directory *ud; 1411 1409 1412 1410 ne->in_limbo = 0; 1413 1411 device_remove_file(&ne->device, &dev_attr_ne_in_limbo); 1414 1412 1415 1413 down(&nodemgr_ud_class.sem); 1416 - list_for_each_entry(cdev, &nodemgr_ud_class.children, node) { 1417 - ud = container_of(cdev, struct unit_directory, class_dev); 1414 + list_for_each_entry(dev, &nodemgr_ud_class.devices, node) { 1415 + ud = container_of(dev, struct unit_directory, unit_dev); 1418 1416 if (ud->ne != ne) 1419 1417 continue; 1420 1418 ··· 1432 1430 { 1433 1431 struct unit_directory *ud; 1434 1432 struct hpsb_protocol_driver *pdrv; 1435 - struct class_device *cdev; 1433 + struct device *dev; 1436 1434 1437 1435 down(&nodemgr_ud_class.sem); 1438 - list_for_each_entry(cdev, &nodemgr_ud_class.children, node) { 1439 - ud = container_of(cdev, struct unit_directory, class_dev); 1436 + list_for_each_entry(dev, &nodemgr_ud_class.devices, node) { 1437 + ud = container_of(dev, struct unit_directory, unit_dev); 1440 1438 if (ud->ne != ne) 1441 1439 continue; 1442 1440 ··· 1511 1509 static void nodemgr_node_probe(struct host_info *hi, int generation) 1512 1510 { 1513 1511 struct hpsb_host *host = hi->host; 1514 - struct class_device *cdev; 1512 + struct device *dev; 1515 1513 struct node_entry *ne; 1516 1514 1517 1515 /* Do some processing of the nodes we've probed. This pulls them ··· 1524 1522 * improvement...) */ 1525 1523 1526 1524 down(&nodemgr_ne_class.sem); 1527 - list_for_each_entry(cdev, &nodemgr_ne_class.children, node) { 1528 - ne = container_of(cdev, struct node_entry, class_dev); 1525 + list_for_each_entry(dev, &nodemgr_ne_class.devices, node) { 1526 + ne = container_of(dev, struct node_entry, node_dev); 1529 1527 if (!ne->needs_probe) 1530 1528 nodemgr_probe_ne(hi, ne, generation); 1531 1529 } 1532 - list_for_each_entry(cdev, &nodemgr_ne_class.children, node) { 1533 - ne = container_of(cdev, struct node_entry, class_dev); 1530 + list_for_each_entry(dev, &nodemgr_ne_class.devices, node) { 1531 + ne = container_of(dev, struct node_entry, node_dev); 1534 1532 if (ne->needs_probe) 1535 1533 nodemgr_probe_ne(hi, ne, generation); 1536 1534 } ··· 1758 1756 */ 1759 1757 int nodemgr_for_each_host(void *data, int (*cb)(struct hpsb_host *, void *)) 1760 1758 { 1761 - struct class_device *cdev; 1759 + struct device *dev; 1762 1760 struct hpsb_host *host; 1763 1761 int error = 0; 1764 1762 1765 1763 down(&hpsb_host_class.sem); 1766 - list_for_each_entry(cdev, &hpsb_host_class.children, node) { 1767 - host = container_of(cdev, struct hpsb_host, class_dev); 1764 + list_for_each_entry(dev, &hpsb_host_class.devices, node) { 1765 + host = container_of(dev, struct hpsb_host, host_dev); 1768 1766 1769 1767 if ((error = cb(host, data))) 1770 1768 break;
+2 -2
drivers/ieee1394/nodemgr.h
··· 84 84 int length; /* Number of quadlets */ 85 85 86 86 struct device device; 87 - struct class_device class_dev; 87 + struct device unit_dev; 88 88 89 89 struct csr1212_keyval *ud_kv; 90 90 u32 lun; /* logical unit number immediate value */ ··· 107 107 u32 capabilities; 108 108 109 109 struct device device; 110 - struct class_device class_dev; 110 + struct device node_dev; 111 111 112 112 /* Means this node is not attached anymore */ 113 113 int in_limbo;
+9 -9
drivers/ieee1394/raw1394.c
··· 3160 3160 hpsb_register_highlevel(&raw1394_highlevel); 3161 3161 3162 3162 if (IS_ERR 3163 - (class_device_create 3164 - (hpsb_protocol_class, NULL, 3165 - MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16), NULL, 3163 + (device_create( 3164 + hpsb_protocol_class, NULL, 3165 + MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16), 3166 3166 RAW1394_DEVICE_NAME))) { 3167 3167 ret = -EFAULT; 3168 3168 goto out_unreg; ··· 3189 3189 goto out; 3190 3190 3191 3191 out_dev: 3192 - class_device_destroy(hpsb_protocol_class, 3193 - MKDEV(IEEE1394_MAJOR, 3194 - IEEE1394_MINOR_BLOCK_RAW1394 * 16)); 3192 + device_destroy(hpsb_protocol_class, 3193 + MKDEV(IEEE1394_MAJOR, 3194 + IEEE1394_MINOR_BLOCK_RAW1394 * 16)); 3195 3195 out_unreg: 3196 3196 hpsb_unregister_highlevel(&raw1394_highlevel); 3197 3197 out: ··· 3200 3200 3201 3201 static void __exit cleanup_raw1394(void) 3202 3202 { 3203 - class_device_destroy(hpsb_protocol_class, 3204 - MKDEV(IEEE1394_MAJOR, 3205 - IEEE1394_MINOR_BLOCK_RAW1394 * 16)); 3203 + device_destroy(hpsb_protocol_class, 3204 + MKDEV(IEEE1394_MAJOR, 3205 + IEEE1394_MINOR_BLOCK_RAW1394 * 16)); 3206 3206 cdev_del(&raw1394_cdev); 3207 3207 hpsb_unregister_highlevel(&raw1394_highlevel); 3208 3208 hpsb_unregister_protocol(&raw1394_driver);
+5 -5
drivers/ieee1394/video1394.c
··· 1340 1340 hpsb_set_hostinfo_key(&video1394_highlevel, host, ohci->host->id); 1341 1341 1342 1342 minor = IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id; 1343 - class_device_create(hpsb_protocol_class, NULL, MKDEV( 1344 - IEEE1394_MAJOR, minor), 1345 - NULL, "%s-%d", VIDEO1394_DRIVER_NAME, ohci->host->id); 1343 + device_create(hpsb_protocol_class, NULL, 1344 + MKDEV(IEEE1394_MAJOR, minor), 1345 + "%s-%d", VIDEO1394_DRIVER_NAME, ohci->host->id); 1346 1346 } 1347 1347 1348 1348 ··· 1351 1351 struct ti_ohci *ohci = hpsb_get_hostinfo(&video1394_highlevel, host); 1352 1352 1353 1353 if (ohci) 1354 - class_device_destroy(hpsb_protocol_class, MKDEV(IEEE1394_MAJOR, 1355 - IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id)); 1354 + device_destroy(hpsb_protocol_class, MKDEV(IEEE1394_MAJOR, 1355 + IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id)); 1356 1356 return; 1357 1357 } 1358 1358