public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] sdio: Use bus type function for shutdown
@ 2026-01-12 15:46 Uwe Kleine-König
  2026-01-12 15:46 ` [PATCH v2 1/3] sdio: Provide a bustype shutdown function Uwe Kleine-König
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Uwe Kleine-König @ 2026-01-12 15:46 UTC (permalink / raw)
  To: Ulf Hansson, Ping-Ke Shih, Johannes Berg; +Cc: linux-wireless, linux-mmc

Hello,

this series is part of an effort to get rid of the .shutdown() callback
(and .probe() and .remove()) in struct device_driver. Preparing that,
all sdio drivers that up to now use this callback are converted to a new
sdio specific shutdown callback.

v1 is available at https://lore.kernel.org/all/cover.1765968841.git.ukleinek@kernel.org.

Changes since v1:
 - Drop patch 2/4 which resulted in a build failure with CONFIG_PM=n

Patches #2 and #3 depend on the first patch, and with just the first
patch applied there is a runtime warning (emitted by the driver core in
driver_register()) for each unconverted driver. So it would be nice to
get the whole series in during a single merge window to not let users
face the warning.

Given that all drivers are in drivers/net/wireless I suggest to apply
the whole series via the wireless tree.

Best regards
Uwe

Uwe Kleine-König (3):
  sdio: Provide a bustype shutdown function
  wifi: rsi: sdio: Migrate to use sdio specific shutdown function
  wifi: rtw88: sdio: Migrate to use sdio specific shutdown function

 drivers/mmc/core/sdio_bus.c                   | 25 +++++++++++++++++++
 .../net/wireless/realtek/rtw88/rtw8723cs.c    |  2 +-
 .../net/wireless/realtek/rtw88/rtw8723ds.c    |  2 +-
 .../net/wireless/realtek/rtw88/rtw8821cs.c    |  2 +-
 .../net/wireless/realtek/rtw88/rtw8822bs.c    |  2 +-
 .../net/wireless/realtek/rtw88/rtw8822cs.c    |  2 +-
 drivers/net/wireless/realtek/rtw88/sdio.c     |  3 +--
 drivers/net/wireless/realtek/rtw88/sdio.h     |  2 +-
 drivers/net/wireless/rsi/rsi_91x_sdio.c       |  5 ++--
 include/linux/mmc/sdio_func.h                 |  1 +
 10 files changed, 35 insertions(+), 11 deletions(-)

base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
-- 
2.47.3

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

* [PATCH v2 1/3] sdio: Provide a bustype shutdown function
  2026-01-12 15:46 [PATCH v2 0/3] sdio: Use bus type function for shutdown Uwe Kleine-König
@ 2026-01-12 15:46 ` Uwe Kleine-König
  2026-01-15  1:26   ` Shawn Lin
                     ` (3 more replies)
  2026-01-12 15:46 ` [PATCH v2 2/3] wifi: rsi: sdio: Migrate to use sdio specific " Uwe Kleine-König
                   ` (2 subsequent siblings)
  3 siblings, 4 replies; 15+ messages in thread
From: Uwe Kleine-König @ 2026-01-12 15:46 UTC (permalink / raw)
  To: Ulf Hansson, Ping-Ke Shih, Johannes Berg; +Cc: linux-wireless, linux-mmc

To prepare sdio drivers to migrate away from struct device_driver::shutdown
(and then eventually remove that callback) create a serdev driver shutdown
callback and migration code to keep the existing behaviour. Note this
introduces a warning for each driver that isn't converted yet to that
callback at register time.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
---
 drivers/mmc/core/sdio_bus.c   | 25 +++++++++++++++++++++++++
 include/linux/mmc/sdio_func.h |  1 +
 2 files changed, 26 insertions(+)

diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c
index 10799772494a..6e5bdc2f0cc8 100644
--- a/drivers/mmc/core/sdio_bus.c
+++ b/drivers/mmc/core/sdio_bus.c
@@ -232,6 +232,15 @@ static void sdio_bus_remove(struct device *dev)
 		pm_runtime_put_sync(dev);
 }
 
+static void sdio_bus_shutdown(struct device *dev)
+{
+	struct sdio_driver *drv = to_sdio_driver(dev->driver);
+	struct sdio_func *func = dev_to_sdio_func(dev);
+
+	if (dev->driver && drv->shutdown)
+		drv->shutdown(func);
+}
+
 static const struct dev_pm_ops sdio_bus_pm_ops = {
 	SET_SYSTEM_SLEEP_PM_OPS(pm_generic_suspend, pm_generic_resume)
 	SET_RUNTIME_PM_OPS(
@@ -248,6 +257,7 @@ static const struct bus_type sdio_bus_type = {
 	.uevent		= sdio_bus_uevent,
 	.probe		= sdio_bus_probe,
 	.remove		= sdio_bus_remove,
+	.shutdown	= sdio_bus_shutdown,
 	.pm		= &sdio_bus_pm_ops,
 };
 
@@ -261,6 +271,14 @@ void sdio_unregister_bus(void)
 	bus_unregister(&sdio_bus_type);
 }
 
+static void sdio_legacy_shutdown(struct sdio_func *func)
+{
+	struct device *dev = &func->dev;
+	struct device_driver *driver = dev->driver;
+
+	driver->shutdown(dev);
+}
+
 /**
  *	__sdio_register_driver - register a function driver
  *	@drv: SDIO function driver
@@ -272,6 +290,13 @@ int __sdio_register_driver(struct sdio_driver *drv, struct module *owner)
 	drv->drv.bus = &sdio_bus_type;
 	drv->drv.owner = owner;
 
+	/*
+	 * This driver needs updating. Note that driver_register() warns about
+	 * this, so we're not adding another warning here.
+	 */
+	if (!drv->shutdown && drv->drv.shutdown)
+		drv->shutdown = sdio_legacy_shutdown;
+
 	return driver_register(&drv->drv);
 }
 EXPORT_SYMBOL_GPL(__sdio_register_driver);
diff --git a/include/linux/mmc/sdio_func.h b/include/linux/mmc/sdio_func.h
index fed1f5f4a8d3..4534bf462aac 100644
--- a/include/linux/mmc/sdio_func.h
+++ b/include/linux/mmc/sdio_func.h
@@ -78,6 +78,7 @@ struct sdio_driver {
 
 	int (*probe)(struct sdio_func *, const struct sdio_device_id *);
 	void (*remove)(struct sdio_func *);
+	void (*shutdown)(struct sdio_func *);
 
 	struct device_driver drv;
 };
-- 
2.47.3


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

* [PATCH v2 2/3] wifi: rsi: sdio: Migrate to use sdio specific shutdown function
  2026-01-12 15:46 [PATCH v2 0/3] sdio: Use bus type function for shutdown Uwe Kleine-König
  2026-01-12 15:46 ` [PATCH v2 1/3] sdio: Provide a bustype shutdown function Uwe Kleine-König
@ 2026-01-12 15:46 ` Uwe Kleine-König
  2026-01-12 15:46 ` [PATCH v2 3/3] wifi: rtw88: " Uwe Kleine-König
  2026-01-12 15:51 ` [PATCH v2 0/3] sdio: Use bus type function for shutdown Johannes Berg
  3 siblings, 0 replies; 15+ messages in thread
From: Uwe Kleine-König @ 2026-01-12 15:46 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless

This saves a cast in the driver. The motivation is stop using the callback
.shutdown in rsi_driver.drv to make it possible to drop that.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
---
 drivers/net/wireless/rsi/rsi_91x_sdio.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/rsi/rsi_91x_sdio.c b/drivers/net/wireless/rsi/rsi_91x_sdio.c
index 1e578533e473..ee7ad81c858d 100644
--- a/drivers/net/wireless/rsi/rsi_91x_sdio.c
+++ b/drivers/net/wireless/rsi/rsi_91x_sdio.c
@@ -1443,9 +1443,8 @@ static int rsi_thaw(struct device *dev)
 	return 0;
 }
 
-static void rsi_shutdown(struct device *dev)
+static void rsi_shutdown(struct sdio_func *pfunction)
 {
-	struct sdio_func *pfunction = dev_to_sdio_func(dev);
 	struct rsi_hw *adapter = sdio_get_drvdata(pfunction);
 	struct rsi_91x_sdiodev *sdev = adapter->rsi_dev;
 	struct ieee80211_hw *hw = adapter->hw;
@@ -1513,9 +1512,9 @@ static struct sdio_driver rsi_driver = {
 	.remove     = rsi_disconnect,
 	.id_table   = rsi_dev_table,
 #ifdef CONFIG_PM
+	.shutdown   = rsi_shutdown,
 	.drv = {
 		.pm = &rsi_pm_ops,
-		.shutdown   = rsi_shutdown,
 	}
 #endif
 };
-- 
2.47.3


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

* [PATCH v2 3/3] wifi: rtw88: sdio: Migrate to use sdio specific shutdown function
  2026-01-12 15:46 [PATCH v2 0/3] sdio: Use bus type function for shutdown Uwe Kleine-König
  2026-01-12 15:46 ` [PATCH v2 1/3] sdio: Provide a bustype shutdown function Uwe Kleine-König
  2026-01-12 15:46 ` [PATCH v2 2/3] wifi: rsi: sdio: Migrate to use sdio specific " Uwe Kleine-König
@ 2026-01-12 15:46 ` Uwe Kleine-König
  2026-01-13  0:29   ` Ping-Ke Shih
  2026-01-12 15:51 ` [PATCH v2 0/3] sdio: Use bus type function for shutdown Johannes Berg
  3 siblings, 1 reply; 15+ messages in thread
From: Uwe Kleine-König @ 2026-01-12 15:46 UTC (permalink / raw)
  To: Ping-Ke Shih, Johannes Berg; +Cc: linux-wireless

This saves a cast in the driver. The motivation is stop using the callback
.shutdown in rsi_driver.drv to make it possible to drop that.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
---
 drivers/net/wireless/realtek/rtw88/rtw8723cs.c | 2 +-
 drivers/net/wireless/realtek/rtw88/rtw8723ds.c | 2 +-
 drivers/net/wireless/realtek/rtw88/rtw8821cs.c | 2 +-
 drivers/net/wireless/realtek/rtw88/rtw8822bs.c | 2 +-
 drivers/net/wireless/realtek/rtw88/rtw8822cs.c | 2 +-
 drivers/net/wireless/realtek/rtw88/sdio.c      | 3 +--
 drivers/net/wireless/realtek/rtw88/sdio.h      | 2 +-
 7 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw88/rtw8723cs.c b/drivers/net/wireless/realtek/rtw88/rtw8723cs.c
index 1f98d35a8dd1..2018c9d76dd1 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8723cs.c
+++ b/drivers/net/wireless/realtek/rtw88/rtw8723cs.c
@@ -23,9 +23,9 @@ static struct sdio_driver rtw_8723cs_driver = {
 	.id_table = rtw_8723cs_id_table,
 	.probe = rtw_sdio_probe,
 	.remove = rtw_sdio_remove,
+	.shutdown = rtw_sdio_shutdown,
 	.drv = {
 		.pm = &rtw_sdio_pm_ops,
-		.shutdown = rtw_sdio_shutdown
 	}};
 module_sdio_driver(rtw_8723cs_driver);
 
diff --git a/drivers/net/wireless/realtek/rtw88/rtw8723ds.c b/drivers/net/wireless/realtek/rtw88/rtw8723ds.c
index 206b77e5b98e..e38c90b769a2 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8723ds.c
+++ b/drivers/net/wireless/realtek/rtw88/rtw8723ds.c
@@ -28,10 +28,10 @@ static struct sdio_driver rtw_8723ds_driver = {
 	.name = KBUILD_MODNAME,
 	.probe = rtw_sdio_probe,
 	.remove = rtw_sdio_remove,
+	.shutdown = rtw_sdio_shutdown,
 	.id_table = rtw_8723ds_id_table,
 	.drv = {
 		.pm = &rtw_sdio_pm_ops,
-		.shutdown = rtw_sdio_shutdown,
 	}
 };
 module_sdio_driver(rtw_8723ds_driver);
diff --git a/drivers/net/wireless/realtek/rtw88/rtw8821cs.c b/drivers/net/wireless/realtek/rtw88/rtw8821cs.c
index 6d94162213c6..58e0ef219cdc 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8821cs.c
+++ b/drivers/net/wireless/realtek/rtw88/rtw8821cs.c
@@ -23,10 +23,10 @@ static struct sdio_driver rtw_8821cs_driver = {
 	.name = KBUILD_MODNAME,
 	.probe = rtw_sdio_probe,
 	.remove = rtw_sdio_remove,
+	.shutdown = rtw_sdio_shutdown,
 	.id_table = rtw_8821cs_id_table,
 	.drv = {
 		.pm = &rtw_sdio_pm_ops,
-		.shutdown = rtw_sdio_shutdown,
 	}
 };
 module_sdio_driver(rtw_8821cs_driver);
diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822bs.c b/drivers/net/wireless/realtek/rtw88/rtw8822bs.c
index 744781dcb419..2de9b11540c5 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8822bs.c
+++ b/drivers/net/wireless/realtek/rtw88/rtw8822bs.c
@@ -23,10 +23,10 @@ static struct sdio_driver rtw_8822bs_driver = {
 	.name = KBUILD_MODNAME,
 	.probe = rtw_sdio_probe,
 	.remove = rtw_sdio_remove,
+	.shutdown = rtw_sdio_shutdown,
 	.id_table = rtw_8822bs_id_table,
 	.drv = {
 		.pm = &rtw_sdio_pm_ops,
-		.shutdown = rtw_sdio_shutdown,
 	}
 };
 module_sdio_driver(rtw_8822bs_driver);
diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822cs.c b/drivers/net/wireless/realtek/rtw88/rtw8822cs.c
index 322281e07eb8..b00ef4173962 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8822cs.c
+++ b/drivers/net/wireless/realtek/rtw88/rtw8822cs.c
@@ -23,10 +23,10 @@ static struct sdio_driver rtw_8822cs_driver = {
 	.name = KBUILD_MODNAME,
 	.probe = rtw_sdio_probe,
 	.remove = rtw_sdio_remove,
+	.shutdown = rtw_sdio_shutdown,
 	.id_table = rtw_8822cs_id_table,
 	.drv = {
 		.pm = &rtw_sdio_pm_ops,
-		.shutdown = rtw_sdio_shutdown,
 	}
 };
 module_sdio_driver(rtw_8822cs_driver);
diff --git a/drivers/net/wireless/realtek/rtw88/sdio.c b/drivers/net/wireless/realtek/rtw88/sdio.c
index 99d7c629eac6..ebd7636e2408 100644
--- a/drivers/net/wireless/realtek/rtw88/sdio.c
+++ b/drivers/net/wireless/realtek/rtw88/sdio.c
@@ -1412,9 +1412,8 @@ void rtw_sdio_remove(struct sdio_func *sdio_func)
 }
 EXPORT_SYMBOL(rtw_sdio_remove);
 
-void rtw_sdio_shutdown(struct device *dev)
+void rtw_sdio_shutdown(struct sdio_func *sdio_func)
 {
-	struct sdio_func *sdio_func = dev_to_sdio_func(dev);
 	const struct rtw_chip_info *chip;
 	struct ieee80211_hw *hw;
 	struct rtw_dev *rtwdev;
diff --git a/drivers/net/wireless/realtek/rtw88/sdio.h b/drivers/net/wireless/realtek/rtw88/sdio.h
index 3c659ed180f0..457e8b02380e 100644
--- a/drivers/net/wireless/realtek/rtw88/sdio.h
+++ b/drivers/net/wireless/realtek/rtw88/sdio.h
@@ -166,7 +166,7 @@ extern const struct dev_pm_ops rtw_sdio_pm_ops;
 int rtw_sdio_probe(struct sdio_func *sdio_func,
 		   const struct sdio_device_id *id);
 void rtw_sdio_remove(struct sdio_func *sdio_func);
-void rtw_sdio_shutdown(struct device *dev);
+void rtw_sdio_shutdown(struct sdio_func *sdio_func);
 
 static inline bool rtw_sdio_is_sdio30_supported(struct rtw_dev *rtwdev)
 {
-- 
2.47.3


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

* Re: [PATCH v2 0/3] sdio: Use bus type function for shutdown
  2026-01-12 15:46 [PATCH v2 0/3] sdio: Use bus type function for shutdown Uwe Kleine-König
                   ` (2 preceding siblings ...)
  2026-01-12 15:46 ` [PATCH v2 3/3] wifi: rtw88: " Uwe Kleine-König
@ 2026-01-12 15:51 ` Johannes Berg
  2026-01-13  0:31   ` Ping-Ke Shih
  3 siblings, 1 reply; 15+ messages in thread
From: Johannes Berg @ 2026-01-12 15:51 UTC (permalink / raw)
  To: Uwe Kleine-König, Ulf Hansson, Ping-Ke Shih
  Cc: linux-wireless, linux-mmc

On Mon, 2026-01-12 at 16:46 +0100, Uwe Kleine-König wrote:
> Hello,
> 
> this series is part of an effort to get rid of the .shutdown() callback
> (and .probe() and .remove()) in struct device_driver. Preparing that,
> all sdio drivers that up to now use this callback are converted to a new
> sdio specific shutdown callback.
> 
> v1 is available at https://lore.kernel.org/all/cover.1765968841.git.ukleinek@kernel.org.
> 
> Changes since v1:
>  - Drop patch 2/4 which resulted in a build failure with CONFIG_PM=n
> 
> Patches #2 and #3 depend on the first patch, and with just the first
> patch applied there is a runtime warning (emitted by the driver core in
> driver_register()) for each unconverted driver. So it would be nice to
> get the whole series in during a single merge window to not let users
> face the warning.
> 
> Given that all drivers are in drivers/net/wireless I suggest to apply
> the whole series via the wireless tree.
> 

Sounds good, thanks for the heads-up.

I guess I should get Ulf's ack for the MMC part, and Ping-Ke's for the
rtw part, and nobody cares about rsi :)

johannes

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

* RE: [PATCH v2 3/3] wifi: rtw88: sdio: Migrate to use sdio specific shutdown function
  2026-01-12 15:46 ` [PATCH v2 3/3] wifi: rtw88: " Uwe Kleine-König
@ 2026-01-13  0:29   ` Ping-Ke Shih
  0 siblings, 0 replies; 15+ messages in thread
From: Ping-Ke Shih @ 2026-01-13  0:29 UTC (permalink / raw)
  To: Uwe Kleine-König, Johannes Berg; +Cc: linux-wireless@vger.kernel.org

Uwe Kleine-König <u.kleine-koenig@baylibre.com> wrote:
> This saves a cast in the driver. The motivation is stop using the callback
> .shutdown in rsi_driver.drv to make it possible to drop that.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>

Acked-by: Ping-Ke Shih <pkshih@realtek.com>



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

* RE: [PATCH v2 0/3] sdio: Use bus type function for shutdown
  2026-01-12 15:51 ` [PATCH v2 0/3] sdio: Use bus type function for shutdown Johannes Berg
@ 2026-01-13  0:31   ` Ping-Ke Shih
  0 siblings, 0 replies; 15+ messages in thread
From: Ping-Ke Shih @ 2026-01-13  0:31 UTC (permalink / raw)
  To: Johannes Berg, Uwe Kleine-König, Ulf Hansson
  Cc: linux-wireless@vger.kernel.org, linux-mmc@vger.kernel.org

Johannes Berg <johannes@sipsolutions.net> wrote:
> On Mon, 2026-01-12 at 16:46 +0100, Uwe Kleine-König wrote:
> > Hello,
> >
> > this series is part of an effort to get rid of the .shutdown() callback
> > (and .probe() and .remove()) in struct device_driver. Preparing that,
> > all sdio drivers that up to now use this callback are converted to a new
> > sdio specific shutdown callback.
> >
> > v1 is available at https://lore.kernel.org/all/cover.1765968841.git.ukleinek@kernel.org.
> >
> > Changes since v1:
> >  - Drop patch 2/4 which resulted in a build failure with CONFIG_PM=n
> >
> > Patches #2 and #3 depend on the first patch, and with just the first
> > patch applied there is a runtime warning (emitted by the driver core in
> > driver_register()) for each unconverted driver. So it would be nice to
> > get the whole series in during a single merge window to not let users
> > face the warning.
> >
> > Given that all drivers are in drivers/net/wireless I suggest to apply
> > the whole series via the wireless tree.
> >
> 
> Sounds good, thanks for the heads-up.
> 
> I guess I should get Ulf's ack for the MMC part, and Ping-Ke's for the
> rtw part, and nobody cares about rsi :)

Acked. And assigned this patch to you in patchwork. Thanks. 



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

* Re: [PATCH v2 1/3] sdio: Provide a bustype shutdown function
  2026-01-12 15:46 ` [PATCH v2 1/3] sdio: Provide a bustype shutdown function Uwe Kleine-König
@ 2026-01-15  1:26   ` Shawn Lin
  2026-01-15  8:23     ` Uwe Kleine-König
  2026-01-19  9:16   ` Johannes Berg
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 15+ messages in thread
From: Shawn Lin @ 2026-01-15  1:26 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: shawn.lin, linux-wireless, linux-mmc, Ulf Hansson, Ping-Ke Shih,
	Johannes Berg

在 2026/01/12 星期一 23:46, Uwe Kleine-König 写道:
> To prepare sdio drivers to migrate away from struct device_driver::shutdown
> (and then eventually remove that callback) create a serdev driver shutdown

/s/serdev driver/sdio driver ?

> callback and migration code to keep the existing behaviour. Note this
> introduces a warning for each driver that isn't converted yet to that
> callback at register time.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
> ---
>   drivers/mmc/core/sdio_bus.c   | 25 +++++++++++++++++++++++++
>   include/linux/mmc/sdio_func.h |  1 +
>   2 files changed, 26 insertions(+)
> 
> diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c
> index 10799772494a..6e5bdc2f0cc8 100644
> --- a/drivers/mmc/core/sdio_bus.c
> +++ b/drivers/mmc/core/sdio_bus.c
> @@ -232,6 +232,15 @@ static void sdio_bus_remove(struct device *dev)
>   		pm_runtime_put_sync(dev);
>   }
>   
> +static void sdio_bus_shutdown(struct device *dev)
> +{
> +	struct sdio_driver *drv = to_sdio_driver(dev->driver);
> +	struct sdio_func *func = dev_to_sdio_func(dev);
> +
> +	if (dev->driver && drv->shutdown)
> +		drv->shutdown(func);
> +}

Seem bogus check as a few line ahead, you used dev->driver to get
sdio_driver already. Otherwise the reset looks good.

> +
>   static const struct dev_pm_ops sdio_bus_pm_ops = {
>   	SET_SYSTEM_SLEEP_PM_OPS(pm_generic_suspend, pm_generic_resume)
>   	SET_RUNTIME_PM_OPS(
> @@ -248,6 +257,7 @@ static const struct bus_type sdio_bus_type = {
>   	.uevent		= sdio_bus_uevent,
>   	.probe		= sdio_bus_probe,
>   	.remove		= sdio_bus_remove,
> +	.shutdown	= sdio_bus_shutdown,
>   	.pm		= &sdio_bus_pm_ops,
>   };
>   
> @@ -261,6 +271,14 @@ void sdio_unregister_bus(void)
>   	bus_unregister(&sdio_bus_type);
>   }
>   
> +static void sdio_legacy_shutdown(struct sdio_func *func)
> +{
> +	struct device *dev = &func->dev;
> +	struct device_driver *driver = dev->driver;
> +
> +	driver->shutdown(dev);
> +}
> +
>   /**
>    *	__sdio_register_driver - register a function driver
>    *	@drv: SDIO function driver
> @@ -272,6 +290,13 @@ int __sdio_register_driver(struct sdio_driver *drv, struct module *owner)
>   	drv->drv.bus = &sdio_bus_type;
>   	drv->drv.owner = owner;
>   
> +	/*
> +	 * This driver needs updating. Note that driver_register() warns about
> +	 * this, so we're not adding another warning here.
> +	 */
> +	if (!drv->shutdown && drv->drv.shutdown)
> +		drv->shutdown = sdio_legacy_shutdown;
> +
>   	return driver_register(&drv->drv);
>   }
>   EXPORT_SYMBOL_GPL(__sdio_register_driver);
> diff --git a/include/linux/mmc/sdio_func.h b/include/linux/mmc/sdio_func.h
> index fed1f5f4a8d3..4534bf462aac 100644
> --- a/include/linux/mmc/sdio_func.h
> +++ b/include/linux/mmc/sdio_func.h
> @@ -78,6 +78,7 @@ struct sdio_driver {
>   
>   	int (*probe)(struct sdio_func *, const struct sdio_device_id *);
>   	void (*remove)(struct sdio_func *);
> +	void (*shutdown)(struct sdio_func *);
>   
>   	struct device_driver drv;
>   };


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

* Re: [PATCH v2 1/3] sdio: Provide a bustype shutdown function
  2026-01-15  1:26   ` Shawn Lin
@ 2026-01-15  8:23     ` Uwe Kleine-König
  0 siblings, 0 replies; 15+ messages in thread
From: Uwe Kleine-König @ 2026-01-15  8:23 UTC (permalink / raw)
  To: Shawn Lin, Ulf Hansson, Johannes Berg
  Cc: linux-wireless, linux-mmc, Ping-Ke Shih

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

On Thu, Jan 15, 2026 at 09:26:21AM +0800, Shawn Lin wrote:
> 在 2026/01/12 星期一 23:46, Uwe Kleine-König 写道:
> > To prepare sdio drivers to migrate away from struct device_driver::shutdown
> > (and then eventually remove that callback) create a serdev driver shutdown
> 
> /s/serdev driver/sdio driver ?

Oh, indeed. Thanks for catching that.

> > callback and migration code to keep the existing behaviour. Note this
> > introduces a warning for each driver that isn't converted yet to that
> > callback at register time.
> > 
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
> > ---
> >   drivers/mmc/core/sdio_bus.c   | 25 +++++++++++++++++++++++++
> >   include/linux/mmc/sdio_func.h |  1 +
> >   2 files changed, 26 insertions(+)
> > 
> > diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c
> > index 10799772494a..6e5bdc2f0cc8 100644
> > --- a/drivers/mmc/core/sdio_bus.c
> > +++ b/drivers/mmc/core/sdio_bus.c
> > @@ -232,6 +232,15 @@ static void sdio_bus_remove(struct device *dev)
> >   		pm_runtime_put_sync(dev);
> >   }
> > +static void sdio_bus_shutdown(struct device *dev)
> > +{
> > +	struct sdio_driver *drv = to_sdio_driver(dev->driver);
> > +	struct sdio_func *func = dev_to_sdio_func(dev);
> > +
> > +	if (dev->driver && drv->shutdown)
> > +		drv->shutdown(func);
> > +}
> 
> Seem bogus check as a few line ahead, you used dev->driver to get
> sdio_driver already. Otherwise the reset looks good.

to_sdio_driver(dev->driver) however is only pointer arithmetic and
doesn't dereference the pointer. So this is not a bug in the class
check-for-NULL-after-dereference. TTBOMY the code if fine as is.

Should I resend for the typo, or can this be fixed up while applying?

Best regards
Uwe

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

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

* Re: [PATCH v2 1/3] sdio: Provide a bustype shutdown function
  2026-01-12 15:46 ` [PATCH v2 1/3] sdio: Provide a bustype shutdown function Uwe Kleine-König
  2026-01-15  1:26   ` Shawn Lin
@ 2026-01-19  9:16   ` Johannes Berg
  2026-01-19 15:00   ` Ulf Hansson
  2026-01-20 10:27   ` Ulf Hansson
  3 siblings, 0 replies; 15+ messages in thread
From: Johannes Berg @ 2026-01-19  9:16 UTC (permalink / raw)
  To: Uwe Kleine-König, Ulf Hansson, Ping-Ke Shih
  Cc: linux-wireless, linux-mmc

On Mon, 2026-01-12 at 16:46 +0100, Uwe Kleine-König wrote:
> To prepare sdio drivers to migrate away from struct device_driver::shutdown
> (and then eventually remove that callback) create a serdev driver shutdown
> callback and migration code to keep the existing behaviour. Note this
> introduces a warning for each driver that isn't converted yet to that
> callback at register time.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>

Ulf, could you send an ACK for taking this through wireless?

Thanks,
johannes

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

* Re: [PATCH v2 1/3] sdio: Provide a bustype shutdown function
  2026-01-12 15:46 ` [PATCH v2 1/3] sdio: Provide a bustype shutdown function Uwe Kleine-König
  2026-01-15  1:26   ` Shawn Lin
  2026-01-19  9:16   ` Johannes Berg
@ 2026-01-19 15:00   ` Ulf Hansson
  2026-01-19 18:25     ` Uwe Kleine-König
  2026-01-20 10:27   ` Ulf Hansson
  3 siblings, 1 reply; 15+ messages in thread
From: Ulf Hansson @ 2026-01-19 15:00 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Ping-Ke Shih, Johannes Berg, linux-wireless, linux-mmc

On Mon, 12 Jan 2026 at 16:47, Uwe Kleine-König
<u.kleine-koenig@baylibre.com> wrote:
>
> To prepare sdio drivers to migrate away from struct device_driver::shutdown
> (and then eventually remove that callback) create a serdev driver shutdown
> callback and migration code to keep the existing behaviour. Note this
> introduces a warning for each driver that isn't converted yet to that
> callback at register time.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
> ---
>  drivers/mmc/core/sdio_bus.c   | 25 +++++++++++++++++++++++++
>  include/linux/mmc/sdio_func.h |  1 +
>  2 files changed, 26 insertions(+)
>
> diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c
> index 10799772494a..6e5bdc2f0cc8 100644
> --- a/drivers/mmc/core/sdio_bus.c
> +++ b/drivers/mmc/core/sdio_bus.c
> @@ -232,6 +232,15 @@ static void sdio_bus_remove(struct device *dev)
>                 pm_runtime_put_sync(dev);
>  }
>
> +static void sdio_bus_shutdown(struct device *dev)
> +{
> +       struct sdio_driver *drv = to_sdio_driver(dev->driver);
> +       struct sdio_func *func = dev_to_sdio_func(dev);
> +
> +       if (dev->driver && drv->shutdown)
> +               drv->shutdown(func);
> +}
> +
>  static const struct dev_pm_ops sdio_bus_pm_ops = {
>         SET_SYSTEM_SLEEP_PM_OPS(pm_generic_suspend, pm_generic_resume)
>         SET_RUNTIME_PM_OPS(
> @@ -248,6 +257,7 @@ static const struct bus_type sdio_bus_type = {
>         .uevent         = sdio_bus_uevent,
>         .probe          = sdio_bus_probe,
>         .remove         = sdio_bus_remove,
> +       .shutdown       = sdio_bus_shutdown,
>         .pm             = &sdio_bus_pm_ops,
>  };
>
> @@ -261,6 +271,14 @@ void sdio_unregister_bus(void)
>         bus_unregister(&sdio_bus_type);
>  }
>
> +static void sdio_legacy_shutdown(struct sdio_func *func)
> +{
> +       struct device *dev = &func->dev;
> +       struct device_driver *driver = dev->driver;
> +
> +       driver->shutdown(dev);
> +}
> +
>  /**
>   *     __sdio_register_driver - register a function driver
>   *     @drv: SDIO function driver
> @@ -272,6 +290,13 @@ int __sdio_register_driver(struct sdio_driver *drv, struct module *owner)
>         drv->drv.bus = &sdio_bus_type;
>         drv->drv.owner = owner;
>
> +       /*
> +        * This driver needs updating. Note that driver_register() warns about
> +        * this, so we're not adding another warning here.
> +        */
> +       if (!drv->shutdown && drv->drv.shutdown)
> +               drv->shutdown = sdio_legacy_shutdown;
> +

Is this added only to keep the series bisectable or are there other
(except those you fix in the series) sdio func drivers that make use
of the shutdown callback?

In any case, when are you planning to remove this?

>         return driver_register(&drv->drv);
>  }
>  EXPORT_SYMBOL_GPL(__sdio_register_driver);
> diff --git a/include/linux/mmc/sdio_func.h b/include/linux/mmc/sdio_func.h
> index fed1f5f4a8d3..4534bf462aac 100644
> --- a/include/linux/mmc/sdio_func.h
> +++ b/include/linux/mmc/sdio_func.h
> @@ -78,6 +78,7 @@ struct sdio_driver {
>
>         int (*probe)(struct sdio_func *, const struct sdio_device_id *);
>         void (*remove)(struct sdio_func *);
> +       void (*shutdown)(struct sdio_func *);
>
>         struct device_driver drv;
>  };
> --
> 2.47.3
>

