linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c: drivers: Avoid unnecessary check in efm32_i2c_probe()
@ 2020-04-15 14:06 Tang Bin
  2020-04-15 14:31 ` Uwe Kleine-König
  2020-05-22 15:07 ` [PATCH] i2c: drivers: Avoid unnecessary check in efm32_i2c_probe() Wolfram Sang
  0 siblings, 2 replies; 6+ messages in thread
From: Tang Bin @ 2020-04-15 14:06 UTC (permalink / raw)
  To: wsa, o.rempel, u.kleine-koenig, ardb
  Cc: linux-i2c, linux-arm-kernel, linux-kernel, Tang Bin, Shengju Zhang

The function efm32_i2c_probe() is only called with an
openfirmware platform device.Therefore there is no need
to check that it has an openfirmware node.

Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
Signed-off-by: Shengju Zhang <zhangshengju@cmss.chinamobile.com>
---
 drivers/i2c/busses/i2c-efm32.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-efm32.c b/drivers/i2c/busses/i2c-efm32.c
index 4de31fae7..4786ef6b2 100644
--- a/drivers/i2c/busses/i2c-efm32.c
+++ b/drivers/i2c/busses/i2c-efm32.c
@@ -312,9 +312,6 @@ static int efm32_i2c_probe(struct platform_device *pdev)
 	int ret;
 	u32 clkdiv;
 
-	if (!np)
-		return -EINVAL;
-
 	ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL);
 	if (!ddata)
 		return -ENOMEM;
-- 
2.20.1.windows.1




^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] i2c: drivers: Avoid unnecessary check in efm32_i2c_probe()
  2020-04-15 14:06 [PATCH] i2c: drivers: Avoid unnecessary check in efm32_i2c_probe() Tang Bin
@ 2020-04-15 14:31 ` Uwe Kleine-König
  2020-04-16  1:30   ` [PATCH] i2c: drivers: Avoid unnecessary check inefm32_i2c_probe() Tang Bin
  2020-05-22 15:07 ` [PATCH] i2c: drivers: Avoid unnecessary check in efm32_i2c_probe() Wolfram Sang
  1 sibling, 1 reply; 6+ messages in thread
From: Uwe Kleine-König @ 2020-04-15 14:31 UTC (permalink / raw)
  To: Tang Bin
  Cc: wsa, o.rempel, ardb, linux-i2c, linux-arm-kernel, linux-kernel,
	Shengju Zhang

Hello,

On Wed, Apr 15, 2020 at 10:06:40PM +0800, Tang Bin wrote:
> The function efm32_i2c_probe() is only called with an
> openfirmware platform device.Therefore there is no need
> to check that it has an openfirmware node.
> 
> Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
> Signed-off-by: Shengju Zhang <zhangshengju@cmss.chinamobile.com>

Same things apply as in the previous patch. (space after punctuation,
Sob of sender should be last)

> ---
>  drivers/i2c/busses/i2c-efm32.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-efm32.c b/drivers/i2c/busses/i2c-efm32.c
> index 4de31fae7..4786ef6b2 100644
> --- a/drivers/i2c/busses/i2c-efm32.c
> +++ b/drivers/i2c/busses/i2c-efm32.c
> @@ -312,9 +312,6 @@ static int efm32_i2c_probe(struct platform_device *pdev)
>  	int ret;
>  	u32 clkdiv;
>  
> -	if (!np)
> -		return -EINVAL;
> -

I don't care much about this change. While the statement that this
driver is only instantiated on dt platforms is probably right,
explicitly checking for it might still prevent surprises later, serves
as explicit statement for the driver reader that non-dt isn't supposed
to work and given that the check is cheap I tend slightly to just keep
it.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] i2c: drivers: Avoid unnecessary check inefm32_i2c_probe()
  2020-04-15 14:31 ` Uwe Kleine-König
