aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ieee1394/nodemgr.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ieee1394/nodemgr.c')
-rw-r--r--drivers/ieee1394/nodemgr.c118
1 files changed, 60 insertions, 58 deletions
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
index 81b3864d2ba7..893955249bad 100644
--- a/drivers/ieee1394/nodemgr.c
+++ b/drivers/ieee1394/nodemgr.c
@@ -154,7 +154,7 @@ struct host_info {
154}; 154};
155 155
156static int nodemgr_bus_match(struct device * dev, struct device_driver * drv); 156static int nodemgr_bus_match(struct device * dev, struct device_driver * drv);
157static int nodemgr_uevent(struct class_device *cdev, char **envp, int num_envp, 157static int nodemgr_uevent(struct device *dev, char **envp, int num_envp,
158 char *buffer, int buffer_size); 158 char *buffer, int buffer_size);
159static void nodemgr_resume_ne(struct node_entry *ne); 159static void nodemgr_resume_ne(struct node_entry *ne);
160static void nodemgr_remove_ne(struct node_entry *ne); 160static void nodemgr_remove_ne(struct node_entry *ne);
@@ -165,37 +165,38 @@ struct bus_type ieee1394_bus_type = {
165 .match = nodemgr_bus_match, 165 .match = nodemgr_bus_match,
166}; 166};
167 167
168static void host_cls_release(struct class_device *class_dev) 168static 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
173struct class hpsb_host_class = { 173struct class hpsb_host_class = {
174 .name = "ieee1394_host", 174 .name = "ieee1394_host",
175 .release = host_cls_release, 175 .dev_release = host_cls_release,
176}; 176};
177 177
178static void ne_cls_release(struct class_device *class_dev) 178static 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
183static struct class nodemgr_ne_class = { 183static struct class nodemgr_ne_class = {
184 .name = "ieee1394_node", 184 .name = "ieee1394_node",
185 .release = ne_cls_release, 185 .dev_release = ne_cls_release,
186}; 186};
187 187
188static void ud_cls_release(struct class_device *class_dev) 188static 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/* The name here is only so that unit directory hotplug works with old 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 */
195static struct class nodemgr_ud_class = { 196static struct class nodemgr_ud_class = {
196 .name = "ieee1394", 197 .name = "ieee1394",
197 .release = ud_cls_release, 198 .dev_release = ud_cls_release,
198 .uevent = nodemgr_uevent, 199 .dev_uevent = nodemgr_uevent,
199}; 200};
200 201
201static struct hpsb_highlevel nodemgr_highlevel; 202static struct hpsb_highlevel nodemgr_highlevel;
@@ -730,11 +731,11 @@ static DEFINE_MUTEX(nodemgr_serialize_remove_uds);
730 731
731static void nodemgr_remove_uds(struct node_entry *ne) 732static void nodemgr_remove_uds(struct node_entry *ne)
732{ 733{
733 struct class_device *cdev; 734 struct device *dev;
734 struct unit_directory *tmp, *ud; 735 struct unit_directory *tmp, *ud;
735 736
736 /* Iteration over nodemgr_ud_class.children has to be protected by 737 /* Iteration over nodemgr_ud_class.devices has to be protected by
737 * nodemgr_ud_class.sem, but class_device_unregister() will eventually 738 * nodemgr_ud_class.sem, but device_unregister() will eventually
738 * take nodemgr_ud_class.sem too. Therefore pick out one ud at a time, 739 * take nodemgr_ud_class.sem too. Therefore pick out one ud at a time,
739 * release the semaphore, and then unregister the ud. Since this code 740 * release the semaphore, and then unregister the ud. Since this code
740 * may be called from other contexts besides the knodemgrds, protect the 741 * may be called from other contexts besides the knodemgrds, protect the
@@ -744,9 +745,9 @@ static void nodemgr_remove_uds(struct node_entry *ne)
744 for (;;) { 745 for (;;) {
745 ud = NULL; 746 ud = NULL;
746 down(&nodemgr_ud_class.sem); 747 down(&nodemgr_ud_class.sem);
747 list_for_each_entry(cdev, &nodemgr_ud_class.children, node) { 748 list_for_each_entry(dev, &nodemgr_ud_class.devices, node) {
748 tmp = container_of(cdev, struct unit_directory, 749 tmp = container_of(dev, struct unit_directory,
749 class_dev); 750 unit_dev);
750 if (tmp->ne == ne) { 751 if (tmp->ne == ne) {
751 ud = tmp; 752 ud = tmp;
752 break; 753 break;
@@ -755,7 +756,7 @@ static void nodemgr_remove_uds(struct node_entry *ne)
755 up(&nodemgr_ud_class.sem); 756 up(&nodemgr_ud_class.sem);
756 if (ud == NULL) 757 if (ud == NULL)
757 break; 758 break;
758 class_device_unregister(&ud->class_dev); 759 device_unregister(&ud->unit_dev);
759 device_unregister(&ud->device); 760 device_unregister(&ud->device);
760 } 761 }
761 mutex_unlock(&nodemgr_serialize_remove_uds); 762 mutex_unlock(&nodemgr_serialize_remove_uds);
@@ -772,10 +773,9 @@ static void nodemgr_remove_ne(struct node_entry *ne)
772 773
773 HPSB_DEBUG("Node removed: ID:BUS[" NODE_BUS_FMT "] GUID[%016Lx]", 774 HPSB_DEBUG("Node removed: ID:BUS[" NODE_BUS_FMT "] GUID[%016Lx]",
774 NODE_BUS_ARGS(ne->host, ne->nodeid), (unsigned long long)ne->guid); 775 NODE_BUS_ARGS(ne->host, ne->nodeid), (unsigned long long)ne->guid);
775
776 nodemgr_remove_uds(ne); 776 nodemgr_remove_uds(ne);
777 777
778 class_device_unregister(&ne->class_dev); 778 device_unregister(&ne->node_dev);
779 device_unregister(dev); 779 device_unregister(dev);
780 780
781 put_device(dev); 781 put_device(dev);
@@ -783,7 +783,9 @@ static void nodemgr_remove_ne(struct node_entry *ne)
783 783
784static int __nodemgr_remove_host_dev(struct device *dev, void *data) 784static 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 return 0; 789 return 0;
788} 790}
789 791
@@ -850,14 +852,14 @@ static struct node_entry *nodemgr_create_node(octlet_t guid, struct csr1212_csr
850 snprintf(ne->device.bus_id, BUS_ID_SIZE, "%016Lx", 852 snprintf(ne->device.bus_id, BUS_ID_SIZE, "%016Lx",
851 (unsigned long long)(ne->guid)); 853 (unsigned long long)(ne->guid));
852 854
853 ne->class_dev.dev = &ne->device; 855 ne->node_dev.parent = &ne->device;
854 ne->class_dev.class = &nodemgr_ne_class; 856 ne->node_dev.class = &nodemgr_ne_class;
855 snprintf(ne->class_dev.class_id, BUS_ID_SIZE, "%016Lx", 857 snprintf(ne->node_dev.bus_id, BUS_ID_SIZE, "%016Lx",
856 (unsigned long long)(ne->guid)); 858 (unsigned long long)(ne->guid));
857 859
858 if (device_register(&ne->device)) 860 if (device_register(&ne->device))
859 goto fail_devreg; 861 goto fail_devreg;
860 if (class_device_register(&ne->class_dev)) 862 if (device_register(&ne->node_dev))
861 goto fail_classdevreg; 863 goto fail_classdevreg;
862 get_device(&ne->device); 864 get_device(&ne->device);
863 865
@@ -885,12 +887,12 @@ fail_alloc:
885 887
886static struct node_entry *find_entry_by_guid(u64 guid) 888static struct node_entry *find_entry_by_guid(u64 guid)
887{ 889{
888 struct class_device *cdev; 890 struct device *dev;
889 struct node_entry *ne, *ret_ne = NULL; 891 struct node_entry *ne, *ret_ne = NULL;
890 892
891 down(&nodemgr_ne_class.sem); 893 down(&nodemgr_ne_class.sem);
892 list_for_each_entry(cdev, &nodemgr_ne_class.children, node) { 894 list_for_each_entry(dev, &nodemgr_ne_class.devices, node) {
893 ne = container_of(cdev, struct node_entry, class_dev); 895 ne = container_of(dev, struct node_entry, node_dev);
894 896
895 if (ne->guid == guid) { 897 if (ne->guid == guid) {
896 ret_ne = ne; 898 ret_ne = ne;
@@ -906,12 +908,12 @@ static struct node_entry *find_entry_by_guid(u64 guid)
906static struct node_entry *find_entry_by_nodeid(struct hpsb_host *host, 908static struct node_entry *find_entry_by_nodeid(struct hpsb_host *host,
907 nodeid_t nodeid) 909 nodeid_t nodeid)
908{ 910{
909 struct class_device *cdev; 911 struct device *dev;
910 struct node_entry *ne, *ret_ne = NULL; 912 struct node_entry *ne, *ret_ne = NULL;
911 913
912 down(&nodemgr_ne_class.sem); 914 down(&nodemgr_ne_class.sem);
913 list_for_each_entry(cdev, &nodemgr_ne_class.children, node) { 915 list_for_each_entry(dev, &nodemgr_ne_class.devices, node) {
914 ne = container_of(cdev, struct node_entry, class_dev); 916 ne = container_of(dev, struct node_entry, node_dev);
915 917
916 if (ne->host == host && ne->nodeid == nodeid) { 918 if (ne->host == host && ne->nodeid == nodeid) {
917 ret_ne = ne; 919 ret_ne = ne;
@@ -935,14 +937,14 @@ static void nodemgr_register_device(struct node_entry *ne,
935 snprintf(ud->device.bus_id, BUS_ID_SIZE, "%s-%u", 937 snprintf(ud->device.bus_id, BUS_ID_SIZE, "%s-%u",
936 ne->device.bus_id, ud->id); 938 ne->device.bus_id, ud->id);
937 939
938 ud->class_dev.dev = &ud->device; 940 ud->unit_dev.parent = &ud->device;
939 ud->class_dev.class = &nodemgr_ud_class; 941 ud->unit_dev.class = &nodemgr_ud_class;
940 snprintf(ud->class_dev.class_id, BUS_ID_SIZE, "%s-%u", 942 snprintf(ud->unit_dev.bus_id, BUS_ID_SIZE, "%s-%u",
941 ne->device.bus_id, ud->id); 943 ne->device.bus_id, ud->id);
942 944
943 if (device_register(&ud->device)) 945 if (device_register(&ud->device))
944 goto fail_devreg; 946 goto fail_devreg;
945 if (class_device_register(&ud->class_dev)) 947 if (device_register(&ud->unit_dev))
946 goto fail_classdevreg; 948 goto fail_classdevreg;
947 get_device(&ud->device); 949 get_device(&ud->device);
948 950
@@ -1159,7 +1161,7 @@ static void nodemgr_process_root_directory(struct host_info *hi, struct node_ent
1159 1161
1160#ifdef CONFIG_HOTPLUG 1162#ifdef CONFIG_HOTPLUG
1161 1163
1162static int nodemgr_uevent(struct class_device *cdev, char **envp, int num_envp, 1164static int nodemgr_uevent(struct device *dev, char **envp, int num_envp,
1163 char *buffer, int buffer_size) 1165 char *buffer, int buffer_size)
1164{ 1166{
1165 struct unit_directory *ud; 1167 struct unit_directory *ud;
@@ -1169,10 +1171,10 @@ static int nodemgr_uevent(struct class_device *cdev, char **envp, int num_envp,
1169 /* ieee1394:venNmoNspNverN */ 1171 /* ieee1394:venNmoNspNverN */
1170 char buf[8 + 1 + 3 + 8 + 2 + 8 + 2 + 8 + 3 + 8 + 1]; 1172 char buf[8 + 1 + 3 + 8 + 2 + 8 + 2 + 8 + 3 + 8 + 1];
1171 1173
1172 if (!cdev) 1174 if (!dev)
1173 return -ENODEV; 1175 return -ENODEV;
1174 1176
1175 ud = container_of(cdev, struct unit_directory, class_dev); 1177 ud = container_of(dev, struct unit_directory, unit_dev);
1176 1178
1177 if (ud->ne->in_limbo || ud->ignore_driver) 1179 if (ud->ne->in_limbo || ud->ignore_driver)
1178 return -ENODEV; 1180 return -ENODEV;
@@ -1207,7 +1209,7 @@ do { \
1207 1209
1208#else 1210#else
1209 1211
1210static int nodemgr_uevent(struct class_device *cdev, char **envp, int num_envp, 1212static int nodemgr_uevent(struct device *dev, char **envp, int num_envp,
1211 char *buffer, int buffer_size) 1213 char *buffer, int buffer_size)
1212{ 1214{
1213 return -ENODEV; 1215 return -ENODEV;
@@ -1378,7 +1380,7 @@ static void nodemgr_node_scan(struct host_info *hi, int generation)
1378 1380
1379static void nodemgr_suspend_ne(struct node_entry *ne) 1381static void nodemgr_suspend_ne(struct node_entry *ne)
1380{ 1382{
1381 struct class_device *cdev; 1383 struct device *dev;
1382 struct unit_directory *ud; 1384 struct unit_directory *ud;
1383 1385
1384 HPSB_DEBUG("Node suspended: ID:BUS[" NODE_BUS_FMT "] GUID[%016Lx]", 1386 HPSB_DEBUG("Node suspended: ID:BUS[" NODE_BUS_FMT "] GUID[%016Lx]",
@@ -1388,8 +1390,8 @@ static void nodemgr_suspend_ne(struct node_entry *ne)
1388 WARN_ON(device_create_file(&ne->device, &dev_attr_ne_in_limbo)); 1390 WARN_ON(device_create_file(&ne->device, &dev_attr_ne_in_limbo));
1389 1391
1390 down(&nodemgr_ud_class.sem); 1392 down(&nodemgr_ud_class.sem);
1391 list_for_each_entry(cdev, &nodemgr_ud_class.children, node) { 1393 list_for_each_entry(dev, &nodemgr_ud_class.devices, node) {
1392 ud = container_of(cdev, struct unit_directory, class_dev); 1394 ud = container_of(dev, struct unit_directory, unit_dev);
1393 if (ud->ne != ne) 1395 if (ud->ne != ne)
1394 continue; 1396 continue;
1395 1397
@@ -1404,15 +1406,15 @@ static void nodemgr_suspend_ne(struct node_entry *ne)
1404 1406
1405static void nodemgr_resume_ne(struct node_entry *ne) 1407static void nodemgr_resume_ne(struct node_entry *ne)
1406{ 1408{
1407 struct class_device *cdev; 1409 struct device *dev;
1408 struct unit_directory *ud; 1410 struct unit_directory *ud;
1409 1411
1410 ne->in_limbo = 0; 1412 ne->in_limbo = 0;
1411 device_remove_file(&ne->device, &dev_attr_ne_in_limbo); 1413 device_remove_file(&ne->device, &dev_attr_ne_in_limbo);
1412 1414
1413 down(&nodemgr_ud_class.sem); 1415 down(&nodemgr_ud_class.sem);
1414 list_for_each_entry(cdev, &nodemgr_ud_class.children, node) { 1416 list_for_each_entry(dev, &nodemgr_ud_class.devices, node) {
1415 ud = container_of(cdev, struct unit_directory, class_dev); 1417 ud = container_of(dev, struct unit_directory, unit_dev);
1416 if (ud->ne != ne) 1418 if (ud->ne != ne)
1417 continue; 1419 continue;
1418 1420
@@ -1430,11 +1432,11 @@ static void nodemgr_update_pdrv(struct node_entry *ne)
1430{ 1432{
1431 struct unit_directory *ud; 1433 struct unit_directory *ud;
1432 struct hpsb_protocol_driver *pdrv; 1434 struct hpsb_protocol_driver *pdrv;
1433 struct class_device *cdev; 1435 struct device *dev;
1434 1436
1435 down(&nodemgr_ud_class.sem); 1437 down(&nodemgr_ud_class.sem);
1436 list_for_each_entry(cdev, &nodemgr_ud_class.children, node) { 1438 list_for_each_entry(dev, &nodemgr_ud_class.devices, node) {
1437 ud = container_of(cdev, struct unit_directory, class_dev); 1439 ud = container_of(dev, struct unit_directory, unit_dev);
1438 if (ud->ne != ne) 1440 if (ud->ne != ne)
1439 continue; 1441 continue;
1440 1442
@@ -1509,7 +1511,7 @@ static void nodemgr_probe_ne(struct host_info *hi, struct node_entry *ne, int ge
1509static void nodemgr_node_probe(struct host_info *hi, int generation) 1511static void nodemgr_node_probe(struct host_info *hi, int generation)
1510{ 1512{
1511 struct hpsb_host *host = hi->host; 1513 struct hpsb_host *host = hi->host;
1512 struct class_device *cdev; 1514 struct device *dev;
1513 struct node_entry *ne; 1515 struct node_entry *ne;
1514 1516
1515 /* Do some processing of the nodes we've probed. This pulls them 1517 /* Do some processing of the nodes we've probed. This pulls them
@@ -1522,13 +1524,13 @@ static void nodemgr_node_probe(struct host_info *hi, int generation)
1522 * improvement...) */ 1524 * improvement...) */
1523 1525
1524 down(&nodemgr_ne_class.sem); 1526 down(&nodemgr_ne_class.sem);
1525 list_for_each_entry(cdev, &nodemgr_ne_class.children, node) { 1527 list_for_each_entry(dev, &nodemgr_ne_class.devices, node) {
1526 ne = container_of(cdev, struct node_entry, class_dev); 1528 ne = container_of(dev, struct node_entry, node_dev);
1527 if (!ne->needs_probe) 1529 if (!ne->needs_probe)
1528 nodemgr_probe_ne(hi, ne, generation); 1530 nodemgr_probe_ne(hi, ne, generation);
1529 } 1531 }
1530 list_for_each_entry(cdev, &nodemgr_ne_class.children, node) { 1532 list_for_each_entry(dev, &nodemgr_ne_class.devices, node) {
1531 ne = container_of(cdev, struct node_entry, class_dev); 1533 ne = container_of(dev, struct node_entry, node_dev);
1532 if (ne->needs_probe) 1534 if (ne->needs_probe)
1533 nodemgr_probe_ne(hi, ne, generation); 1535 nodemgr_probe_ne(hi, ne, generation);
1534 } 1536 }
@@ -1756,13 +1758,13 @@ exit:
1756 */ 1758 */
1757int nodemgr_for_each_host(void *data, int (*cb)(struct hpsb_host *, void *)) 1759int nodemgr_for_each_host(void *data, int (*cb)(struct hpsb_host *, void *))
1758{ 1760{
1759 struct class_device *cdev; 1761 struct device *dev;
1760 struct hpsb_host *host; 1762 struct hpsb_host *host;
1761 int error = 0; 1763 int error = 0;
1762 1764
1763 down(&hpsb_host_class.sem); 1765 down(&hpsb_host_class.sem);
1764 list_for_each_entry(cdev, &hpsb_host_class.children, node) { 1766 list_for_each_entry(dev, &hpsb_host_class.devices, node) {
1765 host = container_of(cdev, struct hpsb_host, class_dev); 1767 host = container_of(dev, struct hpsb_host, host_dev);
1766 1768
1767 if ((error = cb(host, data))) 1769 if ((error = cb(host, data)))
1768 break; 1770 break;