Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'pwm/for-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm

Pull pwm updates from Thierry Reding:
"Various cleanups and fixes across the board"

* tag 'pwm/for-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm: (31 commits)
pwm: lpc32xx: Remove handling of PWM channels
pwm: atmel: Simplify using devm functions
dt-bindings: pwm: brcm,kona-pwm: convert to YAML
pwm: stmpe: Handle errors when disabling the signal
pwm: stm32: Simplify using devm_pwmchip_add()
pwm: stm32: Don't modify HW state in .remove() callback
pwm: Fix order of freeing resources in pwmchip_remove()
pwm: ntxec: Use device_set_of_node_from_dev()
pwm: ntxec: Drop a write-only variable from driver data
pwm: pxa: Don't reimplement of_device_get_match_data()
pwm: lpc18xx-sct: Simplify using devm_clk_get_enabled()
pwm: atmel-tcb: Don't track polarity in driver data
pwm: atmel-tcb: Unroll atmel_tcb_pwm_set_polarity() into only caller
pwm: atmel-tcb: Put per-channel data into driver data
pwm: atmel-tcb: Fix resource freeing in error path and remove
pwm: atmel-tcb: Harmonize resource allocation order
pwm: Drop unused #include <linux/radix-tree.h>
pwm: rz-mtu3: Fix build warning 'num_channel_ios' not described
pwm: Remove outdated documentation for pwmchip_remove()
pwm: atmel: Enable clk when pwm already enabled in bootloader
...

+282 -291
-21
Documentation/devicetree/bindings/pwm/brcm,kona-pwm.txt
··· 1 - Broadcom Kona PWM controller device tree bindings 2 - 3 - This controller has 6 channels. 4 - 5 - Required Properties : 6 - - compatible: should contain "brcm,kona-pwm" 7 - - reg: physical base address and length of the controller's registers 8 - - clocks: phandle + clock specifier pair for the external clock 9 - - #pwm-cells: Should be 3. See pwm.yaml in this directory for a 10 - description of the cells format. 11 - 12 - Refer to clocks/clock-bindings.txt for generic clock consumer properties. 13 - 14 - Example: 15 - 16 - pwm: pwm@3e01a000 { 17 - compatible = "brcm,bcm11351-pwm", "brcm,kona-pwm"; 18 - reg = <0x3e01a000 0xc4>; 19 - clocks = <&pwm_clk>; 20 - #pwm-cells = <3>; 21 - };
+51
Documentation/devicetree/bindings/pwm/brcm,kona-pwm.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/pwm/brcm,kona-pwm.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Broadcom Kona family PWM controller 8 + 9 + description: 10 + This controller has 6 channels. 11 + 12 + maintainers: 13 + - Florian Fainelli <f.fainelli@gmail.com> 14 + 15 + allOf: 16 + - $ref: pwm.yaml# 17 + 18 + properties: 19 + compatible: 20 + items: 21 + - enum: 22 + - brcm,bcm11351-pwm 23 + - const: brcm,kona-pwm 24 + 25 + reg: 26 + maxItems: 1 27 + 28 + clocks: 29 + maxItems: 1 30 + 31 + '#pwm-cells': 32 + const: 3 33 + 34 + required: 35 + - compatible 36 + - reg 37 + - clocks 38 + 39 + unevaluatedProperties: false 40 + 41 + examples: 42 + - | 43 + #include <dt-bindings/clock/bcm281xx.h> 44 + 45 + pwm@3e01a000 { 46 + compatible = "brcm,bcm11351-pwm", "brcm,kona-pwm"; 47 + reg = <0x3e01a000 0xcc>; 48 + clocks = <&slave_ccu BCM281XX_SLAVE_CCU_PWM>; 49 + #pwm-cells = <3>; 50 + }; 51 + ...
+19 -22
drivers/pwm/core.c
··· 8 8 9 9 #include <linux/acpi.h> 10 10 #include <linux/module.h> 11 + #include <linux/of.h> 11 12 #include <linux/pwm.h> 12 - #include <linux/radix-tree.h> 13 13 #include <linux/list.h> 14 14 #include <linux/mutex.h> 15 15 #include <linux/err.h> ··· 127 127 } 128 128 129 129 struct pwm_device * 130 - of_pwm_xlate_with_flags(struct pwm_chip *pc, const struct of_phandle_args *args) 130 + of_pwm_xlate_with_flags(struct pwm_chip *chip, const struct of_phandle_args *args) 131 131 { 132 132 struct pwm_device *pwm; 133 133 134 - if (pc->of_pwm_n_cells < 2) 134 + if (chip->of_pwm_n_cells < 2) 135 135 return ERR_PTR(-EINVAL); 136 136 137 137 /* flags in the third cell are optional */ 138 138 if (args->args_count < 2) 139 139 return ERR_PTR(-EINVAL); 140 140 141 - if (args->args[0] >= pc->npwm) 141 + if (args->args[0] >= chip->npwm) 142 142 return ERR_PTR(-EINVAL); 143 143 144 - pwm = pwm_request_from_chip(pc, args->args[0], NULL); 144 + pwm = pwm_request_from_chip(chip, args->args[0], NULL); 145 145 if (IS_ERR(pwm)) 146 146 return pwm; 147 147 148 148 pwm->args.period = args->args[1]; 149 149 pwm->args.polarity = PWM_POLARITY_NORMAL; 150 150 151 - if (pc->of_pwm_n_cells >= 3) { 151 + if (chip->of_pwm_n_cells >= 3) { 152 152 if (args->args_count > 2 && args->args[2] & PWM_POLARITY_INVERTED) 153 153 pwm->args.polarity = PWM_POLARITY_INVERSED; 154 154 } ··· 158 158 EXPORT_SYMBOL_GPL(of_pwm_xlate_with_flags); 159 159 160 160 struct pwm_device * 161 - of_pwm_single_xlate(struct pwm_chip *pc, const struct of_phandle_args *args) 161 + of_pwm_single_xlate(struct pwm_chip *chip, const struct of_phandle_args *args) 162 162 { 163 163 struct pwm_device *pwm; 164 164 165 - if (pc->of_pwm_n_cells < 1) 165 + if (chip->of_pwm_n_cells < 1) 166 166 return ERR_PTR(-EINVAL); 167 167 168 168 /* validate that one cell is specified, optionally with flags */ 169 169 if (args->args_count != 1 && args->args_count != 2) 170 170 return ERR_PTR(-EINVAL); 171 171 172 - pwm = pwm_request_from_chip(pc, 0, NULL); 172 + pwm = pwm_request_from_chip(chip, 0, NULL); 173 173 if (IS_ERR(pwm)) 174 174 return pwm; 175 175 ··· 312 312 * pwmchip_remove() - remove a PWM chip 313 313 * @chip: the PWM chip to remove 314 314 * 315 - * Removes a PWM chip. This function may return busy if the PWM chip provides 316 - * a PWM device that is still requested. 317 - * 318 - * Returns: 0 on success or a negative error code on failure. 315 + * Removes a PWM chip. 319 316 */ 320 317 void pwmchip_remove(struct pwm_chip *chip) 321 318 { 322 319 pwmchip_sysfs_unexport(chip); 323 320 321 + if (IS_ENABLED(CONFIG_OF)) 322 + of_pwmchip_remove(chip); 323 + 324 324 mutex_lock(&pwm_lock); 325 325 326 326 list_del_init(&chip->list); 327 - 328 - if (IS_ENABLED(CONFIG_OF)) 329 - of_pwmchip_remove(chip); 330 327 331 328 free_pwms(chip); 332 329 ··· 689 692 struct pwm_device *pwm = NULL; 690 693 struct of_phandle_args args; 691 694 struct device_link *dl; 692 - struct pwm_chip *pc; 695 + struct pwm_chip *chip; 693 696 int index = 0; 694 697 int err; 695 698 ··· 706 709 return ERR_PTR(err); 707 710 } 708 711 709 - pc = fwnode_to_pwmchip(of_fwnode_handle(args.np)); 710 - if (IS_ERR(pc)) { 711 - if (PTR_ERR(pc) != -EPROBE_DEFER) 712 + chip = fwnode_to_pwmchip(of_fwnode_handle(args.np)); 713 + if (IS_ERR(chip)) { 714 + if (PTR_ERR(chip) != -EPROBE_DEFER) 712 715 pr_err("%s(): PWM chip not found\n", __func__); 713 716 714 - pwm = ERR_CAST(pc); 717 + pwm = ERR_CAST(chip); 715 718 goto put; 716 719 } 717 720 718 - pwm = pc->of_xlate(pc, &args); 721 + pwm = chip->of_xlate(chip, &args); 719 722 if (IS_ERR(pwm)) 720 723 goto put; 721 724
+1
drivers/pwm/pwm-apple.c
··· 12 12 * - When APPLE_PWM_CTRL is set to 0, the output is constant low 13 13 */ 14 14 15 + #include <linux/mod_devicetable.h> 15 16 #include <linux/module.h> 16 17 #include <linux/platform_device.h> 17 18 #include <linux/pwm.h>
+34 -32
drivers/pwm/pwm-atmel-hlcdc.c
··· 10 10 #include <linux/delay.h> 11 11 #include <linux/mfd/atmel-hlcdc.h> 12 12 #include <linux/module.h> 13 + #include <linux/of.h> 13 14 #include <linux/platform_device.h> 14 15 #include <linux/pwm.h> 15 16 #include <linux/regmap.h> ··· 39 38 return container_of(chip, struct atmel_hlcdc_pwm, chip); 40 39 } 41 40 42 - static int atmel_hlcdc_pwm_apply(struct pwm_chip *c, struct pwm_device *pwm, 41 + static int atmel_hlcdc_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, 43 42 const struct pwm_state *state) 44 43 { 45 - struct atmel_hlcdc_pwm *chip = to_atmel_hlcdc_pwm(c); 46 - struct atmel_hlcdc *hlcdc = chip->hlcdc; 44 + struct atmel_hlcdc_pwm *atmel = to_atmel_hlcdc_pwm(chip); 45 + struct atmel_hlcdc *hlcdc = atmel->hlcdc; 47 46 unsigned int status; 48 47 int ret; 49 48 ··· 55 54 u32 pwmcfg; 56 55 int pres; 57 56 58 - if (!chip->errata || !chip->errata->slow_clk_erratum) { 57 + if (!atmel->errata || !atmel->errata->slow_clk_erratum) { 59 58 clk_freq = clk_get_rate(new_clk); 60 59 if (!clk_freq) 61 60 return -EINVAL; ··· 65 64 } 66 65 67 66 /* Errata: cannot use slow clk on some IP revisions */ 68 - if ((chip->errata && chip->errata->slow_clk_erratum) || 67 + if ((atmel->errata && atmel->errata->slow_clk_erratum) || 69 68 clk_period_ns > state->period) { 70 69 new_clk = hlcdc->sys_clk; 71 70 clk_freq = clk_get_rate(new_clk); ··· 78 77 79 78 for (pres = 0; pres <= ATMEL_HLCDC_PWMPS_MAX; pres++) { 80 79 /* Errata: cannot divide by 1 on some IP revisions */ 81 - if (!pres && chip->errata && 82 - chip->errata->div1_clk_erratum) 80 + if (!pres && atmel->errata && 81 + atmel->errata->div1_clk_erratum) 83 82 continue; 84 83 85 84 if ((clk_period_ns << pres) >= state->period) ··· 91 90 92 91 pwmcfg = ATMEL_HLCDC_PWMPS(pres); 93 92 94 - if (new_clk != chip->cur_clk) { 93 + if (new_clk != atmel->cur_clk) { 95 94 u32 gencfg = 0; 96 95 int ret; 97 96 ··· 99 98 if (ret) 100 99 return ret; 101 100 102 - clk_disable_unprepare(chip->cur_clk); 103 - chip->cur_clk = new_clk; 101 + clk_disable_unprepare(atmel->cur_clk); 102 + atmel->cur_clk = new_clk; 104 103 105 104 if (new_clk == hlcdc->sys_clk) 106 105 gencfg = ATMEL_HLCDC_CLKPWMSEL; ··· 161 160 if (ret) 162 161 return ret; 163 162 164 - clk_disable_unprepare(chip->cur_clk); 165 - chip->cur_clk = NULL; 163 + clk_disable_unprepare(atmel->cur_clk); 164 + atmel->cur_clk = NULL; 166 165 } 167 166 168 167 return 0; ··· 184 183 #ifdef CONFIG_PM_SLEEP 185 184 static int atmel_hlcdc_pwm_suspend(struct device *dev) 186 185 { 187 - struct atmel_hlcdc_pwm *chip = dev_get_drvdata(dev); 186 + struct atmel_hlcdc_pwm *atmel = dev_get_drvdata(dev); 188 187 189 188 /* Keep the periph clock enabled if the PWM is still running. */ 190 - if (pwm_is_enabled(&chip->chip.pwms[0])) 191 - clk_disable_unprepare(chip->hlcdc->periph_clk); 189 + if (pwm_is_enabled(&atmel->chip.pwms[0])) 190 + clk_disable_unprepare(atmel->hlcdc->periph_clk); 192 191 193 192 return 0; 194 193 } 195 194 196 195 static int atmel_hlcdc_pwm_resume(struct device *dev) 197 196 { 198 - struct atmel_hlcdc_pwm *chip = dev_get_drvdata(dev); 197 + struct atmel_hlcdc_pwm *atmel = dev_get_drvdata(dev); 199 198 struct pwm_state state; 200 199 int ret; 201 200 202 - pwm_get_state(&chip->chip.pwms[0], &state); 201 + pwm_get_state(&atmel->chip.pwms[0], &state); 203 202 204 203 /* Re-enable the periph clock it was stopped during suspend. */ 205 204 if (!state.enabled) { 206 - ret = clk_prepare_enable(chip->hlcdc->periph_clk); 205 + ret = clk_prepare_enable(atmel->hlcdc->periph_clk); 207 206 if (ret) 208 207 return ret; 209 208 } 210 209 211 - return atmel_hlcdc_pwm_apply(&chip->chip, &chip->chip.pwms[0], &state); 210 + return atmel_hlcdc_pwm_apply(&atmel->chip, &atmel->chip.pwms[0], 211 + &state); 212 212 } 213 213 #endif 214 214 ··· 246 244 { 247 245 const struct of_device_id *match; 248 246 struct device *dev = &pdev->dev; 249 - struct atmel_hlcdc_pwm *chip; 247 + struct atmel_hlcdc_pwm *atmel; 250 248 struct atmel_hlcdc *hlcdc; 251 249 int ret; 252 250 253 251 hlcdc = dev_get_drvdata(dev->parent); 254 252 255 - chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); 256 - if (!chip) 253 + atmel = devm_kzalloc(dev, sizeof(*atmel), GFP_KERNEL); 254 + if (!atmel) 257 255 return -ENOMEM; 258 256 259 257 ret = clk_prepare_enable(hlcdc->periph_clk); ··· 262 260 263 261 match = of_match_node(atmel_hlcdc_dt_ids, dev->parent->of_node); 264 262 if (match) 265 - chip->errata = match->data; 263 + atmel->errata = match->data; 266 264 267 - chip->hlcdc = hlcdc; 268 - chip->chip.ops = &atmel_hlcdc_pwm_ops; 269 - chip->chip.dev = dev; 270 - chip->chip.npwm = 1; 265 + atmel->hlcdc = hlcdc; 266 + atmel->chip.ops = &atmel_hlcdc_pwm_ops; 267 + atmel->chip.dev = dev; 268 + atmel->chip.npwm = 1; 271 269 272 - ret = pwmchip_add(&chip->chip); 270 + ret = pwmchip_add(&atmel->chip); 273 271 if (ret) { 274 272 clk_disable_unprepare(hlcdc->periph_clk); 275 273 return ret; 276 274 } 277 275 278 - platform_set_drvdata(pdev, chip); 276 + platform_set_drvdata(pdev, atmel); 279 277 280 278 return 0; 281 279 } 282 280 283 281 static void atmel_hlcdc_pwm_remove(struct platform_device *pdev) 284 282 { 285 - struct atmel_hlcdc_pwm *chip = platform_get_drvdata(pdev); 283 + struct atmel_hlcdc_pwm *atmel = platform_get_drvdata(pdev); 286 284 287 - pwmchip_remove(&chip->chip); 285 + pwmchip_remove(&atmel->chip); 288 286 289 - clk_disable_unprepare(chip->hlcdc->periph_clk); 287 + clk_disable_unprepare(atmel->hlcdc->periph_clk); 290 288 } 291 289 292 290 static const struct of_device_id atmel_hlcdc_pwm_dt_ids[] = {
+48 -75
drivers/pwm/pwm-atmel-tcb.c
··· 19 19 #include <linux/mfd/syscon.h> 20 20 #include <linux/platform_device.h> 21 21 #include <linux/pwm.h> 22 - #include <linux/of_device.h> 23 - #include <linux/of_irq.h> 22 + #include <linux/of.h> 24 23 #include <linux/regmap.h> 25 24 #include <linux/slab.h> 26 25 #include <soc/at91/atmel_tcb.h> ··· 33 34 ATMEL_TC_BEEVT | ATMEL_TC_BSWTRG) 34 35 35 36 struct atmel_tcb_pwm_device { 36 - enum pwm_polarity polarity; /* PWM polarity */ 37 37 unsigned div; /* PWM clock divider */ 38 38 unsigned duty; /* PWM duty expressed in clk cycles */ 39 39 unsigned period; /* PWM period expressed in clk cycles */ ··· 55 57 struct clk *clk; 56 58 struct clk *gclk; 57 59 struct clk *slow_clk; 58 - struct atmel_tcb_pwm_device *pwms[NPWM]; 60 + struct atmel_tcb_pwm_device pwms[NPWM]; 59 61 struct atmel_tcb_channel bkup; 60 62 }; 61 63 ··· 66 68 return container_of(chip, struct atmel_tcb_pwm_chip, chip); 67 69 } 68 70 69 - static int atmel_tcb_pwm_set_polarity(struct pwm_chip *chip, 70 - struct pwm_device *pwm, 71 - enum pwm_polarity polarity) 72 - { 73 - struct atmel_tcb_pwm_chip *tcbpwmc = to_tcb_chip(chip); 74 - struct atmel_tcb_pwm_device *tcbpwm = tcbpwmc->pwms[pwm->hwpwm]; 75 - 76 - tcbpwm->polarity = polarity; 77 - 78 - return 0; 79 - } 80 - 81 71 static int atmel_tcb_pwm_request(struct pwm_chip *chip, 82 72 struct pwm_device *pwm) 83 73 { 84 74 struct atmel_tcb_pwm_chip *tcbpwmc = to_tcb_chip(chip); 85 - struct atmel_tcb_pwm_device *tcbpwm; 75 + struct atmel_tcb_pwm_device *tcbpwm = &tcbpwmc->pwms[pwm->hwpwm]; 86 76 unsigned cmr; 87 77 int ret; 88 78 89 - tcbpwm = devm_kzalloc(chip->dev, sizeof(*tcbpwm), GFP_KERNEL); 90 - if (!tcbpwm) 91 - return -ENOMEM; 92 - 93 79 ret = clk_prepare_enable(tcbpwmc->clk); 94 - if (ret) { 95 - devm_kfree(chip->dev, tcbpwm); 80 + if (ret) 96 81 return ret; 97 - } 98 82 99 - tcbpwm->polarity = PWM_POLARITY_NORMAL; 100 83 tcbpwm->duty = 0; 101 84 tcbpwm->period = 0; 102 85 tcbpwm->div = 0; ··· 110 131 regmap_write(tcbpwmc->regmap, ATMEL_TC_REG(tcbpwmc->channel, CMR), cmr); 111 132 spin_unlock(&tcbpwmc->lock); 112 133 113 - tcbpwmc->pwms[pwm->hwpwm] = tcbpwm; 114 - 115 134 return 0; 116 135 } 117 136 118 137 static void atmel_tcb_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm) 119 138 { 120 139 struct atmel_tcb_pwm_chip *tcbpwmc = to_tcb_chip(chip); 121 - struct atmel_tcb_pwm_device *tcbpwm = tcbpwmc->pwms[pwm->hwpwm]; 122 140 123 141 clk_disable_unprepare(tcbpwmc->clk); 124 - tcbpwmc->pwms[pwm->hwpwm] = NULL; 125 - devm_kfree(chip->dev, tcbpwm); 126 142 } 127 143 128 - static void atmel_tcb_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) 144 + static void atmel_tcb_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm, 145 + enum pwm_polarity polarity) 129 146 { 130 147 struct atmel_tcb_pwm_chip *tcbpwmc = to_tcb_chip(chip); 131 - struct atmel_tcb_pwm_device *tcbpwm = tcbpwmc->pwms[pwm->hwpwm]; 148 + struct atmel_tcb_pwm_device *tcbpwm = &tcbpwmc->pwms[pwm->hwpwm]; 132 149 unsigned cmr; 133 - enum pwm_polarity polarity = tcbpwm->polarity; 134 150 135 151 /* 136 152 * If duty is 0 the timer will be stopped and we have to ··· 177 203 spin_unlock(&tcbpwmc->lock); 178 204 } 179 205 180 - static int atmel_tcb_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) 206 + static int atmel_tcb_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm, 207 + enum pwm_polarity polarity) 181 208 { 182 209 struct atmel_tcb_pwm_chip *tcbpwmc = to_tcb_chip(chip); 183 - struct atmel_tcb_pwm_device *tcbpwm = tcbpwmc->pwms[pwm->hwpwm]; 210 + struct atmel_tcb_pwm_device *tcbpwm = &tcbpwmc->pwms[pwm->hwpwm]; 184 211 u32 cmr; 185 - enum pwm_polarity polarity = tcbpwm->polarity; 186 212 187 213 /* 188 214 * If duty is 0 the timer will be stopped and we have to ··· 265 291 int duty_ns, int period_ns) 266 292 { 267 293 struct atmel_tcb_pwm_chip *tcbpwmc = to_tcb_chip(chip); 268 - struct atmel_tcb_pwm_device *tcbpwm = tcbpwmc->pwms[pwm->hwpwm]; 294 + struct atmel_tcb_pwm_device *tcbpwm = &tcbpwmc->pwms[pwm->hwpwm]; 269 295 struct atmel_tcb_pwm_device *atcbpwm = NULL; 270 296 int i = 0; 271 297 int slowclk = 0; ··· 312 338 period = div_u64(period_ns, min); 313 339 314 340 if (pwm->hwpwm == 0) 315 - atcbpwm = tcbpwmc->pwms[1]; 341 + atcbpwm = &tcbpwmc->pwms[1]; 316 342 else 317 - atcbpwm = tcbpwmc->pwms[0]; 343 + atcbpwm = &tcbpwmc->pwms[0]; 318 344 319 345 /* 320 346 * PWM devices provided by the TCB driver are grouped by 2. ··· 345 371 int duty_cycle, period; 346 372 int ret; 347 373 348 - /* This function only sets a flag in driver data */ 349 - atmel_tcb_pwm_set_polarity(chip, pwm, state->polarity); 350 - 351 374 if (!state->enabled) { 352 - atmel_tcb_pwm_disable(chip, pwm); 375 + atmel_tcb_pwm_disable(chip, pwm, state->polarity); 353 376 return 0; 354 377 } 355 378 ··· 357 386 if (ret) 358 387 return ret; 359 388 360 - return atmel_tcb_pwm_enable(chip, pwm); 389 + return atmel_tcb_pwm_enable(chip, pwm, state->polarity); 361 390 } 362 391 363 392 static const struct pwm_ops atmel_tcb_pwm_ops = { ··· 393 422 struct atmel_tcb_pwm_chip *tcbpwm; 394 423 const struct atmel_tcb_config *config; 395 424 struct device_node *np = pdev->dev.of_node; 396 - struct regmap *regmap; 397 - struct clk *clk, *gclk = NULL; 398 - struct clk *slow_clk; 399 425 char clk_name[] = "t0_clk"; 400 426 int err; 401 427 int channel; 428 + 429 + tcbpwm = devm_kzalloc(&pdev->dev, sizeof(*tcbpwm), GFP_KERNEL); 430 + if (tcbpwm == NULL) 431 + return -ENOMEM; 402 432 403 433 err = of_property_read_u32(np, "reg", &channel); 404 434 if (err < 0) { ··· 409 437 return err; 410 438 } 411 439 412 - regmap = syscon_node_to_regmap(np->parent); 413 - if (IS_ERR(regmap)) 414 - return PTR_ERR(regmap); 440 + tcbpwm->regmap = syscon_node_to_regmap(np->parent); 441 + if (IS_ERR(tcbpwm->regmap)) 442 + return PTR_ERR(tcbpwm->regmap); 415 443 416 - slow_clk = of_clk_get_by_name(np->parent, "slow_clk"); 417 - if (IS_ERR(slow_clk)) 418 - return PTR_ERR(slow_clk); 444 + tcbpwm->slow_clk = of_clk_get_by_name(np->parent, "slow_clk"); 445 + if (IS_ERR(tcbpwm->slow_clk)) 446 + return PTR_ERR(tcbpwm->slow_clk); 419 447 420 448 clk_name[1] += channel; 421 - clk = of_clk_get_by_name(np->parent, clk_name); 422 - if (IS_ERR(clk)) 423 - clk = of_clk_get_by_name(np->parent, "t0_clk"); 424 - if (IS_ERR(clk)) 425 - return PTR_ERR(clk); 449 + tcbpwm->clk = of_clk_get_by_name(np->parent, clk_name); 450 + if (IS_ERR(tcbpwm->clk)) 451 + tcbpwm->clk = of_clk_get_by_name(np->parent, "t0_clk"); 452 + if (IS_ERR(tcbpwm->clk)) { 453 + err = PTR_ERR(tcbpwm->clk); 454 + goto err_slow_clk; 455 + } 426 456 427 457 match = of_match_node(atmel_tcb_of_match, np->parent); 428 458 config = match->data; 429 459 430 460 if (config->has_gclk) { 431 - gclk = of_clk_get_by_name(np->parent, "gclk"); 432 - if (IS_ERR(gclk)) 433 - return PTR_ERR(gclk); 434 - } 435 - 436 - tcbpwm = devm_kzalloc(&pdev->dev, sizeof(*tcbpwm), GFP_KERNEL); 437 - if (tcbpwm == NULL) { 438 - err = -ENOMEM; 439 - goto err_slow_clk; 461 + tcbpwm->gclk = of_clk_get_by_name(np->parent, "gclk"); 462 + if (IS_ERR(tcbpwm->gclk)) { 463 + err = PTR_ERR(tcbpwm->gclk); 464 + goto err_clk; 465 + } 440 466 } 441 467 442 468 tcbpwm->chip.dev = &pdev->dev; 443 469 tcbpwm->chip.ops = &atmel_tcb_pwm_ops; 444 470 tcbpwm->chip.npwm = NPWM; 445 471 tcbpwm->channel = channel; 446 - tcbpwm->regmap = regmap; 447 - tcbpwm->clk = clk; 448 - tcbpwm->gclk = gclk; 449 - tcbpwm->slow_clk = slow_clk; 450 472 tcbpwm->width = config->counter_width; 451 473 452 - err = clk_prepare_enable(slow_clk); 474 + err = clk_prepare_enable(tcbpwm->slow_clk); 453 475 if (err) 454 - goto err_slow_clk; 476 + goto err_gclk; 455 477 456 478 spin_lock_init(&tcbpwm->lock); 457 479 ··· 460 494 err_disable_clk: 461 495 clk_disable_unprepare(tcbpwm->slow_clk); 462 496 497 + err_gclk: 498 + clk_put(tcbpwm->gclk); 499 + 500 + err_clk: 501 + clk_put(tcbpwm->clk); 502 + 463 503 err_slow_clk: 464 - clk_put(slow_clk); 504 + clk_put(tcbpwm->slow_clk); 465 505 466 506 return err; 467 507 } ··· 479 507 pwmchip_remove(&tcbpwm->chip); 480 508 481 509 clk_disable_unprepare(tcbpwm->slow_clk); 482 - clk_put(tcbpwm->slow_clk); 510 + clk_put(tcbpwm->gclk); 483 511 clk_put(tcbpwm->clk); 512 + clk_put(tcbpwm->slow_clk); 484 513 } 485 514 486 515 static const struct of_device_id atmel_tcb_pwm_dt_ids[] = {
+51 -28
drivers/pwm/pwm-atmel.c
··· 25 25 #include <linux/io.h> 26 26 #include <linux/module.h> 27 27 #include <linux/of.h> 28 - #include <linux/of_device.h> 29 28 #include <linux/platform_device.h> 30 29 #include <linux/pwm.h> 31 30 #include <linux/slab.h> ··· 35 36 #define PWM_SR 0x0C 36 37 #define PWM_ISR 0x1C 37 38 /* Bit field in SR */ 38 - #define PWM_SR_ALL_CH_ON 0x0F 39 + #define PWM_SR_ALL_CH_MASK 0x0F 39 40 40 41 /* The following register is PWM channel related registers */ 41 42 #define PWM_CH_REG_OFFSET 0x200 ··· 463 464 }; 464 465 MODULE_DEVICE_TABLE(of, atmel_pwm_dt_ids); 465 466 467 + static int atmel_pwm_enable_clk_if_on(struct atmel_pwm_chip *atmel_pwm, bool on) 468 + { 469 + unsigned int i, cnt = 0; 470 + unsigned long sr; 471 + int ret = 0; 472 + 473 + sr = atmel_pwm_readl(atmel_pwm, PWM_SR) & PWM_SR_ALL_CH_MASK; 474 + if (!sr) 475 + return 0; 476 + 477 + cnt = bitmap_weight(&sr, atmel_pwm->chip.npwm); 478 + 479 + if (!on) 480 + goto disable_clk; 481 + 482 + for (i = 0; i < cnt; i++) { 483 + ret = clk_enable(atmel_pwm->clk); 484 + if (ret) { 485 + dev_err(atmel_pwm->chip.dev, 486 + "failed to enable clock for pwm %pe\n", 487 + ERR_PTR(ret)); 488 + 489 + cnt = i; 490 + goto disable_clk; 491 + } 492 + } 493 + 494 + return 0; 495 + 496 + disable_clk: 497 + while (cnt--) 498 + clk_disable(atmel_pwm->clk); 499 + 500 + return ret; 501 + } 502 + 466 503 static int atmel_pwm_probe(struct platform_device *pdev) 467 504 { 468 505 struct atmel_pwm_chip *atmel_pwm; ··· 517 482 if (IS_ERR(atmel_pwm->base)) 518 483 return PTR_ERR(atmel_pwm->base); 519 484 520 - atmel_pwm->clk = devm_clk_get(&pdev->dev, NULL); 485 + atmel_pwm->clk = devm_clk_get_prepared(&pdev->dev, NULL); 521 486 if (IS_ERR(atmel_pwm->clk)) 522 - return PTR_ERR(atmel_pwm->clk); 523 - 524 - ret = clk_prepare(atmel_pwm->clk); 525 - if (ret) { 526 - dev_err(&pdev->dev, "failed to prepare PWM clock\n"); 527 - return ret; 528 - } 487 + return dev_err_probe(&pdev->dev, PTR_ERR(atmel_pwm->clk), 488 + "failed to get prepared PWM clock\n"); 529 489 530 490 atmel_pwm->chip.dev = &pdev->dev; 531 491 atmel_pwm->chip.ops = &atmel_pwm_ops; 532 492 atmel_pwm->chip.npwm = 4; 533 493 534 - ret = pwmchip_add(&atmel_pwm->chip); 494 + ret = atmel_pwm_enable_clk_if_on(atmel_pwm, true); 495 + if (ret < 0) 496 + return ret; 497 + 498 + ret = devm_pwmchip_add(&pdev->dev, &atmel_pwm->chip); 535 499 if (ret < 0) { 536 - dev_err(&pdev->dev, "failed to add PWM chip %d\n", ret); 537 - goto unprepare_clk; 500 + dev_err_probe(&pdev->dev, ret, "failed to add PWM chip\n"); 501 + goto disable_clk; 538 502 } 539 503 540 - platform_set_drvdata(pdev, atmel_pwm); 504 + return 0; 505 + 506 + disable_clk: 507 + atmel_pwm_enable_clk_if_on(atmel_pwm, false); 541 508 542 509 return ret; 543 - 544 - unprepare_clk: 545 - clk_unprepare(atmel_pwm->clk); 546 - return ret; 547 - } 548 - 549 - static void atmel_pwm_remove(struct platform_device *pdev) 550 - { 551 - struct atmel_pwm_chip *atmel_pwm = platform_get_drvdata(pdev); 552 - 553 - pwmchip_remove(&atmel_pwm->chip); 554 - 555 - clk_unprepare(atmel_pwm->clk); 556 510 } 557 511 558 512 static struct platform_driver atmel_pwm_driver = { ··· 550 526 .of_match_table = of_match_ptr(atmel_pwm_dt_ids), 551 527 }, 552 528 .probe = atmel_pwm_probe, 553 - .remove_new = atmel_pwm_remove, 554 529 }; 555 530 module_platform_driver(atmel_pwm_driver); 556 531
+2 -2
drivers/pwm/pwm-bcm-kona.c
··· 61 61 struct clk *clk; 62 62 }; 63 63 64 - static inline struct kona_pwmc *to_kona_pwmc(struct pwm_chip *_chip) 64 + static inline struct kona_pwmc *to_kona_pwmc(struct pwm_chip *chip) 65 65 { 66 - return container_of(_chip, struct kona_pwmc, chip); 66 + return container_of(chip, struct kona_pwmc, chip); 67 67 } 68 68 69 69 /*
+1
drivers/pwm/pwm-berlin.c
··· 13 13 #include <linux/clk.h> 14 14 #include <linux/io.h> 15 15 #include <linux/kernel.h> 16 + #include <linux/mod_devicetable.h> 16 17 #include <linux/module.h> 17 18 #include <linux/platform_device.h> 18 19 #include <linux/pwm.h>
+2 -2
drivers/pwm/pwm-crc.c
··· 34 34 struct regmap *regmap; 35 35 }; 36 36 37 - static inline struct crystalcove_pwm *to_crc_pwm(struct pwm_chip *pc) 37 + static inline struct crystalcove_pwm *to_crc_pwm(struct pwm_chip *chip) 38 38 { 39 - return container_of(pc, struct crystalcove_pwm, chip); 39 + return container_of(chip, struct crystalcove_pwm, chip); 40 40 } 41 41 42 42 static int crc_pwm_calc_clk_div(int period_ns)
+6 -5
drivers/pwm/pwm-cros-ec.c
··· 6 6 */ 7 7 8 8 #include <linux/module.h> 9 + #include <linux/of.h> 9 10 #include <linux/platform_data/cros_ec_commands.h> 10 11 #include <linux/platform_data/cros_ec_proto.h> 11 12 #include <linux/platform_device.h> ··· 38 37 u16 duty_cycle; 39 38 }; 40 39 41 - static inline struct cros_ec_pwm_device *pwm_to_cros_ec_pwm(struct pwm_chip *c) 40 + static inline struct cros_ec_pwm_device *pwm_to_cros_ec_pwm(struct pwm_chip *chip) 42 41 { 43 - return container_of(c, struct cros_ec_pwm_device, chip); 42 + return container_of(chip, struct cros_ec_pwm_device, chip); 44 43 } 45 44 46 45 static int cros_ec_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm) ··· 219 218 } 220 219 221 220 static struct pwm_device * 222 - cros_ec_pwm_xlate(struct pwm_chip *pc, const struct of_phandle_args *args) 221 + cros_ec_pwm_xlate(struct pwm_chip *chip, const struct of_phandle_args *args) 223 222 { 224 223 struct pwm_device *pwm; 225 224 226 - if (args->args[0] >= pc->npwm) 225 + if (args->args[0] >= chip->npwm) 227 226 return ERR_PTR(-EINVAL); 228 227 229 - pwm = pwm_request_from_chip(pc, args->args[0], NULL); 228 + pwm = pwm_request_from_chip(chip, args->args[0], NULL); 230 229 if (IS_ERR(pwm)) 231 230 return pwm; 232 231
+1 -2
drivers/pwm/pwm-fsl-ftm.c
··· 11 11 #include <linux/kernel.h> 12 12 #include <linux/module.h> 13 13 #include <linux/mutex.h> 14 - #include <linux/of_address.h> 15 - #include <linux/of_device.h> 14 + #include <linux/of.h> 16 15 #include <linux/platform_device.h> 17 16 #include <linux/pm.h> 18 17 #include <linux/pwm.h>
+1 -1
drivers/pwm/pwm-hibvt.c
··· 10 10 #include <linux/delay.h> 11 11 #include <linux/io.h> 12 12 #include <linux/module.h> 13 - #include <linux/of_device.h> 13 + #include <linux/of.h> 14 14 #include <linux/platform_device.h> 15 15 #include <linux/pwm.h> 16 16 #include <linux/reset.h>
-1
drivers/pwm/pwm-imx1.c
··· 14 14 #include <linux/kernel.h> 15 15 #include <linux/module.h> 16 16 #include <linux/of.h> 17 - #include <linux/of_device.h> 18 17 #include <linux/platform_device.h> 19 18 #include <linux/pwm.h> 20 19 #include <linux/slab.h>
+1 -1
drivers/pwm/pwm-jz4740.c
··· 15 15 #include <linux/mfd/ingenic-tcu.h> 16 16 #include <linux/mfd/syscon.h> 17 17 #include <linux/module.h> 18 - #include <linux/of_device.h> 18 + #include <linux/of.h> 19 19 #include <linux/platform_device.h> 20 20 #include <linux/pwm.h> 21 21 #include <linux/regmap.h>
+3 -2
drivers/pwm/pwm-lp3943.c
··· 10 10 #include <linux/err.h> 11 11 #include <linux/mfd/lp3943.h> 12 12 #include <linux/module.h> 13 + #include <linux/of.h> 13 14 #include <linux/platform_device.h> 14 15 #include <linux/pwm.h> 15 16 #include <linux/slab.h> ··· 25 24 struct lp3943_platform_data *pdata; 26 25 }; 27 26 28 - static inline struct lp3943_pwm *to_lp3943_pwm(struct pwm_chip *_chip) 27 + static inline struct lp3943_pwm *to_lp3943_pwm(struct pwm_chip *chip) 29 28 { 30 - return container_of(_chip, struct lp3943_pwm, chip); 29 + return container_of(chip, struct lp3943_pwm, chip); 31 30 } 32 31 33 32 static struct lp3943_pwm_map *
+9 -25
drivers/pwm/pwm-lpc18xx-sct.c
··· 22 22 #include <linux/clk.h> 23 23 #include <linux/err.h> 24 24 #include <linux/io.h> 25 + #include <linux/mod_devicetable.h> 25 26 #include <linux/module.h> 26 27 #include <linux/platform_device.h> 27 28 #include <linux/pwm.h> ··· 367 366 if (IS_ERR(lpc18xx_pwm->base)) 368 367 return PTR_ERR(lpc18xx_pwm->base); 369 368 370 - lpc18xx_pwm->pwm_clk = devm_clk_get(&pdev->dev, "pwm"); 369 + lpc18xx_pwm->pwm_clk = devm_clk_get_enabled(&pdev->dev, "pwm"); 371 370 if (IS_ERR(lpc18xx_pwm->pwm_clk)) 372 371 return dev_err_probe(&pdev->dev, PTR_ERR(lpc18xx_pwm->pwm_clk), 373 372 "failed to get pwm clock\n"); 374 373 375 - ret = clk_prepare_enable(lpc18xx_pwm->pwm_clk); 376 - if (ret < 0) 377 - return dev_err_probe(&pdev->dev, ret, 378 - "could not prepare or enable pwm clock\n"); 379 - 380 374 lpc18xx_pwm->clk_rate = clk_get_rate(lpc18xx_pwm->pwm_clk); 381 - if (!lpc18xx_pwm->clk_rate) { 382 - ret = dev_err_probe(&pdev->dev, 383 - -EINVAL, "pwm clock has no frequency\n"); 384 - goto disable_pwmclk; 385 - } 375 + if (!lpc18xx_pwm->clk_rate) 376 + return dev_err_probe(&pdev->dev, 377 + -EINVAL, "pwm clock has no frequency\n"); 386 378 387 379 /* 388 380 * If clkrate is too fast, the calculations in .apply() might overflow. 389 381 */ 390 - if (lpc18xx_pwm->clk_rate > NSEC_PER_SEC) { 391 - ret = dev_err_probe(&pdev->dev, -EINVAL, "pwm clock to fast\n"); 392 - goto disable_pwmclk; 393 - } 382 + if (lpc18xx_pwm->clk_rate > NSEC_PER_SEC) 383 + return dev_err_probe(&pdev->dev, -EINVAL, "pwm clock to fast\n"); 394 384 395 385 mutex_init(&lpc18xx_pwm->res_lock); 396 386 mutex_init(&lpc18xx_pwm->period_lock); ··· 427 435 lpc18xx_pwm_writel(lpc18xx_pwm, LPC18XX_PWM_CTRL, val); 428 436 429 437 ret = pwmchip_add(&lpc18xx_pwm->chip); 430 - if (ret < 0) { 431 - dev_err_probe(&pdev->dev, ret, "pwmchip_add failed\n"); 432 - goto disable_pwmclk; 433 - } 438 + if (ret < 0) 439 + return dev_err_probe(&pdev->dev, ret, "pwmchip_add failed\n"); 434 440 435 441 platform_set_drvdata(pdev, lpc18xx_pwm); 436 442 437 443 return 0; 438 - 439 - disable_pwmclk: 440 - clk_disable_unprepare(lpc18xx_pwm->pwm_clk); 441 - return ret; 442 444 } 443 445 444 446 static void lpc18xx_pwm_remove(struct platform_device *pdev) ··· 445 459 val = lpc18xx_pwm_readl(lpc18xx_pwm, LPC18XX_PWM_CTRL); 446 460 lpc18xx_pwm_writel(lpc18xx_pwm, LPC18XX_PWM_CTRL, 447 461 val | LPC18XX_PWM_CTRL_HALT); 448 - 449 - clk_disable_unprepare(lpc18xx_pwm->pwm_clk); 450 462 } 451 463 452 464 static struct platform_driver lpc18xx_pwm_driver = {
+8 -8
drivers/pwm/pwm-lpc32xx.c
··· 51 51 if (duty_cycles > 255) 52 52 duty_cycles = 255; 53 53 54 - val = readl(lpc32xx->base + (pwm->hwpwm << 2)); 54 + val = readl(lpc32xx->base); 55 55 val &= ~0xFFFF; 56 56 val |= (period_cycles << 8) | duty_cycles; 57 - writel(val, lpc32xx->base + (pwm->hwpwm << 2)); 57 + writel(val, lpc32xx->base); 58 58 59 59 return 0; 60 60 } ··· 69 69 if (ret) 70 70 return ret; 71 71 72 - val = readl(lpc32xx->base + (pwm->hwpwm << 2)); 72 + val = readl(lpc32xx->base); 73 73 val |= PWM_ENABLE; 74 - writel(val, lpc32xx->base + (pwm->hwpwm << 2)); 74 + writel(val, lpc32xx->base); 75 75 76 76 return 0; 77 77 } ··· 81 81 struct lpc32xx_pwm_chip *lpc32xx = to_lpc32xx_pwm_chip(chip); 82 82 u32 val; 83 83 84 - val = readl(lpc32xx->base + (pwm->hwpwm << 2)); 84 + val = readl(lpc32xx->base); 85 85 val &= ~PWM_ENABLE; 86 - writel(val, lpc32xx->base + (pwm->hwpwm << 2)); 86 + writel(val, lpc32xx->base); 87 87 88 88 clk_disable_unprepare(lpc32xx->clk); 89 89 } ··· 141 141 lpc32xx->chip.npwm = 1; 142 142 143 143 /* If PWM is disabled, configure the output to the default value */ 144 - val = readl(lpc32xx->base + (lpc32xx->chip.pwms[0].hwpwm << 2)); 144 + val = readl(lpc32xx->base); 145 145 val &= ~PWM_PIN_LEVEL; 146 - writel(val, lpc32xx->base + (lpc32xx->chip.pwms[0].hwpwm << 2)); 146 + writel(val, lpc32xx->base); 147 147 148 148 ret = devm_pwmchip_add(&pdev->dev, &lpc32xx->chip); 149 149 if (ret < 0) {
-1
drivers/pwm/pwm-mediatek.c
··· 14 14 #include <linux/module.h> 15 15 #include <linux/clk.h> 16 16 #include <linux/of.h> 17 - #include <linux/of_device.h> 18 17 #include <linux/platform_device.h> 19 18 #include <linux/pwm.h> 20 19 #include <linux/slab.h>
-1
drivers/pwm/pwm-meson.c
··· 37 37 #include <linux/math64.h> 38 38 #include <linux/module.h> 39 39 #include <linux/of.h> 40 - #include <linux/of_device.h> 41 40 #include <linux/platform_device.h> 42 41 #include <linux/pwm.h> 43 42 #include <linux/slab.h>
+1 -1
drivers/pwm/pwm-microchip-core.c
··· 37 37 #include <linux/math.h> 38 38 #include <linux/module.h> 39 39 #include <linux/mutex.h> 40 - #include <linux/of_device.h> 40 + #include <linux/of.h> 41 41 #include <linux/platform_device.h> 42 42 #include <linux/pwm.h> 43 43
-1
drivers/pwm/pwm-mtk-disp.c
··· 11 11 #include <linux/io.h> 12 12 #include <linux/module.h> 13 13 #include <linux/of.h> 14 - #include <linux/of_device.h> 15 14 #include <linux/platform_device.h> 16 15 #include <linux/pwm.h> 17 16 #include <linux/slab.h>
+1 -3
drivers/pwm/pwm-ntxec.c
··· 24 24 #include <linux/types.h> 25 25 26 26 struct ntxec_pwm { 27 - struct device *dev; 28 27 struct ntxec *ec; 29 28 struct pwm_chip chip; 30 29 }; ··· 140 141 struct ntxec_pwm *priv; 141 142 struct pwm_chip *chip; 142 143 143 - pdev->dev.of_node = pdev->dev.parent->of_node; 144 + device_set_of_node_from_dev(&pdev->dev, pdev->dev.parent); 144 145 145 146 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); 146 147 if (!priv) 147 148 return -ENOMEM; 148 149 149 150 priv->ec = ec; 150 - priv->dev = &pdev->dev; 151 151 152 152 chip = &priv->chip; 153 153 chip->dev = &pdev->dev;
+2 -8
drivers/pwm/pwm-pxa.c
··· 15 15 * input clock (PWMCR_SD is set) and the output is driven to inactive. 16 16 */ 17 17 18 + #include <linux/mod_devicetable.h> 18 19 #include <linux/module.h> 19 20 #include <linux/kernel.h> 20 21 #include <linux/platform_device.h> ··· 157 156 #define pwm_of_match NULL 158 157 #endif 159 158 160 - static const struct platform_device_id *pxa_pwm_get_id_dt(struct device *dev) 161 - { 162 - const struct of_device_id *id = of_match_device(pwm_of_match, dev); 163 - 164 - return id ? id->data : NULL; 165 - } 166 - 167 159 static int pwm_probe(struct platform_device *pdev) 168 160 { 169 161 const struct platform_device_id *id = platform_get_device_id(pdev); ··· 164 170 int ret = 0; 165 171 166 172 if (IS_ENABLED(CONFIG_OF) && id == NULL) 167 - id = pxa_pwm_get_id_dt(&pdev->dev); 173 + id = of_device_get_match_data(&pdev->dev); 168 174 169 175 if (id == NULL) 170 176 return -EINVAL;
+2 -2
drivers/pwm/pwm-rockchip.c
··· 52 52 u32 enable_conf; 53 53 }; 54 54 55 - static inline struct rockchip_pwm_chip *to_rockchip_pwm_chip(struct pwm_chip *c) 55 + static inline struct rockchip_pwm_chip *to_rockchip_pwm_chip(struct pwm_chip *chip) 56 56 { 57 - return container_of(c, struct rockchip_pwm_chip, chip); 57 + return container_of(chip, struct rockchip_pwm_chip, chip); 58 58 } 59 59 60 60 static int rockchip_pwm_get_state(struct pwm_chip *chip,
+1 -1
drivers/pwm/pwm-rz-mtu3.c
··· 40 40 * struct rz_mtu3_channel_io_map - MTU3 pwm channel map 41 41 * 42 42 * @base_pwm_number: First PWM of a channel 43 - * @num: number of IOs on the HW channel. 43 + * @num_channel_ios: number of IOs on the HW channel. 44 44 */ 45 45 struct rz_mtu3_channel_io_map { 46 46 u8 base_pwm_number;
+3 -2
drivers/pwm/pwm-sifive.c
··· 13 13 */ 14 14 #include <linux/clk.h> 15 15 #include <linux/io.h> 16 + #include <linux/mod_devicetable.h> 16 17 #include <linux/module.h> 17 18 #include <linux/platform_device.h> 18 19 #include <linux/pwm.h> ··· 52 51 }; 53 52 54 53 static inline 55 - struct pwm_sifive_ddata *pwm_sifive_chip_to_ddata(struct pwm_chip *c) 54 + struct pwm_sifive_ddata *pwm_sifive_chip_to_ddata(struct pwm_chip *chip) 56 55 { 57 - return container_of(c, struct pwm_sifive_ddata, chip); 56 + return container_of(chip, struct pwm_sifive_ddata, chip); 58 57 } 59 58 60 59 static int pwm_sifive_request(struct pwm_chip *chip, struct pwm_device *pwm)
+9 -5
drivers/pwm/pwm-sl28cpld.c
··· 38 38 #include <linux/mod_devicetable.h> 39 39 #include <linux/module.h> 40 40 #include <linux/platform_device.h> 41 + #include <linux/property.h> 41 42 #include <linux/pwm.h> 42 43 #include <linux/regmap.h> 43 44 ··· 81 80 regmap_write((priv)->regmap, (priv)->offset + (reg), (val)) 82 81 83 82 struct sl28cpld_pwm { 84 - struct pwm_chip pwm_chip; 83 + struct pwm_chip chip; 85 84 struct regmap *regmap; 86 85 u32 offset; 87 86 }; 88 - #define sl28cpld_pwm_from_chip(_chip) \ 89 - container_of(_chip, struct sl28cpld_pwm, pwm_chip) 87 + 88 + static inline struct sl28cpld_pwm *sl28cpld_pwm_from_chip(struct pwm_chip *chip) 89 + { 90 + return container_of(chip, struct sl28cpld_pwm, chip); 91 + } 90 92 91 93 static int sl28cpld_pwm_get_state(struct pwm_chip *chip, 92 94 struct pwm_device *pwm, ··· 232 228 } 233 229 234 230 /* Initialize the pwm_chip structure */ 235 - chip = &priv->pwm_chip; 231 + chip = &priv->chip; 236 232 chip->dev = &pdev->dev; 237 233 chip->ops = &sl28cpld_pwm_ops; 238 234 chip->npwm = 1; 239 235 240 - ret = devm_pwmchip_add(&pdev->dev, &priv->pwm_chip); 236 + ret = devm_pwmchip_add(&pdev->dev, chip); 241 237 if (ret) { 242 238 dev_err(&pdev->dev, "failed to add PWM chip (%pe)", 243 239 ERR_PTR(ret));
+1
drivers/pwm/pwm-sprd.c
··· 7 7 #include <linux/err.h> 8 8 #include <linux/io.h> 9 9 #include <linux/math64.h> 10 + #include <linux/mod_devicetable.h> 10 11 #include <linux/module.h> 11 12 #include <linux/platform_device.h> 12 13 #include <linux/pwm.h>
+1 -13
drivers/pwm/pwm-stm32.c
··· 637 637 priv->chip.ops = &stm32pwm_ops; 638 638 priv->chip.npwm = stm32_pwm_detect_channels(priv); 639 639 640 - ret = pwmchip_add(&priv->chip); 640 + ret = devm_pwmchip_add(dev, &priv->chip); 641 641 if (ret < 0) 642 642 return ret; 643 643 644 644 platform_set_drvdata(pdev, priv); 645 645 646 646 return 0; 647 - } 648 - 649 - static void stm32_pwm_remove(struct platform_device *pdev) 650 - { 651 - struct stm32_pwm *priv = platform_get_drvdata(pdev); 652 - unsigned int i; 653 - 654 - for (i = 0; i < priv->chip.npwm; i++) 655 - pwm_disable(&priv->chip.pwms[i]); 656 - 657 - pwmchip_remove(&priv->chip); 658 647 } 659 648 660 649 static int __maybe_unused stm32_pwm_suspend(struct device *dev) ··· 690 701 691 702 static struct platform_driver stm32_pwm_driver = { 692 703 .probe = stm32_pwm_probe, 693 - .remove_new = stm32_pwm_remove, 694 704 .driver = { 695 705 .name = "stm32-pwm", 696 706 .of_match_table = stm32_pwm_of_match,
+9 -8
drivers/pwm/pwm-stmpe.c
··· 61 61 return 0; 62 62 } 63 63 64 - static void stmpe_24xx_pwm_disable(struct pwm_chip *chip, 65 - struct pwm_device *pwm) 64 + static int stmpe_24xx_pwm_disable(struct pwm_chip *chip, 65 + struct pwm_device *pwm) 66 66 { 67 67 struct stmpe_pwm *stmpe_pwm = to_stmpe_pwm(chip); 68 68 u8 value; ··· 72 72 if (ret < 0) { 73 73 dev_err(chip->dev, "error reading PWM#%u control\n", 74 74 pwm->hwpwm); 75 - return; 75 + return ret; 76 76 } 77 77 78 78 value = ret & ~BIT(pwm->hwpwm); 79 79 80 80 ret = stmpe_reg_write(stmpe_pwm->stmpe, STMPE24XX_PWMCS, value); 81 - if (ret) { 81 + if (ret) 82 82 dev_err(chip->dev, "error writing PWM#%u control\n", 83 83 pwm->hwpwm); 84 - return; 85 - } 84 + return ret; 86 85 } 87 86 88 87 /* STMPE 24xx PWM instructions */ ··· 110 111 111 112 /* Make sure we are disabled */ 112 113 if (pwm_is_enabled(pwm)) { 113 - stmpe_24xx_pwm_disable(chip, pwm); 114 + ret = stmpe_24xx_pwm_disable(chip, pwm); 115 + if (ret) 116 + return ret; 114 117 } else { 115 118 /* Connect the PWM to the pin */ 116 119 pin = pwm->hwpwm; ··· 270 269 271 270 if (!state->enabled) { 272 271 if (pwm->state.enabled) 273 - stmpe_24xx_pwm_disable(chip, pwm); 272 + return stmpe_24xx_pwm_disable(chip, pwm); 274 273 275 274 return 0; 276 275 }
-1
drivers/pwm/pwm-sun4i.c
··· 17 17 #include <linux/jiffies.h> 18 18 #include <linux/module.h> 19 19 #include <linux/of.h> 20 - #include <linux/of_device.h> 21 20 #include <linux/platform_device.h> 22 21 #include <linux/pwm.h> 23 22 #include <linux/reset.h>
+1
drivers/pwm/pwm-sunplus.c
··· 23 23 #include <linux/clk.h> 24 24 #include <linux/io.h> 25 25 #include <linux/kernel.h> 26 + #include <linux/mod_devicetable.h> 26 27 #include <linux/module.h> 27 28 #include <linux/platform_device.h> 28 29 #include <linux/pwm.h>
-1
drivers/pwm/pwm-tegra.c
··· 41 41 #include <linux/io.h> 42 42 #include <linux/module.h> 43 43 #include <linux/of.h> 44 - #include <linux/of_device.h> 45 44 #include <linux/pm_opp.h> 46 45 #include <linux/pwm.h> 47 46 #include <linux/platform_device.h>
+1 -1
drivers/pwm/pwm-tiecap.c
··· 12 12 #include <linux/clk.h> 13 13 #include <linux/pm_runtime.h> 14 14 #include <linux/pwm.h> 15 - #include <linux/of_device.h> 15 + #include <linux/of.h> 16 16 17 17 /* ECAP registers and bits definitions */ 18 18 #define CAP1 0x08
+1 -1
drivers/pwm/pwm-tiehrpwm.c
··· 12 12 #include <linux/err.h> 13 13 #include <linux/clk.h> 14 14 #include <linux/pm_runtime.h> 15 - #include <linux/of_device.h> 15 + #include <linux/of.h> 16 16 17 17 /* EHRPWM registers and bits definitions */ 18 18
+1 -1
drivers/pwm/pwm-visconti.c
··· 21 21 #include <linux/err.h> 22 22 #include <linux/io.h> 23 23 #include <linux/module.h> 24 - #include <linux/of_device.h> 24 + #include <linux/of.h> 25 25 #include <linux/platform_device.h> 26 26 #include <linux/pwm.h> 27 27
+1 -4
drivers/pwm/pwm-vt8500.c
··· 6 6 * Copyright (C) 2010 Alexey Charkov <alchark@gmail.com> 7 7 */ 8 8 9 + #include <linux/mod_devicetable.h> 9 10 #include <linux/module.h> 10 11 #include <linux/kernel.h> 11 12 #include <linux/platform_device.h> ··· 18 17 #include <linux/clk.h> 19 18 20 19 #include <asm/div64.h> 21 - 22 - #include <linux/of.h> 23 - #include <linux/of_device.h> 24 - #include <linux/of_address.h> 25 20 26 21 /* 27 22 * SoC architecture allocates register space for 4 PWMs but only
+6 -6
drivers/staging/greybus/pwm.c
··· 266 266 { 267 267 struct gb_connection *connection; 268 268 struct gb_pwm_chip *pwmc; 269 - struct pwm_chip *pwm; 269 + struct pwm_chip *chip; 270 270 int ret; 271 271 272 272 pwmc = kzalloc(sizeof(*pwmc), GFP_KERNEL); ··· 294 294 if (ret) 295 295 goto exit_connection_disable; 296 296 297 - pwm = &pwmc->chip; 297 + chip = &pwmc->chip; 298 298 299 - pwm->dev = &gbphy_dev->dev; 300 - pwm->ops = &gb_pwm_ops; 301 - pwm->npwm = pwmc->pwm_max + 1; 299 + chip->dev = &gbphy_dev->dev; 300 + chip->ops = &gb_pwm_ops; 301 + chip->npwm = pwmc->pwm_max + 1; 302 302 303 - ret = pwmchip_add(pwm); 303 + ret = pwmchip_add(chip); 304 304 if (ret) { 305 305 dev_err(&gbphy_dev->dev, 306 306 "failed to register PWM: %d\n", ret);
+3 -3
include/linux/pwm.h
··· 298 298 int base; 299 299 unsigned int npwm; 300 300 301 - struct pwm_device * (*of_xlate)(struct pwm_chip *pc, 301 + struct pwm_device * (*of_xlate)(struct pwm_chip *chip, 302 302 const struct of_phandle_args *args); 303 303 unsigned int of_pwm_n_cells; 304 304 ··· 395 395 unsigned int index, 396 396 const char *label); 397 397 398 - struct pwm_device *of_pwm_xlate_with_flags(struct pwm_chip *pc, 398 + struct pwm_device *of_pwm_xlate_with_flags(struct pwm_chip *chip, 399 399 const struct of_phandle_args *args); 400 - struct pwm_device *of_pwm_single_xlate(struct pwm_chip *pc, 400 + struct pwm_device *of_pwm_single_xlate(struct pwm_chip *chip, 401 401 const struct of_phandle_args *args); 402 402 403 403 struct pwm_device *pwm_get(struct device *dev, const char *con_id);