[PATCH 40/44 V2] staging: unisys: Convert device creation to use visor_device

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

 



This patch removes the legacy dev_info struct and instead creates
and passes around a traditional struct device.

This allows us to remove a lot of the various look up code and
removes the doubt if the struct exists or not.

Half of the churn is just the conversion of visorchipset_device_info
to visor_device.  Various cleanups include re-arranging the failure
paths to make more sense.

Pay attention to the create_visor_device function.  This had a lot of
churn to simplify everything.

Lots of functions disappeared because they are not needed any more.

Signed-off-by: Don Zickus <dzickus@xxxxxxxxxx>

---
V2: Remove the extra put_device().  (Dan Carpenter)
---
 drivers/staging/unisys/include/visorbus.h          |   8 +-
 drivers/staging/unisys/visorbus/visorbus_main.c    | 144 +++++---------------
 drivers/staging/unisys/visorbus/visorbus_private.h |  48 ++-----
 drivers/staging/unisys/visorbus/visorchipset.c     | 149 +++++----------------
 4 files changed, 79 insertions(+), 270 deletions(-)

diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h
index e7f9984..581d962 100644
--- a/drivers/staging/unisys/include/visorbus.h
+++ b/drivers/staging/unisys/include/visorbus.h
@@ -43,7 +43,7 @@ struct visor_device;
 extern struct bus_type visorbus_type;
 
 typedef void (*visorbus_state_complete_func) (struct visor_device *dev,
-					      int status, void *dev_info);
+					      int status);
 struct visorchipset_state {
 	u32 created:1;
 	u32 attached:1;
@@ -106,11 +106,9 @@ struct visor_driver {
 	 *  fails or completes successfully.
 	 */
 	int (*pause)(struct visor_device *dev,
-		     visorbus_state_complete_func complete_func,
-		     void *dev_info);
+		     visorbus_state_complete_func complete_func);
 	int (*resume)(struct visor_device *dev,
-		      visorbus_state_complete_func complete_func,
-		      void *dev_info);
+		      visorbus_state_complete_func complete_func);
 
 	/** These fields are for private use by the bus driver only. */
 	struct device_driver driver;
diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
index bee626c..2cf11d8 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -95,10 +95,10 @@ static long long bus_count;	/** number of bus instances */
 
 static void chipset_bus_create(struct visor_device *bus_info);
 static void chipset_bus_destroy(struct visor_device *bus_info);
-static void chipset_device_create(struct visorchipset_device_info *dev_info);
-static void chipset_device_destroy(struct visorchipset_device_info *dev_info);
-static void chipset_device_pause(struct visorchipset_device_info *dev_info);
-static void chipset_device_resume(struct visorchipset_device_info *dev_info);
+static void chipset_device_create(struct visor_device *dev_info);
+static void chipset_device_destroy(struct visor_device *dev_info);
+static void chipset_device_pause(struct visor_device *dev_info);
+static void chipset_device_resume(struct visor_device *dev_info);
 
 /** These functions are implemented herein, and are called by the chipset
  *  driver to notify us about specific events.
@@ -184,7 +184,6 @@ visorbus_release_busdevice(struct device *xdev)
 
 	dev_set_drvdata(xdev, NULL);
 	kfree(dev);
-	kfree(xdev);
 }
 
 /** This is called when device_unregister() is called for each child
@@ -754,16 +753,9 @@ away:
 	 *  initialized.
 	 */
 	if (!dev->responded_to_device_create) {
-		struct visorchipset_device_info dev_info;
-
-		if (!visorchipset_get_device_info(dev->chipset_bus_no,
-						  dev->chipset_dev_no, &dev_info))
-			/* hmm, what to do here */
-			return rc;
-
 		dev->responded_to_device_create = true;
 		if (chipset_responders.device_create)
-			(*chipset_responders.device_create)(&dev_info, rc);
+			(*chipset_responders.device_create)(dev, rc);
 	}
 	return rc;
 }
@@ -948,30 +940,15 @@ EXPORT_SYMBOL_GPL(visorbus_disable_channel_interrupts);
  *  device.
  */
 static int
-create_visor_device(struct visor_device *bdev,
-		    struct visorchipset_device_info *dev_info)
+create_visor_device(struct visor_device *dev)
 {
 	int rc = -1;
-	struct visor_device *dev = NULL;
-	bool gotten = false, registered1 = false, registered2 = false;
-	u32 chipset_bus_no = dev_info->bus_no;
-	u32 chipset_dev_no = dev_info->dev_no;
+	u32 chipset_bus_no = dev->chipset_bus_no;
+	u32 chipset_dev_no = dev->chipset_dev_no;
 
 	POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, chipset_dev_no, chipset_bus_no,
 			 POSTCODE_SEVERITY_INFO);
-	dev = kmalloc(sizeof(*dev), GFP_KERNEL);
-	if (!dev) {
-		POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, chipset_dev_no,
-				 DIAG_SEVERITY_ERR);
-		goto away;
-	}
 
-	memset(dev, 0, sizeof(struct visor_device));
-	dev->visorchannel = dev_info->visorchannel;
-	dev->channel_type_guid = dev_info->channel_type_guid;
-	dev->chipset_bus_no = chipset_bus_no;
-	dev->chipset_dev_no = chipset_dev_no;
-	dev->device.parent = &bdev->device;
 	sema_init(&dev->visordriver_callback_lock, 1);	/* unlocked */
 	dev->device.bus = &visorbus_type;
 	dev->device.groups = visorbus_dev_groups;
@@ -979,7 +956,6 @@ create_visor_device(struct visor_device *bdev,
 	dev->device.release = visorbus_release_device;
 	/* keep a reference just for us (now 2) */
 	get_device(&dev->device);
-	gotten = true;
 	dev->periodic_work =
 		visor_periodic_work_create(POLLJIFFIES_NORMALCHANNEL,
 					   periodic_dev_workqueue,
@@ -1021,29 +997,20 @@ create_visor_device(struct visor_device *bdev,
 		goto away;
 	}
 
-	/* note: device_register is simply device_initialize + device_add */
-	registered1 = true;
-
 	rc = register_devmajorminor_attributes(dev);
 	if (rc < 0) {
 		POSTCODE_LINUX_3(DEVICE_REGISTER_FAILURE_PC, chipset_dev_no,
 				 DIAG_SEVERITY_ERR);
-		goto away;
+		goto away_register;
 	}
 
-	registered2 = true;
-	rc = 0;
+	list_add_tail(&dev->list_all, &list_all_device_instances);
+	return 0;
 
+away_register:
+	device_unregister(&dev->device);
 away:
-	if (rc < 0) {
-		if (registered2)
-			unregister_devmajorminor_attributes(dev);
-		if (gotten)
-			put_device(&dev->device);
-		kfree(dev);
-	} else {
-		list_add_tail(&dev->list_all, &list_all_device_instances);
-	}
+	put_device(&dev->device);
 	return rc;
 }
 
@@ -1056,21 +1023,6 @@ remove_visor_device(struct visor_device *dev)
 	device_unregister(&dev->device);
 }
 
-static struct visor_device *
-find_visor_device_by_channel(struct visorchannel *channel)
-{
-	struct list_head *listentry, *listtmp;
-
-	list_for_each_safe(listentry, listtmp, &list_all_device_instances) {
-		struct visor_device *dev = list_entry(listentry,
-						      struct visor_device,
-						      list_all);
-		if (dev->visorchannel == channel)
-			return dev;
-	}
-	return NULL;
-}
-
 static int
 get_vbus_header_info(struct visorchannel *chan,
 		     struct spar_vbus_headerinfo *hdr_info)
@@ -1342,25 +1294,16 @@ chipset_bus_destroy(struct visor_device *dev)
 }
 
 static void
-chipset_device_create(struct visorchipset_device_info *dev_info)
+chipset_device_create(struct visor_device *dev_info)
 {
-	struct visor_device *bdev;
 	int rc = -1;
-	u32 bus_no = dev_info->bus_no;
-	u32 dev_no = dev_info->dev_no;
+	u32 bus_no = dev_info->chipset_bus_no;
+	u32 dev_no = dev_info->chipset_dev_no;
 
 	POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, dev_no, bus_no,
 			 POSTCODE_SEVERITY_INFO);
 
