PCI Hotplug: cpqphp cleanups
cover PCI Hotplug: cpqphp cleanups
Hi Jesse,
This is my first pass at cleaning up cpqphp. Why? I dunno, I found some old hardware and thought it might be fun to clean up a crufty old driver.
This series is mostly whitespace and style fixes. A few functions have been reworked so they aren't indented quite so much. I expect that the first few patches will be very hard to read because there's so much code movement, but it does help with readability towards the end of the series.
At the end of the series, we start to see some more interesting changes. For one, we no longer call pcibios_get_irq_routing_table nearly as often.
The other is removing the pci_find_slot() interface. I'm still in the process of untangling exactly what the lifetime rules are for a pci_dev in cpqphp, but this is a good step forward, and also finally gets rid of the last in-tree caller of pci_find_slot(), which would be nice for 2.6.30. Also, this means that cpqphp no longer depends on PCI_LEGACY.
The current functional state of cpqphp is broken. We are able to load the module and successfully power off cards. We have some issues when we try to power them back on though, because commit b81d988c "broke" cpqphp and we get BAR collisions when we try to hot-add. However, I use "broke" very loosely, as I agree with Bjorn's commit, and cpqphp is doing horrible things like essentially duplicating a lot of the PCI core, incorrectly, I might add. Once I rip out some more of the PCI code in cpqphp, I expect hot-add to work again.
I plan on untangling that in the next phase of cleanups.
I've successfully tested my changes on my DL580g2. No functional regressions (compared to behavior since b81d988c).
Anyhow, please consider applying this series for the current merge window. I'd like to be able to turn off PCI_LEGACY. :)
Thanks!
/ac
---
Alex Chiang (15):
PCI: remove deprecated pci_find_slot() interface
PCI Hotplug: cpqphp: don't use pci_find_slot()
PCI Hotplug: cpqphp: constify slot_name()
PCI Hotplug: cpqphp: eliminate dead code - PCI_ScanBusNonBridge PCI Hotplug: cpqphp: clean up accesses to pcibios_get_irq_routing_table() PCI Hotplug: cpqphp: refactor cpqhp_save_config
PCI Hotplug: cpqphp: style cleanups
PCI Hotplug: cpqphp: refactor cpqphp_save_slot_config
PCI Hotplug: cpqphp: clean up cpqphp_ctrl.c
PCI Hotplug: cpqphp: refactor cpqhp_probe
PCI Hotplug: cpqphp: eliminate stray braces
PCI Hotplug: cpqphp: remove useless prototypes in cpqphp_core.c PCI Hotplug: cpqphp: obey 80 column convention in cpqphp.h PCI Hotplug: cpqphp: fix comment style
PCI Hotplug: cpqphp: stray whitespace cleanups
drivers/pci/hotplug/Kconfig | 2 drivers/pci/hotplug/cpqphp.h | 167 +++-- drivers/pci/hotplug/cpqphp_core.c | 1101 +++++++++++++++++------------------- drivers/pci/hotplug/cpqphp_ctrl.c | 371 ++++++------ drivers/pci/hotplug/cpqphp_nvram.c | 97 ++- drivers/pci/hotplug/cpqphp_pci.c | 599 ++++++++++---------- drivers/pci/search.c | 30 - include/linux/pci.h | 8 8 files changed, 1162 insertions(+), 1213 deletions(-)
PATCH 1/15 PCI Hotplug: cpqphp: stray whitespace cleanups
Clean up all stray whitespace issues, such as trailing whitespace, spaces before tabs, etc. and whatever else vim's c_space_errors highlights in red.
---
drivers/pci/hotplug/cpqphp.h | 58 ++++++++++++------------ drivers/pci/hotplug/cpqphp_core.c | 56 +++++++++-------------- drivers/pci/hotplug/cpqphp_ctrl.c | 86 ++++++++++++++++++------------------ drivers/pci/hotplug/cpqphp_nvram.c | 18 ++++---- drivers/pci/hotplug/cpqphp_pci.c | 14 +++--- 5 files changed, 110 insertions(+), 122 deletions(-)
drivers/pci/hotplug/cpqphp.h +29 -29
@@ -150,25 +150,25 @@ struct ctrl_reg { /* offset *//* offsets to the controller registers based on the above structure layout */ enum ctrl_offsets { -SLOT_RST = offsetof(struct ctrl_reg , slot_RST), +SLOT_RST = offsetof(struct ctrl_reg , slot_RST),SLOT_ENABLE = offsetof(struct ctrl_reg , slot_enable),MISC = offsetof(struct ctrl_reg , misc),LED_CONTROL = offsetof(struct ctrl_reg , led_control),INT_INPUT_CLEAR = offsetof(struct ctrl_reg , int_input_clear), -INT_MASK = offsetof(struct ctrl_reg , int_mask), -CTRL_RESERVED0 = offsetof(struct ctrl_reg , reserved0), +INT_MASK = offsetof(struct ctrl_reg , int_mask), +CTRL_RESERVED0 = offsetof(struct ctrl_reg , reserved0),CTRL_RESERVED1 = offsetof(struct ctrl_reg , reserved1),CTRL_RESERVED2 = offsetof(struct ctrl_reg , reserved1), -GEN_OUTPUT_AB = offsetof(struct ctrl_reg , gen_output_AB), -NON_INT_INPUT = offsetof(struct ctrl_reg , non_int_input), +GEN_OUTPUT_AB = offsetof(struct ctrl_reg , gen_output_AB), +NON_INT_INPUT = offsetof(struct ctrl_reg , non_int_input),CTRL_RESERVED3 = offsetof(struct ctrl_reg , reserved3),CTRL_RESERVED4 = offsetof(struct ctrl_reg , reserved4),CTRL_RESERVED5 = offsetof(struct ctrl_reg , reserved5),CTRL_RESERVED6 = offsetof(struct ctrl_reg , reserved6),CTRL_RESERVED7 = offsetof(struct ctrl_reg , reserved7),CTRL_RESERVED8 = offsetof(struct ctrl_reg , reserved8), -SLOT_MASK = offsetof(struct ctrl_reg , slot_mask), -CTRL_RESERVED9 = offsetof(struct ctrl_reg , reserved9), +SLOT_MASK = offsetof(struct ctrl_reg , slot_mask), +CTRL_RESERVED9 = offsetof(struct ctrl_reg , reserved9),CTRL_RESERVED10 = offsetof(struct ctrl_reg , reserved10),CTRL_RESERVED11 = offsetof(struct ctrl_reg , reserved11),SLOT_SERR = offsetof(struct ctrl_reg , slot_SERR),
@@ -220,15 +220,15 @@ struct slot_rt {/* offsets to the hotplug slot resource table registers based on the above structure layout */ enum slot_rt_offsets {DEV_FUNC = offsetof(struct slot_rt , dev_func), -PRIMARY_BUS = offsetof(struct slot_rt , primary_bus), -SECONDARY_BUS = offsetof(struct slot_rt , secondary_bus), -MAX_BUS = offsetof(struct slot_rt , max_bus), -IO_BASE = offsetof(struct slot_rt , io_base), -IO_LENGTH = offsetof(struct slot_rt , io_length), -MEM_BASE = offsetof(struct slot_rt , mem_base), -MEM_LENGTH = offsetof(struct slot_rt , mem_length), -PRE_MEM_BASE = offsetof(struct slot_rt , pre_mem_base), -PRE_MEM_LENGTH = offsetof(struct slot_rt , pre_mem_length), +PRIMARY_BUS = offsetof(struct slot_rt , primary_bus), +SECONDARY_BUS = offsetof(struct slot_rt , secondary_bus), +MAX_BUS = offsetof(struct slot_rt , max_bus), +IO_BASE = offsetof(struct slot_rt , io_base), +IO_LENGTH = offsetof(struct slot_rt , io_length), +MEM_BASE = offsetof(struct slot_rt , mem_base), +MEM_LENGTH = offsetof(struct slot_rt , mem_length), +PRE_MEM_BASE = offsetof(struct slot_rt , pre_mem_base), +PRE_MEM_LENGTH = offsetof(struct slot_rt , pre_mem_length), };struct pci_func {
@@ -471,7 +471,7 @@ static inline void return_resource(struct pci_resource **head, struct pci_resourstatic inline void set_SOGO (struct controller *ctrl) {u16 misc; - + misc =readw (ctrl->hpc_reg +MISC ); misc = (misc |0x0001 ) &0xFFFB ;writew (misc, ctrl->hpc_reg +MISC );
@@ -481,7 +481,7 @@ static inline void set_SOGO(struct controller *ctrl)static inline void amber_LED_on (struct controller *ctrl,u8 slot) {u32 led_control; - + led_control =readl (ctrl->hpc_reg +LED_CONTROL ); led_control |= (0x01010000L << slot);writel (led_control, ctrl->hpc_reg +LED_CONTROL );
@@ -491,7 +491,7 @@ static inline void amber_LED_on(struct controller *ctrl, u8 slot)static inline void amber_LED_off (struct controller *ctrl,u8 slot) {u32 led_control; - + led_control =readl (ctrl->hpc_reg +LED_CONTROL ); led_control &= ~(0x01010000L << slot);writel (led_control, ctrl->hpc_reg +LED_CONTROL );
@@ -504,7 +504,7 @@ static inline int read_amber_LED(struct controller *ctrl, u8 slot) led_control =readl (ctrl->hpc_reg +LED_CONTROL ); led_control &= (0x01010000L << slot); - +return led_control ?1 :0 ; }
@@ -512,7 +512,7 @@ static inline int read_amber_LED(struct controller *ctrl, u8 slot)static inline void green_LED_on (struct controller *ctrl,u8 slot) {u32 led_control; - + led_control =readl (ctrl->hpc_reg +LED_CONTROL ); led_control |=0x0101L << slot;writel (led_control, ctrl->hpc_reg +LED_CONTROL );
@@ -521,7 +521,7 @@ static inline void green_LED_on(struct controller *ctrl, u8 slot)static inline void green_LED_off (struct controller *ctrl,u8 slot) {u32 led_control; - + led_control =readl (ctrl->hpc_reg +LED_CONTROL ); led_control &= ~(0x0101L << slot);writel (led_control, ctrl->hpc_reg +LED_CONTROL );
@@ -531,7 +531,7 @@ static inline void green_LED_off(struct controller *ctrl, u8 slot)static inline void green_LED_blink (struct controller *ctrl,u8 slot) {u32 led_control; - + led_control =readl (ctrl->hpc_reg +LED_CONTROL ); led_control &= ~(0x0101L << slot); led_control |= (0x0001L << slot);
@@ -586,11 +586,11 @@ static inline u8 read_slot_enable(struct controller *ctrl)static inline u8 get_controller_speed (struct controller *ctrl) {u8 curr_freq; -u16 misc; - +u16 misc; +if (ctrl->pcix_support) { curr_freq =readb (ctrl->hpc_reg +NEXT_CURR_FREQ ); -if ((curr_freq &0xB0 ) ==0xB0 ) +if ((curr_freq &0xB0 ) ==0xB0 )return PCI_SPEED_133MHz_PCIX;if ((curr_freq &0xA0 ) ==0xA0 )return PCI_SPEED_100MHz_PCIX;
@@ -602,10 +602,10 @@ static inline u8 get_controller_speed(struct controller *ctrl)return PCI_SPEED_33MHz; } - misc =readw (ctrl->hpc_reg +MISC ); -return (misc &0x0800 ) ? PCI_SPEED_66MHz : PCI_SPEED_33MHz; + misc =readw (ctrl->hpc_reg +MISC ); +return (misc &0x0800 ) ? PCI_SPEED_66MHz : PCI_SPEED_33MHz; } - +/* * get_adapter_speed - find the max supported frequency/mode of adapter.
drivers/pci/hotplug/cpqphp_core.c +22 -34
200 lines not on this page · raw message
drivers/pci/hotplug/cpqphp_ctrl.c +43 -43
242 lines not on this page · raw message
drivers/pci/hotplug/cpqphp_nvram.c +9 -9
@@ -113,7 +113,7 @@ static u32 add_byte( u32 **p_buffer, u8 value, u32 *used, u32 *avail)if ((*used +1 ) > *avail)return (1 ); - + *((u8 *)*p_buffer) = value; tByte = (u8 **)p_buffer; (*tByte)++;
@@ -170,10 +170,10 @@ static u32 access_EV (u16 operation, u8 *ev_name, u8 *buffer, u32 *buf_size)unsigned long flags;int op = operation;int ret_val; - +if (!compaq_int15_entry_point)return -ENODEV ; - +spin_lock_irqsave (&int15_lock, flags); __asm__ ( "xorl %%ebx,%%ebx\n" \
@@ -187,7 +187,7 @@ static u32 access_EV (u16 operation, u8 *ev_name, u8 *buffer, u32 *buf_size) "D" (buffer), "m" (compaq_int15_entry_point) : "%ebx", "%edx");spin_unlock_irqrestore (&int15_lock, flags); - +return ((ret_val &0xFF00 ) >>8 ); }
@@ -263,7 +263,7 @@ static u32 store_HRT (void __iomem *rom_start) p_EV_header = (struct ev_hrt_header *) pFill; ctrl = cpqhp_ctrl_list; - +// The revision of this structure rc =add_byte ( &pFill,1 + ctrl->push_flag, &usedbytes, &available);if (rc)
@@ -401,7 +401,7 @@ static u32 store_HRT (void __iomem *rom_start) ctrl = ctrl->next; } - + p_EV_header->num_of_ctrl = numCtrl;// Now store the EV
@@ -479,7 +479,7 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl) function = p_ev_ctrl->function;while ((bus != ctrl->bus) || - (device !=PCI_SLOT (ctrl->pci_dev->devfn)) || + (device !=PCI_SLOT (ctrl->pci_dev->devfn)) || (function !=PCI_FUNC (ctrl->pci_dev->devfn))) { nummem = p_ev_ctrl->mem_avail; numpmem = p_ev_ctrl->p_mem_avail;
@@ -640,14 +640,14 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl)if (rc)return (rc); }else { -if ((evbuffer[0 ] !=0 ) && (!ctrl->push_flag)) +if ((evbuffer[0 ] !=0 ) && (!ctrl->push_flag))return 1 ; }return 0 ; } - +int compaq_nvram_store (void __iomem *rom_start) {int rc =1 ;
drivers/pci/hotplug/cpqphp_pci.c +7 -7
@@ -82,7 +82,7 @@ static void __iomem *detect_HRT_floating_pointer(void __iomem *begin, void __iom } -int cpqhp_configure_device (struct controller * ctrl,struct pci_func * func) +int cpqhp_configure_device (struct controller * ctrl,struct pci_func * func) {unsigned char bus;struct pci_bus *child;
@@ -116,10 +116,10 @@ int cpqhp_configure_device (struct controller* ctrl, struct pci_func* func) } -int cpqhp_unconfigure_device (struct pci_func * func) +int cpqhp_unconfigure_device (struct pci_func * func) {int j; - +dbg ("%s: bus/dev/func = %x/%x/%x\n" , __func__, func->bus, func->device, func->function);for (j=0 ; j<8 ; j++) {
@@ -195,8 +195,8 @@ int cpqhp_set_irq (u8 bus_num, u8 dev_num, u8 int_pin, u8 irq_num)/* -* WTF??? This function isn't in the code, yet a function calls it, but the -* compiler optimizes it away? strange. Here as a placeholder to keep the +* WTF??? This function isn't in the code, yet a function calls it, but the +* compiler optimizes it away? strange. Here as a placeholder to keep the * compiler happy. */ static int PCI_ScanBusNonBridge (u8 bus,u8 device)
@@ -398,7 +398,7 @@ int cpqhp_save_config(struct controller *ctrl, int busnumber, int is_hot_plug) index =0 ; new_slot =cpqhp_slot_find (busnumber, device, index++); -while (new_slot && +while (new_slot && (new_slot->function != (u8 ) function)) new_slot =cpqhp_slot_find (busnumber, device, index++);
@@ -1168,7 +1168,7 @@ int cpqhp_valid_replace(struct controller *ctrl, struct pci_func * func)* this function is for hot plug ADD! * * returns 0 if success -*/ +*/ int cpqhp_find_available_resources (struct controller *ctrl,void __iomem *rom_start) {u8 temp;
PATCH 2/15 PCI Hotplug: cpqphp: fix comment style
In reply to Alex ChiangFix up comments from C++ to C-style, wrapping if necessary, etc.
---
drivers/pci/hotplug/cpqphp.h | 22 +-- drivers/pci/hotplug/cpqphp_core.c | 157 ++++++++++-------- drivers/pci/hotplug/cpqphp_ctrl.c | 131 +++++++++------ drivers/pci/hotplug/cpqphp_nvram.c | 79 +++++---- drivers/pci/hotplug/cpqphp_pci.c | 313 ++++++++++++++++++++---------------- 5 files changed, 387 insertions(+), 315 deletions(-)
drivers/pci/hotplug/cpqphp.h +11 -11
@@ -190,7 +190,9 @@ struct hrt {u32 reserved2; } __attribute__ ((packed)); -/* offsets to the hotplug resource table registers based on the above structure layout */ +/* offsets to the hotplug resource table registers based on the above +* structure layout +*/ enum hrt_offsets {SIG0 = offsetof(struct hrt , sig0),SIG1 = offsetof(struct hrt , sig1),
@@ -217,7 +219,9 @@ struct slot_rt {u16 pre_mem_length; } __attribute__ ((packed)); -/* offsets to the hotplug slot resource table registers based on the above structure layout */ +/* offsets to the hotplug slot resource table registers based on the above +* structure layout +*/ enum slot_rt_offsets {DEV_FUNC = offsetof(struct slot_rt , dev_func),PRIMARY_BUS = offsetof(struct slot_rt , primary_bus),
@@ -286,8 +290,8 @@ struct event_info {struct controller {struct controller *next;u32 ctrl_int_comp; -struct mutex crit_sect;/* critical section mutex */ -void __iomem *hpc_reg;/* cookie for our pci controller location */ +struct mutex crit_sect;/* critical section mutex */ +void __iomem *hpc_reg;/* cookie for our pci controller location */ struct pci_resource *mem_head;struct pci_resource *p_mem_head;struct pci_resource *io_head;
@@ -299,7 +303,7 @@ struct controller {u8 next_event;u8 interrupt;u8 cfgspc_irq; -u8 bus;/* bus number for the pci hotplug controller */ +u8 bus;/* bus number for the pci hotplug controller */ u8 rev;u8 slot_device_offset;u8 first_slot;
@@ -458,7 +462,6 @@ static inline char *slot_name(struct slot *slot)* return_resource * * Puts node back in the resource list pointed to by head -* */ static inline void return_resource (struct pci_resource **head,struct pci_resource *node) {
@@ -575,13 +578,12 @@ static inline u8 read_slot_enable(struct controller *ctrl) } -/* +/** * get_controller_speed - find the current frequency/mode of controller. * * @ctrl: controller to get frequency/mode for. * * Returns controller speed. -* */ static inline u8 get_controller_speed (struct controller *ctrl) {
@@ -607,14 +609,13 @@ static inline u8 get_controller_speed(struct controller *ctrl) } -/* +/** * get_adapter_speed - find the max supported frequency/mode of adapter. * * @ctrl: hotplug controller. * @hp_slot: hotplug slot where adapter is installed. * * Returns adapter speed. -* */ static inline u8 get_adapter_speed (struct controller *ctrl,u8 hp_slot) {
@@ -719,4 +720,3 @@ static inline int wait_for_ctrl_irq(struct controller *ctrl) }#endif -
drivers/pci/hotplug/cpqphp_core.c +84 -73
380 lines not on this page · raw message
drivers/pci/hotplug/cpqphp_ctrl.c +77 -54
363 lines not on this page · raw message
drivers/pci/hotplug/cpqphp_nvram.c +42 -37
234 lines not on this page · raw message
drivers/pci/hotplug/cpqphp_pci.c +173 -140
755 lines not on this page · raw message
PATCH 3/15 PCI Hotplug: cpqphp: obey 80 column convention in cpqphp.h
In reply to Alex ChiangClean up cpqphp.h to follow 80 column convention.
---
drivers/pci/hotplug/cpqphp.h | 76 +++++++++++++++++++++++++----------------- 1 files changed, 45 insertions(+), 31 deletions(-)
drivers/pci/hotplug/cpqphp.h +45 -31
@@ -405,40 +405,50 @@ struct resource_lists {/* debugfs functions for the hotplug controller info */ -extern void cpqhp_initialize_debugfs (void ); -extern void cpqhp_shutdown_debugfs (void ); -extern void cpqhp_create_debugfs_files (struct controller *ctrl); -extern void cpqhp_remove_debugfs_files (struct controller *ctrl); +extern void cpqhp_initialize_debugfs (void ); +extern void cpqhp_shutdown_debugfs (void ); +extern void cpqhp_create_debugfs_files (struct controller *ctrl); +extern void cpqhp_remove_debugfs_files (struct controller *ctrl);/* controller functions */ -extern void cpqhp_pushbutton_thread (unsigned long event_pointer); -extern irqreturn_t cpqhp_ctrl_intr (int IRQ ,void *data); -extern int cpqhp_find_available_resources (struct controller *ctrl,void __iomem *rom_start); -extern int cpqhp_event_start_thread (void ); -extern void cpqhp_event_stop_thread (void ); -extern struct pci_func *cpqhp_slot_create (unsigned char busnumber); -extern struct pci_func *cpqhp_slot_find (unsigned char bus,unsigned char device,unsigned char index); -extern int cpqhp_process_SI (struct controller *ctrl,struct pci_func *func); -extern int cpqhp_process_SS (struct controller *ctrl,struct pci_func *func); -extern int cpqhp_hardware_test (struct controller *ctrl,int test_num); +extern void cpqhp_pushbutton_thread (unsigned long event_pointer); +extern irqreturn_t cpqhp_ctrl_intr (int IRQ ,void *data); +extern int cpqhp_find_available_resources (struct controller *ctrl, +void __iomem *rom_start); +extern int cpqhp_event_start_thread (void ); +extern void cpqhp_event_stop_thread (void ); +extern struct pci_func *cpqhp_slot_create (unsigned char busnumber); +extern struct pci_func *cpqhp_slot_find (unsigned char bus,unsigned char device, +unsigned char index); +extern int cpqhp_process_SI (struct controller *ctrl,struct pci_func *func); +extern int cpqhp_process_SS (struct controller *ctrl,struct pci_func *func); +extern int cpqhp_hardware_test (struct controller *ctrl,int test_num);/* resource functions */ extern int cpqhp_resource_sort_and_combine (struct pci_resource **head);/* pci functions */ -extern int cpqhp_set_irq (u8 bus_num,u8 dev_num,u8 int_pin,u8 irq_num); -extern int cpqhp_get_bus_dev (struct controller *ctrl,u8 *bus_num,u8 *dev_num,u8 slot); -extern int cpqhp_save_config (struct controller *ctrl,int busnumber,int is_hot_plug); -extern int cpqhp_save_base_addr_length (struct controller *ctrl,struct pci_func * func); -extern int cpqhp_save_used_resources (struct controller *ctrl,struct pci_func * func); -extern int cpqhp_configure_board (struct controller *ctrl,struct pci_func * func); -extern int cpqhp_save_slot_config (struct controller *ctrl,struct pci_func * new_slot); -extern int cpqhp_valid_replace (struct controller *ctrl,struct pci_func * func); -extern void cpqhp_destroy_board_resources (struct pci_func * func); -extern int cpqhp_return_board_resources (struct pci_func * func,struct resource_lists * resources); -extern void cpqhp_destroy_resource_list (struct resource_lists * resources); -extern int cpqhp_configure_device (struct controller * ctrl,struct pci_func * func); -extern int cpqhp_unconfigure_device (struct pci_func * func); +extern int cpqhp_set_irq (u8 bus_num,u8 dev_num,u8 int_pin,u8 irq_num); +extern int cpqhp_get_bus_dev (struct controller *ctrl,u8 *bus_num,u8 *dev_num, +u8 slot); +extern int cpqhp_save_config (struct controller *ctrl,int busnumber, +int is_hot_plug); +extern int cpqhp_save_base_addr_length (struct controller *ctrl, +struct pci_func *func); +extern int cpqhp_save_used_resources (struct controller *ctrl, +struct pci_func *func); +extern int cpqhp_configure_board (struct controller *ctrl, +struct pci_func *func); +extern int cpqhp_save_slot_config (struct controller *ctrl, +struct pci_func *new_slot); +extern int cpqhp_valid_replace (struct controller *ctrl,struct pci_func *func); +extern void cpqhp_destroy_board_resources (struct pci_func *func); +extern int cpqhp_return_board_resources (struct pci_func *func, +struct resource_lists *resources); +extern void cpqhp_destroy_resource_list (struct resource_lists *resources); +extern int cpqhp_configure_device (struct controller *ctrl, +struct pci_func *func); +extern int cpqhp_unconfigure_device (struct pci_func *func);/* Global variables */ extern int cpqhp_debug;
@@ -463,7 +473,8 @@ static inline char *slot_name(struct slot *slot)* * Puts node back in the resource list pointed to by head */ -static inline void return_resource (struct pci_resource **head,struct pci_resource *node) +static inline void return_resource (struct pci_resource **head, +struct pci_resource *node) {if (!node || !head)return ;
@@ -673,7 +684,8 @@ static inline int get_slot_enabled(struct controller *ctrl, struct slot *slot) } -static inline int cpq_get_latch_status (struct controller *ctrl,struct slot *slot) +static inline int cpq_get_latch_status (struct controller *ctrl, +struct slot *slot) {u32 status;u8 hp_slot;
@@ -688,7 +700,8 @@ static inline int cpq_get_latch_status(struct controller *ctrl, struct slot *slo } -static inline int get_presence_status (struct controller *ctrl,struct slot *slot) +static inline int get_presence_status (struct controller *ctrl, +struct slot *slot) {int presence_save =0 ;u8 hp_slot;
@@ -697,7 +710,8 @@ static inline int get_presence_status(struct controller *ctrl, struct slot *slot hp_slot = slot->device - ctrl->slot_device_offset; tempdword =readl (ctrl->hpc_reg +INT_INPUT_CLEAR ); - presence_save = (int ) ((((~tempdword) >>23 ) | ((~tempdword) >>15 )) >> hp_slot) &0x02 ; + presence_save = (int ) ((((~tempdword) >>23 ) | ((~tempdword) >>15 )) + >> hp_slot) &0x02 ;return presence_save; }
PATCH 4/15 PCI Hotplug: cpqphp: remove useless prototypes in cpqphp_core.c
In reply to Alex ChiangImpact: refactor
Refactor code to follow convention more closely and eliminate the need for some useless prototypes.
No functional change.
---
drivers/pci/hotplug/cpqphp_core.c | 461 ++++++++++++++++++------------------- 1 files changed, 224 insertions(+), 237 deletions(-)
drivers/pci/hotplug/cpqphp_core.c +224 -237
@@ -77,33 +77,6 @@ MODULE_PARM_DESC(debug, "Debugging mode enabled or not");#define CPQHPC_MODULE_MINOR 208 -static int one_time_init (void ); -static int set_attention_status (struct hotplug_slot *slot,u8 value); -static int process_SI (struct hotplug_slot *slot); -static int process_SS (struct hotplug_slot *slot); -static int hardware_test (struct hotplug_slot *slot,u32 value); -static int get_power_status (struct hotplug_slot *slot,u8 *value); -static int get_attention_status (struct hotplug_slot *slot,u8 *value); -static int get_latch_status (struct hotplug_slot *slot,u8 *value); -static int get_adapter_status (struct hotplug_slot *slot,u8 *value); -static int get_max_bus_speed (struct hotplug_slot *slot,enum pci_bus_speed *value); -static int get_cur_bus_speed (struct hotplug_slot *slot,enum pci_bus_speed *value); - -static struct hotplug_slot_ops cpqphp_hotplug_slot_ops = { - .owner =THIS_MODULE , - .set_attention_status = set_attention_status, - .enable_slot = process_SI, - .disable_slot = process_SS, - .hardware_test = hardware_test, - .get_power_status = get_power_status, - .get_attention_status = get_attention_status, - .get_latch_status = get_latch_status, - .get_adapter_status = get_adapter_status, - .get_max_bus_speed = get_max_bus_speed, - .get_cur_bus_speed = get_cur_bus_speed, -}; - -static inline int is_slot64bit (struct slot *slot) {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)kfree (slot); } -#define SLOT_NAME_SIZE 10 - -static int ctrl_slot_setup (struct controller *ctrl, -void __iomem *smbios_start, -void __iomem *smbios_table) -{ -struct slot *slot; -struct hotplug_slot *hotplug_slot; -struct hotplug_slot_info *hotplug_slot_info; -u8 number_of_slots; -u8 slot_device; -u8 slot_number; -u8 ctrl_slot; -u32 tempdword; -char name[SLOT_NAME_SIZE ]; -void __iomem *slot_entry=NULL ; -int result = -ENOMEM ; - -dbg ("%s\n" , __func__); - - tempdword =readl (ctrl->hpc_reg +INT_INPUT_CLEAR ); - - number_of_slots =readb (ctrl->hpc_reg +SLOT_MASK ) &0x0F ; - slot_device =readb (ctrl->hpc_reg +SLOT_MASK ) >>4 ; - slot_number = ctrl->first_slot; - -while (number_of_slots) { - slot =kzalloc (sizeof (*slot),GFP_KERNEL ); -if (!slot) - goto error; - - slot->hotplug_slot =kzalloc (sizeof (*(slot->hotplug_slot)), -GFP_KERNEL ); -if (!slot->hotplug_slot) - goto error_slot; - hotplug_slot = slot->hotplug_slot; - - hotplug_slot->info = -kzalloc (sizeof (*(hotplug_slot->info)), -GFP_KERNEL ); -if (!hotplug_slot->info) - goto error_hpslot; - hotplug_slot_info = hotplug_slot->info; - - slot->ctrl = ctrl; - slot->bus = ctrl->bus; - slot->device = slot_device; - slot->number = slot_number; -dbg ("slot->number = %u\n" , slot->number); - - slot_entry =get_SMBIOS_entry (smbios_start, smbios_table,9 , - slot_entry); - -while (slot_entry && (readw (slot_entry +SMBIOS_SLOT_NUMBER ) != - slot->number)) { - slot_entry =get_SMBIOS_entry (smbios_start, - smbios_table,9 , slot_entry); - } - - slot->p_sm_slot = slot_entry; - -init_timer (&slot->task_event); - slot->task_event.expires = jiffies +5 *HZ ; - slot->task_event.function = cpqhp_pushbutton_thread; - -/*FIXME: these capabilities aren't used but if they are -* they need to be correctly implemented -*/ - slot->capabilities |=PCISLOT_REPLACE_SUPPORTED ; - slot->capabilities |=PCISLOT_INTERLOCK_SUPPORTED ; - -if (is_slot64bit (slot)) - slot->capabilities |=PCISLOT_64_BIT_SUPPORTED ; -if (is_slot66mhz (slot)) - slot->capabilities |=PCISLOT_66_MHZ_SUPPORTED ; -if (ctrl->speed == PCI_SPEED_66MHz) - slot->capabilities |=PCISLOT_66_MHZ_OPERATION ; - - ctrl_slot = - slot_device - (readb (ctrl->hpc_reg +SLOT_MASK ) >>4 ); - -/* Check presence */ - slot->capabilities |= - ((((~tempdword) >>23 ) | - ((~tempdword) >>15 )) >> ctrl_slot) &0x02 ; -/* Check the switch state */ - slot->capabilities |= - ((~tempdword &0xFF ) >> ctrl_slot) &0x01 ; -/* Check the slot enable */ - slot->capabilities |= - ((read_slot_enable (ctrl) <<2 ) >> ctrl_slot) &0x04 ; - -/* register this slot with the hotplug pci core */ - hotplug_slot->release = &release_slot; - hotplug_slot->private = slot; -snprintf (name,SLOT_NAME_SIZE ,"%u" , slot->number); - hotplug_slot->ops = &cpqphp_hotplug_slot_ops; - - hotplug_slot_info->power_status =get_slot_enabled (ctrl, slot); - hotplug_slot_info->attention_status = -cpq_get_attention_status (ctrl, slot); - hotplug_slot_info->latch_status = -cpq_get_latch_status (ctrl, slot); - hotplug_slot_info->adapter_status = -get_presence_status (ctrl, slot); - -dbg ("registering bus %d, dev %d, number %d, " -"ctrl->slot_device_offset %d, slot %d\n" , - slot->bus, slot->device, - slot->number, ctrl->slot_device_offset, - slot_number); - result =pci_hp_register (hotplug_slot, - ctrl->pci_dev->bus, - slot->device, - name); -if (result) { -err ("pci_hp_register failed with error %d\n" , result); - goto error_info; - } - - slot->next = ctrl->slot; - ctrl->slot = slot; - - number_of_slots--; - slot_device++; - slot_number++; - } - -return 0 ; -error_info: -kfree (hotplug_slot_info); -error_hpslot: -kfree (hotplug_slot); -error_slot: -kfree (slot); -error: -return result; -} -static int ctrl_slot_cleanup (struct controller * ctrl) {struct slot *old_slot, *next_slot;
@@ -793,6 +627,230 @@ static int get_cur_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_spreturn 0 ; } +static struct hotplug_slot_ops cpqphp_hotplug_slot_ops = { + .owner =THIS_MODULE , + .set_attention_status = set_attention_status, + .enable_slot = process_SI, + .disable_slot = process_SS, + .hardware_test = hardware_test, + .get_power_status = get_power_status, + .get_attention_status = get_attention_status, + .get_latch_status = get_latch_status, + .get_adapter_status = get_adapter_status, + .get_max_bus_speed = get_max_bus_speed, + .get_cur_bus_speed = get_cur_bus_speed, +}; + +#define SLOT_NAME_SIZE 10 + +static int ctrl_slot_setup (struct controller *ctrl, +void __iomem *smbios_start, +void __iomem *smbios_table) +{ +struct slot *slot; +struct hotplug_slot *hotplug_slot; +struct hotplug_slot_info *hotplug_slot_info; +u8 number_of_slots; +u8 slot_device; +u8 slot_number; +u8 ctrl_slot; +u32 tempdword; +char name[SLOT_NAME_SIZE ]; +void __iomem *slot_entry=NULL ; +int result = -ENOMEM ; + +dbg ("%s\n" , __func__); + + tempdword =readl (ctrl->hpc_reg +INT_INPUT_CLEAR ); + + number_of_slots =readb (ctrl->hpc_reg +SLOT_MASK ) &0x0F ; + slot_device =readb (ctrl->hpc_reg +SLOT_MASK ) >>4 ; + slot_number = ctrl->first_slot; + +while (number_of_slots) { + slot =kzalloc (sizeof (*slot),GFP_KERNEL ); +if (!slot) + goto error; + + slot->hotplug_slot =kzalloc (sizeof (*(slot->hotplug_slot)), +GFP_KERNEL ); +if (!slot->hotplug_slot) + goto error_slot; + hotplug_slot = slot->hotplug_slot; + + hotplug_slot->info = +kzalloc (sizeof (*(hotplug_slot->info)), +GFP_KERNEL ); +if (!hotplug_slot->info) + goto error_hpslot; + hotplug_slot_info = hotplug_slot->info; + + slot->ctrl = ctrl; + slot->bus = ctrl->bus; + slot->device = slot_device; + slot->number = slot_number; +dbg ("slot->number = %u\n" , slot->number); + + slot_entry =get_SMBIOS_entry (smbios_start, smbios_table,9 , + slot_entry); + +while (slot_entry && (readw (slot_entry +SMBIOS_SLOT_NUMBER ) != + slot->number)) { + slot_entry =get_SMBIOS_entry (smbios_start, + smbios_table,9 , slot_entry); + } + + slot->p_sm_slot = slot_entry; + +init_timer (&slot->task_event); + slot->task_event.expires = jiffies +5 *HZ ; + slot->task_event.function = cpqhp_pushbutton_thread; + +/*FIXME: these capabilities aren't used but if they are +* they need to be correctly implemented +*/ + slot->capabilities |=PCISLOT_REPLACE_SUPPORTED ; + slot->capabilities |=PCISLOT_INTERLOCK_SUPPORTED ; + +if (is_slot64bit (slot)) + slot->capabilities |=PCISLOT_64_BIT_SUPPORTED ; +if (is_slot66mhz (slot)) + slot->capabilities |=PCISLOT_66_MHZ_SUPPORTED ; +if (ctrl->speed == PCI_SPEED_66MHz) + slot->capabilities |=PCISLOT_66_MHZ_OPERATION ; + + ctrl_slot = + slot_device - (readb (ctrl->hpc_reg +SLOT_MASK ) >>4 ); + +/* Check presence */ + slot->capabilities |= + ((((~tempdword) >>23 ) | + ((~tempdword) >>15 )) >> ctrl_slot) &0x02 ; +/* Check the switch state */ + slot->capabilities |= + ((~tempdword &0xFF ) >> ctrl_slot) &0x01 ; +/* Check the slot enable */ + slot->capabilities |= + ((read_slot_enable (ctrl) <<2 ) >> ctrl_slot) &0x04 ; + +/* register this slot with the hotplug pci core */ + hotplug_slot->release = &release_slot; + hotplug_slot->private = slot; +snprintf (name,SLOT_NAME_SIZE ,"%u" , slot->number); + hotplug_slot->ops = &cpqphp_hotplug_slot_ops; + + hotplug_slot_info->power_status =get_slot_enabled (ctrl, slot); + hotplug_slot_info->attention_status = +cpq_get_attention_status (ctrl, slot); + hotplug_slot_info->latch_status = +cpq_get_latch_status (ctrl, slot); + hotplug_slot_info->adapter_status = +get_presence_status (ctrl, slot); + +dbg ("registering bus %d, dev %d, number %d, " +"ctrl->slot_device_offset %d, slot %d\n" , + slot->bus, slot->device, + slot->number, ctrl->slot_device_offset, + slot_number); + result =pci_hp_register (hotplug_slot, + ctrl->pci_dev->bus, + slot->device, + name); +if (result) { +err ("pci_hp_register failed with error %d\n" , result); + goto error_info; + } + + slot->next = ctrl->slot; + ctrl->slot = slot; + + number_of_slots--; + slot_device++; + slot_number++; + } + +return 0 ; +error_info: +kfree (hotplug_slot_info); +error_hpslot: +kfree (hotplug_slot); +error_slot: +kfree (slot); +error: +return result; +} + +static int one_time_init (void ) +{ +int loop; +int retval =0 ; + +if (initialized) +return 0 ; + + power_mode =0 ; + + retval =pci_print_IRQ_route (); +if (retval) + goto error; + +dbg ("Initialize + Start the notification mechanism \n" ); + + retval =cpqhp_event_start_thread (); +if (retval) + goto error; + +dbg ("Initialize slot lists\n" ); +for (loop =0 ; loop <256 ; loop++) { + cpqhp_slot_list[loop] =NULL ; + } + +/* FIXME: We also need to hook the NMI handler eventually. +* this also needs to be worked with Christoph +* register_NMI_handler(); +*/ +/* Map rom address */ + cpqhp_rom_start =ioremap (ROM_PHY_ADDR ,ROM_PHY_LEN ); +if (!cpqhp_rom_start) { +err ("Could not ioremap memory region for ROM\n" ); + retval = -EIO ; + goto error; + } + +/* Now, map the int15 entry point if we are on compaq specific +* hardware +*/ +compaq_nvram_init (cpqhp_rom_start); + +/* Map smbios table entry point structure */ + smbios_table =detect_SMBIOS_pointer (cpqhp_rom_start, + cpqhp_rom_start +ROM_PHY_LEN ); +if (!smbios_table) { +err ("Could not find the SMBIOS pointer in memory\n" ); + retval = -EIO ; + goto error_rom_start; + } + + smbios_start =ioremap (readl (smbios_table +ST_ADDRESS ), +readw (smbios_table +ST_LENGTH )); +if (!smbios_start) { +err ("Could not ioremap memory region taken from SMBIOS values\n" ); + retval = -EIO ; + goto error_smbios_start; + } + + initialized =1 ; + +return retval; + +error_smbios_start: +iounmap (smbios_start); +error_rom_start: +iounmap (cpqhp_rom_start); +error: +return retval; +} +static int cpqhpc_probe (struct pci_dev *pdev,const struct pci_device_id *ent) {u8 num_of_slots =0 ;
@@ -1300,77 +1358,6 @@ err_disable_device:return rc; } -static int one_time_init (void ) -{ -int loop; -int retval =0 ; - -if (initialized) -return 0 ; - - power_mode =0 ; - - retval =pci_print_IRQ_route (); -if (retval) - goto error; - -dbg ("Initialize + Start the notification mechanism \n" ); - - retval =cpqhp_event_start_thread (); -if (retval) - goto error; - -dbg ("Initialize slot lists\n" ); -for (loop =0 ; loop <256 ; loop++) { - cpqhp_slot_list[loop] =NULL ; - } - -/* FIXME: We also need to hook the NMI handler eventually. -* this also needs to be worked with Christoph -* register_NMI_handler(); -*/ -/* Map rom address */ - cpqhp_rom_start =ioremap (ROM_PHY_ADDR ,ROM_PHY_LEN ); -if (!cpqhp_rom_start) { -err ("Could not ioremap memory region for ROM\n" ); - retval = -EIO ; - goto error; - } - -/* Now, map the int15 entry point if we are on compaq specific -* hardware -*/ -compaq_nvram_init (cpqhp_rom_start); - -/* Map smbios table entry point structure */ - smbios_table =detect_SMBIOS_pointer (cpqhp_rom_start, - cpqhp_rom_start +ROM_PHY_LEN ); -if (!smbios_table) { -err ("Could not find the SMBIOS pointer in memory\n" ); - retval = -EIO ; - goto error_rom_start; - } - - smbios_start =ioremap (readl (smbios_table +ST_ADDRESS ), -readw (smbios_table +ST_LENGTH )); -if (!smbios_start) { -err ("Could not ioremap memory region taken from SMBIOS values\n" ); - retval = -EIO ; - goto error_smbios_start; - } - - initialized =1 ; - -return retval; - -error_smbios_start: -iounmap (smbios_start); -error_rom_start: -iounmap (cpqhp_rom_start); -error: -return retval; -} - static void __exit unload_cpqphpd(void) {struct pci_func *next;
PATCH 5/15 PCI Hotplug: cpqphp: eliminate stray braces
In reply to Alex ChiangClean up style and eliminate superfluous braces and parens.
No functional change.
---
drivers/pci/hotplug/cpqphp_core.c | 55 +++++++++++++++---------------------- 1 files changed, 22 insertions(+), 33 deletions(-)
drivers/pci/hotplug/cpqphp_core.c +22 -33
@@ -154,7 +154,6 @@ static int init_SERR(struct controller * ctrl)return 0 ; } -/* nice debugging output */ static int pci_print_IRQ_route (void ) {
@@ -214,7 +213,7 @@ static void __iomem *get_subsequent_smbios_entry(void __iomem *smbios_start,void __iomem *p_max;if (!smbios_table || !curr) -return (NULL ); +return NULL ;/* set p_max to the end of the table */ p_max = smbios_start +readw (smbios_table +ST_LENGTH );
@@ -227,19 +226,17 @@ static void __iomem *get_subsequent_smbios_entry(void __iomem *smbios_start,* The first condition is the previous byte * and the second is the curr */ -if (!previous_byte && !(readb (p_temp))) { +if (!previous_byte && !(readb (p_temp))) bail =1 ; - } previous_byte =readb (p_temp); p_temp++; } -if (p_temp < p_max) { +if (p_temp < p_max)return p_temp; - }else { +else return NULL ; - } }
@@ -265,21 +262,18 @@ static void __iomem *get_SMBIOS_entry(void __iomem *smbios_start,if (!smbios_table)return NULL ; -if (!previous) { +if (!previous) previous = smbios_start; - }else { +else previous =get_subsequent_smbios_entry (smbios_start, smbios_table, previous); - } -while (previous) { -if (readb (previous +SMBIOS_GENERIC_TYPE ) != type) { +while (previous) +if (readb (previous +SMBIOS_GENERIC_TYPE ) != type) previous =get_subsequent_smbios_entry (smbios_start, smbios_table, previous); - }else { +else break ; - } - }return previous; }
@@ -319,7 +313,7 @@ static int ctrl_slot_cleanup (struct controller * ctrl)release_mem_region (pci_resource_start (ctrl->pci_dev,0 ),pci_resource_len (ctrl->pci_dev,0 )); -return (0 ); +return 0 ; }
@@ -388,9 +382,8 @@ get_slot_mapping(struct pci_bus *bus, u8 bus_num, u8 dev_num, u8 *slot)PCI_DEVFN (tdevice,0 ), PCI_PRIMARY_BUS, &work);// See if bridge's secondary bus matches target bus. -if (((work >>8 ) &0x000000FF ) == (long ) bus_num) { +if (((work >>8 ) &0x000000FF ) == (long ) bus_num) bridgeSlot = tslot; - } } }
@@ -425,21 +418,21 @@ cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func,u8 hp_slot;if (func ==NULL ) -return (1 ); +return 1 ; hp_slot = func->device - ctrl->slot_device_offset;/* Wait for exclusive access to hardware */ mutex_lock (&ctrl->crit_sect); -if (status ==1 ) { +if (status ==1 )amber_LED_on (ctrl, hp_slot); - }else if (status ==0 ) { +else if (status ==0 )amber_LED_off (ctrl, hp_slot); - }else { +else {/* Done with exclusive hardware access */ mutex_unlock (&ctrl->crit_sect); -return (1 ); +return 1 ; }set_SOGO (ctrl);
@@ -450,7 +443,7 @@ cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func,/* Done with exclusive hardware access */ mutex_unlock (&ctrl->crit_sect); -return (0 ); +return 0 ; }
@@ -678,8 +671,7 @@ static int ctrl_slot_setup(struct controller *ctrl, goto error_slot; hotplug_slot = slot->hotplug_slot; - hotplug_slot->info = -kzalloc (sizeof (*(hotplug_slot->info)), + hotplug_slot->info =kzalloc (sizeof (*(hotplug_slot->info)),GFP_KERNEL );if (!hotplug_slot->info) goto error_hpslot;
@@ -801,9 +793,8 @@ static int one_time_init(void) goto error;dbg ("Initialize slot lists\n" ); -for (loop =0 ; loop <256 ; loop++) { +for (loop =0 ; loop <256 ; loop++) cpqhp_slot_list[loop] =NULL ; - }/* FIXME: We also need to hook the NMI handler eventually. * this also needs to be worked with Christoph
@@ -1306,18 +1297,16 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) func->presence_save = (temp_word >> hp_slot) &0x01 ; func->presence_save |= (temp_word >> (hp_slot +7 )) &0x02 ; -if (ctrl->ctrl_int_comp & (0x1L << hp_slot)) { +if (ctrl->ctrl_int_comp & (0x1L << hp_slot)) func->switch_save =0 ; - }else { +else func->switch_save =0x10 ; - } -if (!power_mode) { +if (!power_mode)if (!func->is_a_board) {green_LED_off (ctrl, hp_slot);slot_disable (ctrl, hp_slot); } - } device++; num_of_slots--;
PATCH 6/15 PCI Hotplug: cpqphp: refactor cpqhp_probe
In reply to Alex ChiangApply DeMorgan's theorem:
if ((pdev->revision > 2) || (vendor_id == PCI_VENDOR_ID_INTEL))
turns into
if ((pdev->revision <= 2) && (vendor_id != PCI_VENDOR_ID_INTEL))
Now we can bail out early from the function if the controller is not supported.
This allows us to un-indent the remainder of the function quite a bit and make it much more readable.
Fix up some extra braces, and un-indent the 'case' labels in the switch statement as per CodingStyle.
No functional change.
---
drivers/pci/hotplug/cpqphp_core.c | 382 ++++++++++++++++++------------------- 1 files changed, 185 insertions(+), 197 deletions(-)
drivers/pci/hotplug/cpqphp_core.c +185 -197
@@ -887,214 +887,202 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)* For Intel, each SSID bit identifies a PHP capability. * Also Intel HPC's may have RID=0. */ -if ((pdev->revision >2 ) || (vendor_id ==PCI_VENDOR_ID_INTEL )) { -/* TODO: This code can be made to support non-Compaq or Intel -* subsystem IDs -*/ - rc =pci_read_config_word (pdev,PCI_SUBSYSTEM_VENDOR_ID , &subsystem_vid); -if (rc) { -err ("%s : pci_read_config_word failed\n" , __func__); - goto err_disable_device; - } -dbg ("Subsystem Vendor ID: %x\n" , subsystem_vid); -if ((subsystem_vid !=PCI_VENDOR_ID_COMPAQ ) && (subsystem_vid !=PCI_VENDOR_ID_INTEL )) { -err (msg_HPC_non_compaq_or_intel); - rc = -ENODEV ; - goto err_disable_device; - } +if ((pdev->revision <=2 ) && (vendor_id !=PCI_VENDOR_ID_INTEL )) { +err (msg_HPC_not_supported); +return -ENODEV ; + } + +/* TODO: This code can be made to support non-Compaq or Intel +* subsystem IDs +*/ + rc =pci_read_config_word (pdev,PCI_SUBSYSTEM_VENDOR_ID , &subsystem_vid); +if (rc) { +err ("%s : pci_read_config_word failed\n" , __func__); + goto err_disable_device; + } +dbg ("Subsystem Vendor ID: %x\n" , subsystem_vid); +if ((subsystem_vid !=PCI_VENDOR_ID_COMPAQ ) && (subsystem_vid !=PCI_VENDOR_ID_INTEL )) { +err (msg_HPC_non_compaq_or_intel); + rc = -ENODEV ; + goto err_disable_device; + } + + ctrl =kzalloc (sizeof (struct controller ),GFP_KERNEL ); +if (!ctrl) { +err ("%s : out of memory\n" , __func__); + rc = -ENOMEM ; + goto err_disable_device; + } - ctrl =kzalloc (sizeof (struct controller ),GFP_KERNEL ); -if (!ctrl) { -err ("%s : out of memory\n" , __func__); - rc = -ENOMEM ; - goto err_disable_device; + rc =pci_read_config_word (pdev,PCI_SUBSYSTEM_ID , &subsystem_deviceid); +if (rc) { +err ("%s : pci_read_config_word failed\n" , __func__); + goto err_free_ctrl; + } + +info ("Hot Plug Subsystem Device ID: %x\n" , subsystem_deviceid); + +/* Set Vendor ID, so it can be accessed later from other +* functions +*/ + ctrl->vendor_id = vendor_id; + +switch (subsystem_vid) { +case PCI_VENDOR_ID_COMPAQ : +if (pdev->revision >=0x13 ) {/* CIOBX */ + ctrl->push_flag =1 ; + ctrl->slot_switch_type =1 ; + ctrl->push_button =1 ; + ctrl->pci_config_space =1 ; + ctrl->defeature_PHP =1 ; + ctrl->pcix_support =1 ; + ctrl->pcix_speed_capability =1 ; +pci_read_config_byte (pdev,0x41 , &bus_cap); +if (bus_cap &0x80 ) { +dbg ("bus max supports 133MHz PCI-X\n" ); + ctrl->speed_capability = PCI_SPEED_133MHz_PCIX; +break ; + } +if (bus_cap &0x40 ) { +dbg ("bus max supports 100MHz PCI-X\n" ); + ctrl->speed_capability = PCI_SPEED_100MHz_PCIX; +break ; + } +if (bus_cap &20 ) { +dbg ("bus max supports 66MHz PCI-X\n" ); + ctrl->speed_capability = PCI_SPEED_66MHz_PCIX; +break ; + } +if (bus_cap &10 ) { +dbg ("bus max supports 66MHz PCI\n" ); + ctrl->speed_capability = PCI_SPEED_66MHz; +break ; + } + +break ; } - rc =pci_read_config_word (pdev,PCI_SUBSYSTEM_ID , &subsystem_deviceid); -if (rc) { -err ("%s : pci_read_config_word failed\n" , __func__); +switch (subsystem_deviceid) { +case PCI_SUB_HPC_ID : +/* Original 6500/7000 implementation */ + ctrl->slot_switch_type =1 ; + ctrl->speed_capability = PCI_SPEED_33MHz; + ctrl->push_button =0 ; + ctrl->pci_config_space =1 ; + ctrl->defeature_PHP =1 ; + ctrl->pcix_support =0 ; + ctrl->pcix_speed_capability =0 ; +break ; +case PCI_SUB_HPC_ID2 : +/* First Pushbutton implementation */ + ctrl->push_flag =1 ; + ctrl->slot_switch_type =1 ; + ctrl->speed_capability = PCI_SPEED_33MHz; + ctrl->push_button =1 ; + ctrl->pci_config_space =1 ; + ctrl->defeature_PHP =1 ; + ctrl->pcix_support =0 ; + ctrl->pcix_speed_capability =0 ; +break ; +case PCI_SUB_HPC_ID_INTC : +/* Third party (6500/7000) */ + ctrl->slot_switch_type =1 ; + ctrl->speed_capability = PCI_SPEED_33MHz; + ctrl->push_button =0 ; + ctrl->pci_config_space =1 ; + ctrl->defeature_PHP =1 ; + ctrl->pcix_support =0 ; + ctrl->pcix_speed_capability =0 ; +break ; +case PCI_SUB_HPC_ID3 : +/* First 66 Mhz implementation */ + ctrl->push_flag =1 ; + ctrl->slot_switch_type =1 ; + ctrl->speed_capability = PCI_SPEED_66MHz; + ctrl->push_button =1 ; + ctrl->pci_config_space =1 ; + ctrl->defeature_PHP =1 ; + ctrl->pcix_support =0 ; + ctrl->pcix_speed_capability =0 ; +break ; +case PCI_SUB_HPC_ID4 : +/* First PCI-X implementation, 100MHz */ + ctrl->push_flag =1 ; + ctrl->slot_switch_type =1 ; + ctrl->speed_capability = PCI_SPEED_100MHz_PCIX; + ctrl->push_button =1 ; + ctrl->pci_config_space =1 ; + ctrl->defeature_PHP =1 ; + ctrl->pcix_support =1 ; + ctrl->pcix_speed_capability =0 ; +break ; +default : +err (msg_HPC_not_supported); + rc = -ENODEV ; goto err_free_ctrl; } +break ; -info ("Hot Plug Subsystem Device ID: %x\n" , subsystem_deviceid); +case PCI_VENDOR_ID_INTEL : +/* Check for speed capability (0=33, 1=66) */ +if (subsystem_deviceid &0x0001 ) + ctrl->speed_capability = PCI_SPEED_66MHz; +else + ctrl->speed_capability = PCI_SPEED_33MHz; -/* Set Vendor ID, so it can be accessed later from other -* functions -*/ - ctrl->vendor_id = vendor_id; - -switch (subsystem_vid) { -case PCI_VENDOR_ID_COMPAQ : -if (pdev->revision >=0x13 ) {/* CIOBX */ - ctrl->push_flag =1 ; - ctrl->slot_switch_type =1 ; - ctrl->push_button =1 ; - ctrl->pci_config_space =1 ; - ctrl->defeature_PHP =1 ; - ctrl->pcix_support =1 ; - ctrl->pcix_speed_capability =1 ; -pci_read_config_byte (pdev,0x41 , &bus_cap); -if (bus_cap &0x80 ) { -dbg ("bus max supports 133MHz PCI-X\n" ); - ctrl->speed_capability = PCI_SPEED_133MHz_PCIX; -break ; - } -if (bus_cap &0x40 ) { -dbg ("bus max supports 100MHz PCI-X\n" ); - ctrl->speed_capability = PCI_SPEED_100MHz_PCIX; -break ; - } -if (bus_cap &20 ) { -dbg ("bus max supports 66MHz PCI-X\n" ); - ctrl->speed_capability = PCI_SPEED_66MHz_PCIX; -break ; - } -if (bus_cap &10 ) { -dbg ("bus max supports 66MHz PCI\n" ); - ctrl->speed_capability = PCI_SPEED_66MHz; -break ; - } - -break ; - } - -switch (subsystem_deviceid) { -case PCI_SUB_HPC_ID : -/* Original 6500/7000 implementation */ - ctrl->slot_switch_type =1 ; - ctrl->speed_capability = PCI_SPEED_33MHz; - ctrl->push_button =0 ; - ctrl->pci_config_space =1 ; - ctrl->defeature_PHP =1 ; - ctrl->pcix_support =0 ; - ctrl->pcix_speed_capability =0 ; -break ; -case PCI_SUB_HPC_ID2 : -/* First Pushbutton implementation */ - ctrl->push_flag =1 ; - ctrl->slot_switch_type =1 ; - ctrl->speed_capability = PCI_SPEED_33MHz; - ctrl->push_button =1 ; - ctrl->pci_config_space =1 ; - ctrl->defeature_PHP =1 ; - ctrl->pcix_support =0 ; - ctrl->pcix_speed_capability =0 ; -break ; -case PCI_SUB_HPC_ID_INTC : -/* Third party (6500/7000) */ - ctrl->slot_switch_type =1 ; - ctrl->speed_capability = PCI_SPEED_33MHz; - ctrl->push_button =0 ; - ctrl->pci_config_space =1 ; - ctrl->defeature_PHP =1 ; - ctrl->pcix_support =0 ; - ctrl->pcix_speed_capability =0 ; -break ; -case PCI_SUB_HPC_ID3 : -/* First 66 Mhz implementation */ - ctrl->push_flag =1 ; - ctrl->slot_switch_type =1 ; - ctrl->speed_capability = PCI_SPEED_66MHz; - ctrl->push_button =1 ; - ctrl->pci_config_space =1 ; - ctrl->defeature_PHP =1 ; - ctrl->pcix_support =0 ; - ctrl->pcix_speed_capability =0 ; -break ; -case PCI_SUB_HPC_ID4 : -/* First PCI-X implementation, 100MHz */ - ctrl->push_flag =1 ; - ctrl->slot_switch_type =1 ; - ctrl->speed_capability = PCI_SPEED_100MHz_PCIX; - ctrl->push_button =1 ; - ctrl->pci_config_space =1 ; - ctrl->defeature_PHP =1 ; - ctrl->pcix_support =1 ; - ctrl->pcix_speed_capability =0 ; -break ; -default : -err (msg_HPC_not_supported); - rc = -ENODEV ; - goto err_free_ctrl; - } -break ; +/* Check for push button */ +if (subsystem_deviceid &0x0002 ) + ctrl->push_button =0 ; +else + ctrl->push_button =1 ; -case PCI_VENDOR_ID_INTEL : -/* Check for speed capability (0=33, 1=66) */ -if (subsystem_deviceid &0x0001 ) { - ctrl->speed_capability = PCI_SPEED_66MHz; - }else { - ctrl->speed_capability = PCI_SPEED_33MHz; - } - -/* Check for push button */ -if (subsystem_deviceid &0x0002 ) { -/* no push button */ - ctrl->push_button =0 ; - }else { -/* push button supported */ - ctrl->push_button =1 ; - } - -/* Check for slot switch type (0=mechanical, 1=not mechanical) */ -if (subsystem_deviceid &0x0004 ) { -/* no switch */ - ctrl->slot_switch_type =0 ; - }else { -/* switch */ - ctrl->slot_switch_type =1 ; - } - -/* PHP Status (0=De-feature PHP, 1=Normal operation) */ -if (subsystem_deviceid &0x0008 ) { - ctrl->defeature_PHP =1 ;/* PHP supported */ - }else { - ctrl->defeature_PHP =0 ;/* PHP not supported */ - } - -/* Alternate Base Address Register Interface (0=not supported, 1=supported) */ -if (subsystem_deviceid &0x0010 ) { - ctrl->alternate_base_address =1 ;/* supported */ - }else { - ctrl->alternate_base_address =0 ;/* not supported */ - } - -/* PCI Config Space Index (0=not supported, 1=supported) */ -if (subsystem_deviceid &0x0020 ) { - ctrl->pci_config_space =1 ;/* supported */ - }else { - ctrl->pci_config_space =0 ;/* not supported */ - } - -/* PCI-X support */ -if (subsystem_deviceid &0x0080 ) { -/* PCI-X capable */ - ctrl->pcix_support =1 ; -/* Frequency of operation in PCI-X mode */ -if (subsystem_deviceid &0x0040 ) { -/* 133MHz PCI-X if bit 7 is 1 */ - ctrl->pcix_speed_capability =1 ; - }else { -/* 100MHz PCI-X if bit 7 is 1 and bit 0 is 0, */ -/* 66MHz PCI-X if bit 7 is 1 and bit 0 is 1 */ - ctrl->pcix_speed_capability =0 ; - } - }else { -/* Conventional PCI */ - ctrl->pcix_support =0 ; - ctrl->pcix_speed_capability =0 ; - } -break ; +/* Check for slot switch type (0=mechanical, 1=not mechanical) */ +if (subsystem_deviceid &0x0004 ) + ctrl->slot_switch_type =0 ; +else + ctrl->slot_switch_type =1 ; + +/* PHP Status (0=De-feature PHP, 1=Normal operation) */ +if (subsystem_deviceid &0x0008 ) + ctrl->defeature_PHP =1 ;/* PHP supported */ +else + ctrl->defeature_PHP =0 ;/* PHP not supported */ + +/* Alternate Base Address Register Interface +* (0=not supported, 1=supported) +*/ +if (subsystem_deviceid &0x0010 ) + ctrl->alternate_base_address =1 ; +else + ctrl->alternate_base_address =0 ; -default : -err (msg_HPC_not_supported); - rc = -ENODEV ; - goto err_free_ctrl; +/* PCI Config Space Index (0=not supported, 1=supported) */ +if (subsystem_deviceid &0x0020 ) + ctrl->pci_config_space =1 ; +else + ctrl->pci_config_space =0 ; + +/* PCI-X support */ +if (subsystem_deviceid &0x0080 ) { + ctrl->pcix_support =1 ; +if (subsystem_deviceid &0x0040 ) +/* 133MHz PCI-X if bit 7 is 1 */ + ctrl->pcix_speed_capability =1 ; +else +/* 100MHz PCI-X if bit 7 is 1 and bit 0 is 0, */ +/* 66MHz PCI-X if bit 7 is 1 and bit 0 is 1 */ + ctrl->pcix_speed_capability =0 ; + }else { +/* Conventional PCI */ + ctrl->pcix_support =0 ; + ctrl->pcix_speed_capability =0 ; } +break ; - }else { +default :err (msg_HPC_not_supported); -return -ENODEV ; + rc = -ENODEV ; + goto err_free_ctrl; }/* Tell the user that we found one. */
@@ -1164,7 +1152,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto err_free_mem_region; } -// Check for 66Mhz operation +/* Check for 66Mhz operation */ ctrl->speed =get_controller_speed (ctrl);
PATCH 7/15 PCI Hotplug: cpqphp: clean up cpqphp_ctrl.c
In reply to Alex ChiangStyle and whitespace cleanups, no functional change.
---
drivers/pci/hotplug/cpqphp_ctrl.c | 170 +++++++++++++++++-------------------- 1 files changed, 79 insertions(+), 91 deletions(-)
drivers/pci/hotplug/cpqphp_ctrl.c +79 -91
@@ -132,9 +132,8 @@ static struct slot *cpqhp_find_slot(struct controller *ctrl, u8 device) {struct slot *slot = ctrl->slot; -while (slot && (slot->device != device)) { +while (slot && (slot->device != device)) slot = slot->next; - }return slot; }
@@ -549,10 +548,10 @@ static struct pci_resource *get_io_resource(struct pci_resource **head, u32 sizeif (!(*head))return NULL ; -if (cpqhp_resource_sort_and_combine (head) ) +if (cpqhp_resource_sort_and_combine (head))return NULL ; -if (sort_by_size (head) ) +if (sort_by_size (head))return NULL ;for (node = *head; node; node = node->next) {
@@ -974,12 +973,8 @@ struct pci_func *cpqhp_slot_create(u8 busnumber)struct pci_func *next; new_slot =kzalloc (sizeof (*new_slot),GFP_KERNEL ); -if (new_slot ==NULL ) { -/* I'm not dead yet! -* You will be. -*/ +if (new_slot ==NULL )return new_slot; - } new_slot->next =NULL ; new_slot->configured =1 ;
@@ -1010,10 +1005,8 @@ static int slot_remove(struct pci_func * old_slot)return 1 ; next = cpqhp_slot_list[old_slot->bus]; - -if (next ==NULL ) { +if (next ==NULL )return 1 ; - }if (next == old_slot) { cpqhp_slot_list[old_slot->bus] = old_slot->next;
@@ -1022,9 +1015,8 @@ static int slot_remove(struct pci_func * old_slot)return 0 ; } -while ((next->next != old_slot) && (next->next !=NULL )) { +while ((next->next != old_slot) && (next->next !=NULL )) next = next->next; - }if (next->next == old_slot) { next->next = old_slot->next;
@@ -1054,9 +1046,8 @@ static int bridge_slot_remove(struct pci_func *bridge)for (tempBus = secondaryBus; tempBus <= subordinateBus; tempBus++) { next = cpqhp_slot_list[tempBus]; -while (!slot_remove (next)) { +while (!slot_remove (next)) next = cpqhp_slot_list[tempBus]; - } } next = cpqhp_slot_list[bridge->bus];
@@ -1286,17 +1277,17 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl) hp_slot = func->device - ctrl->slot_device_offset; -if (readl (ctrl->hpc_reg +INT_INPUT_CLEAR ) & (0x01L << hp_slot)) { -/* -* The switch is open. -*/ +/* +* The switch is open. +*/ +if (readl (ctrl->hpc_reg +INT_INPUT_CLEAR ) & (0x01L << hp_slot)) rc =INTERLOCK_OPEN ; - }else if (is_slot_enabled (ctrl, hp_slot)) { -/* -* The board is already on -*/ +/* +* The board is already on +*/ +else if (is_slot_enabled (ctrl, hp_slot)) rc =CARD_FUNCTIONING ; - }else { +else {mutex_lock (&ctrl->crit_sect);/* turn on board without attaching to the bus */
@@ -1542,7 +1533,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) }/* All F's is an empty slot or an invalid board */ -if (temp_register !=0xFFFFFFFF ) {/* Check for a board in the slot */ +if (temp_register !=0xFFFFFFFF ) { res_lists.io_head = ctrl->io_head; res_lists.mem_head = ctrl->mem_head; res_lists.p_mem_head = ctrl->p_mem_head;
@@ -1591,9 +1582,8 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) index =0 ;do { new_slot =cpqhp_slot_find (ctrl->bus, func->device, index++); -if (new_slot && !new_slot->pci_dev) { +if (new_slot && !new_slot->pci_dev)cpqhp_configure_device (ctrl, new_slot); - } }while (new_slot);mutex_lock (&ctrl->crit_sect);
@@ -2134,9 +2124,8 @@ int cpqhp_process_SS(struct controller *ctrl, struct pci_func *func)/* If the VGA Enable bit is set, remove isn't * supported */ -if (BCR &PCI_BRIDGE_CTL_VGA ) { +if (BCR &PCI_BRIDGE_CTL_VGA ) rc =REMOVE_NOT_SUPPORTED ; - } } }
@@ -2204,67 +2193,67 @@ int cpqhp_hardware_test(struct controller *ctrl, int test_num) num_of_slots =readb (ctrl->hpc_reg +SLOT_MASK ) &0x0f ;switch (test_num) { -case 1 : -/* Do stuff here! */ - -/* Do that funky LED thing */ -/* so we can restore them later */ - save_LED =readl (ctrl->hpc_reg +LED_CONTROL ); - work_LED =0x01010101 ; -switch_leds (ctrl, num_of_slots, &work_LED,0 ); -switch_leds (ctrl, num_of_slots, &work_LED,1 ); -switch_leds (ctrl, num_of_slots, &work_LED,0 ); -switch_leds (ctrl, num_of_slots, &work_LED,1 ); - - work_LED =0x01010000 ; -writel (work_LED, ctrl->hpc_reg +LED_CONTROL ); -switch_leds (ctrl, num_of_slots, &work_LED,0 ); -switch_leds (ctrl, num_of_slots, &work_LED,1 ); - work_LED =0x00000101 ; -writel (work_LED, ctrl->hpc_reg +LED_CONTROL ); -switch_leds (ctrl, num_of_slots, &work_LED,0 ); -switch_leds (ctrl, num_of_slots, &work_LED,1 ); - - work_LED =0x01010000 ; -writel (work_LED, ctrl->hpc_reg +LED_CONTROL ); -for (loop =0 ; loop < num_of_slots; loop++) { -set_SOGO (ctrl); +case 1 : +/* Do stuff here! */ + +/* Do that funky LED thing */ +/* so we can restore them later */ + save_LED =readl (ctrl->hpc_reg +LED_CONTROL ); + work_LED =0x01010101 ; +switch_leds (ctrl, num_of_slots, &work_LED,0 ); +switch_leds (ctrl, num_of_slots, &work_LED,1 ); +switch_leds (ctrl, num_of_slots, &work_LED,0 ); +switch_leds (ctrl, num_of_slots, &work_LED,1 ); + + work_LED =0x01010000 ; +writel (work_LED, ctrl->hpc_reg +LED_CONTROL ); +switch_leds (ctrl, num_of_slots, &work_LED,0 ); +switch_leds (ctrl, num_of_slots, &work_LED,1 ); + work_LED =0x00000101 ; +writel (work_LED, ctrl->hpc_reg +LED_CONTROL ); +switch_leds (ctrl, num_of_slots, &work_LED,0 ); +switch_leds (ctrl, num_of_slots, &work_LED,1 ); + + work_LED =0x01010000 ; +writel (work_LED, ctrl->hpc_reg +LED_CONTROL ); +for (loop =0 ; loop < num_of_slots; loop++) { +set_SOGO (ctrl); -/* Wait for SOGO interrupt */ -wait_for_ctrl_irq (ctrl); +/* Wait for SOGO interrupt */ +wait_for_ctrl_irq (ctrl); -/* Get ready for next iteration */ -long_delay ((3 *HZ )/10 ); - work_LED = work_LED >>16 ; -writel (work_LED, ctrl->hpc_reg +LED_CONTROL ); +/* Get ready for next iteration */ +long_delay ((3 *HZ )/10 ); + work_LED = work_LED >>16 ; +writel (work_LED, ctrl->hpc_reg +LED_CONTROL ); -set_SOGO (ctrl); +set_SOGO (ctrl); -/* Wait for SOGO interrupt */ -wait_for_ctrl_irq (ctrl); +/* Wait for SOGO interrupt */ +wait_for_ctrl_irq (ctrl); -/* Get ready for next iteration */ -long_delay ((3 *HZ )/10 ); - work_LED = work_LED <<16 ; -writel (work_LED, ctrl->hpc_reg +LED_CONTROL ); - work_LED = work_LED <<1 ; -writel (work_LED, ctrl->hpc_reg +LED_CONTROL ); - } +/* Get ready for next iteration */ +long_delay ((3 *HZ )/10 ); + work_LED = work_LED <<16 ; +writel (work_LED, ctrl->hpc_reg +LED_CONTROL ); + work_LED = work_LED <<1 ; +writel (work_LED, ctrl->hpc_reg +LED_CONTROL ); + } -/* put it back the way it was */ -writel (save_LED, ctrl->hpc_reg +LED_CONTROL ); +/* put it back the way it was */ +writel (save_LED, ctrl->hpc_reg +LED_CONTROL ); -set_SOGO (ctrl); +set_SOGO (ctrl); -/* Wait for SOBS to be unset */ -wait_for_ctrl_irq (ctrl); -break ; -case 2 : -/* Do other stuff here! */ -break ; -case 3 : -/* and more... */ -break ; +/* Wait for SOBS to be unset */ +wait_for_ctrl_irq (ctrl); +break ; +case 2 : +/* Do other stuff here! */ +break ; +case 3 : +/* and more... */ +break ; }return 0 ; }
@@ -2333,9 +2322,9 @@ static u32 configure_new_device(struct controller * ctrl, struct pci_func * funcwhile ((function < max_functions) && (!stop_it)) {pci_bus_read_config_dword (ctrl->pci_bus,PCI_DEVFN (func->device, function),0x00 , &ID ); -if (ID ==0xFFFFFFFF ) {/* There's nothing there. */ +if (ID ==0xFFFFFFFF ) { function++; - }else {/* There's something there */ + }else {/* Setup slot structure. */ new_slot =cpqhp_slot_create (func->bus);
@@ -2360,8 +2349,8 @@ static u32 configure_new_device(struct controller * ctrl, struct pci_func * func/* -Configuration logic that involves the hotplug data structures and -their bookkeeping +* Configuration logic that involves the hotplug data structures and +* their bookkeeping */
@@ -2414,7 +2403,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *funcif (rc)return rc; -if ((temp_byte &0x7F ) ==PCI_HEADER_TYPE_BRIDGE ) {/* PCI-PCI Bridge */ +if ((temp_byte &0x7F ) ==PCI_HEADER_TYPE_BRIDGE ) {/* set Primary bus */ dbg ("set Primary bus = %d\n" , func->bus); rc =pci_bus_write_config_byte (pci_bus, devfn,PCI_PRIMARY_BUS , func->bus);
@@ -2956,11 +2945,10 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func/* Program IRQ based on card type */ rc =pci_bus_read_config_byte (pci_bus, devfn,0x0B , &class_code); -if (class_code ==PCI_BASE_CLASS_STORAGE ) { +if (class_code ==PCI_BASE_CLASS_STORAGE )IRQ = cpqhp_disk_irq; - }else { +else IRQ = cpqhp_nic_irq; - } }/* IRQ Line */
PATCH 8/15 PCI Hotplug: cpqphp: refactor cpqphp_save_slot_config
In reply to Alex ChiangCheck for an empty slot, and return early if so.
This allows us to un-indent the rest of the function by one level.
---
drivers/pci/hotplug/cpqphp_pci.c | 85 +++++++++++++++++--------------------- 1 files changed, 39 insertions(+), 46 deletions(-)
drivers/pci/hotplug/cpqphp_pci.c +39 -46
@@ -494,7 +494,7 @@ int cpqhp_save_slot_config (struct controller *ctrl, struct pci_func * new_slot)u8 secondary_bus;int sub_bus;int max_functions; -int function; +int function =0 ;int cloop =0 ;int stop_it;
@@ -503,65 +503,58 @@ int cpqhp_save_slot_config (struct controller *ctrl, struct pci_func * new_slot) ctrl->pci_bus->number = new_slot->bus;pci_bus_read_config_dword (ctrl->pci_bus,PCI_DEVFN (new_slot->device,0 ),PCI_VENDOR_ID , &ID ); -if (ID !=0xFFFFFFFF ) {/* device in slot */ -pci_bus_read_config_byte (ctrl->pci_bus,PCI_DEVFN (new_slot->device,0 ),0x0B , &class_code); -pci_bus_read_config_byte (ctrl->pci_bus,PCI_DEVFN (new_slot->device,0 ),PCI_HEADER_TYPE , &header_type); - -if (header_type &0x80 )/* Multi-function device */ - max_functions =8 ; -else - max_functions =1 ; - - function =0 ; +if (ID ==0xFFFFFFFF ) +return 2 ; -do { -if ((header_type &0x7F ) ==PCI_HEADER_TYPE_BRIDGE ) { -/* Recurse the subordinate bus */ -pci_bus_read_config_byte (ctrl->pci_bus,PCI_DEVFN (new_slot->device, function),PCI_SECONDARY_BUS , &secondary_bus); +pci_bus_read_config_byte (ctrl->pci_bus,PCI_DEVFN (new_slot->device,0 ),0x0B , &class_code); +pci_bus_read_config_byte (ctrl->pci_bus,PCI_DEVFN (new_slot->device,0 ),PCI_HEADER_TYPE , &header_type); - sub_bus = (int ) secondary_bus; +if (header_type &0x80 )/* Multi-function device */ + max_functions =8 ; +else + max_functions =1 ; -/* Save the config headers for the secondary -* bus. -*/ - rc =cpqhp_save_config (ctrl, sub_bus,0 ); -if (rc) -return (rc); - ctrl->pci_bus->number = new_slot->bus; +while (function < max_functions) { +if ((header_type &0x7F ) ==PCI_HEADER_TYPE_BRIDGE ) { +/* Recurse the subordinate bus */ +pci_bus_read_config_byte (ctrl->pci_bus,PCI_DEVFN (new_slot->device, function),PCI_SECONDARY_BUS , &secondary_bus); - }/* End of IF */ + sub_bus = (int ) secondary_bus; - new_slot->status =0 ; +/* Save the config headers for the secondary +* bus. +*/ + rc =cpqhp_save_config (ctrl, sub_bus,0 ); +if (rc) +return (rc); + ctrl->pci_bus->number = new_slot->bus; -for (cloop =0 ; cloop <0x20 ; cloop++) { -pci_bus_read_config_dword (ctrl->pci_bus,PCI_DEVFN (new_slot->device, function), cloop <<2 , (u32 *) & (new_slot-> config_space [cloop])); - } + } - function++; + new_slot->status =0 ; - stop_it =0 ; +for (cloop =0 ; cloop <0x20 ; cloop++) +pci_bus_read_config_dword (ctrl->pci_bus,PCI_DEVFN (new_slot->device, function), cloop <<2 , (u32 *) & (new_slot-> config_space [cloop])); -/* this loop skips to the next present function -* reading in the Class Code and the Header type. -*/ -while ((function < max_functions) && (!stop_it)) { -pci_bus_read_config_dword (ctrl->pci_bus,PCI_DEVFN (new_slot->device, function),PCI_VENDOR_ID , &ID ); + function++; -if (ID ==0xFFFFFFFF ) {/* nothing there. */ - function++; - }else {/* Something there */ -pci_bus_read_config_byte (ctrl->pci_bus,PCI_DEVFN (new_slot->device, function),0x0B , &class_code); + stop_it =0 ; -pci_bus_read_config_byte (ctrl->pci_bus,PCI_DEVFN (new_slot->device, function),PCI_HEADER_TYPE , &header_type); +/* this loop skips to the next present function +* reading in the Class Code and the Header type. +*/ +while ((function < max_functions) && (!stop_it)) { +pci_bus_read_config_dword (ctrl->pci_bus,PCI_DEVFN (new_slot->device, function),PCI_VENDOR_ID , &ID ); - stop_it++; - } +if (ID ==0xFFFFFFFF ) + function++; +else { +pci_bus_read_config_byte (ctrl->pci_bus,PCI_DEVFN (new_slot->device, function),0x0B , &class_code); +pci_bus_read_config_byte (ctrl->pci_bus,PCI_DEVFN (new_slot->device, function),PCI_HEADER_TYPE , &header_type); + stop_it++; } + } - }while (function < max_functions); - }/* End of IF (device in slot?) */ -else { -return 2 ; }return 0 ;
PATCH 9/15 PCI Hotplug: cpqphp: style cleanups
In reply to Alex ChiangClean up style, whitespace in cpqphp_pci.c
---
drivers/pci/hotplug/cpqphp_pci.c | 17 ++++++----------- 1 files changed, 6 insertions(+), 11 deletions(-)
drivers/pci/hotplug/cpqphp_pci.c +6 -11
@@ -950,15 +950,13 @@ int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func * func)return (1 ); } }/* End of base register loop */ -/* Some other unknown header type */ - }else { }/* find the next device in this slot */ func =cpqhp_slot_find (func->bus, func->device, index++); } -return (0 ); +return 0 ; }
@@ -993,9 +991,8 @@ int cpqhp_configure_board(struct controller *ctrl, struct pci_func * func)/* Start at the top of config space so that the control * registers are programmed last */ -for (cloop =0x3C ; cloop >0 ; cloop -=4 ) { +for (cloop =0x3C ; cloop >0 ; cloop -=4 )pci_bus_write_config_dword (pci_bus, devfn, cloop, func->config_space[cloop >>2 ]); - }pci_bus_read_config_byte (pci_bus, devfn,PCI_HEADER_TYPE , &header_type);
@@ -1210,9 +1207,9 @@ int cpqhp_find_available_resources(struct controller *ctrl, void __iomem *rom_st rom_resource_table =detect_HRT_floating_pointer (rom_start, rom_start+0xffff );dbg ("rom_resource_table = %p\n" , rom_resource_table); -if (rom_resource_table ==NULL ) { +if (rom_resource_table ==NULL )return -ENODEV ; - } +/* Sum all resources and setup resource maps */ unused_IRQ =readl (rom_resource_table +UNUSED_IRQ );dbg ("unused_IRQ = %x\n" , unused_IRQ);
@@ -1245,13 +1242,11 @@ int cpqhp_find_available_resources(struct controller *ctrl, void __iomem *rom_st temp =0 ; -if (!cpqhp_nic_irq) { +if (!cpqhp_nic_irq) cpqhp_nic_irq = ctrl->cfgspc_irq; - } -if (!cpqhp_disk_irq) { +if (!cpqhp_disk_irq) cpqhp_disk_irq = ctrl->cfgspc_irq; - }dbg ("cpqhp_disk_irq, cpqhp_nic_irq= %d, %d\n" , cpqhp_disk_irq, cpqhp_nic_irq);
PATCH 10/15 PCI Hotplug: cpqphp: refactor cpqhp_save_config
In reply to Alex ChiangHandle an empty slot at the top of the loop, and continue early.
This allows us to un-indent the rest of the function by one level.
---
drivers/pci/hotplug/cpqphp_pci.c | 182 +++++++++++++++++++------------------- 1 files changed, 91 insertions(+), 91 deletions(-)
drivers/pci/hotplug/cpqphp_pci.c +91 -91
@@ -359,121 +359,121 @@ int cpqhp_save_config(struct controller *ctrl, int busnumber, int is_hot_plug) ctrl->pci_bus->number = busnumber;for (device = FirstSupported; device <= LastSupported; device++) {ID =0xFFFFFFFF ; - rc =pci_bus_read_config_dword (ctrl->pci_bus,PCI_DEVFN (device,0 ),PCI_VENDOR_ID , &ID ); + rc =pci_bus_read_config_dword (ctrl->pci_bus,PCI_DEVFN (device,0 ),PCI_VENDOR_ID , &ID ); -if (ID !=0xFFFFFFFF ) {/* device in slot */ - rc =pci_bus_read_config_byte (ctrl->pci_bus,PCI_DEVFN (device,0 ),0x0B , &class_code); -if (rc) -return rc; - - rc =pci_bus_read_config_byte (ctrl->pci_bus,PCI_DEVFN (device,0 ),PCI_HEADER_TYPE , &header_type); -if (rc) -return rc; - -/* If multi-function device, set max_functions to 8 */ -if (header_type &0x80 ) - max_functions =8 ; -else - max_functions =1 ; +if (ID ==0xFFFFFFFF ) { +if (is_hot_plug) { +/* Setup slot structure with entry for empty +* slot +*/ + new_slot =cpqhp_slot_create (busnumber); +if (new_slot ==NULL ) +return 1 ; - function =0 ; + new_slot->bus = (u8 ) busnumber; + new_slot->device = (u8 ) device; + new_slot->function =0 ; + new_slot->is_a_board =0 ; + new_slot->presence_save =0 ; + new_slot->switch_save =0 ; + } +continue ; + } -do { - DevError =0 ; -if ((header_type &0x7F ) ==PCI_HEADER_TYPE_BRIDGE ) { -/* Recurse the subordinate bus -* get the subordinate bus number -*/ - rc =pci_bus_read_config_byte (ctrl->pci_bus,PCI_DEVFN (device, function),PCI_SECONDARY_BUS , &secondary_bus); -if (rc) { -return rc; - }else { - sub_bus = (int ) secondary_bus; + rc =pci_bus_read_config_byte (ctrl->pci_bus,PCI_DEVFN (device,0 ),0x0B , &class_code); +if (rc) +return rc; -/* Save secondary bus cfg spc -* with this recursive call. -*/ - rc =cpqhp_save_config (ctrl, sub_bus,0 ); -if (rc) -return rc; - ctrl->pci_bus->number = busnumber; - } - } + rc =pci_bus_read_config_byte (ctrl->pci_bus,PCI_DEVFN (device,0 ),PCI_HEADER_TYPE , &header_type); +if (rc) +return rc; - index =0 ; - new_slot =cpqhp_slot_find (busnumber, device, index++); -while (new_slot && - (new_slot->function != (u8 ) function)) - new_slot =cpqhp_slot_find (busnumber, device, index++); +/* If multi-function device, set max_functions to 8 */ +if (header_type &0x80 ) + max_functions =8 ; +else + max_functions =1 ; -if (!new_slot) { -/* Setup slot structure. */ - new_slot =cpqhp_slot_create (busnumber); + function =0 ; -if (new_slot ==NULL ) -return (1 ); - } +do { + DevError =0 ; +if ((header_type &0x7F ) ==PCI_HEADER_TYPE_BRIDGE ) { +/* Recurse the subordinate bus +* get the subordinate bus number +*/ + rc =pci_bus_read_config_byte (ctrl->pci_bus,PCI_DEVFN (device, function),PCI_SECONDARY_BUS , &secondary_bus); +if (rc) { +return rc; + }else { + sub_bus = (int ) secondary_bus; - new_slot->bus = (u8 ) busnumber; - new_slot->device = (u8 ) device; - new_slot->function = (u8 ) function; - new_slot->is_a_board =1 ; - new_slot->switch_save =0x10 ; -/* In case of unsupported board */ - new_slot->status = DevError; - new_slot->pci_dev =pci_find_slot (new_slot->bus, (new_slot->device <<3 ) | new_slot->function); - -for (cloop =0 ; cloop <0x20 ; cloop++) { - rc =pci_bus_read_config_dword (ctrl->pci_bus,PCI_DEVFN (device, function), cloop <<2 , (u32 *) & (new_slot-> config_space [cloop])); +/* Save secondary bus cfg spc +* with this recursive call. +*/ + rc =cpqhp_save_config (ctrl, sub_bus,0 );if (rc)return rc; + ctrl->pci_bus->number = busnumber; } + } - function++; + index =0 ; + new_slot =cpqhp_slot_find (busnumber, device, index++); +while (new_slot && + (new_slot->function != (u8 ) function)) + new_slot =cpqhp_slot_find (busnumber, device, index++); - stop_it =0 ; +if (!new_slot) { +/* Setup slot structure. */ + new_slot =cpqhp_slot_create (busnumber); +if (new_slot ==NULL ) +return 1 ; + } -/* this loop skips to the next present function -* reading in Class Code and Header type. -*/ + new_slot->bus = (u8 ) busnumber; + new_slot->device = (u8 ) device; + new_slot->function = (u8 ) function; + new_slot->is_a_board =1 ; + new_slot->switch_save =0x10 ; +/* In case of unsupported board */ + new_slot->status = DevError; + new_slot->pci_dev =pci_find_slot (new_slot->bus, (new_slot->device <<3 ) | new_slot->function); + +for (cloop =0 ; cloop <0x20 ; cloop++) { + rc =pci_bus_read_config_dword (ctrl->pci_bus,PCI_DEVFN (device, function), cloop <<2 , (u32 *) & (new_slot-> config_space [cloop])); +if (rc) +return rc; + } -while ((function < max_functions)&&(!stop_it)) { - rc =pci_bus_read_config_dword (ctrl->pci_bus,PCI_DEVFN (device, function),PCI_VENDOR_ID , &ID ); -if (ID ==0xFFFFFFFF ) {/* nothing there. */ - function++; - }else {/* Something there */ - rc =pci_bus_read_config_byte (ctrl->pci_bus,PCI_DEVFN (device, function),0x0B , &class_code); -if (rc) -return rc; + function++; - rc =pci_bus_read_config_byte (ctrl->pci_bus,PCI_DEVFN (device, function),PCI_HEADER_TYPE , &header_type); -if (rc) -return rc; + stop_it =0 ; - stop_it++; - } +/* this loop skips to the next present function +* reading in Class Code and Header type. +*/ +while ((function < max_functions) && (!stop_it)) { + rc =pci_bus_read_config_dword (ctrl->pci_bus,PCI_DEVFN (device, function),PCI_VENDOR_ID , &ID ); +if (ID ==0xFFFFFFFF ) { + function++; +continue ; } + rc =pci_bus_read_config_byte (ctrl->pci_bus,PCI_DEVFN (device, function),0x0B , &class_code); +if (rc) +return rc; - }while (function < max_functions); - }/* End of IF (device in slot?) */ -else if (is_hot_plug) { -/* Setup slot structure with entry for empty slot */ - new_slot =cpqhp_slot_create (busnumber); + rc =pci_bus_read_config_byte (ctrl->pci_bus,PCI_DEVFN (device, function),PCI_HEADER_TYPE , &header_type); +if (rc) +return rc; -if (new_slot ==NULL ) { -return (1 ); + stop_it++; } - new_slot->bus = (u8 ) busnumber; - new_slot->device = (u8 ) device; - new_slot->function =0 ; - new_slot->is_a_board =0 ; - new_slot->presence_save =0 ; - new_slot->switch_save =0 ; - } + }while (function < max_functions); }/* End of FOR loop */ -return (0 ); +return 0 ; }
PATCH 11/15 PCI Hotplug: cpqphp: clean up accesses to pcibios_get_irq_routing_table()
In reply to Alex ChiangInstead of making multiple calls to pcibios_get_irq_routing_table, let's just do it once and save the answer.
The reason we were making multiple calls is because we liked to calculate its length and perform some loop over it. Instead of open-coding the length calculation every time, provide it in an inline helper function.
Finally, since pci_print_IRQ_route() is used only for debug, let's only do it when cpqhp_debug is set.
---
drivers/pci/hotplug/cpqphp.h | 9 +++++ drivers/pci/hotplug/cpqphp_core.c | 72 ++++++++++++++++--------------------- drivers/pci/hotplug/cpqphp_pci.c | 36 ++++--------------- 3 files changed, 47 insertions(+), 70 deletions(-)
drivers/pci/hotplug/cpqphp.h +9 -0
@@ -455,6 +455,7 @@ extern int cpqhp_debug;extern int cpqhp_legacy_mode;extern struct controller *cpqhp_ctrl_list;extern struct pci_func *cpqhp_slot_list[256 ]; +extern struct irq_routing_table *cpqhp_routing_table;/* these can be gotten rid of, but for debugging they are purty */ extern u8 cpqhp_nic_irq;
@@ -733,4 +734,12 @@ static inline int wait_for_ctrl_irq(struct controller *ctrl) return retval; } +#include <asm/pci_x86.h> +static inline int cpqhp_routing_table_length (void ) +{ +BUG_ON (cpqhp_routing_table ==NULL ); +return ((cpqhp_routing_table->size -sizeof (struct irq_routing_table )) / +sizeof (struct irq_info )); +} +#endif
drivers/pci/hotplug/cpqphp_core.c +31 -41
137 lines not on this page · raw message
drivers/pci/hotplug/cpqphp_pci.c +7 -29
@@ -37,7 +37,6 @@#include "../pci.h" #include "cpqphp.h" #include "cpqphp_nvram.h" -#include <asm/pci_x86.h> u8 cpqhp_nic_irq;
@@ -244,39 +243,23 @@ static int PCI_ScanBusForNonBridge(struct controller *ctrl, u8 bus_num, u8 * devstatic int PCI_GetBusDevHelper (struct controller *ctrl,u8 *bus_num,u8 *dev_num,u8 slot,u8 nobridge) { -struct irq_routing_table *PCIIRQRoutingInfoLength; -long len; -long loop; +int loop, len;u32 work; -u8 tbus, tdevice, tslot; - PCIIRQRoutingInfoLength =pcibios_get_irq_routing_table (); -if (!PCIIRQRoutingInfoLength) -return -1 ; - - len = (PCIIRQRoutingInfoLength->size - -sizeof (struct irq_routing_table )) /sizeof (struct irq_info ); -/* Make sure I got at least one entry */ -if (len ==0 ) { -kfree (PCIIRQRoutingInfoLength ); -return -1 ; - } - + len =cpqhp_routing_table_length ();for (loop =0 ; loop < len; ++loop) { - tbus = PCIIRQRoutingInfoLength->slots[loop].bus; - tdevice = PCIIRQRoutingInfoLength->slots[loop].devfn; - tslot = PCIIRQRoutingInfoLength->slots[loop].slot; + tbus = cpqhp_routing_table->slots[loop].bus; + tdevice = cpqhp_routing_table->slots[loop].devfn; + tslot = cpqhp_routing_table->slots[loop].slot;if (tslot == slot) { *bus_num = tbus; *dev_num = tdevice; ctrl->pci_bus->number = tbus;pci_bus_read_config_dword (ctrl->pci_bus, *dev_num,PCI_VENDOR_ID , &work); -if (!nobridge || (work ==0xffffffff )) { -kfree (PCIIRQRoutingInfoLength ); +if (!nobridge || (work ==0xffffffff ))return 0 ; - }dbg ("bus_num %d devfn %d\n" , *bus_num, *dev_num);pci_bus_read_config_dword (ctrl->pci_bus, *dev_num,PCI_CLASS_REVISION , &work);
@@ -287,17 +270,12 @@ static int PCI_GetBusDevHelper(struct controller *ctrl, u8 *bus_num, u8 *dev_numdbg ("Scan bus for Non Bridge: bus %d\n" , tbus);if (PCI_ScanBusForNonBridge (ctrl, tbus, dev_num) ==0 ) { *bus_num = tbus; -kfree (PCIIRQRoutingInfoLength );return 0 ; } - }else { -kfree (PCIIRQRoutingInfoLength ); + }else return 0 ; - } - } } -kfree (PCIIRQRoutingInfoLength );return -1 ; }
PATCH 12/15 PCI Hotplug: cpqphp: eliminate dead code - PCI_ScanBusNonBridge
In reply to Alex ChiangI have no clue what the original intent here was, but the code as written is useless.
The old dbg() statement above the old callsite might lead one to think that at one point, there was supposed to be some recursion, but any sense of sanity here has been lost to the ravages of time.
---
drivers/pci/hotplug/cpqphp_pci.c | 14 ++------------ 1 files changed, 2 insertions(+), 12 deletions(-)
drivers/pci/hotplug/cpqphp_pci.c +2 -12
@@ -193,16 +193,6 @@ int cpqhp_set_irq (u8 bus_num, u8 dev_num, u8 int_pin, u8 irq_num) } -/* -* WTF??? This function isn't in the code, yet a function calls it, but the -* compiler optimizes it away? strange. Here as a placeholder to keep the -* compiler happy. -*/ -static int PCI_ScanBusNonBridge (u8 bus,u8 device) -{ -return 0 ; -} -static int PCI_ScanBusForNonBridge (struct controller *ctrl,u8 bus_num,u8 * dev_num) {u16 tdevice;
@@ -231,9 +221,9 @@ static int PCI_ScanBusForNonBridge(struct controller *ctrl, u8 bus_num, u8 * dev/* Yep we got one. bridge ? */ if ((work >>8 ) ==PCI_TO_PCI_BRIDGE_CLASS ) {pci_bus_read_config_byte (ctrl->pci_bus,PCI_DEVFN (tdevice,0 ),PCI_SECONDARY_BUS , &tbus); +/* XXX: no recursion, wtf? */ dbg ("Recurse on bus_num %d tdevice %d\n" , tbus, tdevice); -if (PCI_ScanBusNonBridge (tbus, tdevice) ==0 ) -return 0 ; +return 0 ; } }
PATCH 13/15 PCI Hotplug: cpqphp: constify slot_name()
In reply to Alex ChiangEliminate this warning:
warning: return discards qualifiers from pointer target type
---
drivers/pci/hotplug/cpqphp.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/pci/hotplug/cpqphp.h +1 -1
@@ -464,7 +464,7 @@ extern u8 cpqhp_disk_irq;/* inline functions */ -static inline char *slot_name (struct slot *slot) +static inline const char *slot_name (struct slot *slot) {return hotplug_slot_name (slot->hotplug_slot); }
PATCH 14/15 PCI Hotplug: cpqphp: don't use pci_find_slot()
In reply to Alex ChiangConvert uses of pci_find_slot to modern API.
In the conversion sites, we end up calling pci_dev_put() right away.
This may seem like it misses the entire point of doing something like pci_get_bus_and_slot(), since we drop the reference so soon, but it turns out we don't actually do much with the returned pci_dev.
I plan on untangling cpqphp further, but clearly cpqphp never worried too much about a properly refcounted pci_dev anyway. For now, this conversion seems reasonable, as it gets rid of the last in-tree caller of pci_find_slot.
---
drivers/pci/hotplug/Kconfig | 2 +- drivers/pci/hotplug/cpqphp_pci.c | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-)
drivers/pci/hotplug/Kconfig +1 -1
@@ -41,7 +41,7 @@ config HOTPLUG_PCI_FAKE config HOTPLUG_PCI_COMPAQ tristate "Compaq PCI Hotplug driver" - depends on X86 && PCI_BIOS && PCI_LEGACY + depends on X86 && PCI_BIOS help Say Y here if you have a motherboard with a Compaq PCI Hotplug controller.
drivers/pci/hotplug/cpqphp_pci.c +11 -5
@@ -88,7 +88,7 @@ int cpqhp_configure_device (struct controller* ctrl, struct pci_func* func)int num;if (func->pci_dev ==NULL ) - func->pci_dev =pci_find_slot (func->bus,PCI_DEVFN (func->device, func->function)); + func->pci_dev =pci_get_bus_and_slot (func->bus,PCI_DEVFN (func->device, func->function));/* No pci device, we need to create it then */ if (func->pci_dev ==NULL ) {
@@ -98,7 +98,7 @@ int cpqhp_configure_device (struct controller* ctrl, struct pci_func* func)if (num)pci_bus_add_devices (ctrl->pci_dev->bus); - func->pci_dev =pci_find_slot (func->bus,PCI_DEVFN (func->device, func->function)); + func->pci_dev =pci_get_bus_and_slot (func->bus,PCI_DEVFN (func->device, func->function));if (func->pci_dev ==NULL ) {dbg ("ERROR: pci_dev still null\n" );return 0 ;
@@ -111,6 +111,8 @@ int cpqhp_configure_device (struct controller* ctrl, struct pci_func* func)pci_do_scan_bus (child); } +pci_dev_put (func->pci_dev); +return 0 ; }
@@ -122,9 +124,11 @@ int cpqhp_unconfigure_device(struct pci_func* func)dbg ("%s: bus/dev/func = %x/%x/%x\n" , __func__, func->bus, func->device, func->function);for (j=0 ; j<8 ; j++) { -struct pci_dev * temp =pci_find_slot (func->bus,PCI_DEVFN (func->device, j)); -if (temp) +struct pci_dev * temp =pci_get_bus_and_slot (func->bus,PCI_DEVFN (func->device, j)); +if (temp) { +pci_dev_put (temp);pci_remove_bus_device (temp); + } }return 0 ; }
@@ -406,7 +410,7 @@ int cpqhp_save_config(struct controller *ctrl, int busnumber, int is_hot_plug) new_slot->switch_save =0x10 ;/* In case of unsupported board */ new_slot->status = DevError; - new_slot->pci_dev =pci_find_slot (new_slot->bus, (new_slot->device <<3 ) | new_slot->function); + new_slot->pci_dev =pci_get_bus_and_slot (new_slot->bus, (new_slot->device <<3 ) | new_slot->function);for (cloop =0 ; cloop <0x20 ; cloop++) { rc =pci_bus_read_config_dword (ctrl->pci_bus,PCI_DEVFN (device, function), cloop <<2 , (u32 *) & (new_slot-> config_space [cloop]));
@@ -414,6 +418,8 @@ int cpqhp_save_config(struct controller *ctrl, int busnumber, int is_hot_plug)return rc; } +pci_dev_put (new_slot->pci_dev); + function++; stop_it =0 ;
PATCH 15/15 PCI: remove deprecated pci_find_slot() interface
In reply to Alex ChiangThe last in-tree caller of pci_find_slot has been converted, so let's get rid of this deprecated interface.
---
drivers/pci/search.c | 30 ------------------------------ include/linux/pci.h | 8 -------- 2 files changed, 0 insertions(+), 38 deletions(-)
drivers/pci/search.c +0 -30
@@ -115,36 +115,6 @@ pci_find_next_bus(const struct pci_bus *from)#ifdef CONFIG_PCI_LEGACY /** -* pci_find_slot - locate PCI device from a given PCI slot -* @bus: number of PCI bus on which desired PCI device resides -* @devfn: encodes number of PCI slot in which the desired PCI -* device resides and the logical device number within that slot -* in case of multi-function devices. -* -* Given a PCI bus and slot/function number, the desired PCI device -* is located in system global list of PCI devices. If the device -* is found, a pointer to its data structure is returned. If no -* device is found, %NULL is returned. -* -* NOTE: Do not use this function any more; use pci_get_slot() instead, as -* the PCI device returned by this function can disappear at any moment in -* time. -*/ -struct pci_dev *pci_find_slot (unsigned int bus,unsigned int devfn) -{ -struct pci_dev *dev =NULL ; - -while ((dev =pci_get_device (PCI_ANY_ID ,PCI_ANY_ID , dev)) !=NULL ) { -if (dev->bus->number == bus && dev->devfn == devfn) { -pci_dev_put (dev); -return dev; - } - } -return NULL ; -} -EXPORT_SYMBOL (pci_find_slot); - -/** * pci_find_device - begin or continue searching for a PCI device by vendor/device id * @vendor: PCI vendor id to match, or %PCI_ANY_ID to match all vendor ids * @device: PCI device id to match, or %PCI_ANY_ID to match all device ids
include/linux/pci.h +0 -8
@@ -574,8 +574,6 @@ extern void pci_sort_breadthfirst(void);struct pci_dev __deprecated *pci_find_device (unsigned int vendor,unsigned int device,struct pci_dev *from); -struct pci_dev __deprecated *pci_find_slot (unsigned int bus, -unsigned int devfn);#endif /* CONFIG_PCI_LEGACY */ enum pci_lost_interrupt_reason {
@@ -895,12 +893,6 @@ static inline struct pci_dev *pci_find_device(unsigned int vendor,return NULL ; } -static inline struct pci_dev *pci_find_slot (unsigned int bus, -unsigned int devfn) -{ -return NULL ; -} -static inline struct pci_dev *pci_get_device (unsigned int vendor,unsigned int device,struct pci_dev *from)
Re: [PATCH 15/15] PCI: remove deprecated pci_find_slot() interface
Quoted 4 lines · On Tue, 31 Mar 2009 09:24:22 -0600 Alex Chiang <[email protected]> wrote:
The last in-tree caller of
pci_find_slothas been converted, so let's get rid of this deprecated interface.Signed-off-by Alex Chiang <[email protected]>
Ok applied this series. No more pci_find_slot, yay!
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center