summaryrefslogtreecommitdiff
path: root/drivers/pwm/pwm-tegra.c
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2024-02-14 12:32:58 +0300
committerUwe Kleine-König <u.kleine-koenig@pengutronix.de>2024-02-22 16:39:26 +0300
commit7550ebf04c05de66e504c17dc7c6ac5cf8802d8d (patch)
treeed6cb75c14e5d6bafb6c75b3e8ecb20dfb6652d8 /drivers/pwm/pwm-tegra.c
parentaa37f83f7bfadc7e9dac8b32d87f93d185cd5555 (diff)
downloadlinux-7550ebf04c05de66e504c17dc7c6ac5cf8802d8d.tar.xz
pwm: tegra: Make use of devm_pwmchip_alloc() function
This prepares the pwm-tegra driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Link: https://lore.kernel.org/r/8719be3d57b0b5cf575b312e5ff41fe0717e3a43.1707900770.git.u.kleine-koenig@pengutronix.de Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Diffstat (limited to 'drivers/pwm/pwm-tegra.c')
-rw-r--r--drivers/pwm/pwm-tegra.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/drivers/pwm/pwm-tegra.c b/drivers/pwm/pwm-tegra.c
index f61c24376523..a3d69976148f 100644
--- a/drivers/pwm/pwm-tegra.c
+++ b/drivers/pwm/pwm-tegra.c
@@ -65,8 +65,6 @@ struct tegra_pwm_soc {
};
struct tegra_pwm_chip {
- struct pwm_chip chip;
-
struct clk *clk;
struct reset_control*rst;
@@ -80,7 +78,7 @@ struct tegra_pwm_chip {
static inline struct tegra_pwm_chip *to_tegra_pwm_chip(struct pwm_chip *chip)
{
- return container_of(chip, struct tegra_pwm_chip, chip);
+ return pwmchip_get_drvdata(chip);
}
static inline u32 pwm_readl(struct tegra_pwm_chip *pc, unsigned int offset)
@@ -273,14 +271,17 @@ static int tegra_pwm_probe(struct platform_device *pdev)
{
struct pwm_chip *chip;
struct tegra_pwm_chip *pc;
+ const struct tegra_pwm_soc *soc;
int ret;
- pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL);
- if (!pc)
- return -ENOMEM;
- chip = &pc->chip;
+ soc = of_device_get_match_data(&pdev->dev);
+
+ chip = devm_pwmchip_alloc(&pdev->dev, soc->num_channels, sizeof(*pc));
+ if (IS_ERR(chip))
+ return PTR_ERR(chip);
+ pc = to_tegra_pwm_chip(chip);
- pc->soc = of_device_get_match_data(&pdev->dev);
+ pc->soc = soc;
pc->regs = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(pc->regs))
@@ -328,9 +329,7 @@ static int tegra_pwm_probe(struct platform_device *pdev)
reset_control_deassert(pc->rst);
- chip->dev = &pdev->dev;
chip->ops = &tegra_pwm_ops;
- chip->npwm = pc->soc->num_channels;
ret = pwmchip_add(chip);
if (ret < 0) {