static bool master = true;
static int baudrate; /* Use LIN_DEFAULT_BAUDRATE when not set */
+#ifndef BREAK_BY_BAUD
+static bool break_by_baud = false;
+#else /*BREAK_BY_BAUD*/
+static bool break_by_baud = true;
+#endif /*BREAK_BY_BAUD*/
module_param(master, bool, 0444);
MODULE_PARM_DESC(master, "LIN interface is Master device");
module_param(baudrate, int, 0444);
MODULE_PARM_DESC(baudrate, "Baudrate of LIN interface");
+module_param(break_by_baud, bool, 0444);
+MODULE_PARM_DESC(break_by_baud, "Break is sent by temporal baudrate switching");
static int maxdev = 10; /* MAX number of SLLIN channels;
This can be overridden with
int tx_lim; /* actual limit of bytes to Tx */
int tx_cnt; /* number of already Tx bytes */
char lin_master; /* node is a master node */
+ bool lin_break_by_baud; /* send break character by baudrate switching */
int lin_baud; /* LIN baudrate */
int lin_state; /* state */
char id_to_send; /* there is ID to be sent */
}
}
-#ifndef BREAK_BY_BAUD
- /* We didn't receive Break character -- fake it! */
- if ((sl->rx_cnt == SLLIN_BUFF_BREAK) && (*cp == 0x55)) {
- netdev_dbg(sl->dev, "LIN_RX[%d]: 0x00\n", sl->rx_cnt);
- sl->rx_buff[sl->rx_cnt++] = 0x00;
+ if (!sl->lin_break_by_baud ) {
+ /* We didn't receive Break character -- fake it! */
+ if ((sl->rx_cnt == SLLIN_BUFF_BREAK) && (*cp == 0x55)) {
+ netdev_dbg(sl->dev, "LIN_RX[%d]: 0x00\n",
+ sl->rx_cnt);
+ sl->rx_buff[sl->rx_cnt++] = 0x00;
+ }
}
-#endif /* BREAK_BY_BAUD */
if (sl->rx_cnt < SLLIN_BUFF_LEN) {
netdev_dbg(sl->dev, "LIN_RX[%d]: 0x%02x\n", sl->rx_cnt, *cp);
smp_mb__after_atomic();
#endif
-#ifdef BREAK_BY_BAUD
- if (sl->lin_state != SLSTATE_BREAK_SENT)
+ if (sl->lin_break_by_baud) {
+ if (sl->lin_state != SLSTATE_BREAK_SENT)
+ remains = sl->tx_lim - sl->tx_cnt;
+ else
+ remains = 1;
+ } else {
remains = sl->tx_lim - sl->tx_cnt;
- else
- remains = 1;
-#else
- remains = sl->tx_lim - sl->tx_cnt;
-#endif
+ }
res = tty->ops->write(tty, sl->tx_buff + sl->tx_cnt, remains);
if (res < 0)
}
-#ifdef BREAK_BY_BAUD
-static int sllin_send_break(struct sllin *sl)
+static int sllin_send_break_by_baud(struct sllin *sl)
{
struct tty_struct *tty = sl->tty;
unsigned long break_baud;
break_baud = ((sl->lin_baud * 2) / 3);
sltty_change_speed(tty, break_baud);
- if (tty != NULL && tty->ops != NULL && tty->ops->flush_buffer != NULL) {
+ if (tty->ops->flush_buffer != NULL) {
tty->ops->flush_buffer(tty);
} else {
netdev_dbg(sl->dev, "flush_buffer is not implemented.\n");
return 0;
}
-#else /* BREAK_BY_BAUD */
-static int sllin_send_break(struct sllin *sl)
+static int sllin_send_break_by_usleep(struct sllin *sl)
{
struct tty_struct *tty = sl->tty;
int retval;
return 0;
}
-#endif /* BREAK_BY_BAUD */
+static int sllin_send_break(struct sllin *sl)
+{
+ if (sl->lin_break_by_baud)
+ return sllin_send_break_by_baud(sl);
+ else
+ return sllin_send_break_by_usleep(sl);
+}
static enum hrtimer_restart sllin_rx_timeout_handler(struct hrtimer *hrtimer)
{
break;
case SLSTATE_BREAK_SENT:
-#ifdef BREAK_BY_BAUD
- if (sl->rx_cnt <= SLLIN_BUFF_BREAK)
- continue;
+ if (sl->lin_break_by_baud) {
+ if (sl->rx_cnt <= SLLIN_BUFF_BREAK)
+ continue;
- res = sltty_change_speed(tty, sl->lin_baud);
-#endif
+ sltty_change_speed(tty, sl->lin_baud);
+ }
sl->lin_state = SLSTATE_ID_SENT;
sllin_send_tx_buff(sl);
sl->lin_baud = (baudrate == 0) ? LIN_DEFAULT_BAUDRATE : baudrate;
pr_debug("sllin: Baudrate set to %u\n", sl->lin_baud);
+ sl->lin_break_by_baud = break_by_baud;
+
+ if (tty->ops->break_ctl == NULL && !sl->lin_break_by_baud) {
+ sl->lin_break_by_baud = true;
+ pr_notice ("sllin: break_ctl, switching to break_by_baud\n");
+ }
+
sl->lin_state = SLSTATE_IDLE;
hrtimer_init(&sl->rx_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
kfree(sllin_devs);
}
-#ifdef BREAK_BY_BAUD
- pr_debug("sllin: Break is generated by baud-rate change.");
-#else
- pr_debug("sllin: Break is generated manually with tiny sleep.");
-#endif
+ if (break_by_baud)
+ pr_debug("sllin: Break is generated by baud-rate change.");
+ else
+ pr_debug("sllin: Break is generated manually with tiny sleep.");
return status;
}