From: Don Zickus <dzickus@xxxxxxxxxx> 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@xxxxxxxxxx> Signed-off-by: Benjamin Romer <benjamin.romer@xxxxxxxxxx> --- drivers/staging/unisys/visorbus/visorbus_main.c | 44 ++++++++++------------ drivers/staging/unisys/visorbus/visorbus_private.h | 11 +++--- drivers/staging/unisys/visorbus/visorchipset.c | 39 +++++++++---------- 3 files changed, 42 insertions(+), 52 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index b66fce5..dd36d7b 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -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 diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h index bbc64bd..9a2d563 100644 --- a/drivers/staging/unisys/visorbus/visorbus_private.h +++ b/drivers/staging/unisys/visorbus/visorbus_private.h @@ -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); diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 1487daf..432158d 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -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(¬ifier_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; -- 2.1.4 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel