linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] mfd: Make .disable() callback and mfd_cell_disable() return void
@ 2023-01-13 18:24 Uwe Kleine-König
  2023-01-13 18:24 ` [PATCH 1/2] mfd: Make .disable() callback " Uwe Kleine-König
  2023-01-13 18:24 ` [PATCH 2/2] mfd: Make mfd_cell_disable() " Uwe Kleine-König
  0 siblings, 2 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2023-01-13 18:24 UTC (permalink / raw)
  To: Lee Jones, Pavel Machek; +Cc: linux-kernel, kernel, linux-leds

Hello,

this series eventually changes mfd_cell_disable() to return void. Before it
returned an int and always 0. The motivation is to not force drivers to do
error handling that is never hit. Here only a single driver did that:
leds-asic3. For that driver this is a nice improvement because a platform
driver's remove callback is not supposed to return an error code.

This serves as a preparation for the quest to make struct
platform_driver::remove return void, too.

This series is build-tested (using allmodconfig) on arm64, m68k, powerpc,
riscv, s390, sparc64 and x86_64.

I suggest to let this series go into mainline via the mfd tree. So an Ack by
Pavel for the led bits would be nice to let Lee pick it up in good conscience.

Best regards
Uwe

Uwe Kleine-König (2):
  mfd: Make .disable() callback return void
  mfd: Make mfd_cell_disable() return void

 drivers/leds/leds-asic3.c |  6 ++++--
 drivers/mfd/asic3.c       | 17 +++++++++--------
 drivers/mfd/htc-pasic3.c  |  3 +--
 drivers/mfd/mfd-core.c    | 10 ++++------
 drivers/mfd/t7l66xb.c     |  4 +---
 drivers/mfd/tc6387xb.c    |  4 +---
 drivers/mfd/tc6393xb.c    | 16 ++++++++++------
 include/linux/mfd/core.h  |  4 ++--
 8 files changed, 32 insertions(+), 32 deletions(-)

base-commit: 1b929c02afd37871d5afb9d498426f83432e71c2
-- 
2.39.0


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

* [PATCH 1/2] mfd: Make .disable() callback return void
  2023-01-13 18:24 [PATCH 0/2] mfd: Make .disable() callback and mfd_cell_disable() return void Uwe Kleine-König
@ 2023-01-13 18:24 ` Uwe Kleine-König
  2023-01-26 13:34   ` Lee Jones
  2023-01-13 18:24 ` [PATCH 2/2] mfd: Make mfd_cell_disable() " Uwe Kleine-König
  1 sibling, 1 reply; 5+ messages in thread
From: Uwe Kleine-König @ 2023-01-13 18:24 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-kernel, kernel

All implementations return 0 unconditionally, so change the prototype to
return void. This allows to get rid of error handling in callers that
isn't actually used.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/mfd/asic3.c      | 17 +++++++++--------
 drivers/mfd/htc-pasic3.c |  3 +--
 drivers/mfd/mfd-core.c   |  4 +++-
 drivers/mfd/t7l66xb.c    |  4 +---
 drivers/mfd/tc6387xb.c   |  4 +---
 drivers/mfd/tc6393xb.c   | 16 ++++++++++------
 include/linux/mfd/core.h |  2 +-
 7 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/drivers/mfd/asic3.c b/drivers/mfd/asic3.c
index 4fb7e35eb5ed..b62e1732cfd2 100644
--- a/drivers/mfd/asic3.c
+++ b/drivers/mfd/asic3.c
@@ -676,7 +676,7 @@ static int ds1wm_enable(struct platform_device *pdev)
 	return 0;
 }
 
-static int ds1wm_disable(struct platform_device *pdev)
+static void ds1wm_disable(struct platform_device *pdev)
 {
 	struct asic3 *asic = dev_get_drvdata(pdev->dev.parent);
 
@@ -686,8 +686,6 @@ static int ds1wm_disable(struct platform_device *pdev)
 	asic3_clk_disable(asic, &asic->clocks[ASIC3_CLOCK_OWM]);
 	asic3_clk_disable(asic, &asic->clocks[ASIC3_CLOCK_EX0]);
 	asic3_clk_disable(asic, &asic->clocks[ASIC3_CLOCK_EX1]);
-
-	return 0;
 }
 
 static const struct mfd_cell asic3_cell_ds1wm = {
@@ -769,7 +767,7 @@ static int asic3_mmc_enable(struct platform_device *pdev)
 	return 0;
 }
 
-static int asic3_mmc_disable(struct platform_device *pdev)
+static void asic3_mmc_disable(struct platform_device *pdev)
 {
 	struct asic3 *asic = dev_get_drvdata(pdev->dev.parent);
 
@@ -782,6 +780,11 @@ static int asic3_mmc_disable(struct platform_device *pdev)
 	asic3_clk_disable(asic, &asic->clocks[ASIC3_CLOCK_SD_BUS]);
 	asic3_clk_disable(asic, &asic->clocks[ASIC3_CLOCK_EX0]);
 	asic3_clk_disable(asic, &asic->clocks[ASIC3_CLOCK_EX1]);
+}
+
+static int asic3_mmc_suspend(struct platform_device *pdev)
+{
+	asic3_mmc_disable(pdev);
 	return 0;
 }
 
@@ -789,7 +792,7 @@ static const struct mfd_cell asic3_cell_mmc = {
 	.name          = "tmio-mmc",
 	.enable        = asic3_mmc_enable,
 	.disable       = asic3_mmc_disable,
-	.suspend       = asic3_mmc_disable,
+	.suspend       = asic3_mmc_suspend,
 	.resume        = asic3_mmc_enable,
 	.platform_data = &asic3_mmc_data,
 	.pdata_size    = sizeof(asic3_mmc_data),
@@ -813,14 +816,12 @@ static int asic3_leds_enable(struct platform_device *pdev)
 	return 0;
 }
 
-static int asic3_leds_disable(struct platform_device *pdev)
+static void asic3_leds_disable(struct platform_device *pdev)
 {
 	const struct mfd_cell *cell = mfd_get_cell(pdev);
 	struct asic3 *asic = dev_get_drvdata(pdev->dev.parent);
 
 	asic3_clk_disable(asic, &asic->clocks[clock_ledn[cell->id]]);
-
-	return 0;
 }
 
 static int asic3_leds_suspend(struct platform_device *pdev)
diff --git a/drivers/mfd/htc-pasic3.c b/drivers/mfd/htc-pasic3.c
index 0c46b7e64b2d..57fc18e2194f 100644
--- a/drivers/mfd/htc-pasic3.c
+++ b/drivers/mfd/htc-pasic3.c
@@ -82,7 +82,7 @@ static int ds1wm_enable(struct platform_device *pdev)
 	return 0;
 }
 
-static int ds1wm_disable(struct platform_device *pdev)
+static void ds1wm_disable(struct platform_device *pdev)
 {
 	struct device *dev = pdev->dev.parent;
 	int c;
@@ -91,7 +91,6 @@ static int ds1wm_disable(struct platform_device *pdev)
 	pasic3_write_register(dev, 0x28, c | 0x80);
 
 	dev_dbg(dev, "DS1WM OWM_EN high (inactive) %02x\n", c | 0x80);
-	return 0;
 }
 
 static struct ds1wm_driver_data ds1wm_pdata = {
diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
index 16d1861e9682..b854c4adb527 100644
--- a/drivers/mfd/mfd-core.c
+++ b/drivers/mfd/mfd-core.c
@@ -55,7 +55,9 @@ int mfd_cell_disable(struct platform_device *pdev)
 		return 0;
 	}
 
-	return cell->disable(pdev);
+	cell->disable(pdev);
+
+	return 0;
 }
 EXPORT_SYMBOL(mfd_cell_disable);
 
diff --git a/drivers/mfd/t7l66xb.c b/drivers/mfd/t7l66xb.c
index 1d9d1d38d068..fd7dfbe64bf5 100644
--- a/drivers/mfd/t7l66xb.c
+++ b/drivers/mfd/t7l66xb.c
@@ -94,7 +94,7 @@ static int t7l66xb_mmc_enable(struct platform_device *mmc)
 	return 0;
 }
 
-static int t7l66xb_mmc_disable(struct platform_device *mmc)
+static void t7l66xb_mmc_disable(struct platform_device *mmc)
 {
 	struct t7l66xb *t7l66xb = dev_get_drvdata(mmc->dev.parent);
 	unsigned long flags;
@@ -109,8 +109,6 @@ static int t7l66xb_mmc_disable(struct platform_device *mmc)
 	raw_spin_unlock_irqrestore(&t7l66xb->lock, flags);
 
 	clk_disable_unprepare(t7l66xb->clk32k);
-
-	return 0;
 }
 
 static void t7l66xb_mmc_pwr(struct platform_device *mmc, int state)
diff --git a/drivers/mfd/tc6387xb.c b/drivers/mfd/tc6387xb.c
index 5392da6ba7b0..848058e7fe41 100644
--- a/drivers/mfd/tc6387xb.c
+++ b/drivers/mfd/tc6387xb.c
@@ -96,13 +96,11 @@ static int tc6387xb_mmc_enable(struct platform_device *mmc)
 	return 0;
 }
 
-static int tc6387xb_mmc_disable(struct platform_device *mmc)
+static void tc6387xb_mmc_disable(struct platform_device *mmc)
 {
 	struct tc6387xb *tc6387xb = dev_get_drvdata(mmc->dev.parent);
 
 	clk_disable_unprepare(tc6387xb->clk32k);
-
-	return 0;
 }
 
 static struct tmio_mmc_data tc6387xb_mmc_data = {
diff --git a/drivers/mfd/tc6393xb.c b/drivers/mfd/tc6393xb.c
index 997bb8b5881d..20521fece1ae 100644
--- a/drivers/mfd/tc6393xb.c
+++ b/drivers/mfd/tc6393xb.c
@@ -241,7 +241,7 @@ static int tc6393xb_ohci_enable(struct platform_device *dev)
 	return 0;
 }
 
-static int tc6393xb_ohci_disable(struct platform_device *dev)
+static void tc6393xb_ohci_disable(struct platform_device *dev)
 {
 	struct tc6393xb *tc6393xb = dev_get_drvdata(dev->dev.parent);
 	unsigned long flags;
@@ -259,8 +259,6 @@ static int tc6393xb_ohci_disable(struct platform_device *dev)
 	tmio_iowrite16(ccr, tc6393xb->scr + SCR_CCR);
 
 	raw_spin_unlock_irqrestore(&tc6393xb->lock, flags);
-
-	return 0;
 }
 
 static int tc6393xb_ohci_suspend(struct platform_device *dev)
@@ -271,7 +269,9 @@ static int tc6393xb_ohci_suspend(struct platform_device *dev)
 	if (tcpd->resume_restore)
 		return -EBUSY;
 
-	return tc6393xb_ohci_disable(dev);
+	tc6393xb_ohci_disable(dev);
+
+	return 0;
 }
 
 static int tc6393xb_fb_enable(struct platform_device *dev)
@@ -292,7 +292,7 @@ static int tc6393xb_fb_enable(struct platform_device *dev)
 	return 0;
 }
 
-static int tc6393xb_fb_disable(struct platform_device *dev)
+static void tc6393xb_fb_disable(struct platform_device *dev)
 {
 	struct tc6393xb *tc6393xb = dev_get_drvdata(dev->dev.parent);
 	unsigned long flags;
@@ -306,7 +306,11 @@ static int tc6393xb_fb_disable(struct platform_device *dev)
 	tmio_iowrite16(ccr, tc6393xb->scr + SCR_CCR);
 
 	raw_spin_unlock_irqrestore(&tc6393xb->lock, flags);
+}
 
+static int tc6393xb_fb_suspend(struct platform_device *dev)
+{
+	tc6393xb_fb_disable(dev);
 	return 0;
 }
 
@@ -417,7 +421,7 @@ static struct mfd_cell tc6393xb_cells[] = {
 		.num_resources = ARRAY_SIZE(tc6393xb_fb_resources),
 		.resources = tc6393xb_fb_resources,
 		.enable = tc6393xb_fb_enable,
-		.suspend = tc6393xb_fb_disable,
+		.suspend = tc6393xb_fb_suspend,
 		.resume = tc6393xb_fb_enable,
 		.disable = tc6393xb_fb_disable,
 	},
diff --git a/include/linux/mfd/core.h b/include/linux/mfd/core.h
index 0bc7cba798a3..9833d0501d42 100644
--- a/include/linux/mfd/core.h
+++ b/include/linux/mfd/core.h
@@ -69,7 +69,7 @@ struct mfd_cell {
 	int			level;
 
 	int			(*enable)(struct platform_device *dev);
-	int			(*disable)(struct platform_device *dev);
+	void			(*disable)(struct platform_device *dev);
 
 	int			(*suspend)(struct platform_device *dev);
 	int			(*resume)(struct platform_device *dev);
-- 
2.39.0


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

* [PATCH 2/2] mfd: Make mfd_cell_disable() return void
  2023-01-13 18:24 [PATCH 0/2] mfd: Make .disable() callback and mfd_cell_disable() return void Uwe Kleine-König
  2023-01-13 18:24 ` [PATCH 1/2] mfd: Make .disable() callback " Uwe Kleine-König
@ 2023-01-13 18:24 ` Uwe Kleine-König
  1 sibling, 0 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2023-01-13 18:24 UTC (permalink / raw)
  To: Pavel Machek, Lee Jones; +Cc: linux-leds, linux-kernel, kernel

mfd_cell_disable() returns 0 unconditionally. Change it to return void
instead to make its usage a bit more obvious.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/leds/leds-asic3.c |  6 ++++--
 drivers/mfd/mfd-core.c    | 12 ++++--------
 include/linux/mfd/core.h  |  2 +-
 3 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/leds/leds-asic3.c b/drivers/leds/leds-asic3.c
index 8cbc1b8bafa5..8256990394eb 100644
--- a/drivers/leds/leds-asic3.c
+++ b/drivers/leds/leds-asic3.c
@@ -117,7 +117,7 @@ static int asic3_led_probe(struct platform_device *pdev)
 	return 0;
 
 out:
-	(void) mfd_cell_disable(pdev);
+	mfd_cell_disable(pdev);
 	return ret;
 }
 
@@ -127,7 +127,9 @@ static int asic3_led_remove(struct platform_device *pdev)
 
 	led_classdev_unregister(led->cdev);
 
-	return mfd_cell_disable(pdev);
+	mfd_cell_disable(pdev);
+
+	return 0;
 }
 
 #ifdef CONFIG_PM_SLEEP
diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
index b854c4adb527..33720f116b8c 100644
--- a/drivers/mfd/mfd-core.c
+++ b/drivers/mfd/mfd-core.c
@@ -46,18 +46,14 @@ int mfd_cell_enable(struct platform_device *pdev)
 }
 EXPORT_SYMBOL(mfd_cell_enable);
 
-int mfd_cell_disable(struct platform_device *pdev)
+void mfd_cell_disable(struct platform_device *pdev)
 {
 	const struct mfd_cell *cell = mfd_get_cell(pdev);
 
-	if (!cell->disable) {
+	if (cell->disable)
+		cell->disable(pdev);
+	else
 		dev_dbg(&pdev->dev, "No .disable() call-back registered\n");
-		return 0;
-	}
-
-	cell->disable(pdev);
-
-	return 0;
 }
 EXPORT_SYMBOL(mfd_cell_disable);
 
diff --git a/include/linux/mfd/core.h b/include/linux/mfd/core.h
index 9833d0501d42..e43dc9ae2d71 100644
--- a/include/linux/mfd/core.h
+++ b/include/linux/mfd/core.h
@@ -130,7 +130,7 @@ struct mfd_cell {
  * clients are making use of it.
  */
 extern int mfd_cell_enable(struct platform_device *pdev);
-extern int mfd_cell_disable(struct platform_device *pdev);
+extern void mfd_cell_disable(struct platform_device *pdev);
 
 /*
  * Given a platform device that's been created by mfd_add_devices(), fetch
-- 
2.39.0


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

* Re: [PATCH 1/2] mfd: Make .disable() callback return void
  2023-01-13 18:24 ` [PATCH 1/2] mfd: Make .disable() callback " Uwe Kleine-König
