From: Kristen Accardi <kristen.c.accardi@intel.com>
To: pcihpd-discuss@lists.sourceforge.net
Cc: greg@kroah.com, linux-kernel@vger.kernel.org
Subject: [patch] shpchp: support driver remove
Date: Tue, 07 Feb 2006 13:57:58 -0800 [thread overview]
Message-ID: <1139349479.30996.18.camel@whizzy> (raw)
This patch will add remove support to the shpchp driver. It also changes
where the shpchpd thread is started, so that the thread is only started if
a valid controller is enabled.
Signed-off-by: Kristen Carlson Accardi <kristen.c.accardi@intel.com>
drivers/pci/hotplug/shpchp_core.c | 59 ++++++++++++++++++--------------------
1 files changed, 29 insertions(+), 30 deletions(-)
--- linux-shpchp-mm.orig/drivers/pci/hotplug/shpchp_core.c
+++ linux-shpchp-mm/drivers/pci/hotplug/shpchp_core.c
@@ -437,13 +437,21 @@ static int shpc_probe(struct pci_dev *pd
/* Finish setting up the hot plug ctrl device */
ctrl->next_event = 0;
+ if (list_empty(&shpchp_ctrl_list)) {
+ rc = shpc_start_thread();
+ if (rc) {
+ err(SHPC_MODULE_NAME ": Can't start event thread.\n");
+ goto err_out_stop_thread;
+ }
+ }
list_add(&ctrl->ctrl_list, &shpchp_ctrl_list);
-
shpchp_create_ctrl_files(ctrl);
return 0;
+err_out_stop_thread:
+ shpchp_event_stop_thread();
err_out_free_ctrl_slot:
cleanup_slots(ctrl);
err_out_free_ctrl_bus:
@@ -471,26 +479,29 @@ static int shpc_start_thread(void)
return retval;
}
-static void __exit unload_shpchpd(void)
+
+static void __devexit shpc_remove_ctrl(struct controller *ctrl)
{
- 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);
- cleanup_slots(ctrl);
- kfree (ctrl->pci_bus);
- ctrl->hpc_ops->release_ctlr(ctrl);
- kfree(ctrl);
- }
+ shpchp_remove_ctrl_files(ctrl);
+ cleanup_slots(ctrl);
+ kfree(ctrl->pci_bus);
+ ctrl->hpc_ops->release_ctlr(ctrl);
+ list_del(&ctrl->ctrl_list);
+ kfree(ctrl);
+}
- /* Stop the notification mechanism */
- shpchp_event_stop_thread();
+
+static void __devexit shpc_remove(struct pci_dev *pdev)
+{
+ struct controller *ctrl = pci_get_drvdata(pdev);
+ if (ctrl)
+ shpc_remove_ctrl(ctrl);
+ if (list_empty(&shpchp_ctrl_list))
+ shpchp_event_stop_thread();
}
+
static struct pci_device_id shpcd_pci_tbl[] = {
{PCI_DEVICE_CLASS(((PCI_CLASS_BRIDGE_PCI << 8) | 0x00), ~0)},
{ /* end: all zeroes */ }
@@ -501,39 +512,27 @@ static struct pci_driver shpc_driver = {
.name = SHPC_MODULE_NAME,
.id_table = shpcd_pci_tbl,
.probe = shpc_probe,
- /* remove: shpc_remove_one, */
+ .remove = __devexit_p(shpc_remove),
};
static int __init shpcd_init(void)
{
- int retval = 0;
+ int retval;
#ifdef CONFIG_HOTPLUG_PCI_SHPC_POLL_EVENT_MODE
shpchp_poll_mode = 1;
#endif
- retval = shpc_start_thread();
- if (retval)
- goto error_hpc_init;
-
retval = pci_register_driver(&shpc_driver);
dbg("%s: pci_register_driver = %d\n", __FUNCTION__, retval);
info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
-error_hpc_init:
- if (retval) {
- shpchp_event_stop_thread();
- }
return retval;
}
static void __exit shpcd_cleanup(void)
{
- dbg("unload_shpchpd()\n");
- unload_shpchpd();
-
pci_unregister_driver(&shpc_driver);
-
info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n");
}
next reply other threads:[~2006-02-07 21:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-07 21:57 Kristen Accardi [this message]
2006-02-07 22:28 ` [Pcihpd-discuss] [patch] shpchp: support driver remove Kristen Accardi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1139349479.30996.18.camel@whizzy \
--to=kristen.c.accardi@intel.com \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pcihpd-discuss@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox