* [RFC PATCH] mmc: dw_mmc: remove redundant num_slots check
@ 2016-01-21 7:52 Shawn Lin
2016-01-22 2:46 ` Jaehoon Chung
0 siblings, 1 reply; 4+ messages in thread
From: Shawn Lin @ 2016-01-21 7:52 UTC (permalink / raw)
To: Jaehoon Chung, Ulf Hansson; +Cc: linux-mmc, linux-kernel, Shawn Lin
num_slots comes from pdata if existing, otherwise from
dw_mci_parse_dt which make it at least one slot. If
num_slots is less than 1 for the existing pdata case,
current code return -ENODEV. But dw_mci_probe seems to
treat this a optional case as it will call SDMMC_GET_SLOT_NUM
if no slot assigned.
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---
drivers/mmc/host/dw_mmc.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 7128351..a116ec6 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");
--
2.3.7
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] mmc: dw_mmc: remove redundant num_slots check
2016-01-21 7:52 [RFC PATCH] mmc: dw_mmc: remove redundant num_slots check Shawn Lin
@ 2016-01-22 2:46 ` Jaehoon Chung
2016-01-22 3:07 ` Shawn Lin
0 siblings, 1 reply; 4+ messages in thread
From: Jaehoon Chung @ 2016-01-22 2:46 UTC (permalink / raw)
To: Shawn Lin, Ulf Hansson; +Cc: linux-mmc, linux-kernel
Hi, Shawn.
On 01/21/2016 04:52 PM, Shawn Lin wrote:
> num_slots comes from pdata if existing, otherwise from
> dw_mci_parse_dt which make it at least one slot. If
> num_slots is less than 1 for the existing pdata case,
> current code return -ENODEV. But dw_mci_probe seems to
> treat this a optional case as it will call SDMMC_GET_SLOT_NUM
> if no slot assigned.
Well, we need to consider more thing..
Host can get the number of slot from SDMMC_GET_SLOT_NUM().
But i think this way also has the problem.
num_slot isn't defined anywhere, and num_slot should be set to value of SDMMC_GET_SLOT_NUM.
If that value is higher than 1, it should be blocking..(I didn't test all cases..)
Even though this patch is not correct, i could check the problem relevant to num_slot, because of this patch. :)
my suggestion is if pdata->num_slot is not defined anywhere, just set to 1 by default.
not take from SDMMC_GET_SLOT_NUM.
if (host->pdata->nums_slots < 1 ||
host->pdata->nums_slots > SDMMC_GET_SLOT_NUM())
This is correct condition. num_slots can't be higher than number of supported slots.
how about?
Best Regards,
Jaehoon Chung
>
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
>
> ---
>
> drivers/mmc/host/dw_mmc.c | 6 ------
> 1 file changed, 6 deletions(-)
>
> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
> index 7128351..a116ec6 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");
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] mmc: dw_mmc: remove redundant num_slots check
2016-01-22 2:46 ` Jaehoon Chung
@ 2016-01-22 3:07 ` Shawn Lin
2016-01-22 5:04 ` Jaehoon Chung
0 siblings, 1 reply; 4+ messages in thread
From: Shawn Lin @ 2016-01-22 3:07 UTC (permalink / raw)
To: Jaehoon Chung, Ulf Hansson; +Cc: shawn.lin, linux-mmc, linux-kernel
On 2016/1/22 10:46, Jaehoon Chung wrote:
> Hi, Shawn.
>
> On 01/21/2016 04:52 PM, Shawn Lin wrote:
>> num_slots comes from pdata if existing, otherwise from
>> dw_mci_parse_dt which make it at least one slot. If
>> num_slots is less than 1 for the existing pdata case,
>> current code return -ENODEV. But dw_mci_probe seems to
>> treat this a optional case as it will call SDMMC_GET_SLOT_NUM
>> if no slot assigned.
>
> Well, we need to consider more thing..
> Host can get the number of slot from SDMMC_GET_SLOT_NUM().
> But i think this way also has the problem.
>
> num_slot isn't defined anywhere, and num_slot should be set to value of SDMMC_GET_SLOT_NUM.
> If that value is higher than 1, it should be blocking..(I didn't test all cases..)
>
Actually, from the code itself, it confused me the way about how we get
num_slot. At leaset, we might should try to cleanup it someway to make
it a little more clear. And just as what you point out, we see some
broblem here.
> Even though this patch is not correct, i could check the problem relevant to num_slot, because of this patch. :)
>
Nice to here that. I make it a RFC patch since I also not quite sure
about all cases including some corner cases. Let's think it twice.
> my suggestion is if pdata->num_slot is not defined anywhere, just set to 1 by default.
> not take from SDMMC_GET_SLOT_NUM.
>
yes, SDMMC_GET_SLOT_NUM is the capability of controller, num_slot is
hardware wired number. So, geting it from SDMMC_GET_SLOT_NUM has
problem.
> if (host->pdata->nums_slots < 1 ||
> host->pdata->nums_slots > SDMMC_GET_SLOT_NUM())
>
> This is correct condition. num_slots can't be higher than number of supported slots.
> how about?
Seems reasonable.
I guess you want to come up with a new patch dealing with it? :)
>
> Best Regards,
> Jaehoon Chung
>
>>
>> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
>>
>> ---
>>
>> drivers/mmc/host/dw_mmc.c | 6 ------
>> 1 file changed, 6 deletions(-)
>>
>> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
>> index 7128351..a116ec6 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");
>>
>
>
>
>
--
Best Regards
Shawn Lin
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] mmc: dw_mmc: remove redundant num_slots check
2016-01-22 3:07 ` Shawn Lin
@ 2016-01-22 5:04 ` Jaehoon Chung
0 siblings, 0 replies; 4+ messages in thread
From: Jaehoon Chung @ 2016-01-22 5:04 UTC (permalink / raw)
To: Shawn Lin, Ulf Hansson; +Cc: linux-mmc, linux-kernel
On 01/22/2016 12:07 PM, Shawn Lin wrote:
> On 2016/1/22 10:46, Jaehoon Chung wrote:
>> Hi, Shawn.
>>
>> On 01/21/2016 04:52 PM, Shawn Lin wrote:
>>> num_slots comes from pdata if existing, otherwise from
>>> dw_mci_parse_dt which make it at least one slot. If
>>> num_slots is less than 1 for the existing pdata case,
>>> current code return -ENODEV. But dw_mci_probe seems to
>>> treat this a optional case as it will call SDMMC_GET_SLOT_NUM
>>> if no slot assigned.
>>
>> Well, we need to consider more thing..
>> Host can get the number of slot from SDMMC_GET_SLOT_NUM().
>> But i think this way also has the problem.
>>
>> num_slot isn't defined anywhere, and num_slot should be set to value of SDMMC_GET_SLOT_NUM.
>> If that value is higher than 1, it should be blocking..(I didn't test all cases..)
>>
>
> Actually, from the code itself, it confused me the way about how we get
> num_slot. At leaset, we might should try to cleanup it someway to make
> it a little more clear. And just as what you point out, we see some
> broblem here.
>
>> Even though this patch is not correct, i could check the problem relevant to num_slot, because of this patch. :)
>>
>
> Nice to here that. I make it a RFC patch since I also not quite sure
> about all cases including some corner cases. Let's think it twice.
>
>> my suggestion is if pdata->num_slot is not defined anywhere, just set to 1 by default.
>> not take from SDMMC_GET_SLOT_NUM.
>>
>
> yes, SDMMC_GET_SLOT_NUM is the capability of controller, num_slot is
> hardware wired number. So, geting it from SDMMC_GET_SLOT_NUM has
> problem.
>
>> if (host->pdata->nums_slots < 1 ||
>> host->pdata->nums_slots > SDMMC_GET_SLOT_NUM())
>>
>> This is correct condition. num_slots can't be higher than number of supported slots.
>> how about?
>
> Seems reasonable.
> I guess you want to come up with a new patch dealing with it? :)
No matter who does this.
If you are ok, i will wait for patch. :)
Best Regards,
Jaehoon Chung
>
>>
>> Best Regards,
>> Jaehoon Chung
>>
>>>
>>> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
>>>
>>> ---
>>>
>>> drivers/mmc/host/dw_mmc.c | 6 ------
>>> 1 file changed, 6 deletions(-)
>>>
>>> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
>>> index 7128351..a116ec6 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");
>>>
>>
>>
>>
>>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-01-22 5:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-21 7:52 [RFC PATCH] mmc: dw_mmc: remove redundant num_slots check Shawn Lin
2016-01-22 2:46 ` Jaehoon Chung
2016-01-22 3:07 ` Shawn Lin
2016-01-22 5:04 ` Jaehoon Chung
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).