BeagleBoard: match gpio_request() and gpio_free()
PATCH 1/1 BeagleBoard: match gpio_request() and gpio_free()
This patch adds code to match gpio_free() to the corresponding gpio_request()
--- board/ti/beagle/beagle.c | 41 +++++++++++++++++++++++++++-------------- 1 files changed, 27 insertions(+), 14 deletions(-)
board/ti/beagle/beagle.c +27 -14
@@ -115,24 +115,37 @@ 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 ,"" )) { + error =171 ; + goto GPIO_171_ERR; + } +if (gpio_request (172 ,"" )) { + error =172 ; + goto GPIO_172_ERR; + } +if (gpio_request (173 ,"" )) { + 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_NO_ERR: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" , + error); revision =-1 ; }
Signature · 1 line
1.7.3.4
PATCH 1/1 BeagleBoard: match gpio_request() and gpio_free()
Quoted 5 lines · On Tuesday, October 04, 2011 03:59:19 In-Bae Jeong wrote:
board/ti/beagle/beagle.c +2
-3-if (!gpio_request (171 ,"" ) && - !gpio_request (172 ,"" ) && - !gpio_request (173 ,"" )) { +if (gpio_request (171 ,"" )) { + error =171 ;
board/ti/beagle/beagle.c int board_init(void) · line 131
Quoted 10 lines
board/ti/beagle/beagle.c +10
-0+ goto GPIO_171_ERR; + } +if (gpio_request (172 ,"" )) { + error =172 ; + goto GPIO_172_ERR; + } +if (gpio_request (173 ,"" )) { + error =173 ; + goto GPIO_173_ERR; + }
why isn't this code passing a proper label to gpio_request() ?
board/ti/beagle/beagle.c int board_init(void) · line 144
Quoted 4 lines
board/ti/beagle/beagle.c +4
-0+GPIO_NO_ERR:gpio_free (173 ); +GPIO_173_ERR:gpio_free (172 ); +GPIO_172_ERR:gpio_free (171 ); +GPIO_171_ERR:
labels and statements should not be on the same line
also, lose the caps
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111004/63e17ef0/attachment.pgp
PATCH v2 1/1 BeagleBoard: match gpio_request() and gpio_free()
In reply to In-Bae JeongThis patch adds code to match gpio_free() to the corresponding gpio_request()
---
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(-)
board/ti/beagle/beagle.c +29 -14
@@ -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" , + error); revision =-1 ; }
Signature · 1 line
1.7.3.4
PATCH v2 1/1 BeagleBoard: match gpio_request() and gpio_free()
Hi In-Bae Jeong,
Le 05/10/2011 14:08, In-Bae Jeong a ?crit :
Quoted 56 lines
This patch adds code to match
gpio_free()to the correspondinggpio_request()Signed-off-by In-Bae Jeong<[email protected]>---
Changes for v2:
- added lables forgpio_request()
- separated labels and statements--- board/ti/beagle/beagle.c | 43 +++++++++++++++++++++++++++++-------------- 1 files changed, 29 insertions(+), 14 deletions(-)board/ti/beagle/beagle.c +24
-9@@ -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:
board/ti/beagle/beagle.c int board_init(void) · line 149
Quoted 10 lines
board/ti/beagle/beagle.c +4
-5+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?
board/ti/beagle/beagle.c int board_init(void) · line 152
Quoted 3 lines
board/ti/beagle/beagle.c +1
-0+ error); revision =-1 ; }
Amicalement,
Signature · 1 line
Albert.
PATCH v2 1/1 BeagleBoard: match gpio_request() and gpio_free()
Le 21/10/2011 21:14, Albert ARIBAUD a ?crit :
Quoted 74 lines
Hi In-Bae Jeong,
Le 05/10/2011 14:08, In-Bae Jeong a ?crit :
Quoted 56 lines
This patch adds code to match
gpio_free()to the correspondinggpio_request()Signed-off-by In-Bae Jeong<[email protected]>---
Changes for v2:
- added lables forgpio_request()
- separated labels and statements--- board/ti/beagle/beagle.c | 43 +++++++++++++++++++++++++++++-------------- 1 files changed, 29 insertions(+), 14 deletions(-)board/ti/beagle/beagle.c +24
-9@@ -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:board/ti/beagle/beagle.c int board_init(void) · line 149
Quoted 10 lines
board/ti/beagle/beagle.c +4
-5+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?
Quoted 5 lines
board/ti/beagle/beagle.c int board_init(void) · line 152
Quoted 3 lines
board/ti/beagle/beagle.c +1
-0+ error); revision =-1 ; }Amicalement,
Ping?
Amicalement,
Signature · 1 line
Albert.