-	bdev = visorbus_get_device_by_id(bus_no, BUS_ROOT_DEVICE, NULL);
-	if (!bdev)
-		goto away;
-
-	POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, dev_no, bus_no,
-			 POSTCODE_SEVERITY_INFO);
-
-	rc = create_visor_device(bdev, dev_info);
-away:
+	rc = create_visor_device(dev_info);
 	if (rc < 0) {
 		POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
 				 POSTCODE_SEVERITY_ERR);
@@ -1373,22 +1316,12 @@ away:
 }
 
 static void
-chipset_device_destroy(struct visorchipset_device_info *dev_info)
+chipset_device_destroy(struct visor_device *dev_info)
 {
-	struct visor_device *dev;
-	int rc = -1;
-
-	dev = find_visor_device_by_channel(dev_info->visorchannel);
-	if (!dev)
-		goto away;
-	rc = 0;
-away:
-	if (rc < 0)
-			return;
+	remove_visor_device(dev_info);
 
 	if (chipset_responders.device_destroy)
-		(*chipset_responders.device_destroy) (dev_info, rc);
-	remove_visor_device(dev);
+		(*chipset_responders.device_destroy) (dev_info, 0);
 }
 
 /* This is the callback function specified for a function driver, to
@@ -1396,11 +1329,8 @@ away:
  * completed.
  */
 static void
-pause_state_change_complete(struct visor_device *dev, int status,
-			    void *info)
+pause_state_change_complete(struct visor_device *dev, int status)
 {
-	struct visorchipset_device_info *dev_info = info;
-
 	if (!dev->pausing)
 			return;
 
@@ -1411,7 +1341,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_info, status);
+	(*chipset_responders.device_pause) (dev, status);
 }
 
 /* This is the callback function specified for a function driver, to
@@ -1419,11 +1349,8 @@ pause_state_change_complete(struct visor_device *dev, int status,
  * completed.
  */
 static void
-resume_state_change_complete(struct visor_device *dev, int status,
-			     void *info)
+resume_state_change_complete(struct visor_device *dev, int status)
 {
-	struct visorchipset_device_info *dev_info = info;
-
 	if (!dev->resuming)
 			return;
 
@@ -1434,7 +1361,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_info, status);
+	(*chipset_responders.device_resume) (dev, status);
 }
 
 /* Tell the subordinate function driver for a specific device to pause
@@ -1442,14 +1369,11 @@ resume_state_change_complete(struct visor_device *dev, int status,
  * callback function.
  */
 static void
