Commit a9a1f9c3 authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: atkbd - switch to dev_err() and friends

dev_err(), dev_warn() and dev_dbg() ensure consistency in driver messages.
Also switch to using bool where appropriate and fix some formatting issues.
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent 3032458e
...@@ -40,26 +40,26 @@ module_param_named(set, atkbd_set, int, 0); ...@@ -40,26 +40,26 @@ module_param_named(set, atkbd_set, int, 0);
MODULE_PARM_DESC(set, "Select keyboard code set (2 = default, 3 = PS/2 native)"); MODULE_PARM_DESC(set, "Select keyboard code set (2 = default, 3 = PS/2 native)");
#if defined(__i386__) || defined(__x86_64__) || defined(__hppa__) #if defined(__i386__) || defined(__x86_64__) || defined(__hppa__)
static int atkbd_reset; static bool atkbd_reset;
#else #else
static int atkbd_reset = 1; static bool atkbd_reset = true;
#endif #endif
module_param_named(reset, atkbd_reset, bool, 0); module_param_named(reset, atkbd_reset, bool, 0);
MODULE_PARM_DESC(reset, "Reset keyboard during initialization"); MODULE_PARM_DESC(reset, "Reset keyboard during initialization");
static int atkbd_softrepeat; static bool atkbd_softrepeat;
module_param_named(softrepeat, atkbd_softrepeat, bool, 0); module_param_named(softrepeat, atkbd_softrepeat, bool, 0);
MODULE_PARM_DESC(softrepeat, "Use software keyboard repeat"); MODULE_PARM_DESC(softrepeat, "Use software keyboard repeat");
static int atkbd_softraw = 1; static bool atkbd_softraw = true;
module_param_named(softraw, atkbd_softraw, bool, 0); module_param_named(softraw, atkbd_softraw, bool, 0);
MODULE_PARM_DESC(softraw, "Use software generated rawmode"); MODULE_PARM_DESC(softraw, "Use software generated rawmode");
static int atkbd_scroll; static bool atkbd_scroll;
module_param_named(scroll, atkbd_scroll, bool, 0); module_param_named(scroll, atkbd_scroll, bool, 0);
MODULE_PARM_DESC(scroll, "Enable scroll-wheel on MS Office and similar keyboards"); MODULE_PARM_DESC(scroll, "Enable scroll-wheel on MS Office and similar keyboards");
static int atkbd_extra; static bool atkbd_extra;
module_param_named(extra, atkbd_extra, bool, 0); module_param_named(extra, atkbd_extra, bool, 0);
MODULE_PARM_DESC(extra, "Enable extra LEDs and keys on IBM RapidAcces, EzKey and similar keyboards"); MODULE_PARM_DESC(extra, "Enable extra LEDs and keys on IBM RapidAcces, EzKey and similar keyboards");
...@@ -205,18 +205,18 @@ struct atkbd { ...@@ -205,18 +205,18 @@ struct atkbd {
unsigned short keycode[ATKBD_KEYMAP_SIZE]; unsigned short keycode[ATKBD_KEYMAP_SIZE];
DECLARE_BITMAP(force_release_mask, ATKBD_KEYMAP_SIZE); DECLARE_BITMAP(force_release_mask, ATKBD_KEYMAP_SIZE);
unsigned char set; unsigned char set;
unsigned char translated; bool translated;
unsigned char extra; bool extra;
unsigned char write; bool write;
unsigned char softrepeat; bool softrepeat;
unsigned char softraw; bool softraw;
unsigned char scroll; bool scroll;
unsigned char enabled; bool enabled;
/* Accessed only from interrupt */ /* Accessed only from interrupt */
unsigned char emul; unsigned char emul;
unsigned char resend; bool resend;
unsigned char release; bool release;
unsigned long xl_bit; unsigned long xl_bit;
unsigned int last; unsigned int last;
unsigned long time; unsigned long time;
...@@ -298,18 +298,18 @@ static const unsigned int xl_table[] = { ...@@ -298,18 +298,18 @@ static const unsigned int xl_table[] = {
* Checks if we should mangle the scancode to extract 'release' bit * Checks if we should mangle the scancode to extract 'release' bit
* in translated mode. * in translated mode.
*/ */
static int atkbd_need_xlate(unsigned long xl_bit, unsigned char code) static bool atkbd_need_xlate(unsigned long xl_bit, unsigned char code)
{ {
int i; int i;
if (code == ATKBD_RET_EMUL0 || code == ATKBD_RET_EMUL1) if (code == ATKBD_RET_EMUL0 || code == ATKBD_RET_EMUL1)
return 0; return false;
for (i = 0; i < ARRAY_SIZE(xl_table); i++) for (i = 0; i < ARRAY_SIZE(xl_table); i++)
if (code == xl_table[i]) if (code == xl_table[i])
return test_bit(i, &xl_bit); return test_bit(i, &xl_bit);
return 1; return true;
} }
/* /*
...@@ -365,20 +365,18 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, ...@@ -365,20 +365,18 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data,
int value; int value;
unsigned short keycode; unsigned short keycode;
#ifdef ATKBD_DEBUG dev_dbg(&serio->dev, "Received %02x flags %02x\n", data, flags);
printk(KERN_DEBUG "atkbd.c: Received %02x flags %02x\n", data, flags);
#endif
#if !defined(__i386__) && !defined (__x86_64__) #if !defined(__i386__) && !defined (__x86_64__)
if ((flags & (SERIO_FRAME | SERIO_PARITY)) && (~flags & SERIO_TIMEOUT) && !atkbd->resend && atkbd->write) { if ((flags & (SERIO_FRAME | SERIO_PARITY)) && (~flags & SERIO_TIMEOUT) && !atkbd->resend && atkbd->write) {
printk(KERN_WARNING "atkbd.c: frame/parity error: %02x\n", flags); dev_warn(&serio->dev, "Frame/parity error: %02x\n", flags);
serio_write(serio, ATKBD_CMD_RESEND); serio_write(serio, ATKBD_CMD_RESEND);
atkbd->resend = 1; atkbd->resend = true;
goto out; goto out;
} }
if (!flags && data == ATKBD_RET_ACK) if (!flags && data == ATKBD_RET_ACK)
atkbd->resend = 0; atkbd->resend = false;
#endif #endif
if (unlikely(atkbd->ps2dev.flags & PS2_FLAG_ACK)) if (unlikely(atkbd->ps2dev.flags & PS2_FLAG_ACK))
...@@ -410,7 +408,7 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, ...@@ -410,7 +408,7 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data,
switch (code) { switch (code) {
case ATKBD_RET_BAT: case ATKBD_RET_BAT:
atkbd->enabled = 0; atkbd->enabled = false;
serio_reconnect(atkbd->ps2dev.serio); serio_reconnect(atkbd->ps2dev.serio);
goto out; goto out;
case ATKBD_RET_EMUL0: case ATKBD_RET_EMUL0:
...@@ -420,20 +418,20 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, ...@@ -420,20 +418,20 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data,
atkbd->emul = 2; atkbd->emul = 2;
goto out; goto out;
case ATKBD_RET_RELEASE: case ATKBD_RET_RELEASE:
atkbd->release = 1; atkbd->release = true;
goto out; goto out;
case ATKBD_RET_ACK: case ATKBD_RET_ACK:
case ATKBD_RET_NAK: case ATKBD_RET_NAK:
if (printk_ratelimit()) if (printk_ratelimit())
printk(KERN_WARNING "atkbd.c: Spurious %s on %s. " dev_warn(&serio->dev,
"Spurious %s on %s. "
"Some program might be trying access hardware directly.\n", "Some program might be trying access hardware directly.\n",
data == ATKBD_RET_ACK ? "ACK" : "NAK", serio->phys); data == ATKBD_RET_ACK ? "ACK" : "NAK", serio->phys);
goto out; goto out;
case ATKBD_RET_ERR: case ATKBD_RET_ERR:
atkbd->err_count++; atkbd->err_count++;
#ifdef ATKBD_DEBUG dev_dbg(&serio->dev, "Keyboard on %s reports too many keys pressed.\n",
printk(KERN_DEBUG "atkbd.c: Keyboard on %s reports too many keys pressed.\n", serio->phys); serio->phys);
#endif
goto out; goto out;
} }
...@@ -451,27 +449,27 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, ...@@ -451,27 +449,27 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data,
case ATKBD_KEY_NULL: case ATKBD_KEY_NULL:
break; break;
case ATKBD_KEY_UNKNOWN: case ATKBD_KEY_UNKNOWN:
printk(KERN_WARNING dev_warn(&serio->dev,
"atkbd.c: Unknown key %s (%s set %d, code %#x on %s).\n", "Unknown key %s (%s set %d, code %#x on %s).\n",
atkbd->release ? "released" : "pressed", atkbd->release ? "released" : "pressed",
atkbd->translated ? "translated" : "raw", atkbd->translated ? "translated" : "raw",
atkbd->set, code, serio->phys); atkbd->set, code, serio->phys);
printk(KERN_WARNING dev_warn(&serio->dev,
"atkbd.c: Use 'setkeycodes %s%02x <keycode>' to make it known.\n", "Use 'setkeycodes %s%02x <keycode>' to make it known.\n",
code & 0x80 ? "e0" : "", code & 0x7f); code & 0x80 ? "e0" : "", code & 0x7f);
input_sync(dev); input_sync(dev);
break; break;
case ATKBD_SCR_1: case ATKBD_SCR_1:
scroll = 1 - atkbd->release * 2; scroll = 1;
break; break;
case ATKBD_SCR_2: case ATKBD_SCR_2:
scroll = 2 - atkbd->release * 4; scroll = 2;
break; break;
case ATKBD_SCR_4: case ATKBD_SCR_4:
scroll = 4 - atkbd->release * 8; scroll = 4;
break; break;
case ATKBD_SCR_8: case ATKBD_SCR_8:
scroll = 8 - atkbd->release * 16; scroll = 8;
break; break;
case ATKBD_SCR_CLICK: case ATKBD_SCR_CLICK:
click = !atkbd->release; click = !atkbd->release;
...@@ -507,12 +505,13 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, ...@@ -507,12 +505,13 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data,
if (atkbd->scroll) { if (atkbd->scroll) {
if (click != -1) if (click != -1)
input_report_key(dev, BTN_MIDDLE, click); input_report_key(dev, BTN_MIDDLE, click);
input_report_rel(dev, REL_WHEEL, scroll); input_report_rel(dev, REL_WHEEL,
atkbd->release ? -scroll : scroll);
input_report_rel(dev, REL_HWHEEL, hscroll); input_report_rel(dev, REL_HWHEEL, hscroll);
input_sync(dev); input_sync(dev);
} }
atkbd->release = 0; atkbd->release = false;
out: out:
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -639,9 +638,10 @@ static int atkbd_event(struct input_dev *dev, ...@@ -639,9 +638,10 @@ static int atkbd_event(struct input_dev *dev,
if (!atkbd->softrepeat) if (!atkbd->softrepeat)
atkbd_schedule_event_work(atkbd, ATKBD_REP_EVENT_BIT); atkbd_schedule_event_work(atkbd, ATKBD_REP_EVENT_BIT);
return 0; return 0;
}
default:
return -1; return -1;
}
} }
/* /*
...@@ -652,7 +652,7 @@ static int atkbd_event(struct input_dev *dev, ...@@ -652,7 +652,7 @@ static int atkbd_event(struct input_dev *dev,
static inline void atkbd_enable(struct atkbd *atkbd) static inline void atkbd_enable(struct atkbd *atkbd)
{ {
serio_pause_rx(atkbd->ps2dev.serio); serio_pause_rx(atkbd->ps2dev.serio);
atkbd->enabled = 1; atkbd->enabled = true;
serio_continue_rx(atkbd->ps2dev.serio); serio_continue_rx(atkbd->ps2dev.serio);
} }
...@@ -664,7 +664,7 @@ static inline void atkbd_enable(struct atkbd *atkbd) ...@@ -664,7 +664,7 @@ static inline void atkbd_enable(struct atkbd *atkbd)
static inline void atkbd_disable(struct atkbd *atkbd) static inline void atkbd_disable(struct atkbd *atkbd)
{ {
serio_pause_rx(atkbd->ps2dev.serio); serio_pause_rx(atkbd->ps2dev.serio);
atkbd->enabled = 0; atkbd->enabled = false;
serio_continue_rx(atkbd->ps2dev.serio); serio_continue_rx(atkbd->ps2dev.serio);
} }
...@@ -685,7 +685,9 @@ static int atkbd_probe(struct atkbd *atkbd) ...@@ -685,7 +685,9 @@ static int atkbd_probe(struct atkbd *atkbd)
if (atkbd_reset) if (atkbd_reset)
if (ps2_command(ps2dev, NULL, ATKBD_CMD_RESET_BAT)) if (ps2_command(ps2dev, NULL, ATKBD_CMD_RESET_BAT))
printk(KERN_WARNING "atkbd.c: keyboard reset failed on %s\n", ps2dev->serio->phys); dev_warn(&ps2dev->serio->dev,
"keyboard reset failed on %s\n",
ps2dev->serio->phys);
/* /*
* Then we check the keyboard ID. We should get 0xab83 under normal conditions. * Then we check the keyboard ID. We should get 0xab83 under normal conditions.
...@@ -715,8 +717,9 @@ static int atkbd_probe(struct atkbd *atkbd) ...@@ -715,8 +717,9 @@ static int atkbd_probe(struct atkbd *atkbd)
atkbd->id = (param[0] << 8) | param[1]; atkbd->id = (param[0] << 8) | param[1];
if (atkbd->id == 0xaca1 && atkbd->translated) { if (atkbd->id == 0xaca1 && atkbd->translated) {
printk(KERN_ERR "atkbd.c: NCD terminal keyboards are only supported on non-translating\n"); dev_err(&ps2dev->serio->dev,
printk(KERN_ERR "atkbd.c: controllers. Use i8042.direct=1 to disable translation.\n"); "NCD terminal keyboards are only supported on non-translating controlelrs. "
"Use i8042.direct=1 to disable translation.\n");
return -1; return -1;
} }
...@@ -734,7 +737,7 @@ static int atkbd_select_set(struct atkbd *atkbd, int target_set, int allow_extra ...@@ -734,7 +737,7 @@ static int atkbd_select_set(struct atkbd *atkbd, int target_set, int allow_extra
struct ps2dev *ps2dev = &atkbd->ps2dev; struct ps2dev *ps2dev = &atkbd->ps2dev;
unsigned char param[2]; unsigned char param[2];
atkbd->extra = 0; atkbd->extra = false;
/* /*
* For known special keyboards we can go ahead and set the correct set. * For known special keyboards we can go ahead and set the correct set.
* We check for NCD PS/2 Sun, NorthGate OmniKey 101 and * We check for NCD PS/2 Sun, NorthGate OmniKey 101 and
...@@ -753,7 +756,7 @@ static int atkbd_select_set(struct atkbd *atkbd, int target_set, int allow_extra ...@@ -753,7 +756,7 @@ static int atkbd_select_set(struct atkbd *atkbd, int target_set, int allow_extra
if (allow_extra) { if (allow_extra) {
param[0] = 0x71; param[0] = 0x71;
if (!ps2_command(ps2dev, param, ATKBD_CMD_EX_ENABLE)) { if (!ps2_command(ps2dev, param, ATKBD_CMD_EX_ENABLE)) {
atkbd->extra = 1; atkbd->extra = true;
return 2; return 2;
} }
} }
...@@ -818,7 +821,8 @@ static int atkbd_activate(struct atkbd *atkbd) ...@@ -818,7 +821,8 @@ static int atkbd_activate(struct atkbd *atkbd)
*/ */
if (ps2_command(ps2dev, NULL, ATKBD_CMD_ENABLE)) { if (ps2_command(ps2dev, NULL, ATKBD_CMD_ENABLE)) {
printk(KERN_ERR "atkbd.c: Failed to enable keyboard on %s\n", dev_err(&ps2dev->serio->dev,
"Failed to enable keyboard on %s\n",
ps2dev->serio->phys); ps2dev->serio->phys);
return -1; return -1;
} }
...@@ -1091,10 +1095,12 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv) ...@@ -1091,10 +1095,12 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv)
switch (serio->id.type) { switch (serio->id.type) {
case SERIO_8042_XL: case SERIO_8042_XL:
atkbd->translated = 1; atkbd->translated = true;
/* Fall through */
case SERIO_8042: case SERIO_8042:
if (serio->write) if (serio->write)
atkbd->write = 1; atkbd->write = true;
break; break;
} }
...@@ -1103,7 +1109,7 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv) ...@@ -1103,7 +1109,7 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv)
atkbd->scroll = atkbd_scroll; atkbd->scroll = atkbd_scroll;
if (atkbd->softrepeat) if (atkbd->softrepeat)
atkbd->softraw = 1; atkbd->softraw = true;
serio_set_drvdata(serio, atkbd); serio_set_drvdata(serio, atkbd);
...@@ -1161,7 +1167,8 @@ static int atkbd_reconnect(struct serio *serio) ...@@ -1161,7 +1167,8 @@ static int atkbd_reconnect(struct serio *serio)
struct serio_driver *drv = serio->drv; struct serio_driver *drv = serio->drv;
if (!atkbd || !drv) { if (!atkbd || !drv) {
printk(KERN_DEBUG "atkbd: reconnect request, but serio is disconnected, ignoring...\n"); dev_dbg(&serio->dev,
"reconnect request, but serio is disconnected, ignoring...\n");
return -1; return -1;
} }
...@@ -1288,7 +1295,8 @@ static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t coun ...@@ -1288,7 +1295,8 @@ static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t coun
struct input_dev *old_dev, *new_dev; struct input_dev *old_dev, *new_dev;
unsigned long value; unsigned long value;
int err; int err;
unsigned char old_extra, old_set; bool old_extra;
unsigned char old_set;
if (!atkbd->write) if (!atkbd->write)
return -EIO; return -EIO;
...@@ -1371,7 +1379,7 @@ static ssize_t atkbd_set_scroll(struct atkbd *atkbd, const char *buf, size_t cou ...@@ -1371,7 +1379,7 @@ static ssize_t atkbd_set_scroll(struct atkbd *atkbd, const char *buf, size_t cou
struct input_dev *old_dev, *new_dev; struct input_dev *old_dev, *new_dev;
unsigned long value; unsigned long value;
int err; int err;
unsigned char old_scroll; bool old_scroll;
if (strict_strtoul(buf, 10, &value) || value > 1) if (strict_strtoul(buf, 10, &value) || value > 1)
return -EINVAL; return -EINVAL;
...@@ -1415,7 +1423,8 @@ static ssize_t atkbd_set_set(struct atkbd *atkbd, const char *buf, size_t count) ...@@ -1415,7 +1423,8 @@ static ssize_t atkbd_set_set(struct atkbd *atkbd, const char *buf, size_t count)
struct input_dev *old_dev, *new_dev; struct input_dev *old_dev, *new_dev;
unsigned long value; unsigned long value;
int err; int err;
unsigned char old_set, old_extra; unsigned char old_set;
bool old_extra;
if (!atkbd->write) if (!atkbd->write)
return -EIO; return -EIO;
...@@ -1465,7 +1474,7 @@ static ssize_t atkbd_set_softrepeat(struct atkbd *atkbd, const char *buf, size_t ...@@ -1465,7 +1474,7 @@ static ssize_t atkbd_set_softrepeat(struct atkbd *atkbd, const char *buf, size_t
struct input_dev *old_dev, *new_dev; struct input_dev *old_dev, *new_dev;
unsigned long value; unsigned long value;
int err; int err;
unsigned char old_softrepeat, old_softraw; bool old_softrepeat, old_softraw;
if (!atkbd->write) if (!atkbd->write)
return -EIO; return -EIO;
...@@ -1485,7 +1494,7 @@ static ssize_t atkbd_set_softrepeat(struct atkbd *atkbd, const char *buf, size_t ...@@ -1485,7 +1494,7 @@ static ssize_t atkbd_set_softrepeat(struct atkbd *atkbd, const char *buf, size_t
atkbd->dev = new_dev; atkbd->dev = new_dev;
atkbd->softrepeat = value; atkbd->softrepeat = value;
if (atkbd->softrepeat) if (atkbd->softrepeat)
atkbd->softraw = 1; atkbd->softraw = true;
atkbd_set_device_attrs(atkbd); atkbd_set_device_attrs(atkbd);
err = input_register_device(atkbd->dev); err = input_register_device(atkbd->dev);
...@@ -1515,7 +1524,7 @@ static ssize_t atkbd_set_softraw(struct atkbd *atkbd, const char *buf, size_t co ...@@ -1515,7 +1524,7 @@ static ssize_t atkbd_set_softraw(struct atkbd *atkbd, const char *buf, size_t co
struct input_dev *old_dev, *new_dev; struct input_dev *old_dev, *new_dev;
unsigned long value; unsigned long value;
int err; int err;
unsigned char old_softraw; bool old_softraw;
if (strict_strtoul(buf, 10, &value) || value > 1) if (strict_strtoul(buf, 10, &value) || value > 1)
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment