Re: [PATCH v7 1/4] pwm: Imagination Technologies PWM DAC driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





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.Tellapati@xxxxxxxxxx>
>>
>> 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 <abrestic@xxxxxxxxxxxx>
>> Signed-off-by: Naidu Tellapati <Naidu.Tellapati@xxxxxxxxxx>
>> Signed-off-by: Sai Masarapu <Sai.Masarapu@xxxxxxxxxx>
>> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@xxxxxxxxxx>
>> ---
>>  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 devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux