[PATCH] Driver core: pass interface to class interface methods
authorDmitry Torokhov <dtor_core@ameritech.net>
Thu, 15 Sep 2005 07:01:36 +0000 (02:01 -0500)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 28 Oct 2005 16:52:51 +0000 (09:52 -0700)
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>
drivers/base/class.c
drivers/pcmcia/ds.c
drivers/pcmcia/rsrc_nonstatic.c
drivers/pcmcia/socket_sysfs.c
drivers/scsi/sg.c
include/linux/device.h

index 8df58c57dd25a04787032400a98a158946925005..73d44cf53db0f891de96d8af3ece1ef20474a2b1 100644 (file)
@@ -532,7 +532,7 @@ int class_device_add(struct class_device *class_dev)
                list_add_tail(&class_dev->node, &parent->children);
                list_for_each_entry(class_intf, &parent->interfaces, node)
                        if (class_intf->add)
-                               class_intf->add(class_dev);
+                               class_intf->add(class_dev, class_intf);
                up(&parent->sem);
        }
 
@@ -612,7 +612,7 @@ void class_device_del(struct class_device *class_dev)
                list_del_init(&class_dev->node);
                list_for_each_entry(class_intf, &parent->interfaces, node)
                        if (class_intf->remove)
-                               class_intf->remove(class_dev);
+                               class_intf->remove(class_dev, class_intf);
                up(&parent->sem);
        }
 
@@ -729,7 +729,7 @@ int class_interface_register(struct class_interface *class_intf)
        list_add_tail(&class_intf->node, &parent->interfaces);
        if (class_intf->add) {
                list_for_each_entry(class_dev, &parent->children, node)
-                       class_intf->add(class_dev);
+                       class_intf->add(class_dev, class_intf);
        }
        up(&parent->sem);
 
@@ -748,7 +748,7 @@ void class_interface_unregister(struct class_interface *class_intf)
        list_del_init(&class_intf->node);
        if (class_intf->remove) {
                list_for_each_entry(class_dev, &parent->children, node)
-                       class_intf->remove(class_dev);
+                       class_intf->remove(class_dev, class_intf);
        }
        up(&parent->sem);
 
index 080608c7381a749226fb9d136dbd39f19ec7a380..39d096b52926fb4c5d6b33976c38c75511117ac1 100644 (file)
@@ -1157,7 +1157,8 @@ static struct pcmcia_callback pcmcia_bus_callback = {
        .requery = pcmcia_bus_rescan,
 };
 
-static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev)
+static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev,
+                                          struct class_interface *class_intf)
 {
        struct pcmcia_socket *socket = class_get_devdata(class_dev);
        int ret;
@@ -1192,7 +1193,8 @@ static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev)
        return 0;
 }
 
-static void pcmcia_bus_remove_socket(struct class_device *class_dev)
+static void pcmcia_bus_remove_socket(struct class_device *class_dev,
+                                    struct class_interface *class_intf)
 {
        struct pcmcia_socket *socket = class_get_devdata(class_dev);
 
index f9a5c70284b5a8901a7afbd86d07f39b1330978b..fc87e7e2b6b800e90ab43b9e203836b13afd0ba2 100644 (file)
@@ -994,7 +994,8 @@ static struct class_device_attribute *pccard_rsrc_attributes[] = {
        NULL,
 };
 
-static int __devinit pccard_sysfs_add_rsrc(struct class_device *class_dev)
+static int __devinit pccard_sysfs_add_rsrc(struct class_device *class_dev,
+                                          struct class_interface *class_intf)
 {
        struct pcmcia_socket *s = class_get_devdata(class_dev);
        struct class_device_attribute **attr;
@@ -1011,7 +1012,8 @@ static int __devinit pccard_sysfs_add_rsrc(struct class_device *class_dev)
        return ret;
 }
 
-static void __devexit pccard_sysfs_remove_rsrc(struct class_device *class_dev)
+static void __devexit pccard_sysfs_remove_rsrc(struct class_device *class_dev,
+                                              struct class_interface *class_intf)
 {
        struct pcmcia_socket *s = class_get_devdata(class_dev);
        struct class_device_attribute **attr;
index 1040a6c1a8a44c25eec76006154670bee4d69864..4a3150a7854cceab92c4cef1c2ac480c29a67e12 100644 (file)
@@ -341,7 +341,8 @@ static struct bin_attribute pccard_cis_attr = {
        .write = pccard_store_cis,
 };
 
-static int __devinit pccard_sysfs_add_socket(struct class_device *class_dev)
+static int __devinit pccard_sysfs_add_socket(struct class_device *class_dev,
+                                            struct class_interface *class_intf)
 {
        struct class_device_attribute **attr;
        int ret = 0;
@@ -357,7 +358,8 @@ static int __devinit pccard_sysfs_add_socket(struct class_device *class_dev)
        return ret;
 }
 
-static void __devexit pccard_sysfs_remove_socket(struct class_device *class_dev)
+static void __devexit pccard_sysfs_remove_socket(struct class_device *class_dev,
+                                                struct class_interface *class_intf)
 {
        struct class_device_attribute **attr;
 
index ad94367df430a8d8df9d9b62109fc2bf545b7af9..f0d8b4eda5adceffc42deb382eaf5f37855db296 100644 (file)
@@ -104,8 +104,8 @@ static int sg_allow_dio = SG_ALLOW_DIO_DEF;
 
 #define SG_DEV_ARR_LUMP 32     /* amount to over allocate sg_dev_arr by */
 
-static int sg_add(struct class_device *);
-static void sg_remove(struct class_device *);
+static int sg_add(struct class_device *, struct class_interface *);
+static void sg_remove(struct class_device *, struct class_interface *);
 
 static Scsi_Request *dummy_cmdp;       /* only used for sizeof */
 
@@ -1506,7 +1506,7 @@ static int sg_alloc(struct gendisk *disk, struct scsi_device *scsidp)
 }
 
 static int
-sg_add(struct class_device *cl_dev)
+sg_add(struct class_device *cl_dev, struct class_interface *cl_intf)
 {
        struct scsi_device *scsidp = to_scsi_device(cl_dev->dev);
        struct gendisk *disk;
@@ -1582,7 +1582,7 @@ out:
 }
 
 static void
-sg_remove(struct class_device *cl_dev)
+sg_remove(struct class_device *cl_dev, struct class_interface *cl_intf)
 {
        struct scsi_device *scsidp = to_scsi_device(cl_dev->dev);
        Sg_device *sdp = NULL;
index 95d607a48f06edd22c6be64e0feaf74d1aa63467..a53a822c4d16f19e12024b0366849b6b156d2e30 100644 (file)
@@ -251,8 +251,8 @@ struct class_interface {
        struct list_head        node;
        struct class            *class;
 
-       int (*add)      (struct class_device *);
-       void (*remove)  (struct class_device *);
+       int (*add)      (struct class_device *, struct class_interface *);
+       void (*remove)  (struct class_device *, struct class_interface *);
 };
 
 extern int class_interface_register(struct class_interface *);