mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-10 20:02:10 -04:00
pwm: img: Prepare removing pwm_chip from driver data
This prepares the driver for further changes that will drop struct pwm_chip chip from struct img_pwm_chip. Use the pwm_chip as driver data instead of the img_pwm_chip to get access to the pwm_chip in img_pwm_remove() and the PM callbacks without using imgchip->chip. Link: https://lore.kernel.org/r/2ddf76d127f69eca7d9faa6475091e432e890ac9.1707900770.git.u.kleine-koenig@pengutronix.de Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
This commit is contained in:
@@ -224,7 +224,8 @@ MODULE_DEVICE_TABLE(of, img_pwm_of_match);
|
||||
|
||||
static int img_pwm_runtime_suspend(struct device *dev)
|
||||
{
|
||||
struct img_pwm_chip *imgchip = dev_get_drvdata(dev);
|
||||
struct pwm_chip *chip = dev_get_drvdata(dev);
|
||||
struct img_pwm_chip *imgchip = to_img_pwm_chip(chip);
|
||||
|
||||
clk_disable_unprepare(imgchip->pwm_clk);
|
||||
clk_disable_unprepare(imgchip->sys_clk);
|
||||
@@ -234,7 +235,8 @@ static int img_pwm_runtime_suspend(struct device *dev)
|
||||
|
||||
static int img_pwm_runtime_resume(struct device *dev)
|
||||
{
|
||||
struct img_pwm_chip *imgchip = dev_get_drvdata(dev);
|
||||
struct pwm_chip *chip = dev_get_drvdata(dev);
|
||||
struct img_pwm_chip *imgchip = to_img_pwm_chip(chip);
|
||||
int ret;
|
||||
|
||||
ret = clk_prepare_enable(imgchip->sys_clk);
|
||||
@@ -258,11 +260,13 @@ static int img_pwm_probe(struct platform_device *pdev)
|
||||
int ret;
|
||||
u64 val;
|
||||
unsigned long clk_rate;
|
||||
struct pwm_chip *chip;
|
||||
struct img_pwm_chip *imgchip;
|
||||
|
||||
imgchip = devm_kzalloc(&pdev->dev, sizeof(*imgchip), GFP_KERNEL);
|
||||
if (!imgchip)
|
||||
return -ENOMEM;
|
||||
chip = &imgchip->chip;
|
||||
|
||||
imgchip->base = devm_platform_ioremap_resource(pdev, 0);
|
||||
if (IS_ERR(imgchip->base))
|
||||
@@ -287,7 +291,7 @@ static int img_pwm_probe(struct platform_device *pdev)
|
||||
return PTR_ERR(imgchip->pwm_clk);
|
||||
}
|
||||
|
||||
platform_set_drvdata(pdev, imgchip);
|
||||
platform_set_drvdata(pdev, chip);
|
||||
|
||||
pm_runtime_set_autosuspend_delay(&pdev->dev, IMG_PWM_PM_TIMEOUT);
|
||||
pm_runtime_use_autosuspend(&pdev->dev);
|
||||
@@ -314,11 +318,11 @@ static int img_pwm_probe(struct platform_device *pdev)
|
||||
do_div(val, clk_rate);
|
||||
imgchip->min_period_ns = val;
|
||||
|
||||
imgchip->chip.dev = &pdev->dev;
|
||||
imgchip->chip.ops = &img_pwm_ops;
|
||||
imgchip->chip.npwm = IMG_PWM_NPWM;
|
||||
chip->dev = &pdev->dev;
|
||||
chip->ops = &img_pwm_ops;
|
||||
chip->npwm = IMG_PWM_NPWM;
|
||||
|
||||
ret = pwmchip_add(&imgchip->chip);
|
||||
ret = pwmchip_add(chip);
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev, "pwmchip_add failed: %d\n", ret);
|
||||
goto err_suspend;
|
||||
@@ -337,19 +341,20 @@ static int img_pwm_probe(struct platform_device *pdev)
|
||||
|
||||
static void img_pwm_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct img_pwm_chip *imgchip = platform_get_drvdata(pdev);
|
||||
struct pwm_chip *chip = platform_get_drvdata(pdev);
|
||||
|
||||
pm_runtime_disable(&pdev->dev);
|
||||
if (!pm_runtime_status_suspended(&pdev->dev))
|
||||
img_pwm_runtime_suspend(&pdev->dev);
|
||||
|
||||
pwmchip_remove(&imgchip->chip);
|
||||
pwmchip_remove(chip);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
static int img_pwm_suspend(struct device *dev)
|
||||
{
|
||||
struct img_pwm_chip *imgchip = dev_get_drvdata(dev);
|
||||
struct pwm_chip *chip = dev_get_drvdata(dev);
|
||||
struct img_pwm_chip *imgchip = to_img_pwm_chip(chip);
|
||||
int i, ret;
|
||||
|
||||
if (pm_runtime_status_suspended(dev)) {
|
||||
@@ -358,7 +363,7 @@ static int img_pwm_suspend(struct device *dev)
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (i = 0; i < imgchip->chip.npwm; i++)
|
||||
for (i = 0; i < chip->npwm; i++)
|
||||
imgchip->suspend_ch_cfg[i] = img_pwm_readl(imgchip,
|
||||
PWM_CH_CFG(i));
|
||||
|
||||
@@ -371,7 +376,8 @@ static int img_pwm_suspend(struct device *dev)
|
||||
|
||||
static int img_pwm_resume(struct device *dev)
|
||||
{
|
||||
struct img_pwm_chip *imgchip = dev_get_drvdata(dev);
|
||||
struct pwm_chip *chip = dev_get_drvdata(dev);
|
||||
struct img_pwm_chip *imgchip = to_img_pwm_chip(chip);
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
@@ -379,13 +385,13 @@ static int img_pwm_resume(struct device *dev)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
for (i = 0; i < imgchip->chip.npwm; i++)
|
||||
for (i = 0; i < chip->npwm; i++)
|
||||
img_pwm_writel(imgchip, PWM_CH_CFG(i),
|
||||
imgchip->suspend_ch_cfg[i]);
|
||||
|
||||
img_pwm_writel(imgchip, PWM_CTRL_CFG, imgchip->suspend_ctrl_cfg);
|
||||
|
||||
for (i = 0; i < imgchip->chip.npwm; i++)
|
||||
for (i = 0; i < chip->npwm; i++)
|
||||
if (imgchip->suspend_ctrl_cfg & BIT(i))
|
||||
regmap_clear_bits(imgchip->periph_regs,
|
||||
PERIP_PWM_PDM_CONTROL,
|
||||
|
||||
Reference in New Issue
Block a user