[PATCH 127/141] staging: unisys: Convert the notifier functions to visor_device

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

 



From: Don Zickus <dzickus@xxxxxxxxxx>

The next stage is the notifier functions are converted to use
struct visor_device.  The cleanup here is nice because no allocation
is needed.  No lookup needed.  No channel creation needed.

Things simplify down to the obvious calls.

Signed-off-by: Don Zickus <dzickus@xxxxxxxxxx>
Signed-off-by: Benjamin Romer <benjamin.romer@xxxxxxxxxx>
---
 drivers/staging/unisys/visorbus/visorbus_main.c    | 125 +++++----------------
 drivers/staging/unisys/visorbus/visorbus_private.h |  12 +-
 2 files changed, 35 insertions(+), 102 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index bc865cd..2863d15 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -24,6 +24,7 @@
 #include "vbuschannel.h"
 #include "guestlinuxdebug.h"
 #include "vbusdeviceinfo.h"
+#include "controlvmchannel.h"
 
 #define MYDRVNAME "visorbus"
 
@@ -56,6 +57,13 @@ static int visorbus_uevent(struct device *xdev, struct kobj_uevent_env *env);
 static int visorbus_match(struct device *xdev, struct device_driver *xdrv);
 static void fix_vbus_dev_info(struct visor_device *visordev);
 
