Linux Input/HID development
 help / color / mirror / Atom feed
* [PATCH 14/16] Input: Use pm_sleep_ptr() to avoid need for ifdef CONFIG_PM_SLEEP
From: Jonathan Cameron @ 2023-01-14 17:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov; +Cc: jic23, Jonathan Cameron
In-Reply-To: <20230114171620.42891-1-jic23@kernel.org>

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

As the new pm_sleep_ptr() macro lets the compiler see the code, but
then remove it if !CONFIG_PM_SLEEP it can be used to avoid the need
for #ifdef guards.  Use that in the input core to simplify the code
a little.  Note pm_sleep_ptr() has not been applied to each callback
in the ops structure because the pm_sleep_ptr() at the usage site
is sufficient.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/input/input.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/input/input.c b/drivers/input/input.c
index ca2e3dd7188b..9fdb22db2ca4 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -19,6 +19,7 @@
 #include <linux/proc_fs.h>
 #include <linux/sched.h>
 #include <linux/seq_file.h>
+#include <linux/pm.h>
 #include <linux/poll.h>
 #include <linux/device.h>
 #include <linux/kstrtox.h>
@@ -1828,7 +1829,6 @@ static int input_uninhibit_device(struct input_dev *dev)
 	return ret;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int input_dev_suspend(struct device *dev)
 {
 	struct input_dev *input_dev = to_input_dev(dev);
@@ -1903,15 +1903,12 @@ static const struct dev_pm_ops input_dev_pm_ops = {
 	.poweroff	= input_dev_poweroff,
 	.restore	= input_dev_resume,
 };
-#endif /* CONFIG_PM */
 
 static const struct device_type input_dev_type = {
 	.groups		= input_dev_attr_groups,
 	.release	= input_dev_release,
 	.uevent		= input_dev_uevent,
-#ifdef CONFIG_PM_SLEEP
-	.pm		= &input_dev_pm_ops,
-#endif
+	.pm		= pm_sleep_ptr(&input_dev_pm_ops),
 };
 
 static char *input_devnode(const struct device *dev, umode_t *mode)
-- 
2.39.0


^ permalink raw reply related

* [PATCH 13/16] Input: omap4-keyad - use pm_ptr() and RUNTIME_DEV_PM_OPS()
From: Jonathan Cameron @ 2023-01-14 17:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov; +Cc: jic23, Jonathan Cameron
In-Reply-To: <20230114171620.42891-1-jic23@kernel.org>

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

SET_RUNTIME_DEV_PM_OPS() is deprecated as it requires explicit protection
against unused function warnings.  The new combination of pm_ptr()
and RUNTIME_DEV_PM_OPS() allows the compiler to see the functions,
thus suppressing the warning, but still allowing the unused code to be
removed. Thus also drop the __maybe_unused markings.

Note that DEFINE_RUNTIME_DEV_PM_OPS() is not used because that adds
additional callbacks for suspend and resume and would need
testing.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/input/keyboard/omap4-keypad.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c
index ee9d04a3f0d5..4426120398b0 100644
--- a/drivers/input/keyboard/omap4-keypad.c
+++ b/drivers/input/keyboard/omap4-keypad.c
@@ -310,7 +310,7 @@ static int omap4_keypad_check_revision(struct device *dev,
  * Interrupt may not happen for key-up events. We must clear stuck
  * key-up events after the keyboard hardware has auto-idled.
  */
-static int __maybe_unused omap4_keypad_runtime_suspend(struct device *dev)
+static int omap4_keypad_runtime_suspend(struct device *dev)
 {
 	struct platform_device *pdev = to_platform_device(dev);
 	struct omap4_keypad *keypad_data = platform_get_drvdata(pdev);
@@ -328,7 +328,7 @@ static int __maybe_unused omap4_keypad_runtime_suspend(struct device *dev)
 }
 
 static const struct dev_pm_ops omap4_keypad_pm_ops = {
-	SET_RUNTIME_PM_OPS(omap4_keypad_runtime_suspend, NULL, NULL)
+	RUNTIME_PM_OPS(omap4_keypad_runtime_suspend, NULL, NULL)
 };
 
 static void omap4_disable_pm(void *d)
@@ -488,7 +488,7 @@ static struct platform_driver omap4_keypad_driver = {
 	.driver		= {
 		.name	= "omap4-keypad",
 		.of_match_table = omap_keypad_dt_match,
-		.pm = &omap4_keypad_pm_ops,
+		.pm = pm_ptr(&omap4_keypad_pm_ops),
 	},
 };
 module_platform_driver(omap4_keypad_driver);
-- 
2.39.0


^ permalink raw reply related

* [PATCH 12/16] Input: applespi - use pm_sleep_ptr() and SYSTEM_SLEEP_PM_OPS()
From: Jonathan Cameron @ 2023-01-14 17:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov; +Cc: jic23, Jonathan Cameron
In-Reply-To: <20230114171620.42891-1-jic23@kernel.org>

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

SET_SYSTEM_SLEEP_PM_OPS() is deprecated as it requires explicit protection
against unused function warnings.  The new combination of pm_sleep_ptr()
and SYSTEM_SLEEP_PM_OPS() allows the compiler to see the functions,
thus suppressing the warning, but still allowing the unused code to be
removed. Thus also drop the __maybe_unused markings.

In this case we also have a .poweroff_late() callback. Whilst not
strictly necessary, to future proof against relaxation of the protection
of the main driver.pm = pm_sleep_ptr() protect this pointer with
pm_sleep_ptr() as would be done if the LATE_SYSTEM_SLEEP_PM_OPS()
macro were used to set it.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/input/keyboard/applespi.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/input/keyboard/applespi.c b/drivers/input/keyboard/applespi.c
index 91a9810f6980..cf25177b4830 100644
--- a/drivers/input/keyboard/applespi.c
+++ b/drivers/input/keyboard/applespi.c
@@ -1876,7 +1876,7 @@ static int applespi_poweroff_late(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused applespi_suspend(struct device *dev)
+static int applespi_suspend(struct device *dev)
 {
 	struct spi_device *spi = to_spi_device(dev);
 	struct applespi_data *applespi = spi_get_drvdata(spi);
@@ -1903,7 +1903,7 @@ static int __maybe_unused applespi_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused applespi_resume(struct device *dev)
+static int applespi_resume(struct device *dev)
 {
 	struct spi_device *spi = to_spi_device(dev);
 	struct applespi_data *applespi = spi_get_drvdata(spi);
@@ -1947,15 +1947,15 @@ static const struct acpi_device_id applespi_acpi_match[] = {
 MODULE_DEVICE_TABLE(acpi, applespi_acpi_match);
 
 static const struct dev_pm_ops applespi_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(applespi_suspend, applespi_resume)
-	.poweroff_late	= applespi_poweroff_late,
+	SYSTEM_SLEEP_PM_OPS(applespi_suspend, applespi_resume)
+	.poweroff_late	= pm_sleep_ptr(applespi_poweroff_late),
 };
 
 static struct spi_driver applespi_driver = {
 	.driver		= {
 		.name			= "applespi",
 		.acpi_match_table	= applespi_acpi_match,
-		.pm			= &applespi_pm_ops,
+		.pm			= pm_sleep_ptr(&applespi_pm_ops),
 	},
 	.probe		= applespi_probe,
 	.remove		= applespi_remove,
-- 
2.39.0


^ permalink raw reply related

* [PATCH 11/16] Input: cyttsp - use EXPORT_GPL_SIMPLE_DEV_PM_OPS()
From: Jonathan Cameron @ 2023-01-14 17:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov
  Cc: jic23, Jonathan Cameron, Javier Martinez Canillas, Linus Walleij
In-Reply-To: <20230114171620.42891-1-jic23@kernel.org>

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

SIMPLE_DEV_PM_OPS() is deprecated as it requires explicit protection
against unused function warnings.  The new combination of pm_sleep_ptr()
and EXPORT_GPL_SIMPLE_DEV_PMU_OPS() allows the compiler to see the
functions, thus suppressing the warning, but still allowing the unused
code to be removed. Thus also drop the __maybe_unused markings.
It also rolls in the EXPORT_SYMBOL() so that we only export it
if CONFIG_PM_SLEEP.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Javier Martinez Canillas <javier@dowhile0.org>
Cc: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/input/touchscreen/cyttsp_core.c | 7 +++----
 drivers/input/touchscreen/cyttsp_i2c.c  | 2 +-
 drivers/input/touchscreen/cyttsp_spi.c  | 2 +-
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/input/touchscreen/cyttsp_core.c b/drivers/input/touchscreen/cyttsp_core.c
index 1dbd849c9613..132ed5786e84 100644
--- a/drivers/input/touchscreen/cyttsp_core.c
+++ b/drivers/input/touchscreen/cyttsp_core.c
@@ -491,7 +491,7 @@ static int cyttsp_disable(struct cyttsp *ts)
 	return 0;
 }
 
-static int __maybe_unused cyttsp_suspend(struct device *dev)
+static int cyttsp_suspend(struct device *dev)
 {
 	struct cyttsp *ts = dev_get_drvdata(dev);
 	int retval = 0;
@@ -509,7 +509,7 @@ static int __maybe_unused cyttsp_suspend(struct device *dev)
 	return retval;
 }
 
-static int __maybe_unused cyttsp_resume(struct device *dev)
+static int cyttsp_resume(struct device *dev)
 {
 	struct cyttsp *ts = dev_get_drvdata(dev);
 
@@ -525,8 +525,7 @@ static int __maybe_unused cyttsp_resume(struct device *dev)
 	return 0;
 }
 
-SIMPLE_DEV_PM_OPS(cyttsp_pm_ops, cyttsp_suspend, cyttsp_resume);
-EXPORT_SYMBOL_GPL(cyttsp_pm_ops);
+EXPORT_GPL_SIMPLE_DEV_PM_OPS(cyttsp_pm_ops, cyttsp_suspend, cyttsp_resume);
 
 static int cyttsp_open(struct input_dev *dev)
 {
diff --git a/drivers/input/touchscreen/cyttsp_i2c.c b/drivers/input/touchscreen/cyttsp_i2c.c
index 0155a1626adf..3f91cb43ec82 100644
--- a/drivers/input/touchscreen/cyttsp_i2c.c
+++ b/drivers/input/touchscreen/cyttsp_i2c.c
@@ -63,7 +63,7 @@ MODULE_DEVICE_TABLE(of, cyttsp_of_i2c_match);
 static struct i2c_driver cyttsp_i2c_driver = {
 	.driver = {
 		.name	= CY_I2C_NAME,
-		.pm	= &cyttsp_pm_ops,
+		.pm	= pm_sleep_ptr(&cyttsp_pm_ops),
 		.of_match_table = cyttsp_of_i2c_match,
 	},
 	.probe_new	= cyttsp_i2c_probe,
diff --git a/drivers/input/touchscreen/cyttsp_spi.c b/drivers/input/touchscreen/cyttsp_spi.c
index 30c6fbf86a86..ada17f2dadf3 100644
--- a/drivers/input/touchscreen/cyttsp_spi.c
+++ b/drivers/input/touchscreen/cyttsp_spi.c
@@ -172,7 +172,7 @@ MODULE_DEVICE_TABLE(of, cyttsp_of_spi_match);
 static struct spi_driver cyttsp_spi_driver = {
 	.driver = {
 		.name	= CY_SPI_NAME,
-		.pm	= &cyttsp_pm_ops,
+		.pm	= pm_sleep_ptr(&cyttsp_pm_ops),
 		.of_match_table = cyttsp_of_spi_match,
 	},
 	.probe  = cyttsp_spi_probe,
-- 
2.39.0


^ permalink raw reply related

* [PATCH 10/16] Input: cyttsp4 - use EXPORT_GPL_RUNTIME_DEV_PM_OPS()
From: Jonathan Cameron @ 2023-01-14 17:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov; +Cc: jic23, Jonathan Cameron
In-Reply-To: <20230114171620.42891-1-jic23@kernel.org>

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

SET_SYSTEM_SLEEP_PM_OPS() and RUNTIME_PM_OPS() are deprecated as
they requires explicit protection against unused function warnings.
The new combination of pm_ptr() EXPORT_GPL_RUNTIME_DEV_PM_OPS()
allows the compiler to see the functions, thus suppressing the
warning, but still allowing the unused code to be
removed. Thus also drop the #ifdef guards.

Note that we are replacing an unconditional call to the suspend
and resume functions for sleep use cases with one via
pm_runtime_force_suspend() / pm_runtime_force_resume() that only
do anything to the device if we are not already in the appropriate
runtime suspended state.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

--

I 'think' this should be fine in that it can only reduce the number
of unnecessary suspends.  If anyone can test that would be great.
---
 drivers/input/touchscreen/cyttsp4_core.c | 9 ++-------
 drivers/input/touchscreen/cyttsp4_i2c.c  | 2 +-
 drivers/input/touchscreen/cyttsp4_spi.c  | 2 +-
 3 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/input/touchscreen/cyttsp4_core.c b/drivers/input/touchscreen/cyttsp4_core.c
index dccbcb942fe5..0cd6f626adec 100644
--- a/drivers/input/touchscreen/cyttsp4_core.c
+++ b/drivers/input/touchscreen/cyttsp4_core.c
@@ -1744,7 +1744,6 @@ static void cyttsp4_free_si_ptrs(struct cyttsp4 *cd)
 	kfree(si->btn_rec_data);
 }
 
-#ifdef CONFIG_PM
 static int cyttsp4_core_sleep(struct cyttsp4 *cd)
 {
 	int rc;
@@ -1877,13 +1876,9 @@ static int cyttsp4_core_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
-const struct dev_pm_ops cyttsp4_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(cyttsp4_core_suspend, cyttsp4_core_resume)
-	SET_RUNTIME_PM_OPS(cyttsp4_core_suspend, cyttsp4_core_resume, NULL)
-};
-EXPORT_SYMBOL_GPL(cyttsp4_pm_ops);
+EXPORT_GPL_RUNTIME_DEV_PM_OPS(cyttsp4_pm_ops,
+			      cyttsp4_core_suspend, cyttsp4_core_resume, NULL);
 
 static int cyttsp4_mt_open(struct input_dev *input)
 {
diff --git a/drivers/input/touchscreen/cyttsp4_i2c.c b/drivers/input/touchscreen/cyttsp4_i2c.c
index c260bab0c62c..ec7a4779f3fb 100644
--- a/drivers/input/touchscreen/cyttsp4_i2c.c
+++ b/drivers/input/touchscreen/cyttsp4_i2c.c
@@ -58,7 +58,7 @@ MODULE_DEVICE_TABLE(i2c, cyttsp4_i2c_id);
 static struct i2c_driver cyttsp4_i2c_driver = {
 	.driver = {
 		.name	= CYTTSP4_I2C_NAME,
-		.pm	= &cyttsp4_pm_ops,
+		.pm	= pm_ptr(&cyttsp4_pm_ops),
 	},
 	.probe_new	= cyttsp4_i2c_probe,
 	.remove		= cyttsp4_i2c_remove,
diff --git a/drivers/input/touchscreen/cyttsp4_spi.c b/drivers/input/touchscreen/cyttsp4_spi.c
index 5d7db84f2749..944fbbe9113e 100644
--- a/drivers/input/touchscreen/cyttsp4_spi.c
+++ b/drivers/input/touchscreen/cyttsp4_spi.c
@@ -173,7 +173,7 @@ static void cyttsp4_spi_remove(struct spi_device *spi)
 static struct spi_driver cyttsp4_spi_driver = {
 	.driver = {
 		.name	= CYTTSP4_SPI_NAME,
-		.pm	= &cyttsp4_pm_ops,
+		.pm	= pm_ptr(&cyttsp4_pm_ops),
 	},
 	.probe  = cyttsp4_spi_probe,
 	.remove = cyttsp4_spi_remove,
-- 
2.39.0


^ permalink raw reply related

* [PATCH 09/16] Input: tsc200x - use EXPORT_GPL_SIMPLE_DEV_PM_OPS()
From: Jonathan Cameron @ 2023-01-14 17:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov; +Cc: jic23, Jonathan Cameron
In-Reply-To: <20230114171620.42891-1-jic23@kernel.org>

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

SIMPLE_DEV_PM_OPS() is deprecated as it requires explicit protection
against unused function warnings.  The new combination of pm_sleep_ptr()
and EXPORT_GPL_SIMPLE_DEV_PM_OPS() allows the compiler to see the
functions, thus suppressing the warning, but still allowing the unused
code to be removed. Thus also drop the __maybe_unused markings.
This function also removes the need for separate EXPORT_SYMBOL_GPL()

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/input/touchscreen/tsc2004.c      | 2 +-
 drivers/input/touchscreen/tsc2005.c      | 2 +-
 drivers/input/touchscreen/tsc200x-core.c | 7 +++----
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/input/touchscreen/tsc2004.c b/drivers/input/touchscreen/tsc2004.c
index 575768b587bb..45f39eb20638 100644
--- a/drivers/input/touchscreen/tsc2004.c
+++ b/drivers/input/touchscreen/tsc2004.c
@@ -65,7 +65,7 @@ static struct i2c_driver tsc2004_driver = {
 	.driver = {
 		.name   = "tsc2004",
 		.of_match_table = of_match_ptr(tsc2004_of_match),
-		.pm     = &tsc200x_pm_ops,
+		.pm     = pm_sleep_ptr(&tsc200x_pm_ops),
 	},
 	.id_table       = tsc2004_idtable,
 	.probe_new      = tsc2004_probe,
diff --git a/drivers/input/touchscreen/tsc2005.c b/drivers/input/touchscreen/tsc2005.c
index 555dfe98b3c4..b6dfbcfc8c19 100644
--- a/drivers/input/touchscreen/tsc2005.c
+++ b/drivers/input/touchscreen/tsc2005.c
@@ -81,7 +81,7 @@ static struct spi_driver tsc2005_driver = {
 	.driver	= {
 		.name	= "tsc2005",
 		.of_match_table = of_match_ptr(tsc2005_of_match),
-		.pm	= &tsc200x_pm_ops,
+		.pm	= pm_sleep_ptr(&tsc200x_pm_ops),
 	},
 	.probe	= tsc2005_probe,
 	.remove	= tsc2005_remove,
diff --git a/drivers/input/touchscreen/tsc200x-core.c b/drivers/input/touchscreen/tsc200x-core.c
index 72c7258b93a5..b799f26fcf8f 100644
--- a/drivers/input/touchscreen/tsc200x-core.c
+++ b/drivers/input/touchscreen/tsc200x-core.c
@@ -588,7 +588,7 @@ void tsc200x_remove(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(tsc200x_remove);
 
-static int __maybe_unused tsc200x_suspend(struct device *dev)
+static int tsc200x_suspend(struct device *dev)
 {
 	struct tsc200x *ts = dev_get_drvdata(dev);
 
@@ -604,7 +604,7 @@ static int __maybe_unused tsc200x_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused tsc200x_resume(struct device *dev)
+static int tsc200x_resume(struct device *dev)
 {
 	struct tsc200x *ts = dev_get_drvdata(dev);
 
@@ -620,8 +620,7 @@ static int __maybe_unused tsc200x_resume(struct device *dev)
 	return 0;
 }
 
-SIMPLE_DEV_PM_OPS(tsc200x_pm_ops, tsc200x_suspend, tsc200x_resume);
-EXPORT_SYMBOL_GPL(tsc200x_pm_ops);
+EXPORT_GPL_SIMPLE_DEV_PM_OPS(tsc200x_pm_ops, tsc200x_suspend, tsc200x_resume);
 
 MODULE_AUTHOR("Lauri Leukkunen <lauri.leukkunen@nokia.com>");
 MODULE_DESCRIPTION("TSC200x Touchscreen Driver Core");
-- 
2.39.0


^ permalink raw reply related

* [PATCH 08/16] Input: adxl34x - unify dev_pm_ops using EXPORT_SIMPLE_DEV_PM_OPS()
From: Jonathan Cameron @ 2023-01-14 17:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov; +Cc: jic23, Jonathan Cameron, Michael Hennerich
In-Reply-To: <20230114171620.42891-1-jic23@kernel.org>

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

The I2C and SPI PM callbacks were identical (though wrapped in some
bouncing out to the bus specific container of the struct device and
then back again to get the drvdata).  As such rather than just moving
these to SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() take the opportunity
to unify the struct dev_pm_ops and use the new EXPORT_SIMPLE_DEV_PM_OPS()
macro so that we can drop the unused suspend and resume callbacks as well
as the structure if !CONFIG_PM_SLEEP without needing to mark the callbacks
__maybe_unused.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Michael Hennerich <michael.hennerich@analog.com>
---
 drivers/input/misc/adxl34x-i2c.c | 25 +------------------------
 drivers/input/misc/adxl34x-spi.c | 25 +------------------------
 drivers/input/misc/adxl34x.c     | 16 ++++++++++++----
 drivers/input/misc/adxl34x.h     |  4 ++--
 4 files changed, 16 insertions(+), 54 deletions(-)

diff --git a/drivers/input/misc/adxl34x-i2c.c b/drivers/input/misc/adxl34x-i2c.c
index a8ceea36d80a..1c75d98c85a7 100644
--- a/drivers/input/misc/adxl34x-i2c.c
+++ b/drivers/input/misc/adxl34x-i2c.c
@@ -105,29 +105,6 @@ static void adxl34x_i2c_remove(struct i2c_client *client)
 	adxl34x_remove(ac);
 }
 
-static int __maybe_unused adxl34x_i2c_suspend(struct device *dev)
-{
-	struct i2c_client *client = to_i2c_client(dev);
-	struct adxl34x *ac = i2c_get_clientdata(client);
-
-	adxl34x_suspend(ac);
-
-	return 0;
-}
-
-static int __maybe_unused adxl34x_i2c_resume(struct device *dev)
-{
-	struct i2c_client *client = to_i2c_client(dev);
-	struct adxl34x *ac = i2c_get_clientdata(client);
-
-	adxl34x_resume(ac);
-
-	return 0;
-}
-
-static SIMPLE_DEV_PM_OPS(adxl34x_i2c_pm, adxl34x_i2c_suspend,
-			 adxl34x_i2c_resume);
-
 static const struct i2c_device_id adxl34x_id[] = {
 	{ "adxl34x", 0 },
 	{ }
@@ -155,7 +132,7 @@ MODULE_DEVICE_TABLE(of, adxl34x_of_id);
 static struct i2c_driver adxl34x_driver = {
 	.driver = {
 		.name = "adxl34x",
-		.pm = &adxl34x_i2c_pm,
+		.pm = pm_sleep_ptr(&adxl34x_pm),
 		.of_match_table = adxl34x_of_id,
 	},
 	.probe_new = adxl34x_i2c_probe,
diff --git a/drivers/input/misc/adxl34x-spi.c b/drivers/input/misc/adxl34x-spi.c
index 91e44d4c66f7..f1094a8ccdd5 100644
--- a/drivers/input/misc/adxl34x-spi.c
+++ b/drivers/input/misc/adxl34x-spi.c
@@ -94,33 +94,10 @@ static void adxl34x_spi_remove(struct spi_device *spi)
 	adxl34x_remove(ac);
 }
 
-static int __maybe_unused adxl34x_spi_suspend(struct device *dev)
-{
-	struct spi_device *spi = to_spi_device(dev);
-	struct adxl34x *ac = spi_get_drvdata(spi);
-
-	adxl34x_suspend(ac);
-
-	return 0;
-}
-
-static int __maybe_unused adxl34x_spi_resume(struct device *dev)
-{
-	struct spi_device *spi = to_spi_device(dev);
-	struct adxl34x *ac = spi_get_drvdata(spi);
-
-	adxl34x_resume(ac);
-
-	return 0;
-}
-
-static SIMPLE_DEV_PM_OPS(adxl34x_spi_pm, adxl34x_spi_suspend,
-			 adxl34x_spi_resume);
-
 static struct spi_driver adxl34x_driver = {
 	.driver = {
 		.name = "adxl34x",
-		.pm = &adxl34x_spi_pm,
+		.pm = pm_sleep_ptr(&adxl34x_pm),
 	},
 	.probe   = adxl34x_spi_probe,
 	.remove  = adxl34x_spi_remove,
diff --git a/drivers/input/misc/adxl34x.c b/drivers/input/misc/adxl34x.c
index a4af314392a9..eecca671b588 100644
--- a/drivers/input/misc/adxl34x.c
+++ b/drivers/input/misc/adxl34x.c
@@ -412,8 +412,10 @@ static void __adxl34x_enable(struct adxl34x *ac)
 	AC_WRITE(ac, POWER_CTL, ac->pdata.power_mode | PCTL_MEASURE);
 }
 
-void adxl34x_suspend(struct adxl34x *ac)
+static int adxl34x_suspend(struct device *dev)
 {
+	struct adxl34x *ac = dev_get_drvdata(dev);
+
 	mutex_lock(&ac->mutex);
 
 	if (!ac->suspended && !ac->disabled && ac->opened)
@@ -422,11 +424,14 @@ void adxl34x_suspend(struct adxl34x *ac)
 	ac->suspended = true;
 
 	mutex_unlock(&ac->mutex);
+
+	return 0;
 }
-EXPORT_SYMBOL_GPL(adxl34x_suspend);
 
-void adxl34x_resume(struct adxl34x *ac)
+static int adxl34x_resume(struct device *dev)
 {
+	struct adxl34x *ac = dev_get_drvdata(dev);
+
 	mutex_lock(&ac->mutex);
 
 	if (ac->suspended && !ac->disabled && ac->opened)
@@ -435,8 +440,9 @@ void adxl34x_resume(struct adxl34x *ac)
 	ac->suspended = false;
 
 	mutex_unlock(&ac->mutex);
+
+	return 0;
 }
-EXPORT_SYMBOL_GPL(adxl34x_resume);
 
 static ssize_t adxl34x_disable_show(struct device *dev,
 				    struct device_attribute *attr, char *buf)
@@ -906,6 +912,8 @@ void adxl34x_remove(struct adxl34x *ac)
 }
 EXPORT_SYMBOL_GPL(adxl34x_remove);
 
+EXPORT_GPL_SIMPLE_DEV_PM_OPS(adxl34x_pm, adxl34x_suspend, adxl34x_resume);
+
 MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
 MODULE_DESCRIPTION("ADXL345/346 Three-Axis Digital Accelerometer Driver");
 MODULE_LICENSE("GPL");
diff --git a/drivers/input/misc/adxl34x.h b/drivers/input/misc/adxl34x.h
index febf85270fff..f9272a2e7a96 100644
--- a/drivers/input/misc/adxl34x.h
+++ b/drivers/input/misc/adxl34x.h
@@ -20,11 +20,11 @@ struct adxl34x_bus_ops {
 	int (*write)(struct device *, unsigned char, unsigned char);
 };
 
-void adxl34x_suspend(struct adxl34x *ac);
-void adxl34x_resume(struct adxl34x *ac);
 struct adxl34x *adxl34x_probe(struct device *dev, int irq,
 			      bool fifo_delay_default,
 			      const struct adxl34x_bus_ops *bops);
 void adxl34x_remove(struct adxl34x *ac);
 
+extern const struct dev_pm_ops adxl34x_pm;
+
 #endif
-- 
2.39.0


^ permalink raw reply related

* [PATCH 07/16] Input: ad714x - unify dev_pm_ops using EXPORT_SIMPLE_DEV_PM_OPS()
From: Jonathan Cameron @ 2023-01-14 17:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov; +Cc: jic23, Jonathan Cameron, Michael Hennerich
In-Reply-To: <20230114171620.42891-1-jic23@kernel.org>

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

The I2C and SPI PM callbacks were identical (though wrapped in some
bouncing out to the bus specific container of the struct device and
then back again to get the drvdata). As such rather than just moving
these to SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() take the opportunity
to unify the struct dev_pm_ops and use the new EXPORT_SIMPLE_DEV_PM_OPS()
macro so that we can drop the unused suspend and resume callbacks as well
as the structure if !CONFIG_PM_SLEEP without needing to mark the callbacks
__maybe_unused.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Michael Hennerich <michael.hennerich@analog.com>
---
 drivers/input/misc/ad714x-i2c.c | 14 +-------------
 drivers/input/misc/ad714x-spi.c | 14 +-------------
 drivers/input/misc/ad714x.c     | 12 ++++++------
 drivers/input/misc/ad714x.h     |  4 ++--
 4 files changed, 10 insertions(+), 34 deletions(-)

diff --git a/drivers/input/misc/ad714x-i2c.c b/drivers/input/misc/ad714x-i2c.c
index 5ef518a50e63..d8e39f4a57ac 100644
--- a/drivers/input/misc/ad714x-i2c.c
+++ b/drivers/input/misc/ad714x-i2c.c
@@ -12,18 +12,6 @@
 #include <linux/pm.h>
 #include "ad714x.h"
 
-static int __maybe_unused ad714x_i2c_suspend(struct device *dev)
-{
-	return ad714x_disable(i2c_get_clientdata(to_i2c_client(dev)));
-}
-
-static int __maybe_unused ad714x_i2c_resume(struct device *dev)
-{
-	return ad714x_enable(i2c_get_clientdata(to_i2c_client(dev)));
-}
-
-static SIMPLE_DEV_PM_OPS(ad714x_i2c_pm, ad714x_i2c_suspend, ad714x_i2c_resume);
-
 static int ad714x_i2c_write(struct ad714x_chip *chip,
 			    unsigned short reg, unsigned short data)
 {
@@ -96,7 +84,7 @@ MODULE_DEVICE_TABLE(i2c, ad714x_id);
 static struct i2c_driver ad714x_i2c_driver = {
 	.driver = {
 		.name = "ad714x_captouch",
-		.pm   = &ad714x_i2c_pm,
+		.pm   = pm_sleep_ptr(&ad714x_pm),
 	},
 	.probe_new = ad714x_i2c_probe,
 	.id_table = ad714x_id,
diff --git a/drivers/input/misc/ad714x-spi.c b/drivers/input/misc/ad714x-spi.c
index 7d3bf434620f..eb13b4cd6594 100644
--- a/drivers/input/misc/ad714x-spi.c
+++ b/drivers/input/misc/ad714x-spi.c
@@ -15,18 +15,6 @@
 #define AD714x_SPI_CMD_PREFIX      0xE000   /* bits 15:11 */
 #define AD714x_SPI_READ            BIT(10)
 
-static int __maybe_unused ad714x_spi_suspend(struct device *dev)
-{
-	return ad714x_disable(spi_get_drvdata(to_spi_device(dev)));
-}
-
-static int __maybe_unused ad714x_spi_resume(struct device *dev)
-{
-	return ad714x_enable(spi_get_drvdata(to_spi_device(dev)));
-}
-
-static SIMPLE_DEV_PM_OPS(ad714x_spi_pm, ad714x_spi_suspend, ad714x_spi_resume);
-
 static int ad714x_spi_read(struct ad714x_chip *chip,
 			   unsigned short reg, unsigned short *data, size_t len)
 {
@@ -103,7 +91,7 @@ static int ad714x_spi_probe(struct spi_device *spi)
 static struct spi_driver ad714x_spi_driver = {
 	.driver = {
 		.name	= "ad714x_captouch",
-		.pm	= &ad714x_spi_pm,
+		.pm	= pm_sleep_ptr(&ad714x_pm),
 	},
 	.probe		= ad714x_spi_probe,
 };
diff --git a/drivers/input/misc/ad714x.c b/drivers/input/misc/ad714x.c
index 43132d98feda..1acd8429c56c 100644
--- a/drivers/input/misc/ad714x.c
+++ b/drivers/input/misc/ad714x.c
@@ -1162,9 +1162,9 @@ struct ad714x_chip *ad714x_probe(struct device *dev, u16 bus_type, int irq,
 }
 EXPORT_SYMBOL(ad714x_probe);
 
-#ifdef CONFIG_PM
-int ad714x_disable(struct ad714x_chip *ad714x)
+static int ad714x_suspend(struct device *dev)
 {
+	struct ad714x_chip *ad714x = dev_get_drvdata(dev);
 	unsigned short data;
 
 	dev_dbg(ad714x->dev, "%s enter\n", __func__);
@@ -1178,10 +1178,10 @@ int ad714x_disable(struct ad714x_chip *ad714x)
 
 	return 0;
 }
-EXPORT_SYMBOL(ad714x_disable);
 
-int ad714x_enable(struct ad714x_chip *ad714x)
+static int ad714x_resume(struct device *dev)
 {
+	struct ad714x_chip *ad714x = dev_get_drvdata(dev);
 	dev_dbg(ad714x->dev, "%s enter\n", __func__);
 
 	mutex_lock(&ad714x->mutex);
@@ -1201,8 +1201,8 @@ int ad714x_enable(struct ad714x_chip *ad714x)
 
 	return 0;
 }
-EXPORT_SYMBOL(ad714x_enable);
-#endif
+
+EXPORT_SIMPLE_DEV_PM_OPS(ad714x_pm, ad714x_suspend, ad714x_resume);
 
 MODULE_DESCRIPTION("Analog Devices AD714X Capacitance Touch Sensor Driver");
 MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
diff --git a/drivers/input/misc/ad714x.h b/drivers/input/misc/ad714x.h
index af847b5f0d0e..dafa12325f27 100644
--- a/drivers/input/misc/ad714x.h
+++ b/drivers/input/misc/ad714x.h
@@ -8,6 +8,7 @@
 #ifndef _AD714X_H_
 #define _AD714X_H_
 
+#include <linux/pm.h>
 #include <linux/types.h>
 
 #define STAGE_NUM              12
@@ -45,8 +46,7 @@ struct ad714x_chip {
 
 };
 
-int ad714x_disable(struct ad714x_chip *ad714x);
-int ad714x_enable(struct ad714x_chip *ad714x);
+extern const struct dev_pm_ops ad714x_pm;
 struct ad714x_chip *ad714x_probe(struct device *dev, u16 bus_type, int irq,
 				 ad714x_read_t read, ad714x_write_t write);
 
-- 
2.39.0


^ permalink raw reply related

* [PATCH 06/16] Input: stmfts - switch to SYSTEM_SLEEP_/RUNTIME_PM_OPS() and pm_ptr()
From: Jonathan Cameron @ 2023-01-14 17:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov; +Cc: jic23, Jonathan Cameron, Andi Shyti
In-Reply-To: <20230114171620.42891-1-jic23@kernel.org>

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

SET_SYSTEM_SLEEP_PM_OPS() and SET_RUNTIME_PM_OPS() are deprecated as
they require explicit protection against unused function warnings.
The new combination of pm_ptr() and SYSTEM_SLEEP_PM_OPS()/
RUNTIME_PM_OPS() allows the compiler to see the functions,
thus suppressing the warning, but still allowing the unused code to be
removed. Thus also drop the __maybe_unused markings.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Andi Shyti <andi@etezian.org>
---
 drivers/input/touchscreen/stmfts.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/input/touchscreen/stmfts.c b/drivers/input/touchscreen/stmfts.c
index d092e89d40e8..fdbf5e68943c 100644
--- a/drivers/input/touchscreen/stmfts.c
+++ b/drivers/input/touchscreen/stmfts.c
@@ -742,7 +742,7 @@ static void stmfts_remove(struct i2c_client *client)
 	pm_runtime_disable(&client->dev);
 }
 
-static int __maybe_unused stmfts_runtime_suspend(struct device *dev)
+static int stmfts_runtime_suspend(struct device *dev)
 {
 	struct stmfts_data *sdata = dev_get_drvdata(dev);
 	int ret;
@@ -754,7 +754,7 @@ static int __maybe_unused stmfts_runtime_suspend(struct device *dev)
 	return ret;
 }
 
-static int __maybe_unused stmfts_runtime_resume(struct device *dev)
+static int stmfts_runtime_resume(struct device *dev)
 {
 	struct stmfts_data *sdata = dev_get_drvdata(dev);
 	int ret;
@@ -766,7 +766,7 @@ static int __maybe_unused stmfts_runtime_resume(struct device *dev)
 	return ret;
 }
 
-static int __maybe_unused stmfts_suspend(struct device *dev)
+static int stmfts_suspend(struct device *dev)
 {
 	struct stmfts_data *sdata = dev_get_drvdata(dev);
 
@@ -775,7 +775,7 @@ static int __maybe_unused stmfts_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused stmfts_resume(struct device *dev)
+static int stmfts_resume(struct device *dev)
 {
 	struct stmfts_data *sdata = dev_get_drvdata(dev);
 
@@ -783,8 +783,8 @@ static int __maybe_unused stmfts_resume(struct device *dev)
 }
 
 static const struct dev_pm_ops stmfts_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(stmfts_suspend, stmfts_resume)
-	SET_RUNTIME_PM_OPS(stmfts_runtime_suspend, stmfts_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(stmfts_suspend, stmfts_resume)
+	RUNTIME_PM_OPS(stmfts_runtime_suspend, stmfts_runtime_resume, NULL)
 };
 
 #ifdef CONFIG_OF
@@ -805,7 +805,7 @@ static struct i2c_driver stmfts_driver = {
 	.driver = {
 		.name = STMFTS_DEV_NAME,
 		.of_match_table = of_match_ptr(stmfts_of_match),
-		.pm = &stmfts_pm_ops,
+		.pm = pm_ptr(&stmfts_pm_ops),
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
 	},
 	.probe_new = stmfts_probe,
-- 
2.39.0


^ permalink raw reply related

* [PATCH 05/16] Input: rmi4 - switch to SYSTEM_SLEEP/RUNTIME_PM_OPS() and pm_ptr()
From: Jonathan Cameron @ 2023-01-14 17:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov
  Cc: jic23, Jonathan Cameron, Matthias Schiffer, Lyude Paul,
	Andrew Duggan
In-Reply-To: <20230114171620.42891-1-jic23@kernel.org>

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

SET_SYSTEM_SLEEP_PM_OPS() and SET_RUNTIME_PM_OPS() are deprecated
as they requires explicit protection against unused function warnings.
The new combination of pm_ptr() and SYSTEM_SLEEP_PM_OPS() /
RUNTIME_PM_OPS() allows the compiler to see the functions,
thus suppressing the warning, but still allowing the unused code to
be removed. Thus also drop the #ifdef guards.

Whilst all 3 sets of callbacks are similar, there are small differences
that make it challenging to use a single pm_dev_ops structure - hence
leave the duplication as it stands.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
Cc: Lyude Paul <lyude@redhat.com>
Cc: Andrew Duggan <aduggan@synaptics.com>
---
 drivers/input/rmi4/rmi_i2c.c   | 11 +++--------
 drivers/input/rmi4/rmi_smbus.c | 15 +++++++--------
 drivers/input/rmi4/rmi_spi.c   | 11 +++--------
 3 files changed, 13 insertions(+), 24 deletions(-)

diff --git a/drivers/input/rmi4/rmi_i2c.c b/drivers/input/rmi4/rmi_i2c.c
index f2b75c6d3224..d69569ce8d8d 100644
--- a/drivers/input/rmi4/rmi_i2c.c
+++ b/drivers/input/rmi4/rmi_i2c.c
@@ -287,7 +287,6 @@ static int rmi_i2c_probe(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int rmi_i2c_suspend(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
@@ -323,9 +322,7 @@ static int rmi_i2c_resume(struct device *dev)
 
 	return ret;
 }
-#endif
 
-#ifdef CONFIG_PM
 static int rmi_i2c_runtime_suspend(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
@@ -361,12 +358,10 @@ static int rmi_i2c_runtime_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
 static const struct dev_pm_ops rmi_i2c_pm = {
-	SET_SYSTEM_SLEEP_PM_OPS(rmi_i2c_suspend, rmi_i2c_resume)
-	SET_RUNTIME_PM_OPS(rmi_i2c_runtime_suspend, rmi_i2c_runtime_resume,
-			   NULL)
+	SYSTEM_SLEEP_PM_OPS(rmi_i2c_suspend, rmi_i2c_resume)
+	RUNTIME_PM_OPS(rmi_i2c_runtime_suspend, rmi_i2c_runtime_resume, NULL)
 };
 
 static const struct i2c_device_id rmi_id[] = {
@@ -378,7 +373,7 @@ MODULE_DEVICE_TABLE(i2c, rmi_id);
 static struct i2c_driver rmi_i2c_driver = {
 	.driver = {
 		.name	= "rmi4_i2c",
-		.pm	= &rmi_i2c_pm,
+		.pm	= pm_ptr(&rmi_i2c_pm),
 		.of_match_table = of_match_ptr(rmi_i2c_of_match),
 	},
 	.id_table	= rmi_id,
diff --git a/drivers/input/rmi4/rmi_smbus.c b/drivers/input/rmi4/rmi_smbus.c
index 8a9ee2bd7402..4bf0e1df6a4a 100644
--- a/drivers/input/rmi4/rmi_smbus.c
+++ b/drivers/input/rmi4/rmi_smbus.c
@@ -344,7 +344,7 @@ static void rmi_smb_remove(struct i2c_client *client)
 	rmi_unregister_transport_device(&rmi_smb->xport);
 }
 
-static int __maybe_unused rmi_smb_suspend(struct device *dev)
+static int rmi_smb_suspend(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct rmi_smb_xport *rmi_smb = i2c_get_clientdata(client);
@@ -357,7 +357,7 @@ static int __maybe_unused rmi_smb_suspend(struct device *dev)
 	return ret;
 }
 
-static int __maybe_unused rmi_smb_runtime_suspend(struct device *dev)
+static int rmi_smb_runtime_suspend(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct rmi_smb_xport *rmi_smb = i2c_get_clientdata(client);
@@ -370,7 +370,7 @@ static int __maybe_unused rmi_smb_runtime_suspend(struct device *dev)
 	return ret;
 }
 
-static int __maybe_unused rmi_smb_resume(struct device *dev)
+static int rmi_smb_resume(struct device *dev)
 {
 	struct i2c_client *client = container_of(dev, struct i2c_client, dev);
 	struct rmi_smb_xport *rmi_smb = i2c_get_clientdata(client);
@@ -388,7 +388,7 @@ static int __maybe_unused rmi_smb_resume(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused rmi_smb_runtime_resume(struct device *dev)
+static int rmi_smb_runtime_resume(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct rmi_smb_xport *rmi_smb = i2c_get_clientdata(client);
@@ -402,9 +402,8 @@ static int __maybe_unused rmi_smb_runtime_resume(struct device *dev)
 }
 
 static const struct dev_pm_ops rmi_smb_pm = {
-	SET_SYSTEM_SLEEP_PM_OPS(rmi_smb_suspend, rmi_smb_resume)
-	SET_RUNTIME_PM_OPS(rmi_smb_runtime_suspend, rmi_smb_runtime_resume,
-			   NULL)
+	SYSTEM_SLEEP_PM_OPS(rmi_smb_suspend, rmi_smb_resume)
+	RUNTIME_PM_OPS(rmi_smb_runtime_suspend, rmi_smb_runtime_resume, NULL)
 };
 
 static const struct i2c_device_id rmi_id[] = {
@@ -416,7 +415,7 @@ MODULE_DEVICE_TABLE(i2c, rmi_id);
 static struct i2c_driver rmi_smb_driver = {
 	.driver = {
 		.name	= "rmi4_smbus",
-		.pm	= &rmi_smb_pm,
+		.pm	= pm_ptr(&rmi_smb_pm),
 	},
 	.id_table	= rmi_id,
 	.probe_new	= rmi_smb_probe,
diff --git a/drivers/input/rmi4/rmi_spi.c b/drivers/input/rmi4/rmi_spi.c
index c82edda66b23..c5c5e7f3401e 100644
--- a/drivers/input/rmi4/rmi_spi.c
+++ b/drivers/input/rmi4/rmi_spi.c
@@ -447,7 +447,6 @@ static int rmi_spi_probe(struct spi_device *spi)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int rmi_spi_suspend(struct device *dev)
 {
 	struct spi_device *spi = to_spi_device(dev);
@@ -473,9 +472,7 @@ static int rmi_spi_resume(struct device *dev)
 
 	return ret;
 }
-#endif
 
-#ifdef CONFIG_PM
 static int rmi_spi_runtime_suspend(struct device *dev)
 {
 	struct spi_device *spi = to_spi_device(dev);
@@ -501,12 +498,10 @@ static int rmi_spi_runtime_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
 static const struct dev_pm_ops rmi_spi_pm = {
-	SET_SYSTEM_SLEEP_PM_OPS(rmi_spi_suspend, rmi_spi_resume)
-	SET_RUNTIME_PM_OPS(rmi_spi_runtime_suspend, rmi_spi_runtime_resume,
-			   NULL)
+	SYSTEM_SLEEP_PM_OPS(rmi_spi_suspend, rmi_spi_resume)
+	RUNTIME_PM_OPS(rmi_spi_runtime_suspend, rmi_spi_runtime_resume, NULL)
 };
 
 static const struct spi_device_id rmi_id[] = {
@@ -518,7 +513,7 @@ MODULE_DEVICE_TABLE(spi, rmi_id);
 static struct spi_driver rmi_spi_driver = {
 	.driver = {
 		.name	= "rmi4_spi",
-		.pm	= &rmi_spi_pm,
+		.pm	= pm_ptr(&rmi_spi_pm),
 		.of_match_table = of_match_ptr(rmi_spi_of_match),
 	},
 	.id_table	= rmi_id,
-- 
2.39.0


^ permalink raw reply related

* [PATCH 04/16] Input: s6sy761 - switch to SYSTEM_SLEEP_/RUNTIME_PM_OPS() and pm_ptr()
From: Jonathan Cameron @ 2023-01-14 17:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov
  Cc: jic23, Jonathan Cameron, Caleb Connolly, Andi Shyti
In-Reply-To: <20230114171620.42891-1-jic23@kernel.org>

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

SET_SYSTEM_SLEEP_PM_OPS() and SET_RUNTIME_PM_OPS() are deprecated as
they require explicit protection against unused function warnings.
The new combination of pm_ptr() and SYSTEM_SLEEP_PM_OPS()/
RUNTIME_PM_OPS() allows the compiler to see the functions,
thus suppressing the warning, but still allowing the unused code to be
removed. Thus also drop the __maybe_unused markings.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Caleb Connolly <caleb@connolly.tech>
Cc: Andi Shyti <andi@etezian.org>
---
 drivers/input/touchscreen/s6sy761.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/input/touchscreen/s6sy761.c b/drivers/input/touchscreen/s6sy761.c
index cc417c03aaca..371cf4848ad5 100644
--- a/drivers/input/touchscreen/s6sy761.c
+++ b/drivers/input/touchscreen/s6sy761.c
@@ -479,7 +479,7 @@ static void s6sy761_remove(struct i2c_client *client)
 	pm_runtime_disable(&client->dev);
 }
 
-static int __maybe_unused s6sy761_runtime_suspend(struct device *dev)
+static int s6sy761_runtime_suspend(struct device *dev)
 {
 	struct s6sy761_data *sdata = dev_get_drvdata(dev);
 
@@ -487,7 +487,7 @@ static int __maybe_unused s6sy761_runtime_suspend(struct device *dev)
 				S6SY761_APPLICATION_MODE, S6SY761_APP_SLEEP);
 }
 
-static int __maybe_unused s6sy761_runtime_resume(struct device *dev)
+static int s6sy761_runtime_resume(struct device *dev)
 {
 	struct s6sy761_data *sdata = dev_get_drvdata(dev);
 
@@ -495,7 +495,7 @@ static int __maybe_unused s6sy761_runtime_resume(struct device *dev)
 				S6SY761_APPLICATION_MODE, S6SY761_APP_NORMAL);
 }
 
-static int __maybe_unused s6sy761_suspend(struct device *dev)
+static int s6sy761_suspend(struct device *dev)
 {
 	struct s6sy761_data *sdata = dev_get_drvdata(dev);
 
@@ -504,7 +504,7 @@ static int __maybe_unused s6sy761_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused s6sy761_resume(struct device *dev)
+static int s6sy761_resume(struct device *dev)
 {
 	struct s6sy761_data *sdata = dev_get_drvdata(dev);
 
@@ -514,9 +514,8 @@ static int __maybe_unused s6sy761_resume(struct device *dev)
 }
 
 static const struct dev_pm_ops s6sy761_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(s6sy761_suspend, s6sy761_resume)
-	SET_RUNTIME_PM_OPS(s6sy761_runtime_suspend,
-				s6sy761_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(s6sy761_suspend, s6sy761_resume)
+	RUNTIME_PM_OPS(s6sy761_runtime_suspend, s6sy761_runtime_resume, NULL)
 };
 
 #ifdef CONFIG_OF
@@ -537,7 +536,7 @@ static struct i2c_driver s6sy761_driver = {
 	.driver = {
 		.name = S6SY761_DEV_NAME,
 		.of_match_table = of_match_ptr(s6sy761_of_match),
-		.pm = &s6sy761_pm_ops,
+		.pm = pm_ptr(&s6sy761_pm_ops),
 	},
 	.probe_new = s6sy761_probe,
 	.remove = s6sy761_remove,
-- 
2.39.0


^ permalink raw reply related

* [PATCH 03/16] Input: samsung-keypad - switch to pm_ptr() and SYSTEM_SLEEP/RUNTIME_PM_OPS()
From: Jonathan Cameron @ 2023-01-14 17:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov; +Cc: jic23, Jonathan Cameron
In-Reply-To: <20230114171620.42891-1-jic23@kernel.org>

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

The SET_ variants are deprecated as they require explicit protection
against unused function warnings.  The new combination of pm_ptr()
and SYSTEM_SLEEP/RUNTIME_DEV_PM_OPS() allow the compiler to see the
functions, thus suppressing the warning, but still allowing the unused
code to be removed. Thus also drop the #ifdef guards.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/input/keyboard/samsung-keypad.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c
index df0258dcf89e..09e883ea1352 100644
--- a/drivers/input/keyboard/samsung-keypad.c
+++ b/drivers/input/keyboard/samsung-keypad.c
@@ -458,7 +458,6 @@ static int samsung_keypad_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM
 static int samsung_keypad_runtime_suspend(struct device *dev)
 {
 	struct platform_device *pdev = to_platform_device(dev);
@@ -503,9 +502,7 @@ static int samsung_keypad_runtime_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
-#ifdef CONFIG_PM_SLEEP
 static void samsung_keypad_toggle_wakeup(struct samsung_keypad *keypad,
 					 bool enable)
 {
@@ -563,12 +560,11 @@ static int samsung_keypad_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
 static const struct dev_pm_ops samsung_keypad_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(samsung_keypad_suspend, samsung_keypad_resume)
-	SET_RUNTIME_PM_OPS(samsung_keypad_runtime_suspend,
-			   samsung_keypad_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(samsung_keypad_suspend, samsung_keypad_resume)
+	RUNTIME_PM_OPS(samsung_keypad_runtime_suspend,
+		       samsung_keypad_runtime_resume, NULL)
 };
 
 #ifdef CONFIG_OF
@@ -598,7 +594,7 @@ static struct platform_driver samsung_keypad_driver = {
 	.driver		= {
 		.name	= "samsung-keypad",
 		.of_match_table = of_match_ptr(samsung_keypad_dt_match),
-		.pm	= &samsung_keypad_pm_ops,
+		.pm	= pm_ptr(&samsung_keypad_pm_ops),
 	},
 	.id_table	= samsung_keypad_driver_ids,
 };
-- 
2.39.0


^ permalink raw reply related

* [PATCH 02/16] Input: axp20x-pek - switch to SYSTEM_SLEEP_PM_OPS() and pm_sleep_ptr()
From: Jonathan Cameron @ 2023-01-14 17:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov; +Cc: jic23, Jonathan Cameron, Hans de Goede
In-Reply-To: <20230114171620.42891-1-jic23@kernel.org>

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

SET_SYSTEM_SLEEP_PM_OPS() is deprecated as it requires explicit protection
against unused function warnings.  The new combination of pm_sleep_ptr()
and SYSTEM_SLEEP_PM_OPS() allows the compiler to see the functions,
thus suppressing the warning, but still allowing the unused code to be
removed. Thus also drop the __maybe_unused markings.  Here the
additional .resume_noirq callback is protected with pm_sleep_ptr(). This
isn't strictly necessary but is done for consistency with the other
callbacks.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Hans de Goede <hdegoede@redhat.com>
---
 drivers/input/misc/axp20x-pek.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
index 04da7916eb70..4581606a28d6 100644
--- a/drivers/input/misc/axp20x-pek.c
+++ b/drivers/input/misc/axp20x-pek.c
@@ -336,7 +336,7 @@ static int axp20x_pek_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int __maybe_unused axp20x_pek_suspend(struct device *dev)
+static int axp20x_pek_suspend(struct device *dev)
 {
 	struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
 
@@ -355,7 +355,7 @@ static int __maybe_unused axp20x_pek_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused axp20x_pek_resume(struct device *dev)
+static int axp20x_pek_resume(struct device *dev)
 {
 	struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
 
@@ -389,10 +389,8 @@ static int __maybe_unused axp20x_pek_resume_noirq(struct device *dev)
 }
 
 static const struct dev_pm_ops axp20x_pek_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(axp20x_pek_suspend, axp20x_pek_resume)
-#ifdef CONFIG_PM_SLEEP
-	.resume_noirq = axp20x_pek_resume_noirq,
-#endif
+	SYSTEM_SLEEP_PM_OPS(axp20x_pek_suspend, axp20x_pek_resume)
+	.resume_noirq = pm_sleep_ptr(axp20x_pek_resume_noirq),
 };
 
 static const struct platform_device_id axp_pek_id_match[] = {
@@ -413,7 +411,7 @@ static struct platform_driver axp20x_pek_driver = {
 	.id_table	= axp_pek_id_match,
 	.driver		= {
 		.name		= "axp20x-pek",
-		.pm		= &axp20x_pek_pm_ops,
+		.pm		= pm_sleep_ptr(&axp20x_pek_pm_ops),
 		.dev_groups	= axp20x_groups,
 	},
 };
-- 
2.39.0


^ permalink raw reply related

* [PATCH 01/16] Input: cyapa - switch to SYSTEM_SLEEP/RUNTIME_PM_OPS() and pm_ptr()
From: Jonathan Cameron @ 2023-01-14 17:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov; +Cc: jic23, Jonathan Cameron
In-Reply-To: <20230114171620.42891-1-jic23@kernel.org>

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

SET_SYSTEM_SLEEP_PM_OPS() and SET_RUNTIME_PM_OPS() are deprecated as
they require explicit protection against unused function warnings.
The new combination of pm_ptr() and SYSTEM_SLEEP_PM_OPS()/
RUNTIME_PM_OPS() allows the compiler to see the functions,
thus suppressing the warning, but still allowing the unused code to be
removed. Thus also drop the __maybe_unused markings.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/input/mouse/cyapa.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c
index 7e88a6ec7989..dd7b0d70d791 100644
--- a/drivers/input/mouse/cyapa.c
+++ b/drivers/input/mouse/cyapa.c
@@ -1349,7 +1349,7 @@ static int cyapa_probe(struct i2c_client *client)
 	return 0;
 }
 
-static int __maybe_unused cyapa_suspend(struct device *dev)
+static int cyapa_suspend(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct cyapa *cyapa = i2c_get_clientdata(client);
@@ -1397,7 +1397,7 @@ static int __maybe_unused cyapa_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused cyapa_resume(struct device *dev)
+static int cyapa_resume(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct cyapa *cyapa = i2c_get_clientdata(client);
@@ -1424,7 +1424,7 @@ static int __maybe_unused cyapa_resume(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused cyapa_runtime_suspend(struct device *dev)
+static int cyapa_runtime_suspend(struct device *dev)
 {
 	struct cyapa *cyapa = dev_get_drvdata(dev);
 	int error;
@@ -1439,7 +1439,7 @@ static int __maybe_unused cyapa_runtime_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused cyapa_runtime_resume(struct device *dev)
+static int cyapa_runtime_resume(struct device *dev)
 {
 	struct cyapa *cyapa = dev_get_drvdata(dev);
 	int error;
@@ -1453,8 +1453,8 @@ static int __maybe_unused cyapa_runtime_resume(struct device *dev)
 }
 
 static const struct dev_pm_ops cyapa_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(cyapa_suspend, cyapa_resume)
-	SET_RUNTIME_PM_OPS(cyapa_runtime_suspend, cyapa_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(cyapa_suspend, cyapa_resume)
+	RUNTIME_PM_OPS(cyapa_runtime_suspend, cyapa_runtime_resume, NULL)
 };
 
 static const struct i2c_device_id cyapa_id_table[] = {
@@ -1484,7 +1484,7 @@ MODULE_DEVICE_TABLE(of, cyapa_of_match);
 static struct i2c_driver cyapa_driver = {
 	.driver = {
 		.name = "cyapa",
-		.pm = &cyapa_pm_ops,
+		.pm = pm_ptr(&cyapa_pm_ops),
 		.acpi_match_table = ACPI_PTR(cyapa_acpi_id),
 		.of_match_table = of_match_ptr(cyapa_of_match),
 	},
-- 
2.39.0


^ permalink raw reply related

* [PATCH 00/16] Input: Switch to new PM macros set 3
From: Jonathan Cameron @ 2023-01-14 17:16 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov
  Cc: jic23, Jonathan Cameron, Hans de Goede, Caleb Connolly,
	Andi Shyti, Matthias Schiffer, Lyude Paul, Andrew Duggan,
	Michael Hennerich, Javier Martinez Canillas, Linus Walleij

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Continuation of
https://lore.kernel.org/all/20230102181842.718010-1-jic23@kernel.org/

This time we have most of the remaining drivers where the changes needed
are more complex than the earlier straight conversions.

A separate series will deal with pm80x as the cleanup for that will
extend to MFD and RTC trees and cannot easily be broken up due to
some changes in exports.

There is a general mixture of cases in here:
1) More complex direct conversions - typically drivers with separate
   sleep and runtime pm ops.
2) Cases where the callbacks or struct dev_pm_ops is exported to
   multiple modules.
3) Refactors that avoid duplication of callbacks or exports.
4) A tweak to the core input handling to use the new macros - this
   is different from the driver changes, but seemed sensible.

Note there are a few cases in here where I a much more minimal
set of callbacks is provided than DEFINE_SIMPLE_DEV_PM_OPS() and
friends would set. I don't know the history behind those so whilst
they might well be fine converted to the generic macros, I've
left them alone.

Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Caleb Connolly <caleb@connolly.tech>
Cc: Andi Shyti <andi@etezian.org>
Cc: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
Cc: Lyude Paul <lyude@redhat.com>
Cc: Andrew Duggan <aduggan@synaptics.com>
Cc: Michael Hennerich <michael.hennerich@analog.com>
Cc: Javier Martinez Canillas <javier@dowhile0.org>
Cc: Linus Walleij <linus.walleij@linaro.org>

Jonathan Cameron (16):
  Input: cyapa - switch to SYSTEM_SLEEP/RUNTIME_PM_OPS() and pm_ptr()
  Input: axp20x-pek - switch to SYSTEM_SLEEP_PM_OPS() and pm_sleep_ptr()
  Input: samsung-keypad - switch to pm_ptr() and
    SYSTEM_SLEEP/RUNTIME_PM_OPS()
  Input: s6sy761 - switch to SYSTEM_SLEEP_/RUNTIME_PM_OPS() and pm_ptr()
  Input: rmi4 - switch to SYSTEM_SLEEP/RUNTIME_PM_OPS() and pm_ptr()
  Input: stmfts - switch to SYSTEM_SLEEP_/RUNTIME_PM_OPS() and pm_ptr()
  Input: ad714x - unify dev_pm_ops using EXPORT_SIMPLE_DEV_PM_OPS()
  Input: adxl34x - unify dev_pm_ops using EXPORT_SIMPLE_DEV_PM_OPS()
  Input: tsc200x - use EXPORT_GPL_SIMPLE_DEV_PM_OPS()
  Input: cyttsp4 - use EXPORT_GPL_RUNTIME_DEV_PM_OPS()
  Input: cyttsp - use EXPORT_GPL_SIMPLE_DEV_PM_OPS()
  Input: applespi - use pm_sleep_ptr() and SYSTEM_SLEEP_PM_OPS()
  Input: omap4-keyad - use pm_ptr() and RUNTIME_DEV_PM_OPS()
  Input: Use pm_sleep_ptr() to avoid need for ifdef CONFIG_PM_SLEEP
  Input: cma3000 - use pm_sleep_ptr() to allow removal of ifdef
    CONFIG_PM guards
  Input: wistron_btns -  use pm_sleep_ptr() to allow removal of ifdef
    CONFIG_PM guards

 drivers/input/input.c                    |  7 ++-----
 drivers/input/keyboard/applespi.c        | 10 +++++-----
 drivers/input/keyboard/omap4-keypad.c    |  6 +++---
 drivers/input/keyboard/samsung-keypad.c  | 12 ++++--------
 drivers/input/misc/ad714x-i2c.c          | 14 +------------
 drivers/input/misc/ad714x-spi.c          | 14 +------------
 drivers/input/misc/ad714x.c              | 12 ++++++------
 drivers/input/misc/ad714x.h              |  4 ++--
 drivers/input/misc/adxl34x-i2c.c         | 25 +-----------------------
 drivers/input/misc/adxl34x-spi.c         | 25 +-----------------------
 drivers/input/misc/adxl34x.c             | 16 +++++++++++----
 drivers/input/misc/adxl34x.h             |  4 ++--
 drivers/input/misc/axp20x-pek.c          | 12 +++++-------
 drivers/input/misc/cma3000_d0x_i2c.c     |  6 +-----
 drivers/input/misc/wistron_btns.c        |  6 +-----
 drivers/input/mouse/cyapa.c              | 14 ++++++-------
 drivers/input/rmi4/rmi_i2c.c             | 11 +++--------
 drivers/input/rmi4/rmi_smbus.c           | 15 +++++++-------
 drivers/input/rmi4/rmi_spi.c             | 11 +++--------
 drivers/input/touchscreen/cyttsp4_core.c |  9 ++-------
 drivers/input/touchscreen/cyttsp4_i2c.c  |  2 +-
 drivers/input/touchscreen/cyttsp4_spi.c  |  2 +-
 drivers/input/touchscreen/cyttsp_core.c  |  7 +++----
 drivers/input/touchscreen/cyttsp_i2c.c   |  2 +-
 drivers/input/touchscreen/cyttsp_spi.c   |  2 +-
 drivers/input/touchscreen/s6sy761.c      | 15 +++++++-------
 drivers/input/touchscreen/stmfts.c       | 14 ++++++-------
 drivers/input/touchscreen/tsc2004.c      |  2 +-
 drivers/input/touchscreen/tsc2005.c      |  2 +-
 drivers/input/touchscreen/tsc200x-core.c |  7 +++----
 30 files changed, 95 insertions(+), 193 deletions(-)

-- 
2.39.0


^ permalink raw reply

* Re: remove arch/sh
From: Rob Landley @ 2023-01-13 23:32 UTC (permalink / raw)
  To: John Paul Adrian Glaubitz, Geert Uytterhoeven
  Cc: Christoph Hellwig, Yoshinori Sato, Rich Felker, Arnd Bergmann,
	Greg Kroah-Hartman, Laurent Pinchart, Kieran Bingham,
	Geert Uytterhoeven, linux-kernel, linux-watchdog, devicetree,
	linux-arch, dmaengine, dri-devel, linux-renesas-soc, linux-i2c,
	linux-input, linux-media, linux-mmc, linux-mtd, netdev,
	linux-gpio, linux-rtc, linux-spi, linux-serial, linux-usb,
	linux-fbdev, alsa-devel, linux-sh
In-Reply-To: <fe09d811-e290-821d-ec8b-75936b6583c2@physik.fu-berlin.de>

On 1/13/23 13:05, John Paul Adrian Glaubitz wrote:
> Hi Rob!
> 
> On 1/13/23 20:11, Rob Landley wrote:
>> There is definitely interest in this architecture. I'm aware Rich hasn't been
>> the most responsive maintainer. (I'm told he's on vacation with his family at
>> the moment, according to the text I got about this issue from the J-core
>> hardware guys in Japan.)
> 
> Well, maybe we can just give it a try together ...

Jeff Dionne said he'd make himself available to answer hardware questions. (He
said he maintained some Linux ports 20 years ago, but isn't current with Linux
plumbing. Last month he was digging through the guts of vxworks, and the project
before that was some sort of BSD I think?)

I _do_ maintain Linux patches, I just generally don't bother to repost them
endlessly. Here's my "on top of 6.1" stack for example, each of which links to
at least one time it was posted to linux-kernel:

https://landley.net/toybox/downloads/binaries/mkroot/0.8.9/linux-patches/

>> The main reason we haven't converted everything to device tree is we only have
>> access to test hardware for a subset of the boards. Pruning the list of
>> supported boards and converting the rest to device tree might make sense. We can
>> always add/convert boards back later...
> 
> There is a patch by Yoshinori Sato which adds device tree support to SH. Maybe we
> can revive it.

The turtle board is device tree and has been since it was merged. The
infrastructure is there, the question is converting over boards and testing
them, or deciding to prune them. Did Sato-san convert many boards? (I'm not
finding his patch via google...)

> Adrian

Rob

^ permalink raw reply

* Re: remove arch/sh
From: John Paul Adrian Glaubitz @ 2023-01-13 19:05 UTC (permalink / raw)
  To: Rob Landley, Geert Uytterhoeven
  Cc: Christoph Hellwig, Yoshinori Sato, Rich Felker, Arnd Bergmann,
	Greg Kroah-Hartman, Laurent Pinchart, Kieran Bingham,
	Geert Uytterhoeven, linux-kernel, linux-watchdog, devicetree,
	linux-arch, dmaengine, dri-devel, linux-renesas-soc, linux-i2c,
	linux-input, linux-media, linux-mmc, linux-mtd, netdev,
	linux-gpio, linux-rtc, linux-spi, linux-serial, linux-usb,
	linux-fbdev, alsa-devel, linux-sh
In-Reply-To: <6891afb6-4190-6a52-0319-745b3f138d97@landley.net>

Hi Rob!

On 1/13/23 20:11, Rob Landley wrote:
>> I actually would be willing to do it but I'm a bit hesitant as I'm not 100%
>> sure my skills are sufficient. Maybe if someone can assist me?
> 
> My skills aren't sufficient and I dunno how much time I have, but I can
> certainly assist. I test sh4 regularlyish and it's in the list of architectures
> I ship binaries and tiny VM images for, just refreshed tuesday:
> 
> https://landley.net/toybox/downloads/binaries/0.8.9/
> https://landley.net/toybox/downloads/binaries/mkroot/0.8.9/
> 
> (The sh2eb isn't a VM, it's a physical board I have here...)
> 
> There is definitely interest in this architecture. I'm aware Rich hasn't been
> the most responsive maintainer. (I'm told he's on vacation with his family at
> the moment, according to the text I got about this issue from the J-core
> hardware guys in Japan.)

Well, maybe we can just give it a try together ...

> The main reason we haven't converted everything to device tree is we only have
> access to test hardware for a subset of the boards. Pruning the list of
> supported boards and converting the rest to device tree might make sense. We can
> always add/convert boards back later...

There is a patch by Yoshinori Sato which adds device tree support to SH. Maybe we
can revive it.

Adrian

-- 
  .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
   `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913


^ permalink raw reply

* Re: remove arch/sh
From: Rob Landley @ 2023-01-13 19:11 UTC (permalink / raw)
  To: John Paul Adrian Glaubitz, Geert Uytterhoeven
  Cc: Christoph Hellwig, Yoshinori Sato, Rich Felker, Arnd Bergmann,
	Greg Kroah-Hartman, Laurent Pinchart, Kieran Bingham,
	Geert Uytterhoeven, linux-kernel, linux-watchdog, devicetree,
	linux-arch, dmaengine, dri-devel, linux-renesas-soc, linux-i2c,
	linux-input, linux-media, linux-mmc, linux-mtd, netdev,
	linux-gpio, linux-rtc, linux-spi, linux-serial, linux-usb,
	linux-fbdev, alsa-devel, linux-sh
In-Reply-To: <142532fb-5997-bdc1-0811-a80ae33f4ba4@physik.fu-berlin.de>

On 1/13/23 02:52, John Paul Adrian Glaubitz wrote:
> Hi Geert!
> 
> On 1/13/23 09:26, Geert Uytterhoeven wrote:
>> Indeed.  The main issue is not the lack of people sending patches and
>> fixes, but those patches never being applied by the maintainers.
>> Perhaps someone is willing to stand up to take over maintainership?
> 
> I actually would be willing to do it but I'm a bit hesitant as I'm not 100%
> sure my skills are sufficient. Maybe if someone can assist me?

My skills aren't sufficient and I dunno how much time I have, but I can
certainly assist. I test sh4 regularlyish and it's in the list of architectures
I ship binaries and tiny VM images for, just refreshed tuesday:

https://landley.net/toybox/downloads/binaries/0.8.9/
https://landley.net/toybox/downloads/binaries/mkroot/0.8.9/

(The sh2eb isn't a VM, it's a physical board I have here...)

There is definitely interest in this architecture. I'm aware Rich hasn't been
the most responsive maintainer. (I'm told he's on vacation with his family at
the moment, according to the text I got about this issue from the J-core
hardware guys in Japan.)

The main reason we haven't converted everything to device tree is we only have
access to test hardware for a subset of the boards. Pruning the list of
supported boards and converting the rest to device tree might make sense. We can
always add/convert boards back later...

Rob

^ permalink raw reply

* Re: [PATCH] driver: input: matric-keypad: switch to gpiod API
From: Andy Shevchenko @ 2023-01-13 18:43 UTC (permalink / raw)
  To: Gireesh.Hiremath
  Cc: linux-input, linux-kernel, dmitry.torokhov, Jonathan.Cameron,
	lis8215, sjoerd.simons, VinayKumar.Shettar,
	Govindaraji.Sivanantham, anaclaudia.dias
In-Reply-To: <20230113062538.1537-1-Gireesh.Hiremath@in.bosch.com>

On Fri, Jan 13, 2023 at 06:25:38AM +0000, Gireesh.Hiremath@in.bosch.com wrote:
> From: Gireesh Hiremath <Gireesh.Hiremath@in.bosch.com>

Thank you for the patch, my comments below.

> switch to new gpio descriptor based API

Please, respect English grammar and punctuation.

Also, you have a typo in the Subject besides the fact that the template for
Input subsystem is different. So prefix has to be changed as well.

...

>  	bool level_on = !pdata->active_low;
>  
>  	if (on) {
> -		gpio_direction_output(pdata->col_gpios[col], level_on);
> +		gpiod_direction_output(pdata->col_gpios[col], level_on);
>  	} else {
> -		gpio_set_value_cansleep(pdata->col_gpios[col], !level_on);
> +		gpiod_set_value_cansleep(pdata->col_gpios[col], !level_on);
>  	}

I believe it's not so trivial. The GPIO descriptor already has encoded the
level information and above one as below are not clear now.

> -	return gpio_get_value_cansleep(pdata->row_gpios[row]) ?
> +	return gpiod_get_value_cansleep(pdata->row_gpios[row]) ?
>  			!pdata->active_low : pdata->active_low;

...

> -		err = gpio_request(pdata->col_gpios[i], "matrix_kbd_col");
> +		err = gpiod_direction_output(pdata->col_gpios[i], !pdata->active_low);

>  	while (--i >= 0)
> -		gpio_free(pdata->row_gpios[i]);
> +		gpiod_put(pdata->row_gpios[i]);

This looks like an incorrect change.

>  	while (--i >= 0)
> -		gpio_free(pdata->col_gpios[i]);
> +		gpiod_put(pdata->col_gpios[i]);

So does this.

Since you dropped gpio_request() you need to drop gpio_free() as well,
and not replace it.

...

>  	for (i = 0; i < nrow; i++) {
> -		ret = of_get_named_gpio(np, "row-gpios", i);
> -		if (ret < 0)

> -			return ERR_PTR(ret);

(1)

> -		gpios[i] = ret;
> +		desc = gpiod_get_index(dev, "row", i, GPIOD_IN);
> +		if (IS_ERR(desc))

> +			return ERR_PTR(-EINVAL);

Why?! How will it handle deferred probe, for example?

> +		gpios[i] = desc;
>  	}

...

>  	for (i = 0; i < ncol; i++) {
> -		ret = of_get_named_gpio(np, "col-gpios", i);
> -		if (ret < 0)
> -			return ERR_PTR(ret);
> -		gpios[nrow + i] = ret;
> +		desc = gpiod_get_index(dev, "col", i, GPIOD_IN);
> +		if (IS_ERR(desc))
> +			return ERR_PTR(-EINVAL);

Ditto.

> +		gpios[nrow + i] = desc;
>  	}

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply

* Re: [PATCH 04/22] sound: remove sound/sh
From: Takashi Iwai @ 2023-01-13 16:18 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Yoshinori Sato, Rich Felker, Arnd Bergmann, Greg Kroah-Hartman,
	linux-fbdev, Geert Uytterhoeven, linux-sh, alsa-devel, dri-devel,
	linux-mtd, Laurent Pinchart, linux-arch, linux-serial,
	linux-input, linux-media, devicetree, linux-watchdog, linux-gpio,
	netdev, linux-usb, linux-mmc, linux-kernel, linux-spi,
	linux-renesas-soc, Kieran Bingham, linux-i2c, dmaengine,
	linux-rtc
In-Reply-To: <20230113062339.1909087-5-hch@lst.de>

On Fri, 13 Jan 2023 07:23:21 +0100,
Christoph Hellwig wrote:
> 
> Now that arch/sh is removed these drivers are dead code.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Supposed you take in your tree:

Acked-by: Takashi Iwai <tiwai@suse.de>


thanks,

Takashi

> ---
>  sound/Kconfig           |   2 -
>  sound/Makefile          |   2 +-
>  sound/sh/Kconfig        |  32 --
>  sound/sh/Makefile       |  11 -
>  sound/sh/aica.c         | 628 ----------------------------------------
>  sound/sh/aica.h         |  68 -----
>  sound/sh/sh_dac_audio.c | 412 --------------------------
>  7 files changed, 1 insertion(+), 1154 deletions(-)
>  delete mode 100644 sound/sh/Kconfig
>  delete mode 100644 sound/sh/Makefile
>  delete mode 100644 sound/sh/aica.c
>  delete mode 100644 sound/sh/aica.h
>  delete mode 100644 sound/sh/sh_dac_audio.c
> 
> diff --git a/sound/Kconfig b/sound/Kconfig
> index e56d96d2b11cae..14361bb428baa1 100644
> --- a/sound/Kconfig
> +++ b/sound/Kconfig
> @@ -75,8 +75,6 @@ source "sound/spi/Kconfig"
>  
>  source "sound/mips/Kconfig"
>  
> -source "sound/sh/Kconfig"
> -
>  # the following will depend on the order of config.
>  # here assuming USB is defined before ALSA
>  source "sound/usb/Kconfig"
> diff --git a/sound/Makefile b/sound/Makefile
> index 04ef04b1168f39..bb4b8806321c67 100644
> --- a/sound/Makefile
> +++ b/sound/Makefile
> @@ -4,7 +4,7 @@
>  
>  obj-$(CONFIG_SOUND) += soundcore.o
>  obj-$(CONFIG_DMASOUND) += oss/dmasound/
> -obj-$(CONFIG_SND) += core/ i2c/ drivers/ isa/ pci/ ppc/ arm/ sh/ synth/ usb/ \
> +obj-$(CONFIG_SND) += core/ i2c/ drivers/ isa/ pci/ ppc/ arm/ synth/ usb/ \
>  	firewire/ sparc/ spi/ parisc/ pcmcia/ mips/ soc/ atmel/ hda/ x86/ xen/ \
>  	virtio/
>  obj-$(CONFIG_SND_AOA) += aoa/
> diff --git a/sound/sh/Kconfig b/sound/sh/Kconfig
> deleted file mode 100644
> index b75fbb3236a7b9..00000000000000
> --- a/sound/sh/Kconfig
> +++ /dev/null
> @@ -1,32 +0,0 @@
> -# SPDX-License-Identifier: GPL-2.0-only
> -# ALSA SH drivers
> -
> -menuconfig SND_SUPERH
> -	bool "SUPERH sound devices"
> -	depends on SUPERH
> -	default y
> -	help
> -	  Support for sound devices specific to SUPERH architectures.
> -	  Drivers that are implemented on ASoC can be found in
> -	  "ALSA for SoC audio support" section.
> -
> -if SND_SUPERH
> -
> -config SND_AICA
> -	tristate "Dreamcast Yamaha AICA sound"
> -	depends on SH_DREAMCAST
> -	select SND_PCM
> -	select G2_DMA
> -	help
> -	  ALSA Sound driver for the SEGA Dreamcast console.
> -
> -config SND_SH_DAC_AUDIO
> -	tristate "SuperH DAC audio support"
> -	depends on SND
> -	depends on CPU_SH3 && HIGH_RES_TIMERS
> -	select SND_PCM
> -	help
> -	  Say Y here to include support for the on-chip DAC.
> -
> -endif	# SND_SUPERH
> -
> diff --git a/sound/sh/Makefile b/sound/sh/Makefile
> deleted file mode 100644
> index c0bbc500c17c73..00000000000000
> --- a/sound/sh/Makefile
> +++ /dev/null
> @@ -1,11 +0,0 @@
> -# SPDX-License-Identifier: GPL-2.0-only
> -#
> -# Makefile for ALSA
> -#
> -
> -snd-aica-objs := aica.o
> -snd-sh_dac_audio-objs := sh_dac_audio.o
> -
> -# Toplevel Module Dependency
> -obj-$(CONFIG_SND_AICA) += snd-aica.o
> -obj-$(CONFIG_SND_SH_DAC_AUDIO) += snd-sh_dac_audio.o
> diff --git a/sound/sh/aica.c b/sound/sh/aica.c
> deleted file mode 100644
> index 6e9d6bd67369af..00000000000000
> --- a/sound/sh/aica.c
> +++ /dev/null
> @@ -1,628 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0-only
> -/*
> -*
> -* Copyright Adrian McMenamin 2005, 2006, 2007
> -* <adrian@mcmen.demon.co.uk>
> -* Requires firmware (BSD licenced) available from:
> -* http://linuxdc.cvs.sourceforge.net/linuxdc/linux-sh-dc/sound/oss/aica/firmware/
> -* or the maintainer
> -*/
> -
> -#include <linux/init.h>
> -#include <linux/jiffies.h>
> -#include <linux/slab.h>
> -#include <linux/time.h>
> -#include <linux/wait.h>
> -#include <linux/module.h>
> -#include <linux/platform_device.h>
> -#include <linux/firmware.h>
> -#include <linux/timer.h>
> -#include <linux/delay.h>
> -#include <linux/workqueue.h>
> -#include <linux/io.h>
> -#include <sound/core.h>
> -#include <sound/control.h>
> -#include <sound/pcm.h>
> -#include <sound/initval.h>
> -#include <sound/info.h>
> -#include <asm/dma.h>
> -#include <mach/sysasic.h>
> -#include "aica.h"
> -
> -MODULE_AUTHOR("Adrian McMenamin <adrian@mcmen.demon.co.uk>");
> -MODULE_DESCRIPTION("Dreamcast AICA sound (pcm) driver");
> -MODULE_LICENSE("GPL");
> -MODULE_FIRMWARE("aica_firmware.bin");
> -
> -/* module parameters */
> -#define CARD_NAME "AICA"
> -static int index = -1;
> -static char *id;
> -static bool enable = 1;
> -module_param(index, int, 0444);
> -MODULE_PARM_DESC(index, "Index value for " CARD_NAME " soundcard.");
> -module_param(id, charp, 0444);
> -MODULE_PARM_DESC(id, "ID string for " CARD_NAME " soundcard.");
> -module_param(enable, bool, 0644);
> -MODULE_PARM_DESC(enable, "Enable " CARD_NAME " soundcard.");
> -
> -/* Simple platform device */
> -static struct platform_device *pd;
> -static struct resource aica_memory_space[2] = {
> -	{
> -	 .name = "AICA ARM CONTROL",
> -	 .start = ARM_RESET_REGISTER,
> -	 .flags = IORESOURCE_MEM,
> -	 .end = ARM_RESET_REGISTER + 3,
> -	 },
> -	{
> -	 .name = "AICA Sound RAM",
> -	 .start = SPU_MEMORY_BASE,
> -	 .flags = IORESOURCE_MEM,
> -	 .end = SPU_MEMORY_BASE + 0x200000 - 1,
> -	 },
> -};
> -
> -/* SPU specific functions */
> -/* spu_write_wait - wait for G2-SH FIFO to clear */
> -static void spu_write_wait(void)
> -{
> -	int time_count;
> -	time_count = 0;
> -	while (1) {
> -		if (!(readl(G2_FIFO) & 0x11))
> -			break;
> -		/* To ensure hardware failure doesn't wedge kernel */
> -		time_count++;
> -		if (time_count > 0x10000) {
> -			snd_printk
> -			    ("WARNING: G2 FIFO appears to be blocked.\n");
> -			break;
> -		}
> -	}
> -}
> -
> -/* spu_memset - write to memory in SPU address space */
> -static void spu_memset(u32 toi, u32 what, int length)
> -{
> -	int i;
> -	unsigned long flags;
> -	if (snd_BUG_ON(length % 4))
> -		return;
> -	for (i = 0; i < length; i++) {
> -		if (!(i % 8))
> -			spu_write_wait();
> -		local_irq_save(flags);
> -		writel(what, toi + SPU_MEMORY_BASE);
> -		local_irq_restore(flags);
> -		toi++;
> -	}
> -}
> -
> -/* spu_memload - write to SPU address space */
> -static void spu_memload(u32 toi, const void *from, int length)
> -{
> -	unsigned long flags;
> -	const u32 *froml = from;
> -	u32 __iomem *to = (u32 __iomem *) (SPU_MEMORY_BASE + toi);
> -	int i;
> -	u32 val;
> -	length = DIV_ROUND_UP(length, 4);
> -	spu_write_wait();
> -	for (i = 0; i < length; i++) {
> -		if (!(i % 8))
> -			spu_write_wait();
> -		val = *froml;
> -		local_irq_save(flags);
> -		writel(val, to);
> -		local_irq_restore(flags);
> -		froml++;
> -		to++;
> -	}
> -}
> -
> -/* spu_disable - set spu registers to stop sound output */
> -static void spu_disable(void)
> -{
> -	int i;
> -	unsigned long flags;
> -	u32 regval;
> -	spu_write_wait();
> -	regval = readl(ARM_RESET_REGISTER);
> -	regval |= 1;
> -	spu_write_wait();
> -	local_irq_save(flags);
> -	writel(regval, ARM_RESET_REGISTER);
> -	local_irq_restore(flags);
> -	for (i = 0; i < 64; i++) {
> -		spu_write_wait();
> -		regval = readl(SPU_REGISTER_BASE + (i * 0x80));
> -		regval = (regval & ~0x4000) | 0x8000;
> -		spu_write_wait();
> -		local_irq_save(flags);
> -		writel(regval, SPU_REGISTER_BASE + (i * 0x80));
> -		local_irq_restore(flags);
> -	}
> -}
> -
> -/* spu_enable - set spu registers to enable sound output */
> -static void spu_enable(void)
> -{
> -	unsigned long flags;
> -	u32 regval = readl(ARM_RESET_REGISTER);
> -	regval &= ~1;
> -	spu_write_wait();
> -	local_irq_save(flags);
> -	writel(regval, ARM_RESET_REGISTER);
> -	local_irq_restore(flags);
> -}
> -
> -/* 
> - * Halt the sound processor, clear the memory,
> - * load some default ARM7 code, and then restart ARM7
> -*/
> -static void spu_reset(void)
> -{
> -	unsigned long flags;
> -	spu_disable();
> -	spu_memset(0, 0, 0x200000 / 4);
> -	/* Put ARM7 in endless loop */
> -	local_irq_save(flags);
> -	__raw_writel(0xea000002, SPU_MEMORY_BASE);
> -	local_irq_restore(flags);
> -	spu_enable();
> -}
> -
> -/* aica_chn_start - write to spu to start playback */
> -static void aica_chn_start(void)
> -{
> -	unsigned long flags;
> -	spu_write_wait();
> -	local_irq_save(flags);
> -	writel(AICA_CMD_KICK | AICA_CMD_START, (u32 *) AICA_CONTROL_POINT);
> -	local_irq_restore(flags);
> -}
> -
> -/* aica_chn_halt - write to spu to halt playback */
> -static void aica_chn_halt(void)
> -{
> -	unsigned long flags;
> -	spu_write_wait();
> -	local_irq_save(flags);
> -	writel(AICA_CMD_KICK | AICA_CMD_STOP, (u32 *) AICA_CONTROL_POINT);
> -	local_irq_restore(flags);
> -}
> -
> -/* ALSA code below */
> -static const struct snd_pcm_hardware snd_pcm_aica_playback_hw = {
> -	.info = (SNDRV_PCM_INFO_NONINTERLEAVED),
> -	.formats =
> -	    (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE |
> -	     SNDRV_PCM_FMTBIT_IMA_ADPCM),
> -	.rates = SNDRV_PCM_RATE_8000_48000,
> -	.rate_min = 8000,
> -	.rate_max = 48000,
> -	.channels_min = 1,
> -	.channels_max = 2,
> -	.buffer_bytes_max = AICA_BUFFER_SIZE,
> -	.period_bytes_min = AICA_PERIOD_SIZE,
> -	.period_bytes_max = AICA_PERIOD_SIZE,
> -	.periods_min = AICA_PERIOD_NUMBER,
> -	.periods_max = AICA_PERIOD_NUMBER,
> -};
> -
> -static int aica_dma_transfer(int channels, int buffer_size,
> -			     struct snd_pcm_substream *substream)
> -{
> -	int q, err, period_offset;
> -	struct snd_card_aica *dreamcastcard;
> -	struct snd_pcm_runtime *runtime;
> -	unsigned long flags;
> -	err = 0;
> -	dreamcastcard = substream->pcm->private_data;
> -	period_offset = dreamcastcard->clicks;
> -	period_offset %= (AICA_PERIOD_NUMBER / channels);
> -	runtime = substream->runtime;
> -	for (q = 0; q < channels; q++) {
> -		local_irq_save(flags);
> -		err = dma_xfer(AICA_DMA_CHANNEL,
> -			       (unsigned long) (runtime->dma_area +
> -						(AICA_BUFFER_SIZE * q) /
> -						channels +
> -						AICA_PERIOD_SIZE *
> -						period_offset),
> -			       AICA_CHANNEL0_OFFSET + q * CHANNEL_OFFSET +
> -			       AICA_PERIOD_SIZE * period_offset,
> -			       buffer_size / channels, AICA_DMA_MODE);
> -		if (unlikely(err < 0)) {
> -			local_irq_restore(flags);
> -			break;
> -		}
> -		dma_wait_for_completion(AICA_DMA_CHANNEL);
> -		local_irq_restore(flags);
> -	}
> -	return err;
> -}
> -
> -static void startup_aica(struct snd_card_aica *dreamcastcard)
> -{
> -	spu_memload(AICA_CHANNEL0_CONTROL_OFFSET,
> -		    dreamcastcard->channel, sizeof(struct aica_channel));
> -	aica_chn_start();
> -}
> -
> -static void run_spu_dma(struct work_struct *work)
> -{
> -	int buffer_size;
> -	struct snd_pcm_runtime *runtime;
> -	struct snd_card_aica *dreamcastcard;
> -	dreamcastcard =
> -	    container_of(work, struct snd_card_aica, spu_dma_work);
> -	runtime = dreamcastcard->substream->runtime;
> -	if (unlikely(dreamcastcard->dma_check == 0)) {
> -		buffer_size =
> -		    frames_to_bytes(runtime, runtime->buffer_size);
> -		if (runtime->channels > 1)
> -			dreamcastcard->channel->flags |= 0x01;
> -		aica_dma_transfer(runtime->channels, buffer_size,
> -				  dreamcastcard->substream);
> -		startup_aica(dreamcastcard);
> -		dreamcastcard->clicks =
> -		    buffer_size / (AICA_PERIOD_SIZE * runtime->channels);
> -		return;
> -	} else {
> -		aica_dma_transfer(runtime->channels,
> -				  AICA_PERIOD_SIZE * runtime->channels,
> -				  dreamcastcard->substream);
> -		snd_pcm_period_elapsed(dreamcastcard->substream);
> -		dreamcastcard->clicks++;
> -		if (unlikely(dreamcastcard->clicks >= AICA_PERIOD_NUMBER))
> -			dreamcastcard->clicks %= AICA_PERIOD_NUMBER;
> -		mod_timer(&dreamcastcard->timer, jiffies + 1);
> -	}
> -}
> -
> -static void aica_period_elapsed(struct timer_list *t)
> -{
> -	struct snd_card_aica *dreamcastcard = from_timer(dreamcastcard,
> -							      t, timer);
> -	struct snd_pcm_substream *substream = dreamcastcard->substream;
> -	/*timer function - so cannot sleep */
> -	int play_period;
> -	struct snd_pcm_runtime *runtime;
> -	runtime = substream->runtime;
> -	dreamcastcard = substream->pcm->private_data;
> -	/* Have we played out an additional period? */
> -	play_period =
> -	    frames_to_bytes(runtime,
> -			    readl
> -			    (AICA_CONTROL_CHANNEL_SAMPLE_NUMBER)) /
> -	    AICA_PERIOD_SIZE;
> -	if (play_period == dreamcastcard->current_period) {
> -		/* reschedule the timer */
> -		mod_timer(&(dreamcastcard->timer), jiffies + 1);
> -		return;
> -	}
> -	if (runtime->channels > 1)
> -		dreamcastcard->current_period = play_period;
> -	if (unlikely(dreamcastcard->dma_check == 0))
> -		dreamcastcard->dma_check = 1;
> -	schedule_work(&(dreamcastcard->spu_dma_work));
> -}
> -
> -static void spu_begin_dma(struct snd_pcm_substream *substream)
> -{
> -	struct snd_card_aica *dreamcastcard;
> -	struct snd_pcm_runtime *runtime;
> -	runtime = substream->runtime;
> -	dreamcastcard = substream->pcm->private_data;
> -	/*get the queue to do the work */
> -	schedule_work(&(dreamcastcard->spu_dma_work));
> -	mod_timer(&dreamcastcard->timer, jiffies + 4);
> -}
> -
> -static int snd_aicapcm_pcm_open(struct snd_pcm_substream
> -				*substream)
> -{
> -	struct snd_pcm_runtime *runtime;
> -	struct aica_channel *channel;
> -	struct snd_card_aica *dreamcastcard;
> -	if (!enable)
> -		return -ENOENT;
> -	dreamcastcard = substream->pcm->private_data;
> -	channel = kmalloc(sizeof(struct aica_channel), GFP_KERNEL);
> -	if (!channel)
> -		return -ENOMEM;
> -	/* set defaults for channel */
> -	channel->sfmt = SM_8BIT;
> -	channel->cmd = AICA_CMD_START;
> -	channel->vol = dreamcastcard->master_volume;
> -	channel->pan = 0x80;
> -	channel->pos = 0;
> -	channel->flags = 0;	/* default to mono */
> -	dreamcastcard->channel = channel;
> -	runtime = substream->runtime;
> -	runtime->hw = snd_pcm_aica_playback_hw;
> -	spu_enable();
> -	dreamcastcard->clicks = 0;
> -	dreamcastcard->current_period = 0;
> -	dreamcastcard->dma_check = 0;
> -	return 0;
> -}
> -
> -static int snd_aicapcm_pcm_close(struct snd_pcm_substream
> -				 *substream)
> -{
> -	struct snd_card_aica *dreamcastcard = substream->pcm->private_data;
> -	flush_work(&(dreamcastcard->spu_dma_work));
> -	del_timer(&dreamcastcard->timer);
> -	dreamcastcard->substream = NULL;
> -	kfree(dreamcastcard->channel);
> -	spu_disable();
> -	return 0;
> -}
> -
> -static int snd_aicapcm_pcm_prepare(struct snd_pcm_substream
> -				   *substream)
> -{
> -	struct snd_card_aica *dreamcastcard = substream->pcm->private_data;
> -	if ((substream->runtime)->format == SNDRV_PCM_FORMAT_S16_LE)
> -		dreamcastcard->channel->sfmt = SM_16BIT;
> -	dreamcastcard->channel->freq = substream->runtime->rate;
> -	dreamcastcard->substream = substream;
> -	return 0;
> -}
> -
> -static int snd_aicapcm_pcm_trigger(struct snd_pcm_substream
> -				   *substream, int cmd)
> -{
> -	switch (cmd) {
> -	case SNDRV_PCM_TRIGGER_START:
> -		spu_begin_dma(substream);
> -		break;
> -	case SNDRV_PCM_TRIGGER_STOP:
> -		aica_chn_halt();
> -		break;
> -	default:
> -		return -EINVAL;
> -	}
> -	return 0;
> -}
> -
> -static unsigned long snd_aicapcm_pcm_pointer(struct snd_pcm_substream
> -					     *substream)
> -{
> -	return readl(AICA_CONTROL_CHANNEL_SAMPLE_NUMBER);
> -}
> -
> -static const struct snd_pcm_ops snd_aicapcm_playback_ops = {
> -	.open = snd_aicapcm_pcm_open,
> -	.close = snd_aicapcm_pcm_close,
> -	.prepare = snd_aicapcm_pcm_prepare,
> -	.trigger = snd_aicapcm_pcm_trigger,
> -	.pointer = snd_aicapcm_pcm_pointer,
> -};
> -
> -/* TO DO: set up to handle more than one pcm instance */
> -static int __init snd_aicapcmchip(struct snd_card_aica
> -				  *dreamcastcard, int pcm_index)
> -{
> -	struct snd_pcm *pcm;
> -	int err;
> -	/* AICA has no capture ability */
> -	err =
> -	    snd_pcm_new(dreamcastcard->card, "AICA PCM", pcm_index, 1, 0,
> -			&pcm);
> -	if (unlikely(err < 0))
> -		return err;
> -	pcm->private_data = dreamcastcard;
> -	strcpy(pcm->name, "AICA PCM");
> -	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
> -			&snd_aicapcm_playback_ops);
> -	/* Allocate the DMA buffers */
> -	snd_pcm_set_managed_buffer_all(pcm,
> -				       SNDRV_DMA_TYPE_CONTINUOUS,
> -				       NULL,
> -				       AICA_BUFFER_SIZE,
> -				       AICA_BUFFER_SIZE);
> -	return 0;
> -}
> -
> -/* Mixer controls */
> -#define aica_pcmswitch_info		snd_ctl_boolean_mono_info
> -
> -static int aica_pcmswitch_get(struct snd_kcontrol *kcontrol,
> -			      struct snd_ctl_elem_value *ucontrol)
> -{
> -	ucontrol->value.integer.value[0] = 1;	/* TO DO: Fix me */
> -	return 0;
> -}
> -
> -static int aica_pcmswitch_put(struct snd_kcontrol *kcontrol,
> -			      struct snd_ctl_elem_value *ucontrol)
> -{
> -	if (ucontrol->value.integer.value[0] == 1)
> -		return 0;	/* TO DO: Fix me */
> -	else
> -		aica_chn_halt();
> -	return 0;
> -}
> -
> -static int aica_pcmvolume_info(struct snd_kcontrol *kcontrol,
> -			       struct snd_ctl_elem_info *uinfo)
> -{
> -	uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
> -	uinfo->count = 1;
> -	uinfo->value.integer.min = 0;
> -	uinfo->value.integer.max = 0xFF;
> -	return 0;
> -}
> -
> -static int aica_pcmvolume_get(struct snd_kcontrol *kcontrol,
> -			      struct snd_ctl_elem_value *ucontrol)
> -{
> -	struct snd_card_aica *dreamcastcard;
> -	dreamcastcard = kcontrol->private_data;
> -	if (unlikely(!dreamcastcard->channel))
> -		return -ETXTBSY;	/* we've not yet been set up */
> -	ucontrol->value.integer.value[0] = dreamcastcard->channel->vol;
> -	return 0;
> -}
> -
> -static int aica_pcmvolume_put(struct snd_kcontrol *kcontrol,
> -			      struct snd_ctl_elem_value *ucontrol)
> -{
> -	struct snd_card_aica *dreamcastcard;
> -	unsigned int vol;
> -	dreamcastcard = kcontrol->private_data;
> -	if (unlikely(!dreamcastcard->channel))
> -		return -ETXTBSY;
> -	vol = ucontrol->value.integer.value[0];
> -	if (vol > 0xff)
> -		return -EINVAL;
> -	if (unlikely(dreamcastcard->channel->vol == vol))
> -		return 0;
> -	dreamcastcard->channel->vol = ucontrol->value.integer.value[0];
> -	dreamcastcard->master_volume = ucontrol->value.integer.value[0];
> -	spu_memload(AICA_CHANNEL0_CONTROL_OFFSET,
> -		    dreamcastcard->channel, sizeof(struct aica_channel));
> -	return 1;
> -}
> -
> -static const struct snd_kcontrol_new snd_aica_pcmswitch_control = {
> -	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
> -	.name = "PCM Playback Switch",
> -	.index = 0,
> -	.info = aica_pcmswitch_info,
> -	.get = aica_pcmswitch_get,
> -	.put = aica_pcmswitch_put
> -};
> -
> -static const struct snd_kcontrol_new snd_aica_pcmvolume_control = {
> -	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
> -	.name = "PCM Playback Volume",
> -	.index = 0,
> -	.info = aica_pcmvolume_info,
> -	.get = aica_pcmvolume_get,
> -	.put = aica_pcmvolume_put
> -};
> -
> -static int load_aica_firmware(void)
> -{
> -	int err;
> -	const struct firmware *fw_entry;
> -	spu_reset();
> -	err = request_firmware(&fw_entry, "aica_firmware.bin", &pd->dev);
> -	if (unlikely(err))
> -		return err;
> -	/* write firmware into memory */
> -	spu_disable();
> -	spu_memload(0, fw_entry->data, fw_entry->size);
> -	spu_enable();
> -	release_firmware(fw_entry);
> -	return err;
> -}
> -
> -static int add_aicamixer_controls(struct snd_card_aica *dreamcastcard)
> -{
> -	int err;
> -	err = snd_ctl_add
> -	    (dreamcastcard->card,
> -	     snd_ctl_new1(&snd_aica_pcmvolume_control, dreamcastcard));
> -	if (unlikely(err < 0))
> -		return err;
> -	err = snd_ctl_add
> -	    (dreamcastcard->card,
> -	     snd_ctl_new1(&snd_aica_pcmswitch_control, dreamcastcard));
> -	if (unlikely(err < 0))
> -		return err;
> -	return 0;
> -}
> -
> -static int snd_aica_remove(struct platform_device *devptr)
> -{
> -	struct snd_card_aica *dreamcastcard;
> -	dreamcastcard = platform_get_drvdata(devptr);
> -	if (unlikely(!dreamcastcard))
> -		return -ENODEV;
> -	snd_card_free(dreamcastcard->card);
> -	kfree(dreamcastcard);
> -	return 0;
> -}
> -
> -static int snd_aica_probe(struct platform_device *devptr)
> -{
> -	int err;
> -	struct snd_card_aica *dreamcastcard;
> -	dreamcastcard = kzalloc(sizeof(struct snd_card_aica), GFP_KERNEL);
> -	if (unlikely(!dreamcastcard))
> -		return -ENOMEM;
> -	err = snd_card_new(&devptr->dev, index, SND_AICA_DRIVER,
> -			   THIS_MODULE, 0, &dreamcastcard->card);
> -	if (unlikely(err < 0)) {
> -		kfree(dreamcastcard);
> -		return err;
> -	}
> -	strcpy(dreamcastcard->card->driver, "snd_aica");
> -	strcpy(dreamcastcard->card->shortname, SND_AICA_DRIVER);
> -	strcpy(dreamcastcard->card->longname,
> -	       "Yamaha AICA Super Intelligent Sound Processor for SEGA Dreamcast");
> -	/* Prepare to use the queue */
> -	INIT_WORK(&(dreamcastcard->spu_dma_work), run_spu_dma);
> -	timer_setup(&dreamcastcard->timer, aica_period_elapsed, 0);
> -	/* Load the PCM 'chip' */
> -	err = snd_aicapcmchip(dreamcastcard, 0);
> -	if (unlikely(err < 0))
> -		goto freedreamcast;
> -	/* Add basic controls */
> -	err = add_aicamixer_controls(dreamcastcard);
> -	if (unlikely(err < 0))
> -		goto freedreamcast;
> -	/* Register the card with ALSA subsystem */
> -	err = snd_card_register(dreamcastcard->card);
> -	if (unlikely(err < 0))
> -		goto freedreamcast;
> -	platform_set_drvdata(devptr, dreamcastcard);
> -	snd_printk
> -	    ("ALSA Driver for Yamaha AICA Super Intelligent Sound Processor\n");
> -	return 0;
> -      freedreamcast:
> -	snd_card_free(dreamcastcard->card);
> -	kfree(dreamcastcard);
> -	return err;
> -}
> -
> -static struct platform_driver snd_aica_driver = {
> -	.probe = snd_aica_probe,
> -	.remove = snd_aica_remove,
> -	.driver = {
> -		.name = SND_AICA_DRIVER,
> -	},
> -};
> -
> -static int __init aica_init(void)
> -{
> -	int err;
> -	err = platform_driver_register(&snd_aica_driver);
> -	if (unlikely(err < 0))
> -		return err;
> -	pd = platform_device_register_simple(SND_AICA_DRIVER, -1,
> -					     aica_memory_space, 2);
> -	if (IS_ERR(pd)) {
> -		platform_driver_unregister(&snd_aica_driver);
> -		return PTR_ERR(pd);
> -	}
> -	/* Load the firmware */
> -	return load_aica_firmware();
> -}
> -
> -static void __exit aica_exit(void)
> -{
> -	platform_device_unregister(pd);
> -	platform_driver_unregister(&snd_aica_driver);
> -	/* Kill any sound still playing and reset ARM7 to safe state */
> -	spu_reset();
> -}
> -
> -module_init(aica_init);
> -module_exit(aica_exit);
> diff --git a/sound/sh/aica.h b/sound/sh/aica.h
> deleted file mode 100644
> index 021b132e088e82..00000000000000
> --- a/sound/sh/aica.h
> +++ /dev/null
> @@ -1,68 +0,0 @@
> -/* SPDX-License-Identifier: GPL-2.0-only */
> -/* aica.h
> - * Header file for ALSA driver for
> - * Sega Dreamcast Yamaha AICA sound
> - * Copyright Adrian McMenamin
> - * <adrian@mcmen.demon.co.uk>
> - * 2006
> - */
> -
> -/* SPU memory and register constants etc */
> -#define G2_FIFO 0xa05f688c
> -#define SPU_MEMORY_BASE 0xA0800000
> -#define ARM_RESET_REGISTER 0xA0702C00
> -#define SPU_REGISTER_BASE 0xA0700000
> -
> -/* AICA channels stuff */
> -#define AICA_CONTROL_POINT 0xA0810000
> -#define AICA_CONTROL_CHANNEL_SAMPLE_NUMBER 0xA0810008
> -#define AICA_CHANNEL0_CONTROL_OFFSET 0x10004
> -
> -/* Command values */
> -#define AICA_CMD_KICK 0x80000000
> -#define AICA_CMD_NONE 0
> -#define AICA_CMD_START 1
> -#define AICA_CMD_STOP 2
> -#define AICA_CMD_VOL 3
> -
> -/* Sound modes */
> -#define SM_8BIT		1
> -#define SM_16BIT	0
> -#define SM_ADPCM	2
> -
> -/* Buffer and period size */
> -#define AICA_BUFFER_SIZE 0x8000
> -#define AICA_PERIOD_SIZE 0x800
> -#define AICA_PERIOD_NUMBER 16
> -
> -#define AICA_CHANNEL0_OFFSET 0x11000
> -#define AICA_CHANNEL1_OFFSET 0x21000
> -#define CHANNEL_OFFSET 0x10000
> -
> -#define AICA_DMA_CHANNEL 5
> -#define AICA_DMA_MODE 5
> -
> -#define SND_AICA_DRIVER "AICA"
> -
> -struct aica_channel {
> -	uint32_t cmd;		/* Command ID           */
> -	uint32_t pos;		/* Sample position      */
> -	uint32_t length;	/* Sample length        */
> -	uint32_t freq;		/* Frequency            */
> -	uint32_t vol;		/* Volume 0-255         */
> -	uint32_t pan;		/* Pan 0-255            */
> -	uint32_t sfmt;		/* Sound format         */
> -	uint32_t flags;		/* Bit flags            */
> -};
> -
> -struct snd_card_aica {
> -	struct work_struct spu_dma_work;
> -	struct snd_card *card;
> -	struct aica_channel *channel;
> -	struct snd_pcm_substream *substream;
> -	int clicks;
> -	int current_period;
> -	struct timer_list timer;
> -	int master_volume;
> -	int dma_check;
> -};
> diff --git a/sound/sh/sh_dac_audio.c b/sound/sh/sh_dac_audio.c
> deleted file mode 100644
> index 8ebd972846acb5..00000000000000
> --- a/sound/sh/sh_dac_audio.c
> +++ /dev/null
> @@ -1,412 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0-or-later
> -/*
> - * sh_dac_audio.c - SuperH DAC audio driver for ALSA
> - *
> - * Copyright (c) 2009 by Rafael Ignacio Zurita <rizurita@yahoo.com>
> - *
> - * Based on sh_dac_audio.c (Copyright (C) 2004, 2005 by Andriy Skulysh)
> - */
> -
> -#include <linux/hrtimer.h>
> -#include <linux/interrupt.h>
> -#include <linux/io.h>
> -#include <linux/platform_device.h>
> -#include <linux/slab.h>
> -#include <linux/module.h>
> -#include <sound/core.h>
> -#include <sound/initval.h>
> -#include <sound/pcm.h>
> -#include <sound/sh_dac_audio.h>
> -#include <asm/clock.h>
> -#include <asm/hd64461.h>
> -#include <mach/hp6xx.h>
> -#include <cpu/dac.h>
> -
> -MODULE_AUTHOR("Rafael Ignacio Zurita <rizurita@yahoo.com>");
> -MODULE_DESCRIPTION("SuperH DAC audio driver");
> -MODULE_LICENSE("GPL");
> -
> -/* Module Parameters */
> -static int index = SNDRV_DEFAULT_IDX1;
> -static char *id = SNDRV_DEFAULT_STR1;
> -module_param(index, int, 0444);
> -MODULE_PARM_DESC(index, "Index value for SuperH DAC audio.");
> -module_param(id, charp, 0444);
> -MODULE_PARM_DESC(id, "ID string for SuperH DAC audio.");
> -
> -/* main struct */
> -struct snd_sh_dac {
> -	struct snd_card *card;
> -	struct snd_pcm_substream *substream;
> -	struct hrtimer hrtimer;
> -	ktime_t wakeups_per_second;
> -
> -	int rate;
> -	int empty;
> -	char *data_buffer, *buffer_begin, *buffer_end;
> -	int processed; /* bytes proccesed, to compare with period_size */
> -	int buffer_size;
> -	struct dac_audio_pdata *pdata;
> -};
> -
> -
> -static void dac_audio_start_timer(struct snd_sh_dac *chip)
> -{
> -	hrtimer_start(&chip->hrtimer, chip->wakeups_per_second,
> -		      HRTIMER_MODE_REL);
> -}
> -
> -static void dac_audio_stop_timer(struct snd_sh_dac *chip)
> -{
> -	hrtimer_cancel(&chip->hrtimer);
> -}
> -
> -static void dac_audio_reset(struct snd_sh_dac *chip)
> -{
> -	dac_audio_stop_timer(chip);
> -	chip->buffer_begin = chip->buffer_end = chip->data_buffer;
> -	chip->processed = 0;
> -	chip->empty = 1;
> -}
> -
> -static void dac_audio_set_rate(struct snd_sh_dac *chip)
> -{
> -	chip->wakeups_per_second = 1000000000 / chip->rate;
> -}
> -
> -
> -/* PCM INTERFACE */
> -
> -static const struct snd_pcm_hardware snd_sh_dac_pcm_hw = {
> -	.info			= (SNDRV_PCM_INFO_MMAP |
> -					SNDRV_PCM_INFO_MMAP_VALID |
> -					SNDRV_PCM_INFO_INTERLEAVED |
> -					SNDRV_PCM_INFO_HALF_DUPLEX),
> -	.formats		= SNDRV_PCM_FMTBIT_U8,
> -	.rates			= SNDRV_PCM_RATE_8000,
> -	.rate_min		= 8000,
> -	.rate_max		= 8000,
> -	.channels_min		= 1,
> -	.channels_max		= 1,
> -	.buffer_bytes_max	= (48*1024),
> -	.period_bytes_min	= 1,
> -	.period_bytes_max	= (48*1024),
> -	.periods_min		= 1,
> -	.periods_max		= 1024,
> -};
> -
> -static int snd_sh_dac_pcm_open(struct snd_pcm_substream *substream)
> -{
> -	struct snd_sh_dac *chip = snd_pcm_substream_chip(substream);
> -	struct snd_pcm_runtime *runtime = substream->runtime;
> -
> -	runtime->hw = snd_sh_dac_pcm_hw;
> -
> -	chip->substream = substream;
> -	chip->buffer_begin = chip->buffer_end = chip->data_buffer;
> -	chip->processed = 0;
> -	chip->empty = 1;
> -
> -	chip->pdata->start(chip->pdata);
> -
> -	return 0;
> -}
> -
> -static int snd_sh_dac_pcm_close(struct snd_pcm_substream *substream)
> -{
> -	struct snd_sh_dac *chip = snd_pcm_substream_chip(substream);
> -
> -	chip->substream = NULL;
> -
> -	dac_audio_stop_timer(chip);
> -	chip->pdata->stop(chip->pdata);
> -
> -	return 0;
> -}
> -
> -static int snd_sh_dac_pcm_prepare(struct snd_pcm_substream *substream)
> -{
> -	struct snd_sh_dac *chip = snd_pcm_substream_chip(substream);
> -	struct snd_pcm_runtime *runtime = chip->substream->runtime;
> -
> -	chip->buffer_size = runtime->buffer_size;
> -	memset(chip->data_buffer, 0, chip->pdata->buffer_size);
> -
> -	return 0;
> -}
> -
> -static int snd_sh_dac_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
> -{
> -	struct snd_sh_dac *chip = snd_pcm_substream_chip(substream);
> -
> -	switch (cmd) {
> -	case SNDRV_PCM_TRIGGER_START:
> -		dac_audio_start_timer(chip);
> -		break;
> -	case SNDRV_PCM_TRIGGER_STOP:
> -		chip->buffer_begin = chip->buffer_end = chip->data_buffer;
> -		chip->processed = 0;
> -		chip->empty = 1;
> -		dac_audio_stop_timer(chip);
> -		break;
> -	default:
> -		 return -EINVAL;
> -	}
> -
> -	return 0;
> -}
> -
> -static int snd_sh_dac_pcm_copy(struct snd_pcm_substream *substream,
> -			       int channel, unsigned long pos,
> -			       void __user *src, unsigned long count)
> -{
> -	/* channel is not used (interleaved data) */
> -	struct snd_sh_dac *chip = snd_pcm_substream_chip(substream);
> -
> -	if (copy_from_user_toio(chip->data_buffer + pos, src, count))
> -		return -EFAULT;
> -	chip->buffer_end = chip->data_buffer + pos + count;
> -
> -	if (chip->empty) {
> -		chip->empty = 0;
> -		dac_audio_start_timer(chip);
> -	}
> -
> -	return 0;
> -}
> -
> -static int snd_sh_dac_pcm_copy_kernel(struct snd_pcm_substream *substream,
> -				      int channel, unsigned long pos,
> -				      void *src, unsigned long count)
> -{
> -	/* channel is not used (interleaved data) */
> -	struct snd_sh_dac *chip = snd_pcm_substream_chip(substream);
> -
> -	memcpy_toio(chip->data_buffer + pos, src, count);
> -	chip->buffer_end = chip->data_buffer + pos + count;
> -
> -	if (chip->empty) {
> -		chip->empty = 0;
> -		dac_audio_start_timer(chip);
> -	}
> -
> -	return 0;
> -}
> -
> -static int snd_sh_dac_pcm_silence(struct snd_pcm_substream *substream,
> -				  int channel, unsigned long pos,
> -				  unsigned long count)
> -{
> -	/* channel is not used (interleaved data) */
> -	struct snd_sh_dac *chip = snd_pcm_substream_chip(substream);
> -
> -	memset_io(chip->data_buffer + pos, 0, count);
> -	chip->buffer_end = chip->data_buffer + pos + count;
> -
> -	if (chip->empty) {
> -		chip->empty = 0;
> -		dac_audio_start_timer(chip);
> -	}
> -
> -	return 0;
> -}
> -
> -static
> -snd_pcm_uframes_t snd_sh_dac_pcm_pointer(struct snd_pcm_substream *substream)
> -{
> -	struct snd_sh_dac *chip = snd_pcm_substream_chip(substream);
> -	int pointer = chip->buffer_begin - chip->data_buffer;
> -
> -	return pointer;
> -}
> -
> -/* pcm ops */
> -static const struct snd_pcm_ops snd_sh_dac_pcm_ops = {
> -	.open		= snd_sh_dac_pcm_open,
> -	.close		= snd_sh_dac_pcm_close,
> -	.prepare	= snd_sh_dac_pcm_prepare,
> -	.trigger	= snd_sh_dac_pcm_trigger,
> -	.pointer	= snd_sh_dac_pcm_pointer,
> -	.copy_user	= snd_sh_dac_pcm_copy,
> -	.copy_kernel	= snd_sh_dac_pcm_copy_kernel,
> -	.fill_silence	= snd_sh_dac_pcm_silence,
> -	.mmap		= snd_pcm_lib_mmap_iomem,
> -};
> -
> -static int snd_sh_dac_pcm(struct snd_sh_dac *chip, int device)
> -{
> -	int err;
> -	struct snd_pcm *pcm;
> -
> -	/* device should be always 0 for us */
> -	err = snd_pcm_new(chip->card, "SH_DAC PCM", device, 1, 0, &pcm);
> -	if (err < 0)
> -		return err;
> -
> -	pcm->private_data = chip;
> -	strcpy(pcm->name, "SH_DAC PCM");
> -	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sh_dac_pcm_ops);
> -
> -	/* buffer size=48K */
> -	snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS,
> -				       NULL, 48 * 1024, 48 * 1024);
> -
> -	return 0;
> -}
> -/* END OF PCM INTERFACE */
> -
> -
> -/* driver .remove  --  destructor */
> -static int snd_sh_dac_remove(struct platform_device *devptr)
> -{
> -	snd_card_free(platform_get_drvdata(devptr));
> -	return 0;
> -}
> -
> -/* free -- it has been defined by create */
> -static int snd_sh_dac_free(struct snd_sh_dac *chip)
> -{
> -	/* release the data */
> -	kfree(chip->data_buffer);
> -	kfree(chip);
> -
> -	return 0;
> -}
> -
> -static int snd_sh_dac_dev_free(struct snd_device *device)
> -{
> -	struct snd_sh_dac *chip = device->device_data;
> -
> -	return snd_sh_dac_free(chip);
> -}
> -
> -static enum hrtimer_restart sh_dac_audio_timer(struct hrtimer *handle)
> -{
> -	struct snd_sh_dac *chip = container_of(handle, struct snd_sh_dac,
> -					       hrtimer);
> -	struct snd_pcm_runtime *runtime = chip->substream->runtime;
> -	ssize_t b_ps = frames_to_bytes(runtime, runtime->period_size);
> -
> -	if (!chip->empty) {
> -		sh_dac_output(*chip->buffer_begin, chip->pdata->channel);
> -		chip->buffer_begin++;
> -
> -		chip->processed++;
> -		if (chip->processed >= b_ps) {
> -			chip->processed -= b_ps;
> -			snd_pcm_period_elapsed(chip->substream);
> -		}
> -
> -		if (chip->buffer_begin == (chip->data_buffer +
> -					   chip->buffer_size - 1))
> -			chip->buffer_begin = chip->data_buffer;
> -
> -		if (chip->buffer_begin == chip->buffer_end)
> -			chip->empty = 1;
> -
> -	}
> -
> -	if (!chip->empty)
> -		hrtimer_start(&chip->hrtimer, chip->wakeups_per_second,
> -			      HRTIMER_MODE_REL);
> -
> -	return HRTIMER_NORESTART;
> -}
> -
> -/* create  --  chip-specific constructor for the cards components */
> -static int snd_sh_dac_create(struct snd_card *card,
> -			     struct platform_device *devptr,
> -			     struct snd_sh_dac **rchip)
> -{
> -	struct snd_sh_dac *chip;
> -	int err;
> -
> -	static const struct snd_device_ops ops = {
> -		   .dev_free = snd_sh_dac_dev_free,
> -	};
> -
> -	*rchip = NULL;
> -
> -	chip = kzalloc(sizeof(*chip), GFP_KERNEL);
> -	if (chip == NULL)
> -		return -ENOMEM;
> -
> -	chip->card = card;
> -
> -	hrtimer_init(&chip->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
> -	chip->hrtimer.function = sh_dac_audio_timer;
> -
> -	dac_audio_reset(chip);
> -	chip->rate = 8000;
> -	dac_audio_set_rate(chip);
> -
> -	chip->pdata = devptr->dev.platform_data;
> -
> -	chip->data_buffer = kmalloc(chip->pdata->buffer_size, GFP_KERNEL);
> -	if (chip->data_buffer == NULL) {
> -		kfree(chip);
> -		return -ENOMEM;
> -	}
> -
> -	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
> -	if (err < 0) {
> -		snd_sh_dac_free(chip);
> -		return err;
> -	}
> -
> -	*rchip = chip;
> -
> -	return 0;
> -}
> -
> -/* driver .probe  --  constructor */
> -static int snd_sh_dac_probe(struct platform_device *devptr)
> -{
> -	struct snd_sh_dac *chip;
> -	struct snd_card *card;
> -	int err;
> -
> -	err = snd_card_new(&devptr->dev, index, id, THIS_MODULE, 0, &card);
> -	if (err < 0) {
> -			snd_printk(KERN_ERR "cannot allocate the card\n");
> -			return err;
> -	}
> -
> -	err = snd_sh_dac_create(card, devptr, &chip);
> -	if (err < 0)
> -		goto probe_error;
> -
> -	err = snd_sh_dac_pcm(chip, 0);
> -	if (err < 0)
> -		goto probe_error;
> -
> -	strcpy(card->driver, "snd_sh_dac");
> -	strcpy(card->shortname, "SuperH DAC audio driver");
> -	printk(KERN_INFO "%s %s", card->longname, card->shortname);
> -
> -	err = snd_card_register(card);
> -	if (err < 0)
> -		goto probe_error;
> -
> -	snd_printk(KERN_INFO "ALSA driver for SuperH DAC audio");
> -
> -	platform_set_drvdata(devptr, card);
> -	return 0;
> -
> -probe_error:
> -	snd_card_free(card);
> -	return err;
> -}
> -
> -/*
> - * "driver" definition
> - */
> -static struct platform_driver sh_dac_driver = {
> -	.probe	= snd_sh_dac_probe,
> -	.remove = snd_sh_dac_remove,
> -	.driver = {
> -		.name = "dac_audio",
> -	},
> -};
> -
> -module_platform_driver(sh_dac_driver);
> -- 
> 2.39.0
> 

^ permalink raw reply

* Re: remove arch/sh
From: Rob Herring @ 2023-01-13 15:18 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Yoshinori Sato, Rich Felker, Arnd Bergmann, Greg Kroah-Hartman,
	Laurent Pinchart, Kieran Bingham, Geert Uytterhoeven,
	linux-kernel, linux-watchdog, devicetree, linux-arch, dmaengine,
	dri-devel, linux-renesas-soc, linux-i2c, linux-input, linux-media,
	linux-mmc, linux-mtd, netdev, linux-gpio, linux-rtc, linux-spi,
	linux-serial, linux-usb, linux-fbdev, alsa-devel, linux-sh
In-Reply-To: <20230113062339.1909087-1-hch@lst.de>

On Fri, Jan 13, 2023 at 07:23:17AM +0100, Christoph Hellwig wrote:
> Hi all,
> 
> arch/sh has been a long drag because it supports a lot of SOCs, and most
> of them haven't even been converted to device tree infrastructure.  These
> SOCs are generally obsolete as well, and all of the support has been barely
> maintained for almost 10 years, and not at all for more than 1 year.
> 
> Drop arch/sh and everything that depends on it.
> 
> Diffstat:
>  Documentation/sh/booting.rst                             |   12 
>  Documentation/sh/features.rst                            |    3 
>  Documentation/sh/index.rst                               |   56 
>  Documentation/sh/new-machine.rst                         |  277 -
>  Documentation/sh/register-banks.rst                      |   40 

Can you please also remove:

Documentation/devicetree/bindings/mtd/flctl-nand.txt
Documentation/devicetree/bindings/interrupt-controller/jcore,aic.txt
Documentation/devicetree/bindings/spi/jcore,spi.txt
Documentation/devicetree/bindings/timer/jcore,pit.txt

Rob

^ permalink raw reply

* [PATCH 2/2] HID: uhid: Over-ride the default maximum data buffer value with our own
From: Lee Jones @ 2023-01-13 15:05 UTC (permalink / raw)
  To: lee, jikos, benjamin.tissoires, avid.rheinsberg; +Cc: linux-kernel, linux-input
In-Reply-To: <20230113150557.1308176-1-lee@kernel.org>

The default maximum data buffer size for this interface is UHID_DATA_MAX
(4k).  When data buffers are being processed, ensure this value is used
when ensuring the sanity, rather than a value between the user provided
value and HID_MAX_BUFFER_SIZE (16k).

Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/hid/uhid.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
index 2a918aeb0af13..59ac757c1d471 100644
--- a/drivers/hid/uhid.c
+++ b/drivers/hid/uhid.c
@@ -395,6 +395,7 @@ struct hid_ll_driver uhid_hid_driver = {
 	.parse = uhid_hid_parse,
 	.raw_request = uhid_hid_raw_request,
 	.output_report = uhid_hid_output_report,
+	.max_buffer_size = UHID_DATA_MAX,
 };
 EXPORT_SYMBOL_GPL(uhid_hid_driver);
 
-- 
2.39.0.314.g84b9a713c41-goog


^ permalink raw reply related

* [PATCH 1/2] HID: core: Provide new max_buffer_size attribute to over-ride the default
From: Lee Jones @ 2023-01-13 15:05 UTC (permalink / raw)
  To: lee, jikos, benjamin.tissoires, avid.rheinsberg; +Cc: linux-kernel, linux-input

Presently, when a report is processed, its size is compared solely
against the value specified by user-space.  If the received report ends
up being smaller than this, the remainder of the buffer is zeroed.  That
is, the space between sizeof(csize) (size of the current report) and the
rsize (size provided by the user - i.e. Report Size * Report Count),
which can be handled up to HID_MAX_BUFFER_SIZE (16k).

This is an issue.  In the case of some low-level drivers, the buffers
are significantly smaller than the default 16k.  For instance, in the
case of uhid, the data buffer is a mere UHID_DATA_MAX (4k).  Meaning
that memset() shoots straight past the end of the buffer boundary and
starts zeroing out in-use values, often resulting in calamity.

This patch introduces a new variable into 'struct hid_ll_driver' where
individual low-level drivers can over-ride the default maximum value of
HID_MAX_BUFFER_SIZE (16k) with something more sympathetic to the
interface.

Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/hid/hid-core.c | 32 +++++++++++++++++++++++++-------
 include/linux/hid.h    |  3 +++
 2 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index bd47628da6be0..b10383ca8fc05 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -261,6 +261,7 @@ static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsign
 {
 	struct hid_report *report;
 	struct hid_field *field;
+	unsigned int max_buffer_size = HID_MAX_BUFFER_SIZE;
 	unsigned int usages;
 	unsigned int offset;
 	unsigned int i;
@@ -291,8 +292,11 @@ static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsign
 	offset = report->size;
 	report->size += parser->global.report_size * parser->global.report_count;
 
+	if (parser->device->ll_driver->max_buffer_size)
+		max_buffer_size = parser->device->ll_driver->max_buffer_size;
+
 	/* Total size check: Allow for possible report index byte */
-	if (report->size > (HID_MAX_BUFFER_SIZE - 1) << 3) {
+	if (report->size > (max_buffer_size - 1) << 3) {
 		hid_err(parser->device, "report is too long\n");
 		return -1;
 	}
@@ -1963,6 +1967,7 @@ int hid_report_raw_event(struct hid_device *hid, enum hid_report_type type, u8 *
 	struct hid_report_enum *report_enum = hid->report_enum + type;
 	struct hid_report *report;
 	struct hid_driver *hdrv;
+	int max_buffer_size = HID_MAX_BUFFER_SIZE;
 	u32 rsize, csize = size;
 	u8 *cdata = data;
 	int ret = 0;
@@ -1978,10 +1983,13 @@ int hid_report_raw_event(struct hid_device *hid, enum hid_report_type type, u8 *
 
 	rsize = hid_compute_report_size(report);
 
-	if (report_enum->numbered && rsize >= HID_MAX_BUFFER_SIZE)
-		rsize = HID_MAX_BUFFER_SIZE - 1;
-	else if (rsize > HID_MAX_BUFFER_SIZE)
-		rsize = HID_MAX_BUFFER_SIZE;
+	if (hid->ll_driver->max_buffer_size)
+		max_buffer_size = hid->ll_driver->max_buffer_size;
+
+	if (report_enum->numbered && rsize >= max_buffer_size)
+		rsize = max_buffer_size - 1;
+	else if (rsize > max_buffer_size)
+		rsize = max_buffer_size;
 
 	if (csize < rsize) {
 		dbg_hid("report %d is too short, (%d < %d)\n", report->id,
@@ -2384,7 +2392,12 @@ int hid_hw_raw_request(struct hid_device *hdev,
 		       unsigned char reportnum, __u8 *buf,
 		       size_t len, enum hid_report_type rtype, enum hid_class_request reqtype)
 {
-	if (len < 1 || len > HID_MAX_BUFFER_SIZE || !buf)
+	unsigned int max_buffer_size = HID_MAX_BUFFER_SIZE;
+
+	if (hdev->ll_driver->max_buffer_size)
+		max_buffer_size = hdev->ll_driver->max_buffer_size;
+
+	if (len < 1 || len > max_buffer_size || !buf)
 		return -EINVAL;
 
 	return hdev->ll_driver->raw_request(hdev, reportnum, buf, len,
@@ -2403,7 +2416,12 @@ EXPORT_SYMBOL_GPL(hid_hw_raw_request);
  */
 int hid_hw_output_report(struct hid_device *hdev, __u8 *buf, size_t len)
 {
-	if (len < 1 || len > HID_MAX_BUFFER_SIZE || !buf)
+	unsigned int max_buffer_size = HID_MAX_BUFFER_SIZE;
+
+	if (hdev->ll_driver->max_buffer_size)
+		max_buffer_size = hdev->ll_driver->max_buffer_size;
+
+	if (len < 1 || len > max_buffer_size || !buf)
 		return -EINVAL;
 
 	if (hdev->ll_driver->output_report)
diff --git a/include/linux/hid.h b/include/linux/hid.h
index 8677ae38599e4..f9b500b26f67c 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -826,6 +826,7 @@ struct hid_driver {
  * @output_report: send output report to device
  * @idle: send idle request to device
  * @may_wakeup: return if device may act as a wakeup source during system-suspend
+ * @max_buffer_size: over-ride maximum data buffer size (default: HID_MAX_BUFFER_SIZE)
  */
 struct hid_ll_driver {
 	int (*start)(struct hid_device *hdev);
@@ -851,6 +852,8 @@ struct hid_ll_driver {
 
 	int (*idle)(struct hid_device *hdev, int report, int idle, int reqtype);
 	bool (*may_wakeup)(struct hid_device *hdev);
+
+	unsigned int max_buffer_size;
 };
 
 extern struct hid_ll_driver i2c_hid_ll_driver;
-- 
2.39.0.314.g84b9a713c41-goog


^ permalink raw reply related

* Re: [PATCH 06/22] watchdog: remove the shwdt driver
From: Guenter Roeck @ 2023-01-13 14:00 UTC (permalink / raw)
  To: Christoph Hellwig, Yoshinori Sato, Rich Felker, Arnd Bergmann,
	Greg Kroah-Hartman
  Cc: Laurent Pinchart, Kieran Bingham, Geert Uytterhoeven,
	linux-kernel, linux-watchdog, devicetree, linux-arch, dmaengine,
	dri-devel, linux-renesas-soc, linux-i2c, linux-input, linux-media,
	linux-mmc, linux-mtd, netdev, linux-gpio, linux-rtc, linux-spi,
	linux-serial, linux-usb, linux-fbdev, alsa-devel, linux-sh
In-Reply-To: <20230113062339.1909087-7-hch@lst.de>

On 1/12/23 22:23, Christoph Hellwig wrote:
> Now that arch/sh is removed this driver is dead code.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Acked-by: Guenter Roeck <linux@roeck-us.net>

> ---
>   .../watchdog/watchdog-parameters.rst          |  12 -
>   drivers/watchdog/Kconfig                      |  20 -
>   drivers/watchdog/Makefile                     |   3 -
>   drivers/watchdog/shwdt.c                      | 344 ------------------
>   4 files changed, 379 deletions(-)
>   delete mode 100644 drivers/watchdog/shwdt.c
> 
> diff --git a/Documentation/watchdog/watchdog-parameters.rst b/Documentation/watchdog/watchdog-parameters.rst
> index 29153eed668900..553ac2f8ae23f7 100644
> --- a/Documentation/watchdog/watchdog-parameters.rst
> +++ b/Documentation/watchdog/watchdog-parameters.rst
> @@ -579,18 +579,6 @@ scx200_wdt:
>   
>   -------------------------------------------------
>   
> -shwdt:
> -    clock_division_ratio:
> -	Clock division ratio. Valid ranges are from 0x5 (1.31ms)
> -	to 0x7 (5.25ms). (default=7)
> -    heartbeat:
> -	Watchdog heartbeat in seconds. (1 <= heartbeat <= 3600, default=30
> -    nowayout:
> -	Watchdog cannot be stopped once started
> -	(default=kernel config parameter)
> -
> --------------------------------------------------
> -
>   smsc37b787_wdt:
>       timeout:
>   	range is 1-255 units, default is 60
> diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
> index 0bc40b763b0652..7db0a5e636cf65 100644
> --- a/drivers/watchdog/Kconfig
> +++ b/drivers/watchdog/Kconfig
> @@ -2015,26 +2015,6 @@ config DIAG288_WATCHDOG
>   	  To compile this driver as a module, choose M here. The module
>   	  will be called diag288_wdt.
>   
> -# SUPERH (sh + sh64) Architecture
> -
> -config SH_WDT
> -	tristate "SuperH Watchdog"
> -	depends on SUPERH && (CPU_SH3 || CPU_SH4 || COMPILE_TEST)
> -	select WATCHDOG_CORE
> -	help
> -	  This driver adds watchdog support for the integrated watchdog in the
> -	  SuperH processors. If you have one of these processors and wish
> -	  to have watchdog support enabled, say Y, otherwise say N.
> -
> -	  As a side note, saying Y here will automatically boost HZ to 1000
> -	  so that the timer has a chance to clear the overflow counter. On
> -	  slower systems (such as the SH-2 and SH-3) this will likely yield
> -	  some performance issues. As such, the WDT should be avoided here
> -	  unless it is absolutely necessary.
> -
> -	  To compile this driver as a module, choose M here: the
> -	  module will be called shwdt.
> -
>   # SPARC Architecture
>   
>   # SPARC64 Architecture
> diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
> index 9cbf6580f16c9f..a852ab4d7176ac 100644
> --- a/drivers/watchdog/Makefile
> +++ b/drivers/watchdog/Makefile
> @@ -195,9 +195,6 @@ obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o
>   # S390 Architecture
>   obj-$(CONFIG_DIAG288_WATCHDOG) += diag288_wdt.o
>   
> -# SUPERH (sh + sh64) Architecture
> -obj-$(CONFIG_SH_WDT) += shwdt.o
> -
>   # SPARC Architecture
>   
>   # SPARC64 Architecture
> diff --git a/drivers/watchdog/shwdt.c b/drivers/watchdog/shwdt.c
> deleted file mode 100644
> index f55533e0e0454e..00000000000000
> --- a/drivers/watchdog/shwdt.c
> +++ /dev/null
> @@ -1,344 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0-or-later
> -/*
> - * drivers/watchdog/shwdt.c
> - *
> - * Watchdog driver for integrated watchdog in the SuperH processors.
> - *
> - * Copyright (C) 2001 - 2012  Paul Mundt <lethal@linux-sh.org>
> - *
> - * 14-Dec-2001 Matt Domsch <Matt_Domsch@dell.com>
> - *     Added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT
> - *
> - * 19-Apr-2002 Rob Radez <rob@osinvestor.com>
> - *     Added expect close support, made emulated timeout runtime changeable
> - *     general cleanups, add some ioctls
> - */
> -
> -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> -
> -#include <linux/module.h>
> -#include <linux/moduleparam.h>
> -#include <linux/platform_device.h>
> -#include <linux/init.h>
> -#include <linux/types.h>
> -#include <linux/spinlock.h>
> -#include <linux/watchdog.h>
> -#include <linux/pm_runtime.h>
> -#include <linux/fs.h>
> -#include <linux/mm.h>
> -#include <linux/slab.h>
> -#include <linux/io.h>
> -#include <linux/clk.h>
> -#include <linux/err.h>
> -#include <asm/watchdog.h>
> -
> -#define DRV_NAME "sh-wdt"
> -
> -/*
> - * Default clock division ratio is 5.25 msecs. For an additional table of
> - * values, consult the asm-sh/watchdog.h. Overload this at module load
> - * time.
> - *
> - * In order for this to work reliably we need to have HZ set to 1000 or
> - * something quite higher than 100 (or we need a proper high-res timer
> - * implementation that will deal with this properly), otherwise the 10ms
> - * resolution of a jiffy is enough to trigger the overflow. For things like
> - * the SH-4 and SH-5, this isn't necessarily that big of a problem, though
> - * for the SH-2 and SH-3, this isn't recommended unless the WDT is absolutely
> - * necssary.
> - *
> - * As a result of this timing problem, the only modes that are particularly
> - * feasible are the 4096 and the 2048 divisors, which yield 5.25 and 2.62ms
> - * overflow periods respectively.
> - *
> - * Also, since we can't really expect userspace to be responsive enough
> - * before the overflow happens, we maintain two separate timers .. One in
> - * the kernel for clearing out WOVF every 2ms or so (again, this depends on
> - * HZ == 1000), and another for monitoring userspace writes to the WDT device.
> - *
> - * As such, we currently use a configurable heartbeat interval which defaults
> - * to 30s. In this case, the userspace daemon is only responsible for periodic
> - * writes to the device before the next heartbeat is scheduled. If the daemon
> - * misses its deadline, the kernel timer will allow the WDT to overflow.
> - */
> -static int clock_division_ratio = WTCSR_CKS_4096;
> -#define next_ping_period(cks)	(jiffies + msecs_to_jiffies(cks - 4))
> -
> -#define WATCHDOG_HEARTBEAT 30			/* 30 sec default heartbeat */
> -static int heartbeat = WATCHDOG_HEARTBEAT;	/* in seconds */
> -static bool nowayout = WATCHDOG_NOWAYOUT;
> -static unsigned long next_heartbeat;
> -
> -struct sh_wdt {
> -	void __iomem		*base;
> -	struct device		*dev;
> -	struct clk		*clk;
> -	spinlock_t		lock;
> -
> -	struct timer_list	timer;
> -};
> -
> -static int sh_wdt_start(struct watchdog_device *wdt_dev)
> -{
> -	struct sh_wdt *wdt = watchdog_get_drvdata(wdt_dev);
> -	unsigned long flags;
> -	u8 csr;
> -
> -	pm_runtime_get_sync(wdt->dev);
> -	clk_enable(wdt->clk);
> -
> -	spin_lock_irqsave(&wdt->lock, flags);
> -
> -	next_heartbeat = jiffies + (heartbeat * HZ);
> -	mod_timer(&wdt->timer, next_ping_period(clock_division_ratio));
> -
> -	csr = sh_wdt_read_csr();
> -	csr |= WTCSR_WT | clock_division_ratio;
> -	sh_wdt_write_csr(csr);
> -
> -	sh_wdt_write_cnt(0);
> -
> -	/*
> -	 * These processors have a bit of an inconsistent initialization
> -	 * process.. starting with SH-3, RSTS was moved to WTCSR, and the
> -	 * RSTCSR register was removed.
> -	 *
> -	 * On the SH-2 however, in addition with bits being in different
> -	 * locations, we must deal with RSTCSR outright..
> -	 */
> -	csr = sh_wdt_read_csr();
> -	csr |= WTCSR_TME;
> -	csr &= ~WTCSR_RSTS;
> -	sh_wdt_write_csr(csr);
> -
> -#ifdef CONFIG_CPU_SH2
> -	csr = sh_wdt_read_rstcsr();
> -	csr &= ~RSTCSR_RSTS;
> -	sh_wdt_write_rstcsr(csr);
> -#endif
> -	spin_unlock_irqrestore(&wdt->lock, flags);
> -
> -	return 0;
> -}
> -
> -static int sh_wdt_stop(struct watchdog_device *wdt_dev)
> -{
> -	struct sh_wdt *wdt = watchdog_get_drvdata(wdt_dev);
> -	unsigned long flags;
> -	u8 csr;
> -
> -	spin_lock_irqsave(&wdt->lock, flags);
> -
> -	del_timer(&wdt->timer);
> -
> -	csr = sh_wdt_read_csr();
> -	csr &= ~WTCSR_TME;
> -	sh_wdt_write_csr(csr);
> -
> -	spin_unlock_irqrestore(&wdt->lock, flags);
> -
> -	clk_disable(wdt->clk);
> -	pm_runtime_put_sync(wdt->dev);
> -
> -	return 0;
> -}
> -
> -static int sh_wdt_keepalive(struct watchdog_device *wdt_dev)
> -{
> -	struct sh_wdt *wdt = watchdog_get_drvdata(wdt_dev);
> -	unsigned long flags;
> -
> -	spin_lock_irqsave(&wdt->lock, flags);
> -	next_heartbeat = jiffies + (heartbeat * HZ);
> -	spin_unlock_irqrestore(&wdt->lock, flags);
> -
> -	return 0;
> -}
> -
> -static int sh_wdt_set_heartbeat(struct watchdog_device *wdt_dev, unsigned t)
> -{
> -	struct sh_wdt *wdt = watchdog_get_drvdata(wdt_dev);
> -	unsigned long flags;
> -
> -	if (unlikely(t < 1 || t > 3600)) /* arbitrary upper limit */
> -		return -EINVAL;
> -
> -	spin_lock_irqsave(&wdt->lock, flags);
> -	heartbeat = t;
> -	wdt_dev->timeout = t;
> -	spin_unlock_irqrestore(&wdt->lock, flags);
> -
> -	return 0;
> -}
> -
> -static void sh_wdt_ping(struct timer_list *t)
> -{
> -	struct sh_wdt *wdt = from_timer(wdt, t, timer);
> -	unsigned long flags;
> -
> -	spin_lock_irqsave(&wdt->lock, flags);
> -	if (time_before(jiffies, next_heartbeat)) {
> -		u8 csr;
> -
> -		csr = sh_wdt_read_csr();
> -		csr &= ~WTCSR_IOVF;
> -		sh_wdt_write_csr(csr);
> -
> -		sh_wdt_write_cnt(0);
> -
> -		mod_timer(&wdt->timer, next_ping_period(clock_division_ratio));
> -	} else
> -		dev_warn(wdt->dev, "Heartbeat lost! Will not ping "
> -		         "the watchdog\n");
> -	spin_unlock_irqrestore(&wdt->lock, flags);
> -}
> -
> -static const struct watchdog_info sh_wdt_info = {
> -	.options		= WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT |
> -				  WDIOF_MAGICCLOSE,
> -	.firmware_version	= 1,
> -	.identity		= "SH WDT",
> -};
> -
> -static const struct watchdog_ops sh_wdt_ops = {
> -	.owner		= THIS_MODULE,
> -	.start		= sh_wdt_start,
> -	.stop		= sh_wdt_stop,
> -	.ping		= sh_wdt_keepalive,
> -	.set_timeout	= sh_wdt_set_heartbeat,
> -};
> -
> -static struct watchdog_device sh_wdt_dev = {
> -	.info	= &sh_wdt_info,
> -	.ops	= &sh_wdt_ops,
> -};
> -
> -static int sh_wdt_probe(struct platform_device *pdev)
> -{
> -	struct sh_wdt *wdt;
> -	int rc;
> -
> -	/*
> -	 * As this driver only covers the global watchdog case, reject
> -	 * any attempts to register per-CPU watchdogs.
> -	 */
> -	if (pdev->id != -1)
> -		return -EINVAL;
> -
> -	wdt = devm_kzalloc(&pdev->dev, sizeof(struct sh_wdt), GFP_KERNEL);
> -	if (unlikely(!wdt))
> -		return -ENOMEM;
> -
> -	wdt->dev = &pdev->dev;
> -
> -	wdt->clk = devm_clk_get(&pdev->dev, NULL);
> -	if (IS_ERR(wdt->clk)) {
> -		/*
> -		 * Clock framework support is optional, continue on
> -		 * anyways if we don't find a matching clock.
> -		 */
> -		wdt->clk = NULL;
> -	}
> -
> -	wdt->base = devm_platform_ioremap_resource(pdev, 0);
> -	if (IS_ERR(wdt->base))
> -		return PTR_ERR(wdt->base);
> -
> -	watchdog_set_nowayout(&sh_wdt_dev, nowayout);
> -	watchdog_set_drvdata(&sh_wdt_dev, wdt);
> -	sh_wdt_dev.parent = &pdev->dev;
> -
> -	spin_lock_init(&wdt->lock);
> -
> -	rc = sh_wdt_set_heartbeat(&sh_wdt_dev, heartbeat);
> -	if (unlikely(rc)) {
> -		/* Default timeout if invalid */
> -		sh_wdt_set_heartbeat(&sh_wdt_dev, WATCHDOG_HEARTBEAT);
> -
> -		dev_warn(&pdev->dev,
> -			 "heartbeat value must be 1<=x<=3600, using %d\n",
> -			 sh_wdt_dev.timeout);
> -	}
> -
> -	dev_info(&pdev->dev, "configured with heartbeat=%d sec (nowayout=%d)\n",
> -		 sh_wdt_dev.timeout, nowayout);
> -
> -	rc = watchdog_register_device(&sh_wdt_dev);
> -	if (unlikely(rc)) {
> -		dev_err(&pdev->dev, "Can't register watchdog (err=%d)\n", rc);
> -		return rc;
> -	}
> -
> -	timer_setup(&wdt->timer, sh_wdt_ping, 0);
> -	wdt->timer.expires	= next_ping_period(clock_division_ratio);
> -
> -	dev_info(&pdev->dev, "initialized.\n");
> -
> -	pm_runtime_enable(&pdev->dev);
> -
> -	return 0;
> -}
> -
> -static int sh_wdt_remove(struct platform_device *pdev)
> -{
> -	watchdog_unregister_device(&sh_wdt_dev);
> -
> -	pm_runtime_disable(&pdev->dev);
> -
> -	return 0;
> -}
> -
> -static void sh_wdt_shutdown(struct platform_device *pdev)
> -{
> -	sh_wdt_stop(&sh_wdt_dev);
> -}
> -
> -static struct platform_driver sh_wdt_driver = {
> -	.driver		= {
> -		.name	= DRV_NAME,
> -	},
> -
> -	.probe		= sh_wdt_probe,
> -	.remove		= sh_wdt_remove,
> -	.shutdown	= sh_wdt_shutdown,
> -};
> -
> -static int __init sh_wdt_init(void)
> -{
> -	if (unlikely(clock_division_ratio < 0x5 ||
> -		     clock_division_ratio > 0x7)) {
> -		clock_division_ratio = WTCSR_CKS_4096;
> -
> -		pr_info("divisor must be 0x5<=x<=0x7, using %d\n",
> -			clock_division_ratio);
> -	}
> -
> -	return platform_driver_register(&sh_wdt_driver);
> -}
> -
> -static void __exit sh_wdt_exit(void)
> -{
> -	platform_driver_unregister(&sh_wdt_driver);
> -}
> -module_init(sh_wdt_init);
> -module_exit(sh_wdt_exit);
> -
> -MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>");
> -MODULE_DESCRIPTION("SuperH watchdog driver");
> -MODULE_LICENSE("GPL");
> -MODULE_ALIAS("platform:" DRV_NAME);
> -
> -module_param(clock_division_ratio, int, 0);
> -MODULE_PARM_DESC(clock_division_ratio,
> -	"Clock division ratio. Valid ranges are from 0x5 (1.31ms) "
> -	"to 0x7 (5.25ms). (default=" __MODULE_STRING(WTCSR_CKS_4096) ")");
> -
> -module_param(heartbeat, int, 0);
> -MODULE_PARM_DESC(heartbeat,
> -	"Watchdog heartbeat in seconds. (1 <= heartbeat <= 3600, default="
> -				__MODULE_STRING(WATCHDOG_HEARTBEAT) ")");
> -
> -module_param(nowayout, bool, 0);
> -MODULE_PARM_DESC(nowayout,
> -	"Watchdog cannot be stopped once started (default="
> -				__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");


^ permalink raw reply

* Re: [PATCH 11/22] mtd/nand: remove sh_flctl
From: Arnd Bergmann @ 2023-01-13 10:06 UTC (permalink / raw)
  To: Geert Uytterhoeven, Christoph Hellwig
  Cc: Yoshinori Sato, Rich Felker, Greg Kroah-Hartman, laurent.pinchart,
	Kieran Bingham, Geert Uytterhoeven, linux-kernel, linux-watchdog,
	devicetree, Linux-Arch, dmaengine, dri-devel, Linux-Renesas,
	linux-i2c, linux-input, linux-media,
	linux-mmc @ vger . kernel . org, linux-mtd, Netdev,
	open list:GPIO SUBSYSTEM, linux-rtc, linux-spi, linux-serial,
	linux-usb, linux-fbdev, alsa-devel, linux-sh
In-Reply-To: <CAMuHMdXYt4dNHUDsTnPa-RP+sdK=35nNa9xQzMChwK54qO44mA@mail.gmail.com>

On Fri, Jan 13, 2023, at 09:30, Geert Uytterhoeven wrote:
> On Fri, Jan 13, 2023 at 7:24 AM Christoph Hellwig <hch@lst.de> wrote:
>> Now that arch/sh is removed this driver is dead code.
>
> FTR, this hardware block is also present on the ARM-based
> SH-Mobile AG5 and R-Mobile A1 SoCs.
> Again, no DT support.

I would generally consider drivers dead when they have no DT support
and no platform in the upstream kernel registering the corresponding
device.

If anyone still uses this driver on SH-Mobile or R-Mobile, they
have clearly given up on upstreaming their patches by now, and
they can carry the burden of maintaining the driver out of tree,
or re-submit a working version.

    Arnd

^ permalink raw reply


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