Kind regards
Uffe

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

* Re: [PATCH v2 1/3] sdio: Provide a bustype shutdown function
  2026-01-19 15:00   ` Ulf Hansson
@ 2026-01-19 18:25     ` Uwe Kleine-König
  2026-01-20 10:25       ` Ulf Hansson
  0 siblings, 1 reply; 15+ messages in thread
From: Uwe Kleine-König @ 2026-01-19 18:25 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: Ping-Ke Shih, Johannes Berg, linux-wireless, linux-mmc

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

Hello Ulf,

On Mon, Jan 19, 2026 at 04:00:48PM +0100, Ulf Hansson wrote:
> On Mon, 12 Jan 2026 at 16:47, Uwe Kleine-König
> <u.kleine-koenig@baylibre.com> wrote:
> > @@ -272,6 +290,13 @@ int __sdio_register_driver(struct sdio_driver *drv, struct module *owner)
> >         drv->drv.bus = &sdio_bus_type;
> >         drv->drv.owner = owner;
> >
> > +       /*
> > +        * This driver needs updating. Note that driver_register() warns about
> > +        * this, so we're not adding another warning here.
> > +        */
> > +       if (!drv->shutdown && drv->drv.shutdown)
> > +               drv->shutdown = sdio_legacy_shutdown;
> > +
> 
> Is this added only to keep the series bisectable or are there other
> (except those you fix in the series) sdio func drivers that make use
> of the shutdown callback?

It's kept because I don't know if there are any other sdio driver in
flight and these would break silently when they are applied between this
series and the removal of the callbacks from struct device_driver.

> In any case, when are you planning to remove this?

So my plan is to remove this in a series where the last patch is the
modification to struct driver.

Best regards
Uwe

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

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

* Re: [PATCH v2 1/3] sdio: Provide a bustype shutdown function
  2026-01-19 18:25     ` Uwe Kleine-König
