Skip to content

Commit 2f102a5

Browse files
lategoodbyegregkh
authored andcommitted
serial: 8250_bcm2835aux: Fix clock imbalance in PM resume
During review Ulf Hansson discovered a clock imbalance in the recently introduced PM resume code. The driver should enable the clock only in case it has been disabled in suspend before. In order to make the conditions easier to read, refactor this into a separate function. Reported-by: Ulf Hansson <[email protected]> Closes: https://lore.kernel.org/linux-arm-kernel/CAPDyKFoJh3j8xSeXZ9o031YZLTCDYVA+dgvURuwozjDpU_aauA@mail.gmail.com/ Fixes: 0e1d878 ("serial: 8250_bcm2835aux: add PM suspend/resume support") Signed-off-by: Stefan Wahren <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent d2e8590 commit 2f102a5

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

drivers/tty/serial/8250/8250_bcm2835aux.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,17 +214,27 @@ static const struct acpi_device_id bcm2835aux_serial_acpi_match[] = {
214214
};
215215
MODULE_DEVICE_TABLE(acpi, bcm2835aux_serial_acpi_match);
216216

217-
static int bcm2835aux_suspend(struct device *dev)
217+
static bool bcm2835aux_can_disable_clock(struct device *dev)
218218
{
219219
struct bcm2835aux_data *data = dev_get_drvdata(dev);
220220
struct uart_8250_port *up = serial8250_get_port(data->line);
221221

222-
serial8250_suspend_port(data->line);
223-
224222
if (device_may_wakeup(dev))
225-
return 0;
223+
return false;
226224

227225
if (uart_console(&up->port) && !console_suspend_enabled)
226+
return false;
227+
228+
return true;
229+
}
230+
231+
static int bcm2835aux_suspend(struct device *dev)
232+
{
233+
struct bcm2835aux_data *data = dev_get_drvdata(dev);
234+
235+
serial8250_suspend_port(data->line);
236+
237+
if (!bcm2835aux_can_disable_clock(dev))
228238
return 0;
229239

230240
clk_disable_unprepare(data->clk);
@@ -236,9 +246,11 @@ static int bcm2835aux_resume(struct device *dev)
236246
struct bcm2835aux_data *data = dev_get_drvdata(dev);
237247
int ret;
238248

239-
ret = clk_prepare_enable(data->clk);
240-
if (ret)
241-
return ret;
249+
if (bcm2835aux_can_disable_clock(dev)) {
250+
ret = clk_prepare_enable(data->clk);
251+
if (ret)
252+
return ret;
253+
}
242254

243255
serial8250_resume_port(data->line);
244256

0 commit comments

Comments
 (0)