Patchwork [U-Boot,1/2] mvsata: fix ide_preinit for missing disks

login
register
mail settings
Submitter Simon Guinot
Date Nov. 1, 2011, 1:46 p.m.
Message ID <1320155177-7317-2-git-send-email-simon@sequanux.org>
Download mbox | patch
Permalink /patch/123072/
State Superseded
Headers show

Comments

Simon Guinot - Nov. 1, 2011, 1:46 p.m.
From: Simon Guinot <simon.guinot@sequanux.org>

Consider that ide_preinit() succeed if at least one port is successfully
initialized. This allows to iniatialize IDE support on a board with two
SATA ports but a single hard disk available.

Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
---
 drivers/block/mvsata_ide.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)
Prafulla Wadaskar - Nov. 2, 2011, 6:18 a.m.
> -----Original Message-----
> From: Simon Guinot [mailto:simon@sequanux.org]
> Sent: Tuesday, November 01, 2011 7:16 PM
> To: Prafulla Wadaskar
> Cc: u-boot@lists.denx.de; Simon Guinot
> Subject: [PATCH 1/2] mvsata: fix ide_preinit for missing disks
> 
> From: Simon Guinot <simon.guinot@sequanux.org>
> 
> Consider that ide_preinit() succeed if at least one port is
> successfully
> initialized. This allows to iniatialize IDE support on a board
> with two
> SATA ports but a single hard disk available.
> 
> Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
> ---
>  drivers/block/mvsata_ide.c |   14 ++++++++------
>  1 files changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/block/mvsata_ide.c
> b/drivers/block/mvsata_ide.c
> index 1be395f..c7357fc 100644
> --- a/drivers/block/mvsata_ide.c
> +++ b/drivers/block/mvsata_ide.c
> @@ -150,23 +150,25 @@ static int
> mvsata_ide_initialize_port(struct mvsata_port_registers *port)
> 
>  int ide_preinit(void)
>  {
> +	int ret = 1;

Replace magic no 1 by MVSATA_STATUS_TIMEOUT

>  	int status;
> +
>  	/* Enable ATA port 0 (could be SATA port 0 or 1) if
> declared */
>  #if defined(CONFIG_SYS_ATA_IDE0_OFFSET)
>  	status = mvsata_ide_initialize_port(
>  		(struct mvsata_port_registers *)
>  		(CONFIG_SYS_ATA_BASE_ADDR +
> CONFIG_SYS_ATA_IDE0_OFFSET));
> -	if (status)
> -		return status;
> +	if (status == MVSATA_STATUS_OK)
> +		ret = 0;

Replace magic no 0 by MVSATA_STATUS_OK

>  #endif
>  	/* Enable ATA port 1 (could be SATA port 0 or 1) if
> declared */
>  #if defined(CONFIG_SYS_ATA_IDE1_OFFSET)
>  	status = mvsata_ide_initialize_port(
>  		(struct mvsata_port_registers *)
>  		(CONFIG_SYS_ATA_BASE_ADDR +
> CONFIG_SYS_ATA_IDE1_OFFSET));
> -	if (status)
> -		return status;
> +	if (status == MVSATA_STATUS_OK)
> +		ret = 0;

Replace magic no 0 by MVSATA_STATUS_OK


>  #endif
> -	/* return success if all ports initializations succeeded */
> -	return MVSATA_STATUS_OK;
> +	/* Return success if at least one port initialization
> succeeded */
> +	return ret;

Regards..
Prafulla . .

>  }
> --
> 1.7.5.1

Patch

diff --git a/drivers/block/mvsata_ide.c b/drivers/block/mvsata_ide.c
index 1be395f..c7357fc 100644
--- a/drivers/block/mvsata_ide.c
+++ b/drivers/block/mvsata_ide.c
@@ -150,23 +150,25 @@  static int mvsata_ide_initialize_port(struct mvsata_port_registers *port)
 
 int ide_preinit(void)
 {
+	int ret = 1;
 	int status;
+
 	/* Enable ATA port 0 (could be SATA port 0 or 1) if declared */
 #if defined(CONFIG_SYS_ATA_IDE0_OFFSET)
 	status = mvsata_ide_initialize_port(
 		(struct mvsata_port_registers *)
 		(CONFIG_SYS_ATA_BASE_ADDR + CONFIG_SYS_ATA_IDE0_OFFSET));
-	if (status)
-		return status;
+	if (status == MVSATA_STATUS_OK)
+		ret = 0;
 #endif
 	/* Enable ATA port 1 (could be SATA port 0 or 1) if declared */
 #if defined(CONFIG_SYS_ATA_IDE1_OFFSET)
 	status = mvsata_ide_initialize_port(
 		(struct mvsata_port_registers *)
 		(CONFIG_SYS_ATA_BASE_ADDR + CONFIG_SYS_ATA_IDE1_OFFSET));
-	if (status)
-		return status;
+	if (status == MVSATA_STATUS_OK)
+		ret = 0;
 #endif
-	/* return success if all ports initializations succeeded */
-	return MVSATA_STATUS_OK;
+	/* Return success if at least one port initialization succeeded */
+	return ret;
 }