@ 2023-01-26 13:34   ` Lee Jones
  2023-01-26 15:27     ` Uwe Kleine-König
  0 siblings, 1 reply; 5+ messages in thread
From: Lee Jones @ 2023-01-26 13:34 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: linux-kernel, kernel

On Fri, 13 Jan 2023, Uwe Kleine-König wrote:

> All implementations return 0 unconditionally, so change the prototype to
> return void. This allows to get rid of error handling in callers that
> isn't actually used.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  drivers/mfd/asic3.c      | 17 +++++++++--------
>  drivers/mfd/htc-pasic3.c |  3 +--
>  drivers/mfd/mfd-core.c   |  4 +++-
>  drivers/mfd/t7l66xb.c    |  4 +---
>  drivers/mfd/tc6387xb.c   |  4 +---
>  drivers/mfd/tc6393xb.c   | 16 ++++++++++------
>  include/linux/mfd/core.h |  2 +-
>  7 files changed, 26 insertions(+), 24 deletions(-)

Doesn't apply to the MFD tree.

Please rebase and I'll merge it.

-- 
Lee Jones [李琼斯]

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

* Re: [PATCH 1/2] mfd: Make .disable() callback return void
  2023-01-26 13:34   ` Lee Jones
@ 2023-01-26 15:27     ` Uwe Kleine-König
  0 siblings, 0 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2023-01-26 15:27 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-kernel, kernel

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

Hello,

On Thu, Jan 26, 2023 at 01:34:16PM +0000, Lee Jones wrote:
> On Fri, 13 Jan 2023, Uwe Kleine-König wrote:
> 
> > All implementations return 0 unconditionally, so change the prototype to
> > return void. This allows to get rid of error handling in callers that
> > isn't actually used.
> > 
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > ---
> >  drivers/mfd/asic3.c      | 17 +++++++++--------
> >  drivers/mfd/htc-pasic3.c |  3 +--
> >  drivers/mfd/mfd-core.c   |  4 +++-
> >  drivers/mfd/t7l66xb.c    |  4 +---
> >  drivers/mfd/tc6387xb.c   |  4 +---
> >  drivers/mfd/tc6393xb.c   | 16 ++++++++++------
> >  include/linux/mfd/core.h |  2 +-
> >  7 files changed, 26 insertions(+), 24 deletions(-)
> 
> Doesn't apply to the MFD tree.
> 
> Please rebase and I'll merge it.

Oh, all the drivers that still provided the .enable() and .disable()
callbacks are gone now. So my patch series is superseeded by

	http://lore.kernel.org/lkml/20230126152429.580539-1-u.kleine-koenig@pengutronix.de

Best regards
Uwe

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

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

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

end of thread, other threads:[~2023-01-26 15:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-13 18:24 [PATCH 0/2] mfd: Make .disable() callback and mfd_cell_disable() return void Uwe Kleine-König
2023-01-13 18:24 ` [PATCH 1/2] mfd: Make .disable() callback " Uwe Kleine-König
2023-01-26 13:34   ` Lee Jones
2023-01-26 15:27     ` Uwe Kleine-König
2023-01-13 18:24 ` [PATCH 2/2] mfd: Make mfd_cell_disable() " Uwe Kleine-König

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