Re: [RFC/PATCH] of: platform: Remove unique device name enforcement

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Wed, May 21, 2014 at 2:43 AM, Grant Likely <grant.likely@xxxxxxxxxxxx> wrote:
> On Wed, 21 May 2014 09:53:57 +0900, Grant Likely <grant.likely@xxxxxxxxxxxx> wrote:
>> On Tue, 20 May 2014 13:30:02 -0500, Rob Herring <robherring2@xxxxxxxxx> wrote:
>> > On Tue, May 20, 2014 at 1:50 AM, Grant Likely <grant.likely@xxxxxxxxxxxx> wrote:

[...]

>> > > Another way to handle it is to only add the suffix when a conflict
>> > > actually occurs. That requires checking first whether or not a name will
>> > > conflict and ammending it only when that happens. I don't know if that
>> > > can be done nicely. I'll take a look.
>> >
>> > That was my idea as well and to move to a local number so you have
>> > something like deviceA, deviceA.1, deviceB, deviceB.1 (maybe the
>> > number is always appended). Perhaps a random number instead so no one
>> > expects the names to be an ABI. ;)
>>
>> Another idea: how about fix the name to alwasy be the final component of
>> the path name, followed by phandle. Anything that doesn't have a phandle
>> can be assigned one at boot. That would guarantee uniqueness without the
>> cost of trying to find duplicates.
>>
>> for example:
>>       uart@10043000:0012
>
> Yet another approach. How about this patch? If the unit address cannot
> be translated, then append the translated name of the parent.

I Ilke this, but...

> diff --git a/drivers/of/platform.c b/drivers/of/platform.c
> index 9c121819e813..e74fccbeb177 100644
> --- a/drivers/of/platform.c
> +++ b/drivers/of/platform.c
> @@ -74,12 +74,9 @@ EXPORT_SYMBOL(of_find_device_by_node);
>   */
>  void of_device_make_bus_id(struct device *dev)
>  {
> -       static atomic_t bus_no_reg_magic;
>         struct device_node *node = dev->of_node;
>         const __be32 *reg;
>         u64 addr;
> -       const __be32 *addrp;
> -       int magic;
>
>  #ifdef CONFIG_PPC_DCR
>         /*
> @@ -101,33 +98,26 @@ void of_device_make_bus_id(struct device *dev)
>         }
>  #endif /* CONFIG_PPC_DCR */
>
> -       /*
> -        * For MMIO, get the physical address
> -        */
> -       reg = of_get_property(node, "reg", NULL);
> -       if (reg) {
> -               if (of_can_translate_address(node)) {
> +       /* Construct the name, using parent nodes if necessary to ensure uniqueness */
> +       while (node->parent) {
> +               /*
> +                * If the address can be translated, then that is as much
> +                * uniqueness as we need. Make it the first component and return
> +                */
> +               reg = of_get_property(node, "reg", NULL);
> +               if (reg && of_can_translate_address(node)) {
>                         addr = of_translate_address(node, reg);

This needs to be rebased on my fix and killing off of of_can_translate_address.

Rob
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux