linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] treewide: simplify getting the adapter of an I2C client, part2
@ 2019-06-10  9:51 Wolfram Sang
  2019-06-10  9:51 ` [PATCH 1/3] hwmon: lm90: simplify getting the adapter of a client Wolfram Sang
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Wolfram Sang @ 2019-06-10  9:51 UTC (permalink / raw)
  To: linux-i2c
  Cc: Peter Rosin, Wolfram Sang, devicetree, linux-hwmon, linux-kernel,
	linux-leds

This is a small follow-up series to a larger cleanup series already
sent:

http://patchwork.ozlabs.org/project/linux-i2c/list/?series=112605
("treewide: simplify getting the adapter of an I2C client")

These drivers use a bit different but still unnecessarily complex way to
determine the adapter of a client. Thanks to Peter Rosin for pointing
them out. They have been fixed manually, no need for a coccinelle script
here. Build tested, too. From the previous cover-letter:

The I2C core populates the parent pointer of a client as:
	client->dev.parent = &client->adapter->dev;

Now take into consideration that
	to_i2c_adapter(&adapter->dev);

is a complicated way of saying 'adapter', then we can even formally
prove that the complicated expression can be simplified by using
client->adapter.

A branch can be found here:

git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/no_to_adapter

Please apply the patches to the individual subsystem trees. There are no
dependencies.

Thanks and kind regards,

   Wolfram

Wolfram Sang (3):
  hwmon: lm90: simplify getting the adapter of a client
  leds: is31fl319x: simplify getting the adapter of a client
  of: unittest: simplify getting the adapter of a client

 drivers/hwmon/lm90.c           | 2 +-
 drivers/leds/leds-is31fl319x.c | 2 +-
 drivers/of/unittest.c          | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

-- 
2.19.1


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

* [PATCH 1/3] hwmon: lm90: simplify getting the adapter of a client
  2019-06-10  9:51 [PATCH 0/3] treewide: simplify getting the adapter of an I2C client, part2 Wolfram Sang
@ 2019-06-10  9:51 ` Wolfram Sang
  2019-06-12 12:41   ` Guenter Roeck
  2019-06-10  9:51 ` [PATCH 2/3] leds: is31fl319x: " Wolfram Sang
  2019-06-10  9:51 ` [PATCH 3/3] of: unittest: " Wolfram Sang
  2 siblings, 1 reply; 7+ messages in thread
From: Wolfram Sang @ 2019-06-10  9:51 UTC (permalink / raw)
  To: linux-i2c
  Cc: Peter Rosin, Wolfram Sang, Jean Delvare, Guenter Roeck,
	linux-hwmon, linux-kernel

We have a dedicated pointer for that, so use it. Much easier to read and
less computation involved.

Reported-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---

Please apply to your subsystem tree.

 drivers/hwmon/lm90.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index e562a578f20e..2ebcab8b0a9b 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -1718,7 +1718,7 @@ static int lm90_probe(struct i2c_client *client,
 		      const struct i2c_device_id *id)
 {
 	struct device *dev = &client->dev;
-	struct i2c_adapter *adapter = to_i2c_adapter(dev->parent);
+	struct i2c_adapter *adapter = client->adapter;
 	struct hwmon_channel_info *info;
 	struct regulator *regulator;
 	struct device *hwmon_dev;
-- 
2.19.1


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

* [PATCH 2/3] leds: is31fl319x: simplify getting the adapter of a client
  2019-06-10  9:51 [PATCH 0/3] treewide: simplify getting the adapter of an I2C client, part2 Wolfram Sang
  2019-06-10  9:51 ` [PATCH 1/3] hwmon: lm90: simplify getting the adapter of a client Wolfram Sang
@ 2019-06-10  9:51 ` Wolfram Sang
  2019-06-10  9:53   ` Pavel Machek
  2019-06-10  9:51 ` [PATCH 3/3] of: unittest: " Wolfram Sang
  2 siblings, 1 reply; 7+ messages in thread
From: Wolfram Sang @ 2019-06-10  9:51 UTC (permalink / raw)
  To: linux-i2c
  Cc: Peter Rosin, Wolfram Sang, Jacek Anaszewski, Pavel Machek,
	Dan Murphy, linux-leds, linux-kernel

We have a dedicated pointer for that, so use it. Much easier to read and
less computation involved.

Reported-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---

Please apply to your subsystem tree.

 drivers/leds/leds-is31fl319x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/leds/leds-is31fl319x.c b/drivers/leds/leds-is31fl319x.c
index f123309597e4..3615ec19085d 100644
--- a/drivers/leds/leds-is31fl319x.c
+++ b/drivers/leds/leds-is31fl319x.c
@@ -337,7 +337,7 @@ static int is31fl319x_probe(struct i2c_client *client,
 {
 	struct is31fl319x_chip *is31;
 	struct device *dev = &client->dev;
-	struct i2c_adapter *adapter = to_i2c_adapter(dev->parent);
+	struct i2c_adapter *adapter = client->adapter;
 	int err;
 	int i = 0;
 	u32 aggregated_led_microamp = IS31FL319X_CURRENT_MAX;
-- 
2.19.1


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

* [PATCH 3/3] of: unittest: simplify getting the adapter of a client
  2019-06-10  9:51 [PATCH 0/3] treewide: simplify getting the adapter of an I2C client, part2 Wolfram Sang
  2019-06-10  9:51 ` [PATCH 1/3] hwmon: lm90: simplify getting the adapter of a client Wolfram Sang
  2019-06-10  9:51 ` [PATCH 2/3] leds: is31fl319x: " Wolfram Sang
@ 2019-06-10  9:51 ` Wolfram Sang
  2019-07-09  2:23   ` Rob Herring
  2 siblings, 1 reply; 7+ messages in thread
From: Wolfram Sang @ 2019-06-10  9:51 UTC (permalink / raw)
  To: linux-i2c
  Cc: Peter Rosin, Wolfram Sang, Rob Herring, Frank Rowand, devicetree,
	linux-kernel

We have a dedicated pointer for that, so use it. Much easier to read and
less computation involved.

Reported-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---

Please apply to your subsystem tree.

 drivers/of/unittest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index 3832a5de4602..e6b175370f2e 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -1946,7 +1946,7 @@ static int unittest_i2c_mux_probe(struct i2c_client *client,
 {
 	int i, nchans;
 	struct device *dev = &client->dev;
-	struct i2c_adapter *adap = to_i2c_adapter(dev->parent);
+	struct i2c_adapter *adap = client->adapter;
 	struct device_node *np = client->dev.of_node, *child;
 	struct i2c_mux_core *muxc;
 	u32 reg, max_reg;
-- 
2.19.1


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

* Re: [PATCH 2/3] leds: is31fl319x: simplify getting the adapter of a client
  2019-06-10  9:51 ` [PATCH 2/3] leds: is31fl319x: " Wolfram Sang
