diff options
author | Alex Chiang <achiang@hp.com> | 2009-03-31 11:23:26 -0400 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2009-06-11 15:04:09 -0400 |
commit | b4d897a48d451db0ab6a4ebf8c28eb314eba0280 (patch) | |
tree | 9a194e33c272dce89e386c6d9210f32c68733e18 /drivers/pci | |
parent | 86a58023e4078a843f8ca8a9b6fa23542d881f99 (diff) |
PCI Hotplug: cpqphp: remove useless prototypes in cpqphp_core.c
Impact: refactor
Refactor code to follow convention more closely and eliminate the need
for some useless prototypes.
No functional change.
Signed-off-by: Alex Chiang <achiang@hp.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci')
-rw-r--r-- | drivers/pci/hotplug/cpqphp_core.c | 461 |
1 files changed, 224 insertions, 237 deletions
diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c index 91dc95850cce..f05ea7a5606b 100644 --- a/drivers/pci/hotplug/cpqphp_core.c +++ b/drivers/pci/hotplug/cpqphp_core.c | |||
@@ -77,33 +77,6 @@ MODULE_PARM_DESC(debug, "Debugging mode enabled or not"); | |||
77 | 77 | ||
78 | #define CPQHPC_MODULE_MINOR 208 | 78 | #define CPQHPC_MODULE_MINOR 208 |
79 | 79 | ||
80 | static int one_time_init (void); | ||
81 | static int set_attention_status (struct hotplug_slot *slot, u8 value); | ||
82 | static int process_SI (struct hotplug_slot *slot); | ||
83 | static int process_SS (struct hotplug_slot *slot); | ||
84 | static int hardware_test (struct hotplug_slot *slot, u32 value); | ||
85 | static int get_power_status (struct hotplug_slot *slot, u8 *value); | ||
86 | static int get_attention_status (struct hotplug_slot *slot, u8 *value); | ||
87 | static int get_latch_status (struct hotplug_slot *slot, u8 *value); | ||
88 | static int get_adapter_status (struct hotplug_slot *slot, u8 *value); | ||
89 | static int get_max_bus_speed (struct hotplug_slot *slot, enum pci_bus_speed *value); | ||
90 | static int get_cur_bus_speed (struct hotplug_slot *slot, enum pci_bus_speed *value); | ||
91 | |||
92 | static struct hotplug_slot_ops cpqphp_hotplug_slot_ops = { | ||
93 | .owner = THIS_MODULE, | ||
94 | .set_attention_status = set_attention_status, | ||
95 | .enable_slot = process_SI, | ||
96 | .disable_slot = process_SS, | ||
97 | .hardware_test = hardware_test, | ||
98 | .get_power_status = get_power_status, | ||
99 | .get_attention_status = get_attention_status, | ||
100 | .get_latch_status = get_latch_status, | ||
101 | .get_adapter_status = get_adapter_status, | ||
102 | .get_max_bus_speed = get_max_bus_speed, | ||
103 | .get_cur_bus_speed = get_cur_bus_speed, | ||
104 | }; | ||
105 | |||
106 | |||
107 | static inline int is_slot64bit(struct slot *slot) | 80 | static inline int is_slot64bit(struct slot *slot) |
108 | { | 81 | { |
109 | return (readb(slot->p_sm_slot + SMBIOS_SLOT_WIDTH) == 0x06) ? 1 : 0; | 82 | return (readb(slot->p_sm_slot + SMBIOS_SLOT_WIDTH) == 0x06) ? 1 : 0; |
@@ -322,145 +295,6 @@ static void release_slot(struct hotplug_slot *hotplug_slot) | |||
322 | kfree(slot); | 295 | kfree(slot); |
323 | } | 296 | } |
324 | 297 | ||
325 | #define SLOT_NAME_SIZE 10 | ||
326 | |||
327 | static int ctrl_slot_setup(struct controller *ctrl, | ||
328 | void __iomem *smbios_start, | ||
329 | void __iomem *smbios_table) | ||
330 | { | ||
331 | struct slot *slot; | ||
332 | struct hotplug_slot *hotplug_slot; | ||
333 | struct hotplug_slot_info *hotplug_slot_info; | ||
334 | u8 number_of_slots; | ||
335 | u8 slot_device; | ||
336 | u8 slot_number; | ||
337 | u8 ctrl_slot; | ||
338 | u32 tempdword; | ||
339 | char name[SLOT_NAME_SIZE]; | ||
340 | void __iomem *slot_entry= NULL; | ||
341 | int result = -ENOMEM; | ||
342 | |||
343 | dbg("%s\n", __func__); | ||
344 | |||
345 | tempdword = readl(ctrl->hpc_reg + INT_INPUT_CLEAR); | ||
346 | |||
347 | number_of_slots = readb(ctrl->hpc_reg + SLOT_MASK) & 0x0F; | ||
348 | slot_device = readb(ctrl->hpc_reg + SLOT_MASK) >> 4; | ||
349 | slot_number = ctrl->first_slot; | ||
350 | |||
351 | while (number_of_slots) { | ||
352 | slot = kzalloc(sizeof(*slot), GFP_KERNEL); | ||
353 | if (!slot) | ||
354 | goto error; | ||
355 | |||
356 | slot->hotplug_slot = kzalloc(sizeof(*(slot->hotplug_slot)), | ||
357 | GFP_KERNEL); | ||
358 | if (!slot->hotplug_slot) | ||
359 | goto error_slot; | ||
360 | hotplug_slot = slot->hotplug_slot; | ||
361 | |||
362 | hotplug_slot->info = | ||
363 | kzalloc(sizeof(*(hotplug_slot->info)), | ||
364 | GFP_KERNEL); | ||
365 | if (!hotplug_slot->info) | ||
366 | goto error_hpslot; | ||
367 | hotplug_slot_info = hotplug_slot->info; | ||
368 | |||
369 | slot->ctrl = ctrl; | ||
370 | slot->bus = ctrl->bus; | ||
371 | slot->device = slot_device; | ||
372 | slot->number = slot_number; | ||
373 | dbg("slot->number = %u\n", slot->number); | ||
374 | |||
375 | slot_entry = get_SMBIOS_entry(smbios_start, smbios_table, 9, | ||
376 | slot_entry); | ||
377 | |||
378 | while (slot_entry && (readw(slot_entry + SMBIOS_SLOT_NUMBER) != | ||
379 | slot->number)) { | ||
380 | slot_entry = get_SMBIOS_entry(smbios_start, | ||
381 | smbios_table, 9, slot_entry); | ||
382 | } | ||
383 | |||
384 | slot->p_sm_slot = slot_entry; | ||
385 | |||
386 | init_timer(&slot->task_event); | ||
387 | slot->task_event.expires = jiffies + 5 * HZ; | ||
388 | slot->task_event.function = cpqhp_pushbutton_thread; | ||
389 | |||
390 | /*FIXME: these capabilities aren't used but if they are | ||
391 | * they need to be correctly implemented | ||
392 | */ | ||
393 | slot->capabilities |= PCISLOT_REPLACE_SUPPORTED; | ||
394 | slot->capabilities |= PCISLOT_INTERLOCK_SUPPORTED; | ||
395 | |||
396 | if (is_slot64bit(slot)) | ||
397 | slot->capabilities |= PCISLOT_64_BIT_SUPPORTED; | ||
398 | if (is_slot66mhz(slot)) | ||
399 | slot->capabilities |= PCISLOT_66_MHZ_SUPPORTED; | ||
400 | if (ctrl->speed == PCI_SPEED_66MHz) | ||
401 | slot->capabilities |= PCISLOT_66_MHZ_OPERATION; | ||
402 | |||
403 | ctrl_slot = | ||
404 | slot_device - (readb(ctrl->hpc_reg + SLOT_MASK) >> 4); | ||
405 | |||
406 | /* Check presence */ | ||
407 | slot->capabilities |= | ||
408 | ((((~tempdword) >> 23) | | ||
409 | ((~tempdword) >> 15)) >> ctrl_slot) & 0x02; | ||
410 | /* Check the switch state */ | ||
411 | slot->capabilities |= | ||
412 | ((~tempdword & 0xFF) >> ctrl_slot) & 0x01; | ||
413 | /* Check the slot enable */ | ||
414 | slot->capabilities |= | ||
415 | ((read_slot_enable(ctrl) << 2) >> ctrl_slot) & 0x04; | ||
416 | |||
417 | /* register this slot with the hotplug pci core */ | ||
418 | hotplug_slot->release = &release_slot; | ||
419 | hotplug_slot->private = slot; | ||
420 | snprintf(name, SLOT_NAME_SIZE, "%u", slot->number); | ||
421 | hotplug_slot->ops = &cpqphp_hotplug_slot_ops; | ||
422 | |||
423 | hotplug_slot_info->power_status = get_slot_enabled(ctrl, slot); | ||
424 | hotplug_slot_info->attention_status = | ||
425 | cpq_get_attention_status(ctrl, slot); | ||
426 | hotplug_slot_info->latch_status = | ||
427 | cpq_get_latch_status(ctrl, slot); | ||
428 | hotplug_slot_info->adapter_status = | ||
429 | get_presence_status(ctrl, slot); | ||
430 | |||
431 | dbg("registering bus %d, dev %d, number %d, " | ||
432 | "ctrl->slot_device_offset %d, slot %d\n", | ||
433 | slot->bus, slot->device, | ||
434 | slot->number, ctrl->slot_device_offset, | ||
435 | slot_number); | ||
436 | result = pci_hp_register(hotplug_slot, | ||
437 | ctrl->pci_dev->bus, | ||
438 | slot->device, | ||
439 | name); | ||
440 | if (result) { | ||
441 | err("pci_hp_register failed with error %d\n", result); | ||
442 | goto error_info; | ||
443 | } | ||
444 | |||
445 | slot->next = ctrl->slot; | ||
446 | ctrl->slot = slot; | ||
447 | |||
448 | number_of_slots--; | ||
449 | slot_device++; | ||
450 | slot_number++; | ||
451 | } | ||
452 | |||
453 | return 0; | ||
454 | error_info: | ||
455 | kfree(hotplug_slot_info); | ||
456 | error_hpslot: | ||
457 | kfree(hotplug_slot); | ||
458 | error_slot: | ||
459 | kfree(slot); | ||
460 | error: | ||
461 | return result; | ||
462 | } | ||
463 | |||
464 | static int ctrl_slot_cleanup (struct controller * ctrl) | 298 | static int ctrl_slot_cleanup (struct controller * ctrl) |
465 | { | 299 | { |
466 | struct slot *old_slot, *next_slot; | 300 | struct slot *old_slot, *next_slot; |
@@ -793,6 +627,230 @@ static int get_cur_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_sp | |||
793 | return 0; | 627 | return 0; |
794 | } | 628 | } |
795 | 629 | ||
630 | static struct hotplug_slot_ops cpqphp_hotplug_slot_ops = { | ||
631 | .owner = THIS_MODULE, | ||
632 | .set_attention_status = set_attention_status, | ||
633 | .enable_slot = process_SI, | ||
634 | .disable_slot = process_SS, | ||
635 | .hardware_test = hardware_test, | ||
636 | .get_power_status = get_power_status, | ||
637 | .get_attention_status = get_attention_status, | ||
638 | .get_latch_status = get_latch_status, | ||
639 | .get_adapter_status = get_adapter_status, | ||
640 | .get_max_bus_speed = get_max_bus_speed, | ||
641 | .get_cur_bus_speed = get_cur_bus_speed, | ||
642 | }; | ||
643 | |||
644 | #define SLOT_NAME_SIZE 10 | ||
645 | |||
646 | static int ctrl_slot_setup(struct controller *ctrl, | ||
647 | void __iomem *smbios_start, | ||
648 | void __iomem *smbios_table) | ||
649 | { | ||
650 | struct slot *slot; | ||
651 | struct hotplug_slot *hotplug_slot; | ||
652 | struct hotplug_slot_info *hotplug_slot_info; | ||
653 | u8 number_of_slots; | ||
654 | u8 slot_device; | ||
655 | u8 slot_number; | ||
656 | u8 ctrl_slot; | ||
657 | u32 tempdword; | ||
658 | char name[SLOT_NAME_SIZE]; | ||
659 | void __iomem *slot_entry= NULL; | ||
660 | int result = -ENOMEM; | ||
661 | |||
662 | dbg("%s\n", __func__); | ||
663 | |||
664 | tempdword = readl(ctrl->hpc_reg + INT_INPUT_CLEAR); | ||
665 | |||
666 | number_of_slots = readb(ctrl->hpc_reg + SLOT_MASK) & 0x0F; | ||
667 | slot_device = readb(ctrl->hpc_reg + SLOT_MASK) >> 4; | ||
668 | slot_number = ctrl->first_slot; | ||
669 | |||
670 | while (number_of_slots) { | ||
671 | slot = kzalloc(sizeof(*slot), GFP_KERNEL); | ||
672 | if (!slot) | ||
673 | goto error; | ||
674 | |||
675 | slot->hotplug_slot = kzalloc(sizeof(*(slot->hotplug_slot)), | ||
676 | GFP_KERNEL); | ||
677 | if (!slot->hotplug_slot) | ||
678 | goto error_slot; | ||
679 | hotplug_slot = slot->hotplug_slot; | ||
680 | |||
681 | hotplug_slot->info = | ||
682 | kzalloc(sizeof(*(hotplug_slot->info)), | ||
683 | GFP_KERNEL); | ||
684 | if (!hotplug_slot->info) | ||
685 | goto error_hpslot; | ||
686 | hotplug_slot_info = hotplug_slot->info; | ||
687 | |||
688 | slot->ctrl = ctrl; | ||
689 | slot->bus = ctrl->bus; | ||
690 | slot->device = slot_device; | ||
691 | slot->number = slot_number; | ||
692 | dbg("slot->number = %u\n", slot->number); | ||
693 | |||
694 | slot_entry = get_SMBIOS_entry(smbios_start, smbios_table, 9, | ||
695 | slot_entry); | ||
696 | |||
697 | while (slot_entry && (readw(slot_entry + SMBIOS_SLOT_NUMBER) != | ||
698 | slot->number)) { | ||
699 | slot_entry = get_SMBIOS_entry(smbios_start, | ||
700 | smbios_table, 9, slot_entry); | ||
701 | } | ||
702 | |||
703 | slot->p_sm_slot = slot_entry; | ||
704 | |||
705 | init_timer(&slot->task_event); | ||
706 | slot->task_event.expires = jiffies + 5 * HZ; | ||
707 | slot->task_event.function = cpqhp_pushbutton_thread; | ||
708 | |||
709 | /*FIXME: these capabilities aren't used but if they are | ||
710 | * they need to be correctly implemented | ||
711 | */ | ||
712 | slot->capabilities |= PCISLOT_REPLACE_SUPPORTED; | ||
713 | slot->capabilities |= PCISLOT_INTERLOCK_SUPPORTED; | ||
714 | |||
715 | if (is_slot64bit(slot)) | ||
716 | slot->capabilities |= PCISLOT_64_BIT_SUPPORTED; | ||
717 | if (is_slot66mhz(slot)) | ||
718 | slot->capabilities |= PCISLOT_66_MHZ_SUPPORTED; | ||
719 | if (ctrl->speed == PCI_SPEED_66MHz) | ||
720 | slot->capabilities |= PCISLOT_66_MHZ_OPERATION; | ||
721 | |||
722 | ctrl_slot = | ||
723 | slot_device - (readb(ctrl->hpc_reg + SLOT_MASK) >> 4); | ||
724 | |||
725 | /* Check presence */ | ||
726 | slot->capabilities |= | ||
727 | ((((~tempdword) >> 23) | | ||
728 | ((~tempdword) >> 15)) >> ctrl_slot) & 0x02; | ||
729 | /* Check the switch state */ | ||
730 | slot->capabilities |= | ||
731 | ((~tempdword & 0xFF) >> ctrl_slot) & 0x01; | ||
732 | /* Check the slot enable */ | ||
733 | slot->capabilities |= | ||
734 | ((read_slot_enable(ctrl) << 2) >> ctrl_slot) & 0x04; | ||
735 | |||
736 | /* register this slot with the hotplug pci core */ | ||
737 | hotplug_slot->release = &release_slot; | ||
738 | hotplug_slot->private = slot; | ||
739 | snprintf(name, SLOT_NAME_SIZE, "%u", slot->number); | ||
740 | hotplug_slot->ops = &cpqphp_hotplug_slot_ops; | ||
741 | |||
742 | hotplug_slot_info->power_status = get_slot_enabled(ctrl, slot); | ||
743 | hotplug_slot_info->attention_status = | ||
744 | cpq_get_attention_status(ctrl, slot); | ||
745 | hotplug_slot_info->latch_status = | ||
746 | cpq_get_latch_status(ctrl, slot); | ||
747 | hotplug_slot_info->adapter_status = | ||
748 | get_presence_status(ctrl, slot); | ||
749 | |||
750 | dbg("registering bus %d, dev %d, number %d, " | ||
751 | "ctrl->slot_device_offset %d, slot %d\n", | ||
752 | slot->bus, slot->device, | ||
753 | slot->number, ctrl->slot_device_offset, | ||
754 | slot_number); | ||
755 | result = pci_hp_register(hotplug_slot, | ||
756 | ctrl->pci_dev->bus, | ||
757 | slot->device, | ||
758 | name); | ||
759 | if (result) { | ||
760 | err("pci_hp_register failed with error %d\n", result); | ||
761 | goto error_info; | ||
762 | } | ||
763 | |||
764 | slot->next = ctrl->slot; | ||
765 | ctrl->slot = slot; | ||
766 | |||
767 | number_of_slots--; | ||
768 | slot_device++; | ||
769 | slot_number++; | ||
770 | } | ||
771 | |||
772 | return 0; | ||
773 | error_info: | ||
774 | kfree(hotplug_slot_info); | ||
775 | error_hpslot: | ||
776 | kfree(hotplug_slot); | ||
777 | error_slot: | ||
778 | kfree(slot); | ||
779 | error: | ||
780 | return result; | ||
781 | } | ||
782 | |||
783 | static int one_time_init(void) | ||
784 | { | ||
785 | int loop; | ||
786 | int retval = 0; | ||
787 | |||
788 | if (initialized) | ||
789 | return 0; | ||
790 | |||
791 | power_mode = 0; | ||
792 | |||
793 | retval = pci_print_IRQ_route(); | ||
794 | if (retval) | ||
795 | goto error; | ||
796 | |||
797 | dbg("Initialize + Start the notification mechanism \n"); | ||
798 | |||
799 | retval = cpqhp_event_start_thread(); | ||
800 | if (retval) | ||
801 | goto error; | ||
802 | |||
803 | dbg("Initialize slot lists\n"); | ||
804 | for (loop = 0; loop < 256; loop++) { | ||
805 | cpqhp_slot_list[loop] = NULL; | ||
806 | } | ||
807 | |||
808 | /* FIXME: We also need to hook the NMI handler eventually. | ||
809 | * this also needs to be worked with Christoph | ||
810 | * register_NMI_handler(); | ||
811 | */ | ||
812 | /* Map rom address */ | ||
813 | cpqhp_rom_start = ioremap(ROM_PHY_ADDR, ROM_PHY_LEN); | ||
814 | if (!cpqhp_rom_start) { | ||
815 | err ("Could not ioremap memory region for ROM\n"); | ||
816 | retval = -EIO; | ||
817 | goto error; | ||
818 | } | ||
819 | |||
820 | /* Now, map the int15 entry point if we are on compaq specific | ||
821 | * hardware | ||
822 | */ | ||
823 | compaq_nvram_init(cpqhp_rom_start); | ||
824 | |||
825 | /* Map smbios table entry point structure */ | ||
826 | smbios_table = detect_SMBIOS_pointer(cpqhp_rom_start, | ||
827 | cpqhp_rom_start + ROM_PHY_LEN); | ||
828 | if (!smbios_table) { | ||
829 | err ("Could not find the SMBIOS pointer in memory\n"); | ||
830 | retval = -EIO; | ||
831 | goto error_rom_start; | ||
832 | } | ||
833 | |||
834 | smbios_start = ioremap(readl(smbios_table + ST_ADDRESS), | ||
835 | readw(smbios_table + ST_LENGTH)); | ||
836 | if (!smbios_start) { | ||
837 | err ("Could not ioremap memory region taken from SMBIOS values\n"); | ||
838 | retval = -EIO; | ||
839 | goto error_smbios_start; | ||
840 | } | ||
841 | |||
842 | initialized = 1; | ||
843 | |||
844 | return retval; | ||
845 | |||
846 | error_smbios_start: | ||
847 | iounmap(smbios_start); | ||
848 | error_rom_start: | ||
849 | iounmap(cpqhp_rom_start); | ||
850 | error: | ||
851 | return retval; | ||
852 | } | ||
853 | |||
796 | static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | 854 | static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) |
797 | { | 855 | { |
798 | u8 num_of_slots = 0; | 856 | u8 num_of_slots = 0; |
@@ -1300,77 +1358,6 @@ err_disable_device: | |||
1300 | return rc; | 1358 | return rc; |
1301 | } | 1359 | } |
1302 | 1360 | ||
1303 | static int one_time_init(void) | ||
1304 | { | ||
1305 | int loop; | ||
1306 | int retval = 0; | ||
1307 | |||
1308 | if (initialized) | ||
1309 | return 0; | ||
1310 | |||
1311 | power_mode = 0; | ||
1312 | |||
1313 | retval = pci_print_IRQ_route(); | ||
1314 | if (retval) | ||
1315 | goto error; | ||
1316 | |||
1317 | dbg("Initialize + Start the notification mechanism \n"); | ||
1318 | |||
1319 | retval = cpqhp_event_start_thread(); | ||
1320 | if (retval) | ||
1321 | goto error; | ||
1322 | |||
1323 | dbg("Initialize slot lists\n"); | ||
1324 | for (loop = 0; loop < 256; loop++) { | ||
1325 | cpqhp_slot_list[loop] = NULL; | ||
1326 | } | ||
1327 | |||
1328 | /* FIXME: We also need to hook the NMI handler eventually. | ||
1329 | * this also needs to be worked with Christoph | ||
1330 | * register_NMI_handler(); | ||
1331 | */ | ||
1332 | /* Map rom address */ | ||
1333 | cpqhp_rom_start = ioremap(ROM_PHY_ADDR, ROM_PHY_LEN); | ||
1334 | if (!cpqhp_rom_start) { | ||
1335 | err ("Could not ioremap memory region for ROM\n"); | ||
1336 | retval = -EIO; | ||
1337 | goto error; | ||
1338 | } | ||
1339 | |||
1340 | /* Now, map the int15 entry point if we are on compaq specific | ||
1341 | * hardware | ||
1342 | */ | ||
1343 | compaq_nvram_init(cpqhp_rom_start); | ||
1344 | |||
1345 | /* Map smbios table entry point structure */ | ||
1346 | smbios_table = detect_SMBIOS_pointer(cpqhp_rom_start, | ||
1347 | cpqhp_rom_start + ROM_PHY_LEN); | ||
1348 | if (!smbios_table) { | ||
1349 | err ("Could not find the SMBIOS pointer in memory\n"); | ||
1350 | retval = -EIO; | ||
1351 | goto error_rom_start; | ||
1352 | } | ||
1353 | |||
1354 | smbios_start = ioremap(readl(smbios_table + ST_ADDRESS), | ||
1355 | readw(smbios_table + ST_LENGTH)); | ||
1356 | if (!smbios_start) { | ||
1357 | err ("Could not ioremap memory region taken from SMBIOS values\n"); | ||
1358 | retval = -EIO; | ||
1359 | goto error_smbios_start; | ||
1360 | } | ||
1361 | |||
1362 | initialized = 1; | ||
1363 | |||
1364 | return retval; | ||
1365 | |||
1366 | error_smbios_start: | ||
1367 | iounmap(smbios_start); | ||
1368 | error_rom_start: | ||
1369 | iounmap(cpqhp_rom_start); | ||
1370 | error: | ||
1371 | return retval; | ||
1372 | } | ||
1373 | |||
1374 | static void __exit unload_cpqphpd(void) | 1361 | static void __exit unload_cpqphpd(void) |
1375 | { | 1362 | { |
1376 | struct pci_func *next; | 1363 | struct pci_func *next; |