linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] i2c: remove deprecated attach_adapter callback
@ 2018-08-21 15:02 Wolfram Sang
  2018-08-21 15:02 ` [PATCH 1/2] macintosh: therm_windtunnel: drop using attach_adapter Wolfram Sang
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Wolfram Sang @ 2018-08-21 15:02 UTC (permalink / raw)
  To: linux-i2c
  Cc: linuxppc-dev, Benjamin Herrenschmidt, Michael Ellerman,
	linux-kernel, Wolfram Sang

So, I wanted to do this in the next cycle, but Linus seems to want it this
cycle already [1], so here it is:

Remove the attach_adapter callback from the 2.4 times by converting
the last user to a custom probing mechanism based on deferred probing. We used
this already in commit ac397c80de89 ("ALSA: ppc: keywest: drop using attach
adapter") successfully on HW, so we agreed to use it on the windtunnel driver
as well.

With the last user gone, we can then remove the callback \o/ I think this
allows for more cleanup in the core, but let's do this later and focus on the
removal for now.

Tested on a Renesas R-Car Salvator-XS board (M3N) by using and rebinding
various I2C busses. Build bot and checkpatch are happy, too.

I'd like to send a pull request to Linus this merge window, so looking forward
to super fast comments, acks, etc...

Thanks,

   Wolfram

[1] http://patchwork.ozlabs.org/patch/959322/#1976742

Wolfram Sang (2):
  macintosh: therm_windtunnel: drop using attach_adapter
  i2c: remove deprecated attach_adapter callback

 drivers/i2c/i2c-core-base.c          | 11 +----------
 drivers/macintosh/therm_windtunnel.c | 25 +++++++++++++++++++++++--
 include/linux/i2c.h                  |  6 ------
 3 files changed, 24 insertions(+), 18 deletions(-)

-- 
2.11.0


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

* [PATCH 1/2] macintosh: therm_windtunnel: drop using attach_adapter
  2018-08-21 15:02 [PATCH 0/2] i2c: remove deprecated attach_adapter callback Wolfram Sang
@ 2018-08-21 15:02 ` Wolfram Sang
  2018-08-23  3:31   ` Michael Ellerman
  2018-08-24 12:47   ` Wolfram Sang
  2018-08-21 15:02 ` [PATCH 2/2] i2c: remove deprecated attach_adapter callback Wolfram Sang
  2018-08-23  3:30 ` [PATCH 0/2] " Michael Ellerman
  2 siblings, 2 replies; 7+ messages in thread
From: Wolfram Sang @ 2018-08-21 15:02 UTC (permalink / raw)
  To: linux-i2c
  Cc: linuxppc-dev, Benjamin Herrenschmidt, Michael Ellerman,
	linux-kernel, Wolfram Sang

As we now have deferred probing, we can use a custom mechanism and
finally get rid of the legacy interface from the i2c core.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
---
 drivers/macintosh/therm_windtunnel.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c
index 68dcbcb4fc5b..8c744578122a 100644
--- a/drivers/macintosh/therm_windtunnel.c
+++ b/drivers/macintosh/therm_windtunnel.c
@@ -432,7 +432,6 @@ static struct i2c_driver g4fan_driver = {
 	.driver = {
 		.name	= "therm_windtunnel",
 	},
-	.attach_adapter = do_attach,
 	.probe		= do_probe,
 	.remove		= do_remove,
 	.id_table	= therm_windtunnel_id,
@@ -445,7 +444,29 @@ static struct i2c_driver g4fan_driver = {
 
 static int therm_of_probe(struct platform_device *dev)
 {
-	return i2c_add_driver( &g4fan_driver );
+	struct i2c_adapter *adap;
+	int ret, i = 0;
+
+	adap = i2c_get_adapter(0);
+	if (!adap)
+		return -EPROBE_DEFER;
+
+	ret = i2c_add_driver(&g4fan_driver);
+	if (ret) {
+		i2c_put_adapter(adap);
+		return ret;
+	}
+
+	/* We assume Macs have consecutive I2C bus numbers starting at 0 */
+	while (adap) {
+		do_attach(adap);
+		if (x.running)
+			return 0;
+		i2c_put_adapter(adap);
+		adap = i2c_get_adapter(++i);
+	}
+
+	return -ENODEV;
 }
 
 static int
-- 
2.11.0


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

* [PATCH 2/2] i2c: remove deprecated attach_adapter callback
  2018-08-21 15:02 [PATCH 0/2] i2c: remove deprecated attach_adapter callback Wolfram Sang
  2018-08-21 15:02 ` [PATCH 1/2] macintosh: therm_windtunnel: drop using attach_adapter Wolfram Sang
@ 2018-08-21 15:02 ` Wolfram Sang
  2018-08-24 12:47   ` Wolfram Sang
  2018-08-23  3:30 ` [PATCH 0/2] " Michael Ellerman
  2 siblings, 1 reply; 7+ messages in thread
From: Wolfram Sang @ 2018-08-21 15:02 UTC (permalink / raw)
  To: linux-i2c
  Cc: linuxppc-dev, Benjamin Herrenschmidt, Michael Ellerman,
	linux-kernel, Wolfram Sang

There aren't any users left. Remove this callback from the 2.4 times.
Phew, finally, that took years to reach...

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
---
 drivers/i2c/i2c-core-base.c | 11 +----------
 include/linux/i2c.h         |  6 ------
 2 files changed, 1 insertion(+), 16 deletions(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 5a937109a289..f15737763608 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -62,7 +62,7 @@
 
 /*
  * core_lock protects i2c_adapter_idr, and guarantees that device detection,
- * deletion of detected devices, and attach_adapter calls are serialized
+ * deletion of detected devices are serialized
  */
 static DEFINE_MUTEX(core_lock);
 static DEFINE_IDR(i2c_adapter_idr);
@@ -1124,15 +1124,6 @@ static int i2c_do_add_adapter(struct i2c_driver *driver,
 	/* Detect supported devices on that bus, and instantiate them */
 	i2c_detect(adap, driver);
 
-	/* Let legacy drivers scan this bus for matching devices */
-	if (driver->attach_adapter) {
-		dev_warn(&adap->dev, "%s: attach_adapter method is deprecated\n",
-			 driver->driver.name);
-		dev_warn(&adap->dev,
-			 "Please use another way to instantiate your i2c_client\n");
-		/* We ignore the return code; if it fails, too bad */
-		driver->attach_adapter(adap);
-	}
 	return 0;
 }
 
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 36f357ecdf67..b79387fd57da 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -231,7 +231,6 @@ enum i2c_alert_protocol {
 /**
  * struct i2c_driver - represent an I2C device driver
  * @class: What kind of i2c device we instantiate (for detect)
- * @attach_adapter: Callback for bus addition (deprecated)
  * @probe: Callback for device binding - soon to be deprecated
  * @probe_new: New callback for device binding
  * @remove: Callback for device unbinding
@@ -268,11 +267,6 @@ enum i2c_alert_protocol {
 struct i2c_driver {
 	unsigned int class;
 
-	/* Notifies the driver that a new bus has appeared. You should avoid
-	 * using this, it will be removed in a near future.
-	 */
-	int (*attach_adapter)(struct i2c_adapter *) __deprecated;
-
 	/* Standard driver model interfaces */
 	int (*probe)(struct i2c_client *, const struct i2c_device_id *);
 	int (*remove)(struct i2c_client *);
-- 
2.11.0


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

* Re: [PATCH 0/2] i2c: remove deprecated attach_adapter callback
  2018-08-21 15:02 [PATCH 0/2] i2c: remove deprecated attach_adapter callback Wolfram Sang
  2018-08-21 15:02 ` [PATCH 1/2] macintosh: therm_windtunnel: drop using attach_adapter Wolfram Sang
  2018-08-21 15:02 ` [PATCH 2/2] i2c: remove deprecated attach_adapter callback Wolfram Sang
@ 2018-08-23  3:30 ` Michael Ellerman
  2 siblings, 0 replies; 7+ messages in thread
From: Michael Ellerman @ 2018-08-23  3:30 UTC (permalink / raw)
  To: Wolfram Sang, linux-i2c
  Cc: linuxppc-dev, Benjamin Herrenschmidt, linux-kernel, Wolfram Sang

Wolfram Sang <wsa@the-dreams.de> writes:

> So, I wanted to do this in the next cycle, but Linus seems to want it this
> cycle already [1], so here it is:
>
> Remove the attach_adapter callback from the 2.4 times by converting
> the last user to a custom probing mechanism based on deferred probing. We used
> this already in commit ac397c80de89 ("ALSA: ppc: keywest: drop using attach
> adapter") successfully on HW, so we agreed to use it on the windtunnel driver
> as well.
>
> With the last user gone, we can then remove the callback \o/ I think this
> allows for more cleanup in the core, but let's do this later and focus on the
> removal for now.
>
> Tested on a Renesas R-Car Salvator-XS board (M3N) by using and rebinding
> various I2C busses. Build bot and checkpatch are happy, too.
>
> I'd like to send a pull request to Linus this merge window, so looking forward
> to super fast comments, acks, etc...

Sure, I don't have a G4 hooked up to test this, so just merge it and if
it breaks we can fix it.

cheers

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

* Re: [PATCH 1/2] macintosh: therm_windtunnel: drop using attach_adapter
  2018-08-21 15:02 ` [PATCH 1/2] macintosh: therm_windtunnel: drop using attach_adapter Wolfram Sang
@ 2018-08-23  3:31   ` Michael Ellerman
  2018-08-24 12:47   ` Wolfram Sang
  1 sibling, 0 replies; 7+ messages in thread
From: Michael Ellerman @ 2018-08-23  3:31 UTC (permalink / raw)
  To: Wolfram Sang, linux-i2c
  Cc: linuxppc-dev, Benjamin Herrenschmidt, linux-kernel, Wolfram Sang

Wolfram Sang <wsa@the-dreams.de> writes:

> As we now have deferred probing, we can use a custom mechanism and
> finally get rid of the legacy interface from the i2c core.
>
> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
> ---
>  drivers/macintosh/therm_windtunnel.c | 25 +++++++++++++++++++++++--
>  1 file changed, 23 insertions(+), 2 deletions(-)

I don't have a G4 to test this on, so merge it and if it breaks we can
fix it up later.

Acked-by: Michael Ellerman <mpe@ellerman.id.au>

cheers

> diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c
> index 68dcbcb4fc5b..8c744578122a 100644
> --- a/drivers/macintosh/therm_windtunnel.c
> +++ b/drivers/macintosh/therm_windtunnel.c
> @@ -432,7 +432,6 @@ static struct i2c_driver g4fan_driver = {
>  	.driver = {
>  		.name	= "therm_windtunnel",
>  	},
> -	.attach_adapter = do_attach,
>  	.probe		= do_probe,
>  	.remove		= do_remove,
>  	.id_table	= therm_windtunnel_id,
> @@ -445,7 +444,29 @@ static struct i2c_driver g4fan_driver = {
>  
>  static int therm_of_probe(struct platform_device *dev)
>  {
> -	return i2c_add_driver( &g4fan_driver );
> +	struct i2c_adapter *adap;
> +	int ret, i = 0;
> +
> +	adap = i2c_get_adapter(0);
> +	if (!adap)
> +		return -EPROBE_DEFER;
> +
> +	ret = i2c_add_driver(&g4fan_driver);
> +	if (ret) {
> +		i2c_put_adapter(adap);
> +		return ret;
> +	}
> +
> +	/* We assume Macs have consecutive I2C bus numbers starting at 0 */
> +	while (adap) {
> +		do_attach(adap);
> +		if (x.running)
> +			return 0;
> +		i2c_put_adapter(adap);
> +		adap = i2c_get_adapter(++i);
> +	}
> +
> +	return -ENODEV;
>  }
>  
>  static int
> -- 
> 2.11.0

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

* Re: [PATCH 1/2] macintosh: therm_windtunnel: drop using attach_adapter
  2018-08-21 15:02 ` [PATCH 1/2] macintosh: therm_windtunnel: drop using attach_adapter Wolfram Sang
  2018-08-23  3:31   ` Michael Ellerman
@ 2018-08-24 12:47   ` Wolfram Sang
  1 sibling, 0 replies; 7+ messages in thread
From: Wolfram Sang @ 2018-08-24 12:47 UTC (permalink / raw)
  To: linux-i2c
  Cc: linuxppc-dev, Benjamin Herrenschmidt, Michael Ellerman, linux-kernel

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

On Tue, Aug 21, 2018 at 05:02:39PM +0200, Wolfram Sang wrote:
> As we now have deferred probing, we can use a custom mechanism and
> finally get rid of the legacy interface from the i2c core.
> 
> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>

Applied to for-next, thanks!


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

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

* Re: [PATCH 2/2] i2c: remove deprecated attach_adapter callback
  2018-08-21 15:02 ` [PATCH 2/2] i2c: remove deprecated attach_adapter callback Wolfram Sang
@ 2018-08-24 12:47   ` Wolfram Sang
  0 siblings, 0 replies; 7+ messages in thread
From: Wolfram Sang @ 2018-08-24 12:47 UTC (permalink / raw)
  To: linux-i2c
  Cc: linuxppc-dev, Benjamin Herrenschmidt, Michael Ellerman, linux-kernel

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

On Tue, Aug 21, 2018 at 05:02:40PM +0200, Wolfram Sang wrote:
> There aren't any users left. Remove this callback from the 2.4 times.
> Phew, finally, that took years to reach...
> 
> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>

Applied to for-next, thanks!


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

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

end of thread, other threads:[~2018-08-24 12:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-21 15:02 [PATCH 0/2] i2c: remove deprecated attach_adapter callback Wolfram Sang
2018-08-21 15:02 ` [PATCH 1/2] macintosh: therm_windtunnel: drop using attach_adapter Wolfram Sang
2018-08-23  3:31   ` Michael Ellerman
2018-08-24 12:47   ` Wolfram Sang
2018-08-21 15:02 ` [PATCH 2/2] i2c: remove deprecated attach_adapter callback Wolfram Sang
2018-08-24 12:47   ` Wolfram Sang
2018-08-23  3:30 ` [PATCH 0/2] " Michael Ellerman

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