Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 350684
b: refs/heads/master
c: be2d7e4
h: refs/heads/master
v: v3
  • Loading branch information
Shawn Nematbakhsh authored and Dmitry Torokhov committed Jan 22, 2013
1 parent 6a4475e commit 4f84715
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 22 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4a31ba37b7ed39c9c7178da6e6df7bce63ffc56f
refs/heads/master: be2d7e4233a4fe439125b825470020cef83407d5
72 changes: 51 additions & 21 deletions trunk/drivers/input/keyboard/atkbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,39 @@ static inline void atkbd_disable(struct atkbd *atkbd)
serio_continue_rx(atkbd->ps2dev.serio);
}

static int atkbd_activate(struct atkbd *atkbd)
{
struct ps2dev *ps2dev = &atkbd->ps2dev;

/*
* Enable the keyboard to receive keystrokes.
*/

if (ps2_command(ps2dev, NULL, ATKBD_CMD_ENABLE)) {
dev_err(&ps2dev->serio->dev,
"Failed to enable keyboard on %s\n",
ps2dev->serio->phys);
return -1;
}

return 0;
}

/*
* atkbd_deactivate() resets and disables the keyboard from sending
* keystrokes.
*/

static void atkbd_deactivate(struct atkbd *atkbd)
{
struct ps2dev *ps2dev = &atkbd->ps2dev;

if (ps2_command(ps2dev, NULL, ATKBD_CMD_RESET_DIS))
dev_err(&ps2dev->serio->dev,
"Failed to deactivate keyboard on %s\n",
ps2dev->serio->phys);
}

/*
* atkbd_probe() probes for an AT keyboard on a serio port.
*/
Expand Down Expand Up @@ -731,6 +764,12 @@ static int atkbd_probe(struct atkbd *atkbd)
return -1;
}

/*
* Make sure nothing is coming from the keyboard and disturbs our
* internal state.
*/
atkbd_deactivate(atkbd);

return 0;
}

Expand Down Expand Up @@ -825,24 +864,6 @@ static int atkbd_reset_state(struct atkbd *atkbd)
return 0;
}

static int atkbd_activate(struct atkbd *atkbd)
{
struct ps2dev *ps2dev = &atkbd->ps2dev;

/*
* Enable the keyboard to receive keystrokes.
*/

if (ps2_command(ps2dev, NULL, ATKBD_CMD_ENABLE)) {
dev_err(&ps2dev->serio->dev,
"Failed to enable keyboard on %s\n",
ps2dev->serio->phys);
return -1;
}

return 0;
}

/*
* atkbd_cleanup() restores the keyboard state so that BIOS is happy after a
* reboot.
Expand Down Expand Up @@ -1150,7 +1171,6 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv)

atkbd->set = atkbd_select_set(atkbd, atkbd_set, atkbd_extra);
atkbd_reset_state(atkbd);
atkbd_activate(atkbd);

} else {
atkbd->set = 2;
Expand All @@ -1165,6 +1185,8 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv)
goto fail3;

atkbd_enable(atkbd);
if (serio->write)
atkbd_activate(atkbd);

err = input_register_device(atkbd->dev);
if (err)
Expand Down Expand Up @@ -1208,8 +1230,6 @@ static int atkbd_reconnect(struct serio *serio)
if (atkbd->set != atkbd_select_set(atkbd, atkbd->set, atkbd->extra))
goto out;

atkbd_activate(atkbd);

/*
* Restore LED state and repeat rate. While input core
* will do this for us at resume time reconnect may happen
Expand All @@ -1223,7 +1243,17 @@ static int atkbd_reconnect(struct serio *serio)

}

/*
* Reset our state machine in case reconnect happened in the middle
* of multi-byte scancode.
*/
atkbd->xl_bit = 0;
atkbd->emul = 0;

atkbd_enable(atkbd);
if (atkbd->write)
atkbd_activate(atkbd);

retval = 0;

out:
Expand Down

0 comments on commit 4f84715

Please sign in to comment.