+static void chipset_bus_create(struct visor_device *vdev);
+static void chipset_bus_destroy(struct visor_device *vdev);
+static void chipset_device_create(struct visor_device *vdev);
+static void chipset_device_destroy(struct visor_device *vdev);
+static void chipset_device_pause(struct visor_device *vdev);
+static void chipset_device_resume(struct visor_device *vdev);
+
 /*  BUS type attributes
  *
  *  define & implement display of bus attributes under
@@ -108,12 +116,6 @@ 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_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);
-static void chipset_device_resume(u32 bus_no, u32 dev_no);
 
 /** These functions are implemented herein, and are called by the chipset
  *  driver to notify us about specific events.
@@ -1484,29 +1486,14 @@ remove_all_visor_devices(void)
 	}
 }
 
-static bool entered_testing_mode;
-static struct visorchipset_channel_info test_channel_infos[MAXDEVICETEST];
-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 visor_device *vdev)
 {
-	struct visorchipset_bus_info bus_info;
-	struct visorbus_devdata *devdata;
-	int rc = -1;
+	int rc;
+	u32 bus_no = vdev->chipset_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);
-	if (!devdata)
-		goto away;
-	if (!visorchipset_set_bus_context(bus_no, devdata))
-		goto away;
-	POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus_no, POSTCODE_SEVERITY_INFO);
-	rc = 0;
-away:
+	rc = create_bus_instance(vdev);
 	if (rc < 0) {
 		POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no,
 				 POSTCODE_SEVERITY_ERR);
@@ -1515,96 +1502,42 @@ 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) (vdev, rc);
 }
 
 static void
-chipset_bus_destroy(u32 bus_no)
+chipset_bus_destroy(struct visor_device *vdev)
 {
-	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);
-	if (!devdata)
-		goto away;
-	remove_bus_instance(devdata);
-	if (!visorchipset_set_bus_context(bus_no, NULL))
-		goto away;
-	rc = 0;
-away:
-	if (rc < 0)
-		return;
+	remove_bus_instance(vdev);
 	if (chipset_responders.bus_destroy)
-		(*chipset_responders.bus_destroy)(bus_no, rc);
+		(*chipset_responders.bus_destroy)(vdev, 0);
 }
 
 static void
-chipset_device_create(u32 bus_no, u32 dev_no)
+chipset_device_create(struct visor_device *dev)
 {
-	struct visorchipset_device_info dev_info;
-	struct visorchipset_bus_info bus_info;
-	struct visorbus_devdata *devdata = NULL;
 	int rc = -1;
+	u32 bus_no = dev->chipset_bus_no;
+	u32 dev_no = dev->chipset_dev_no;
 
 	POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, dev_no, bus_no,
 			 POSTCODE_SEVERITY_INFO);
 
-	if (entered_testing_mode)
-		return;
-	if (!visorchipset_get_device_info(bus_no, dev_no, &dev_info))
-		goto away;
-	if (!visorchipset_get_bus_info(bus_no, &bus_info))
-		goto away;
-	if (visorbus_devicetest)
-		if (total_devices_created < MAXDEVICETEST) {
-			test_channel_infos[total_devices_created] =
-			    dev_info.chan_info;
-			test_bus_nos[total_devices_created] = bus_no;
-			test_dev_nos[total_devices_created] = dev_no;
-		}
-	POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, dev_no, bus_no,
-			 POSTCODE_SEVERITY_INFO);
-	rc = 0;
-away:
-	if (rc < 0) {
-		POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
-				 POSTCODE_SEVERITY_ERR);
-		return;
-	}
-	devdata = (struct visorbus_devdata *)(bus_info.bus_driver_context);
-	rc = create_visor_device(devdata, bus_no, dev_no,
-				 dev_info.chan_info, bus_info.partition_handle);
+	rc = create_visor_device(dev);
 	POSTCODE_LINUX_4(DEVICE_CREATE_SUCCESS_PC, dev_no, bus_no,
 			 POSTCODE_SEVERITY_INFO);
 	if (rc < 0)
 		if (chipset_responders.device_create)
-			(*chipset_responders.device_create)(bus_no, dev_no, rc);
+			(*chipset_responders.device_create)(dev, rc);
 }
 
 static void
-chipset_device_destroy(u32 bus_no, u32 dev_no)
+chipset_device_destroy(struct visor_device *dev)
 {
-	struct visorchipset_device_info dev_info;
-	struct visor_device *dev;
-	int rc = -1;
-
-	if (entered_testing_mode)
-		return;
-	if (!visorchipset_get_device_info(bus_no, dev_no, &dev_info))
-		goto away;
-	dev = find_visor_device_by_channel(dev_info.chan_info.channel_addr);
-	if (!dev)
-		goto away;
-	rc = 0;
-away:
-	if (rc < 0)
-			return;
+	int rc = 0;
 
 	if (chipset_responders.device_destroy)
-		(*chipset_responders.device_destroy) (bus_no, dev_no, rc);
+		(*chipset_responders.device_destroy) (dev, rc);
 	remove_visor_device(dev);
 }
 
@@ -1721,20 +1654,20 @@ initiate_chipset_device_pause_resume(u32 bus_no, u32 dev_no, bool is_pause)
 away:
 	if (rc < 0) {
 		if (notify_func)
-				(*notify_func)(bus_no, dev_no, rc);
+				(*notify_func)(dev, rc);
 	}
 }
 
 static void
-chipset_device_pause(u32 bus_no, u32 dev_no)
+chipset_device_pause(struct visor_device *dev)
 {
-	initiate_chipset_device_pause_resume(bus_no, dev_no, true);
+	initiate_chipset_device_pause_resume(dev, true);
 }
 
 static void
-chipset_device_resume(u32 bus_no, u32 dev_no)
+chipset_device_resume(struct visor_device *dev)
 {
-	initiate_chipset_device_pause_resume(bus_no, dev_no, false);
+	initiate_chipset_device_pause_resume(dev, false);
 }
 
 struct channel_size_info {
diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h
index bbc64bd..9b84a1d 100644
--- a/drivers/staging/unisys/visorbus/visorbus_private.h
+++ b/drivers/staging/unisys/visorbus/visorbus_private.h
@@ -104,12 +104,12 @@ struct visorchipset_bus_info {
  *  visorchipset.)
  */
 struct visorchipset_busdev_notifiers {
-	void (*bus_create)(u32 bus_no);
-	void (*bus_destroy)(u32 bus_no);
-	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);
-	void (*device_resume)(u32 bus_no, u32 dev_no);
+	void (*bus_create)(struct visor_device *vdev);
+	void (*bus_destroy)(struct visor_device *vdev);
+	void (*device_create)(struct visor_device *vdev);
+	void (*device_destroy)(struct visor_device *vdev);
+	void (*device_pause)(struct visor_device *vdev);
+	void (*device_resume)(struct visor_device *vdev);
 };
 
 /*  These functions live inside visorchipset, and will be called to indicate
-- 
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