[PATCH 129/141] staging: unisys: Convert the responders to visor_device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Don Zickus <dzickus@xxxxxxxxxx>

This is the next stage of conversion, the command responders to
struct visor_device.

Most of this is mechanical and straightforward. I will point out some
quirks that I ran into and what I did:

- bus_responder
  - bus_info_clear is no longer used as I am now expecting the core
    infrastructure to cleanup correctly, so this code simplified more
    than expected.  I am not sure the cleanup happens and perhaps a
    couple of put_devices might be needed, but in theory some release
    functions should be called to cleanup.
- dev_responder
  - same as the bus_responder but with dev_info_clear.

Both of the above quirks should be verified that things still work
correctly.

Signed-off-by: Don Zickus <dzickus@xxxxxxxxxx>
Signed-off-by: Benjamin Romer <benjamin.romer@xxxxxxxxxx>
---
 drivers/staging/unisys/visorbus/visorbus_main.c    | 10 +--
 drivers/staging/unisys/visorbus/visorbus_private.h | 12 ++--
 drivers/staging/unisys/visorbus/visorchipset.c     | 84 +++++++---------------
 3 files changed, 34 insertions(+), 72 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index a3062ea..1a46788 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -841,9 +841,7 @@ away:
 	if (!dev->responded_to_device_create) {
 		dev->responded_to_device_create = true;
 		if (chipset_responders.device_create)
-			(*chipset_responders.device_create)(dev->chipset_bus_no,
-							    dev->chipset_dev_no,
-							    rc);
+			(*chipset_responders.device_create)(dev, rc);
 	}
 	return rc;
 }
@@ -1479,8 +1477,7 @@ pause_state_change_complete(struct visor_device *dev, int status)
 	/* Notify the chipset driver that the pause is complete, which
 	* will presumably want to send some sort of response to the
 	* initiator. */
-	(*chipset_responders.device_pause) (dev->chipset_bus_no,
-					    dev->chipset_dev_no, status);
+	(*chipset_responders.device_pause) (dev, status);
 }
 
 /* This is the callback function specified for a function driver, to
@@ -1500,8 +1497,7 @@ resume_state_change_complete(struct visor_device *dev, int status)
 	/* Notify the chipset driver that the resume is complete,
 	 * which will presumably want to send some sort of response to
 	 * the initiator. */
-	(*chipset_responders.device_resume) (dev->chipset_bus_no,
-					     dev->chipset_dev_no, status);
+	(*chipset_responders.device_resume) (dev, status);
 }
 
 /* Tell the subordinate function driver for a specific device to pause
diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h
index 9b84a1d..5b3c0cd 100644
--- a/drivers/staging/unisys/visorbus/visorbus_private.h
+++ b/drivers/staging/unisys/visorbus/visorbus_private.h
@@ -119,12 +119,12 @@ 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 (*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);
-	void (*device_resume)(u32 bus_no, u32 dev_no, int response);
+	void (*bus_create)(struct visor_device *p, int response);
+	void (*bus_destroy)(struct visor_device *p, int response);
+	void (*device_create)(struct visor_device *p, int response);
+	void (*device_destroy)(struct visor_device *p, int response);
+	void (*device_pause)(struct visor_device *p, int response);
+	void (*device_resume)(struct visor_device *p, int response);
 };
 
 /** Register functions (in the bus driver) to get called by visorchipset
diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index 51d708f..84b47a1 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -228,13 +228,13 @@ 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 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);
+static void bus_create_response(struct visor_device *dev, int response);
+static void bus_destroy_response(struct visor_device *dev, int response);
+static void device_create_response(struct visor_device *dev, int response);
+static void device_destroy_response(struct visor_device *dev, int response);
+static void device_resume_response(struct visor_device *dev, int response);
 
-static void visorchipset_device_pause_response(u32 bus_no, u32 dev_no,
+static void visorchipset_device_pause_response(struct visor_device *dev,
 					       int response);
 
 static struct visorchipset_busdev_responders busdev_responders = {
@@ -958,26 +958,10 @@ 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 visor_device *p, int response)
 {
-	struct visorchipset_bus_info *p;
-	bool need_clear = false;
-
-	p = bus_find(&bus_info_list, bus_no);
-	if (!p)
-		return;
-
-	if (response < 0) {
-		if ((cmd_id == CONTROLVM_BUS_CREATE) &&
-		    (response != (-CONTROLVM_RESP_ERROR_ALREADY_DONE)))
-			/* undo the row we just created... */
-			busdevices_del(&dev_info_list, bus_no);
-	} else {
-		if (cmd_id == CONTROLVM_BUS_CREATE)
+	if (cmd_id == CONTROLVM_BUS_CREATE)
 			p->state.created = 1;
-		if (cmd_id == CONTROLVM_BUS_DESTROY)
-			need_clear = true;
-	}
 
 	if (p->pending_msg_hdr.id == CONTROLVM_INVALID)
 		return;		/* no controlvm response needed */
