Commit 95575e34 authored by Jean Tourrilhes's avatar Jean Tourrilhes Committed by Linus Torvalds

[IRDA]: Update tekram-sir driver.

From Martin Diehl.

* increase default write-delay to 150msec
* convert to de-virtualized sirdev helpers
parent 87bcdb9f
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
MODULE_PARM(tekram_delay, "i"); MODULE_PARM(tekram_delay, "i");
MODULE_PARM_DESC(tekram_delay, "tekram dongle write complete delay"); MODULE_PARM_DESC(tekram_delay, "tekram dongle write complete delay");
static int tekram_delay = 50; /* default is 50 ms */ static int tekram_delay = 150; /* default is 150 ms */
static int tekram_open(struct sir_dev *); static int tekram_open(struct sir_dev *);
static int tekram_close(struct sir_dev *); static int tekram_close(struct sir_dev *);
...@@ -61,8 +61,10 @@ static struct dongle_driver tekram = { ...@@ -61,8 +61,10 @@ static struct dongle_driver tekram = {
int __init tekram_sir_init(void) int __init tekram_sir_init(void)
{ {
if (tekram_delay < 1 || tekram_delay>500) if (tekram_delay < 1 || tekram_delay > 500)
tekram_delay = 200; tekram_delay = 200;
IRDA_DEBUG(1, "%s - using %d ms delay\n",
tekram.driver_name, tekram_delay);
return irda_register_dongle(&tekram); return irda_register_dongle(&tekram);
} }
...@@ -77,7 +79,8 @@ static int tekram_open(struct sir_dev *dev) ...@@ -77,7 +79,8 @@ static int tekram_open(struct sir_dev *dev)
IRDA_DEBUG(2, "%s()\n", __FUNCTION__); IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
dev->set_dtr_rts(dev, TRUE, TRUE); sirdev_set_dtr_rts(dev, TRUE, TRUE);
qos->baud_rate.bits &= IR_9600|IR_19200|IR_38400|IR_57600|IR_115200; qos->baud_rate.bits &= IR_9600|IR_19200|IR_38400|IR_57600|IR_115200;
qos->min_turn_time.bits = 0x01; /* Needs at least 10 ms */ qos->min_turn_time.bits = 0x01; /* Needs at least 10 ms */
irda_qos_bits_to_value(qos); irda_qos_bits_to_value(qos);
...@@ -92,7 +95,7 @@ static int tekram_close(struct sir_dev *dev) ...@@ -92,7 +95,7 @@ static int tekram_close(struct sir_dev *dev)
IRDA_DEBUG(2, "%s()\n", __FUNCTION__); IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
/* Power off dongle */ /* Power off dongle */
dev->set_dtr_rts(dev, FALSE, FALSE); sirdev_set_dtr_rts(dev, FALSE, FALSE);
return 0; return 0;
} }
...@@ -122,19 +125,20 @@ static int tekram_close(struct sir_dev *dev) ...@@ -122,19 +125,20 @@ static int tekram_close(struct sir_dev *dev)
static int tekram_change_speed(struct sir_dev *dev, unsigned speed) static int tekram_change_speed(struct sir_dev *dev, unsigned speed)
{ {
unsigned state = dev->fsm.substate;
unsigned delay = 0; unsigned delay = 0;
unsigned next_state = dev->fsm.substate;
u8 byte; u8 byte;
static int ret = 0;
IRDA_DEBUG(2, "%s()\n", __FUNCTION__); IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
switch(dev->fsm.substate) { switch(state) {
case SIRDEV_STATE_DONGLE_SPEED: case SIRDEV_STATE_DONGLE_SPEED:
switch (speed) { switch (speed) {
default: default:
speed = 9600; speed = 9600;
ret = -EINVAL;
/* fall thru */ /* fall thru */
case 9600: case 9600:
byte = TEKRAM_PW|TEKRAM_9600; byte = TEKRAM_PW|TEKRAM_9600;
...@@ -154,36 +158,34 @@ static int tekram_change_speed(struct sir_dev *dev, unsigned speed) ...@@ -154,36 +158,34 @@ static int tekram_change_speed(struct sir_dev *dev, unsigned speed)
} }
/* Set DTR, Clear RTS */ /* Set DTR, Clear RTS */
dev->set_dtr_rts(dev, TRUE, FALSE); sirdev_set_dtr_rts(dev, TRUE, FALSE);
/* Wait at least 7us */ /* Wait at least 7us */
udelay(14); udelay(14);
/* Write control byte */ /* Write control byte */
dev->write(dev, &byte, 1); sirdev_raw_write(dev, &byte, 1);
dev->speed = speed; dev->speed = speed;
next_state = TEKRAM_STATE_WAIT_SPEED; state = TEKRAM_STATE_WAIT_SPEED;
delay = tekram_delay; /* default: 50 ms */ delay = tekram_delay;
break; break;
case TEKRAM_STATE_WAIT_SPEED: case TEKRAM_STATE_WAIT_SPEED:
/* Set DTR, Set RTS */ /* Set DTR, Set RTS */
dev->set_dtr_rts(dev, TRUE, TRUE); sirdev_set_dtr_rts(dev, TRUE, TRUE);
udelay(50); udelay(50);
break;
return 0;
default: default:
ERROR("%s - undefined state\n", __FUNCTION__); ERROR("%s - undefined state %d\n", __FUNCTION__, state);
return -EINVAL; ret = -EINVAL;
break;
} }
dev->fsm.substate = next_state; dev->fsm.substate = state;
return (delay > 0) ? delay : ret;
return delay;
} }
/* /*
...@@ -200,43 +202,26 @@ static int tekram_change_speed(struct sir_dev *dev, unsigned speed) ...@@ -200,43 +202,26 @@ static int tekram_change_speed(struct sir_dev *dev, unsigned speed)
* operation * operation
*/ */
#define TEKRAM_STATE_WAIT_RESET (SIRDEV_STATE_DONGLE_RESET + 1)
static int tekram_reset(struct sir_dev *dev) static int tekram_reset(struct sir_dev *dev)
{ {
unsigned delay = 0;
unsigned next_state = dev->fsm.substate;
IRDA_DEBUG(2, "%s()\n", __FUNCTION__); IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
switch(dev->fsm.substate) {
case SIRDEV_STATE_DONGLE_RESET:
/* Clear DTR, Set RTS */ /* Clear DTR, Set RTS */
dev->set_dtr_rts(dev, FALSE, TRUE); sirdev_set_dtr_rts(dev, FALSE, TRUE);
next_state = TEKRAM_STATE_WAIT_RESET; /* Should sleep 1 ms */
delay = 1; /* Should sleep 1 ms */ set_current_state(TASK_UNINTERRUPTIBLE);
break; schedule_timeout(MSECS_TO_JIFFIES(1));
case TEKRAM_STATE_WAIT_RESET:
/* Set DTR, Set RTS */ /* Set DTR, Set RTS */
dev->set_dtr_rts(dev, TRUE, TRUE); sirdev_set_dtr_rts(dev, TRUE, TRUE);
/* Wait at least 50 us */ /* Wait at least 50 us */
udelay(75); udelay(75);
return 0; dev->speed = 9600;
default:
ERROR("%s - undefined state\n", __FUNCTION__);
return -EINVAL;
}
dev->fsm.substate = next_state; return 0;
return delay;
} }
MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no>"); MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no>");
......
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