@ 2020-04-16  1:30   ` Tang Bin
  2020-04-16  6:50     ` Uwe Kleine-König
  0 siblings, 1 reply; 6+ messages in thread
From: Tang Bin @ 2020-04-16  1:30 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: wsa, o.rempel, ardb, linux-i2c, linux-arm-kernel, linux-kernel

Hi Uwe:

On 2020/4/15 22:31, Uwe Kleine-König wrote:
> Same things apply as in the previous patch. (space after punctuation,
> Sob of sender should be last)
I will notice this problem next time, thanks.
>> ---
>>   drivers/i2c/busses/i2c-efm32.c | 3 ---
>>   1 file changed, 3 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-efm32.c b/drivers/i2c/busses/i2c-efm32.c
>> index 4de31fae7..4786ef6b2 100644
>> --- a/drivers/i2c/busses/i2c-efm32.c
>> +++ b/drivers/i2c/busses/i2c-efm32.c
>> @@ -312,9 +312,6 @@ static int efm32_i2c_probe(struct platform_device *pdev)
>>   	int ret;
>>   	u32 clkdiv;
>>   
>> -	if (!np)
>> -		return -EINVAL;
>> -
> I don't care much about this change. While the statement that this
> driver is only instantiated on dt platforms is probably right,
> explicitly checking for it might still prevent surprises later, serves
> as explicit statement for the driver reader that non-dt isn't supposed
> to work and given that the check is cheap I tend slightly to just keep
> it.
>
In this driver, the function efm32_i2c_probe() can be triggered only if 
the platform_device and platform_driver matches,  and the matching 
condition is DTS. It's my opinion.

Tnanks,

Tang Bin




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] i2c: drivers: Avoid unnecessary check inefm32_i2c_probe()
  2020-04-16  1:30   ` [PATCH] i2c: drivers: Avoid unnecessary check inefm32_i2c_probe() Tang Bin
@ 2020-04-16  6:50     ` Uwe Kleine-König
  2020-04-16  9:00       ` Tang Bin
  0 siblings, 1 reply; 6+ messages in thread
From: Uwe Kleine-König @ 2020-04-16  6:50 UTC (permalink / raw)
  To: Tang Bin; +Cc: wsa, o.rempel, ardb, linux-i2c, linux-arm-kernel, linux-kernel

On Thu, Apr 16, 2020 at 09:30:22AM +0800, Tang Bin wrote:
> Hi Uwe:
> 
> On 2020/4/15 22:31, Uwe Kleine-König wrote:
> > Same things apply as in the previous patch. (space after punctuation,
> > Sob of sender should be last)
> I will notice this problem next time, thanks.
> > > ---
> > >   drivers/i2c/busses/i2c-efm32.c | 3 ---
> > >   1 file changed, 3 deletions(-)
> > > 
> > > diff --git a/drivers/i2c/busses/i2c-efm32.c b/drivers/i2c/busses/i2c-efm32.c
> > > index 4de31fae7..4786ef6b2 100644
> > > --- a/drivers/i2c/busses/i2c-efm32.c
> > > +++ b/drivers/i2c/busses/i2c-efm32.c
> > > @@ -312,9 +312,6 @@ static int efm32_i2c_probe(struct platform_device *pdev)
> > >   	int ret;
> > >   	u32 clkdiv;
> > > -	if (!np)
> > > -		return -EINVAL;
> > > -
> > I don't care much about this change. While the statement that this
> > driver is only instantiated on dt platforms is probably right,
> > explicitly checking for it might still prevent surprises later, serves
> > as explicit statement for the driver reader that non-dt isn't supposed
> > to work and given that the check is cheap I tend slightly to just keep
> > it.
> > 
> In this driver, the function efm32_i2c_probe() can be triggered only if the
> platform_device and platform_driver matches,  and the matching condition is
> DTS. It's my opinion.

I admit I didn't recheck, but I think the driver will also be matched on
non-dt platforms that provide an "efm32-i2c" device.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] i2c: drivers: Avoid unnecessary check inefm32_i2c_probe()
  2020-04-16  6:50     ` Uwe Kleine-König
