| From kay.sievers@vrfy.org Thu Nov 16 21:09:09 2006 |
| From: Kay Sievers <kay.sievers@vrfy.org> |
| Subject: Driver core: convert ieee1394 subsystem to use struct device |
| Date: Tue, 24 Oct 2006 18:40:53 +0200 |
| Message-Id: <1161708053.3452.4.camel@pim.off.vrfy.org> |
| |
| From: Kay Sievers <kay.sievers@vrfy.org> |
| |
| Converts from using struct "class_device" to "struct device" making |
| everything show up properly in /sys/devices/ with symlinks from the |
| /sys/class directory. |
| |
| Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> |
| Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> |
| --- |
| drivers/ieee1394/dv1394.c | 8 +- |
| drivers/ieee1394/hosts.c | 10 +-- |
| drivers/ieee1394/hosts.h | 2 |
| drivers/ieee1394/nodemgr.c | 117 ++++++++++++++++++++++--------------------- |
| drivers/ieee1394/nodemgr.h | 4 - |
| drivers/ieee1394/raw1394.c | 18 +++--- |
| drivers/ieee1394/video1394.c | 10 +-- |
| 7 files changed, 86 insertions(+), 83 deletions(-) |
| |
| --- a/drivers/ieee1394/dv1394.c |
| +++ b/drivers/ieee1394/dv1394.c |
| @@ -2281,7 +2281,7 @@ static void dv1394_remove_host(struct hp |
| } while (video); |
| |
| if (found_ohci_card) |
| - class_device_destroy(hpsb_protocol_class, MKDEV(IEEE1394_MAJOR, |
| + device_destroy(hpsb_protocol_class, MKDEV(IEEE1394_MAJOR, |
| IEEE1394_MINOR_BLOCK_DV1394 * 16 + (host->id << 2))); |
| } |
| |
| @@ -2296,9 +2296,9 @@ static void dv1394_add_host(struct hpsb_ |
| |
| ohci = (struct ti_ohci *)host->hostdata; |
| |
| - class_device_create(hpsb_protocol_class, NULL, MKDEV( |
| - IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)), |
| - NULL, "dv1394-%d", id); |
| + device_create(hpsb_protocol_class, NULL, MKDEV( |
| + IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)), |
| + "dv1394-%d", id); |
| |
| dv1394_init(ohci, DV1394_NTSC, MODE_RECEIVE); |
| dv1394_init(ohci, DV1394_NTSC, MODE_TRANSMIT); |
| --- a/drivers/ieee1394/hosts.c |
| +++ b/drivers/ieee1394/hosts.c |
| @@ -166,13 +166,13 @@ struct hpsb_host *hpsb_alloc_host(struct |
| h->device.parent = dev; |
| snprintf(h->device.bus_id, BUS_ID_SIZE, "fw-host%d", h->id); |
| |
| - h->class_dev.dev = &h->device; |
| - h->class_dev.class = &hpsb_host_class; |
| - snprintf(h->class_dev.class_id, BUS_ID_SIZE, "fw-host%d", h->id); |
| + h->host_dev.parent = &h->device; |
| + h->host_dev.class = &hpsb_host_class; |
| + snprintf(h->host_dev.bus_id, BUS_ID_SIZE, "fw-host%d", h->id); |
| |
| if (device_register(&h->device)) |
| goto fail; |
| - if (class_device_register(&h->class_dev)) { |
| + if (device_register(&h->host_dev)) { |
| device_unregister(&h->device); |
| goto fail; |
| } |
| @@ -213,7 +213,7 @@ void hpsb_remove_host(struct hpsb_host * |
| highlevel_remove_host(host); |
| hpsb_remove_extra_config_roms(host); |
| |
| - class_device_unregister(&host->class_dev); |
| + device_unregister(&host->host_dev); |
| device_unregister(&host->device); |
| } |
| |
| --- a/drivers/ieee1394/hosts.h |
| +++ b/drivers/ieee1394/hosts.h |
| @@ -59,7 +59,7 @@ struct hpsb_host { |
| struct hpsb_host_driver *driver; |
| struct pci_dev *pdev; |
| struct device device; |
| - struct class_device class_dev; |
| + struct device host_dev; |
| |
| struct delayed_work delayed_reset; |
| unsigned config_roms:31; |
| --- a/drivers/ieee1394/nodemgr.c |
| +++ b/drivers/ieee1394/nodemgr.c |
| @@ -153,7 +153,7 @@ struct host_info { |
| }; |
| |
| static int nodemgr_bus_match(struct device * dev, struct device_driver * drv); |
| -static int nodemgr_uevent(struct class_device *cdev, char **envp, int num_envp, |
| +static int nodemgr_uevent(struct device *dev, char **envp, int num_envp, |
| char *buffer, int buffer_size); |
| static void nodemgr_resume_ne(struct node_entry *ne); |
| static void nodemgr_remove_ne(struct node_entry *ne); |
| @@ -164,37 +164,39 @@ struct bus_type ieee1394_bus_type = { |
| .match = nodemgr_bus_match, |
| }; |
| |
| -static void host_cls_release(struct class_device *class_dev) |
| +static void host_cls_release(struct device *dev) |
| { |
| - put_device(&container_of((class_dev), struct hpsb_host, class_dev)->device); |
| + put_device(&container_of((dev), struct hpsb_host, host_dev)->device); |
| } |
| |
| struct class hpsb_host_class = { |
| .name = "ieee1394_host", |
| - .release = host_cls_release, |
| + .dev_release = host_cls_release, |
| }; |
| |
| -static void ne_cls_release(struct class_device *class_dev) |
| +static void ne_cls_release(struct device *dev) |
| { |
| - put_device(&container_of((class_dev), struct node_entry, class_dev)->device); |
| + put_device(&container_of((dev), struct node_entry, node_dev)->device); |
| } |
| |
| static struct class nodemgr_ne_class = { |
| .name = "ieee1394_node", |
| - .release = ne_cls_release, |
| + .dev_release = ne_cls_release, |
| }; |
| |
| -static void ud_cls_release(struct class_device *class_dev) |
| +static void ud_cls_release(struct device *dev) |
| { |
| - put_device(&container_of((class_dev), struct unit_directory, class_dev)->device); |
| + put_device(&container_of((dev), struct unit_directory, unit_dev)->device); |
| } |
| |
| /* The name here is only so that unit directory hotplug works with old |
| - * style hotplug, which only ever did unit directories anyway. */ |
| + * style hotplug, which only ever did unit directories anyway. We join |
| + * the "ieee1394" subsystem created by the bus. */ |
| static struct class nodemgr_ud_class = { |
| .name = "ieee1394", |
| - .release = ud_cls_release, |
| - .uevent = nodemgr_uevent, |
| + .dev_release = ud_cls_release, |
| + .dev_uevent = nodemgr_uevent, |
| + .bus = &ieee1394_bus_type |
| }; |
| |
| static struct hpsb_highlevel nodemgr_highlevel; |
| @@ -731,11 +733,11 @@ static DEFINE_MUTEX(nodemgr_serialize_re |
| |
| static void nodemgr_remove_uds(struct node_entry *ne) |
| { |
| - struct class_device *cdev; |
| + struct device *dev; |
| struct unit_directory *tmp, *ud; |
| |
| /* Iteration over nodemgr_ud_class.children has to be protected by |
| - * nodemgr_ud_class.sem, but class_device_unregister() will eventually |
| + * nodemgr_ud_class.sem, but device_unregister() will eventually |
| * take nodemgr_ud_class.sem too. Therefore pick out one ud at a time, |
| * release the semaphore, and then unregister the ud. Since this code |
| * may be called from other contexts besides the knodemgrds, protect the |
| @@ -745,9 +747,9 @@ static void nodemgr_remove_uds(struct no |
| for (;;) { |
| ud = NULL; |
| down(&nodemgr_ud_class.sem); |
| - list_for_each_entry(cdev, &nodemgr_ud_class.children, node) { |
| - tmp = container_of(cdev, struct unit_directory, |
| - class_dev); |
| + list_for_each_entry(dev, &nodemgr_ud_class.devices, node) { |
| + tmp = container_of(dev, struct unit_directory, |
| + unit_dev); |
| if (tmp->ne == ne) { |
| ud = tmp; |
| break; |
| @@ -756,7 +758,7 @@ static void nodemgr_remove_uds(struct no |
| up(&nodemgr_ud_class.sem); |
| if (ud == NULL) |
| break; |
| - class_device_unregister(&ud->class_dev); |
| + device_unregister(&ud->unit_dev); |
| device_unregister(&ud->device); |
| } |
| mutex_unlock(&nodemgr_serialize_remove_uds); |
| @@ -773,10 +775,9 @@ static void nodemgr_remove_ne(struct nod |
| |
| HPSB_DEBUG("Node removed: ID:BUS[" NODE_BUS_FMT "] GUID[%016Lx]", |
| NODE_BUS_ARGS(ne->host, ne->nodeid), (unsigned long long)ne->guid); |
| - |
| nodemgr_remove_uds(ne); |
| |
| - class_device_unregister(&ne->class_dev); |
| + device_unregister(&ne->node_dev); |
| device_unregister(dev); |
| |
| put_device(dev); |
| @@ -784,7 +785,9 @@ static void nodemgr_remove_ne(struct nod |
| |
| static int __nodemgr_remove_host_dev(struct device *dev, void *data) |
| { |
| - nodemgr_remove_ne(container_of(dev, struct node_entry, device)); |
| + if (dev->bus == &ieee1394_bus_type) |
| + nodemgr_remove_ne(container_of(dev, struct node_entry, |
| + device)); |
| return 0; |
| } |
| |
| @@ -851,14 +854,14 @@ static struct node_entry *nodemgr_create |
| snprintf(ne->device.bus_id, BUS_ID_SIZE, "%016Lx", |
| (unsigned long long)(ne->guid)); |
| |
| - ne->class_dev.dev = &ne->device; |
| - ne->class_dev.class = &nodemgr_ne_class; |
| - snprintf(ne->class_dev.class_id, BUS_ID_SIZE, "%016Lx", |
| - (unsigned long long)(ne->guid)); |
| + ne->node_dev.parent = &ne->device; |
| + ne->node_dev.class = &nodemgr_ne_class; |
| + snprintf(ne->node_dev.bus_id, BUS_ID_SIZE, "%016Lx", |
| + (unsigned long long)(ne->guid)); |
| |
| if (device_register(&ne->device)) |
| goto fail_devreg; |
| - if (class_device_register(&ne->class_dev)) |
| + if (device_register(&ne->node_dev)) |
| goto fail_classdevreg; |
| get_device(&ne->device); |
| |
| @@ -886,12 +889,12 @@ fail_alloc: |
| |
| static struct node_entry *find_entry_by_guid(u64 guid) |
| { |
| - struct class_device *cdev; |
| + struct device *dev; |
| struct node_entry *ne, *ret_ne = NULL; |
| |
| down(&nodemgr_ne_class.sem); |
| - list_for_each_entry(cdev, &nodemgr_ne_class.children, node) { |
| - ne = container_of(cdev, struct node_entry, class_dev); |
| + list_for_each_entry(dev, &nodemgr_ne_class.children, node) { |
| + ne = container_of(dev, struct node_entry, node_dev); |
| |
| if (ne->guid == guid) { |
| ret_ne = ne; |
| @@ -907,12 +910,12 @@ static struct node_entry *find_entry_by_ |
| static struct node_entry *find_entry_by_nodeid(struct hpsb_host *host, |
| nodeid_t nodeid) |
| { |
| - struct class_device *cdev; |
| + struct device *dev; |
| struct node_entry *ne, *ret_ne = NULL; |
| |
| down(&nodemgr_ne_class.sem); |
| - list_for_each_entry(cdev, &nodemgr_ne_class.children, node) { |
| - ne = container_of(cdev, struct node_entry, class_dev); |
| + list_for_each_entry(dev, &nodemgr_ne_class.children, node) { |
| + ne = container_of(dev, struct node_entry, node_dev); |
| |
| if (ne->host == host && ne->nodeid == nodeid) { |
| ret_ne = ne; |
| @@ -936,14 +939,14 @@ static void nodemgr_register_device(stru |
| snprintf(ud->device.bus_id, BUS_ID_SIZE, "%s-%u", |
| ne->device.bus_id, ud->id); |
| |
| - ud->class_dev.dev = &ud->device; |
| - ud->class_dev.class = &nodemgr_ud_class; |
| - snprintf(ud->class_dev.class_id, BUS_ID_SIZE, "%s-%u", |
| + ud->unit_dev.parent = &ud->device; |
| + ud->unit_dev.class = &nodemgr_ud_class; |
| + snprintf(ud->unit_dev.bus_id, BUS_ID_SIZE, "%s-%u", |
| ne->device.bus_id, ud->id); |
| |
| if (device_register(&ud->device)) |
| goto fail_devreg; |
| - if (class_device_register(&ud->class_dev)) |
| + if (device_register(&ud->unit_dev)) |
| goto fail_classdevreg; |
| get_device(&ud->device); |
| |
| @@ -1155,7 +1158,7 @@ fail: |
| |
| #ifdef CONFIG_HOTPLUG |
| |
| -static int nodemgr_uevent(struct class_device *cdev, char **envp, int num_envp, |
| +static int nodemgr_uevent(struct device *dev, char **envp, int num_envp, |
| char *buffer, int buffer_size) |
| { |
| struct unit_directory *ud; |
| @@ -1165,10 +1168,10 @@ static int nodemgr_uevent(struct class_d |
| /* ieee1394:venNmoNspNverN */ |
| char buf[8 + 1 + 3 + 8 + 2 + 8 + 2 + 8 + 3 + 8 + 1]; |
| |
| - if (!cdev) |
| + if (!dev) |
| return -ENODEV; |
| |
| - ud = container_of(cdev, struct unit_directory, class_dev); |
| + ud = container_of(dev, struct unit_directory, unit_dev); |
| |
| if (ud->ne->in_limbo || ud->ignore_driver) |
| return -ENODEV; |
| @@ -1203,7 +1206,7 @@ do { \ |
| |
| #else |
| |
| -static int nodemgr_uevent(struct class_device *cdev, char **envp, int num_envp, |
| +static int nodemgr_uevent(struct device *dev, char **envp, int num_envp, |
| char *buffer, int buffer_size) |
| { |
| return -ENODEV; |
| @@ -1374,7 +1377,7 @@ static void nodemgr_node_scan(struct hos |
| |
| static void nodemgr_suspend_ne(struct node_entry *ne) |
| { |
| - struct class_device *cdev; |
| + struct device *dev; |
| struct unit_directory *ud; |
| |
| HPSB_DEBUG("Node suspended: ID:BUS[" NODE_BUS_FMT "] GUID[%016Lx]", |
| @@ -1384,8 +1387,8 @@ static void nodemgr_suspend_ne(struct no |
| WARN_ON(device_create_file(&ne->device, &dev_attr_ne_in_limbo)); |
| |
| down(&nodemgr_ud_class.sem); |
| - list_for_each_entry(cdev, &nodemgr_ud_class.children, node) { |
| - ud = container_of(cdev, struct unit_directory, class_dev); |
| + list_for_each_entry(dev, &nodemgr_ud_class.children, node) { |
| + ud = container_of(dev, struct unit_directory, unit_dev); |
| if (ud->ne != ne) |
| continue; |
| |
| @@ -1400,15 +1403,15 @@ static void nodemgr_suspend_ne(struct no |
| |
| static void nodemgr_resume_ne(struct node_entry *ne) |
| { |
| - struct class_device *cdev; |
| + struct device *dev; |
| struct unit_directory *ud; |
| |
| ne->in_limbo = 0; |
| device_remove_file(&ne->device, &dev_attr_ne_in_limbo); |
| |
| down(&nodemgr_ud_class.sem); |
| - list_for_each_entry(cdev, &nodemgr_ud_class.children, node) { |
| - ud = container_of(cdev, struct unit_directory, class_dev); |
| + list_for_each_entry(dev, &nodemgr_ud_class.children, node) { |
| + ud = container_of(dev, struct unit_directory, unit_dev); |
| if (ud->ne != ne) |
| continue; |
| |
| @@ -1426,11 +1429,11 @@ static void nodemgr_update_pdrv(struct n |
| { |
| struct unit_directory *ud; |
| struct hpsb_protocol_driver *pdrv; |
| - struct class_device *cdev; |
| + struct device *dev; |
| |
| down(&nodemgr_ud_class.sem); |
| - list_for_each_entry(cdev, &nodemgr_ud_class.children, node) { |
| - ud = container_of(cdev, struct unit_directory, class_dev); |
| + list_for_each_entry(dev, &nodemgr_ud_class.children, node) { |
| + ud = container_of(dev, struct unit_directory, unit_dev); |
| if (ud->ne != ne) |
| continue; |
| |
| @@ -1505,7 +1508,7 @@ static void nodemgr_probe_ne(struct host |
| static void nodemgr_node_probe(struct host_info *hi, int generation) |
| { |
| struct hpsb_host *host = hi->host; |
| - struct class_device *cdev; |
| + struct device *dev; |
| struct node_entry *ne; |
| |
| /* Do some processing of the nodes we've probed. This pulls them |
| @@ -1518,13 +1521,13 @@ static void nodemgr_node_probe(struct ho |
| * improvement...) */ |
| |
| down(&nodemgr_ne_class.sem); |
| - list_for_each_entry(cdev, &nodemgr_ne_class.children, node) { |
| - ne = container_of(cdev, struct node_entry, class_dev); |
| + list_for_each_entry(dev, &nodemgr_ne_class.children, node) { |
| + ne = container_of(dev, struct node_entry, node_dev); |
| if (!ne->needs_probe) |
| nodemgr_probe_ne(hi, ne, generation); |
| } |
| - list_for_each_entry(cdev, &nodemgr_ne_class.children, node) { |
| - ne = container_of(cdev, struct node_entry, class_dev); |
| + list_for_each_entry(dev, &nodemgr_ne_class.children, node) { |
| + ne = container_of(dev, struct node_entry, node_dev); |
| if (ne->needs_probe) |
| nodemgr_probe_ne(hi, ne, generation); |
| } |
| @@ -1740,13 +1743,13 @@ exit: |
| |
| int nodemgr_for_each_host(void *__data, int (*cb)(struct hpsb_host *, void *)) |
| { |
| - struct class_device *cdev; |
| + struct device *dev; |
| struct hpsb_host *host; |
| int error = 0; |
| |
| down(&hpsb_host_class.sem); |
| - list_for_each_entry(cdev, &hpsb_host_class.children, node) { |
| - host = container_of(cdev, struct hpsb_host, class_dev); |
| + list_for_each_entry(dev, &hpsb_host_class.children, node) { |
| + host = container_of(dev, struct hpsb_host, host_dev); |
| |
| if ((error = cb(host, __data))) |
| break; |
| --- a/drivers/ieee1394/nodemgr.h |
| +++ b/drivers/ieee1394/nodemgr.h |
| @@ -83,7 +83,7 @@ struct unit_directory { |
| int length; /* Number of quadlets */ |
| |
| struct device device; |
| - struct class_device class_dev; |
| + struct device unit_dev; |
| |
| struct csr1212_keyval *ud_kv; |
| u32 lun; /* logical unit number immediate value */ |
| @@ -106,7 +106,7 @@ struct node_entry { |
| u32 capabilities; |
| |
| struct device device; |
| - struct class_device class_dev; |
| + struct device node_dev; |
| |
| /* Means this node is not attached anymore */ |
| int in_limbo; |
| --- a/drivers/ieee1394/raw1394.c |
| +++ b/drivers/ieee1394/raw1394.c |
| @@ -3052,9 +3052,9 @@ static int __init init_raw1394(void) |
| hpsb_register_highlevel(&raw1394_highlevel); |
| |
| if (IS_ERR |
| - (class_device_create |
| - (hpsb_protocol_class, NULL, |
| - MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16), NULL, |
| + (device_create( |
| + hpsb_protocol_class, NULL, |
| + MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16), |
| RAW1394_DEVICE_NAME))) { |
| ret = -EFAULT; |
| goto out_unreg; |
| @@ -3081,9 +3081,9 @@ static int __init init_raw1394(void) |
| goto out; |
| |
| out_dev: |
| - class_device_destroy(hpsb_protocol_class, |
| - MKDEV(IEEE1394_MAJOR, |
| - IEEE1394_MINOR_BLOCK_RAW1394 * 16)); |
| + device_destroy(hpsb_protocol_class, |
| + MKDEV(IEEE1394_MAJOR, |
| + IEEE1394_MINOR_BLOCK_RAW1394 * 16)); |
| out_unreg: |
| hpsb_unregister_highlevel(&raw1394_highlevel); |
| out: |
| @@ -3092,9 +3092,9 @@ static int __init init_raw1394(void) |
| |
| static void __exit cleanup_raw1394(void) |
| { |
| - class_device_destroy(hpsb_protocol_class, |
| - MKDEV(IEEE1394_MAJOR, |
| - IEEE1394_MINOR_BLOCK_RAW1394 * 16)); |
| + device_destroy(hpsb_protocol_class, |
| + MKDEV(IEEE1394_MAJOR, |
| + IEEE1394_MINOR_BLOCK_RAW1394 * 16)); |
| cdev_del(&raw1394_cdev); |
| hpsb_unregister_highlevel(&raw1394_highlevel); |
| hpsb_unregister_protocol(&raw1394_driver); |
| --- a/drivers/ieee1394/video1394.c |
| +++ b/drivers/ieee1394/video1394.c |
| @@ -1341,9 +1341,9 @@ static void video1394_add_host (struct h |
| hpsb_set_hostinfo_key(&video1394_highlevel, host, ohci->host->id); |
| |
| minor = IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id; |
| - class_device_create(hpsb_protocol_class, NULL, MKDEV( |
| - IEEE1394_MAJOR, minor), |
| - NULL, "%s-%d", VIDEO1394_DRIVER_NAME, ohci->host->id); |
| + device_create(hpsb_protocol_class, NULL, |
| + MKDEV(IEEE1394_MAJOR, minor), |
| + "%s-%d", VIDEO1394_DRIVER_NAME, ohci->host->id); |
| } |
| |
| |
| @@ -1352,8 +1352,8 @@ static void video1394_remove_host (struc |
| struct ti_ohci *ohci = hpsb_get_hostinfo(&video1394_highlevel, host); |
| |
| if (ohci) |
| - class_device_destroy(hpsb_protocol_class, MKDEV(IEEE1394_MAJOR, |
| - IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id)); |
| + device_destroy(hpsb_protocol_class, MKDEV(IEEE1394_MAJOR, |
| + IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id)); |
| return; |
| } |
| |