-initiate_chipset_device_pause_resume(struct visorchipset_device_info *dev_info,
-				     bool is_pause)
+initiate_chipset_device_pause_resume(struct visor_device *dev, bool is_pause)
 {
-	struct visor_device *dev = NULL;
 	int rc = -1, x;
 	struct visor_driver *drv = NULL;
-	void (*notify_func)(struct visorchipset_device_info *dev_info,
-			    int response) = NULL;
+	void (*notify_func)(struct visor_device *dev, int response) = NULL;
 
 	if (is_pause)
 		notify_func = chipset_responders.device_pause;
@@ -1458,10 +1382,6 @@ initiate_chipset_device_pause_resume(struct visorchipset_device_info *dev_info,
 	if (!notify_func)
 			goto away;
 
-	dev = find_visor_device_by_channel(dev_info->visorchannel);
-	if (!dev)
-			goto away;
-
 	drv = to_visor_driver(dev->device.driver);
 	if (!drv)
 			goto away;
@@ -1481,7 +1401,7 @@ initiate_chipset_device_pause_resume(struct visorchipset_device_info *dev_info,
 				goto away;
 
 		dev->pausing = true;
-		x = drv->pause(dev, pause_state_change_complete, (void *)dev_info);
+		x = drv->pause(dev, pause_state_change_complete);
 	} else {
 		/* This should be done at BUS resume time, but an
 		 * existing problem prevents us from ever getting a bus
@@ -1493,7 +1413,7 @@ initiate_chipset_device_pause_resume(struct visorchipset_device_info *dev_info,
 				goto away;
 
 		dev->resuming = true;
-		x = drv->resume(dev, resume_state_change_complete, (void *)dev_info);
+		x = drv->resume(dev, resume_state_change_complete);
 	}
 	if (x < 0) {
 		if (is_pause)
@@ -1506,18 +1426,18 @@ initiate_chipset_device_pause_resume(struct visorchipset_device_info *dev_info,
 away:
 	if (rc < 0) {
 		if (notify_func)
-				(*notify_func)(dev_info, rc);
+				(*notify_func)(dev, rc);
 	}
 }
 
 static void
-chipset_device_pause(struct visorchipset_device_info *dev_info)
+chipset_device_pause(struct visor_device *dev_info)
 {
 	initiate_chipset_device_pause_resume(dev_info, true);
 }
 
 static void
-chipset_device_resume(struct visorchipset_device_info *dev_info)
+chipset_device_resume(struct visor_device *dev_info)
 {
 	initiate_chipset_device_pause_resume(dev_info, false);
 }
diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h
index a3bfa38..2f12483 100644
--- a/drivers/staging/unisys/visorbus/visorbus_private.h
+++ b/drivers/staging/unisys/visorbus/visorbus_private.h
@@ -20,35 +20,10 @@
 
 #include <linux/uuid.h>
 
-#include "channel.h"
 #include "controlvmchannel.h"
 #include "vbusdeviceinfo.h"
 #include "vbushelper.h"
 
-struct visorchannel;
-
-/** Attributes for a particular Supervisor device.
- *  Any visorchipset client can query these attributes using
- *  visorchipset_get_client_device_info() or
- *  visorchipset_get_server_device_info().
- */
-struct visorchipset_device_info {
-	struct list_head entry;
-	u32 bus_no;
-	u32 dev_no;
-	uuid_le dev_inst_uuid;
-	struct visorchipset_state state;
-	struct visorchannel *visorchannel;
-	uuid_le channel_type_guid;
-	u32 reserved1;		/* control_vm_id */
-	u64 reserved2;
-	u32 switch_no;		/* when devState.attached==1 */
-	u32 internal_port_no;	/* when devState.attached==1 */
-	struct controlvm_message_header *pending_msg_hdr;/* CONTROLVM_MESSAGE */
-	/** For private use by the bus driver */
-	void *bus_driver_context;
-};
-
 /*  These functions will be called from within visorchipset when certain
  *  events happen.  (The implementation of these functions is outside of
  *  visorchipset.)
@@ -56,10 +31,10 @@ struct visorchipset_device_info {
 struct visorchipset_busdev_notifiers {
 	void (*bus_create)(struct visor_device *bus_info);
 	void (*bus_destroy)(struct visor_device *bus_info);
-	void (*device_create)(struct visorchipset_device_info *bus_info);
-	void (*device_destroy)(struct visorchipset_device_info *bus_info);
-	void (*device_pause)(struct visorchipset_device_info *bus_info);
-	void (*device_resume)(struct visorchipset_device_info *bus_info);
+	void (*device_create)(struct visor_device *bus_info);
+	void (*device_destroy)(struct visor_device *bus_info);
+	void (*device_pause)(struct visor_device *bus_info);
+	void (*device_resume)(struct visor_device *bus_info);
 };
 
 /*  These functions live inside visorchipset, and will be called to indicate
@@ -71,10 +46,10 @@ struct visorchipset_busdev_notifiers {
 struct visorchipset_busdev_responders {
 	void (*bus_create)(struct visor_device *p, int response);
 	void (*bus_destroy)(struct visor_device *p, int response);
-	void (*device_create)(struct visorchipset_device_info *p, int response);
-	void (*device_destroy)(struct visorchipset_device_info *p, int response);
-	void (*device_pause)(struct visorchipset_device_info *p, int response);
-	void (*device_resume)(struct visorchipset_device_info *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
@@ -88,13 +63,6 @@ visorchipset_register_busdev(
 			struct visorchipset_busdev_responders *responders,
 			struct ultra_vbus_deviceinfo *driver_info);
 
-bool visorchipset_get_bus_info(u32 bus_no,
-			       struct visor_device *bus_info);
-bool visorchipset_get_device_info(u32 bus_no, u32 dev_no,
-				  struct visorchipset_device_info *dev_info);
-bool visorchipset_set_bus_context(struct visor_device *bus_info,
-				  void *context);
-
 /* visorbus init and exit functions */
 int visorbus_init(void);
 void visorbus_exit(void);
diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index 5c29377..9689cfb 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -230,11 +230,11 @@ static struct visorchipset_busdev_notifiers busdev_notifiers;
 
 static void bus_create_response(struct visor_device *p, int response);
 static void bus_destroy_response(struct visor_device *p, int response);
-static void device_create_response(struct visorchipset_device_info *p, int response);
-static void device_destroy_response(struct visorchipset_device_info *p, int response);
-static void device_resume_response(struct visorchipset_device_info *p, int response);
+static void device_create_response(struct visor_device *p, int response);
+static void device_destroy_response(struct visor_device *p, int response);
+static void device_resume_response(struct visor_device *p, int response);
 
-static void visorchipset_device_pause_response(struct visorchipset_device_info *p,
+static void visorchipset_device_pause_response(struct visor_device *p,
 					       int response);
 
 static struct visorchipset_busdev_responders busdev_responders = {
@@ -692,15 +692,6 @@ static ssize_t remaining_steps_store(struct device *dev,
 	return count;
 }
 
-static void
-dev_info_clear(void *v)
-{
-	struct visorchipset_device_info *p =
-		(struct visorchipset_device_info *) v;
-
-	memset(p, 0, sizeof(struct visorchipset_device_info));
-}
-
 struct visor_busdev {
 	u32 bus_no;
 	u32 dev_no;
@@ -740,31 +731,6 @@ struct visor_device *visorbus_get_device_by_id(u32 bus_no, u32 dev_no,
 }
 EXPORT_SYMBOL(visorbus_get_device_by_id);
 
-static struct visorchipset_device_info *
-device_find(struct list_head *list, u32 bus_no, u32 dev_no)
-{
-	struct visorchipset_device_info *p;
-
-	list_for_each_entry(p, list, entry) {
-		if (p->bus_no == bus_no && p->dev_no == dev_no)
-			return p;
-	}
-
-	return NULL;
-}
-
-static void busdevices_del(struct list_head *list, u32 bus_no)
-{
-	struct visorchipset_device_info *p, *tmp;
-
-	list_for_each_entry_safe(p, tmp, list, entry) {
-		if (p->bus_no == bus_no) {
-			list_del(&p->entry);
-			kfree(p);
-		}
-	}
-}
-
 static u8
 check_chipset_events(void)
 {
@@ -811,18 +777,6 @@ visorchipset_register_busdev(
 EXPORT_SYMBOL_GPL(visorchipset_register_busdev);
 
 static void
-cleanup_controlvm_structures(void)
-{
-	struct visorchipset_device_info *di, *tmp_di;
-
-	list_for_each_entry_safe(di, tmp_di, &dev_info_list, entry) {
-		dev_info_clear(di);
-		list_del(&di->entry);
-		kfree(di);
-	}
-}
-
-static void
 chipset_init(struct controlvm_message *inmsg)
 {
 	static int chipset_inited;
@@ -848,8 +802,6 @@ chipset_init(struct controlvm_message *inmsg)
 	features |= ULTRA_CHIPSET_FEATURE_REPLY;
 
 cleanup:
-	if (rc < 0)
-		cleanup_controlvm_structures();
 	if (inmsg->hdr.flags.response_expected)
 		controlvm_respond_chipset_init(&inmsg->hdr, rc, features);
 }
@@ -943,12 +895,12 @@ bus_responder(enum controlvm_id cmd_id,
 
 static void
 device_changestate_responder(enum controlvm_id cmd_id,
-			     struct visorchipset_device_info *p, int response,
+			     struct visor_device *p, int response,
 			     struct spar_segment_state response_state)
 {
 	struct controlvm_message outmsg;
-	u32 bus_no = p->bus_no;
-	u32 dev_no = p->dev_no;
+	u32 bus_no = p->chipset_bus_no;
+	u32 dev_no = p->chipset_dev_no;
 
 	if (p->pending_msg_hdr == NULL)
 		return;		/* no controlvm response needed */
@@ -1049,15 +1001,15 @@ away:
 }
 
 static void
-device_epilog(struct visorchipset_device_info *dev_info,
+device_epilog(struct visor_device *dev_info,
 	      struct spar_segment_state state, u32 cmd,
 	      struct controlvm_message_header *msg_hdr, int response,
 	      bool need_response, bool for_visorbus)
 {
 	struct visorchipset_busdev_notifiers *notifiers;
 	bool notified = false;
-	u32 bus_no = dev_info->bus_no;
-	u32 dev_no = dev_info->dev_no;
+	u32 bus_no = dev_info->chipset_bus_no;
+	u32 dev_no = dev_info->chipset_dev_no;
 	struct controlvm_message_header *pmsg_hdr = NULL;
 
 	char *envp[] = {
@@ -1281,31 +1233,34 @@ my_device_create(struct controlvm_message *inmsg)
 	struct controlvm_message_packet *cmd = &inmsg->cmd;
 	u32 bus_no = cmd->create_device.bus_no;
 	u32 dev_no = cmd->create_device.dev_no;
-	struct visorchipset_device_info *dev_info;
+	struct visor_device *dev_info = NULL;
 	struct visor_device *bus_info;
 	struct visorchannel *visorchannel;
 	int rc = CONTROLVM_RESP_SUCCESS;
 
-	dev_info = device_find(&dev_info_list, bus_no, dev_no);
-	if (dev_info && (dev_info->state.created == 1)) {
+	bus_info = visorbus_get_device_by_id(bus_no, BUS_ROOT_DEVICE, NULL);
+	if (!bus_info) {
 		POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
 				 POSTCODE_SEVERITY_ERR);
-		rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
+		rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
 		goto cleanup;
 	}
-	bus_info = visorbus_get_device_by_id(bus_no, dev_no, NULL);
-	if (!bus_info) {
+
+	if (bus_info->state.created == 0) {
 		POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
 				 POSTCODE_SEVERITY_ERR);
 		rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
 		goto cleanup;
 	}
-	if (bus_info->state.created == 0) {
+
+	dev_info = visorbus_get_device_by_id(bus_no, dev_no, NULL);
+	if (dev_info && (dev_info->state.created == 1)) {
 		POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
 				 POSTCODE_SEVERITY_ERR);
-		rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
+		rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
 		goto cleanup;
 	}
+
 	dev_info = kzalloc(sizeof(*dev_info), GFP_KERNEL);
 	if (!dev_info) {
 		POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
@@ -1314,10 +1269,13 @@ my_device_create(struct controlvm_message *inmsg)
 		goto cleanup;
 	}
 
-	INIT_LIST_HEAD(&dev_info->entry);
-	dev_info->bus_no = bus_no;
-	dev_info->dev_no = dev_no;
-	dev_info->dev_inst_uuid = cmd->create_device.dev_inst_uuid;
+	dev_info->chipset_bus_no = bus_no;
+	dev_info->chipset_dev_no = dev_no;
+	dev_info->inst = cmd->create_device.dev_inst_uuid;
+
+	/* not sure where the best place to set the 'parent' */
+	dev_info->device.parent = &bus_info->device;
+
 	POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, dev_no, bus_no,
 			 POSTCODE_SEVERITY_INFO);
 
@@ -1335,7 +1293,6 @@ my_device_create(struct controlvm_message *inmsg)
 	}
 	dev_info->visorchannel = visorchannel;
 	dev_info->channel_type_guid = cmd->create_device.data_type_uuid;
-	list_add(&dev_info->entry, &dev_info_list);
 	POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, dev_no, bus_no,
 			 POSTCODE_SEVERITY_INFO);
 cleanup:
@@ -1357,10 +1314,10 @@ my_device_changestate(struct controlvm_message *inmsg)
 	u32 bus_no = cmd->device_change_state.bus_no;
 	u32 dev_no = cmd->device_change_state.dev_no;
 	struct spar_segment_state state = cmd->device_change_state.state;
-	struct visorchipset_device_info *dev_info;
+	struct visor_device *dev_info;
 	int rc = CONTROLVM_RESP_SUCCESS;
 
-	dev_info = device_find(&dev_info_list, bus_no, dev_no);
+	dev_info = visorbus_get_device_by_id(bus_no, dev_no, NULL);
 	if (!dev_info) {
 		POSTCODE_LINUX_4(DEVICE_CHANGESTATE_FAILURE_PC, dev_no, bus_no,
 				 POSTCODE_SEVERITY_ERR);
@@ -1382,10 +1339,10 @@ my_device_destroy(struct controlvm_message *inmsg)
 	struct controlvm_message_packet *cmd = &inmsg->cmd;
 	u32 bus_no = cmd->destroy_device.bus_no;
 	u32 dev_no = cmd->destroy_device.dev_no;
-	struct visorchipset_device_info *dev_info;
+	struct visor_device *dev_info;
 	int rc = CONTROLVM_RESP_SUCCESS;
 
-	dev_info = device_find(&dev_info_list, bus_no, dev_no);
+	dev_info = visorbus_get_device_by_id(bus_no, dev_no, NULL);
 	if (!dev_info)
 		rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID;
 	else if (dev_info->state.created == 0)
@@ -2099,10 +2056,6 @@ bus_create_response(struct visor_device *bus_info, int response)
 {
 	if (response >= 0) {
 		bus_info->state.created = 1;
-	} else {
-		if (response != -CONTROLVM_RESP_ERROR_ALREADY_DONE)
-			/* undo the row we just created... */
-			busdevices_del(&dev_info_list, bus_info->chipset_bus_no);
 	}
 
 	bus_responder(CONTROLVM_BUS_CREATE, bus_info->pending_msg_hdr, response);
@@ -2118,12 +2071,10 @@ bus_destroy_response(struct visor_device *bus_info, int response)
 
 	kfree(bus_info->pending_msg_hdr);
 	bus_info->pending_msg_hdr = NULL;
-
-	busdevices_del(&dev_info_list, bus_info->chipset_bus_no);
 }
 
 static void
-device_create_response(struct visorchipset_device_info *dev_info, int response)
+device_create_response(struct visor_device *dev_info, int response)
 {
 	if (response >= 0)
 		dev_info->state.created = 1;
@@ -2131,22 +2082,19 @@ device_create_response(struct visorchipset_device_info *dev_info, int response)
 	device_responder(CONTROLVM_DEVICE_CREATE, dev_info->pending_msg_hdr, response);
 
 	kfree(dev_info->pending_msg_hdr);
-	dev_info->pending_msg_hdr = NULL;
 }
 
 static void
-device_destroy_response(struct visorchipset_device_info *dev_info, int response)
+device_destroy_response(struct visor_device *dev_info, int response)
 {
 	device_responder(CONTROLVM_DEVICE_DESTROY, dev_info->pending_msg_hdr, response);
 
 	kfree(dev_info->pending_msg_hdr);
 	dev_info->pending_msg_hdr = NULL;
-
-	dev_info_clear(dev_info);
 }
 
 static void
-visorchipset_device_pause_response(struct visorchipset_device_info *dev_info,
+visorchipset_device_pause_response(struct visor_device *dev_info,
 				   int response)
 {
 	device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE,
@@ -2158,7 +2106,7 @@ visorchipset_device_pause_response(struct visorchipset_device_info *dev_info,
 }
 
 static void
-device_resume_response(struct visorchipset_device_info *dev_info, int response)
+device_resume_response(struct visor_device *dev_info, int response)
 {
 	device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE,
 				     dev_info, response,
@@ -2168,29 +2116,6 @@ device_resume_response(struct visorchipset_device_info *dev_info, int response)
 	dev_info->pending_msg_hdr = NULL;
 }
 
-bool
-visorchipset_get_device_info(u32 bus_no, u32 dev_no,
-			     struct visorchipset_device_info *dev_info)
-{
-	void *p = device_find(&dev_info_list, bus_no, dev_no);
-
-	if (!p)
-		return false;
-	memcpy(dev_info, p, sizeof(struct visorchipset_device_info));
-	return true;
-}
-EXPORT_SYMBOL_GPL(visorchipset_get_device_info);
-
-bool
-visorchipset_set_device_context(struct visorchipset_device_info *p, void *context)
-{
-	if (!p)
-		return false;
-	p->bus_driver_context = context;
-	return true;
-}
-EXPORT_SYMBOL_GPL(visorchipset_set_device_context);
-
 static ssize_t chipsetready_store(struct device *dev,
 				  struct device_attribute *attr,
 				  const char *buf, size_t count)
@@ -2464,8 +2389,6 @@ visorchipset_exit(struct acpi_device *acpi_device)
 	periodic_controlvm_workqueue = NULL;
 	destroy_controlvm_payload_info(&controlvm_payload_info);
 
-	cleanup_controlvm_structures();
-
 	memset(&g_chipset_msg_hdr, 0, sizeof(struct controlvm_message_header));
 
 	visorchannel_destroy(controlvm_channel);
-- 
2.1.0

_______________________________________________
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