[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAAObsKA85fbnt5ENM8_rfpoNV777ySRe=weWYBgy8tLPxu5jZg@mail.gmail.com>
Date: Tue, 22 Sep 2015 08:45:51 +0200
From: Tomeu Vizoso <tomeu.vizoso@...labora.com>
To: Rob Herring <robh@...nel.org>
Cc: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Stephen Warren <swarren@...dotorg.org>,
Javier Martinez Canillas <javier@....samsung.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Mark Brown <broonie@...nel.org>,
Thierry Reding <thierry.reding@...il.com>,
Alan Stern <stern@...land.harvard.edu>,
"Rafael J. Wysocki" <rjw@...ysocki.net>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>,
Dmitry Torokhov <dmitry.torokhov@...il.com>,
"devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
Linus Walleij <linus.walleij@...aro.org>,
"linux-acpi@...r.kernel.org" <linux-acpi@...r.kernel.org>,
Arnd Bergmann <arnd@...db.de>
Subject: Re: [PATCH v6 03/22] of/platform: Point to struct device from device node
On 22 September 2015 at 02:39, Rob Herring <robh@...nel.org> wrote:
> On Mon, Sep 21, 2015 at 9:02 AM, Tomeu Vizoso
> <tomeu.vizoso@...labora.com> wrote:
>> When adding platform and AMBA devices, set the device node's device
>> member to point to it.
>>
>> This speeds lookups considerably and is safe because we only create one
>> of these devices for any given device node.
>>
>> Signed-off-by: Tomeu Vizoso <tomeu.vizoso@...labora.com>
>> ---
>>
>> Changes in v5:
>> - Set the pointer to struct device also for AMBA devices
>> - Unset the pointer to struct device when the platform device is about
>> to be unregistered
>> - Increase the reference count of the device before returning from
>> of_find_device_by_node()
>>
>> drivers/of/platform.c | 19 ++++++++++---------
>> include/linux/of.h | 1 +
>> 2 files changed, 11 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/of/platform.c b/drivers/of/platform.c
>> index 1001efaedcb8..408d89f1d124 100644
>> --- a/drivers/of/platform.c
>> +++ b/drivers/of/platform.c
>> @@ -32,11 +32,6 @@ const struct of_device_id of_default_bus_match_table[] = {
>> {} /* Empty terminated list */
>> };
>>
>> -static int of_dev_node_match(struct device *dev, void *data)
>> -{
>> - return dev->of_node == data;
>> -}
>> -
>> /**
>> * of_find_device_by_node - Find the platform_device associated with a node
>> * @np: Pointer to device tree node
>> @@ -45,10 +40,10 @@ static int of_dev_node_match(struct device *dev, void *data)
>> */
>> struct platform_device *of_find_device_by_node(struct device_node *np)
>> {
>> - struct device *dev;
>> -
>> - dev = bus_find_device(&platform_bus_type, NULL, np, of_dev_node_match);
>> - return dev ? to_platform_device(dev) : NULL;
>> + if (np->device && np->device->bus == &platform_bus_type &&
>> + get_device(np->device))
>
> Where do we drop the reference incremented by get_device?
>
> However, bus_find_device also took a reference I think, so you aren't
> really changing behavior.
Yeah, Intel's 0day build bot warned of the missing get_device() when
running the OF unittests.
Regards,
Tomeu
> Rob
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists