DesignWare PWM improvements
v2 cover DesignWare PWM improvements
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
Signature · 1 line
2.35.3
PATCH v2 1/5 pwm: dwc: drop redundant error check
pcim_iomap_table() fails only if pcim_iomap_regions() fails. No need to check for failure if the latter is already successful.
--- drivers/pwm/pwm-dwc.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/pwm/pwm-dwc.c +0 -4
@@ -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)
Signature · 1 line
2.35.3
Re: [PATCH v2 1/5] pwm: dwc: drop redundant error check
Quoted 2 lines · Raag Jadav
pcim_iomap_table()fails only ifpcim_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
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |
Re: [PATCH v2 1/5] pwm: dwc: drop redundant error check
Quoted 8 lines · Uwe Kleine-König
Quoted 2 lines · Raag Jadav
pcim_iomap_table()fails only ifpcim_iomap_regions()fails. No need to check for failure if the latter is already successful.Is this really true?
pcim_iomap_table()callsdevres_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?
Quoted 1 line
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?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 1/5] pwm: dwc: drop redundant error check
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Uwe Kleine-König
On Thu, Feb 08, 2024 at 12:35:25PM +0530, Raag Jadav wrote:
...
Quoted 1 line
Quoted 1 line
(Yes, I know https://lwn.net/Articles/627419/,
Btw, it has nothing to do with this case.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 1/5] pwm: dwc: drop redundant error check
In reply to Andy ShevchenkoHello Andy,
Quoted 12 lines · Andy Shevchenko
Quoted 8 lines · Uwe Kleine-König
Quoted 2 lines · Raag Jadav
pcim_iomap_table()fails only ifpcim_iomap_regions()fails. No need to check for failure if the latter is already successful.Is this really true?
pcim_iomap_table()callsdevres_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?
Quoted 8 lines
Quoted 1 line
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 thepcim_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
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |
Re: [PATCH v2 1/5] pwm: dwc: drop redundant error check
Quoted 22 lines · Uwe Kleine-König
Quoted 12 lines · Andy Shevchenko
Quoted 8 lines · Uwe Kleine-König
Quoted 2 lines · Raag Jadav
pcim_iomap_table()fails only ifpcim_iomap_regions()fails. No need to check for failure if the latter is already successful.Is this really true?
pcim_iomap_table()callsdevres_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?
Quoted 8 lines
Quoted 1 line
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 thepcim_iomap_regions()previously succeeded. Does it help to understand how it designed?
Quoted 7 lines
I assume you're saying that after
pcim_iomap_regions()succeeded it's already known thatpcim_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).
Quoted 7 lines
but for me as an uninitiated pci code
reader, I wonder aboutdwc->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.
Quoted 2 lines
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?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 1/5] pwm: dwc: drop redundant error check
Quoted 31 lines · Andy Shevchenko
Quoted 22 lines · Uwe Kleine-König
Quoted 12 lines · Andy Shevchenko
Quoted 8 lines · Uwe Kleine-König
Quoted 2 lines · Raag Jadav
pcim_iomap_table()fails only ifpcim_iomap_regions()fails. No need to check for failure if the latter is already successful.Is this really true?
pcim_iomap_table()callsdevres_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?
Quoted 8 lines
Quoted 1 line
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 thepcim_iomap_regions()previously succeeded. Does it help to understand how it designed?Quoted 7 lines
I assume you're saying that after
pcim_iomap_regions()succeeded it's already known thatpcim_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?),
Quoted 6 lines
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 :-)
Quoted 8 lines
Quoted 7 lines
but for me as an uninitiated pci code
reader, I wonder aboutdwc->base = pcim_iomap_table(pci)[0];without error checking. (OTOH, if
pcim_iomap_table()returned NULL, the "[0]" part is already problematic.)
Quoted 7 lines
Seems it's your problem, many drivers use the way I suggested.
Quoted 2 lines
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
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |
Re: [PATCH v2 1/5] pwm: dwc: drop redundant error check
Quoted 32 lines · Uwe Kleine-König
Quoted 31 lines · Andy Shevchenko
Quoted 29 lines · Uwe Kleine-König
Quoted 12 lines · Andy Shevchenko
Quoted 8 lines · Uwe Kleine-König
Quoted 2 lines · Raag Jadav
pcim_iomap_table()fails only ifpcim_iomap_regions()fails. No need to check for failure if the latter is already successful.Is this really true?
pcim_iomap_table()callsdevres_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?
Quoted 8 lines
Quoted 1 line
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 thepcim_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 thatpcim_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?),
Quoted 8 lines
Quoted 6 lines
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.
Quoted 13 lines
Quoted 13 lines
Quoted 7 lines
but for me as an uninitiated pci code
reader, I wonder aboutdwc->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.
Quoted 2 lines
I'd like to have a code comment here saying that
pcim_iomap_table()won't return NULL.
Quoted 7 lines
Quoted 2 lines
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)?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 1/5] pwm: dwc: drop redundant error check
Hello Andy,
Quoted 8 lines · Andy Shevchenko
Quoted 4 lines · Uwe Kleine-König
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 greptool. 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.
Quoted 3 lines
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
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |
Re: [PATCH v2 1/5] pwm: dwc: drop redundant error check
Quoted 17 lines · Uwe Kleine-König
Quoted 8 lines · Andy Shevchenko
Quoted 4 lines · Uwe Kleine-König
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 greptool. 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.
Quoted 7 lines
Quoted 3 lines
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.
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v2 2/5 pwm: dwc: Add 16 channel support for Intel Elkhart Lake
In reply to Raag JadavIntel Elkhart Lake PSE includes two instances of PWM as a single PCI function with 8 channels each. Add support for the remaining channels.
--- drivers/pwm/pwm-dwc.c | 33 +++++++++++++++++++++++++-------- drivers/pwm/pwm-dwc.h | 5 +++++ 2 files changed, 30 insertions(+), 8 deletions(-)
drivers/pwm/pwm-dwc.c +25 -8
@@ -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);
drivers/pwm/pwm-dwc.h +5 -0
@@ -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;
Signature · 1 line
2.35.3
Re: [PATCH v2 2/5] pwm: dwc: Add 16 channel support for Intel Elkhart Lake
Quoted 2 lines · 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.
Side Q: Have you used --histogram diff algo when prepared the series? If no, it's better to start using it.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 2/5] pwm: dwc: Add 16 channel support for Intel Elkhart Lake
Quoted 6 lines · Andy Shevchenko
Quoted 2 lines · 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.
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
Re: [PATCH v2 2/5] pwm: dwc: Add 16 channel support for Intel Elkhart Lake
Quoted 5 lines · Raag Jadav
Quoted 4 lines · Andy Shevchenko
Quoted 2 lines · 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.
Quoted 7 lines
Quoted 2 lines
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/
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 2/5] pwm: dwc: Add 16 channel support for Intel Elkhart Lake
Hello,
Quoted 9 lines · Andy Shevchenko
Quoted 8 lines · Raag Jadav
Quoted 6 lines · Andy Shevchenko
Quoted 2 lines · 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.
Side Q: Have you used --histogram diff algo when prepared the series? If no, it's better to start using it.
Quoted 7 lines
Quoted 4 lines
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
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |
Re: [PATCH v2 2/5] pwm: dwc: Add 16 channel support for Intel Elkhart Lake
Quoted 4 lines · Uwe Kleine-König
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Raag Jadav
Quoted 1 line · Andy Shevchenko
On Thu, Feb 08, 2024 at 12:35:26PM +0530, Raag Jadav wrote:
...
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
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.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
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.
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v2 3/5 pwm: dwc: simplify error handling
In reply to Raag JadavSimplify error handling in ->probe() function using dev_err_probe() helper.
--- drivers/pwm/pwm-dwc.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/pwm/pwm-dwc.c +4 -8
@@ -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;
Signature · 1 line
2.35.3
Re: [PATCH v2 3/5] pwm: dwc: simplify error handling
Quoted 1 line · Raag Jadav
Simplify error handling in ->probe() function using
dev_err_probe()helper.
...
drivers/pwm/pwm-dwc.c static int dwc_pwm_probe(struct pci_dev *pci, const struct pci_device_id *id) · line 55
Quoted 1 line
drivers/pwm/pwm-dwc.c +1
-0+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.
...
drivers/pwm/pwm-dwc.c static int dwc_pwm_probe(struct pci_dev *pci, const struct pci_device_id *id) · line 61
Quoted 1 line
drivers/pwm/pwm-dwc.c +1
-0+return dev_err_probe (dev, ret,"Failed to iomap PCI BAR (%pe)\n" ,ERR_PTR (ret));
Ditto.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 3/5] pwm: dwc: simplify error handling
Quoted 9 lines · Andy Shevchenko
Quoted 1 line · Raag Jadav
Simplify error handling in ->probe() function using
dev_err_probe()helper....
drivers/pwm/pwm-dwc.c static int dwc_pwm_probe(struct pci_dev *pci, const struct pci_device_id *id) · line 55
Quoted 1 line
drivers/pwm/pwm-dwc.c +1
-0+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
Re: [PATCH v2 3/5] pwm: dwc: simplify error handling
Quoted 2 lines · Raag Jadav
Quoted 1 line · Andy Shevchenko
On Thu, Feb 08, 2024 at 12:35:27PM +0530, Raag Jadav wrote:
...
Quoted 6 lines
Quoted 4 lines
drivers/pwm/pwm-dwc.c static int dwc_pwm_probe(struct pci_dev *pci, const struct pci_device_id *id) · line 55
Quoted 1 line
drivers/pwm/pwm-dwc.c +1
-0+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 :-)
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v2 4/5 pwm: dwc: access driver_data using dev_get_drvdata()
In reply to Raag JadavNow that we're setting driver_data using dev_set_drvdata(), we can use dev_get_drvdata() for accessing it.
--- drivers/pwm/pwm-dwc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/pwm/pwm-dwc.c +2 -4
@@ -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++) {
Signature · 1 line
2.35.3
PATCH v2 5/5 pwm: dwc: use pm_sleep_ptr() macro
In reply to Raag JadavSince 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.
--- drivers/pwm/pwm-dwc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pwm/pwm-dwc.c +1 -1
@@ -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), }, };
Signature · 1 line
2.35.3
Re: [PATCH v2 5/5] pwm: dwc: use pm_sleep_ptr() macro
Quoted 5 lines · 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 caseCONFIG_PM_SLEEP=n.Fixes 30b5b066fa83 ("pwm: dwc: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions")
Fixes always should go first in the series.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 5/5] pwm: dwc: use pm_sleep_ptr() macro
Quoted 8 lines · Andy Shevchenko
Quoted 5 lines · 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 caseCONFIG_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
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |
Quoted 9 lines · Raag Jadav
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: accessdriver_datausingdev_get_drvdata()
pwm: dwc: usepm_sleep_ptr()macro
For patches except #3
Signature · 2 lines
With Best Regards, Andy Shevchenko