diff mbox

[U-Boot,02/32] nitrogen6x: simplify board_mmc_getcd

Message ID 1412277413-30271-3-git-send-email-eric.nelson@boundarydevices.com
State Awaiting Upstream
Delegated to: Stefano Babic
Headers show

Commit Message

Eric Nelson Oct. 2, 2014, 7:16 p.m. UTC
From: Troy Kisky <troy.kisky@boundarydevices.com>

The same logic applies to both SD card slots, only with different
GPIOs and the code should make that easier to see.

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
---
 board/boundary/nitrogen6x/nitrogen6x.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

Comments

Stefano Babic Oct. 6, 2014, 3:58 p.m. UTC | #1
On 02/10/2014 21:16, Eric Nelson wrote:
> From: Troy Kisky <troy.kisky@boundarydevices.com>
> 
> The same logic applies to both SD card slots, only with different
> GPIOs and the code should make that easier to see.
> 
> Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
> ---



Applied to u-boot-imx, thanks !

Best regards,
Stefano Babic
diff mbox

Patch

diff --git a/board/boundary/nitrogen6x/nitrogen6x.c b/board/boundary/nitrogen6x/nitrogen6x.c
index 1a6edac..e8cc243 100644
--- a/board/boundary/nitrogen6x/nitrogen6x.c
+++ b/board/boundary/nitrogen6x/nitrogen6x.c
@@ -279,17 +279,11 @@  struct fsl_esdhc_cfg usdhc_cfg[2] = {
 int board_mmc_getcd(struct mmc *mmc)
 {
 	struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
-	int ret;
-
-	if (cfg->esdhc_base == USDHC3_BASE_ADDR) {
-		gpio_direction_input(IMX_GPIO_NR(7, 0));
-		ret = !gpio_get_value(IMX_GPIO_NR(7, 0));
-	} else {
-		gpio_direction_input(IMX_GPIO_NR(2, 6));
-		ret = !gpio_get_value(IMX_GPIO_NR(2, 6));
-	}
+	int gp_cd = (cfg->esdhc_base == USDHC3_BASE_ADDR) ? IMX_GPIO_NR(7, 0) :
+			IMX_GPIO_NR(2, 6);
 
-	return ret;
+	gpio_direction_input(gp_cd);
+	return !gpio_get_value(gp_cd);
 }
 
 int board_mmc_init(bd_t *bis)