On 01/08/2015 12:49 PM, Vladimir Zapolskiy wrote:
> Hi Ezequiel,
> 
> On 07.01.2015 19:20, Ezequiel Garcia wrote:
>> From: Naidu Tellapati <naidu.tellap...@imgtec.com>
>>
>> The Pistachio SOC from Imagination Technologies includes a Pulse Width
>> Modulation DAC which produces 1 to 4 digital bit-outputs which represent
>> digital waveforms. These PWM outputs are primarily in charge of controlling
>> backlight LED devices.
>>
>> Reviewed-by: Andrew Bresticker <abres...@chromium.org>
>> Signed-off-by: Naidu Tellapati <naidu.tellap...@imgtec.com>
>> Signed-off-by: Sai Masarapu <sai.masar...@imgtec.com>
>> Signed-off-by: Ezequiel Garcia <ezequiel.gar...@imgtec.com>
>> ---
>>  drivers/pwm/Kconfig   |  13 +++
>>  drivers/pwm/Makefile  |   1 +
>>  drivers/pwm/pwm-img.c | 250 
>> ++++++++++++++++++++++++++++++++++++++++++++++++++
>>  3 files changed, 264 insertions(+)
>>  create mode 100644 drivers/pwm/pwm-img.c
>>
> 
> [snip]
> 
>> +static int img_pwm_probe(struct platform_device *pdev)
>> +{
>> +    int ret;
>> +    struct resource *res;
>> +    struct img_pwm_chip *pwm;
>> +
>> +    pwm = devm_kzalloc(&pdev->dev, sizeof(*pwm), GFP_KERNEL);
>> +    if (!pwm)
>> +            return -ENOMEM;
>> +
>> +    pwm->dev = &pdev->dev;
>> +
>> +    res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> +    pwm->base = devm_ioremap_resource(&pdev->dev, res);
>> +    if (IS_ERR(pwm->base))
>> +            return PTR_ERR(pwm->base);
>> +
>> +    pwm->periph_regs = syscon_regmap_lookup_by_phandle(pdev->dev.of_node,
>> +                                                       "img,cr-periph");
>> +    if (IS_ERR(pwm->periph_regs))
>> +            return PTR_ERR(pwm->periph_regs);
>> +
>> +    pwm->sys_clk = devm_clk_get(&pdev->dev, "sys");
>> +    if (IS_ERR(pwm->sys_clk)) {
>> +            dev_err(&pdev->dev, "failed to get system clock\n");
>> +            return PTR_ERR(pwm->sys_clk);
>> +    }
>> +
>> +    pwm->pwm_clk = devm_clk_get(&pdev->dev, "pwm");
>> +    if (IS_ERR(pwm->pwm_clk)) {
>> +            dev_err(&pdev->dev, "failed to get pwm clock\n");
>> +            return PTR_ERR(pwm->pwm_clk);
>> +    }
>> +
>> +    ret = clk_prepare_enable(pwm->sys_clk);
>> +    if (ret < 0) {
>> +            dev_err(&pdev->dev, "could not prepare or enable sys clock\n");
>> +            return ret;
>> +    }
>> +
>> +    ret = clk_prepare_enable(pwm->pwm_clk);
>> +    if (ret < 0) {
>> +            dev_err(&pdev->dev, "could not prepare or enable pwm clock\n");
>> +            goto disable_sysclk;
>> +    }
>> +
>> +    pwm->chip.dev = &pdev->dev;
>> +    pwm->chip.ops = &img_pwm_ops;
>> +    pwm->chip.base = -1;
>> +    pwm->chip.npwm = 4;
>> +
>> +    ret = pwmchip_add(&pwm->chip);
>> +    if (ret < 0) {
>> +            dev_err(&pdev->dev, "pwmchip_add failed: %d\n", ret);
>> +            goto disable_pwmclk;
>> +    }
>> +
>> +    platform_set_drvdata(pdev, pwm);
>> +
>> +disable_pwmclk:
>> +    clk_disable_unprepare(pwm->pwm_clk);
>> +disable_sysclk:
>> +    clk_disable_unprepare(pwm->sys_clk);
>> +
>> +    return 0;
> 
> return ret on error paths?
> 
> Also should you reenable sys and pwm clocks after successful driver
> registration?
> 

Argh, that's definitely bogus. I must have missed it.

Thanks for the catch!
-- 
Ezequiel
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to