@@ -985,23 +969,15 @@ bus_responder(enum controlvm_id cmd_id, u32 bus_no, int response)
 		return;
 	controlvm_respond(&p->pending_msg_hdr, response);
 	p->pending_msg_hdr.id = CONTROLVM_INVALID;
-	if (need_clear) {
-		bus_info_clear(p);
-		busdevices_del(&dev_info_list, bus_no);
-	}
 }
 
 static void
 device_changestate_responder(enum controlvm_id cmd_id,
-			     u32 bus_no, u32 dev_no, int response,
+			     struct visor_device *p, int response,
 			     struct spar_segment_state response_state)
 {
-	struct visorchipset_device_info *p;
 	struct controlvm_message outmsg;
 
-	p = device_find(&dev_info_list, bus_no, dev_no);
-	if (!p)
-		return;
 	if (p->pending_msg_hdr.id == CONTROLVM_INVALID)
 		return;		/* no controlvm response needed */
 	if (p->pending_msg_hdr.id != cmd_id)
@@ -1009,8 +985,8 @@ device_changestate_responder(enum controlvm_id cmd_id,
 
 	controlvm_init_response(&outmsg, &p->pending_msg_hdr, response);
 
-	outmsg.cmd.device_change_state.bus_no = bus_no;
-	outmsg.cmd.device_change_state.dev_no = dev_no;
+	outmsg.cmd.device_change_state.bus_no = p->chipset_bus_no;
+	outmsg.cmd.device_change_state.dev_no = p->chipset_dev_no;
 	outmsg.cmd.device_change_state.state = response_state;
 
 	if (!visorchannel_signalinsert(controlvm_channel,
@@ -1021,19 +997,11 @@ device_changestate_responder(enum controlvm_id cmd_id,
 }
 
 static void
-device_responder(enum controlvm_id cmd_id, u32 bus_no, u32 dev_no, int response)
+device_responder(enum controlvm_id cmd_id, struct visor_device *p, int response)
 {
-	struct visorchipset_device_info *p;
-	bool need_clear = false;
-
-	p = device_find(&dev_info_list, bus_no, dev_no);
-	if (!p)
-		return;
 	if (response >= 0) {
 		if (cmd_id == CONTROLVM_DEVICE_CREATE)
 			p->state.created = 1;
-		if (cmd_id == CONTROLVM_DEVICE_DESTROY)
-			need_clear = true;
 	}
 
 	if (p->pending_msg_hdr.id == CONTROLVM_INVALID)
@@ -1044,8 +1012,6 @@ device_responder(enum controlvm_id cmd_id, u32 bus_no, u32 dev_no, int response)
 
 	controlvm_respond(&p->pending_msg_hdr, response);
 	p->pending_msg_hdr.id = CONTROLVM_INVALID;
-	if (need_clear)
-		dev_info_clear(p);
 }
 
 static void
@@ -1176,7 +1142,7 @@ device_epilog(struct visor_device *dev_info, struct spar_segment_state state,
 		 */
 		;
 	else
-		device_responder(cmd, bus_no, dev_no, response);
+		device_responder(cmd, dev_info, response);
 	up(&notifier_lock);
 }
 
@@ -2107,42 +2073,42 @@ cleanup:
 }
 
 static void
-bus_create_response(u32 bus_no, int response)
+bus_create_response(struct visor_device *dev, int response)
 {
-	bus_responder(CONTROLVM_BUS_CREATE, bus_no, response);
+	bus_responder(CONTROLVM_BUS_CREATE, dev, response);
 }
 
 static void
-bus_destroy_response(u32 bus_no, int response)
+bus_destroy_response(struct visor_device *dev, int response)
 {
-	bus_responder(CONTROLVM_BUS_DESTROY, bus_no, response);
+	bus_responder(CONTROLVM_BUS_DESTROY, dev, response);
 }
 
 static void
-device_create_response(u32 bus_no, u32 dev_no, int response)
+device_create_response(struct visor_device *dev, int response)
 {
-	device_responder(CONTROLVM_DEVICE_CREATE, bus_no, dev_no, response);
+	device_responder(CONTROLVM_DEVICE_CREATE, dev, response);
 }
 
 static void
-device_destroy_response(u32 bus_no, u32 dev_no, int response)
+device_destroy_response(struct visor_device *dev, int response)
 {
-	device_responder(CONTROLVM_DEVICE_DESTROY, bus_no, dev_no, response);
+	device_responder(CONTROLVM_DEVICE_DESTROY, dev, response);
 }
 
 static void
-visorchipset_device_pause_response(u32 bus_no, u32 dev_no, int response)
+visorchipset_device_pause_response(struct visor_device *dev, int response)
 {
 	device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE,
-				     bus_no, dev_no, response,
+				     dev, response,
 				     segment_state_standby);
 }
 
 static void
-device_resume_response(u32 bus_no, u32 dev_no, int response)
+device_resume_response(struct visor_device *dev, int response)
 {
 	device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE,
-				     bus_no, dev_no, response,
+				     dev, response,
 				     segment_state_running);
 }
 
-- 
2.1.4

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux