linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mmc: dw_mmc: fix num_slots setting
@ 2016-01-22  7:43 Shawn Lin
  2016-02-02  4:42 ` Jaehoon Chung
  0 siblings, 1 reply; 3+ messages in thread
From: Shawn Lin @ 2016-01-22  7:43 UTC (permalink / raw)
  To: Jaehoon Chung, Ulf Hansson; +Cc: linux-mmc, linux-kernel, Shawn Lin

This patch make num_slots to 1 if pdata->num_slot is not
defined. Meanwhile, we need to make sure num_slots should
not larger that the supported slots

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/mmc/host/dw_mmc.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 7128351..065a8f5 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -2949,12 +2949,6 @@ int dw_mci_probe(struct dw_mci *host)
 		}
 	}
 
-	if (host->pdata->num_slots < 1) {
-		dev_err(host->dev,
-			"Platform data must supply num_slots.\n");
-		return -ENODEV;
-	}
-
 	host->biu_clk = devm_clk_get(host->dev, "biu");
 	if (IS_ERR(host->biu_clk)) {
 		dev_dbg(host->dev, "biu clock not available\n");
@@ -3111,7 +3105,15 @@ int dw_mci_probe(struct dw_mci *host)
 	if (host->pdata->num_slots)
 		host->num_slots = host->pdata->num_slots;
 	else
-		host->num_slots = SDMMC_GET_SLOT_NUM(mci_readl(host, HCON));
+		host->num_slots = 1;
+
+	if (host->num_slots < 1 ||
+	    host->num_slots > SDMMC_GET_SLOT_NUM(mci_readl(host, HCON))) {
+		dev_err(host->dev,
+			"Platform data must supply correct num_slots.\n");
+		ret = -ENODEV;
+		goto err_clk_ciu;
+	}
 
 	/*
 	 * Enable interrupts for command done, data over, data empty,
-- 
2.3.7

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mmc: dw_mmc: fix num_slots setting
  2016-01-22  7:43 [PATCH] mmc: dw_mmc: fix num_slots setting Shawn Lin
@ 2016-02-02  4:42 ` Jaehoon Chung
  2016-02-02  6:02   ` Shawn Lin
  0 siblings, 1 reply; 3+ messages in thread
From: Jaehoon Chung @ 2016-02-02  4:42 UTC (permalink / raw)
  To: Shawn Lin, Ulf Hansson; +Cc: linux-mmc, linux-kernel

Hi, Shawn.

On 01/22/2016 04:43 PM, Shawn Lin wrote:
> This patch make num_slots to 1 if pdata->num_slot is not
> defined. Meanwhile, we need to make sure num_slots should
> not larger that the supported slots
> 
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
> ---
> 
>  drivers/mmc/host/dw_mmc.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
> index 7128351..065a8f5 100644
> --- a/drivers/mmc/host/dw_mmc.c
> +++ b/drivers/mmc/host/dw_mmc.c
> @@ -2949,12 +2949,6 @@ int dw_mci_probe(struct dw_mci *host)
>  		}
>  	}
>  
> -	if (host->pdata->num_slots < 1) {
> -		dev_err(host->dev,
> -			"Platform data must supply num_slots.\n");
> -		return -ENODEV;
> -	}
> -
>  	host->biu_clk = devm_clk_get(host->dev, "biu");
>  	if (IS_ERR(host->biu_clk)) {
>  		dev_dbg(host->dev, "biu clock not available\n");
> @@ -3111,7 +3105,15 @@ int dw_mci_probe(struct dw_mci *host)
>  	if (host->pdata->num_slots)
>  		host->num_slots = host->pdata->num_slots;
>  	else
> -		host->num_slots = SDMMC_GET_SLOT_NUM(mci_readl(host, HCON));
> +		host->num_slots = 1;

If host->nums_slots is set to 1, it assumes that there is one slot.
Then the code in dw_mci_parse_dt() can be removed 

                dev_info(dev,
                         "num-slots property not found, assuming 1 slot is available\n");
                pdata->num_slots = 1;


Best Regards,
Jaehoon Chung
            

> +
> +	if (host->num_slots < 1 ||
> +	    host->num_slots > SDMMC_GET_SLOT_NUM(mci_readl(host, HCON))) {
> +		dev_err(host->dev,
> +			"Platform data must supply correct num_slots.\n");
> +		ret = -ENODEV;
> +		goto err_clk_ciu;
> +	}
>  
>  	/*
>  	 * Enable interrupts for command done, data over, data empty,
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mmc: dw_mmc: fix num_slots setting
  2016-02-02  4:42 ` Jaehoon Chung
@ 2016-02-02  6:02   ` Shawn Lin
  0 siblings, 0 replies; 3+ messages in thread
From: Shawn Lin @ 2016-02-02  6:02 UTC (permalink / raw)
  To: Jaehoon Chung, Ulf Hansson; +Cc: shawn.lin, linux-mmc, linux-kernel

Hi Jaehoon,

On 2016/2/2 12:42, Jaehoon Chung wrote:
> Hi, Shawn.
>
> On 01/22/2016 04:43 PM, Shawn Lin wrote:
>> This patch make num_slots to 1 if pdata->num_slot is not
>> defined. Meanwhile, we need to make sure num_slots should
>> not larger that the supported slots
>>
>> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
>> ---
>>
>>   drivers/mmc/host/dw_mmc.c | 16 +++++++++-------
>>   1 file changed, 9 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
>> index 7128351..065a8f5 100644
>> --- a/drivers/mmc/host/dw_mmc.c
>> +++ b/drivers/mmc/host/dw_mmc.c
>> @@ -2949,12 +2949,6 @@ int dw_mci_probe(struct dw_mci *host)
>>   		}
>>   	}
>>
>> -	if (host->pdata->num_slots < 1) {
>> -		dev_err(host->dev,
>> -			"Platform data must supply num_slots.\n");
>> -		return -ENODEV;
>> -	}
>> -
>>   	host->biu_clk = devm_clk_get(host->dev, "biu");
>>   	if (IS_ERR(host->biu_clk)) {
>>   		dev_dbg(host->dev, "biu clock not available\n");
>> @@ -3111,7 +3105,15 @@ int dw_mci_probe(struct dw_mci *host)
>>   	if (host->pdata->num_slots)
>>   		host->num_slots = host->pdata->num_slots;
>>   	else
>> -		host->num_slots = SDMMC_GET_SLOT_NUM(mci_readl(host, HCON));
>> +		host->num_slots = 1;
>
> If host->nums_slots is set to 1, it assumes that there is one slot.
> Then the code in dw_mci_parse_dt() can be removed
>
>                  dev_info(dev,
>                           "num-slots property not found, assuming 1 slot is available\n");
>                  pdata->num_slots = 1;
>

Good catch. I will respin v2 to move it.

Thanks.
>
> Best Regards,
> Jaehoon Chung
>
>
>> +
>> +	if (host->num_slots < 1 ||
>> +	    host->num_slots > SDMMC_GET_SLOT_NUM(mci_readl(host, HCON))) {
>> +		dev_err(host->dev,
>> +			"Platform data must supply correct num_slots.\n");
>> +		ret = -ENODEV;
>> +		goto err_clk_ciu;
>> +	}
>>
>>   	/*
>>   	 * Enable interrupts for command done, data over, data empty,
>>
>
>
>
>


-- 
Best Regards
Shawn Lin

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-02-02  6:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-22  7:43 [PATCH] mmc: dw_mmc: fix num_slots setting Shawn Lin
2016-02-02  4:42 ` Jaehoon Chung
2016-02-02  6:02   ` Shawn Lin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).