diff options
author | Dmitry Torokhov <dtor_core@ameritech.net> | 2005-09-15 03:01:36 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-10-28 12:52:51 -0400 |
commit | d8539d81aeee4dbdc0624a798321e822fb2df7ae (patch) | |
tree | 3fc46e80f2fdec0a7ca714dfa3fb8f08648d3bb8 | |
parent | 7bd7b091429705eb281d60c553cc643aada8045a (diff) |
[PATCH] Driver core: pass interface to class interface methods
Driver core: pass interface to class intreface methods
Pass interface as argument to add() and remove() class interface
methods. This way a subsystem can implement generic add/remove
handlers and then call interface-specific ones.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/base/class.c | 8 | ||||
-rw-r--r-- | drivers/pcmcia/ds.c | 6 | ||||
-rw-r--r-- | drivers/pcmcia/rsrc_nonstatic.c | 6 | ||||
-rw-r--r-- | drivers/pcmcia/socket_sysfs.c | 6 | ||||
-rw-r--r-- | drivers/scsi/sg.c | 8 | ||||
-rw-r--r-- | include/linux/device.h | 4 |
6 files changed, 22 insertions, 16 deletions
diff --git a/drivers/base/class.c b/drivers/base/class.c index 8df58c57dd25..73d44cf53db0 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c | |||
@@ -532,7 +532,7 @@ int class_device_add(struct class_device *class_dev) | |||
532 | list_add_tail(&class_dev->node, &parent->children); | 532 | list_add_tail(&class_dev->node, &parent->children); |
533 | list_for_each_entry(class_intf, &parent->interfaces, node) | 533 | list_for_each_entry(class_intf, &parent->interfaces, node) |
534 | if (class_intf->add) | 534 | if (class_intf->add) |
535 | class_intf->add(class_dev); | 535 | class_intf->add(class_dev, class_intf); |
536 | up(&parent->sem); | 536 | up(&parent->sem); |
537 | } | 537 | } |
538 | 538 | ||
@@ -612,7 +612,7 @@ void class_device_del(struct class_device *class_dev) | |||
612 | list_del_init(&class_dev->node); | 612 | list_del_init(&class_dev->node); |
613 | list_for_each_entry(class_intf, &parent->interfaces, node) | 613 | list_for_each_entry(class_intf, &parent->interfaces, node) |
614 | if (class_intf->remove) | 614 | if (class_intf->remove) |
615 | class_intf->remove(class_dev); | 615 | class_intf->remove(class_dev, class_intf); |
616 | up(&parent->sem); | 616 | up(&parent->sem); |
617 | } | 617 | } |
618 | 618 | ||
@@ -729,7 +729,7 @@ int class_interface_register(struct class_interface *class_intf) | |||
729 | list_add_tail(&class_intf->node, &parent->interfaces); | 729 | list_add_tail(&class_intf->node, &parent->interfaces); |
730 | if (class_intf->add) { | 730 | if (class_intf->add) { |
731 | list_for_each_entry(class_dev, &parent->children, node) | 731 | list_for_each_entry(class_dev, &parent->children, node) |
732 | class_intf->add(class_dev); | 732 | class_intf->add(class_dev, class_intf); |
733 | } | 733 | } |
734 | up(&parent->sem); | 734 | up(&parent->sem); |
735 | 735 | ||
@@ -748,7 +748,7 @@ void class_interface_unregister(struct class_interface *class_intf) | |||
748 | list_del_init(&class_intf->node); | 748 | list_del_init(&class_intf->node); |
749 | if (class_intf->remove) { | 749 | if (class_intf->remove) { |
750 | list_for_each_entry(class_dev, &parent->children, node) | 750 | list_for_each_entry(class_dev, &parent->children, node) |
751 | class_intf->remove(class_dev); | 751 | class_intf->remove(class_dev, class_intf); |
752 | } | 752 | } |
753 | up(&parent->sem); | 753 | up(&parent->sem); |
754 | 754 | ||
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 080608c7381a..39d096b52926 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c | |||
@@ -1157,7 +1157,8 @@ static struct pcmcia_callback pcmcia_bus_callback = { | |||
1157 | .requery = pcmcia_bus_rescan, | 1157 | .requery = pcmcia_bus_rescan, |
1158 | }; | 1158 | }; |
1159 | 1159 | ||
1160 | static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev) | 1160 | static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev, |
1161 | struct class_interface *class_intf) | ||
1161 | { | 1162 | { |
1162 | struct pcmcia_socket *socket = class_get_devdata(class_dev); | 1163 | struct pcmcia_socket *socket = class_get_devdata(class_dev); |
1163 | int ret; | 1164 | int ret; |
@@ -1192,7 +1193,8 @@ static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev) | |||
1192 | return 0; | 1193 | return 0; |
1193 | } | 1194 | } |
1194 | 1195 | ||
1195 | static void pcmcia_bus_remove_socket(struct class_device *class_dev) | 1196 | static void pcmcia_bus_remove_socket(struct class_device *class_dev, |
1197 | struct class_interface *class_intf) | ||
1196 | { | 1198 | { |
1197 | struct pcmcia_socket *socket = class_get_devdata(class_dev); | 1199 | struct pcmcia_socket *socket = class_get_devdata(class_dev); |
1198 | 1200 | ||
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c index f9a5c70284b5..fc87e7e2b6b8 100644 --- a/drivers/pcmcia/rsrc_nonstatic.c +++ b/drivers/pcmcia/rsrc_nonstatic.c | |||
@@ -994,7 +994,8 @@ static struct class_device_attribute *pccard_rsrc_attributes[] = { | |||
994 | NULL, | 994 | NULL, |
995 | }; | 995 | }; |
996 | 996 | ||
997 | static int __devinit pccard_sysfs_add_rsrc(struct class_device *class_dev) | 997 | static int __devinit pccard_sysfs_add_rsrc(struct class_device *class_dev, |
998 | struct class_interface *class_intf) | ||
998 | { | 999 | { |
999 | struct pcmcia_socket *s = class_get_devdata(class_dev); | 1000 | struct pcmcia_socket *s = class_get_devdata(class_dev); |
1000 | struct class_device_attribute **attr; | 1001 | struct class_device_attribute **attr; |
@@ -1011,7 +1012,8 @@ static int __devinit pccard_sysfs_add_rsrc(struct class_device *class_dev) | |||
1011 | return ret; | 1012 | return ret; |
1012 | } | 1013 | } |
1013 | 1014 | ||
1014 | static void __devexit pccard_sysfs_remove_rsrc(struct class_device *class_dev) | 1015 | static void __devexit pccard_sysfs_remove_rsrc(struct class_device *class_dev, |
1016 | struct class_interface *class_intf) | ||
1015 | { | 1017 | { |
1016 | struct pcmcia_socket *s = class_get_devdata(class_dev); | 1018 | struct pcmcia_socket *s = class_get_devdata(class_dev); |
1017 | struct class_device_attribute **attr; | 1019 | struct class_device_attribute **attr; |
diff --git a/drivers/pcmcia/socket_sysfs.c b/drivers/pcmcia/socket_sysfs.c index 1040a6c1a8a4..4a3150a7854c 100644 --- a/drivers/pcmcia/socket_sysfs.c +++ b/drivers/pcmcia/socket_sysfs.c | |||
@@ -341,7 +341,8 @@ static struct bin_attribute pccard_cis_attr = { | |||
341 | .write = pccard_store_cis, | 341 | .write = pccard_store_cis, |
342 | }; | 342 | }; |
343 | 343 | ||
344 | static int __devinit pccard_sysfs_add_socket(struct class_device *class_dev) | 344 | static int __devinit pccard_sysfs_add_socket(struct class_device *class_dev, |
345 | struct class_interface *class_intf) | ||
345 | { | 346 | { |
346 | struct class_device_attribute **attr; | 347 | struct class_device_attribute **attr; |
347 | int ret = 0; | 348 | int ret = 0; |
@@ -357,7 +358,8 @@ static int __devinit pccard_sysfs_add_socket(struct class_device *class_dev) | |||
357 | return ret; | 358 | return ret; |
358 | } | 359 | } |
359 | 360 | ||
360 | static void __devexit pccard_sysfs_remove_socket(struct class_device *class_dev) | 361 | static void __devexit pccard_sysfs_remove_socket(struct class_device *class_dev, |
362 | struct class_interface *class_intf) | ||
361 | { | 363 | { |
362 | struct class_device_attribute **attr; | 364 | struct class_device_attribute **attr; |
363 | 365 | ||
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index ad94367df430..f0d8b4eda5ad 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
@@ -104,8 +104,8 @@ static int sg_allow_dio = SG_ALLOW_DIO_DEF; | |||
104 | 104 | ||
105 | #define SG_DEV_ARR_LUMP 32 /* amount to over allocate sg_dev_arr by */ | 105 | #define SG_DEV_ARR_LUMP 32 /* amount to over allocate sg_dev_arr by */ |
106 | 106 | ||
107 | static int sg_add(struct class_device *); | 107 | static int sg_add(struct class_device *, struct class_interface *); |
108 | static void sg_remove(struct class_device *); | 108 | static void sg_remove(struct class_device *, struct class_interface *); |
109 | 109 | ||
110 | static Scsi_Request *dummy_cmdp; /* only used for sizeof */ | 110 | static Scsi_Request *dummy_cmdp; /* only used for sizeof */ |
111 | 111 | ||
@@ -1506,7 +1506,7 @@ static int sg_alloc(struct gendisk *disk, struct scsi_device *scsidp) | |||
1506 | } | 1506 | } |
1507 | 1507 | ||
1508 | static int | 1508 | static int |
1509 | sg_add(struct class_device *cl_dev) | 1509 | sg_add(struct class_device *cl_dev, struct class_interface *cl_intf) |
1510 | { | 1510 | { |
1511 | struct scsi_device *scsidp = to_scsi_device(cl_dev->dev); | 1511 | struct scsi_device *scsidp = to_scsi_device(cl_dev->dev); |
1512 | struct gendisk *disk; | 1512 | struct gendisk *disk; |
@@ -1582,7 +1582,7 @@ out: | |||
1582 | } | 1582 | } |
1583 | 1583 | ||
1584 | static void | 1584 | static void |
1585 | sg_remove(struct class_device *cl_dev) | 1585 | sg_remove(struct class_device *cl_dev, struct class_interface *cl_intf) |
1586 | { | 1586 | { |
1587 | struct scsi_device *scsidp = to_scsi_device(cl_dev->dev); | 1587 | struct scsi_device *scsidp = to_scsi_device(cl_dev->dev); |
1588 | Sg_device *sdp = NULL; | 1588 | Sg_device *sdp = NULL; |
diff --git a/include/linux/device.h b/include/linux/device.h index 95d607a48f06..a53a822c4d16 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -251,8 +251,8 @@ struct class_interface { | |||
251 | struct list_head node; | 251 | struct list_head node; |
252 | struct class *class; | 252 | struct class *class; |
253 | 253 | ||
254 | int (*add) (struct class_device *); | 254 | int (*add) (struct class_device *, struct class_interface *); |
255 | void (*remove) (struct class_device *); | 255 | void (*remove) (struct class_device *, struct class_interface *); |
256 | }; | 256 | }; |
257 | 257 | ||
258 | extern int class_interface_register(struct class_interface *); | 258 | extern int class_interface_register(struct class_interface *); |