Skip to content

Commit

Permalink
soc: amlogic: canvas: Fix meson_canvas_get when probe failed
Browse files Browse the repository at this point in the history
When probe fails, a platforn_device is still associated to the node,
but dev_get_drvdata() returns NULL.

Handle this case by returning a consistent error.

Fixes: d498398 ("soc: amlogic: add meson-canvas driver")
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Reviewed-by: Maxime Jourdan <mjourdan@baylibre.com>
[khilman: fixed minor typo in comment ]
Signed-off-by: Kevin Hilman <khilman@baylibre.com>
  • Loading branch information
Neil Armstrong authored and Kevin Hilman committed Feb 8, 2019
1 parent 99e5a8d commit 382f8be
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion drivers/soc/amlogic/meson-canvas.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ struct meson_canvas *meson_canvas_get(struct device *dev)
{
struct device_node *canvas_node;
struct platform_device *canvas_pdev;
struct meson_canvas *canvas;

canvas_node = of_parse_phandle(dev->of_node, "amlogic,canvas", 0);
if (!canvas_node)
Expand All @@ -63,7 +64,17 @@ struct meson_canvas *meson_canvas_get(struct device *dev)
}

of_node_put(canvas_node);
return dev_get_drvdata(&canvas_pdev->dev);

/*
* If priv is NULL, it's probably because the canvas hasn't
* properly initialized. Bail out with -EINVAL because, in the
* current state, this driver probe cannot return -EPROBE_DEFER
*/
canvas = dev_get_drvdata(&canvas_pdev->dev);
if (!canvas)
return ERR_PTR(-EINVAL);

return canvas;
}
EXPORT_SYMBOL_GPL(meson_canvas_get);

Expand Down

0 comments on commit 382f8be

Please sign in to comment.