From mboxrd@z Thu Jan 1 00:00:00 1970 From: Albert ARIBAUD Date: Tue, 08 Nov 2011 22:53:02 +0100 Subject: [U-Boot] [PATCH v2] BeagleBoard: match gpio_request() and gpio_free() In-Reply-To: <4EA1C4A0.7050005@aribaud.net> References: <1317715159-11367-1-git-send-email-kukyakya@gmail.com> <1317816507-5566-1-git-send-email-kukyakya@gmail.com> <4EA1C4A0.7050005@aribaud.net> Message-ID: <4EB9A4BE.4030701@aribaud.net> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Le 21/10/2011 21:14, Albert ARIBAUD a ?crit : > Hi In-Bae Jeong, > > Le 05/10/2011 14:08, In-Bae Jeong a ?crit : >> This patch adds code to match gpio_free() to the corresponding >> gpio_request() >> >> Signed-off-by: In-Bae Jeong >> --- >> Changes for v2: >> - added lables for gpio_request() >> - separated labels and statements >> --- >> board/ti/beagle/beagle.c | 43 +++++++++++++++++++++++++++++-------------- >> 1 files changed, 29 insertions(+), 14 deletions(-) >> >> diff --git a/board/ti/beagle/beagle.c b/board/ti/beagle/beagle.c >> index aa5047c..6859594 100644 >> --- a/board/ti/beagle/beagle.c >> +++ b/board/ti/beagle/beagle.c >> @@ -115,24 +115,39 @@ int board_init(void) >> int get_board_revision(void) >> { >> int revision; >> + int error = 0; >> >> - if (!gpio_request(171, "")&& >> - !gpio_request(172, "")&& >> - !gpio_request(173, "")) { >> + if (gpio_request(171, "revision0")) { >> + error = 171; >> + goto gpio_171_err; >> + } >> + if (gpio_request(172, "revision1")) { >> + error = 172; >> + goto gpio_172_err; >> + } >> + if (gpio_request(173, "revision2")) { >> + error = 173; >> + goto gpio_173_err; >> + } >> + >> + gpio_direction_input(171); >> + gpio_direction_input(172); >> + gpio_direction_input(173); >> >> - gpio_direction_input(171); >> - gpio_direction_input(172); >> - gpio_direction_input(173); >> + revision = gpio_get_value(173)<< 2 | >> + gpio_get_value(172)<< 1 | >> + gpio_get_value(171); >> >> - revision = gpio_get_value(173)<< 2 | >> - gpio_get_value(172)<< 1 | >> - gpio_get_value(171); >> + gpio_free(173); >> +gpio_173_err: >> + gpio_free(172); >> +gpio_172_err: >> + gpio_free(171); >> +gpio_171_err: >> >> - gpio_free(171); >> - gpio_free(172); >> - gpio_free(173); >> - } else { >> - printf("Error: unable to acquire board revision GPIOs\n"); >> + if (error) { >> + printf("Error: Unable to acquire board revision gpio %i\n", > > Nitpick: i and d format specifiers are indeed interchangeable, but d is > far more common -- to the point that I had to go and check wether i > differed in any from d. Can you resubmit using d as the specifier? > >> + error); >> revision = -1; >> } > > Amicalement, Ping? Amicalement, -- Albert.