@ 2019-06-10  9:53   ` Pavel Machek
  0 siblings, 0 replies; 7+ messages in thread
From: Pavel Machek @ 2019-06-10  9:53 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-i2c, Peter Rosin, Jacek Anaszewski, Dan Murphy, linux-leds,
	linux-kernel

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

On Mon 2019-06-10 11:51:55, Wolfram Sang wrote:
> We have a dedicated pointer for that, so use it. Much easier to read and
> less computation involved.
> 
> Reported-by: Peter Rosin <peda@axentia.se>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
> 
> Please apply to your subsystem tree.

Acked-by: Pavel Machek <pavel@ucw.cz>

									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

* Re: [PATCH 1/3] hwmon: lm90: simplify getting the adapter of a client
  2019-06-10  9:51 ` [PATCH 1/3] hwmon: lm90: simplify getting the adapter of a client Wolfram Sang
@ 2019-06-12 12:41   ` Guenter Roeck
  0 siblings, 0 replies; 7+ messages in thread
From: Guenter Roeck @ 2019-06-12 12:41 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-i2c, Peter Rosin, Jean Delvare, linux-hwmon, linux-kernel

On Mon, Jun 10, 2019 at 11:51:54AM +0200, Wolfram Sang wrote:
> We have a dedicated pointer for that, so use it. Much easier to read and
> less computation involved.
> 
> Reported-by: Peter Rosin <peda@axentia.se>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Aplied.

Thanks,
Guenter

> ---
> 
> Please apply to your subsystem tree.
> 
>  drivers/hwmon/lm90.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
> index e562a578f20e..2ebcab8b0a9b 100644
> --- a/drivers/hwmon/lm90.c
> +++ b/drivers/hwmon/lm90.c
> @@ -1718,7 +1718,7 @@ static int lm90_probe(struct i2c_client *client,
>  		      const struct i2c_device_id *id)
>  {
>  	struct device *dev = &client->dev;
> -	struct i2c_adapter *adapter = to_i2c_adapter(dev->parent);
> +	struct i2c_adapter *adapter = client->adapter;
>  	struct hwmon_channel_info *info;
>  	struct regulator *regulator;
>  	struct device *hwmon_dev;

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

* Re: [PATCH 3/3] of: unittest: simplify getting the adapter of a client
  2019-06-10  9:51 ` [PATCH 3/3] of: unittest: " Wolfram Sang
@ 2019-07-09  2:23   ` Rob Herring
  0 siblings, 0 replies; 7+ messages in thread
From: Rob Herring @ 2019-07-09  2:23 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-i2c, Peter Rosin, Wolfram Sang, Frank Rowand, devicetree,
	linux-kernel

On Mon, 10 Jun 2019 11:51:56 +0200, Wolfram Sang wrote:
> We have a dedicated pointer for that, so use it. Much easier to read and
> less computation involved.
> 
> Reported-by: Peter Rosin <peda@axentia.se>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
> 
> Please apply to your subsystem tree.
> 
>  drivers/of/unittest.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

Applied, thanks.

Rob

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

end of thread, other threads:[~2019-07-09  2:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-10  9:51 [PATCH 0/3] treewide: simplify getting the adapter of an I2C client, part2 Wolfram Sang
2019-06-10  9:51 ` [PATCH 1/3] hwmon: lm90: simplify getting the adapter of a client Wolfram Sang
2019-06-12 12:41   ` Guenter Roeck
2019-06-10  9:51 ` [PATCH 2/3] leds: is31fl319x: " Wolfram Sang
2019-06-10  9:53   ` Pavel Machek
2019-06-10  9:51 ` [PATCH 3/3] of: unittest: " Wolfram Sang
2019-07-09  2:23   ` Rob Herring

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