* [PATCH] PCI: cpqphp: minor cleanup and removal of unreachable paths
[not found] <1356030701-16284-1-git-send-email-sasha.levin@oracle.com>
@ 2012-12-20 19:11 ` Sasha Levin
2013-01-07 18:48 ` Bjorn Helgaas
0 siblings, 1 reply; 2+ messages in thread
From: Sasha Levin @ 2012-12-20 19:11 UTC (permalink / raw)
To: Bjorn Helgaas, Sasha Levin, Alan Cox, linux-pci, linux-kernel
Remove cases of redundant checks and remote unreachable paths.
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
drivers/pci/hotplug/cpqphp_ctrl.c | 57 ++++++++++++++-------------------------
1 file changed, 20 insertions(+), 37 deletions(-)
diff --git a/drivers/pci/hotplug/cpqphp_ctrl.c b/drivers/pci/hotplug/cpqphp_ctrl.c
index 36112fe..d282019 100644
--- a/drivers/pci/hotplug/cpqphp_ctrl.c
+++ b/drivers/pci/hotplug/cpqphp_ctrl.c
@@ -1900,8 +1900,7 @@ static void interrupt_event_handler(struct controller *ctrl)
dbg("power fault\n");
} else {
/* refresh notification */
- if (p_slot)
- update_slot_info(ctrl, p_slot);
+ update_slot_info(ctrl, p_slot);
}
ctrl->event_queue[loop].event_type = 0;
@@ -2520,44 +2519,28 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
/* If we have IO resources copy them and fill in the bridge's
* IO range registers */
- if (io_node) {
- memcpy(hold_IO_node, io_node, sizeof(struct pci_resource));
- io_node->next = NULL;
+ memcpy(hold_IO_node, io_node, sizeof(struct pci_resource));
+ io_node->next = NULL;
- /* set IO base and Limit registers */
- temp_byte = io_node->base >> 8;
- rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_IO_BASE, temp_byte);
+ /* set IO base and Limit registers */
+ temp_byte = io_node->base >> 8;
+ rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_IO_BASE, temp_byte);
- temp_byte = (io_node->base + io_node->length - 1) >> 8;
- rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_IO_LIMIT, temp_byte);
- } else {
- kfree(hold_IO_node);
- hold_IO_node = NULL;
- }
-
- /* If we have memory resources copy them and fill in the
- * bridge's memory range registers. Otherwise, fill in the
- * range registers with values that disable them. */
- if (mem_node) {
- memcpy(hold_mem_node, mem_node, sizeof(struct pci_resource));
- mem_node->next = NULL;
-
- /* set Mem base and Limit registers */
- temp_word = mem_node->base >> 16;
- rc = pci_bus_write_config_word(pci_bus, devfn, PCI_MEMORY_BASE, temp_word);
+ temp_byte = (io_node->base + io_node->length - 1) >> 8;
+ rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_IO_LIMIT, temp_byte);
- temp_word = (mem_node->base + mem_node->length - 1) >> 16;
- rc = pci_bus_write_config_word(pci_bus, devfn, PCI_MEMORY_LIMIT, temp_word);
- } else {
- temp_word = 0xFFFF;
- rc = pci_bus_write_config_word(pci_bus, devfn, PCI_MEMORY_BASE, temp_word);
+ /* Copy the memory resources and fill in the bridge's memory
+ * range registers.
+ */
+ memcpy(hold_mem_node, mem_node, sizeof(struct pci_resource));
+ mem_node->next = NULL;
- temp_word = 0x0000;
- rc = pci_bus_write_config_word(pci_bus, devfn, PCI_MEMORY_LIMIT, temp_word);
+ /* set Mem base and Limit registers */
+ temp_word = mem_node->base >> 16;
+ rc = pci_bus_write_config_word(pci_bus, devfn, PCI_MEMORY_BASE, temp_word);
- kfree(hold_mem_node);
- hold_mem_node = NULL;
- }
+ temp_word = (mem_node->base + mem_node->length - 1) >> 16;
+ rc = pci_bus_write_config_word(pci_bus, devfn, PCI_MEMORY_LIMIT, temp_word);
memcpy(hold_p_mem_node, p_mem_node, sizeof(struct pci_resource));
p_mem_node->next = NULL;
@@ -2627,7 +2610,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
/* Return unused bus resources
* First use the temporary node to store information for
* the board */
- if (hold_bus_node && bus_node && temp_resources.bus_head) {
+ if (bus_node && temp_resources.bus_head) {
hold_bus_node->length = bus_node->base - hold_bus_node->base;
hold_bus_node->next = func->bus_head;
@@ -2751,7 +2734,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
}
/* If we have prefetchable memory space available and there
* is some left at the end, return the unused portion */
- if (hold_p_mem_node && temp_resources.p_mem_head) {
+ if (temp_resources.p_mem_head) {
p_mem_node = do_pre_bridge_resource_split(&(temp_resources.p_mem_head),
&hold_p_mem_node, 0x100000);
--
1.8.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] PCI: cpqphp: minor cleanup and removal of unreachable paths
2012-12-20 19:11 ` [PATCH] PCI: cpqphp: minor cleanup and removal of unreachable paths Sasha Levin
@ 2013-01-07 18:48 ` Bjorn Helgaas
0 siblings, 0 replies; 2+ messages in thread
From: Bjorn Helgaas @ 2013-01-07 18:48 UTC (permalink / raw)
To: Sasha Levin; +Cc: Alan Cox, linux-pci, linux-kernel
On Thu, Dec 20, 2012 at 12:11 PM, Sasha Levin <sasha.levin@oracle.com> wrote:
> Remove cases of redundant checks and remote unreachable paths.
>
> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Thanks, Sasha. I applied this for v3.9.
> ---
> drivers/pci/hotplug/cpqphp_ctrl.c | 57 ++++++++++++++-------------------------
> 1 file changed, 20 insertions(+), 37 deletions(-)
>
> diff --git a/drivers/pci/hotplug/cpqphp_ctrl.c b/drivers/pci/hotplug/cpqphp_ctrl.c
> index 36112fe..d282019 100644
> --- a/drivers/pci/hotplug/cpqphp_ctrl.c
> +++ b/drivers/pci/hotplug/cpqphp_ctrl.c
> @@ -1900,8 +1900,7 @@ static void interrupt_event_handler(struct controller *ctrl)
> dbg("power fault\n");
> } else {
> /* refresh notification */
> - if (p_slot)
> - update_slot_info(ctrl, p_slot);
> + update_slot_info(ctrl, p_slot);
> }
>
> ctrl->event_queue[loop].event_type = 0;
> @@ -2520,44 +2519,28 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
>
> /* If we have IO resources copy them and fill in the bridge's
> * IO range registers */
> - if (io_node) {
> - memcpy(hold_IO_node, io_node, sizeof(struct pci_resource));
> - io_node->next = NULL;
> + memcpy(hold_IO_node, io_node, sizeof(struct pci_resource));
> + io_node->next = NULL;
>
> - /* set IO base and Limit registers */
> - temp_byte = io_node->base >> 8;
> - rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_IO_BASE, temp_byte);
> + /* set IO base and Limit registers */
> + temp_byte = io_node->base >> 8;
> + rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_IO_BASE, temp_byte);
>
> - temp_byte = (io_node->base + io_node->length - 1) >> 8;
> - rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_IO_LIMIT, temp_byte);
> - } else {
> - kfree(hold_IO_node);
> - hold_IO_node = NULL;
> - }
> -
> - /* If we have memory resources copy them and fill in the
> - * bridge's memory range registers. Otherwise, fill in the
> - * range registers with values that disable them. */
> - if (mem_node) {
> - memcpy(hold_mem_node, mem_node, sizeof(struct pci_resource));
> - mem_node->next = NULL;
> -
> - /* set Mem base and Limit registers */
> - temp_word = mem_node->base >> 16;
> - rc = pci_bus_write_config_word(pci_bus, devfn, PCI_MEMORY_BASE, temp_word);
> + temp_byte = (io_node->base + io_node->length - 1) >> 8;
> + rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_IO_LIMIT, temp_byte);
>
> - temp_word = (mem_node->base + mem_node->length - 1) >> 16;
> - rc = pci_bus_write_config_word(pci_bus, devfn, PCI_MEMORY_LIMIT, temp_word);
> - } else {
> - temp_word = 0xFFFF;
> - rc = pci_bus_write_config_word(pci_bus, devfn, PCI_MEMORY_BASE, temp_word);
> + /* Copy the memory resources and fill in the bridge's memory
> + * range registers.
> + */
> + memcpy(hold_mem_node, mem_node, sizeof(struct pci_resource));
> + mem_node->next = NULL;
>
> - temp_word = 0x0000;
> - rc = pci_bus_write_config_word(pci_bus, devfn, PCI_MEMORY_LIMIT, temp_word);
> + /* set Mem base and Limit registers */
> + temp_word = mem_node->base >> 16;
> + rc = pci_bus_write_config_word(pci_bus, devfn, PCI_MEMORY_BASE, temp_word);
>
> - kfree(hold_mem_node);
> - hold_mem_node = NULL;
> - }
> + temp_word = (mem_node->base + mem_node->length - 1) >> 16;
> + rc = pci_bus_write_config_word(pci_bus, devfn, PCI_MEMORY_LIMIT, temp_word);
>
> memcpy(hold_p_mem_node, p_mem_node, sizeof(struct pci_resource));
> p_mem_node->next = NULL;
> @@ -2627,7 +2610,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
> /* Return unused bus resources
> * First use the temporary node to store information for
> * the board */
> - if (hold_bus_node && bus_node && temp_resources.bus_head) {
> + if (bus_node && temp_resources.bus_head) {
> hold_bus_node->length = bus_node->base - hold_bus_node->base;
>
> hold_bus_node->next = func->bus_head;
> @@ -2751,7 +2734,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
> }
> /* If we have prefetchable memory space available and there
> * is some left at the end, return the unused portion */
> - if (hold_p_mem_node && temp_resources.p_mem_head) {
> + if (temp_resources.p_mem_head) {
> p_mem_node = do_pre_bridge_resource_split(&(temp_resources.p_mem_head),
> &hold_p_mem_node, 0x100000);
>
> --
> 1.8.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-01-07 18:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1356030701-16284-1-git-send-email-sasha.levin@oracle.com>
2012-12-20 19:11 ` [PATCH] PCI: cpqphp: minor cleanup and removal of unreachable paths Sasha Levin
2013-01-07 18:48 ` Bjorn Helgaas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).