From e3be40a73fc6e5232aae0f69edbc766669663c54 Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Wed, 11 Sep 2024 13:33:56 +0100 Subject: [PATCH] pwm: tegra-tachometer: Fix build for Linux v6.12 In Linux v6.12, commit f9ecc2febf6f ("pwm: Don't export pwm_capture()") made pwm_capture an internal function and this broke the build for the Tegra Tachometer driver. The pwm_capture() function simply calls the drivers '.capture' callback and so fix this by directly calling the function pwm_tegra_tacho_capture() instead. Note that the rpm_show() function is also moved to after the declaration of the pwm_tegra_tacho_capture() function. Bug 4876974 Change-Id: Idf7fbc16382a9077c651755d9907ded7652610cc Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3217391 GVS: buildbot_gerritrpt Reviewed-by: Yi-Wei Wang --- drivers/pwm/pwm-tegra-tachometer.c | 62 +++++++++++++++--------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/drivers/pwm/pwm-tegra-tachometer.c b/drivers/pwm/pwm-tegra-tachometer.c index 76c1032b..9021d824 100644 --- a/drivers/pwm/pwm-tegra-tachometer.c +++ b/drivers/pwm/pwm-tegra-tachometer.c @@ -107,37 +107,6 @@ static struct pwm_tegra_tach *to_tegra_pwm_chip(struct pwm_chip *chip) #endif } -static ssize_t rpm_show(struct device *dev, struct device_attribute *attr, - char *buf) -{ - struct pwm_chip *chip = dev_get_drvdata(dev); - struct pwm_device *pwm = &chip->pwms[0]; - struct pwm_capture result; - unsigned int rpm = 0; - int ret; - - ret = pwm_capture(pwm, &result, 0); - if (ret < 0) { - dev_err(dev, "Failed to capture PWM: %d\n", ret); - return ret; - } - - if (result.period) - rpm = DIV_ROUND_CLOSEST_ULL(60ULL * NSEC_PER_SEC, - result.period); - - return sprintf(buf, "%u\n", rpm); -} - -static DEVICE_ATTR_RO(rpm); - -static struct attribute *pwm_tach_attrs[] = { - &dev_attr_rpm.attr, - NULL, -}; - -ATTRIBUTE_GROUPS(pwm_tach); - static u32 tachometer_readl(struct pwm_tegra_tach *ptt, unsigned long reg) { return readl(ptt->regs + reg); @@ -314,6 +283,37 @@ static irqreturn_t tegra_pwm_tach_irq(int irq, void *dev) return IRQ_HANDLED; } +static ssize_t rpm_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct pwm_chip *chip = dev_get_drvdata(dev); + struct pwm_device *pwm = &chip->pwms[0]; + struct pwm_capture result; + unsigned int rpm = 0; + int ret; + + ret = pwm_tegra_tacho_capture(chip, pwm, &result, 0); + if (ret < 0) { + dev_err(dev, "Failed to capture PWM: %d\n", ret); + return ret; + } + + if (result.period) + rpm = DIV_ROUND_CLOSEST_ULL(60ULL * NSEC_PER_SEC, + result.period); + + return sprintf(buf, "%u\n", rpm); +} + +static DEVICE_ATTR_RO(rpm); + +static struct attribute *pwm_tach_attrs[] = { + &dev_attr_rpm.attr, + NULL, +}; + +ATTRIBUTE_GROUPS(pwm_tach); + static const struct pwm_ops pwm_tegra_tach_ops = { #if defined(NV_PWM_OPS_STRUCT_HAS_CONFIG) /* Linux 6.0 */ .config = tegra_pwm_config,