staging: unisys: Convert bus functions to pass bus_info pointer around
authorDon Zickus <dzickus@redhat.com>
Wed, 13 May 2015 17:22:24 +0000 (13:22 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 24 May 2015 20:28:56 +0000 (13:28 -0700)
Most bus functions pass bus_no around and then do a lookup inside each
function to find the bus_info struct.  Instead just pass the pointer.

This prepares us for a later conversion to using visor_device.

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/unisys/visorbus/visorbus_main.c
drivers/staging/unisys/visorbus/visorbus_private.h
drivers/staging/unisys/visorbus/visorchipset.c

index b66fce5d63b52b82975d428c1f4ca47307c3b908..dd36d7b7e743678e7616d09b8528ad5aae0de958 100644 (file)
@@ -108,8 +108,8 @@ static long long bus_count; /** number of bus instances */
 static long long total_devices_created;
                                        /** ever-increasing */
 
-static void chipset_bus_create(u32 bus_no);
-static void chipset_bus_destroy(u32 bus_no);
+static void chipset_bus_create(struct visorchipset_bus_info *bus_info);
+static void chipset_bus_destroy(struct visorchipset_bus_info *bus_info);
 static void chipset_device_create(u32 bus_no, u32 dev_no);
 static void chipset_device_destroy(u32 bus_no, u32 dev_no);
 static void chipset_device_pause(u32 bus_no, u32 dev_no);
@@ -1331,11 +1331,11 @@ fix_vbus_dev_info(struct visor_device *visordev)
 /** Create a device instance for the visor bus itself.
  */
 static struct visorbus_devdata *
-create_bus_instance(int id)
+create_bus_instance(struct visorchipset_bus_info *bus_info)
 {
        struct visorbus_devdata *rc = NULL;
        struct visorbus_devdata *devdata = NULL;
-       struct visorchipset_bus_info bus_info;
+       int id = bus_info->bus_no;
 
        POSTCODE_LINUX_2(BUS_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
        devdata = kzalloc(sizeof(*devdata), GFP_KERNEL);
@@ -1355,15 +1355,14 @@ create_bus_instance(int id)
                goto away;
        }
        devdata->devno = id;
-       if ((visorchipset_get_bus_info(id, &bus_info)) &&
-           (bus_info.chan_info.channel_addr > 0) &&
-           (bus_info.chan_info.n_channel_bytes > 0)) {
-               u64 channel_addr = bus_info.chan_info.channel_addr;
+       if ((bus_info->chan_info.channel_addr > 0) &&
+           (bus_info->chan_info.n_channel_bytes > 0)) {
+               u64 channel_addr = bus_info->chan_info.channel_addr;
                unsigned long n_channel_bytes =
                                (unsigned long)
-                               bus_info.chan_info.n_channel_bytes;
+                               bus_info->chan_info.n_channel_bytes;
                uuid_le channel_type_guid =
-                               bus_info.chan_info.channel_type_uuid;
+                               bus_info->chan_info.channel_type_uuid;
 
                devdata->chan = visorchannel_create(channel_addr,
                                                    n_channel_bytes,
@@ -1373,7 +1372,7 @@ create_bus_instance(int id)
                        POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, channel_addr,
                                         POSTCODE_SEVERITY_ERR);
                } else {
-                       if (bus_info.flags.server) {
+                       if (bus_info->flags.server) {
                                init_vbus_channel(devdata->chan);
                        } else {
                                if (get_vbus_header_info(devdata->chan,
@@ -1466,19 +1465,17 @@ static unsigned long test_bus_nos[MAXDEVICETEST];
 static unsigned long test_dev_nos[MAXDEVICETEST];
 
 static void
-chipset_bus_create(u32 bus_no)
+chipset_bus_create(struct visorchipset_bus_info *bus_info)
 {
-       struct visorchipset_bus_info bus_info;
        struct visorbus_devdata *devdata;
        int rc = -1;
+       u32 bus_no = bus_info->bus_no;
 
        POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, bus_no, POSTCODE_SEVERITY_INFO);
-       if (!visorchipset_get_bus_info(bus_no, &bus_info))
-               goto away;
-       devdata = create_bus_instance(bus_no);
+       devdata = create_bus_instance(bus_info);
        if (!devdata)
                goto away;
-       if (!visorchipset_set_bus_context(bus_no, devdata))
+       if (!visorchipset_set_bus_context(bus_info, devdata))
                goto away;
        POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus_no, POSTCODE_SEVERITY_INFO);
        rc = 0;
@@ -1491,30 +1488,27 @@ away:
        POSTCODE_LINUX_3(CHIPSET_INIT_SUCCESS_PC, bus_no,
                         POSTCODE_SEVERITY_INFO);
        if (chipset_responders.bus_create)
-               (*chipset_responders.bus_create) (bus_no, rc);
+               (*chipset_responders.bus_create) (bus_info, rc);
 }
 
 static void
-chipset_bus_destroy(u32 bus_no)
+chipset_bus_destroy(struct visorchipset_bus_info *bus_info)
 {
-       struct visorchipset_bus_info bus_info;
        struct visorbus_devdata *devdata;
        int rc = -1;
 
-       if (!visorchipset_get_bus_info(bus_no, &bus_info))
-               goto away;
-       devdata = (struct visorbus_devdata *)(bus_info.bus_driver_context);
+       devdata = (struct visorbus_devdata *)(bus_info->bus_driver_context);
        if (!devdata)
                goto away;
        remove_bus_instance(devdata);
-       if (!visorchipset_set_bus_context(bus_no, NULL))
+       if (!visorchipset_set_bus_context(bus_info, NULL))
                goto away;
        rc = 0;
 away:
        if (rc < 0)
                return;
        if (chipset_responders.bus_destroy)
-               (*chipset_responders.bus_destroy)(bus_no, rc);
+               (*chipset_responders.bus_destroy)(bus_info, rc);
 }
 
 static void
index bbc64bd88e0a221fe3bd7453803aa23b4f49f42e..9a2d5636db5425fed15ccf10562eb3b27b9e2d53 100644 (file)
@@ -104,8 +104,8 @@ struct visorchipset_bus_info {
  *  visorchipset.)
  */
 struct visorchipset_busdev_notifiers {
-       void (*bus_create)(u32 bus_no);
-       void (*bus_destroy)(u32 bus_no);
+       void (*bus_create)(struct visorchipset_bus_info *bus_info);
+       void (*bus_destroy)(struct visorchipset_bus_info *bus_info);
        void (*device_create)(u32 bus_no, u32 dev_no);
        void (*device_destroy)(u32 bus_no, u32 dev_no);
        void (*device_pause)(u32 bus_no, u32 dev_no);
@@ -119,8 +119,8 @@ struct visorchipset_busdev_notifiers {
  *      -1 = it failed
  */
 struct visorchipset_busdev_responders {
-       void (*bus_create)(u32 bus_no, int response);
-       void (*bus_destroy)(u32 bus_no, int response);
+       void (*bus_create)(struct visorchipset_bus_info *p, int response);
+       void (*bus_destroy)(struct visorchipset_bus_info *p, int response);
        void (*device_create)(u32 bus_no, u32 dev_no, int response);
        void (*device_destroy)(u32 bus_no, u32 dev_no, int response);
        void (*device_pause)(u32 bus_no, u32 dev_no, int response);
@@ -142,7 +142,8 @@ bool visorchipset_get_bus_info(u32 bus_no,
                               struct visorchipset_bus_info *bus_info);
 bool visorchipset_get_device_info(u32 bus_no, u32 dev_no,
                                  struct visorchipset_device_info *dev_info);
-bool visorchipset_set_bus_context(u32 bus_no, void *context);
+bool visorchipset_set_bus_context(struct visorchipset_bus_info *bus_info,
+                                 void *context);
 
 /* visorbus init and exit functions */
 int visorbus_init(void);
index 1487dafb18b9226335f079439f201f3278a84b53..432158d2e3188d8552e167fc13cd61b2b2822914 100644 (file)
@@ -228,8 +228,8 @@ static void parahotplug_process_list(void);
  */
 static struct visorchipset_busdev_notifiers busdev_notifiers;
 
-static void bus_create_response(u32 bus_no, int response);
-static void bus_destroy_response(u32 bus_no, int response);
+static void bus_create_response(struct visorchipset_bus_info *p, int response);
+static void bus_destroy_response(struct visorchipset_bus_info *p, int response);
 static void device_create_response(u32 bus_no, u32 dev_no, int response);
 static void device_destroy_response(u32 bus_no, u32 dev_no, int response);
 static void device_resume_response(u32 bus_no, u32 dev_no, int response);
@@ -958,12 +958,12 @@ enum crash_obj_type {
 };
 
 static void
-bus_responder(enum controlvm_id cmd_id, u32 bus_no, int response)
+bus_responder(enum controlvm_id cmd_id, struct visorchipset_bus_info *p,
+             int response)
 {
-       struct visorchipset_bus_info *p;
        bool need_clear = false;
+       u32 bus_no = p->bus_no;
 
-       p = bus_find(&bus_info_list, bus_no);
        if (!p)
                return;
 
@@ -1049,15 +1049,12 @@ device_responder(enum controlvm_id cmd_id, u32 bus_no, u32 dev_no, int response)
 }
 
 static void
-bus_epilog(u32 bus_no,
+bus_epilog(struct visorchipset_bus_info *bus_info,
           u32 cmd, struct controlvm_message_header *msg_hdr,
           int response, bool need_response)
 {
-       struct visorchipset_bus_info *bus_info;
        bool notified = false;
 
-       bus_info = bus_find(&bus_info_list, bus_no);
-
        if (!bus_info)
                return;
 
@@ -1073,13 +1070,13 @@ bus_epilog(u32 bus_no,
                switch (cmd) {
                case CONTROLVM_BUS_CREATE:
                        if (busdev_notifiers.bus_create) {
-                               (*busdev_notifiers.bus_create) (bus_no);
+                               (*busdev_notifiers.bus_create) (bus_info);
                                notified = true;
                        }
                        break;
                case CONTROLVM_BUS_DESTROY:
                        if (busdev_notifiers.bus_destroy) {
-                               (*busdev_notifiers.bus_destroy) (bus_no);
+                               (*busdev_notifiers.bus_destroy) (bus_info);
                                notified = true;
                        }
                        break;
@@ -1092,7 +1089,7 @@ bus_epilog(u32 bus_no,
                 */
                ;
        else
-               bus_responder(cmd, bus_no, response);
+               bus_responder(cmd, bus_info, response);
        up(&notifier_lock);
 }
 
@@ -1236,7 +1233,7 @@ bus_create(struct controlvm_message *inmsg)
        POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus_no, POSTCODE_SEVERITY_INFO);
 
 cleanup:
-       bus_epilog(bus_no, CONTROLVM_BUS_CREATE, &inmsg->hdr,
+       bus_epilog(bus_info, CONTROLVM_BUS_CREATE, &inmsg->hdr,
                   rc, inmsg->hdr.flags.response_expected == 1);
 }
 
@@ -1254,7 +1251,7 @@ bus_destroy(struct controlvm_message *inmsg)
        else if (bus_info->state.created == 0)
                rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
 
-       bus_epilog(bus_no, CONTROLVM_BUS_DESTROY, &inmsg->hdr,
+       bus_epilog(bus_info, CONTROLVM_BUS_DESTROY, &inmsg->hdr,
                   rc, inmsg->hdr.flags.response_expected == 1);
 }
 
@@ -1295,7 +1292,7 @@ bus_configure(struct controlvm_message *inmsg,
                POSTCODE_LINUX_3(BUS_CONFIGURE_EXIT_PC, bus_no,
                                 POSTCODE_SEVERITY_INFO);
        }
-       bus_epilog(bus_no, CONTROLVM_BUS_CONFIGURE, &inmsg->hdr,
+       bus_epilog(bus_info, CONTROLVM_BUS_CONFIGURE, &inmsg->hdr,
                   rc, inmsg->hdr.flags.response_expected == 1);
 }
 
@@ -2112,15 +2109,15 @@ cleanup:
 }
 
 static void
-bus_create_response(u32 bus_no, int response)
+bus_create_response(struct visorchipset_bus_info *bus_info, int response)
 {
-       bus_responder(CONTROLVM_BUS_CREATE, bus_no, response);
+       bus_responder(CONTROLVM_BUS_CREATE, bus_info, response);
 }
 
 static void
-bus_destroy_response(u32 bus_no, int response)
+bus_destroy_response(struct visorchipset_bus_info *bus_info, int response)
 {
-       bus_responder(CONTROLVM_BUS_DESTROY, bus_no, response);
+       bus_responder(CONTROLVM_BUS_DESTROY, bus_info, response);
 }
 
 static void
@@ -2164,10 +2161,8 @@ visorchipset_get_bus_info(u32 bus_no, struct visorchipset_bus_info *bus_info)
 EXPORT_SYMBOL_GPL(visorchipset_get_bus_info);
 
 bool
-visorchipset_set_bus_context(u32 bus_no, void *context)
+visorchipset_set_bus_context(struct visorchipset_bus_info *p, void *context)
 {
-       struct visorchipset_bus_info *p = bus_find(&bus_info_list, bus_no);
-
        if (!p)
                return false;
        p->bus_driver_context = context;