]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
pwm: Manage owner assignment implicitly for drivers
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Fri, 4 Aug 2023 14:27:06 +0000 (16:27 +0200)
committerThierry Reding <thierry.reding@gmail.com>
Fri, 13 Oct 2023 08:07:17 +0000 (10:07 +0200)
Instead of requiring each driver to care for assigning the owner member
of struct pwm_ops, handle that implicitly using a macro. Note that the
owner member has to be moved to struct pwm_chip, as the ops structure
usually lives in read-only memory and so cannot be modified.

The upside is that new low level drivers cannot forget the assignment and
save one line each. The pwm-crc driver didn't assign .owner, that's not
a problem in practice though as the driver cannot be compiled as a
module.

Acked-by: Andy Shevchenko <andy.shevchenko@gmail.com> # Intel LPSS
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> # pwm-{bcm,brcm}*.c
Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com> # sun4i
Acked-by: Andi Shyti <andi.shyti@kernel.org>
Acked-by: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp> # pwm-visconti
Acked-by: Heiko Stuebner <heiko@sntech.de> # pwm-rockchip
Acked-by: Michael Walle <michael@walle.cc> # pwm-sl28cpld
Acked-by: Neil Armstrong <neil.armstrong@linaro.org> # pwm-meson
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20230804142707.412137-2-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
68 files changed:
drivers/gpio/gpio-mvebu.c
drivers/gpu/drm/bridge/ti-sn65dsi86.c
drivers/leds/rgb/leds-qcom-lpg.c
drivers/pwm/core.c
drivers/pwm/pwm-ab8500.c
drivers/pwm/pwm-apple.c
drivers/pwm/pwm-atmel-hlcdc.c
drivers/pwm/pwm-atmel-tcb.c
drivers/pwm/pwm-atmel.c
drivers/pwm/pwm-bcm-iproc.c
drivers/pwm/pwm-bcm-kona.c
drivers/pwm/pwm-bcm2835.c
drivers/pwm/pwm-berlin.c
drivers/pwm/pwm-brcmstb.c
drivers/pwm/pwm-clk.c
drivers/pwm/pwm-clps711x.c
drivers/pwm/pwm-cros-ec.c
drivers/pwm/pwm-dwc.c
drivers/pwm/pwm-ep93xx.c
drivers/pwm/pwm-fsl-ftm.c
drivers/pwm/pwm-hibvt.c
drivers/pwm/pwm-img.c
drivers/pwm/pwm-imx-tpm.c
drivers/pwm/pwm-imx1.c
drivers/pwm/pwm-imx27.c
drivers/pwm/pwm-intel-lgm.c
drivers/pwm/pwm-iqs620a.c
drivers/pwm/pwm-jz4740.c
drivers/pwm/pwm-keembay.c
drivers/pwm/pwm-lp3943.c
drivers/pwm/pwm-lpc18xx-sct.c
drivers/pwm/pwm-lpc32xx.c
drivers/pwm/pwm-lpss.c
drivers/pwm/pwm-mediatek.c
drivers/pwm/pwm-meson.c
drivers/pwm/pwm-microchip-core.c
drivers/pwm/pwm-mtk-disp.c
drivers/pwm/pwm-mxs.c
drivers/pwm/pwm-ntxec.c
drivers/pwm/pwm-omap-dmtimer.c
drivers/pwm/pwm-pca9685.c
drivers/pwm/pwm-pxa.c
drivers/pwm/pwm-raspberrypi-poe.c
drivers/pwm/pwm-rcar.c
drivers/pwm/pwm-renesas-tpu.c
drivers/pwm/pwm-rockchip.c
drivers/pwm/pwm-rz-mtu3.c
drivers/pwm/pwm-samsung.c
drivers/pwm/pwm-sifive.c
drivers/pwm/pwm-sl28cpld.c
drivers/pwm/pwm-spear.c
drivers/pwm/pwm-sprd.c
drivers/pwm/pwm-sti.c
drivers/pwm/pwm-stm32-lp.c
drivers/pwm/pwm-stm32.c
drivers/pwm/pwm-stmpe.c
drivers/pwm/pwm-sun4i.c
drivers/pwm/pwm-sunplus.c
drivers/pwm/pwm-tegra.c
drivers/pwm/pwm-tiecap.c
drivers/pwm/pwm-tiehrpwm.c
drivers/pwm/pwm-twl-led.c
drivers/pwm/pwm-twl.c
drivers/pwm/pwm-visconti.c
drivers/pwm/pwm-vt8500.c
drivers/pwm/pwm-xilinx.c
drivers/staging/greybus/pwm.c
include/linux/pwm.h

index 67497116ce27d4950673e5535a795ef1975b8f4c..64acd497a341a0a27254177d435ec931f8511143 100644 (file)
@@ -756,7 +756,6 @@ static const struct pwm_ops mvebu_pwm_ops = {
        .free = mvebu_pwm_free,
        .get_state = mvebu_pwm_get_state,
        .apply = mvebu_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static void __maybe_unused mvebu_pwm_suspend(struct mvebu_gpio_chip *mvchip)
index f448b903e19075676247fc72d30a1a9b1f501085..08e8c4f333e3819dd2ca950a970da7b48c9e1813 100644 (file)
@@ -1580,7 +1580,6 @@ static const struct pwm_ops ti_sn_pwm_ops = {
        .free = ti_sn_pwm_free,
        .apply = ti_sn_pwm_apply,
        .get_state = ti_sn_pwm_get_state,
-       .owner = THIS_MODULE,
 };
 
 static int ti_sn_pwm_probe(struct auxiliary_device *adev,
index df469aaa7e6e7ecf00d4be99f736c8da5fd262f4..c8525f59748c21fa16d3016ad9242d2cce4bb6ab 100644 (file)
@@ -1085,7 +1085,6 @@ static const struct pwm_ops lpg_pwm_ops = {
        .request = lpg_pwm_request,
        .apply = lpg_pwm_apply,
        .get_state = lpg_pwm_get_state,
-       .owner = THIS_MODULE,
 };
 
 static int lpg_add_pwm(struct lpg *lpg)
index dc66e3405bf50bf10f128d01bacb899023cb7dfe..a2824eb4e236dc97fce47086dcb14c898ba4980e 100644 (file)
@@ -89,13 +89,13 @@ static int pwm_device_request(struct pwm_device *pwm, const char *label)
        if (test_bit(PWMF_REQUESTED, &pwm->flags))
                return -EBUSY;
 
-       if (!try_module_get(pwm->chip->ops->owner))
+       if (!try_module_get(pwm->chip->owner))
                return -ENODEV;
 
        if (pwm->chip->ops->request) {
                err = pwm->chip->ops->request(pwm->chip, pwm);
                if (err) {
-                       module_put(pwm->chip->ops->owner);
+                       module_put(pwm->chip->owner);
                        return err;
                }
        }
@@ -253,14 +253,16 @@ static bool pwm_ops_check(const struct pwm_chip *chip)
 }
 
 /**
- * pwmchip_add() - register a new PWM chip
+ * __pwmchip_add() - register a new PWM chip
  * @chip: the PWM chip to add
+ * @owner: reference to the module providing the chip.
  *
- * Register a new PWM chip.
+ * Register a new PWM chip. @owner is supposed to be THIS_MODULE, use the
+ * pwmchip_add wrapper to do this right.
  *
  * Returns: 0 on success or a negative error code on failure.
  */
-int pwmchip_add(struct pwm_chip *chip)
+int __pwmchip_add(struct pwm_chip *chip, struct module *owner)
 {
        struct pwm_device *pwm;
        unsigned int i;
@@ -272,6 +274,8 @@ int pwmchip_add(struct pwm_chip *chip)
        if (!pwm_ops_check(chip))
                return -EINVAL;
 
+       chip->owner = owner;
+
        chip->pwms = kcalloc(chip->npwm, sizeof(*pwm), GFP_KERNEL);
        if (!chip->pwms)
                return -ENOMEM;
@@ -306,7 +310,7 @@ int pwmchip_add(struct pwm_chip *chip)
 
        return 0;
 }
-EXPORT_SYMBOL_GPL(pwmchip_add);
+EXPORT_SYMBOL_GPL(__pwmchip_add);
 
 /**
  * pwmchip_remove() - remove a PWM chip
@@ -338,17 +342,17 @@ static void devm_pwmchip_remove(void *data)
        pwmchip_remove(chip);
 }
 
-int devm_pwmchip_add(struct device *dev, struct pwm_chip *chip)
+int __devm_pwmchip_add(struct device *dev, struct pwm_chip *chip, struct module *owner)
 {
        int ret;
 
-       ret = pwmchip_add(chip);
+       ret = __pwmchip_add(chip, owner);
        if (ret)
                return ret;
 
        return devm_add_action_or_reset(dev, devm_pwmchip_remove, chip);
 }
-EXPORT_SYMBOL_GPL(devm_pwmchip_add);
+EXPORT_SYMBOL_GPL(__devm_pwmchip_add);
 
 /**
  * pwm_request_from_chip() - request a PWM device relative to a PWM chip
@@ -979,7 +983,7 @@ void pwm_put(struct pwm_device *pwm)
        pwm_set_chip_data(pwm, NULL);
        pwm->label = NULL;
 
-       module_put(pwm->chip->ops->owner);
+       module_put(pwm->chip->owner);
 out:
        mutex_unlock(&pwm_lock);
 }
index 583a7d69c7415173caca43124b70e8491008a17d..670d33daea846bb8c4cc183438c270d2fb403c0c 100644 (file)
@@ -181,7 +181,6 @@ static int ab8500_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
 static const struct pwm_ops ab8500_pwm_ops = {
        .apply = ab8500_pwm_apply,
        .get_state = ab8500_pwm_get_state,
-       .owner = THIS_MODULE,
 };
 
 static int ab8500_pwm_probe(struct platform_device *pdev)
index 8e7d67fb5fbefd84e32c7437335784e5b6238e0b..4d755b628d9e79650d5e71d5ab912a7995697312 100644 (file)
@@ -99,7 +99,6 @@ static int apple_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
 static const struct pwm_ops apple_pwm_ops = {
        .apply = apple_pwm_apply,
        .get_state = apple_pwm_get_state,
-       .owner = THIS_MODULE,
 };
 
 static int apple_pwm_probe(struct platform_device *pdev)
index e271d920151e471c8d6622841c7b432557da8c46..07920e0347575aeb420c303c93fdd3ae99dc8448 100644 (file)
@@ -170,7 +170,6 @@ static int atmel_hlcdc_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 
 static const struct pwm_ops atmel_hlcdc_pwm_ops = {
        .apply = atmel_hlcdc_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static const struct atmel_hlcdc_pwm_errata atmel_hlcdc_pwm_at91sam9x5_errata = {
index c00dd37c5fbd86b9dd060d5c16757348e145a281..98b33c016c3c76b8a9bd4cd2492b5871a33690aa 100644 (file)
@@ -364,7 +364,6 @@ static const struct pwm_ops atmel_tcb_pwm_ops = {
        .request = atmel_tcb_pwm_request,
        .free = atmel_tcb_pwm_free,
        .apply = atmel_tcb_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static struct atmel_tcb_config tcb_rm9200_config = {
index 35ae876bf2ea2c0e2d4fe2be43b707c411b2917b..47bcc8a3bf9d50c48cf80f29e1b03defdb388e4c 100644 (file)
@@ -402,7 +402,6 @@ static int atmel_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
 static const struct pwm_ops atmel_pwm_ops = {
        .apply = atmel_pwm_apply,
        .get_state = atmel_pwm_get_state,
-       .owner = THIS_MODULE,
 };
 
 static const struct atmel_pwm_data atmel_sam9rl_pwm_data = {
index 7d70b6f186a6f8a459d9e4e6c5693ae248f477ed..1da902440df2443a00071acf0a874d5afb5bcd15 100644 (file)
@@ -183,7 +183,6 @@ static int iproc_pwmc_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 static const struct pwm_ops iproc_pwm_ops = {
        .apply = iproc_pwmc_apply,
        .get_state = iproc_pwmc_get_state,
-       .owner = THIS_MODULE,
 };
 
 static int iproc_pwmc_probe(struct platform_device *pdev)
index e5b00cc9f7a762d4b4fe1b2c753c62aec394f72a..15d6ed03c3ce05a58db5d65e8fb1f3532b35635f 100644 (file)
@@ -269,7 +269,6 @@ static int kona_pwmc_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 
 static const struct pwm_ops kona_pwm_ops = {
        .apply = kona_pwmc_apply,
-       .owner = THIS_MODULE,
 };
 
 static int kona_pwmc_probe(struct platform_device *pdev)
index bdfc2a5ec0d6929f9f09ddeb25766485c6771199..af318a35d510e1212bccb89e2ec797b6dfcce819 100644 (file)
@@ -129,7 +129,6 @@ static const struct pwm_ops bcm2835_pwm_ops = {
        .request = bcm2835_pwm_request,
        .free = bcm2835_pwm_free,
        .apply = bcm2835_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static int bcm2835_pwm_probe(struct platform_device *pdev)
index 0971c666afd134f28e343b7218e4dbb2a947d88f..6a6641fc4fa1bd1c9577436cdc0d770199630a12 100644 (file)
@@ -205,7 +205,6 @@ static const struct pwm_ops berlin_pwm_ops = {
        .request = berlin_pwm_request,
        .free = berlin_pwm_free,
        .apply = berlin_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static const struct of_device_id berlin_pwm_match[] = {
index a3faa9a3de7ccfa6dc4c82253de3d8ef1b0fb4ef..96967f8a8dad92833b82d4cdab1ee3853dc89ffb 100644 (file)
@@ -220,7 +220,6 @@ static int brcmstb_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 
 static const struct pwm_ops brcmstb_pwm_ops = {
        .apply = brcmstb_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static const struct of_device_id brcmstb_pwm_of_match[] = {
index 0ee4d2aee4df0c31d7878e1527d690f13557e335..9dd88b386907cf87a4b7ebc47055f2c84391da0d 100644 (file)
@@ -77,7 +77,6 @@ static int pwm_clk_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 
 static const struct pwm_ops pwm_clk_ops = {
        .apply = pwm_clk_apply,
-       .owner = THIS_MODULE,
 };
 
 static int pwm_clk_probe(struct platform_device *pdev)
index b0d91142da8d07a2792f9ca6542a67ac7a0ed8be..42179b3f7ec399a22f3db1adc397309e0be9208f 100644 (file)
@@ -72,7 +72,6 @@ static int clps711x_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 static const struct pwm_ops clps711x_pwm_ops = {
        .request = clps711x_pwm_request,
        .apply = clps711x_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static struct pwm_device *clps711x_pwm_xlate(struct pwm_chip *chip,
index baaac0c33aa0687a1a44fa7763b468417670a4e2..500504c7d459bb194f3237cfdeddaa66032964c4 100644 (file)
@@ -241,7 +241,6 @@ static const struct pwm_ops cros_ec_pwm_ops = {
        .free = cros_ec_pwm_free,
        .get_state      = cros_ec_pwm_get_state,
        .apply          = cros_ec_pwm_apply,
-       .owner          = THIS_MODULE,
 };
 
 /*
index 3bbb26c862c35c6f866d6129c2a488ff9979cab6..53fe00ccd47efc921622309acc58abb642f8e19d 100644 (file)
@@ -195,7 +195,6 @@ static int dwc_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
 static const struct pwm_ops dwc_pwm_ops = {
        .apply = dwc_pwm_apply,
        .get_state = dwc_pwm_get_state,
-       .owner = THIS_MODULE,
 };
 
 static struct dwc_pwm *dwc_pwm_alloc(struct device *dev)
index c45a75e65c869ea48cb4ecde71937571e3309393..51e072572a87be12308d4059ac3f8f05dc21bcbf 100644 (file)
@@ -159,7 +159,6 @@ static const struct pwm_ops ep93xx_pwm_ops = {
        .request = ep93xx_pwm_request,
        .free = ep93xx_pwm_free,
        .apply = ep93xx_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static int ep93xx_pwm_probe(struct platform_device *pdev)
index b7c6045c5d0898de1424a7c022f389467524fcec..d1b6d1aa477369e4db5ffbd93a9319c137a367a7 100644 (file)
@@ -350,7 +350,6 @@ static const struct pwm_ops fsl_pwm_ops = {
        .request = fsl_pwm_request,
        .free = fsl_pwm_free,
        .apply = fsl_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static int fsl_pwm_init(struct fsl_pwm_chip *fpc)
index f7ba6fe9a349a3ebdb09f16bc50004624ab75f7d..c435776e2f78688b4739aa3aada6d2558eae5363 100644 (file)
@@ -185,7 +185,6 @@ static const struct pwm_ops hibvt_pwm_ops = {
        .get_state = hibvt_pwm_get_state,
        .apply = hibvt_pwm_apply,
 
-       .owner = THIS_MODULE,
 };
 
 static int hibvt_pwm_probe(struct platform_device *pdev)
index 326af85888e7b4bd27f852d4bc62eaea080191c1..116fa060e3029942f557fceb4d090794f87d3044 100644 (file)
@@ -208,7 +208,6 @@ static int img_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 
 static const struct pwm_ops img_pwm_ops = {
        .apply = img_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static const struct img_pwm_soc_data pistachio_pwm = {
index 98ab65c896850ef224febe09506e919f47338b3b..fe8bf598d388956bceda07439f6901569fe3f851 100644 (file)
@@ -332,7 +332,6 @@ static const struct pwm_ops imx_tpm_pwm_ops = {
        .free = pwm_imx_tpm_free,
        .get_state = pwm_imx_tpm_get_state,
        .apply = pwm_imx_tpm_apply,
-       .owner = THIS_MODULE,
 };
 
 static int pwm_imx_tpm_probe(struct platform_device *pdev)
index 0651983bed190c411df3bdf1b7d84b1c6fbb68bc..d175d895f22a338bc46b309a5805f563366ab886 100644 (file)
@@ -146,7 +146,6 @@ static int pwm_imx1_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 
 static const struct pwm_ops pwm_imx1_ops = {
        .apply = pwm_imx1_apply,
-       .owner = THIS_MODULE,
 };
 
 static const struct of_device_id pwm_imx1_dt_ids[] = {
index 29a3089c534cdab089e672f2d693a9ab0f70afa8..7d9bc43f12b0e96cf33b15e1a6f4247f8555d907 100644 (file)
@@ -296,7 +296,6 @@ static int pwm_imx27_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 static const struct pwm_ops pwm_imx27_ops = {
        .apply = pwm_imx27_apply,
        .get_state = pwm_imx27_get_state,
-       .owner = THIS_MODULE,
 };
 
 static const struct of_device_id pwm_imx27_dt_ids[] = {
index 0cd7dd548e82f22ddcc7a16363abe646478d735c..54ecae7f937ed0517e58a0c09615240c6fe71e0a 100644 (file)
@@ -107,7 +107,6 @@ static int lgm_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
 static const struct pwm_ops lgm_pwm_ops = {
        .get_state = lgm_pwm_get_state,
        .apply = lgm_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static void lgm_pwm_init(struct lgm_pwm_chip *pc)
index 47b3141135f38eccdcde2c66330a72b6000fdb0a..378ab036edfec43e82530e4d2e349e27e2c3b39b 100644 (file)
@@ -166,7 +166,6 @@ static int iqs620_pwm_notifier(struct notifier_block *notifier,
 static const struct pwm_ops iqs620_pwm_ops = {
        .apply = iqs620_pwm_apply,
        .get_state = iqs620_pwm_get_state,
-       .owner = THIS_MODULE,
 };
 
 static void iqs620_pwm_notifier_unregister(void *context)
index 6b21242662732774cebe4d3ef7fcb81172104336..49a6e28d1d986d0b37963abf2053f02312e4785d 100644 (file)
@@ -216,7 +216,6 @@ static const struct pwm_ops jz4740_pwm_ops = {
        .request = jz4740_pwm_request,
        .free = jz4740_pwm_free,
        .apply = jz4740_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static int jz4740_pwm_probe(struct platform_device *pdev)
index ac02d8bb4a0b5eba2877bf71b800e0bd2332617b..ac824ecc3f641045676477bb32a68d62f07cc1c5 100644 (file)
@@ -178,7 +178,6 @@ static int keembay_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 }
 
 static const struct pwm_ops keembay_pwm_ops = {
-       .owner = THIS_MODULE,
        .apply = keembay_pwm_apply,
        .get_state = keembay_pwm_get_state,
 };
index 4b133a17f4be3bea2b070237abaed93d25080ef4..a1a106747372d864467c3f2cf007a443161d0ad4 100644 (file)
@@ -216,7 +216,6 @@ static const struct pwm_ops lp3943_pwm_ops = {
        .request        = lp3943_pwm_request,
        .free           = lp3943_pwm_free,
        .apply          = lp3943_pwm_apply,
-       .owner          = THIS_MODULE,
 };
 
 static int lp3943_pwm_parse_dt(struct device *dev,
index 7a19a840bca5fca00d90af908b872ef8e3fdc0de..ef7d0da137ede3453684322dc3e2312d6ff0e59e 100644 (file)
@@ -341,7 +341,6 @@ static const struct pwm_ops lpc18xx_pwm_ops = {
        .apply = lpc18xx_pwm_apply,
        .request = lpc18xx_pwm_request,
        .free = lpc18xx_pwm_free,
-       .owner = THIS_MODULE,
 };
 
 static const struct of_device_id lpc18xx_pwm_of_match[] = {
index 806f0bb3ad6d8d1ba6b1c8094b15bcb979111899..78f664e41e6e3a174f16ed0ecc216f2e0b1ae087 100644 (file)
@@ -115,7 +115,6 @@ static int lpc32xx_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 
 static const struct pwm_ops lpc32xx_pwm_ops = {
        .apply = lpc32xx_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static int lpc32xx_pwm_probe(struct platform_device *pdev)
index 23fe332b2394788a9c610eca28d9ed853370a5a3..a6ea3ce7e0196ad0e70323bb26dbdc4c7da2b48e 100644 (file)
@@ -243,7 +243,6 @@ static int pwm_lpss_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
 static const struct pwm_ops pwm_lpss_ops = {
        .apply = pwm_lpss_apply,
        .get_state = pwm_lpss_get_state,
-       .owner = THIS_MODULE,
 };
 
 struct pwm_lpss_chip *devm_pwm_lpss_probe(struct device *dev, void __iomem *base,
index 6adb0ed019066a0f29bb70ff704958aeb020caac..373abfd25acb28509520e82ce6b3efc13896e9d9 100644 (file)
@@ -229,7 +229,6 @@ static int pwm_mediatek_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 
 static const struct pwm_ops pwm_mediatek_ops = {
        .apply = pwm_mediatek_apply,
-       .owner = THIS_MODULE,
 };
 
 static int pwm_mediatek_probe(struct platform_device *pdev)
index 25519cddc2a9dd5461671b3de449a0709a4e1bc7..5bea53243ed2fab3c170591f7b385fdb25890658 100644 (file)
@@ -335,7 +335,6 @@ static const struct pwm_ops meson_pwm_ops = {
        .free = meson_pwm_free,
        .apply = meson_pwm_apply,
        .get_state = meson_pwm_get_state,
-       .owner = THIS_MODULE,
 };
 
 static const char * const pwm_meson8b_parent_names[] = {
index e7525c98105ebc30db26648be60df27bd0b029f1..c0c53968f3e9d1a84c6f727b66bdb6396ec00f1b 100644 (file)
@@ -435,7 +435,6 @@ static int mchp_core_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm
 static const struct pwm_ops mchp_core_pwm_ops = {
        .apply = mchp_core_pwm_apply,
        .get_state = mchp_core_pwm_get_state,
-       .owner = THIS_MODULE,
 };
 
 static const struct of_device_id mchp_core_of_match[] = {
index a83bd6e18b07ff8b2e618f03bae754386b0f2d63..7748e3eaa818640fbaaab933397a5a359885a28c 100644 (file)
@@ -227,7 +227,6 @@ static int mtk_disp_pwm_get_state(struct pwm_chip *chip,
 static const struct pwm_ops mtk_disp_pwm_ops = {
        .apply = mtk_disp_pwm_apply,
        .get_state = mtk_disp_pwm_get_state,
-       .owner = THIS_MODULE,
 };
 
 static int mtk_disp_pwm_probe(struct platform_device *pdev)
index 766dbc58dad8409c096528ed8337560aaf41dbca..1b5e787d78f1cdb163a650e12104ea900d4b3d21 100644 (file)
@@ -115,7 +115,6 @@ static int mxs_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 
 static const struct pwm_ops mxs_pwm_ops = {
        .apply = mxs_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static int mxs_pwm_probe(struct platform_device *pdev)
index 7514ea384ec56585d33c93783fea68bc153528e0..78606039eda2eea757175f559d0ada50b7eadeec 100644 (file)
@@ -126,7 +126,6 @@ static int ntxec_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm_dev,
 }
 
 static const struct pwm_ops ntxec_pwm_ops = {
-       .owner = THIS_MODULE,
        .apply = ntxec_pwm_apply,
        /*
         * No .get_state callback, because the current state cannot be read
index 94faa4650686672f27eed1252c051e6ef7744d09..13161e08dd6eb38e86bb1863d131517f7e2f1706 100644 (file)
@@ -311,7 +311,6 @@ unlock_mutex:
 
 static const struct pwm_ops pwm_omap_dmtimer_ops = {
        .apply = pwm_omap_dmtimer_apply,
-       .owner = THIS_MODULE,
 };
 
 static int pwm_omap_dmtimer_probe(struct platform_device *pdev)
index 3038a68412a75e1270cd44c5590fcefe765b94e6..e79b1de8c4d83f1b4ad06269a844f1b3cc932162 100644 (file)
@@ -505,7 +505,6 @@ static const struct pwm_ops pca9685_pwm_ops = {
        .get_state = pca9685_pwm_get_state,
        .request = pca9685_pwm_request,
        .free = pca9685_pwm_free,
-       .owner = THIS_MODULE,
 };
 
 static const struct regmap_config pca9685_regmap_i2c_config = {
index 1e475ed10180ea302b0c60d66949bb93ab13323d..faf6b35b9336564a0dc09685a9f84aca332dc485 100644 (file)
@@ -135,7 +135,6 @@ static int pxa_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 
 static const struct pwm_ops pxa_pwm_ops = {
        .apply = pxa_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 #ifdef CONFIG_OF
index 2939b71a7ba7b5e340d418d511648d9a6da0354b..1ad814fdec6bd6483620dfae8dddfa2cd1756015 100644 (file)
@@ -135,7 +135,6 @@ static int raspberrypi_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 static const struct pwm_ops raspberrypi_pwm_ops = {
        .get_state = raspberrypi_pwm_get_state,
        .apply = raspberrypi_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static int raspberrypi_pwm_probe(struct platform_device *pdev)
index 5b5f357c44de61f8d4aa3aef115f314c15bacf1e..13269f55fccff143769687c88437c1a02d4fcc95 100644 (file)
@@ -198,7 +198,6 @@ static const struct pwm_ops rcar_pwm_ops = {
        .request = rcar_pwm_request,
        .free = rcar_pwm_free,
        .apply = rcar_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static int rcar_pwm_probe(struct platform_device *pdev)
index d7311614c846dda20dbf7696618d628bff7a3ef0..1b004e01829a284855d9645e71f6c03abc206204 100644 (file)
@@ -431,7 +431,6 @@ static const struct pwm_ops tpu_pwm_ops = {
        .request = tpu_pwm_request,
        .free = tpu_pwm_free,
        .apply = tpu_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 /* -----------------------------------------------------------------------------
index 03ee18fb82d5b40dc5699da1c5410dac830d5ac1..cce4381e188af0bfb7549db11de1d0819c893be6 100644 (file)
@@ -228,7 +228,6 @@ out:
 static const struct pwm_ops rockchip_pwm_ops = {
        .get_state = rockchip_pwm_get_state,
        .apply = rockchip_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static const struct rockchip_pwm_data pwm_data_v1 = {
index a56cecb0e46e3e207811d95104e3a3c74cad375e..bdda315b3bd30c135e4c0d10174fa52a144455fc 100644 (file)
@@ -438,7 +438,6 @@ static const struct pwm_ops rz_mtu3_pwm_ops = {
        .free = rz_mtu3_pwm_free,
        .get_state = rz_mtu3_pwm_get_state,
        .apply = rz_mtu3_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static int rz_mtu3_pwm_pm_runtime_suspend(struct device *dev)
index e8828f57ab1502f0a3450e72e1fdd8de1f401d7b..08a9032573836fea338199f3aa87fcd50ae81db2 100644 (file)
@@ -475,7 +475,6 @@ static const struct pwm_ops pwm_samsung_ops = {
        .request        = pwm_samsung_request,
        .free           = pwm_samsung_free,
        .apply          = pwm_samsung_apply,
-       .owner          = THIS_MODULE,
 };
 
 #ifdef CONFIG_OF
index eabddb7c782083cefbdffeedcc0f54184ccc814a..089e50bdbbf01759cd8e49755267dd5cdefbc27d 100644 (file)
@@ -203,7 +203,6 @@ static const struct pwm_ops pwm_sifive_ops = {
        .free = pwm_sifive_free,
        .get_state = pwm_sifive_get_state,
        .apply = pwm_sifive_apply,
-       .owner = THIS_MODULE,
 };
 
 static int pwm_sifive_clock_notifier(struct notifier_block *nb,
index 9e42e3a74ad6ec6e73de13a939fb4f517396fd15..88b01ff9e4602728df2f2d1f9de2872c685b5886 100644 (file)
@@ -200,7 +200,6 @@ static int sl28cpld_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 static const struct pwm_ops sl28cpld_pwm_ops = {
        .apply = sl28cpld_pwm_apply,
        .get_state = sl28cpld_pwm_get_state,
-       .owner = THIS_MODULE,
 };
 
 static int sl28cpld_pwm_probe(struct platform_device *pdev)
index 4e1cfd8d7c037ee449b28899dd39939449c853a1..2cbc34cf6799b68d42f6d46edf61bae45b388001 100644 (file)
@@ -189,7 +189,6 @@ static int spear_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 
 static const struct pwm_ops spear_pwm_ops = {
        .apply = spear_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static int spear_pwm_probe(struct platform_device *pdev)
index 1499c8c1fe3753a89a655d1638f5513641c3e193..dfda2152a7c1895c3bbb87f0b4ecf32251b7bab4 100644 (file)
@@ -210,7 +210,6 @@ static int sprd_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 static const struct pwm_ops sprd_pwm_ops = {
        .apply = sprd_pwm_apply,
        .get_state = sprd_pwm_get_state,
-       .owner = THIS_MODULE,
 };
 
 static int sprd_pwm_clk_init(struct sprd_pwm_chip *spc)
index b1d1373648a38fb39cfa9f263ba53c13564a6f3b..5756f2e3b3c0b5982a9aa43f91f63a6fb66b75b6 100644 (file)
@@ -420,7 +420,6 @@ static const struct pwm_ops sti_pwm_ops = {
        .capture = sti_pwm_capture,
        .apply = sti_pwm_apply,
        .free = sti_pwm_free,
-       .owner = THIS_MODULE,
 };
 
 static irqreturn_t sti_pwm_interrupt(int irq, void *data)
index bb3a045a7334303941f277e07f70e14ece98180a..b67974cc18725189fd1bbc33e1449a68d035757a 100644 (file)
@@ -189,7 +189,6 @@ static int stm32_pwm_lp_get_state(struct pwm_chip *chip,
 }
 
 static const struct pwm_ops stm32_pwm_lp_ops = {
-       .owner = THIS_MODULE,
        .apply = stm32_pwm_lp_apply,
        .get_state = stm32_pwm_lp_get_state,
 };
index 3d6be7749e23142a7bdd9cda6c4640f3f6ff0246..3303a754ea020fb3300c1e9e2c46346a4709744f 100644 (file)
@@ -487,7 +487,6 @@ static int stm32_pwm_apply_locked(struct pwm_chip *chip, struct pwm_device *pwm,
 }
 
 static const struct pwm_ops stm32pwm_ops = {
-       .owner = THIS_MODULE,
        .apply = stm32_pwm_apply_locked,
        .capture = IS_ENABLED(CONFIG_DMA_ENGINE) ? stm32_pwm_capture : NULL,
 };
index e205405c4828b81561199b2d9704efa75e19f022..a46f5b4dd81622ce3651f6c35c5fc4ff0b91b83a 100644 (file)
@@ -287,7 +287,6 @@ static int stmpe_24xx_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 
 static const struct pwm_ops stmpe_24xx_pwm_ops = {
        .apply = stmpe_24xx_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static int __init stmpe_pwm_probe(struct platform_device *pdev)
index c84fcf1a13dc2c4d2aad25a6edcca4958d4f9f66..1a439025540d45a0cbf979cb46f8cd92bb1a691a 100644 (file)
@@ -325,7 +325,6 @@ static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 static const struct pwm_ops sun4i_pwm_ops = {
        .apply = sun4i_pwm_apply,
        .get_state = sun4i_pwm_get_state,
-       .owner = THIS_MODULE,
 };
 
 static const struct sun4i_pwm_data sun4i_pwm_dual_nobypass = {
index 7705c7b86c3a3066544bcabf8787133d8a8d6231..773e2f80526e891d6ec8feceb69f05d090bba171 100644 (file)
@@ -163,7 +163,6 @@ static int sunplus_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
 static const struct pwm_ops sunplus_pwm_ops = {
        .apply = sunplus_pwm_apply,
        .get_state = sunplus_pwm_get_state,
-       .owner = THIS_MODULE,
 };
 
 static void sunplus_pwm_clk_release(void *data)
index a169a34e07781683bf0d68de9ffa475ca12cb43d..39ea51e08c946d0ec24a7cc311fc930b3ca1b823 100644 (file)
@@ -268,7 +268,6 @@ static int tegra_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 
 static const struct pwm_ops tegra_pwm_ops = {
        .apply = tegra_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static int tegra_pwm_probe(struct platform_device *pdev)
index 8c94b266c1b2a0ee4b44a820e800ca5fa496a6ff..11e3549cf103445cfd4f6f6de5eca55769ecd1e5 100644 (file)
@@ -205,7 +205,6 @@ static int ecap_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 
 static const struct pwm_ops ecap_pwm_ops = {
        .apply = ecap_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static const struct of_device_id ecap_of_match[] = {
index ecbfd7e954ecb8a1feb10c3c2cadb156e256ac4a..66ac2655845f783a20bf5efd7f974f061ee5ee25 100644 (file)
@@ -437,7 +437,6 @@ static int ehrpwm_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 static const struct pwm_ops ehrpwm_pwm_ops = {
        .free = ehrpwm_pwm_free,
        .apply = ehrpwm_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static const struct of_device_id ehrpwm_of_match[] = {
index 8fb84b4418538023129e3288f280ed7940263912..625233f4703a972462c2d096bd1b7ca79c1fb5db 100644 (file)
@@ -189,7 +189,6 @@ static int twl4030_pwmled_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 
 static const struct pwm_ops twl4030_pwmled_ops = {
        .apply = twl4030_pwmled_apply,
-       .owner = THIS_MODULE,
 };
 
 static int twl6030_pwmled_config(struct pwm_chip *chip, struct pwm_device *pwm,
@@ -342,7 +341,6 @@ static const struct pwm_ops twl6030_pwmled_ops = {
        .apply = twl6030_pwmled_apply,
        .request = twl6030_pwmled_request,
        .free = twl6030_pwmled_free,
-       .owner = THIS_MODULE,
 };
 
 static int twl_pwmled_probe(struct platform_device *pdev)
index 86567add79dbe5df1435c9f29f1575aa4da7e4b7..603d31f27470f6b80b6cc347b2fcc44d0d855bb6 100644 (file)
@@ -333,12 +333,10 @@ static const struct pwm_ops twl4030_pwm_ops = {
        .apply = twl4030_pwm_apply,
        .request = twl4030_pwm_request,
        .free = twl4030_pwm_free,
-       .owner = THIS_MODULE,
 };
 
 static const struct pwm_ops twl6030_pwm_ops = {
        .apply = twl6030_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static int twl_pwm_probe(struct platform_device *pdev)
index 7f7591a2384c558e81d81b609cb665891a656779..8d736d5581221614b92a7037bba93827b8345577 100644 (file)
@@ -129,7 +129,6 @@ static int visconti_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
 static const struct pwm_ops visconti_pwm_ops = {
        .apply = visconti_pwm_apply,
        .get_state = visconti_pwm_get_state,
-       .owner = THIS_MODULE,
 };
 
 static int visconti_pwm_probe(struct platform_device *pdev)
index 6d46db51daaccdf0cb124d34f172dfe9ff7be9d6..a96c7f5d909993f49770e4896fc10a33cb812202 100644 (file)
@@ -221,7 +221,6 @@ static int vt8500_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 
 static const struct pwm_ops vt8500_pwm_ops = {
        .apply = vt8500_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static const struct of_device_id vt8500_pwm_dt_ids[] = {
index 85153ee90809c757144b2422b77853adb160c79c..5f3c2a6fed11c34631ebd26d9131dd9b812a79bb 100644 (file)
@@ -198,7 +198,6 @@ static int xilinx_pwm_get_state(struct pwm_chip *chip,
 static const struct pwm_ops xilinx_pwm_ops = {
        .apply = xilinx_pwm_apply,
        .get_state = xilinx_pwm_get_state,
-       .owner = THIS_MODULE,
 };
 
 static const struct regmap_config xilinx_pwm_regmap_config = {
index 57cc1960d0598f5442724a528020cb34487bd00b..a3cb68cfa0f9b7059f8911deb924ab8970f07357 100644 (file)
@@ -258,7 +258,6 @@ static const struct pwm_ops gb_pwm_ops = {
        .request = gb_pwm_request,
        .free = gb_pwm_free,
        .apply = gb_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static int gb_pwm_probe(struct gbphy_device *gbphy_dev,
index d2f9f690a9c1452d189c5f638a61a02300d1200c..56e3b7a09824ae1a9a689646d90103ec42b5d848 100644 (file)
@@ -267,7 +267,6 @@ struct pwm_capture {
  * @get_state: get the current PWM state. This function is only
  *            called once per PWM device when the PWM chip is
  *            registered.
- * @owner: helps prevent removal of modules exporting active PWMs
  */
 struct pwm_ops {
        int (*request)(struct pwm_chip *chip, struct pwm_device *pwm);
@@ -278,13 +277,13 @@ struct pwm_ops {
                     const struct pwm_state *state);
        int (*get_state)(struct pwm_chip *chip, struct pwm_device *pwm,
                         struct pwm_state *state);
-       struct module *owner;
 };
 
 /**
  * struct pwm_chip - abstract a PWM controller
  * @dev: device providing the PWMs
  * @ops: callbacks for this PWM controller
+ * @owner: module providing this chip
  * @base: number of first PWM controlled by this chip
  * @npwm: number of PWMs controlled by this chip
  * @of_xlate: request a PWM device given a device tree PWM specifier
@@ -295,6 +294,7 @@ struct pwm_ops {
 struct pwm_chip {
        struct device *dev;
        const struct pwm_ops *ops;
+       struct module *owner;
        int base;
        unsigned int npwm;
 
@@ -386,10 +386,12 @@ int pwm_capture(struct pwm_device *pwm, struct pwm_capture *result,
 int pwm_set_chip_data(struct pwm_device *pwm, void *data);
 void *pwm_get_chip_data(struct pwm_device *pwm);
 
-int pwmchip_add(struct pwm_chip *chip);
+int __pwmchip_add(struct pwm_chip *chip, struct module *owner);
+#define pwmchip_add(chip) __pwmchip_add(chip, THIS_MODULE)
 void pwmchip_remove(struct pwm_chip *chip);
 
-int devm_pwmchip_add(struct device *dev, struct pwm_chip *chip);
+int __devm_pwmchip_add(struct device *dev, struct pwm_chip *chip, struct module *owner);
+#define devm_pwmchip_add(dev, chip) __devm_pwmchip_add(dev, chip, THIS_MODULE)
 
 struct pwm_device *pwm_request_from_chip(struct pwm_chip *chip,
                                         unsigned int index,