@@ -34,8 +34,6 @@ struct vf610_gpio_port {
void __iomem *gpio_base;
const struct fsl_gpio_soc_data *sdata;
u8 irqc[VF610_GPIO_PER_PORT];
- struct clk *clk_port;
- struct clk *clk_gpio;
int irq;
};
@@ -232,11 +230,6 @@ static int vf610_gpio_irq_set_wake(struct irq_data *d, u32 enable)
return 0;
}
-static void vf610_gpio_disable_clk(void *data)
-{
- clk_disable_unprepare(data);
-}
-
static int vf610_gpio_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -245,6 +238,8 @@ static int vf610_gpio_probe(struct platform_device *pdev)
struct gpio_chip *gc;
struct gpio_irq_chip *girq;
struct irq_chip *ic;
+ struct clk *clk_port;
+ struct clk *clk_gpio;
int i;
int ret;
@@ -265,37 +260,13 @@ static int vf610_gpio_probe(struct platform_device *pdev)
if (port->irq < 0)
return port->irq;
- port->clk_port = devm_clk_get(dev, "port");
- ret = PTR_ERR_OR_ZERO(port->clk_port);
- if (!ret) {
- ret = clk_prepare_enable(port->clk_port);
- if (ret)
- return ret;
- ret = devm_add_action_or_reset(dev, vf610_gpio_disable_clk,
- port->clk_port);
- if (ret)
- return ret;
- } else if (ret == -EPROBE_DEFER) {
- /*
- * Percolate deferrals, for anything else,
- * just live without the clocking.
- */
- return ret;
- }
+ clk_port = devm_clk_get_optional_enabled(dev, "port");
+ if (IS_ERR(clk_port))
+ return PTR_ERR(clk_port);
- port->clk_gpio = devm_clk_get(dev, "gpio");
- ret = PTR_ERR_OR_ZERO(port->clk_gpio);
- if (!ret) {
- ret = clk_prepare_enable(port->clk_gpio);
- if (ret)
- return ret;
- ret = devm_add_action_or_reset(dev, vf610_gpio_disable_clk,
- port->clk_gpio);
- if (ret)
- return ret;
- } else if (ret == -EPROBE_DEFER) {
- return ret;
- }
+ clk_gpio = devm_clk_get_optional_enabled(dev, "gpio");
+ if (IS_ERR(clk_gpio))
+ return PTR_ERR(clk_gpio);
gc = &port->gc;
gc->parent = dev;
Instead of manually enabling and registering a devm cleanup handler that disables the clock, use devm_clk_get_enabled(). Also replace the handling of the optional clocks by using a variant of clk_get_optional(). The resulting code is a tad stricter than the previous code as errors from clk_get() (apart from -ENOENT) make vf610_gpio_probe() return an error. This is however an improvement. Also make the clock pointers local variables instead of a member of driver data, as they are only used in .probe(). Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- drivers/gpio/gpio-vf610.c | 45 +++++++-------------------------------- 1 file changed, 8 insertions(+), 37 deletions(-)