From 29bad58ada635337342eca46bf71f3b4f6dac62c Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Wed, 11 Mar 2009 12:23:40 -0300 Subject: Fewer HDQ errors on 3D7K If no battery is connected, we periodically get a burst of HDQ error messages (at least on 3D7K), interrupting whatever we're doing on the console. This patch reduces this to only one message per sequence of errors, and one more message if communication with HDQ is successful later. Signed-off-by: Werner Almesberger --- drivers/power/hdq.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'drivers/power') diff --git a/drivers/power/hdq.c b/drivers/power/hdq.c index 755a5efe5ec..d64f8f69e0c 100644 --- a/drivers/power/hdq.c +++ b/drivers/power/hdq.c @@ -33,7 +33,7 @@ enum hdq_bitbang_states { HDQB_WAIT_TX, }; -struct hdq_priv { +static struct hdq_priv { u8 hdq_probed; /* nonzero after HDQ driver probed */ struct mutex hdq_lock; /* if you want to use hdq, you have to take lock */ unsigned long hdq_gpio_pin; /* GTA02 = GPD14 which pin to meddle with */ @@ -49,11 +49,26 @@ struct hdq_priv { u8 hdq_shifter; u8 hdq_tx_data_done; enum hdq_bitbang_states hdq_state; + int reported_error; struct hdq_platform_data *pdata; } hdq_priv; +static void hdq_bad(void) +{ + if (!hdq_priv.reported_error) + printk(KERN_ERR "HDQ error: %d\n", hdq_priv.hdq_error); + hdq_priv.reported_error = 1; +} + +static void hdq_good(void) +{ + if (hdq_priv.reported_error) + printk(KERN_INFO "HDQ responds again\n"); + hdq_priv.reported_error = 0; +} + int hdq_fiq_handler(void) { if (!hdq_priv.hdq_probed) @@ -267,9 +282,10 @@ int hdq_read(int address) continue; if (hdq_priv.hdq_error) { - printk(KERN_ERR "HDQ error: %d\n", hdq_priv.hdq_error); + hdq_bad(); goto done; /* didn't see a response in good time */ } + hdq_good(); ret = hdq_priv.hdq_rx_data; goto done; @@ -308,9 +324,10 @@ int hdq_write(int address, u8 data) continue; /* something bad with FIQ */ if (hdq_priv.hdq_error) { - printk(KERN_ERR "HDQ error: %d\n", hdq_priv.hdq_error); + hdq_bad(); goto done; /* didn't see a response in good time */ } + hdq_good(); ret = 0; goto done; -- cgit v1.2.3