@ 2020-04-16  9:00       ` Tang Bin
  0 siblings, 0 replies; 6+ messages in thread
From: Tang Bin @ 2020-04-16  9:00 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: wsa, o.rempel, ardb, linux-i2c, linux-arm-kernel, linux-kernel

Hi Uwe:

On 2020/4/16 14:50, Uwe Kleine-König wrote:
>>>> diff --git a/drivers/i2c/busses/i2c-efm32.c b/drivers/i2c/busses/i2c-efm32.c
>>>> index 4de31fae7..4786ef6b2 100644
>>>> --- a/drivers/i2c/busses/i2c-efm32.c
>>>> +++ b/drivers/i2c/busses/i2c-efm32.c
>>>> @@ -312,9 +312,6 @@ static int efm32_i2c_probe(struct platform_device *pdev)
>>>>    	int ret;
>>>>    	u32 clkdiv;
>>>> -	if (!np)
>>>> -		return -EINVAL;
>>>> -
>>> I don't care much about this change. While the statement that this
>>> driver is only instantiated on dt platforms is probably right,
>>> explicitly checking for it might still prevent surprises later, serves
>>> as explicit statement for the driver reader that non-dt isn't supposed
>>> to work and given that the check is cheap I tend slightly to just keep
>>> it.
>>>
>> In this driver, the function efm32_i2c_probe() can be triggered only if the
>> platform_device and platform_driver matches,  and the matching condition is
>> DTS. It's my opinion.
> I admit I didn't recheck, but I think the driver will also be matched on
> non-dt platforms that provide an "efm32-i2c" device.

Year, I agree with you, the driver should be matched on dt or non-dt 
platforms. But for non-dt platforms, I think this driver may need minor 
changes, after all, it is just suitable for the dt platforms right now. 
That's my shallow opinions.

Thanks for your patient guidance and reply, thank you. I think you are 
also a good teacher, thanks.

Tang Bin

>




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] i2c: drivers: Avoid unnecessary check in efm32_i2c_probe()
  2020-04-15 14:06 [PATCH] i2c: drivers: Avoid unnecessary check in efm32_i2c_probe() Tang Bin
  2020-04-15 14:31 ` Uwe Kleine-König
@ 2020-05-22 15:07 ` Wolfram Sang
  1 sibling, 0 replies; 6+ messages in thread
From: Wolfram Sang @ 2020-05-22 15:07 UTC (permalink / raw)
  To: Tang Bin
  Cc: o.rempel, u.kleine-koenig, ardb, linux-i2c, linux-arm-kernel,
	linux-kernel, Shengju Zhang

[-- Attachment #1: Type: text/plain, Size: 506 bytes --]

On Wed, Apr 15, 2020 at 10:06:40PM +0800, Tang Bin wrote:
> The function efm32_i2c_probe() is only called with an
> openfirmware platform device.Therefore there is no need
> to check that it has an openfirmware node.
> 
> Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
> Signed-off-by: Shengju Zhang <zhangshengju@cmss.chinamobile.com>

Applied to for-next, thanks! I agree the driver will need additions for
non-DT platforms anyhow, so greeting with an OOPS is kinda suitable, too
;)


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-05-22 15:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-15 14:06 [PATCH] i2c: drivers: Avoid unnecessary check in efm32_i2c_probe() Tang Bin
2020-04-15 14:31 ` Uwe Kleine-König
2020-04-16  1:30   ` [PATCH] i2c: drivers: Avoid unnecessary check inefm32_i2c_probe() Tang Bin
2020-04-16  6:50     ` Uwe Kleine-König
2020-04-16  9:00       ` Tang Bin
2020-05-22 15:07 ` [PATCH] i2c: drivers: Avoid unnecessary check in efm32_i2c_probe() Wolfram Sang

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).