Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] shpchp - cleanup controller list

This patch changes SHPCHP driver to use list_head structure for
managing controller list.

Signed-off-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Kenji Kaneshige and committed by
Greg Kroah-Hartman
a4534560 5b1a960d

+10 -21
+2 -2
drivers/pci/hotplug/shpchp.h
··· 78 78 }; 79 79 80 80 struct controller { 81 - struct controller *next; 81 + struct list_head ctrl_list; 82 82 struct mutex crit_sect; /* critical section mutex */ 83 83 struct php_ctlr_state_s *hpc_ctlr_handle; /* HPC controller handle */ 84 84 int num_slots; /* Number of slots on ctlr */ ··· 204 204 205 205 206 206 /* Global variables */ 207 - extern struct controller *shpchp_ctrl_list; 207 + extern struct list_head shpchp_ctrl_list; 208 208 209 209 struct ctrl_reg { 210 210 volatile u32 base_offset;
+7 -18
drivers/pci/hotplug/shpchp_core.c
··· 38 38 int shpchp_debug; 39 39 int shpchp_poll_mode; 40 40 int shpchp_poll_time; 41 - struct controller *shpchp_ctrl_list; /* = NULL */ 41 + LIST_HEAD(shpchp_ctrl_list); 42 42 43 43 #define DRIVER_VERSION "0.4" 44 44 #define DRIVER_AUTHOR "Dan Zink <dan.zink@compaq.com>, Greg Kroah-Hartman <greg@kroah.com>, Dely Sy <dely.l.sy@intel.com>" ··· 452 452 /* Finish setting up the hot plug ctrl device */ 453 453 ctrl->next_event = 0; 454 454 455 - if (!shpchp_ctrl_list) { 456 - shpchp_ctrl_list = ctrl; 457 - ctrl->next = NULL; 458 - } else { 459 - ctrl->next = shpchp_ctrl_list; 460 - shpchp_ctrl_list = ctrl; 461 - } 455 + list_add(&ctrl->ctrl_list, &shpchp_ctrl_list); 462 456 463 457 shpchp_create_ctrl_files(ctrl); 464 458 ··· 487 493 488 494 static void __exit unload_shpchpd(void) 489 495 { 496 + struct list_head *tmp; 497 + struct list_head *next; 490 498 struct controller *ctrl; 491 - struct controller *tctrl; 492 499 493 - ctrl = shpchp_ctrl_list; 494 - 495 - while (ctrl) { 500 + list_for_each_safe(tmp, next, &shpchp_ctrl_list) { 501 + ctrl = list_entry(tmp, struct controller, ctrl_list); 496 502 shpchp_remove_ctrl_files(ctrl); 497 503 cleanup_slots(ctrl); 498 - 499 504 kfree (ctrl->pci_bus); 500 505 ctrl->hpc_ops->release_ctlr(ctrl); 501 - 502 - tctrl = ctrl; 503 - ctrl = ctrl->next; 504 - 505 - kfree(tctrl); 506 + kfree(ctrl); 506 507 } 507 508 508 509 /* Stop the notification mechanism */
+1 -1
drivers/pci/hotplug/shpchp_ctrl.c
··· 688 688 if (pushbutton_pending) 689 689 shpchp_pushbutton_thread(pushbutton_pending); 690 690 else 691 - for (ctrl = shpchp_ctrl_list; ctrl; ctrl=ctrl->next) 691 + list_for_each_entry(ctrl, &shpchp_ctrl_list, ctrl_list) 692 692 interrupt_event_handler(ctrl); 693 693 } 694 694 dbg("event_thread signals exit\n");