Skip to content

Commit

Permalink
drivers/tty/serial/amba-pl0{10,11}.c: use clk_prepare_enable and clk_…
Browse files Browse the repository at this point in the history
…disable_unprepare

Clk_prepare_enable and clk_disable_unprepare combine clk_prepare and
clk_enable, and clk_disable and clk_unprepare.  The9 make the code more
concise, and ensure that clk_unprepare is called when clk_enable fails.

A simplified version of the semantic patch that introduces calls to these
functions is as follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression e;
@@

- clk_prepare(e);
- clk_enable(e);
+ clk_prepare_enable(e);

@@
expression e;
@@

- clk_disable(e);
- clk_unprepare(e);
+ clk_disable_unprepare(e);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Julia Lawall authored and Greg Kroah-Hartman committed Sep 5, 2012
1 parent e372dc6 commit 1c4c439
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 22 deletions.
15 changes: 4 additions & 11 deletions drivers/tty/serial/amba-pl010.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,16 +312,12 @@ static int pl010_startup(struct uart_port *port)
struct uart_amba_port *uap = (struct uart_amba_port *)port;
int retval;

retval = clk_prepare(uap->clk);
if (retval)
goto out;

/*
* Try to enable the clock producer.
*/
retval = clk_enable(uap->clk);
retval = clk_prepare_enable(uap->clk);
if (retval)
goto clk_unprep;
goto out;

uap->port.uartclk = clk_get_rate(uap->clk);

Expand All @@ -346,9 +342,7 @@ static int pl010_startup(struct uart_port *port)
return 0;

clk_dis:
clk_disable(uap->clk);
clk_unprep:
clk_unprepare(uap->clk);
clk_disable_unprepare(uap->clk);
out:
return retval;
}
Expand All @@ -375,8 +369,7 @@ static void pl010_shutdown(struct uart_port *port)
/*
* Shut down the clock producer
*/
clk_disable(uap->clk);
clk_unprepare(uap->clk);
clk_disable_unprepare(uap->clk);
}

static void
Expand Down
15 changes: 4 additions & 11 deletions drivers/tty/serial/amba-pl011.c
Original file line number Diff line number Diff line change
Expand Up @@ -1324,16 +1324,12 @@ static int pl011_startup(struct uart_port *port)
"could not set default pins\n");
}

retval = clk_prepare(uap->clk);
if (retval)
goto out;

/*
* Try to enable the clock producer.
*/
retval = clk_enable(uap->clk);
retval = clk_prepare_enable(uap->clk);
if (retval)
goto clk_unprep;
goto out;

uap->port.uartclk = clk_get_rate(uap->clk);

Expand Down Expand Up @@ -1411,9 +1407,7 @@ static int pl011_startup(struct uart_port *port)
return 0;

clk_dis:
clk_disable(uap->clk);
clk_unprep:
clk_unprepare(uap->clk);
clk_disable_unprepare(uap->clk);
out:
return retval;
}
Expand Down Expand Up @@ -1473,8 +1467,7 @@ static void pl011_shutdown(struct uart_port *port)
/*
* Shut down the clock producer
*/
clk_disable(uap->clk);
clk_unprepare(uap->clk);
clk_disable_unprepare(uap->clk);
/* Optionally let pins go into sleep states */
if (!IS_ERR(uap->pins_sleep)) {
retval = pinctrl_select_state(uap->pinctrl, uap->pins_sleep);
Expand Down

0 comments on commit 1c4c439

Please sign in to comment.