public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/5] DesignWare PWM improvements
@ 2024-02-08  7:05 Raag Jadav
  2024-02-08  7:05 ` [PATCH v2 1/5] pwm: dwc: drop redundant error check Raag Jadav
                   ` (5 more replies)
  0 siblings, 6 replies; 26+ messages in thread
From: Raag Jadav @ 2024-02-08  7:05 UTC (permalink / raw)
  To: u.kleine-koenig, jarkko.nikula, mika.westerberg,
	andriy.shevchenko, lakshmi.sowjanya.d
  Cc: linux-pwm, linux-kernel, Raag Jadav

This series implements 16 channel PWM support for Intel Elkhart Lake
along with minor cleanups for DesignWare PWM driver.

Changes since v1:
- Drop redundant error check
- Provide dwc_pwm_init_one() to initialize one PWM instance
- Use dev_get_drvdata() instead of pci_get_drvdata()
- Use pm_sleep_ptr() instead of use pm_ptr()

Raag Jadav (5):
  pwm: dwc: drop redundant error check
  pwm: dwc: Add 16 channel support for Intel Elkhart Lake
  pwm: dwc: simplify error handling
  pwm: dwc: access driver_data using dev_get_drvdata()
  pwm: dwc: use pm_sleep_ptr() macro

 drivers/pwm/pwm-dwc.c | 59 ++++++++++++++++++++++++-------------------
 drivers/pwm/pwm-dwc.h |  5 ++++
 2 files changed, 38 insertions(+), 26 deletions(-)


base-commit: 6613476e225e090cc9aad49be7fa504e290dd33d
-- 
2.35.3


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

* [PATCH v2 1/5] pwm: dwc: drop redundant error check
  2024-02-08  7:05 [PATCH v2 0/5] DesignWare PWM improvements Raag Jadav
@ 2024-02-08  7:05 ` Raag Jadav
  2024-02-08  7:46   ` Uwe Kleine-König
  2024-02-08  7:05 ` [PATCH v2 2/5] pwm: dwc: Add 16 channel support for Intel Elkhart Lake Raag Jadav
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 26+ messages in thread
From: Raag Jadav @ 2024-02-08  7:05 UTC (permalink / raw)
  To: u.kleine-koenig, jarkko.nikula, mika.westerberg,
	andriy.shevchenko, lakshmi.sowjanya.d
  Cc: linux-pwm, linux-kernel, Raag Jadav

pcim_iomap_table() fails only if pcim_iomap_regions() fails. No need to
check for failure if the latter is already successful.

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
 drivers/pwm/pwm-dwc.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/pwm/pwm-dwc.c b/drivers/pwm/pwm-dwc.c
index 4929354f8cd9..596a0bb35c40 100644
--- a/drivers/pwm/pwm-dwc.c
+++ b/drivers/pwm/pwm-dwc.c
@@ -50,10 +50,6 @@ static int dwc_pwm_probe(struct pci_dev *pci, const struct pci_device_id *id)
 	}
 
 	dwc->base = pcim_iomap_table(pci)[0];
-	if (!dwc->base) {
-		dev_err(dev, "Base address missing\n");
-		return -ENOMEM;
-	}
 
 	ret = devm_pwmchip_add(dev, &dwc->chip);
 	if (ret)
-- 
2.35.3


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

* [PATCH v2 2/5] pwm: dwc: Add 16 channel support for Intel Elkhart Lake
  2024-02-08  7:05 [PATCH v2 0/5] DesignWare PWM improvements Raag Jadav
  2024-02-08  7:05 ` [PATCH v2 1/5] pwm: dwc: drop redundant error check Raag Jadav