@ 2026-01-20 10:25       ` Ulf Hansson
  0 siblings, 0 replies; 15+ messages in thread
From: Ulf Hansson @ 2026-01-20 10:25 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Ping-Ke Shih, Johannes Berg, linux-wireless, linux-mmc

On Mon, 19 Jan 2026 at 19:25, Uwe Kleine-König
<u.kleine-koenig@baylibre.com> wrote:
>
> Hello Ulf,
>
> On Mon, Jan 19, 2026 at 04:00:48PM +0100, Ulf Hansson wrote:
> > On Mon, 12 Jan 2026 at 16:47, Uwe Kleine-König
> > <u.kleine-koenig@baylibre.com> wrote:
> > > @@ -272,6 +290,13 @@ int __sdio_register_driver(struct sdio_driver *drv, struct module *owner)
> > >         drv->drv.bus = &sdio_bus_type;
> > >         drv->drv.owner = owner;
> > >
> > > +       /*
> > > +        * This driver needs updating. Note that driver_register() warns about
> > > +        * this, so we're not adding another warning here.
> > > +        */
> > > +       if (!drv->shutdown && drv->drv.shutdown)
> > > +               drv->shutdown = sdio_legacy_shutdown;
> > > +
> >
> > Is this added only to keep the series bisectable or are there other
> > (except those you fix in the series) sdio func drivers that make use
> > of the shutdown callback?
>
> It's kept because I don't know if there are any other sdio driver in
> flight and these would break silently when they are applied between this
> series and the removal of the callbacks from struct device_driver.
>
> > In any case, when are you planning to remove this?
>
> So my plan is to remove this in a series where the last patch is the
> modification to struct driver.

Okay, thanks for clarifying!

Kind regards
Uffe

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

* Re: [PATCH v2 1/3] sdio: Provide a bustype shutdown function
  2026-01-12 15:46 ` [PATCH v2 1/3] sdio: Provide a bustype shutdown function Uwe Kleine-König
                     ` (2 preceding siblings ...)
  2026-01-19 15:00   ` Ulf Hansson
@ 2026-01-20 10:27   ` Ulf Hansson
  2026-01-20 10:29     ` Johannes Berg
  3 siblings, 1 reply; 15+ messages in thread
From: Ulf Hansson @ 2026-01-20 10:27 UTC (permalink / raw)
  To: Uwe Kleine-König, Johannes Berg
  Cc: Ping-Ke Shih, linux-wireless, linux-mmc

On Mon, 12 Jan 2026 at 16:47, Uwe Kleine-König
<u.kleine-koenig@baylibre.com> wrote:
>
> To prepare sdio drivers to migrate away from struct device_driver::shutdown
> (and then eventually remove that callback) create a serdev driver shutdown
> callback and migration code to keep the existing behaviour. Note this
> introduces a warning for each driver that isn't converted yet to that
> callback at register time.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>

Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>

Johannes, please pick this via your tree. And sorry for the delay in
reviewing this!

Kind regards
Uffe

> ---
>  drivers/mmc/core/sdio_bus.c   | 25 +++++++++++++++++++++++++
>  include/linux/mmc/sdio_func.h |  1 +
>  2 files changed, 26 insertions(+)
>
> diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c
> index 10799772494a..6e5bdc2f0cc8 100644
> --- a/drivers/mmc/core/sdio_bus.c
> +++ b/drivers/mmc/core/sdio_bus.c
> @@ -232,6 +232,15 @@ static void sdio_bus_remove(struct device *dev)
>                 pm_runtime_put_sync(dev);
>  }
>
> +static void sdio_bus_shutdown(struct device *dev)
> +{
> +       struct sdio_driver *drv = to_sdio_driver(dev->driver);
> +       struct sdio_func *func = dev_to_sdio_func(dev);
> +
> +       if (dev->driver && drv->shutdown)
> +               drv->shutdown(func);
> +}
> +
>  static const struct dev_pm_ops sdio_bus_pm_ops = {
>         SET_SYSTEM_SLEEP_PM_OPS(pm_generic_suspend, pm_generic_resume)
>         SET_RUNTIME_PM_OPS(
> @@ -248,6 +257,7 @@ static const struct bus_type sdio_bus_type = {
>         .uevent         = sdio_bus_uevent,
>         .probe          = sdio_bus_probe,
>         .remove         = sdio_bus_remove,
> +       .shutdown       = sdio_bus_shutdown,
>         .pm             = &sdio_bus_pm_ops,
>  };
>
> @@ -261,6 +271,14 @@ void sdio_unregister_bus(void)
>         bus_unregister(&sdio_bus_type);
>  }
>
> +static void sdio_legacy_shutdown(struct sdio_func *func)
> +{
> +       struct device *dev = &func->dev;
> +       struct device_driver *driver = dev->driver;
> +
> +       driver->shutdown(dev);
> +}
> +
>  /**
>   *     __sdio_register_driver - register a function driver
>   *     @drv: SDIO function driver
> @@ -272,6 +290,13 @@ int __sdio_register_driver(struct sdio_driver *drv, struct module *owner)
>         drv->drv.bus = &sdio_bus_type;
>         drv->drv.owner = owner;
>
> +       /*
> +        * This driver needs updating. Note that driver_register() warns about
> +        * this, so we're not adding another warning here.
> +        */
> +       if (!drv->shutdown && drv->drv.shutdown)
> +               drv->shutdown = sdio_legacy_shutdown;
> +
>         return driver_register(&drv->drv);
>  }
>  EXPORT_SYMBOL_GPL(__sdio_register_driver);
> diff --git a/include/linux/mmc/sdio_func.h b/include/linux/mmc/sdio_func.h
> index fed1f5f4a8d3..4534bf462aac 100644
> --- a/include/linux/mmc/sdio_func.h
> +++ b/include/linux/mmc/sdio_func.h
> @@ -78,6 +78,7 @@ struct sdio_driver {
>
>         int (*probe)(struct sdio_func *, const struct sdio_device_id *);
>         void (*remove)(struct sdio_func *);
> +       void (*shutdown)(struct sdio_func *);
>
>         struct device_driver drv;
>  };
> --
> 2.47.3
>

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

* Re: [PATCH v2 1/3] sdio: Provide a bustype shutdown function
  2026-01-20 10:27   ` Ulf Hansson
@ 2026-01-20 10:29     ` Johannes Berg
  0 siblings, 0 replies; 15+ messages in thread
From: Johannes Berg @ 2026-01-20 10:29 UTC (permalink / raw)
  To: Ulf Hansson, Uwe Kleine-König
  Cc: Ping-Ke Shih, linux-wireless, linux-mmc

On Tue, 2026-01-20 at 11:27 +0100, Ulf Hansson wrote:
> On Mon, 12 Jan 2026 at 16:47, Uwe Kleine-König
> <u.kleine-koenig@baylibre.com> wrote:
> > 
> > To prepare sdio drivers to migrate away from struct device_driver::shutdown
> > (and then eventually remove that callback) create a serdev driver shutdown
> > callback and migration code to keep the existing behaviour. Note this
> > introduces a warning for each driver that isn't converted yet to that
> > callback at register time.
> > 
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
> 
> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
> 
> Johannes, please pick this via your tree. And sorry for the delay in
> reviewing this!

Will do, no worries at all, thanks!

johannes

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

end of thread, other threads:[~2026-01-20 10:29 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-12 15:46 [PATCH v2 0/3] sdio: Use bus type function for shutdown Uwe Kleine-König
2026-01-12 15:46 ` [PATCH v2 1/3] sdio: Provide a bustype shutdown function Uwe Kleine-König
2026-01-15  1:26   ` Shawn Lin
2026-01-15  8:23     ` Uwe Kleine-König
2026-01-19  9:16   ` Johannes Berg
2026-01-19 15:00   ` Ulf Hansson
2026-01-19 18:25     ` Uwe Kleine-König
2026-01-20 10:25       ` Ulf Hansson
2026-01-20 10:27   ` Ulf Hansson
2026-01-20 10:29     ` Johannes Berg
2026-01-12 15:46 ` [PATCH v2 2/3] wifi: rsi: sdio: Migrate to use sdio specific " Uwe Kleine-König
2026-01-12 15:46 ` [PATCH v2 3/3] wifi: rtw88: " Uwe Kleine-König
2026-01-13  0:29   ` Ping-Ke Shih
2026-01-12 15:51 ` [PATCH v2 0/3] sdio: Use bus type function for shutdown Johannes Berg
2026-01-13  0:31   ` Ping-Ke Shih

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox