[RESEND] mmc: core: try to use an id from the devicetree
diff mbox series

Message ID 20190620152432.1408278-1-lkundrak@v3.sk
State New
Headers show
Series
  • [RESEND] mmc: core: try to use an id from the devicetree
Related show

Commit Message

Lubomir Rintel June 20, 2019, 3:24 p.m. UTC
If there's a mmc* alias in the device tree, take the device number from
it, so that we end up with a device name that matches the alias.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 drivers/mmc/core/host.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Ulf Hansson June 20, 2019, 3:37 p.m. UTC | #1
+ Doug

On Thu, 20 Jun 2019 at 17:24, Lubomir Rintel <lkundrak@v3.sk> wrote:
>
> If there's a mmc* alias in the device tree, take the device number from
> it, so that we end up with a device name that matches the alias.

Lots of people would be happy if I queue something along the lines of
what you propose. I am not really having any big problems with it, but
I am reluctant to queue it because of other peoples quite strong
opinions [1] that have been expressed in regards to this already.

Kind regards
Uffe

[1]
https://www.spinics.net/lists/devicetree-spec/msg00254.html

>
> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
> ---
>  drivers/mmc/core/host.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
> index 6a51f7a06ce7..4733ddb894da 100644
> --- a/drivers/mmc/core/host.c
> +++ b/drivers/mmc/core/host.c
> @@ -411,7 +411,12 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
>         /* scanning will be enabled when we're ready */
>         host->rescan_disable = 1;
>
> -       err = ida_simple_get(&mmc_host_ida, 0, 0, GFP_KERNEL);
> +       /* prefer an alias */
> +       err = of_alias_get_id(dev->of_node, "mmc");
> +       if (err < 0)
> +               err = 0;
> +
> +       err = ida_simple_get(&mmc_host_ida, err, 0, GFP_KERNEL);
>         if (err < 0) {
>                 kfree(host);
>                 return NULL;
> --
> 2.21.0
>
Douglas Anderson June 20, 2019, 9:16 p.m. UTC | #2
Hi,

On Thu, Jun 20, 2019 at 8:37 AM Ulf Hansson <ulf.hansson@linaro.org> wrote:
>
> + Doug
>
> On Thu, 20 Jun 2019 at 17:24, Lubomir Rintel <lkundrak@v3.sk> wrote:
> >
> > If there's a mmc* alias in the device tree, take the device number from
> > it, so that we end up with a device name that matches the alias.
>
> Lots of people would be happy if I queue something along the lines of
> what you propose. I am not really having any big problems with it, but
> I am reluctant to queue it because of other peoples quite strong
> opinions [1] that have been expressed in regards to this already.
>
> Kind regards
> Uffe
>
> [1]
> https://www.spinics.net/lists/devicetree-spec/msg00254.html

Yeah, I personally like being able to assign numbers too, but
unfortunately there are lots of people who objected.  BTW: if you
prefer the patchwork view of the same discussion that Ulf pointed to:

https://lore.kernel.org/patchwork/cover/674381/

As per that discussion, I think might be OK if we could find a way to
assign a string-based name to devices.  Then if your user manual calls
them "emmc", "sd", and "sdio" you could name them that way.  ...and if
your manual calls them "emmc", "sd0", "sd1" you could name them that
way.  ...but I wouldn't swear that people would actually truly like
that.

Given the total number of people who keep feeling like this is an
issue that needs to be solved, though, it does seem worthwhile for
someone to come up with a solution.


-Doug

Patch
diff mbox series

diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 6a51f7a06ce7..4733ddb894da 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -411,7 +411,12 @@  struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
 	/* scanning will be enabled when we're ready */
 	host->rescan_disable = 1;
 
-	err = ida_simple_get(&mmc_host_ida, 0, 0, GFP_KERNEL);
+	/* prefer an alias */
+	err = of_alias_get_id(dev->of_node, "mmc");
+	if (err < 0)
+		err = 0;
+
+	err = ida_simple_get(&mmc_host_ida, err, 0, GFP_KERNEL);
 	if (err < 0) {
 		kfree(host);
 		return NULL;