From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751677AbdJ3MaS (ORCPT ); Mon, 30 Oct 2017 08:30:18 -0400 Received: from mout.web.de ([212.227.17.12]:62162 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751451AbdJ3MaQ (ORCPT ); Mon, 30 Oct 2017 08:30:16 -0400 To: linux-pci@vger.kernel.org, Bjorn Helgaas Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Subject: [PATCH] ibmphp_pci: Use common error handling code in unconfigure_boot_device() Message-ID: <9db967bd-b7f9-d7e8-a858-a409f07c2a51@users.sourceforge.net> Date: Mon, 30 Oct 2017 13:30:13 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:3uXleqK7vMc6HBqdow2kHmT3bCZibaxGcx7enJohyMzc3avi3Qa akP0lFHiONwuavF8JPhdeGQzOTlD9SUQwue6XfQXZK4JeoS5LcOWtAcb0Th8q3Z9VahfkkA /Tznony+aSV93rTdBLcjqFDBAcaT7+EYnt0FMNEjv3SjejlsIR9KA8LNgB1JCmtwPeFa8IO AVqcWCuKC59B826MZ+g9A== X-UI-Out-Filterresults: notjunk:1;V01:K0:CO1e6g4fGtk=:n4IVKee1b6IbHZEh6CpO3a yYFaEwgY69+//+Q1ijuRRB/avCFgoOI85+fD3MKAHZZLAbaZEA2CaZCaUZuHAyuXsfirOzDvo hVeZIaYZ1w1vu84jCkq8pCKy1vPh9tevLETIUFJVwKzKLwuh5Xxfgx6mqkyDjuW5JTKgGbjOL tN2t5r1KvkfEtepRt2o5CXdNVWTFNCztR2rrhjLeAjr3oCm9RmyhDqGh/wFf0ZO1Fg3VKzHws O1O/Fp9+mHqEFXqhgTJeW6Oso2FGNb/do+mhcEUEVU3geA4NFx+Z1FkosxENGaJ8BnPNLkK0V nj8abn8NIzmq/JiwZxlmOALnGw+3aieHIlNUy8IH3TaXVjI4aENMMgfPZRCftLlen39cSG2JB YhoSbA1UX54YhCQc3fAHl1W3kv9V+WctcSbB+GZzH2/VvNBe+o3l+aFRsqKte179mesl/1prv 7nIFTbGPK1POGKc/PR3+WlXN/b4++EI0q+ls7XAFFcr0fK9T43KdOBHqn6SM0Ds2m7Uf+Aah8 uuzU7wAwoawKA6QJrS7TbdSpe4fiHfqrRI5sGN9iIwWvstinvbK7Yd6WyQGDCg0SlxtrxeYOA 2pi4CiaOGAWhI/RoyqmK5N1b0n5OXCNIu9h/02w6II/RVgmnhnu1PRwFboK681sWOn/5LVqJl NIWHDJszMyXqzHQrNUJenPChu49L5gfoG2GXBsTzK4QZOweN6u7uNaT9QGAu+qlNZdJjPmrWu nicjbSCYRhfYEWu4aQ2zsCogcNr8xyaOnpGs9uh4rGCCcDX8LLMKCdJjHCTkxTMnBFCiLLITp lZpc0hfjvH54LVkPudhxgtrYROUnl+NTu027ahQwOqxPU7AtQw= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Mon, 30 Oct 2017 13:26:32 +0100 * Add a jump target so that a specific error message is stored only once at the end of this function implementation. * Replace two calls of the macro "err" by goto statements. * Adjust two condition checks. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/pci/hotplug/ibmphp_pci.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/pci/hotplug/ibmphp_pci.c b/drivers/pci/hotplug/ibmphp_pci.c index dc1876feb06f..25edd0b18b75 100644 --- a/drivers/pci/hotplug/ibmphp_pci.c +++ b/drivers/pci/hotplug/ibmphp_pci.c @@ -1267,20 +1267,19 @@ static int unconfigure_boot_device(u8 busno, u8 device, u8 function) size = size & 0xFFFFFFFC; size = ~size + 1; end_address = start_address + size - 1; - if (ibmphp_find_resource(bus, start_address, &io, IO) < 0) { - err("cannot find corresponding IO resource to remove\n"); - return -EIO; - } + if (ibmphp_find_resource(bus, start_address, &io, IO)) + goto report_search_failure; + debug("io->start = %x\n", io->start); temp_end = io->end; start_address = io->end + 1; ibmphp_remove_resource(io); /* This is needed b/c of the old I/O restrictions in the BIOS */ while (temp_end < end_address) { - if (ibmphp_find_resource(bus, start_address, &io, IO) < 0) { - err("cannot find corresponding IO resource to remove\n"); - return -EIO; - } + if (ibmphp_find_resource(bus, start_address, + &io, IO)) + goto report_search_failure; + debug("io->start = %x\n", io->start); temp_end = io->end; start_address = io->end + 1; @@ -1327,6 +1326,10 @@ static int unconfigure_boot_device(u8 busno, u8 device, u8 function) } /* end of for */ return 0; + +report_search_failure: + err("cannot find corresponding IO resource to remove\n"); + return -EIO; } static int unconfigure_boot_bridge(u8 busno, u8 device, u8 function) -- 2.14.3