From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nikita Kiryanov Date: Thu, 20 Jun 2013 10:44:43 +0300 Subject: [U-Boot] [PATCH] gpio: omap_gpio: Remove check_gpio() function In-Reply-To: References: <1371690189.3940.1.camel@phoenix> <51C290E5.50703@compulab.co.il> Message-ID: <51C2B2EB.8080300@compulab.co.il> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 06/20/2013 10:20 AM, Axel Lin wrote: > 2013/6/20 Nikita Kiryanov > >> Hi Axel, >> >> >> On 06/20/2013 04:03 AM, Axel Lin wrote: >> >>> check_gpio() and gpio_is_valid() are both used to check if a gpio is >>> valid or >>> not. It looks pointless to have both function because we can just call >>> gpio_is_valid() instead of check_gpio(). Thus remove check_gpio() >>> function. >>> >> >> I don't see the benefit in this patch. >> The functions clearly exist for different reasons: gpio_is_valid() is >> part of the gpio api, while check_gpio() exists to attach an error >> message to a failed validity check without causing code duplication all >> over omap_gpio.c. >> > > How about just showing error in gpio_is_valid() and then remove > check_gpio()? It is not an error for gpio_is_valid() to report that a gpio is not valid. It is however an error to attempt to use an invalid gpio. > > int gpio_is_valid(int gpio) > { > if ((gpio >= 0) && (gpio < 192)) > return 1; > > printf("ERROR : invalid GPIO %d\n", gpio); > return 0; > } > > >> Essentially what you are doing is removing a helpful error message. > > My intention is to remove redundant code. check_gpio() adds upon gpio_is_valid(). If you want to argue redundancy you should explain why this addition is unnecessary. > > Regards, > Axel > -- Regards, Nikita.