Skip to content

Commit f3bfe64

Browse files
committed
Merge tag 'pwm/for-6.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm
Pull pwm updates from Thierry Reding: "This contains a few fixes and a bunch of cleanups, a lot of which is in preparation for Uwe's character device support that may be ready in time for the next merge window" * tag 'pwm/for-6.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm: (37 commits) pwm: samsung: Document new member .channel in struct samsung_pwm_chip pwm: bcm2835: Add support for suspend/resume pwm: brcmstb: Checked clk_prepare_enable() return value pwm: brcmstb: Utilize appropriate clock APIs in suspend/resume pwm: pxa: Explicitly include correct DT includes pwm: cros-ec: Simplify using devm_pwmchip_add() and dev_err_probe() pwm: samsung: Consistently use the same name for driver data pwm: vt8500: Simplify using devm functions pwm: sprd: Simplify using devm_pwmchip_add() and dev_err_probe() pwm: sprd: Provide a helper to cast a chip to driver data pwm: spear: Simplify using devm functions pwm: mtk-disp: Simplify using devm_pwmchip_add() pwm: imx-tpm: Simplify using devm functions pwm: brcmstb: Simplify using devm functions pwm: bcm2835: Simplify using devm functions pwm: bcm-iproc: Simplify using devm functions pwm: Adapt sysfs API documentation to reality pwm: dwc: add PWM bit unset in get_state call pwm: dwc: make timer clock configurable pwm: dwc: split pci out of core driver ...
2 parents 4bbdb72 + 4059206 commit f3bfe64

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+536
-775
lines changed

Documentation/devicetree/bindings/pwm/mxs-pwm.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,19 @@ allOf:
1515

1616
properties:
1717
compatible:
18-
enum:
19-
- fsl,imx23-pwm
18+
oneOf:
19+
- const: fsl,imx23-pwm
20+
- items:
21+
- enum:
22+
- fsl,imx28-pwm
23+
- const: fsl,imx23-pwm
2024

2125
reg:
2226
maxItems: 1
2327

28+
clocks:
29+
maxItems: 1
30+
2431
"#pwm-cells":
2532
const: 3
2633

@@ -31,6 +38,7 @@ properties:
3138
required:
3239
- compatible
3340
- reg
41+
- clocks
3442
- fsl,pwm-number
3543

3644
additionalProperties: false
@@ -40,6 +48,7 @@ examples:
4048
pwm@80064000 {
4149
compatible = "fsl,imx23-pwm";
4250
reg = <0x80064000 0x2000>;
51+
clocks = <&clks 30>;
4352
#pwm-cells = <3>;
4453
fsl,pwm-number = <8>;
4554
};

drivers/gpio/gpio-mvebu.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,6 @@ static const struct pwm_ops mvebu_pwm_ops = {
757757
.free = mvebu_pwm_free,
758758
.get_state = mvebu_pwm_get_state,
759759
.apply = mvebu_pwm_apply,
760-
.owner = THIS_MODULE,
761760
};
762761

763762
static void __maybe_unused mvebu_pwm_suspend(struct mvebu_gpio_chip *mvchip)

drivers/gpu/drm/bridge/ti-sn65dsi86.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1580,7 +1580,6 @@ static const struct pwm_ops ti_sn_pwm_ops = {
15801580
.free = ti_sn_pwm_free,
15811581
.apply = ti_sn_pwm_apply,
15821582
.get_state = ti_sn_pwm_get_state,
1583-
.owner = THIS_MODULE,
15841583
};
15851584

15861585
static int ti_sn_pwm_probe(struct auxiliary_device *adev,

drivers/leds/rgb/leds-qcom-lpg.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,6 @@ static const struct pwm_ops lpg_pwm_ops = {
10851085
.request = lpg_pwm_request,
10861086
.apply = lpg_pwm_apply,
10871087
.get_state = lpg_pwm_get_state,
1088-
.owner = THIS_MODULE,
10891088
};
10901089

10911090
static int lpg_add_pwm(struct lpg *lpg)

drivers/pwm/Kconfig

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ config PWM_CLPS711X
173173
will be called pwm-clps711x.
174174

175175
config PWM_CRC
176-
bool "Intel Crystalcove (CRC) PWM support"
177-
depends on X86 && INTEL_SOC_PMIC
176+
tristate "Intel Crystalcove (CRC) PWM support"
177+
depends on INTEL_SOC_PMIC
178178
help
179179
Generic PWM framework driver for Crystalcove (CRC) PMIC based PWM
180180
control.
@@ -186,9 +186,19 @@ config PWM_CROS_EC
186186
PWM driver for exposing a PWM attached to the ChromeOS Embedded
187187
Controller.
188188

189+
config PWM_DWC_CORE
190+
tristate
191+
depends on HAS_IOMEM
192+
help
193+
PWM driver for Synopsys DWC PWM Controller.
194+
195+
To compile this driver as a module, build the dependecies as
196+
modules, this will be called pwm-dwc-core.
197+
189198
config PWM_DWC
190-
tristate "DesignWare PWM Controller"
191-
depends on PCI
199+
tristate "DesignWare PWM Controller (PCI bus)"
200+
depends on HAS_IOMEM && PCI
201+
select PWM_DWC_CORE
192202
help
193203
PWM driver for Synopsys DWC PWM Controller attached to a PCI bus.
194204

@@ -407,7 +417,7 @@ config PWM_MEDIATEK
407417

408418
config PWM_MICROCHIP_CORE
409419
tristate "Microchip corePWM PWM support"
410-
depends on SOC_MICROCHIP_POLARFIRE || COMPILE_TEST
420+
depends on ARCH_MICROCHIP_POLARFIRE || COMPILE_TEST
411421
depends on HAS_IOMEM && OF
412422
help
413423
PWM driver for Microchip FPGA soft IP core.

drivers/pwm/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ obj-$(CONFIG_PWM_CLK) += pwm-clk.o
1515
obj-$(CONFIG_PWM_CLPS711X) += pwm-clps711x.o
1616
obj-$(CONFIG_PWM_CRC) += pwm-crc.o
1717
obj-$(CONFIG_PWM_CROS_EC) += pwm-cros-ec.o
18+
obj-$(CONFIG_PWM_DWC_CORE) += pwm-dwc-core.o
1819
obj-$(CONFIG_PWM_DWC) += pwm-dwc.o
1920
obj-$(CONFIG_PWM_EP93XX) += pwm-ep93xx.o
2021
obj-$(CONFIG_PWM_FSL_FTM) += pwm-fsl-ftm.o

drivers/pwm/core.c

Lines changed: 14 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@ static int pwm_device_request(struct pwm_device *pwm, const char *label)
8989
if (test_bit(PWMF_REQUESTED, &pwm->flags))
9090
return -EBUSY;
9191

92-
if (!try_module_get(pwm->chip->ops->owner))
92+
if (!try_module_get(pwm->chip->owner))
9393
return -ENODEV;
9494

9595
if (pwm->chip->ops->request) {
9696
err = pwm->chip->ops->request(pwm->chip, pwm);
9797
if (err) {
98-
module_put(pwm->chip->ops->owner);
98+
module_put(pwm->chip->owner);
9999
return err;
100100
}
101101
}
@@ -208,36 +208,6 @@ static void of_pwmchip_remove(struct pwm_chip *chip)
208208
of_node_put(chip->dev->of_node);
209209
}
210210

211-
/**
212-
* pwm_set_chip_data() - set private chip data for a PWM
213-
* @pwm: PWM device
214-
* @data: pointer to chip-specific data
215-
*
216-
* Returns: 0 on success or a negative error code on failure.
217-
*/
218-
int pwm_set_chip_data(struct pwm_device *pwm, void *data)
219-
{
220-
if (!pwm)
221-
return -EINVAL;
222-
223-
pwm->chip_data = data;
224-
225-
return 0;
226-
}
227-
EXPORT_SYMBOL_GPL(pwm_set_chip_data);
228-
229-
/**
230-
* pwm_get_chip_data() - get private chip data for a PWM
231-
* @pwm: PWM device
232-
*
233-
* Returns: A pointer to the chip-private data for the PWM device.
234-
*/
235-
void *pwm_get_chip_data(struct pwm_device *pwm)
236-
{
237-
return pwm ? pwm->chip_data : NULL;
238-
}
239-
EXPORT_SYMBOL_GPL(pwm_get_chip_data);
240-
241211
static bool pwm_ops_check(const struct pwm_chip *chip)
242212
{
243213
const struct pwm_ops *ops = chip->ops;
@@ -253,14 +223,16 @@ static bool pwm_ops_check(const struct pwm_chip *chip)
253223
}
254224

255225
/**
256-
* pwmchip_add() - register a new PWM chip
226+
* __pwmchip_add() - register a new PWM chip
257227
* @chip: the PWM chip to add
228+
* @owner: reference to the module providing the chip.
258229
*
259-
* Register a new PWM chip.
230+
* Register a new PWM chip. @owner is supposed to be THIS_MODULE, use the
231+
* pwmchip_add wrapper to do this right.
260232
*
261233
* Returns: 0 on success or a negative error code on failure.
262234
*/
263-
int pwmchip_add(struct pwm_chip *chip)
235+
int __pwmchip_add(struct pwm_chip *chip, struct module *owner)
264236
{
265237
struct pwm_device *pwm;
266238
unsigned int i;
@@ -272,6 +244,8 @@ int pwmchip_add(struct pwm_chip *chip)
272244
if (!pwm_ops_check(chip))
273245
return -EINVAL;
274246

247+
chip->owner = owner;
248+
275249
chip->pwms = kcalloc(chip->npwm, sizeof(*pwm), GFP_KERNEL);
276250
if (!chip->pwms)
277251
return -ENOMEM;
@@ -306,7 +280,7 @@ int pwmchip_add(struct pwm_chip *chip)
306280

307281
return 0;
308282
}
309-
EXPORT_SYMBOL_GPL(pwmchip_add);
283+
EXPORT_SYMBOL_GPL(__pwmchip_add);
310284

311285
/**
312286
* pwmchip_remove() - remove a PWM chip
@@ -338,17 +312,17 @@ static void devm_pwmchip_remove(void *data)
338312
pwmchip_remove(chip);
339313
}
340314

341-
int devm_pwmchip_add(struct device *dev, struct pwm_chip *chip)
315+
int __devm_pwmchip_add(struct device *dev, struct pwm_chip *chip, struct module *owner)
342316
{
343317
int ret;
344318

345-
ret = pwmchip_add(chip);
319+
ret = __pwmchip_add(chip, owner);
346320
if (ret)
347321
return ret;
348322

349323
return devm_add_action_or_reset(dev, devm_pwmchip_remove, chip);
350324
}
351-
EXPORT_SYMBOL_GPL(devm_pwmchip_add);
325+
EXPORT_SYMBOL_GPL(__devm_pwmchip_add);
352326

353327
/**
354328
* pwm_request_from_chip() - request a PWM device relative to a PWM chip
@@ -976,10 +950,9 @@ void pwm_put(struct pwm_device *pwm)
976950
if (pwm->chip->ops->free)
977951
pwm->chip->ops->free(pwm->chip, pwm);
978952

979-
pwm_set_chip_data(pwm, NULL);
980953
pwm->label = NULL;
981954

982-
module_put(pwm->chip->ops->owner);
955+
module_put(pwm->chip->owner);
983956
out:
984957
mutex_unlock(&pwm_lock);
985958
}

drivers/pwm/pwm-ab8500.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ static int ab8500_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
181181
static const struct pwm_ops ab8500_pwm_ops = {
182182
.apply = ab8500_pwm_apply,
183183
.get_state = ab8500_pwm_get_state,
184-
.owner = THIS_MODULE,
185184
};
186185

187186
static int ab8500_pwm_probe(struct platform_device *pdev)

drivers/pwm/pwm-apple.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ static int apple_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
9999
static const struct pwm_ops apple_pwm_ops = {
100100
.apply = apple_pwm_apply,
101101
.get_state = apple_pwm_get_state,
102-
.owner = THIS_MODULE,
103102
};
104103

105104
static int apple_pwm_probe(struct platform_device *pdev)

drivers/pwm/pwm-atmel-hlcdc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ static int atmel_hlcdc_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
170170

171171
static const struct pwm_ops atmel_hlcdc_pwm_ops = {
172172
.apply = atmel_hlcdc_pwm_apply,
173-
.owner = THIS_MODULE,
174173
};
175174

176175
static const struct atmel_hlcdc_pwm_errata atmel_hlcdc_pwm_at91sam9x5_errata = {

drivers/pwm/pwm-atmel-tcb.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ static const struct pwm_ops atmel_tcb_pwm_ops = {
364364
.request = atmel_tcb_pwm_request,
365365
.free = atmel_tcb_pwm_free,
366366
.apply = atmel_tcb_pwm_apply,
367-
.owner = THIS_MODULE,
368367
};
369368

370369
static struct atmel_tcb_config tcb_rm9200_config = {

drivers/pwm/pwm-atmel.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,6 @@ static int atmel_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
402402
static const struct pwm_ops atmel_pwm_ops = {
403403
.apply = atmel_pwm_apply,
404404
.get_state = atmel_pwm_get_state,
405-
.owner = THIS_MODULE,
406405
};
407406

408407
static const struct atmel_pwm_data atmel_sam9rl_pwm_data = {
@@ -547,7 +546,7 @@ static int atmel_pwm_probe(struct platform_device *pdev)
547546
static struct platform_driver atmel_pwm_driver = {
548547
.driver = {
549548
.name = "atmel-pwm",
550-
.of_match_table = of_match_ptr(atmel_pwm_dt_ids),
549+
.of_match_table = atmel_pwm_dt_ids,
551550
},
552551
.probe = atmel_pwm_probe,
553552
};

drivers/pwm/pwm-bcm-iproc.c

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ static int iproc_pwmc_apply(struct pwm_chip *chip, struct pwm_device *pwm,
183183
static const struct pwm_ops iproc_pwm_ops = {
184184
.apply = iproc_pwmc_apply,
185185
.get_state = iproc_pwmc_get_state,
186-
.owner = THIS_MODULE,
187186
};
188187

189188
static int iproc_pwmc_probe(struct platform_device *pdev)
@@ -207,18 +206,10 @@ static int iproc_pwmc_probe(struct platform_device *pdev)
207206
if (IS_ERR(ip->base))
208207
return PTR_ERR(ip->base);
209208

210-
ip->clk = devm_clk_get(&pdev->dev, NULL);
211-
if (IS_ERR(ip->clk)) {
212-
dev_err(&pdev->dev, "failed to get clock: %ld\n",
213-
PTR_ERR(ip->clk));
214-
return PTR_ERR(ip->clk);
215-
}
216-
217-
ret = clk_prepare_enable(ip->clk);
218-
if (ret < 0) {
219-
dev_err(&pdev->dev, "failed to enable clock: %d\n", ret);
220-
return ret;
221-
}
209+
ip->clk = devm_clk_get_enabled(&pdev->dev, NULL);
210+
if (IS_ERR(ip->clk))
211+
return dev_err_probe(&pdev->dev, PTR_ERR(ip->clk),
212+
"failed to get clock\n");
222213

223214
/* Set full drive and normal polarity for all channels */
224215
value = readl(ip->base + IPROC_PWM_CTRL_OFFSET);
@@ -230,22 +221,12 @@ static int iproc_pwmc_probe(struct platform_device *pdev)
230221

231222
writel(value, ip->base + IPROC_PWM_CTRL_OFFSET);
232223

233-
ret = pwmchip_add(&ip->chip);
234-
if (ret < 0) {
235-
dev_err(&pdev->dev, "failed to add PWM chip: %d\n", ret);
236-
clk_disable_unprepare(ip->clk);
237-
}
238-
239-
return ret;
240-
}
241-
242-
static void iproc_pwmc_remove(struct platform_device *pdev)
243-
{
244-
struct iproc_pwmc *ip = platform_get_drvdata(pdev);
224+
ret = devm_pwmchip_add(&pdev->dev, &ip->chip);
225+
if (ret < 0)
226+
return dev_err_probe(&pdev->dev, ret,
227+
"failed to add PWM chip\n");
245228

246-
pwmchip_remove(&ip->chip);
247-
248-
clk_disable_unprepare(ip->clk);
229+
return 0;
249230
}
250231

251232
static const struct of_device_id bcm_iproc_pwmc_dt[] = {
@@ -260,7 +241,6 @@ static struct platform_driver iproc_pwmc_driver = {
260241
.of_match_table = bcm_iproc_pwmc_dt,
261242
},
262243
.probe = iproc_pwmc_probe,
263-
.remove_new = iproc_pwmc_remove,
264244
};
265245
module_platform_driver(iproc_pwmc_driver);
266246

drivers/pwm/pwm-bcm-kona.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ static int kona_pwmc_apply(struct pwm_chip *chip, struct pwm_device *pwm,
269269

270270
static const struct pwm_ops kona_pwm_ops = {
271271
.apply = kona_pwmc_apply,
272-
.owner = THIS_MODULE,
273272
};
274273

275274
static int kona_pwmc_probe(struct platform_device *pdev)

0 commit comments

Comments
 (0)