Re: [PATCH V5 3/3] hwmon: pwm-fan: Add RPM support via external interrupt

From: Guenter Roeck
Date: Fri Apr 12 2019 - 10:29:17 EST


On 4/12/19 6:54 AM, Robin Murphy wrote:
On 12/04/2019 14:50, Guenter Roeck wrote:
On 4/12/19 4:50 AM, Robin Murphy wrote:
On 12/04/2019 12:07, Stefan Wahren wrote:
On 11.04.19 18:57, Guenter Roeck wrote:
On Thu, Apr 11, 2019 at 03:30:11PM +0200, Stefan Wahren wrote:
-ATTRIBUTE_GROUPS(pwm_fan);
+static umode_t pwm_fan_attrs_visible(struct kobject *kobj, struct attribute *a,
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ int n)
+{
+ÂÂÂ struct device *dev = container_of(kobj, struct device, kobj);
+ÂÂÂ struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
+ÂÂÂ struct device_attribute *devattr;
+
+ /* Hide fan_input in case no interrupt is available */
+ÂÂÂ devattr = container_of(a, struct device_attribute, attr);
Field day for static analyzers - devattr is no longer used.
No need to resend. I'll let the series rest for a couple of days
and then apply to hwmon-next (after removing devattr) unless there are
additional comments.

Thank you

FWIW you can have a

Reviewed-by: Robin Murphy <robin.murphy@xxxxxxx>

for the whole series. The only minor comment that springs to mind
isn't actually specific to this patch, so is probably best made as
the follow-up below.

Robin.


Any chance you can send the patch below as separate patch ? I track patches
using patchwork, and attachments don't show up there.

Sure, can do - would you like an explicit R-b on #1 and #2 here for patchwork to pick up as well?
That would simplify my life a bit, but I can add that part myself to the patches.
I primarily like to have the patches in patchwork to make sure they don't get lost
and that I can pick them up again later if needed.

Thanks,
Guenter

Robin.


Thanks,
Guenter

----->8-----
From: Robin Murphy <robin.murphy@xxxxxxx>
Subject: [PATCH] hwmon: pwm-fan: Report probe errors consistently

Printing the error code for a failure provides a head-start for
debugging, since it's often sufficient to pinpoint the origin of the
failure. We already do this for some probe-failure messages, so let's
make the rest of them consistent.

Signed-off-by: Robin Murphy <robin.murphy@xxxxxxx>
---
 drivers/hwmon/pwm-fan.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 8c4c5eefd4ca..556db4bef743 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -330,7 +330,7 @@ static int pwm_fan_probe(struct platform_device *pdev)

ÂÂÂÂÂ ret = pwm_apply_state(ctx->pwm, &state);
ÂÂÂÂÂ if (ret) {
-ÂÂÂÂÂÂÂ dev_err(&pdev->dev, "Failed to configure PWM\n");
+ÂÂÂÂÂÂÂ dev_err(&pdev->dev, "Failed to configure PWM: %d\n", ret);
ÂÂÂÂÂÂÂÂÂ goto err_reg_disable;
ÂÂÂÂÂ }

@@ -348,7 +348,8 @@ static int pwm_fan_probe(struct platform_device *pdev)
ÂÂÂÂÂÂÂÂÂ ret = devm_request_irq(&pdev->dev, ctx->irq, pulse_handler, 0,
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ pdev->name, ctx);
ÂÂÂÂÂÂÂÂÂ if (ret) {
-ÂÂÂÂÂÂÂÂÂÂÂ dev_err(&pdev->dev, "Can't get interrupt working.\n");
+ÂÂÂÂÂÂÂÂÂÂÂ dev_err(&pdev->dev,
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ "Failed to request interrupt: %d\n", ret);
ÂÂÂÂÂÂÂÂÂÂÂÂÂ goto err_pwm_disable;
ÂÂÂÂÂÂÂÂÂ }
ÂÂÂÂÂÂÂÂÂ ctx->sample_start = ktime_get();
@@ -358,8 +359,9 @@ static int pwm_fan_probe(struct platform_device *pdev)
ÂÂÂÂÂ hwmon = devm_hwmon_device_register_with_groups(&pdev->dev, "pwmfan",
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ ctx, pwm_fan_groups);
ÂÂÂÂÂ if (IS_ERR(hwmon)) {
-ÂÂÂÂÂÂÂ dev_err(&pdev->dev, "Failed to register hwmon device\n");
ÂÂÂÂÂÂÂÂÂ ret = PTR_ERR(hwmon);
+ÂÂÂÂÂÂÂ dev_err(&pdev->dev,
+ÂÂÂÂÂÂÂÂÂÂÂ "Failed to register hwmon device: %d\n", ret);
ÂÂÂÂÂÂÂÂÂ goto err_del_timer;
ÂÂÂÂÂ }

@@ -373,9 +375,10 @@ static int pwm_fan_probe(struct platform_device *pdev)
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ "pwm-fan", ctx,
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ &pwm_fan_cooling_ops);
ÂÂÂÂÂÂÂÂÂ if (IS_ERR(cdev)) {
-ÂÂÂÂÂÂÂÂÂÂÂ dev_err(&pdev->dev,
-ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ "Failed to register pwm-fan as cooling device");
ÂÂÂÂÂÂÂÂÂÂÂÂÂ ret = PTR_ERR(cdev);
+ÂÂÂÂÂÂÂÂÂÂÂ dev_err(&pdev->dev,
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ "Failed to register pwm-fan as cooling device: %d\n",
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ ret);
ÂÂÂÂÂÂÂÂÂÂÂÂÂ goto err_del_timer;
ÂÂÂÂÂÂÂÂÂ }
ÂÂÂÂÂÂÂÂÂ ctx->cdev = cdev;