提交 ffd51f46 编写于 作者: H Helge Deller 提交者: Dmitry Torokhov

Input: HIL - cleanup coding style

Signed-off-by: NHelge Deller <deller@gmx.de>
Signed-off-by: NDmitry Torokhov <dtor@mail.ru>
上级 3acaf540
...@@ -94,10 +94,12 @@ static void hil_kbd_process_record(struct hil_kbd *kbd) ...@@ -94,10 +94,12 @@ static void hil_kbd_process_record(struct hil_kbd *kbd)
idx = kbd->idx4/4; idx = kbd->idx4/4;
p = data[idx - 1]; p = data[idx - 1];
if ((p & ~HIL_CMDCT_POL) == if ((p & ~HIL_CMDCT_POL) ==
(HIL_ERR_INT | HIL_PKT_CMD | HIL_CMD_POL)) goto report; (HIL_ERR_INT | HIL_PKT_CMD | HIL_CMD_POL))
if ((p & ~HIL_CMDCT_RPL) == goto report;
(HIL_ERR_INT | HIL_PKT_CMD | HIL_CMD_RPL)) goto report; if ((p & ~HIL_CMDCT_RPL) ==
(HIL_ERR_INT | HIL_PKT_CMD | HIL_CMD_RPL))
goto report;
/* Not a poll response. See if we are loading config records. */ /* Not a poll response. See if we are loading config records. */
switch (p & HIL_PKT_DATA_MASK) { switch (p & HIL_PKT_DATA_MASK) {
...@@ -107,27 +109,32 @@ static void hil_kbd_process_record(struct hil_kbd *kbd) ...@@ -107,27 +109,32 @@ static void hil_kbd_process_record(struct hil_kbd *kbd)
for (; i < HIL_KBD_MAX_LENGTH; i++) for (; i < HIL_KBD_MAX_LENGTH; i++)
kbd->idd[i] = 0; kbd->idd[i] = 0;
break; break;
case HIL_CMD_RSC: case HIL_CMD_RSC:
for (i = 0; i < idx; i++) for (i = 0; i < idx; i++)
kbd->rsc[i] = kbd->data[i] & HIL_PKT_DATA_MASK; kbd->rsc[i] = kbd->data[i] & HIL_PKT_DATA_MASK;
for (; i < HIL_KBD_MAX_LENGTH; i++) for (; i < HIL_KBD_MAX_LENGTH; i++)
kbd->rsc[i] = 0; kbd->rsc[i] = 0;
break; break;
case HIL_CMD_EXD: case HIL_CMD_EXD:
for (i = 0; i < idx; i++) for (i = 0; i < idx; i++)
kbd->exd[i] = kbd->data[i] & HIL_PKT_DATA_MASK; kbd->exd[i] = kbd->data[i] & HIL_PKT_DATA_MASK;
for (; i < HIL_KBD_MAX_LENGTH; i++) for (; i < HIL_KBD_MAX_LENGTH; i++)
kbd->exd[i] = 0; kbd->exd[i] = 0;
break; break;
case HIL_CMD_RNM: case HIL_CMD_RNM:
for (i = 0; i < idx; i++) for (i = 0; i < idx; i++)
kbd->rnm[i] = kbd->data[i] & HIL_PKT_DATA_MASK; kbd->rnm[i] = kbd->data[i] & HIL_PKT_DATA_MASK;
for (; i < HIL_KBD_MAX_LENGTH + 1; i++) for (; i < HIL_KBD_MAX_LENGTH + 1; i++)
kbd->rnm[i] = '\0'; kbd->rnm[i] = '\0';
break; break;
default: default:
/* These occur when device isn't present */ /* These occur when device isn't present */
if (p == (HIL_ERR_INT | HIL_PKT_CMD)) break; if (p == (HIL_ERR_INT | HIL_PKT_CMD))
break;
/* Anything else we'd like to know about. */ /* Anything else we'd like to know about. */
printk(KERN_WARNING PREFIX "Device sent unknown record %x\n", p); printk(KERN_WARNING PREFIX "Device sent unknown record %x\n", p);
break; break;
...@@ -139,16 +146,19 @@ static void hil_kbd_process_record(struct hil_kbd *kbd) ...@@ -139,16 +146,19 @@ static void hil_kbd_process_record(struct hil_kbd *kbd)
switch (kbd->data[0] & HIL_POL_CHARTYPE_MASK) { switch (kbd->data[0] & HIL_POL_CHARTYPE_MASK) {
case HIL_POL_CHARTYPE_NONE: case HIL_POL_CHARTYPE_NONE:
break; break;
case HIL_POL_CHARTYPE_ASCII: case HIL_POL_CHARTYPE_ASCII:
while (cnt < idx - 1) while (cnt < idx - 1)
input_report_key(dev, kbd->data[cnt++] & 0x7f, 1); input_report_key(dev, kbd->data[cnt++] & 0x7f, 1);
break; break;
case HIL_POL_CHARTYPE_RSVD1: case HIL_POL_CHARTYPE_RSVD1:
case HIL_POL_CHARTYPE_RSVD2: case HIL_POL_CHARTYPE_RSVD2:
case HIL_POL_CHARTYPE_BINARY: case HIL_POL_CHARTYPE_BINARY:
while (cnt < idx - 1) while (cnt < idx - 1)
input_report_key(dev, kbd->data[cnt++], 1); input_report_key(dev, kbd->data[cnt++], 1);
break; break;
case HIL_POL_CHARTYPE_SET1: case HIL_POL_CHARTYPE_SET1:
while (cnt < idx - 1) { while (cnt < idx - 1) {
unsigned int key; unsigned int key;
...@@ -161,6 +171,7 @@ static void hil_kbd_process_record(struct hil_kbd *kbd) ...@@ -161,6 +171,7 @@ static void hil_kbd_process_record(struct hil_kbd *kbd)
input_report_key(dev, key, !up); input_report_key(dev, key, !up);
} }
break; break;
case HIL_POL_CHARTYPE_SET2: case HIL_POL_CHARTYPE_SET2:
while (cnt < idx - 1) { while (cnt < idx - 1) {
unsigned int key; unsigned int key;
...@@ -173,6 +184,7 @@ static void hil_kbd_process_record(struct hil_kbd *kbd) ...@@ -173,6 +184,7 @@ static void hil_kbd_process_record(struct hil_kbd *kbd)
input_report_key(dev, key, !up); input_report_key(dev, key, !up);
} }
break; break;
case HIL_POL_CHARTYPE_SET3: case HIL_POL_CHARTYPE_SET3:
while (cnt < idx - 1) { while (cnt < idx - 1) {
unsigned int key; unsigned int key;
...@@ -191,42 +203,43 @@ static void hil_kbd_process_record(struct hil_kbd *kbd) ...@@ -191,42 +203,43 @@ static void hil_kbd_process_record(struct hil_kbd *kbd)
up(&kbd->sem); up(&kbd->sem);
} }
static void hil_kbd_process_err(struct hil_kbd *kbd) { static void hil_kbd_process_err(struct hil_kbd *kbd)
{
printk(KERN_WARNING PREFIX "errored HIL packet\n"); printk(KERN_WARNING PREFIX "errored HIL packet\n");
kbd->idx4 = 0; kbd->idx4 = 0;
up(&kbd->sem); up(&kbd->sem);
} }
static irqreturn_t hil_kbd_interrupt(struct serio *serio, static irqreturn_t hil_kbd_interrupt(struct serio *serio,
unsigned char data, unsigned int flags) unsigned char data, unsigned int flags)
{ {
struct hil_kbd *kbd; struct hil_kbd *kbd;
hil_packet packet; hil_packet packet;
int idx; int idx;
kbd = serio_get_drvdata(serio); kbd = serio_get_drvdata(serio);
if (kbd == NULL) { BUG_ON(kbd == NULL);
BUG();
return IRQ_HANDLED;
}
if (kbd->idx4 >= (HIL_KBD_MAX_LENGTH * sizeof(hil_packet))) { if (kbd->idx4 >= (HIL_KBD_MAX_LENGTH * sizeof(hil_packet))) {
hil_kbd_process_err(kbd); hil_kbd_process_err(kbd);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
idx = kbd->idx4/4; idx = kbd->idx4/4;
if (!(kbd->idx4 % 4)) kbd->data[idx] = 0; if (!(kbd->idx4 % 4))
kbd->data[idx] = 0;
packet = kbd->data[idx]; packet = kbd->data[idx];
packet |= ((hil_packet)data) << ((3 - (kbd->idx4 % 4)) * 8); packet |= ((hil_packet)data) << ((3 - (kbd->idx4 % 4)) * 8);
kbd->data[idx] = packet; kbd->data[idx] = packet;
/* Records of N 4-byte hil_packets must terminate with a command. */ /* Records of N 4-byte hil_packets must terminate with a command. */
if ((++(kbd->idx4)) % 4) return IRQ_HANDLED; if ((++(kbd->idx4)) % 4)
return IRQ_HANDLED;
if ((packet & 0xffff0000) != HIL_ERR_INT) { if ((packet & 0xffff0000) != HIL_ERR_INT) {
hil_kbd_process_err(kbd); hil_kbd_process_err(kbd);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
if (packet & HIL_PKT_CMD) hil_kbd_process_record(kbd); if (packet & HIL_PKT_CMD)
hil_kbd_process_record(kbd);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -235,10 +248,7 @@ static void hil_kbd_disconnect(struct serio *serio) ...@@ -235,10 +248,7 @@ static void hil_kbd_disconnect(struct serio *serio)
struct hil_kbd *kbd; struct hil_kbd *kbd;
kbd = serio_get_drvdata(serio); kbd = serio_get_drvdata(serio);
if (kbd == NULL) { BUG_ON(kbd == NULL);
BUG();
return;
}
serio_close(serio); serio_close(serio);
input_unregister_device(kbd->dev); input_unregister_device(kbd->dev);
...@@ -267,34 +277,34 @@ static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv) ...@@ -267,34 +277,34 @@ static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv)
serio_set_drvdata(serio, kbd); serio_set_drvdata(serio, kbd);
kbd->serio = serio; kbd->serio = serio;
init_MUTEX_LOCKED(&(kbd->sem)); init_MUTEX_LOCKED(&kbd->sem);
/* Get device info. MLC driver supplies devid/status/etc. */ /* Get device info. MLC driver supplies devid/status/etc. */
serio->write(serio, 0); serio->write(serio, 0);
serio->write(serio, 0); serio->write(serio, 0);
serio->write(serio, HIL_PKT_CMD >> 8); serio->write(serio, HIL_PKT_CMD >> 8);
serio->write(serio, HIL_CMD_IDD); serio->write(serio, HIL_CMD_IDD);
down(&(kbd->sem)); down(&kbd->sem);
serio->write(serio, 0); serio->write(serio, 0);
serio->write(serio, 0); serio->write(serio, 0);
serio->write(serio, HIL_PKT_CMD >> 8); serio->write(serio, HIL_PKT_CMD >> 8);
serio->write(serio, HIL_CMD_RSC); serio->write(serio, HIL_CMD_RSC);
down(&(kbd->sem)); down(&kbd->sem);
serio->write(serio, 0); serio->write(serio, 0);
serio->write(serio, 0); serio->write(serio, 0);
serio->write(serio, HIL_PKT_CMD >> 8); serio->write(serio, HIL_PKT_CMD >> 8);
serio->write(serio, HIL_CMD_RNM); serio->write(serio, HIL_CMD_RNM);
down(&(kbd->sem)); down(&kbd->sem);
serio->write(serio, 0); serio->write(serio, 0);
serio->write(serio, 0); serio->write(serio, 0);
serio->write(serio, HIL_PKT_CMD >> 8); serio->write(serio, HIL_PKT_CMD >> 8);
serio->write(serio, HIL_CMD_EXD); serio->write(serio, HIL_CMD_EXD);
down(&(kbd->sem)); down(&kbd->sem);
up(&(kbd->sem)); up(&kbd->sem);
did = kbd->idd[0]; did = kbd->idd[0];
idd = kbd->idd + 1; idd = kbd->idd + 1;
...@@ -310,12 +320,11 @@ static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv) ...@@ -310,12 +320,11 @@ static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv)
goto bail2; goto bail2;
} }
if(HIL_IDD_NUM_BUTTONS(idd) || HIL_IDD_NUM_AXES_PER_SET(*idd)) { if (HIL_IDD_NUM_BUTTONS(idd) || HIL_IDD_NUM_AXES_PER_SET(*idd)) {
printk(KERN_INFO PREFIX "keyboards only, no combo devices supported.\n"); printk(KERN_INFO PREFIX "keyboards only, no combo devices supported.\n");
goto bail2; goto bail2;
} }
kbd->dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); kbd->dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
kbd->dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL); kbd->dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL);
kbd->dev->keycodemax = HIL_KEYCODES_SET1_TBLSIZE; kbd->dev->keycodemax = HIL_KEYCODES_SET1_TBLSIZE;
...@@ -344,8 +353,8 @@ static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv) ...@@ -344,8 +353,8 @@ static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv)
serio->write(serio, 0); serio->write(serio, 0);
serio->write(serio, HIL_PKT_CMD >> 8); serio->write(serio, HIL_PKT_CMD >> 8);
serio->write(serio, HIL_CMD_EK1); /* Enable Keyswitch Autorepeat 1 */ serio->write(serio, HIL_CMD_EK1); /* Enable Keyswitch Autorepeat 1 */
down(&(kbd->sem)); down(&kbd->sem);
up(&(kbd->sem)); up(&kbd->sem);
return 0; return 0;
bail2: bail2:
...@@ -374,20 +383,20 @@ static struct serio_driver hil_kbd_serio_drv = { ...@@ -374,20 +383,20 @@ static struct serio_driver hil_kbd_serio_drv = {
}, },
.description = "HP HIL keyboard driver", .description = "HP HIL keyboard driver",
.id_table = hil_kbd_ids, .id_table = hil_kbd_ids,
.connect = hil_kbd_connect, .connect = hil_kbd_connect,
.disconnect = hil_kbd_disconnect, .disconnect = hil_kbd_disconnect,
.interrupt = hil_kbd_interrupt .interrupt = hil_kbd_interrupt
}; };
static int __init hil_kbd_init(void) static int __init hil_kbd_init(void)
{ {
return serio_register_driver(&hil_kbd_serio_drv); return serio_register_driver(&hil_kbd_serio_drv);
} }
static void __exit hil_kbd_exit(void) static void __exit hil_kbd_exit(void)
{ {
serio_unregister_driver(&hil_kbd_serio_drv); serio_unregister_driver(&hil_kbd_serio_drv);
} }
module_init(hil_kbd_init); module_init(hil_kbd_init);
module_exit(hil_kbd_exit); module_exit(hil_kbd_exit);
...@@ -88,10 +88,12 @@ static void hil_ptr_process_record(struct hil_ptr *ptr) ...@@ -88,10 +88,12 @@ static void hil_ptr_process_record(struct hil_ptr *ptr)
idx = ptr->idx4/4; idx = ptr->idx4/4;
p = data[idx - 1]; p = data[idx - 1];
if ((p & ~HIL_CMDCT_POL) == if ((p & ~HIL_CMDCT_POL) ==
(HIL_ERR_INT | HIL_PKT_CMD | HIL_CMD_POL)) goto report; (HIL_ERR_INT | HIL_PKT_CMD | HIL_CMD_POL))
if ((p & ~HIL_CMDCT_RPL) == goto report;
(HIL_ERR_INT | HIL_PKT_CMD | HIL_CMD_RPL)) goto report; if ((p & ~HIL_CMDCT_RPL) ==
(HIL_ERR_INT | HIL_PKT_CMD | HIL_CMD_RPL))
goto report;
/* Not a poll response. See if we are loading config records. */ /* Not a poll response. See if we are loading config records. */
switch (p & HIL_PKT_DATA_MASK) { switch (p & HIL_PKT_DATA_MASK) {
...@@ -101,27 +103,32 @@ static void hil_ptr_process_record(struct hil_ptr *ptr) ...@@ -101,27 +103,32 @@ static void hil_ptr_process_record(struct hil_ptr *ptr)
for (; i < HIL_PTR_MAX_LENGTH; i++) for (; i < HIL_PTR_MAX_LENGTH; i++)
ptr->idd[i] = 0; ptr->idd[i] = 0;
break; break;
case HIL_CMD_RSC: case HIL_CMD_RSC:
for (i = 0; i < idx; i++) for (i = 0; i < idx; i++)
ptr->rsc[i] = ptr->data[i] & HIL_PKT_DATA_MASK; ptr->rsc[i] = ptr->data[i] & HIL_PKT_DATA_MASK;
for (; i < HIL_PTR_MAX_LENGTH; i++) for (; i < HIL_PTR_MAX_LENGTH; i++)
ptr->rsc[i] = 0; ptr->rsc[i] = 0;
break; break;
case HIL_CMD_EXD: case HIL_CMD_EXD:
for (i = 0; i < idx; i++) for (i = 0; i < idx; i++)
ptr->exd[i] = ptr->data[i] & HIL_PKT_DATA_MASK; ptr->exd[i] = ptr->data[i] & HIL_PKT_DATA_MASK;
for (; i < HIL_PTR_MAX_LENGTH; i++) for (; i < HIL_PTR_MAX_LENGTH; i++)
ptr->exd[i] = 0; ptr->exd[i] = 0;
break; break;
case HIL_CMD_RNM: case HIL_CMD_RNM:
for (i = 0; i < idx; i++) for (i = 0; i < idx; i++)
ptr->rnm[i] = ptr->data[i] & HIL_PKT_DATA_MASK; ptr->rnm[i] = ptr->data[i] & HIL_PKT_DATA_MASK;
for (; i < HIL_PTR_MAX_LENGTH + 1; i++) for (; i < HIL_PTR_MAX_LENGTH + 1; i++)
ptr->rnm[i] = '\0'; ptr->rnm[i] = 0;
break; break;
default: default:
/* These occur when device isn't present */ /* These occur when device isn't present */
if (p == (HIL_ERR_INT | HIL_PKT_CMD)) break; if (p == (HIL_ERR_INT | HIL_PKT_CMD))
break;
/* Anything else we'd like to know about. */ /* Anything else we'd like to know about. */
printk(KERN_WARNING PREFIX "Device sent unknown record %x\n", p); printk(KERN_WARNING PREFIX "Device sent unknown record %x\n", p);
break; break;
...@@ -130,7 +137,8 @@ static void hil_ptr_process_record(struct hil_ptr *ptr) ...@@ -130,7 +137,8 @@ static void hil_ptr_process_record(struct hil_ptr *ptr)
report: report:
if ((p & HIL_CMDCT_POL) != idx - 1) { if ((p & HIL_CMDCT_POL) != idx - 1) {
printk(KERN_WARNING PREFIX "Malformed poll packet %x (idx = %i)\n", p, idx); printk(KERN_WARNING PREFIX
"Malformed poll packet %x (idx = %i)\n", p, idx);
goto out; goto out;
} }
...@@ -139,7 +147,7 @@ static void hil_ptr_process_record(struct hil_ptr *ptr) ...@@ -139,7 +147,7 @@ static void hil_ptr_process_record(struct hil_ptr *ptr)
laxis += i; laxis += i;
ax16 = ptr->idd[1] & HIL_IDD_HEADER_16BIT; /* 8 or 16bit resolution */ ax16 = ptr->idd[1] & HIL_IDD_HEADER_16BIT; /* 8 or 16bit resolution */
absdev = ptr->idd[1] & HIL_IDD_HEADER_ABS; absdev = ptr->idd[1] & HIL_IDD_HEADER_ABS;
for (cnt = 1; i < laxis; i++) { for (cnt = 1; i < laxis; i++) {
unsigned int lo,hi,val; unsigned int lo,hi,val;
...@@ -157,7 +165,8 @@ static void hil_ptr_process_record(struct hil_ptr *ptr) ...@@ -157,7 +165,8 @@ static void hil_ptr_process_record(struct hil_ptr *ptr)
input_report_abs(dev, ABS_X + i, val); input_report_abs(dev, ABS_X + i, val);
} else { } else {
val = (int) (((int8_t)lo) | ((int8_t)hi<<8)); val = (int) (((int8_t)lo) | ((int8_t)hi<<8));
if (i%3) val *= -1; if (i%3)
val *= -1;
input_report_rel(dev, REL_X + i, val); input_report_rel(dev, REL_X + i, val);
} }
} }
...@@ -168,10 +177,11 @@ static void hil_ptr_process_record(struct hil_ptr *ptr) ...@@ -168,10 +177,11 @@ static void hil_ptr_process_record(struct hil_ptr *ptr)
btn = ptr->data[cnt++]; btn = ptr->data[cnt++];
up = btn & 1; up = btn & 1;
btn &= 0xfe; btn &= 0xfe;
if (btn == 0x8e) { if (btn == 0x8e)
continue; /* TODO: proximity == touch? */ continue; /* TODO: proximity == touch? */
} else
else if ((btn > 0x8c) || (btn < 0x80)) continue; if ((btn > 0x8c) || (btn < 0x80))
continue;
btn = (btn - 0x80) >> 1; btn = (btn - 0x80) >> 1;
btn = ptr->btnmap[btn]; btn = ptr->btnmap[btn];
input_report_key(dev, btn, !up); input_report_key(dev, btn, !up);
...@@ -182,14 +192,14 @@ static void hil_ptr_process_record(struct hil_ptr *ptr) ...@@ -182,14 +192,14 @@ static void hil_ptr_process_record(struct hil_ptr *ptr)
up(&ptr->sem); up(&ptr->sem);
} }
static void hil_ptr_process_err(struct hil_ptr *ptr) { static void hil_ptr_process_err(struct hil_ptr *ptr)
{
printk(KERN_WARNING PREFIX "errored HIL packet\n"); printk(KERN_WARNING PREFIX "errored HIL packet\n");
ptr->idx4 = 0; ptr->idx4 = 0;
up(&ptr->sem); up(&ptr->sem);
return;
} }
static irqreturn_t hil_ptr_interrupt(struct serio *serio, static irqreturn_t hil_ptr_interrupt(struct serio *serio,
unsigned char data, unsigned int flags) unsigned char data, unsigned int flags)
{ {
struct hil_ptr *ptr; struct hil_ptr *ptr;
...@@ -197,29 +207,29 @@ static irqreturn_t hil_ptr_interrupt(struct serio *serio, ...@@ -197,29 +207,29 @@ static irqreturn_t hil_ptr_interrupt(struct serio *serio,
int idx; int idx;
ptr = serio_get_drvdata(serio); ptr = serio_get_drvdata(serio);
if (ptr == NULL) { BUG_ON(ptr == NULL);
BUG();
return IRQ_HANDLED;
}
if (ptr->idx4 >= (HIL_PTR_MAX_LENGTH * sizeof(hil_packet))) { if (ptr->idx4 >= (HIL_PTR_MAX_LENGTH * sizeof(hil_packet))) {
hil_ptr_process_err(ptr); hil_ptr_process_err(ptr);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
idx = ptr->idx4/4; idx = ptr->idx4/4;
if (!(ptr->idx4 % 4)) ptr->data[idx] = 0; if (!(ptr->idx4 % 4))
ptr->data[idx] = 0;
packet = ptr->data[idx]; packet = ptr->data[idx];
packet |= ((hil_packet)data) << ((3 - (ptr->idx4 % 4)) * 8); packet |= ((hil_packet)data) << ((3 - (ptr->idx4 % 4)) * 8);
ptr->data[idx] = packet; ptr->data[idx] = packet;
/* Records of N 4-byte hil_packets must terminate with a command. */ /* Records of N 4-byte hil_packets must terminate with a command. */
if ((++(ptr->idx4)) % 4) return IRQ_HANDLED; if ((++(ptr->idx4)) % 4)
return IRQ_HANDLED;
if ((packet & 0xffff0000) != HIL_ERR_INT) { if ((packet & 0xffff0000) != HIL_ERR_INT) {
hil_ptr_process_err(ptr); hil_ptr_process_err(ptr);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
if (packet & HIL_PKT_CMD) if (packet & HIL_PKT_CMD)
hil_ptr_process_record(ptr); hil_ptr_process_record(ptr);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -228,10 +238,7 @@ static void hil_ptr_disconnect(struct serio *serio) ...@@ -228,10 +238,7 @@ static void hil_ptr_disconnect(struct serio *serio)
struct hil_ptr *ptr; struct hil_ptr *ptr;
ptr = serio_get_drvdata(serio); ptr = serio_get_drvdata(serio);
if (ptr == NULL) { BUG_ON(ptr == NULL);
BUG();
return;
}
serio_close(serio); serio_close(serio);
input_unregister_device(ptr->dev); input_unregister_device(ptr->dev);
...@@ -241,7 +248,7 @@ static void hil_ptr_disconnect(struct serio *serio) ...@@ -241,7 +248,7 @@ static void hil_ptr_disconnect(struct serio *serio)
static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver) static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver)
{ {
struct hil_ptr *ptr; struct hil_ptr *ptr;
char *txt; const char *txt;
unsigned int i, naxsets, btntype; unsigned int i, naxsets, btntype;
uint8_t did, *idd; uint8_t did, *idd;
...@@ -260,34 +267,34 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver) ...@@ -260,34 +267,34 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver)
serio_set_drvdata(serio, ptr); serio_set_drvdata(serio, ptr);
ptr->serio = serio; ptr->serio = serio;
init_MUTEX_LOCKED(&(ptr->sem)); init_MUTEX_LOCKED(&ptr->sem);
/* Get device info. MLC driver supplies devid/status/etc. */ /* Get device info. MLC driver supplies devid/status/etc. */
serio->write(serio, 0); serio->write(serio, 0);
serio->write(serio, 0); serio->write(serio, 0);
serio->write(serio, HIL_PKT_CMD >> 8); serio->write(serio, HIL_PKT_CMD >> 8);
serio->write(serio, HIL_CMD_IDD); serio->write(serio, HIL_CMD_IDD);
down(&(ptr->sem)); down(&ptr->sem);
serio->write(serio, 0); serio->write(serio, 0);
serio->write(serio, 0); serio->write(serio, 0);
serio->write(serio, HIL_PKT_CMD >> 8); serio->write(serio, HIL_PKT_CMD >> 8);
serio->write(serio, HIL_CMD_RSC); serio->write(serio, HIL_CMD_RSC);
down(&(ptr->sem)); down(&ptr->sem);
serio->write(serio, 0); serio->write(serio, 0);
serio->write(serio, 0); serio->write(serio, 0);
serio->write(serio, HIL_PKT_CMD >> 8); serio->write(serio, HIL_PKT_CMD >> 8);
serio->write(serio, HIL_CMD_RNM); serio->write(serio, HIL_CMD_RNM);
down(&(ptr->sem)); down(&ptr->sem);
serio->write(serio, 0); serio->write(serio, 0);
serio->write(serio, 0); serio->write(serio, 0);
serio->write(serio, HIL_PKT_CMD >> 8); serio->write(serio, HIL_PKT_CMD >> 8);
serio->write(serio, HIL_CMD_EXD); serio->write(serio, HIL_CMD_EXD);
down(&(ptr->sem)); down(&ptr->sem);
up(&(ptr->sem)); up(&ptr->sem);
did = ptr->idd[0]; did = ptr->idd[0];
idd = ptr->idd + 1; idd = ptr->idd + 1;
...@@ -301,12 +308,12 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver) ...@@ -301,12 +308,12 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver)
ptr->dev->evbit[0] = BIT(EV_ABS); ptr->dev->evbit[0] = BIT(EV_ABS);
txt = "absolute"; txt = "absolute";
} }
if (!ptr->dev->evbit[0]) { if (!ptr->dev->evbit[0])
goto bail2; goto bail2;
}
ptr->nbtn = HIL_IDD_NUM_BUTTONS(idd); ptr->nbtn = HIL_IDD_NUM_BUTTONS(idd);
if (ptr->nbtn) ptr->dev->evbit[0] |= BIT(EV_KEY); if (ptr->nbtn)
ptr->dev->evbit[0] |= BIT(EV_KEY);
naxsets = HIL_IDD_NUM_AXSETS(*idd); naxsets = HIL_IDD_NUM_AXSETS(*idd);
ptr->naxes = HIL_IDD_NUM_AXES_PER_SET(*idd); ptr->naxes = HIL_IDD_NUM_AXES_PER_SET(*idd);
...@@ -315,7 +322,7 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver) ...@@ -315,7 +322,7 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver)
did, txt); did, txt);
printk(KERN_INFO PREFIX "HIL pointer has %i buttons and %i sets of %i axes\n", printk(KERN_INFO PREFIX "HIL pointer has %i buttons and %i sets of %i axes\n",
ptr->nbtn, naxsets, ptr->naxes); ptr->nbtn, naxsets, ptr->naxes);
btntype = BTN_MISC; btntype = BTN_MISC;
if ((did & HIL_IDD_DID_ABS_TABLET_MASK) == HIL_IDD_DID_ABS_TABLET) if ((did & HIL_IDD_DID_ABS_TABLET_MASK) == HIL_IDD_DID_ABS_TABLET)
#ifdef TABLET_SIMULATES_MOUSE #ifdef TABLET_SIMULATES_MOUSE
...@@ -325,7 +332,7 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver) ...@@ -325,7 +332,7 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver)
#endif #endif
if ((did & HIL_IDD_DID_ABS_TSCREEN_MASK) == HIL_IDD_DID_ABS_TSCREEN) if ((did & HIL_IDD_DID_ABS_TSCREEN_MASK) == HIL_IDD_DID_ABS_TSCREEN)
btntype = BTN_TOUCH; btntype = BTN_TOUCH;
if ((did & HIL_IDD_DID_REL_MOUSE_MASK) == HIL_IDD_DID_REL_MOUSE) if ((did & HIL_IDD_DID_REL_MOUSE_MASK) == HIL_IDD_DID_REL_MOUSE)
btntype = BTN_MOUSE; btntype = BTN_MOUSE;
...@@ -341,12 +348,10 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver) ...@@ -341,12 +348,10 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver)
} }
if ((did & HIL_IDD_DID_TYPE_MASK) == HIL_IDD_DID_TYPE_REL) { if ((did & HIL_IDD_DID_TYPE_MASK) == HIL_IDD_DID_TYPE_REL) {
for (i = 0; i < ptr->naxes; i++) { for (i = 0; i < ptr->naxes; i++)
set_bit(REL_X + i, ptr->dev->relbit); set_bit(REL_X + i, ptr->dev->relbit);
} for (i = 3; (i < ptr->naxes + 3) && (naxsets > 1); i++)
for (i = 3; (i < ptr->naxes + 3) && (naxsets > 1); i++) {
set_bit(REL_X + i, ptr->dev->relbit); set_bit(REL_X + i, ptr->dev->relbit);
}
} else { } else {
for (i = 0; i < ptr->naxes; i++) { for (i = 0; i < ptr->naxes; i++) {
set_bit(ABS_X + i, ptr->dev->absbit); set_bit(ABS_X + i, ptr->dev->absbit);
...@@ -419,11 +424,11 @@ static int __init hil_ptr_init(void) ...@@ -419,11 +424,11 @@ static int __init hil_ptr_init(void)
{ {
return serio_register_driver(&hil_ptr_serio_driver); return serio_register_driver(&hil_ptr_serio_driver);
} }
static void __exit hil_ptr_exit(void) static void __exit hil_ptr_exit(void)
{ {
serio_unregister_driver(&hil_ptr_serio_driver); serio_unregister_driver(&hil_ptr_serio_driver);
} }
module_init(hil_ptr_init); module_init(hil_ptr_init);
module_exit(hil_ptr_exit); module_exit(hil_ptr_exit);
此差异已折叠。
此差异已折叠。
...@@ -58,12 +58,13 @@ struct hp_sdc_mlc_priv_s { ...@@ -58,12 +58,13 @@ struct hp_sdc_mlc_priv_s {
} hp_sdc_mlc_priv; } hp_sdc_mlc_priv;
/************************* Interrupt context ******************************/ /************************* Interrupt context ******************************/
static void hp_sdc_mlc_isr (int irq, void *dev_id, static void hp_sdc_mlc_isr (int irq, void *dev_id,
uint8_t status, uint8_t data) { uint8_t status, uint8_t data)
int idx; {
int idx;
hil_mlc *mlc = &hp_sdc_mlc; hil_mlc *mlc = &hp_sdc_mlc;
write_lock(&(mlc->lock)); write_lock(&mlc->lock);
if (mlc->icount < 0) { if (mlc->icount < 0) {
printk(KERN_WARNING PREFIX "HIL Overflow!\n"); printk(KERN_WARNING PREFIX "HIL Overflow!\n");
up(&mlc->isem); up(&mlc->isem);
...@@ -73,239 +74,247 @@ static void hp_sdc_mlc_isr (int irq, void *dev_id, ...@@ -73,239 +74,247 @@ static void hp_sdc_mlc_isr (int irq, void *dev_id,
if ((status & HP_SDC_STATUS_IRQMASK) == HP_SDC_STATUS_HILDATA) { if ((status & HP_SDC_STATUS_IRQMASK) == HP_SDC_STATUS_HILDATA) {
mlc->ipacket[idx] |= data | HIL_ERR_INT; mlc->ipacket[idx] |= data | HIL_ERR_INT;
mlc->icount--; mlc->icount--;
if (hp_sdc_mlc_priv.got5x) goto check; if (hp_sdc_mlc_priv.got5x || !idx)
if (!idx) goto check; goto check;
if ((mlc->ipacket[idx-1] & HIL_PKT_ADDR_MASK) != if ((mlc->ipacket[idx - 1] & HIL_PKT_ADDR_MASK) !=
(mlc->ipacket[idx] & HIL_PKT_ADDR_MASK)) { (mlc->ipacket[idx] & HIL_PKT_ADDR_MASK)) {
mlc->ipacket[idx] &= ~HIL_PKT_ADDR_MASK; mlc->ipacket[idx] &= ~HIL_PKT_ADDR_MASK;
mlc->ipacket[idx] |= (mlc->ipacket[idx-1] mlc->ipacket[idx] |= (mlc->ipacket[idx - 1]
& HIL_PKT_ADDR_MASK); & HIL_PKT_ADDR_MASK);
} }
goto check; goto check;
} }
/* We know status is 5X */ /* We know status is 5X */
if (data & HP_SDC_HIL_ISERR) goto err; if (data & HP_SDC_HIL_ISERR)
mlc->ipacket[idx] = goto err;
mlc->ipacket[idx] =
(data & HP_SDC_HIL_R1MASK) << HIL_PKT_ADDR_SHIFT; (data & HP_SDC_HIL_R1MASK) << HIL_PKT_ADDR_SHIFT;
hp_sdc_mlc_priv.got5x = 1; hp_sdc_mlc_priv.got5x = 1;
goto out; goto out;
check: check:
hp_sdc_mlc_priv.got5x = 0; hp_sdc_mlc_priv.got5x = 0;
if (mlc->imatch == 0) goto done; if (mlc->imatch == 0)
if ((mlc->imatch == (HIL_ERR_INT | HIL_PKT_CMD | HIL_CMD_POL)) goto done;
&& (mlc->ipacket[idx] == (mlc->imatch | idx))) goto done; if ((mlc->imatch == (HIL_ERR_INT | HIL_PKT_CMD | HIL_CMD_POL))
if (mlc->ipacket[idx] == mlc->imatch) goto done; && (mlc->ipacket[idx] == (mlc->imatch | idx)))
goto done;
if (mlc->ipacket[idx] == mlc->imatch)
goto done;
goto out; goto out;
err: err:
printk(KERN_DEBUG PREFIX "err code %x\n", data); printk(KERN_DEBUG PREFIX "err code %x\n", data);
switch (data) { switch (data) {
case HP_SDC_HIL_RC_DONE: case HP_SDC_HIL_RC_DONE:
printk(KERN_WARNING PREFIX "Bastard SDC reconfigured loop!\n"); printk(KERN_WARNING PREFIX "Bastard SDC reconfigured loop!\n");
break; break;
case HP_SDC_HIL_ERR: case HP_SDC_HIL_ERR:
mlc->ipacket[idx] |= HIL_ERR_INT | HIL_ERR_PERR | mlc->ipacket[idx] |= HIL_ERR_INT | HIL_ERR_PERR |
HIL_ERR_FERR | HIL_ERR_FOF; HIL_ERR_FERR | HIL_ERR_FOF;
break; break;
case HP_SDC_HIL_TO: case HP_SDC_HIL_TO:
mlc->ipacket[idx] |= HIL_ERR_INT | HIL_ERR_LERR; mlc->ipacket[idx] |= HIL_ERR_INT | HIL_ERR_LERR;
break; break;
case HP_SDC_HIL_RC: case HP_SDC_HIL_RC:
printk(KERN_WARNING PREFIX "Bastard SDC decided to reconfigure loop!\n"); printk(KERN_WARNING PREFIX "Bastard SDC decided to reconfigure loop!\n");
break; break;
default: default:
printk(KERN_WARNING PREFIX "Unkown HIL Error status (%x)!\n", data); printk(KERN_WARNING PREFIX "Unkown HIL Error status (%x)!\n", data);
break; break;
} }
/* No more data will be coming due to an error. */ /* No more data will be coming due to an error. */
done: done:
tasklet_schedule(mlc->tasklet); tasklet_schedule(mlc->tasklet);
up(&(mlc->isem)); up(&mlc->isem);
out: out:
write_unlock(&(mlc->lock)); write_unlock(&mlc->lock);
} }
/******************** Tasklet or userspace context functions ****************/ /******************** Tasklet or userspace context functions ****************/
static int hp_sdc_mlc_in (hil_mlc *mlc, suseconds_t timeout) { static int hp_sdc_mlc_in(hil_mlc *mlc, suseconds_t timeout)
{
unsigned long flags; unsigned long flags;
struct hp_sdc_mlc_priv_s *priv; struct hp_sdc_mlc_priv_s *priv;
int rc = 2; int rc = 2;
priv = mlc->priv; priv = mlc->priv;
write_lock_irqsave(&(mlc->lock), flags); write_lock_irqsave(&mlc->lock, flags);
/* Try to down the semaphore */ /* Try to down the semaphore */
if (down_trylock(&(mlc->isem))) { if (down_trylock(&mlc->isem)) {
struct timeval tv; struct timeval tv;
if (priv->emtestmode) { if (priv->emtestmode) {
mlc->ipacket[0] = mlc->ipacket[0] =
HIL_ERR_INT | (mlc->opacket & HIL_ERR_INT | (mlc->opacket &
(HIL_PKT_CMD | (HIL_PKT_CMD |
HIL_PKT_ADDR_MASK | HIL_PKT_ADDR_MASK |
HIL_PKT_DATA_MASK)); HIL_PKT_DATA_MASK));
mlc->icount = 14; mlc->icount = 14;
/* printk(KERN_DEBUG PREFIX ">[%x]\n", mlc->ipacket[0]); */ /* printk(KERN_DEBUG PREFIX ">[%x]\n", mlc->ipacket[0]); */
goto wasup; goto wasup;
} }
do_gettimeofday(&tv); do_gettimeofday(&tv);
tv.tv_usec += 1000000 * (tv.tv_sec - mlc->instart.tv_sec); tv.tv_usec += USEC_PER_SEC * (tv.tv_sec - mlc->instart.tv_sec);
if (tv.tv_usec - mlc->instart.tv_usec > mlc->intimeout) { if (tv.tv_usec - mlc->instart.tv_usec > mlc->intimeout) {
/* printk("!%i %i", /* printk("!%i %i",
tv.tv_usec - mlc->instart.tv_usec, tv.tv_usec - mlc->instart.tv_usec,
mlc->intimeout); mlc->intimeout);
*/ */
rc = 1; rc = 1;
up(&(mlc->isem)); up(&mlc->isem);
} }
goto done; goto done;
} }
wasup: wasup:
up(&(mlc->isem)); up(&mlc->isem);
rc = 0; rc = 0;
goto done; goto done;
done: done:
write_unlock_irqrestore(&(mlc->lock), flags); write_unlock_irqrestore(&mlc->lock, flags);
return rc; return rc;
} }
static int hp_sdc_mlc_cts (hil_mlc *mlc) { static int hp_sdc_mlc_cts(hil_mlc *mlc)
{
struct hp_sdc_mlc_priv_s *priv; struct hp_sdc_mlc_priv_s *priv;
unsigned long flags; unsigned long flags;
priv = mlc->priv; priv = mlc->priv;
write_lock_irqsave(&(mlc->lock), flags); write_lock_irqsave(&mlc->lock, flags);
/* Try to down the semaphores -- they should be up. */ /* Try to down the semaphores -- they should be up. */
if (down_trylock(&(mlc->isem))) { BUG_ON(down_trylock(&mlc->isem));
BUG(); BUG_ON(down_trylock(&mlc->osem));
goto busy;
}
if (down_trylock(&(mlc->osem))) {
BUG();
up(&(mlc->isem));
goto busy;
}
up(&(mlc->isem));
up(&(mlc->osem));
if (down_trylock(&(mlc->csem))) { up(&mlc->isem);
if (priv->trans.act.semaphore != &(mlc->csem)) goto poll; up(&mlc->osem);
goto busy;
if (down_trylock(&mlc->csem)) {
if (priv->trans.act.semaphore != &mlc->csem)
goto poll;
else
goto busy;
} }
if (!(priv->tseq[4] & HP_SDC_USE_LOOP)) goto done;
if (!(priv->tseq[4] & HP_SDC_USE_LOOP))
goto done;
poll: poll:
priv->trans.act.semaphore = &(mlc->csem); priv->trans.act.semaphore = &mlc->csem;
priv->trans.actidx = 0; priv->trans.actidx = 0;
priv->trans.idx = 1; priv->trans.idx = 1;
priv->trans.endidx = 5; priv->trans.endidx = 5;
priv->tseq[0] = priv->tseq[0] =
HP_SDC_ACT_POSTCMD | HP_SDC_ACT_DATAIN | HP_SDC_ACT_SEMAPHORE; HP_SDC_ACT_POSTCMD | HP_SDC_ACT_DATAIN | HP_SDC_ACT_SEMAPHORE;
priv->tseq[1] = HP_SDC_CMD_READ_USE; priv->tseq[1] = HP_SDC_CMD_READ_USE;
priv->tseq[2] = 1; priv->tseq[2] = 1;
priv->tseq[3] = 0; priv->tseq[3] = 0;
priv->tseq[4] = 0; priv->tseq[4] = 0;
hp_sdc_enqueue_transaction(&(priv->trans)); hp_sdc_enqueue_transaction(&priv->trans);
busy: busy:
write_unlock_irqrestore(&(mlc->lock), flags); write_unlock_irqrestore(&mlc->lock, flags);
return 1; return 1;
done: done:
priv->trans.act.semaphore = &(mlc->osem); priv->trans.act.semaphore = &mlc->osem;
up(&(mlc->csem)); up(&mlc->csem);
write_unlock_irqrestore(&(mlc->lock), flags); write_unlock_irqrestore(&mlc->lock, flags);
return 0; return 0;
} }
static void hp_sdc_mlc_out (hil_mlc *mlc) { static void hp_sdc_mlc_out(hil_mlc *mlc)
{
struct hp_sdc_mlc_priv_s *priv; struct hp_sdc_mlc_priv_s *priv;
unsigned long flags; unsigned long flags;
priv = mlc->priv; priv = mlc->priv;
write_lock_irqsave(&(mlc->lock), flags); write_lock_irqsave(&mlc->lock, flags);
/* Try to down the semaphore -- it should be up. */ /* Try to down the semaphore -- it should be up. */
if (down_trylock(&(mlc->osem))) { BUG_ON(down_trylock(&mlc->osem));
BUG();
goto done;
}
if (mlc->opacket & HIL_DO_ALTER_CTRL) goto do_control; if (mlc->opacket & HIL_DO_ALTER_CTRL)
goto do_control;
do_data: do_data:
if (priv->emtestmode) { if (priv->emtestmode) {
up(&(mlc->osem)); up(&mlc->osem);
goto done; goto done;
} }
/* Shouldn't be sending commands when loop may be busy */ /* Shouldn't be sending commands when loop may be busy */
if (down_trylock(&(mlc->csem))) { BUG_ON(down_trylock(&mlc->csem));
BUG(); up(&mlc->csem);
goto done;
}
up(&(mlc->csem));
priv->trans.actidx = 0; priv->trans.actidx = 0;
priv->trans.idx = 1; priv->trans.idx = 1;
priv->trans.act.semaphore = &(mlc->osem); priv->trans.act.semaphore = &mlc->osem;
priv->trans.endidx = 6; priv->trans.endidx = 6;
priv->tseq[0] = priv->tseq[0] =
HP_SDC_ACT_DATAREG | HP_SDC_ACT_POSTCMD | HP_SDC_ACT_SEMAPHORE; HP_SDC_ACT_DATAREG | HP_SDC_ACT_POSTCMD | HP_SDC_ACT_SEMAPHORE;
priv->tseq[1] = 0x7; priv->tseq[1] = 0x7;
priv->tseq[2] = priv->tseq[2] =
(mlc->opacket & (mlc->opacket &
(HIL_PKT_ADDR_MASK | HIL_PKT_CMD)) (HIL_PKT_ADDR_MASK | HIL_PKT_CMD))
>> HIL_PKT_ADDR_SHIFT; >> HIL_PKT_ADDR_SHIFT;
priv->tseq[3] = priv->tseq[3] =
(mlc->opacket & HIL_PKT_DATA_MASK) (mlc->opacket & HIL_PKT_DATA_MASK)
>> HIL_PKT_DATA_SHIFT; >> HIL_PKT_DATA_SHIFT;
priv->tseq[4] = 0; /* No timeout */ priv->tseq[4] = 0; /* No timeout */
if (priv->tseq[3] == HIL_CMD_DHR) priv->tseq[4] = 1; if (priv->tseq[3] == HIL_CMD_DHR)
priv->tseq[4] = 1;
priv->tseq[5] = HP_SDC_CMD_DO_HIL; priv->tseq[5] = HP_SDC_CMD_DO_HIL;
goto enqueue; goto enqueue;
do_control: do_control:
priv->emtestmode = mlc->opacket & HIL_CTRL_TEST; priv->emtestmode = mlc->opacket & HIL_CTRL_TEST;
/* we cannot emulate this, it should not be used. */ /* we cannot emulate this, it should not be used. */
BUG_ON((mlc->opacket & (HIL_CTRL_APE | HIL_CTRL_IPF)) == HIL_CTRL_APE); BUG_ON((mlc->opacket & (HIL_CTRL_APE | HIL_CTRL_IPF)) == HIL_CTRL_APE);
if ((mlc->opacket & HIL_CTRL_ONLY) == HIL_CTRL_ONLY) goto control_only; if ((mlc->opacket & HIL_CTRL_ONLY) == HIL_CTRL_ONLY)
if (mlc->opacket & HIL_CTRL_APE) { goto control_only;
BUG(); /* Should not send command/data after engaging APE */
goto done; /* Should not send command/data after engaging APE */
} BUG_ON(mlc->opacket & HIL_CTRL_APE);
/* Disengaging APE this way would not be valid either since
/* Disengaging APE this way would not be valid either since
* the loop must be allowed to idle. * the loop must be allowed to idle.
* *
* So, it works out that we really never actually send control * So, it works out that we really never actually send control
* and data when using SDC, we just send the data. * and data when using SDC, we just send the data.
*/ */
goto do_data; goto do_data;
control_only: control_only:
priv->trans.actidx = 0; priv->trans.actidx = 0;
priv->trans.idx = 1; priv->trans.idx = 1;
priv->trans.act.semaphore = &(mlc->osem); priv->trans.act.semaphore = &mlc->osem;
priv->trans.endidx = 4; priv->trans.endidx = 4;
priv->tseq[0] = priv->tseq[0] =
HP_SDC_ACT_PRECMD | HP_SDC_ACT_DATAOUT | HP_SDC_ACT_SEMAPHORE; HP_SDC_ACT_PRECMD | HP_SDC_ACT_DATAOUT | HP_SDC_ACT_SEMAPHORE;
priv->tseq[1] = HP_SDC_CMD_SET_LPC; priv->tseq[1] = HP_SDC_CMD_SET_LPC;
priv->tseq[2] = 1; priv->tseq[2] = 1;
// priv->tseq[3] = (mlc->ddc + 1) | HP_SDC_LPS_ACSUCC; /* priv->tseq[3] = (mlc->ddc + 1) | HP_SDC_LPS_ACSUCC; */
priv->tseq[3] = 0; priv->tseq[3] = 0;
if (mlc->opacket & HIL_CTRL_APE) { if (mlc->opacket & HIL_CTRL_APE) {
priv->tseq[3] |= HP_SDC_LPC_APE_IPF; priv->tseq[3] |= HP_SDC_LPC_APE_IPF;
down_trylock(&(mlc->csem)); down_trylock(&mlc->csem);
} }
enqueue: enqueue:
hp_sdc_enqueue_transaction(&(priv->trans)); hp_sdc_enqueue_transaction(&priv->trans);
done: done:
write_unlock_irqrestore(&(mlc->lock), flags); write_unlock_irqrestore(&mlc->lock, flags);
} }
static int __init hp_sdc_mlc_init(void) static int __init hp_sdc_mlc_init(void)
...@@ -316,14 +325,13 @@ static int __init hp_sdc_mlc_init(void) ...@@ -316,14 +325,13 @@ static int __init hp_sdc_mlc_init(void)
hp_sdc_mlc_priv.emtestmode = 0; hp_sdc_mlc_priv.emtestmode = 0;
hp_sdc_mlc_priv.trans.seq = hp_sdc_mlc_priv.tseq; hp_sdc_mlc_priv.trans.seq = hp_sdc_mlc_priv.tseq;
hp_sdc_mlc_priv.trans.act.semaphore = &(mlc->osem); hp_sdc_mlc_priv.trans.act.semaphore = &mlc->osem;
hp_sdc_mlc_priv.got5x = 0; hp_sdc_mlc_priv.got5x = 0;
mlc->cts = &hp_sdc_mlc_cts; mlc->cts = &hp_sdc_mlc_cts;
mlc->in = &hp_sdc_mlc_in; mlc->in = &hp_sdc_mlc_in;
mlc->out = &hp_sdc_mlc_out; mlc->out = &hp_sdc_mlc_out;
mlc->priv = &hp_sdc_mlc_priv;
mlc->priv = &hp_sdc_mlc_priv;
if (hil_mlc_register(mlc)) { if (hil_mlc_register(mlc)) {
printk(KERN_WARNING PREFIX "Failed to register MLC structure with hil_mlc\n"); printk(KERN_WARNING PREFIX "Failed to register MLC structure with hil_mlc\n");
...@@ -336,10 +344,9 @@ static int __init hp_sdc_mlc_init(void) ...@@ -336,10 +344,9 @@ static int __init hp_sdc_mlc_init(void)
} }
return 0; return 0;
err1: err1:
if (hil_mlc_unregister(mlc)) { if (hil_mlc_unregister(mlc))
printk(KERN_ERR PREFIX "Failed to unregister MLC structure with hil_mlc.\n" printk(KERN_ERR PREFIX "Failed to unregister MLC structure with hil_mlc.\n"
"This is bad. Could cause an oops.\n"); "This is bad. Could cause an oops.\n");
}
err0: err0:
return -EBUSY; return -EBUSY;
} }
...@@ -347,14 +354,14 @@ static int __init hp_sdc_mlc_init(void) ...@@ -347,14 +354,14 @@ static int __init hp_sdc_mlc_init(void)
static void __exit hp_sdc_mlc_exit(void) static void __exit hp_sdc_mlc_exit(void)
{ {
hil_mlc *mlc = &hp_sdc_mlc; hil_mlc *mlc = &hp_sdc_mlc;
if (hp_sdc_release_hil_irq(&hp_sdc_mlc_isr)) {
if (hp_sdc_release_hil_irq(&hp_sdc_mlc_isr))
printk(KERN_ERR PREFIX "Failed to release the raw HIL ISR hook.\n" printk(KERN_ERR PREFIX "Failed to release the raw HIL ISR hook.\n"
"This is bad. Could cause an oops.\n"); "This is bad. Could cause an oops.\n");
}
if (hil_mlc_unregister(mlc)) { if (hil_mlc_unregister(mlc))
printk(KERN_ERR PREFIX "Failed to unregister MLC structure with hil_mlc.\n" printk(KERN_ERR PREFIX "Failed to unregister MLC structure with hil_mlc.\n"
"This is bad. Could cause an oops.\n"); "This is bad. Could cause an oops.\n");
}
} }
module_init(hp_sdc_mlc_init); module_init(hp_sdc_mlc_init);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册