@ 2024-02-08  7:05 ` Raag Jadav
  2024-02-08 17:20   ` Andy Shevchenko
  2024-02-08  7:05 ` [PATCH v2 3/5] pwm: dwc: simplify error handling Raag Jadav
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 26+ messages in thread
From: Raag Jadav @ 2024-02-08  7:05 UTC (permalink / raw)
  To: u.kleine-koenig, jarkko.nikula, mika.westerberg,
	andriy.shevchenko, lakshmi.sowjanya.d
  Cc: linux-pwm, linux-kernel, Raag Jadav

Intel Elkhart Lake PSE includes two instances of PWM as a single PCI
function with 8 channels each. Add support for the remaining channels.

Signed-off-by: Raag Jadav <raag.jadav@intel.com>
Tested-by: Lakshmi Sowjanya D <lakshmi.sowjanya.d@intel.com>
---
 drivers/pwm/pwm-dwc.c | 33 +++++++++++++++++++++++++--------
 drivers/pwm/pwm-dwc.h |  5 +++++
 2 files changed, 30 insertions(+), 8 deletions(-)

diff --git a/drivers/pwm/pwm-dwc.c b/drivers/pwm/pwm-dwc.c
index 596a0bb35c40..47d76f5367fe 100644
--- a/drivers/pwm/pwm-dwc.c
+++ b/drivers/pwm/pwm-dwc.c
@@ -25,16 +25,31 @@
 
 #include "pwm-dwc.h"
 
-static int dwc_pwm_probe(struct pci_dev *pci, const struct pci_device_id *id)
+/* Elkhart Lake */
+static const struct dwc_pwm_info ehl_pwm_info = {
+	.nr = 2,
+	.size = 0x1000,
+};
+
+static int dwc_pwm_init_one(struct device *dev, void __iomem *base, unsigned int offset)
 {
-	struct device *dev = &pci->dev;
 	struct dwc_pwm *dwc;
-	int ret;
 
 	dwc = dwc_pwm_alloc(dev);
 	if (!dwc)
 		return -ENOMEM;
 
+	dwc->base = base + offset;
+
+	return devm_pwmchip_add(dev, &dwc->chip);
+}
+
+static int dwc_pwm_probe(struct pci_dev *pci, const struct pci_device_id *id)
+{
+	const struct dwc_pwm_info *info;
+	struct device *dev = &pci->dev;
+	int i, ret;
+
 	ret = pcim_enable_device(pci);
 	if (ret) {
 		dev_err(dev, "Failed to enable device (%pe)\n", ERR_PTR(ret));
@@ -49,11 +64,13 @@ static int dwc_pwm_probe(struct pci_dev *pci, const struct pci_device_id *id)
 		return ret;
 	}
 
-	dwc->base = pcim_iomap_table(pci)[0];
+	info = (const struct dwc_pwm_info *)id->driver_data;
 
-	ret = devm_pwmchip_add(dev, &dwc->chip);
-	if (ret)
-		return ret;
+	for (i = 0; i < info->nr; i++) {
+		ret = dwc_pwm_init_one(dev, pcim_iomap_table(pci)[0], i * info->size);
+		if (ret)
+			return ret;
+	}
 
 	pm_runtime_put(dev);
 	pm_runtime_allow(dev);
@@ -105,7 +122,7 @@ static int dwc_pwm_resume(struct device *dev)
 static DEFINE_SIMPLE_DEV_PM_OPS(dwc_pwm_pm_ops, dwc_pwm_suspend, dwc_pwm_resume);
 
 static const struct pci_device_id dwc_pwm_id_table[] = {
-	{ PCI_VDEVICE(INTEL, 0x4bb7) }, /* Elkhart Lake */
+	{ PCI_VDEVICE(INTEL, 0x4bb7), (kernel_ulong_t)&ehl_pwm_info },
 	{  }	/* Terminating Entry */
 };
 MODULE_DEVICE_TABLE(pci, dwc_pwm_id_table);
diff --git a/drivers/pwm/pwm-dwc.h b/drivers/pwm/pwm-dwc.h
index 64795247c54c..c9bbfc77b568 100644
--- a/drivers/pwm/pwm-dwc.h
+++ b/drivers/pwm/pwm-dwc.h
@@ -33,6 +33,11 @@ MODULE_IMPORT_NS(dwc_pwm);
 #define DWC_TIM_CTRL_INT_MASK	BIT(2)
 #define DWC_TIM_CTRL_PWM	BIT(3)
 
+struct dwc_pwm_info {
+	unsigned int nr;
+	unsigned int size;
+};
+
 struct dwc_pwm_ctx {
 	u32 cnt;
 	u32 cnt2;
-- 
2.35.3


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

* [PATCH v2 3/5] pwm: dwc: simplify error handling
  2024-02-08  7:05 [PATCH v2 0/5] DesignWare PWM improvements Raag Jadav
  2024-02-08  7:05 ` [PATCH v2 1/5] pwm: dwc: drop redundant error check Raag Jadav
  2024-02-08  7:05 ` [PATCH v2 2/5] pwm: dwc: Add 16 channel support for Intel Elkhart Lake Raag Jadav
@ 2024-02-08  7:05 ` Raag Jadav
  2024-02-08 17:22   ` Andy Shevchenko
  2024-02-08  7:05 ` [PATCH v2 4/5] pwm: dwc: access driver_data using dev_get_drvdata() Raag Jadav
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 26+ messages in thread
From: Raag Jadav @ 2024-02-08  7:05 UTC (permalink / raw)
  To: u.kleine-koenig, jarkko.nikula, mika.westerberg,
	andriy.shevchenko, lakshmi.sowjanya.d
  Cc: linux-pwm, linux-kernel, Raag Jadav

Simplify error handling in ->probe() function using dev_err_probe() helper.

Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
 drivers/pwm/pwm-dwc.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/pwm/pwm-dwc.c b/drivers/pwm/pwm-dwc.c
index 47d76f5367fe..e1e3c62ecc56 100644
--- a/drivers/pwm/pwm-dwc.c
+++ b/drivers/pwm/pwm-dwc.c
@@ -51,18 +51,14 @@ static int dwc_pwm_probe(struct pci_dev *pci, const struct pci_device_id *id)
 	int i, ret;
 
 	ret = pcim_enable_device(pci);
