Linux-OMAP Archive on lore.kernel.org
 help / color / Atom feed
From: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
To: Marek Szyprowski <m.szyprowski@samsung.com>,
	Support Opensource <support.opensource@diasemi.com>,
	Lee Jones <lee.jones@linaro.org>,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
	Tony Lindgren <tony@atomide.com>,
	linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org,
	linux-omap@vger.kernel.org, patches@opensource.cirrus.com
Subject: Re: [PATCH 5/7] mfd: sec: Simplify getting of_device_id match data
Date: Tue, 20 Apr 2021 09:03:06 +0200
Message-ID: <4a5e80c0-653e-a4d6-630e-0d75e3779f6d@canonical.com> (raw)
In-Reply-To: <64fb91ae-c754-fb25-0ef7-17b2f1b8a1e4@samsung.com>

On 20/04/2021 07:25, Marek Szyprowski wrote:
> 
> On 19.04.2021 10:17, Krzysztof Kozlowski wrote:
>> Use of_device_get_match_data() to make the code slightly smaller.
>>
>> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
>> ---
>>   drivers/mfd/sec-core.c | 9 +++------
>>   1 file changed, 3 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c
>> index 8d55992da19e..3126c39f3203 100644
>> --- a/drivers/mfd/sec-core.c
>> +++ b/drivers/mfd/sec-core.c
>> @@ -10,6 +10,7 @@
>>   #include <linux/slab.h>
>>   #include <linux/i2c.h>
>>   #include <linux/of.h>
>> +#include <linux/of_device.h>
>>   #include <linux/of_irq.h>
>>   #include <linux/interrupt.h>
>>   #include <linux/pm_runtime.h>
>> @@ -324,12 +325,8 @@ static inline unsigned long sec_i2c_get_driver_data(struct i2c_client *i2c,
>>   						const struct i2c_device_id *id)
>>   {
>>   #ifdef CONFIG_OF
>> -	if (i2c->dev.of_node) {
>> -		const struct of_device_id *match;
>> -
>> -		match = of_match_node(sec_dt_match, i2c->dev.of_node);
>> -		return (unsigned long)match->data;
>> -	}
>> +	if (i2c->dev.of_node)
>> +		return (unsigned long)of_device_get_match_data(&i2c->dev);
>>   #endif
> 
> Does it make any sense to keep the #ifdef CONFIG_OF after this change?

Good point, it was only to hide usage of of_device_id table.

> I would also skip (i2c->dev.of_node) check, because 
> of_device_get_match_data() already does that (although indirectly).

First, the enum sec_device_type would need to be changed so it starts
from 1, not 0. It's because the value returned by this function is later
assigned to that enum and there is no way currently to differentiate
between NULL and S5M8767X.

Second, it wouldn't make the code smaller;

unsigned long data;
data = of_device_get_match_data(&i2c->dev);
if (data)
	return data;

Best regards,
Krzysztof

  reply index

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-19  8:17 [PATCH 1/7] mfd: max8997: " Krzysztof Kozlowski
2021-04-19  8:17 ` [PATCH 2/7] mfd: max8998: " Krzysztof Kozlowski
2021-04-19  8:17 ` [PATCH 3/7] mfd: da9052: " Krzysztof Kozlowski
2021-04-19 11:00   ` Adam Thomson
2021-04-19  8:17 ` [PATCH 4/7] " Krzysztof Kozlowski
2021-04-19 11:00   ` Adam Thomson
2021-04-19 11:04   ` Krzysztof Kozlowski
2021-04-19  8:17 ` [PATCH 5/7] mfd: sec: " Krzysztof Kozlowski
2021-04-20  5:25   ` Marek Szyprowski
2021-04-20  7:03     ` Krzysztof Kozlowski [this message]
2021-04-20  7:12       ` Marek Szyprowski
2021-04-20  7:25         ` Krzysztof Kozlowski
2021-04-19  8:17 ` [PATCH 6/7] mfd: wm831x: Correct kerneldoc Krzysztof Kozlowski
2021-04-19  8:41   ` Charles Keepax
2021-04-19  8:17 ` [PATCH 7/7] mfd: twl: " Krzysztof Kozlowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4a5e80c0-653e-a4d6-630e-0d75e3779f6d@canonical.com \
    --to=krzysztof.kozlowski@canonical.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=patches@opensource.cirrus.com \
    --cc=support.opensource@diasemi.com \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-OMAP Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-omap/0 linux-omap/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-omap linux-omap/ https://lore.kernel.org/linux-omap \
		linux-omap@vger.kernel.org
	public-inbox-index linux-omap

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-omap


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git