.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)
 
        .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,
 
        .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)
 
        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;
                }
        }
 }
 
 /**
- * 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;
        if (!pwm_ops_check(chip))
                return -EINVAL;
 
+       chip->owner = owner;
+
        chip->pwms = kcalloc(chip->npwm, sizeof(*pwm), GFP_KERNEL);
        if (!chip->pwms)
                return -ENOMEM;
 
        return 0;
 }
-EXPORT_SYMBOL_GPL(pwmchip_add);
+EXPORT_SYMBOL_GPL(__pwmchip_add);
 
 /**
  * pwmchip_remove() - remove a PWM chip
        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
        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);
 }
 
 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)
 
 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)
 
 
 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 = {
 
        .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 = {
 
 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 = {
 
 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)
 
 
 static const struct pwm_ops kona_pwm_ops = {
        .apply = kona_pwmc_apply,
-       .owner = THIS_MODULE,
 };
 
 static int kona_pwmc_probe(struct platform_device *pdev)
 
        .request = bcm2835_pwm_request,
        .free = bcm2835_pwm_free,
        .apply = bcm2835_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static int bcm2835_pwm_probe(struct platform_device *pdev)
 
        .request = berlin_pwm_request,
        .free = berlin_pwm_free,
        .apply = berlin_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static const struct of_device_id berlin_pwm_match[] = {
 
 
 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[] = {
 
 
 static const struct pwm_ops pwm_clk_ops = {
        .apply = pwm_clk_apply,
-       .owner = THIS_MODULE,
 };
 
 static int pwm_clk_probe(struct platform_device *pdev)
 
 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,
 
        .free = cros_ec_pwm_free,
        .get_state      = cros_ec_pwm_get_state,
        .apply          = cros_ec_pwm_apply,
-       .owner          = THIS_MODULE,
 };
 
 /*
 
 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)
 
        .request = ep93xx_pwm_request,
        .free = ep93xx_pwm_free,
        .apply = ep93xx_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static int ep93xx_pwm_probe(struct platform_device *pdev)
 
        .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)
 
        .get_state = hibvt_pwm_get_state,
        .apply = hibvt_pwm_apply,
 
-       .owner = THIS_MODULE,
 };
 
 static int hibvt_pwm_probe(struct platform_device *pdev)
 
 
 static const struct pwm_ops img_pwm_ops = {
        .apply = img_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static const struct img_pwm_soc_data pistachio_pwm = {
 
        .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)
 
 
 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[] = {
 
 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[] = {
 
 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)
 
 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)
 
        .request = jz4740_pwm_request,
        .free = jz4740_pwm_free,
        .apply = jz4740_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static int jz4740_pwm_probe(struct platform_device *pdev)
 
 }
 
 static const struct pwm_ops keembay_pwm_ops = {
-       .owner = THIS_MODULE,
        .apply = keembay_pwm_apply,
        .get_state = keembay_pwm_get_state,
 };
 
        .request        = lp3943_pwm_request,
        .free           = lp3943_pwm_free,
        .apply          = lp3943_pwm_apply,
-       .owner          = THIS_MODULE,
 };
 
 static int lp3943_pwm_parse_dt(struct device *dev,
 
        .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[] = {
 
 
 static const struct pwm_ops lpc32xx_pwm_ops = {
        .apply = lpc32xx_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static int lpc32xx_pwm_probe(struct platform_device *pdev)
 
 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,
 
 
 static const struct pwm_ops pwm_mediatek_ops = {
        .apply = pwm_mediatek_apply,
-       .owner = THIS_MODULE,
 };
 
 static int pwm_mediatek_probe(struct platform_device *pdev)
 
        .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[] = {
 
 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[] = {
 
 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)
 
 
 static const struct pwm_ops mxs_pwm_ops = {
        .apply = mxs_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static int mxs_pwm_probe(struct platform_device *pdev)
 
 }
 
 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
 
 
 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)
 
        .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 = {
 
 
 static const struct pwm_ops pxa_pwm_ops = {
        .apply = pxa_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 #ifdef CONFIG_OF
 
 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)
 
        .request = rcar_pwm_request,
        .free = rcar_pwm_free,
        .apply = rcar_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static int rcar_pwm_probe(struct platform_device *pdev)
 
        .request = tpu_pwm_request,
        .free = tpu_pwm_free,
        .apply = tpu_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 /* -----------------------------------------------------------------------------
 
 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 = {
 
        .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)
 
        .request        = pwm_samsung_request,
        .free           = pwm_samsung_free,
        .apply          = pwm_samsung_apply,
-       .owner          = THIS_MODULE,
 };
 
 #ifdef CONFIG_OF
 
        .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,
 
 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)
 
 
 static const struct pwm_ops spear_pwm_ops = {
        .apply = spear_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static int spear_pwm_probe(struct platform_device *pdev)
 
 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)
 
        .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)
 
 }
 
 static const struct pwm_ops stm32_pwm_lp_ops = {
-       .owner = THIS_MODULE,
        .apply = stm32_pwm_lp_apply,
        .get_state = stm32_pwm_lp_get_state,
 };
 
 }
 
 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,
 };
 
 
 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)
 
 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 = {
 
 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)
 
 
 static const struct pwm_ops tegra_pwm_ops = {
        .apply = tegra_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static int tegra_pwm_probe(struct platform_device *pdev)
 
 
 static const struct pwm_ops ecap_pwm_ops = {
        .apply = ecap_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 static const struct of_device_id ecap_of_match[] = {
 
 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[] = {
 
 
 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,
        .apply = twl6030_pwmled_apply,
        .request = twl6030_pwmled_request,
        .free = twl6030_pwmled_free,
-       .owner = THIS_MODULE,
 };
 
 static int twl_pwmled_probe(struct platform_device *pdev)
 
        .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)
 
 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)
 
 
 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[] = {
 
 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 = {
 
        .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,
 
  * @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);
                     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
 struct pwm_chip {
        struct device *dev;
        const struct pwm_ops *ops;
+       struct module *owner;
        int base;
        unsigned int npwm;
 
 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,