-	if (ret) {
-		dev_err(dev, "Failed to enable device (%pe)\n", ERR_PTR(ret));
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to enable device (%pe)\n", ERR_PTR(ret));
 
 	pci_set_master(pci);
 
 	ret = pcim_iomap_regions(pci, BIT(0), pci_name(pci));
-	if (ret) {
-		dev_err(dev, "Failed to iomap PCI BAR (%pe)\n", ERR_PTR(ret));
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to iomap PCI BAR (%pe)\n", ERR_PTR(ret));
 
 	info = (const struct dwc_pwm_info *)id->driver_data;
 
-- 
2.35.3


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

* [PATCH v2 4/5] pwm: dwc: access driver_data using dev_get_drvdata()
  2024-02-08  7:05 [PATCH v2 0/5] DesignWare PWM improvements Raag Jadav
                   ` (2 preceding siblings ...)
  2024-02-08  7:05 ` [PATCH v2 3/5] pwm: dwc: simplify error handling Raag Jadav
@ 2024-02-08  7:05 ` Raag Jadav
  2024-02-08  7:05 ` [PATCH v2 5/5] pwm: dwc: use pm_sleep_ptr() macro Raag Jadav
  2024-02-08 17:23 ` [PATCH v2 0/5] DesignWare PWM improvements Andy Shevchenko
  5 siblings, 0 replies; 26+ messages in thread
From: Raag Jadav @ 2024-02-08  7:05 UTC (permalink / raw)
  To: u.kleine-koenig, jarkko.nikula, mika.westerberg,
	andriy.shevchenko, lakshmi.sowjanya.d
  Cc: linux-pwm, linux-kernel, Raag Jadav

Now that we're setting driver_data using dev_set_drvdata(), we can use
dev_get_drvdata() for accessing it.

Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
 drivers/pwm/pwm-dwc.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/pwm/pwm-dwc.c b/drivers/pwm/pwm-dwc.c
index e1e3c62ecc56..cc5bba977f47 100644
--- a/drivers/pwm/pwm-dwc.c
+++ b/drivers/pwm/pwm-dwc.c
@@ -82,8 +82,7 @@ static void dwc_pwm_remove(struct pci_dev *pci)
 
 static int dwc_pwm_suspend(struct device *dev)
 {
-	struct pci_dev *pdev = container_of(dev, struct pci_dev, dev);
-	struct dwc_pwm *dwc = pci_get_drvdata(pdev);
+	struct dwc_pwm *dwc = dev_get_drvdata(dev);
 	int i;
 
 	for (i = 0; i < DWC_TIMERS_TOTAL; i++) {
@@ -102,8 +101,7 @@ static int dwc_pwm_suspend(struct device *dev)
 
 static int dwc_pwm_resume(struct device *dev)
 {
-	struct pci_dev *pdev = container_of(dev, struct pci_dev, dev);
-	struct dwc_pwm *dwc = pci_get_drvdata(pdev);
+	struct dwc_pwm *dwc = dev_get_drvdata(dev);
 	int i;
 
 	for (i = 0; i < DWC_TIMERS_TOTAL; i++) {
-- 
2.35.3


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

* [PATCH v2 5/5] pwm: dwc: use pm_sleep_ptr() macro
  2024-02-08  7:05 [PATCH v2 0/5] DesignWare PWM improvements Raag Jadav
                   ` (3 preceding siblings ...)
  2024-02-08  7:05 ` [PATCH v2 4/5] pwm: dwc: access driver_data using dev_get_drvdata() Raag Jadav
@ 2024-02-08  7:05 ` Raag Jadav
  2024-02-08 17:22   ` Andy Shevchenko
  2024-02-08 17:23 ` [PATCH v2 0/5] DesignWare PWM improvements Andy Shevchenko
  5 siblings, 1 reply; 26+ messages in thread
From: Raag Jadav @ 2024-02-08  7:05 UTC (permalink / raw)
  To: u.kleine-koenig, jarkko.nikula, mika.westerberg,
	andriy.shevchenko, lakshmi.sowjanya.d
  Cc: linux-pwm, linux-kernel, Raag Jadav

Since we don't have runtime PM handles here, we should be using
pm_sleep_ptr() macro, so that the compiler can discard it in case
CONFIG_PM_SLEEP=n.

Fixes: 30b5b066fa83 ("pwm: dwc: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions")
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
 drivers/pwm/pwm-dwc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pwm/pwm-dwc.c b/drivers/pwm/pwm-dwc.c
index cc5bba977f47..bb39cc34f895 100644
--- a/drivers/pwm/pwm-dwc.c
+++ b/drivers/pwm/pwm-dwc.c
@@ -127,7 +127,7 @@ static struct pci_driver dwc_pwm_driver = {
 	.remove = dwc_pwm_remove,
 	.id_table = dwc_pwm_id_table,
 	.driver = {
-		.pm = pm_ptr(&dwc_pwm_pm_ops),
+		.pm = pm_sleep_ptr(&dwc_pwm_pm_ops),
 	},
 };
 
-- 
2.35.3


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

* Re: [PATCH v2 1/5] pwm: dwc: drop redundant error check
  2024-02-08  7:05 ` [PATCH v2 1/5] pwm: dwc: drop redundant error check Raag Jadav
@ 2024-02-08  7:46   ` Uwe Kleine-König
  2024-02-08 17:04     ` Andy Shevchenko
  0 siblings, 1 reply; 26+ messages in thread
From: Uwe Kleine-König @ 2024-02-08  7:46 UTC (permalink / raw)
  To: andriy.shevchenko, Raag Jadav
  Cc: jarkko.nikula, mika.westerberg, lakshmi.sowjanya.d, linux-pwm,
	linux-kernel

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

On Thu, Feb 08, 2024 at 12:35:25PM +0530, Raag Jadav wrote:
> pcim_iomap_table() fails only if pcim_iomap_regions() fails. No need to
> check for failure if the latter is already successful.

Is this really true? pcim_iomap_table() calls devres_alloc_node() which
might fail if the allocation fails. (Yes, I know
https://lwn.net/Articles/627419/, but the rule is still to check for
errors, right?)

What am I missing?

Best regards
Uwe

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

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

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

* Re: [PATCH v2 1/5] pwm: dwc: drop redundant error check
  2024-02-08  7:46   ` Uwe Kleine-König
@ 2024-02-08 17:04     ` Andy Shevchenko
  2024-02-08 17:06       ` Andy Shevchenko
  2024-02-14 17:45       ` Uwe Kleine-König
  0 siblings, 2 replies; 26+ messages in thread
From: Andy Shevchenko @ 2024-02-08 17:04 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Raag Jadav, jarkko.nikula, mika.westerberg, lakshmi.sowjanya.d,
	linux-pwm, linux-kernel

On Thu, Feb 08, 2024 at 08:46:44AM +0100, Uwe Kleine-König wrote:
> On Thu, Feb 08, 2024 at 12:35:25PM +0530, Raag Jadav wrote:
> > pcim_iomap_table() fails only if pcim_iomap_regions() fails. No need to
> > check for failure if the latter is already successful.
> 
> Is this really true? pcim_iomap_table() calls devres_alloc_node() which
> might fail if the allocation fails. (Yes, I know
> https://lwn.net/Articles/627419/, but the rule is still to check for
> errors, right?)

We do not add a dead code to the kernel, right?

> What am I missing?

Mysterious ways of the twisted PCI devres code.
Read the above commit message again :-)

For your convenience I can elaborate. pcim_iomap_table() calls _first_
devres_find() which _will_ succeed if the pcim_iomap_regions() previously
succeeded. Does it help to understand how it designed?

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v2 1/5] pwm: dwc: drop redundant error check
  2024-02-08 17:04     ` Andy Shevchenko
@ 2024-02-08 17:06       ` Andy Shevchenko
  2024-02-14 17:45       ` Uwe Kleine-König
  1 sibling, 0 replies; 26+ messages in thread
From: Andy Shevchenko @ 2024-02-08 17:06 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Raag Jadav, jarkko.nikula, mika.westerberg, lakshmi.sowjanya.d,
	linux-pwm, linux-kernel

On Thu, Feb 08, 2024 at 07:04:34PM +0200, Andy Shevchenko wrote:
> On Thu, Feb 08, 2024 at 08:46:44AM +0100, Uwe Kleine-König wrote:
> > On Thu, Feb 08, 2024 at 12:35:25PM +0530, Raag Jadav wrote:

...

> > (Yes, I know https://lwn.net/Articles/627419/,

Btw, it has nothing to do with this case.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v2 2/5] pwm: dwc: Add 16 channel support for Intel Elkhart Lake
  2024-02-08  7:05 ` [PATCH v2 2/5] pwm: dwc: Add 16 channel support for Intel Elkhart Lake Raag Jadav
@ 2024-02-08 17:20   ` Andy Shevchenko
  2024-02-09 19:18     ` Raag Jadav
  0 siblings, 1 reply; 26+ messages in thread
From: Andy Shevchenko @ 2024-02-08 17:20 UTC (permalink / raw)
  To: Raag Jadav
  Cc: u.kleine-koenig, jarkko.nikula, mika.westerberg,
	lakshmi.sowjanya.d, linux-pwm, linux-kernel

On Thu, Feb 08, 2024 at 12:35:26PM +0530, Raag Jadav wrote:
> Intel Elkhart Lake PSE includes two instances of PWM as a single PCI
> function with 8 channels each. Add support for the remaining channels.

Side Q: Have you used --histogram diff algo when prepared the series?
If no, it's better to start using it.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v2 3/5] pwm: dwc: simplify error handling
  2024-02-08  7:05 ` [PATCH v2 3/5] pwm: dwc: simplify error handling Raag Jadav
@ 2024-02-08 17:22   ` Andy Shevchenko
  2024-02-09 20:33     ` Raag Jadav
  0 siblings, 1 reply; 26+ messages in thread
From: Andy Shevchenko @ 2024-02-08 17:22 UTC (permalink / raw)
  To: Raag Jadav
  Cc: u.kleine-koenig, jarkko.nikula, mika.westerberg,
	lakshmi.sowjanya.d, linux-pwm, linux-kernel

On Thu, Feb 08, 2024 at 12:35:27PM +0530, Raag Jadav wrote:
> Simplify error handling in ->probe() function using dev_err_probe() helper.

...

> +		return dev_err_probe(dev, ret, "Failed to enable device (%pe)\n", ERR_PTR(ret));

Have you checked the output?
Note, it will duplicate error codes which we don't want.

...

> +		return dev_err_probe(dev, ret, "Failed to iomap PCI BAR (%pe)\n", ERR_PTR(ret));

Ditto.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v2 5/5] pwm: dwc: use pm_sleep_ptr() macro
  2024-02-08  7:05 ` [PATCH v2 5/5] pwm: dwc: use pm_sleep_ptr() macro Raag Jadav
@ 2024-02-08 17:22   ` Andy Shevchenko
  2024-02-15 11:22     ` Uwe Kleine-König
  0 siblings, 1 reply; 26+ messages in thread
From: Andy Shevchenko @ 2024-02-08 17:22 UTC (permalink / raw)
  To: Raag Jadav
  Cc: u.kleine-koenig, jarkko.nikula, mika.westerberg,
	lakshmi.sowjanya.d, linux-pwm, linux-kernel

On Thu, Feb 08, 2024 at 12:35:29PM +0530, Raag Jadav wrote:
> Since we don't have runtime PM handles here, we should be using
> pm_sleep_ptr() macro, so that the compiler can discard it in case
> CONFIG_PM_SLEEP=n.

> Fixes: 30b5b066fa83 ("pwm: dwc: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions")

Fixes always should go first in the series.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v2 0/5] DesignWare PWM improvements
  2024-02-08  7:05 [PATCH v2 0/5] DesignWare PWM improvements Raag Jadav
                   ` (4 preceding siblings ...)
  2024-02-08  7:05 ` [PATCH v2 5/5] pwm: dwc: use pm_sleep_ptr() macro Raag Jadav
@ 2024-02-08 17:23 ` Andy Shevchenko
  5 siblings, 0 replies; 26+ messages in thread
From: Andy Shevchenko @ 2024-02-08 17:23 UTC (permalink / raw)
  To: Raag Jadav
  Cc: u.kleine-koenig, jarkko.nikula, mika.westerberg,
	lakshmi.sowjanya.d, linux-pwm, linux-kernel

On Thu, Feb 08, 2024 at 12:35:24PM +0530, Raag Jadav wrote:
> This series implements 16 channel PWM support for Intel Elkhart Lake
> along with minor cleanups for DesignWare PWM driver.

> Raag Jadav (5):
>   pwm: dwc: drop redundant error check
>   pwm: dwc: Add 16 channel support for Intel Elkhart Lake
>   pwm: dwc: simplify error handling
>   pwm: dwc: access driver_data using dev_get_drvdata()
>   pwm: dwc: use pm_sleep_ptr() macro

For patches except #3
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v2 2/5] pwm: dwc: Add 16 channel support for Intel Elkhart Lake
  2024-02-08 17:20   ` Andy Shevchenko
@ 2024-02-09 19:18     ` Raag Jadav
  2024-02-09 19:41       ` Andy Shevchenko
  0 siblings, 1 reply; 26+ messages in thread
From: Raag Jadav @ 2024-02-09 19:18 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: u.kleine-koenig, jarkko.nikula, mika.westerberg,
	lakshmi.sowjanya.d, linux-pwm, linux-kernel

On Thu, Feb 08, 2024 at 07:20:59PM +0200, Andy Shevchenko wrote:
> On Thu, Feb 08, 2024 at 12:35:26PM +0530, Raag Jadav wrote:
> > Intel Elkhart Lake PSE includes two instances of PWM as a single PCI
> > function with 8 channels each. Add support for the remaining channels.
> 
> Side Q: Have you used --histogram diff algo when prepared the series?
> If no, it's better to start using it.

I used it for a few weeks, but I think I've grown a bit too comfortable
with patience.

I'll use histogram for pinctrl stuff if you insist :)

Raag

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

* Re: [PATCH v2 2/5] pwm: dwc: Add 16 channel support for Intel Elkhart Lake
  2024-02-09 19:18     ` Raag Jadav
@ 2024-02-09 19:41       ` Andy Shevchenko
  2024-02-10 17:19         ` Uwe Kleine-König
  0 siblings, 1 reply; 26+ messages in thread
From: Andy Shevchenko @ 2024-02-09 19:41 UTC (permalink / raw)
  To: Raag Jadav
  Cc: u.kleine-koenig, jarkko.nikula, mika.westerberg,
	lakshmi.sowjanya.d, linux-pwm, linux-kernel

On Fri, Feb 09, 2024 at 09:18:41PM +0200, Raag Jadav wrote:
> On Thu, Feb 08, 2024 at 07:20:59PM +0200, Andy Shevchenko wrote:
> > On Thu, Feb 08, 2024 at 12:35:26PM +0530, Raag Jadav wrote:
> > > Intel Elkhart Lake PSE includes two instances of PWM as a single PCI
> > > function with 8 channels each. Add support for the remaining channels.
> > 
> > Side Q: Have you used --histogram diff algo when prepared the series?
> > If no, it's better to start using it.
> 
> I used it for a few weeks, but I think I've grown a bit too comfortable
> with patience.
> 
> I'll use histogram for pinctrl stuff if you insist :)

It's recommended by Torvalds:
https://lore.kernel.org/linux-gpio/CAHk-=wiVNOFP1dzKdCqXvoery5p8QoBB5THiJUMbZ1TxJb7FhQ@mail.gmail.com/

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v2 3/5] pwm: dwc: simplify error handling
  2024-02-08 17:22   ` Andy Shevchenko
@ 2024-02-09 20:33     ` Raag Jadav
  2024-02-12 11:52       ` Andy Shevchenko
  0 siblings, 1 reply; 26+ messages in thread
From: Raag Jadav @ 2024-02-09 20:33 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: u.kleine-koenig, jarkko.nikula, mika.westerberg,
	lakshmi.sowjanya.d, linux-pwm, linux-kernel

On Thu, Feb 08, 2024 at 07:22:13PM +0200, Andy Shevchenko wrote:
> On Thu, Feb 08, 2024 at 12:35:27PM +0530, Raag Jadav wrote:
> > Simplify error handling in ->probe() function using dev_err_probe() helper.
> 
> ...
> 
> > +		return dev_err_probe(dev, ret, "Failed to enable device (%pe)\n", ERR_PTR(ret));
> 
> Have you checked the output?
> Note, it will duplicate error codes which we don't want.

True. Does it make sense to remove it?

Raag

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

* Re: [PATCH v2 2/5] pwm: dwc: Add 16 channel support for Intel Elkhart Lake
  2024-02-09 19:41       ` Andy Shevchenko
@ 2024-02-10 17:19         ` Uwe Kleine-König
  2024-02-12 11:53           ` Andy Shevchenko
  0 siblings, 1 reply; 26+ messages in thread
From: Uwe Kleine-König @ 2024-02-10 17:19 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Raag Jadav, jarkko.nikula, mika.westerberg, lakshmi.sowjanya.d,
	linux-pwm, linux-kernel

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

Hello,

On Fri, Feb 09, 2024 at 09:41:50PM +0200, Andy Shevchenko wrote:
> On Fri, Feb 09, 2024 at 09:18:41PM +0200, Raag Jadav wrote:
> > On Thu, Feb 08, 2024 at 07:20:59PM +0200, Andy Shevchenko wrote:
> > > On Thu, Feb 08, 2024 at 12:35:26PM +0530, Raag Jadav wrote:
> > > > Intel Elkhart Lake PSE includes two instances of PWM as a single PCI
> > > > function with 8 channels each. Add support for the remaining channels.
> > > 
> > > Side Q: Have you used --histogram diff algo when prepared the series?
> > > If no, it's better to start using it.
> > 
> > I used it for a few weeks, but I think I've grown a bit too comfortable
> > with patience.
> > 
> > I'll use histogram for pinctrl stuff if you insist :)
> 
> It's recommended by Torvalds:
> https://lore.kernel.org/linux-gpio/CAHk-=wiVNOFP1dzKdCqXvoery5p8QoBB5THiJUMbZ1TxJb7FhQ@mail.gmail.com/

BTW, the magic to use it by default is:

	git config --global diff.algorithm histogram

Best regards
Uwe

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

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

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

* Re: [PATCH v2 3/5] pwm: dwc: simplify error handling
  2024-02-09 20:33     ` Raag Jadav
@ 2024-02-12 11:52       ` Andy Shevchenko
  0 siblings, 0 replies; 26+ messages in thread
From: Andy Shevchenko @ 2024-02-12 11:52 UTC (permalink / raw)
  To: Raag Jadav
  Cc: u.kleine-koenig, jarkko.nikula, mika.westerberg,
	lakshmi.sowjanya.d, linux-pwm, linux-kernel

On Fri, Feb 09, 2024 at 10:33:01PM +0200, Raag Jadav wrote:
> On Thu, Feb 08, 2024 at 07:22:13PM +0200, Andy Shevchenko wrote:
> > On Thu, Feb 08, 2024 at 12:35:27PM +0530, Raag Jadav wrote:

...

> > > +		return dev_err_probe(dev, ret, "Failed to enable device (%pe)\n", ERR_PTR(ret));
> > 
> > Have you checked the output?
> > Note, it will duplicate error codes which we don't want.
> 
> True. Does it make sense to remove it?

"...which we don't want." had been stated above :-)

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v2 2/5] pwm: dwc: Add 16 channel support for Intel Elkhart Lake
  2024-02-10 17:19         ` Uwe Kleine-König
@ 2024-02-12 11:53           ` Andy Shevchenko
  0 siblings, 0 replies; 26+ messages in thread
From: Andy Shevchenko @ 2024-02-12 11:53 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Raag Jadav, jarkko.nikula, mika.westerberg, lakshmi.sowjanya.d,
	linux-pwm, linux-kernel

On Sat, Feb 10, 2024 at 06:19:53PM +0100, Uwe Kleine-König wrote:
> On Fri, Feb 09, 2024 at 09:41:50PM +0200, Andy Shevchenko wrote:
> > On Fri, Feb 09, 2024 at 09:18:41PM +0200, Raag Jadav wrote:
> > > On Thu, Feb 08, 2024 at 07:20:59PM +0200, Andy Shevchenko wrote:
> > > > On Thu, Feb 08, 2024 at 12:35:26PM +0530, Raag Jadav wrote:

...

> > > > Side Q: Have you used --histogram diff algo when prepared the series?
> > > > If no, it's better to start using it.
> > > 
> > > I used it for a few weeks, but I think I've grown a bit too comfortable
> > > with patience.
> > > 
> > > I'll use histogram for pinctrl stuff if you insist :)
> > 
> > It's recommended by Torvalds:
> > https://lore.kernel.org/linux-gpio/CAHk-=wiVNOFP1dzKdCqXvoery5p8QoBB5THiJUMbZ1TxJb7FhQ@mail.gmail.com/
> 
> BTW, the magic to use it by default is:
> 
> 	git config --global diff.algorithm histogram

Yep, that's what I have on my machines for development.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v2 1/5] pwm: dwc: drop redundant error check
  2024-02-08 17:04     ` Andy Shevchenko
  2024-02-08 17:06       ` Andy Shevchenko
@ 2024-02-14 17:45       ` Uwe Kleine-König
  2024-02-14 17:54         ` Andy Shevchenko
  1 sibling, 1 reply; 26+ messages in thread
From: Uwe Kleine-König @ 2024-02-14 17:45 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Raag Jadav, jarkko.nikula, mika.westerberg, lakshmi.sowjanya.d,
	linux-pwm, linux-kernel

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

Hello Andy,

On Thu, Feb 08, 2024 at 07:04:33PM +0200, Andy Shevchenko wrote:
> On Thu, Feb 08, 2024 at 08:46:44AM +0100, Uwe Kleine-König wrote:
> > On Thu, Feb 08, 2024 at 12:35:25PM +0530, Raag Jadav wrote:
> > > pcim_iomap_table() fails only if pcim_iomap_regions() fails. No need to
> > > check for failure if the latter is already successful.
> > 
> > Is this really true? pcim_iomap_table() calls devres_alloc_node() which
> > might fail if the allocation fails. (Yes, I know
> > https://lwn.net/Articles/627419/, but the rule is still to check for
> > errors, right?)
> 
> We do not add a dead code to the kernel, right?
> 
> > What am I missing?
> 
> Mysterious ways of the twisted PCI devres code.
> Read the above commit message again :-)
> 
> For your convenience I can elaborate. pcim_iomap_table() calls _first_
> devres_find() which _will_ succeed if the pcim_iomap_regions() previously
> succeeded. Does it help to understand how it designed?

I assume you're saying that after pcim_iomap_regions() succeeded it's
already known that pcim_iomap_table() succeeds (because the former
already called the latter).

I'm still concerned here. I agree that error checking might be skipped
if it's clear that no error can happen (the device cannot disappear
between these two calls, can it?), but for me as an uninitiated pci code
reader, I wonder about

	dwc->base = pcim_iomap_table(pci)[0];

without error checking. (OTOH, if pcim_iomap_table() returned NULL, the
"[0]" part is already problematic.)

I'd like to have a code comment here saying that pcim_iomap_table()
won't return NULL.

Best regards
Uwe

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

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

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

* Re: [PATCH v2 1/5] pwm: dwc: drop redundant error check
  2024-02-14 17:45       ` Uwe Kleine-König
@ 2024-02-14 17:54         ` Andy Shevchenko
  2024-02-15  9:22           ` Uwe Kleine-König
  0 siblings, 1 reply; 26+ messages in thread
From: Andy Shevchenko @ 2024-02-14 17:54 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Raag Jadav, jarkko.nikula, mika.westerberg, lakshmi.sowjanya.d,
	linux-pwm, linux-kernel

On Wed, Feb 14, 2024 at 06:45:48PM +0100, Uwe Kleine-König wrote:
> On Thu, Feb 08, 2024 at 07:04:33PM +0200, Andy Shevchenko wrote:
> > On Thu, Feb 08, 2024 at 08:46:44AM +0100, Uwe Kleine-König wrote:
> > > On Thu, Feb 08, 2024 at 12:35:25PM +0530, Raag Jadav wrote:
> > > > pcim_iomap_table() fails only if pcim_iomap_regions() fails. No need to
> > > > check for failure if the latter is already successful.
> > > 
> > > Is this really true? pcim_iomap_table() calls devres_alloc_node() which
> > > might fail if the allocation fails. (Yes, I know
> > > https://lwn.net/Articles/627419/, but the rule is still to check for
> > > errors, right?)
> > 
> > We do not add a dead code to the kernel, right?
> > 
> > > What am I missing?
> > 
> > Mysterious ways of the twisted PCI devres code.
> > Read the above commit message again :-)
> > 
> > For your convenience I can elaborate. pcim_iomap_table() calls _first_
> > devres_find() which _will_ succeed if the pcim_iomap_regions() previously
> > succeeded. Does it help to understand how it designed?
> 
> I assume you're saying that after pcim_iomap_regions() succeeded it's
> already known that pcim_iomap_table() succeeds (because the former
> already called the latter).
> 
> I'm still concerned here. I agree that error checking might be skipped
> if it's clear that no error can happen (the device cannot disappear
> between these two calls, can it?), 

It depends. If you call it in some asynchronous callbacks which may be run
after PCI device disappears, then indeed, it's problematic. But you probably
will have much bigger issue at that point already.

In ->probe() it's guaranteed to work as I suggested (assuming properly working
hardware).

> but for me as an uninitiated pci code
> reader, I wonder about
> 
> 	dwc->base = pcim_iomap_table(pci)[0];
> 
> without error checking. (OTOH, if pcim_iomap_table() returned NULL, the
> "[0]" part is already problematic.)

Seems it's your problem, many drivers use the way I suggested.

> I'd like to have a code comment here saying that pcim_iomap_table()
> won't return NULL.

Why? It's redundant. If you use it, you should know this API.
So, the bottom line, does this API needs better documentation?

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v2 1/5] pwm: dwc: drop redundant error check
  2024-02-14 17:54         ` Andy Shevchenko
@ 2024-02-15  9:22           ` Uwe Kleine-König
  2024-02-15 13:36             ` Andy Shevchenko
  0 siblings, 1 reply; 26+ messages in thread
From: Uwe Kleine-König @ 2024-02-15  9:22 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Raag Jadav, jarkko.nikula, mika.westerberg, lakshmi.sowjanya.d,
	linux-pwm, linux-kernel

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

On Wed, Feb 14, 2024 at 07:54:58PM +0200, Andy Shevchenko wrote:
> On Wed, Feb 14, 2024 at 06:45:48PM +0100, Uwe Kleine-König wrote:
> > On Thu, Feb 08, 2024 at 07:04:33PM +0200, Andy Shevchenko wrote:
> > > On Thu, Feb 08, 2024 at 08:46:44AM +0100, Uwe Kleine-König wrote:
> > > > On Thu, Feb 08, 2024 at 12:35:25PM +0530, Raag Jadav wrote:
> > > > > pcim_iomap_table() fails only if pcim_iomap_regions() fails. No need to
> > > > > check for failure if the latter is already successful.
> > > > 
> > > > Is this really true? pcim_iomap_table() calls devres_alloc_node() which
> > > > might fail if the allocation fails. (Yes, I know
> > > > https://lwn.net/Articles/627419/, but the rule is still to check for
> > > > errors, right?)
> > > 
> > > We do not add a dead code to the kernel, right?
> > > 
> > > > What am I missing?
> > > 
> > > Mysterious ways of the twisted PCI devres code.
> > > Read the above commit message again :-)
> > > 
> > > For your convenience I can elaborate. pcim_iomap_table() calls _first_
> > > devres_find() which _will_ succeed if the pcim_iomap_regions() previously
> > > succeeded. Does it help to understand how it designed?
> > 
> > I assume you're saying that after pcim_iomap_regions() succeeded it's
> > already known that pcim_iomap_table() succeeds (because the former
> > already called the latter).
> > 
> > I'm still concerned here. I agree that error checking might be skipped
> > if it's clear that no error can happen (the device cannot disappear
> > between these two calls, can it?), 
> 
> It depends. If you call it in some asynchronous callbacks which may be run
> after PCI device disappears, then indeed, it's problematic. But you probably
> will have much bigger issue at that point already.
> 
> In ->probe() it's guaranteed to work as I suggested (assuming properly working
> hardware).

Assuming properly working hardware allows to drop many error checks :-)

> > but for me as an uninitiated pci code
> > reader, I wonder about
> > 
> > 	dwc->base = pcim_iomap_table(pci)[0];
> > 
> > without error checking. (OTOH, if pcim_iomap_table() returned NULL, the
> > "[0]" part is already problematic.)
> 
> Seems it's your problem, many drivers use the way I suggested.
> 
> > I'd like to have a code comment here saying that pcim_iomap_table()
> > won't return NULL.
> 
> Why? It's redundant. If you use it, you should know this API.
> So, the bottom line, does this API needs better documentation?

If a driver author knows it while writing the code, it's obvious. But if
the driver author looks again in 2 years or someone else (e.g. me with
the PWM maintainer hat on and with little pci experience) that knowledge
might be faded.

Best regards
Uwe

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

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

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

* Re: [PATCH v2 5/5] pwm: dwc: use pm_sleep_ptr() macro
  2024-02-08 17:22   ` Andy Shevchenko
@ 2024-02-15 11:22     ` Uwe Kleine-König
  0 siblings, 0 replies; 26+ messages in thread
From: Uwe Kleine-König @ 2024-02-15 11:22 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Raag Jadav, jarkko.nikula, mika.westerberg, lakshmi.sowjanya.d,
	linux-pwm, linux-kernel

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

On Thu, Feb 08, 2024 at 07:22:52PM +0200, Andy Shevchenko wrote:
> On Thu, Feb 08, 2024 at 12:35:29PM +0530, Raag Jadav wrote:
> > Since we don't have runtime PM handles here, we should be using
> > pm_sleep_ptr() macro, so that the compiler can discard it in case
> > CONFIG_PM_SLEEP=n.
> 
> > Fixes: 30b5b066fa83 ("pwm: dwc: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions")
> 
> Fixes always should go first in the series.

No need to resend for that, I'll pick patches 3-5 in the order I
consider sensible. Git seems to handle that just fine.

Best regards
Uwe

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

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

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

* Re: [PATCH v2 1/5] pwm: dwc: drop redundant error check
  2024-02-15  9:22           ` Uwe Kleine-König
@ 2024-02-15 13:36             ` Andy Shevchenko
  2024-02-15 17:20               ` Uwe Kleine-König
  0 siblings, 1 reply; 26+ messages in thread
From: Andy Shevchenko @ 2024-02-15 13:36 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Raag Jadav, jarkko.nikula, mika.westerberg, lakshmi.sowjanya.d,
	linux-pwm, linux-kernel

On Thu, Feb 15, 2024 at 10:22:57AM +0100, Uwe Kleine-König wrote:
> On Wed, Feb 14, 2024 at 07:54:58PM +0200, Andy Shevchenko wrote:
> > On Wed, Feb 14, 2024 at 06:45:48PM +0100, Uwe Kleine-König wrote:
> > > On Thu, Feb 08, 2024 at 07:04:33PM +0200, Andy Shevchenko wrote:
> > > > On Thu, Feb 08, 2024 at 08:46:44AM +0100, Uwe Kleine-König wrote:
> > > > > On Thu, Feb 08, 2024 at 12:35:25PM +0530, Raag Jadav wrote:
> > > > > > pcim_iomap_table() fails only if pcim_iomap_regions() fails. No need to
> > > > > > check for failure if the latter is already successful.
> > > > > 
> > > > > Is this really true? pcim_iomap_table() calls devres_alloc_node() which
> > > > > might fail if the allocation fails. (Yes, I know
> > > > > https://lwn.net/Articles/627419/, but the rule is still to check for
> > > > > errors, right?)
> > > > 
> > > > We do not add a dead code to the kernel, right?
> > > > 
> > > > > What am I missing?
> > > > 
> > > > Mysterious ways of the twisted PCI devres code.
> > > > Read the above commit message again :-)
> > > > 
> > > > For your convenience I can elaborate. pcim_iomap_table() calls _first_
> > > > devres_find() which _will_ succeed if the pcim_iomap_regions() previously
> > > > succeeded. Does it help to understand how it designed?
> > > 
> > > I assume you're saying that after pcim_iomap_regions() succeeded it's
> > > already known that pcim_iomap_table() succeeds (because the former
> > > already called the latter).
> > > 
> > > I'm still concerned here. I agree that error checking might be skipped
> > > if it's clear that no error can happen (the device cannot disappear
> > > between these two calls, can it?), 
> > 
> > It depends. If you call it in some asynchronous callbacks which may be run
> > after PCI device disappears, then indeed, it's problematic. But you probably
> > will have much bigger issue at that point already.
> > 
> > In ->probe() it's guaranteed to work as I suggested (assuming properly working
> > hardware).
> 
> Assuming properly working hardware allows to drop many error checks :-)

Yes, and we have some checks are being not implemented ("dropped"), but here is
the thing: this is a PCI device and surprise removal (while it's not possible
for the on-die devices) should be handled differently, not related to this code
anyway. Malicious hardware is out of scope either.

> > > but for me as an uninitiated pci code
> > > reader, I wonder about
> > > 
> > > 	dwc->base = pcim_iomap_table(pci)[0];
> > > 
> > > without error checking. (OTOH, if pcim_iomap_table() returned NULL, the
> > > "[0]" part is already problematic.)
> > 
> > Seems it's your problem, many drivers use the way I suggested.
> > 
> > > I'd like to have a code comment here saying that pcim_iomap_table()
> > > won't return NULL.
> > 
> > Why? It's redundant. If you use it, you should know this API.
> > So, the bottom line, does this API needs better documentation?
> 
> If a driver author knows it while writing the code, it's obvious. But if
> the driver author looks again in 2 years or someone else (e.g. me with
> the PWM maintainer hat on and with little pci experience) that knowledge
> might be faded.

This is widely used pattern. Anybody who works with Git should know how
to use `git grep` tool. If in doubts, always can ask in the mailing lists.
I still consider it redundant.

P.S. That's what you call "bikeshedding" (done by yourself here)?



-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v2 1/5] pwm: dwc: drop redundant error check
  2024-02-15 13:36             ` Andy Shevchenko
@ 2024-02-15 17:20               ` Uwe Kleine-König
  2024-02-15 19:25                 ` Andy Shevchenko
  0 siblings, 1 reply; 26+ messages in thread
From: Uwe Kleine-König @ 2024-02-15 17:20 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Raag Jadav, jarkko.nikula, mika.westerberg, lakshmi.sowjanya.d,
	linux-pwm, linux-kernel

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

Hello Andy,

On Thu, Feb 15, 2024 at 03:36:12PM +0200, Andy Shevchenko wrote:
> On Thu, Feb 15, 2024 at 10:22:57AM +0100, Uwe Kleine-König wrote:
> > If a driver author knows it while writing the code, it's obvious. But if
> > the driver author looks again in 2 years or someone else (e.g. me with
> > the PWM maintainer hat on and with little pci experience) that knowledge
> > might be faded.
> 
> This is widely used pattern. Anybody who works with Git should know how
> to use `git grep` tool. If in doubts, always can ask in the mailing lists.

IMHO you're assuming to much. If someone sees this pattern and quickly
looks at the implementation of pcim_iomap_table() they might (as I did)
conclude that this call should be error checked. If they send a patch in
say 2 years I think I won't remember this discussion/patch and happily
accept this patch. And I probably won't get enough doubts to start
grepping around.

> I still consider it redundant.
> 
> P.S. That's what you call "bikeshedding" (done by yourself here)?

I can understand that you consider that bikeshedding given that for you
it's obvious that the second function cannot fail. For me it's not and I
take this as a hint that it's not obvious for everyone.

Best regards
Uwe

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

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

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

* Re: [PATCH v2 1/5] pwm: dwc: drop redundant error check
  2024-02-15 17:20               ` Uwe Kleine-König
@ 2024-02-15 19:25                 ` Andy Shevchenko
  0 siblings, 0 replies; 26+ messages in thread
From: Andy Shevchenko @ 2024-02-15 19:25 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Raag Jadav, jarkko.nikula, mika.westerberg, lakshmi.sowjanya.d,
	linux-pwm, linux-kernel

On Thu, Feb 15, 2024 at 06:20:15PM +0100, Uwe Kleine-König wrote:
> On Thu, Feb 15, 2024 at 03:36:12PM +0200, Andy Shevchenko wrote:
> > On Thu, Feb 15, 2024 at 10:22:57AM +0100, Uwe Kleine-König wrote:
> > > If a driver author knows it while writing the code, it's obvious. But if
> > > the driver author looks again in 2 years or someone else (e.g. me with
> > > the PWM maintainer hat on and with little pci experience) that knowledge
> > > might be faded.
> > 
> > This is widely used pattern. Anybody who works with Git should know how
> > to use `git grep` tool. If in doubts, always can ask in the mailing lists.
> 
> IMHO you're assuming to much. If someone sees this pattern and quickly
> looks at the implementation of pcim_iomap_table() they might (as I did)
> conclude that this call should be error checked. If they send a patch in
> say 2 years I think I won't remember this discussion/patch and happily
> accept this patch. And I probably won't get enough doubts to start
> grepping around.
> 
> > I still consider it redundant.
> > 
> > P.S. That's what you call "bikeshedding" (done by yourself here)?
> 
> I can understand that you consider that bikeshedding given that for you
> it's obvious that the second function cannot fail. For me it's not and I
> take this as a hint that it's not obvious for everyone.

The bottom line that PCI devres code should be refactored. And IIRC somebody
is doing that job, not sure at which stage it is now.

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2024-02-15 19:26 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-08  7:05 [PATCH v2 0/5] DesignWare PWM improvements Raag Jadav
2024-02-08  7:05 ` [PATCH v2 1/5] pwm: dwc: drop redundant error check Raag Jadav
2024-02-08  7:46   ` Uwe Kleine-König
2024-02-08 17:04     ` Andy Shevchenko
2024-02-08 17:06       ` Andy Shevchenko
2024-02-14 17:45       ` Uwe Kleine-König
2024-02-14 17:54         ` Andy Shevchenko
2024-02-15  9:22           ` Uwe Kleine-König
2024-02-15 13:36             ` Andy Shevchenko
2024-02-15 17:20               ` Uwe Kleine-König
2024-02-15 19:25                 ` Andy Shevchenko
2024-02-08  7:05 ` [PATCH v2 2/5] pwm: dwc: Add 16 channel support for Intel Elkhart Lake Raag Jadav
2024-02-08 17:20   ` Andy Shevchenko
2024-02-09 19:18     ` Raag Jadav
2024-02-09 19:41       ` Andy Shevchenko
2024-02-10 17:19         ` Uwe Kleine-König
2024-02-12 11:53           ` Andy Shevchenko
2024-02-08  7:05 ` [PATCH v2 3/5] pwm: dwc: simplify error handling Raag Jadav
2024-02-08 17:22   ` Andy Shevchenko
2024-02-09 20:33     ` Raag Jadav
2024-02-12 11:52       ` Andy Shevchenko
2024-02-08  7:05 ` [PATCH v2 4/5] pwm: dwc: access driver_data using dev_get_drvdata() Raag Jadav
2024-02-08  7:05 ` [PATCH v2 5/5] pwm: dwc: use pm_sleep_ptr() macro Raag Jadav
2024-02-08 17:22   ` Andy Shevchenko
2024-02-15 11:22     ` Uwe Kleine-König
2024-02-08 17:23 ` [PATCH v2 0/5] DesignWare PWM improvements Andy Shevchenko

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