Re: [PATCH v4 3/4] pwm: jz4740: Obtain regmap from parent node

From: Paul Cercueil
Date: Mon Mar 30 2020 - 12:41:22 EST


Hi Thierry,

Le lun. 30 mars 2020 à 16:37, Thierry Reding <thierry.reding@xxxxxxxxx> a écrit :
On Mon, Mar 23, 2020 at 03:24:20PM +0100, Paul Cercueil wrote:
[...]
diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c
[...]
@@ -196,12 +208,19 @@ static const struct pwm_ops jz4740_pwm_ops = {
static int jz4740_pwm_probe(struct platform_device *pdev)
{
struct jz4740_pwm_chip *jz4740;
+ struct device *dev = &pdev->dev;

- jz4740 = devm_kzalloc(&pdev->dev, sizeof(*jz4740), GFP_KERNEL);
+ jz4740 = devm_kzalloc(dev, sizeof(*jz4740), GFP_KERNEL);
if (!jz4740)
return -ENOMEM;

- jz4740->chip.dev = &pdev->dev;
+ jz4740->map = device_node_to_regmap(dev->parent->of_node);
+ if (!jz4740->map) {

This seems wrong. According to the code, device_node_to_regmap() returns
an ERR_PTR()-encoded error code on failure, so I think this should be:

if (IS_ERR(jz4740->map)) {
...
return PTR_ERR(jz4740->map);
}

No need to resend for that, I can take care of that when applying. Let
me know if that doesn't work.

Yes, that works for me. Good catch.

Thanks,
-Paul


Thierry