Parcourir la source

[PATCH] shpchp: adapt to pci driver model

This patch adapts SHPCHP driver to the PCI device driver model.

Signed-off-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Signed-off-by: Kristen Carlson Accardi <kristen.c.accardi@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Kenji Kaneshige il y a 19 ans
Parent
commit
e6b82b13c4
2 fichiers modifiés avec 7 ajouts et 23 suppressions
  1. 0 4
      drivers/pci/hotplug/shpchp.h
  2. 7 19
      drivers/pci/hotplug/shpchp_core.c

+ 0 - 4
drivers/pci/hotplug/shpchp.h

@@ -82,7 +82,6 @@ struct event_info {
 };
 };
 
 
 struct controller {
 struct controller {
-	struct list_head ctrl_list;
 	struct mutex crit_sect;		/* critical section mutex */
 	struct mutex crit_sect;		/* critical section mutex */
 	struct mutex cmd_lock;		/* command lock */
 	struct mutex cmd_lock;		/* command lock */
 	struct php_ctlr_state_s *hpc_ctlr_handle; /* HPC controller handle */
 	struct php_ctlr_state_s *hpc_ctlr_handle; /* HPC controller handle */
@@ -203,9 +202,6 @@ extern void	shpchp_remove_ctrl_files(struct controller *ctrl);
 extern void	cleanup_slots(struct controller *ctrl);
 extern void	cleanup_slots(struct controller *ctrl);
 extern void	queue_pushbutton_work(void *data);
 extern void	queue_pushbutton_work(void *data);
 
 
-/* Global variables */
-extern struct list_head shpchp_ctrl_list;
-
 struct ctrl_reg {
 struct ctrl_reg {
 	volatile u32 base_offset;
 	volatile u32 base_offset;
 	volatile u32 slot_avail1;
 	volatile u32 slot_avail1;

+ 7 - 19
drivers/pci/hotplug/shpchp_core.c

@@ -39,7 +39,6 @@
 int shpchp_debug;
 int shpchp_debug;
 int shpchp_poll_mode;
 int shpchp_poll_mode;
 int shpchp_poll_time;
 int shpchp_poll_time;
-LIST_HEAD(shpchp_ctrl_list);
 struct workqueue_struct *shpchp_wq;
 struct workqueue_struct *shpchp_wq;
 
 
 #define DRIVER_VERSION	"0.4"
 #define DRIVER_VERSION	"0.4"
@@ -433,8 +432,6 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		ctrl->speed = PCI_SPEED_33MHz;
 		ctrl->speed = PCI_SPEED_33MHz;
 	}
 	}
 
 
-	list_add(&ctrl->ctrl_list, &shpchp_ctrl_list);
-
 	shpchp_create_ctrl_files(ctrl);
 	shpchp_create_ctrl_files(ctrl);
 
 
 	return 0;
 	return 0;
@@ -447,20 +444,13 @@ err_out_none:
 	return -ENODEV;
 	return -ENODEV;
 }
 }
 
 
-static void __exit unload_shpchpd(void)
+static void shpc_remove(struct pci_dev *dev)
 {
 {
-	struct list_head *tmp;
-	struct list_head *next;
-	struct controller *ctrl;
-
-	list_for_each_safe(tmp, next, &shpchp_ctrl_list) {
-		ctrl = list_entry(tmp, struct controller, ctrl_list);
-		shpchp_remove_ctrl_files(ctrl);
-		ctrl->hpc_ops->release_ctlr(ctrl);
-		kfree(ctrl);
-	}
+	struct controller *ctrl = pci_get_drvdata(dev);
 
 
-	destroy_workqueue(shpchp_wq);
+	shpchp_remove_ctrl_files(ctrl);
+	ctrl->hpc_ops->release_ctlr(ctrl);
+	kfree(ctrl);
 }
 }
 
 
 static struct pci_device_id shpcd_pci_tbl[] = {
 static struct pci_device_id shpcd_pci_tbl[] = {
@@ -473,7 +463,7 @@ static struct pci_driver shpc_driver = {
 	.name =		SHPC_MODULE_NAME,
 	.name =		SHPC_MODULE_NAME,
 	.id_table =	shpcd_pci_tbl,
 	.id_table =	shpcd_pci_tbl,
 	.probe =	shpc_probe,
 	.probe =	shpc_probe,
-	/* remove:	shpc_remove_one, */
+	.remove =	shpc_remove,
 };
 };
 
 
 static int __init shpcd_init(void)
 static int __init shpcd_init(void)
@@ -500,10 +490,8 @@ static int __init shpcd_init(void)
 static void __exit shpcd_cleanup(void)
 static void __exit shpcd_cleanup(void)
 {
 {
 	dbg("unload_shpchpd()\n");
 	dbg("unload_shpchpd()\n");
-	unload_shpchpd();
-
 	pci_unregister_driver(&shpc_driver);
 	pci_unregister_driver(&shpc_driver);
-
+	destroy_workqueue(shpchp_wq);
 	info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n");
 	info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n");
 }
 }