git://ftp.safe.ca
/
safe
/
jmp
/
linux-2.6
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
mxser: use tty_port
[safe/jmp/linux-2.6]
/
drivers
/
char
/
hvsi.c
diff --git
a/drivers/char/hvsi.c
b/drivers/char/hvsi.c
index
8dc205b
..
59c6f9a
100644
(file)
--- a/
drivers/char/hvsi.c
+++ b/
drivers/char/hvsi.c
@@
-39,7
+39,6
@@
#include <linux/module.h>
#include <linux/major.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/major.h>
#include <linux/kernel.h>
-#include <linux/sched.h>
#include <linux/spinlock.h>
#include <linux/sysrq.h>
#include <linux/tty.h>
#include <linux/spinlock.h>
#include <linux/sysrq.h>
#include <linux/tty.h>
@@
-69,7
+68,7
@@
#define __ALIGNED__ __attribute__((__aligned__(sizeof(long))))
struct hvsi_struct {
#define __ALIGNED__ __attribute__((__aligned__(sizeof(long))))
struct hvsi_struct {
- struct
work_struct
writer;
+ struct
delayed_work
writer;
struct work_struct handshaker;
wait_queue_head_t emptyq; /* woken when outbuf is emptied */
wait_queue_head_t stateq; /* woken when HVSI state changes */
struct work_struct handshaker;
wait_queue_head_t emptyq; /* woken when outbuf is emptied */
wait_queue_head_t stateq; /* woken when HVSI state changes */
@@
-247,7
+246,7
@@
static void compact_inbuf(struct hvsi_struct *hp, uint8_t *read_to)
{
int remaining = (int)(hp->inbuf_end - read_to);
{
int remaining = (int)(hp->inbuf_end - read_to);
- pr_debug("%s: %i chars remain\n", __
FUNCTION
__, remaining);
+ pr_debug("%s: %i chars remain\n", __
func
__, remaining);
if (read_to != hp->inbuf)
memmove(hp->inbuf, read_to, remaining);
if (read_to != hp->inbuf)
memmove(hp->inbuf, read_to, remaining);
@@
-311,7
+310,8
@@
static void hvsi_recv_control(struct hvsi_struct *hp, uint8_t *packet,
/* CD went away; no more connection */
pr_debug("hvsi%i: CD dropped\n", hp->index);
hp->mctrl &= TIOCM_CD;
/* CD went away; no more connection */
pr_debug("hvsi%i: CD dropped\n", hp->index);
hp->mctrl &= TIOCM_CD;
- if (!(hp->tty->flags & CLOCAL))
+ /* If userland hasn't done an open(2) yet, hp->tty is NULL. */
+ if (hp->tty && !(hp->tty->flags & CLOCAL))
*to_hangup = hp->tty;
}
break;
*to_hangup = hp->tty;
}
break;
@@
-365,7
+365,7
@@
static int hvsi_version_respond(struct hvsi_struct *hp, uint16_t query_seqno)
packet.u.version = HVSI_VERSION;
packet.query_seqno = query_seqno+1;
packet.u.version = HVSI_VERSION;
packet.query_seqno = query_seqno+1;
- pr_debug("%s: sending %i bytes\n", __
FUNCTION
__, packet.len);
+ pr_debug("%s: sending %i bytes\n", __
func
__, packet.len);
dbg_dump_hex((uint8_t*)&packet, packet.len);
wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.len);
dbg_dump_hex((uint8_t*)&packet, packet.len);
wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.len);
@@
-405,7
+405,7
@@
static void hvsi_insert_chars(struct hvsi_struct *hp, const char *buf, int len)
hp->sysrq = 1;
continue;
} else if (hp->sysrq) {
hp->sysrq = 1;
continue;
} else if (hp->sysrq) {
- handle_sysrq(c,
NULL,
hp->tty);
+ handle_sysrq(c, hp->tty);
hp->sysrq = 0;
continue;
}
hp->sysrq = 0;
continue;
}
@@
-437,7
+437,7
@@
static struct tty_struct *hvsi_recv_data(struct hvsi_struct *hp,
return NULL;
if (overflow > 0) {
return NULL;
if (overflow > 0) {
- pr_debug("%s: got >TTY_THRESHOLD_THROTTLE bytes\n", __
FUNCTION
__);
+ pr_debug("%s: got >TTY_THRESHOLD_THROTTLE bytes\n", __
func
__);
datalen = TTY_THRESHOLD_THROTTLE;
}
datalen = TTY_THRESHOLD_THROTTLE;
}
@@
-448,7
+448,7
@@
static struct tty_struct *hvsi_recv_data(struct hvsi_struct *hp,
* we still have more data to deliver, so we need to save off the
* overflow and send it later
*/
* we still have more data to deliver, so we need to save off the
* overflow and send it later
*/
- pr_debug("%s: deferring overflow\n", __
FUNCTION
__);
+ pr_debug("%s: deferring overflow\n", __
func
__);
memcpy(hp->throttle_buf, data + TTY_THRESHOLD_THROTTLE, overflow);
hp->n_throttle = overflow;
}
memcpy(hp->throttle_buf, data + TTY_THRESHOLD_THROTTLE, overflow);
hp->n_throttle = overflow;
}
@@
-474,11
+474,11
@@
static int hvsi_load_chunk(struct hvsi_struct *hp, struct tty_struct **flip,
chunklen = hvsi_read(hp, hp->inbuf_end, HVSI_MAX_READ);
if (chunklen == 0) {
chunklen = hvsi_read(hp, hp->inbuf_end, HVSI_MAX_READ);
if (chunklen == 0) {
- pr_debug("%s: 0-length read\n", __
FUNCTION
__);
+ pr_debug("%s: 0-length read\n", __
func
__);
return 0;
}
return 0;
}
- pr_debug("%s: got %i bytes\n", __
FUNCTION
__, chunklen);
+ pr_debug("%s: got %i bytes\n", __
func
__, chunklen);
dbg_dump_hex(hp->inbuf_end, chunklen);
hp->inbuf_end += chunklen;
dbg_dump_hex(hp->inbuf_end, chunklen);
hp->inbuf_end += chunklen;
@@
-495,7
+495,7
@@
static int hvsi_load_chunk(struct hvsi_struct *hp, struct tty_struct **flip,
continue;
}
continue;
}
- pr_debug("%s: handling %i-byte packet\n", __
FUNCTION
__,
+ pr_debug("%s: handling %i-byte packet\n", __
func
__,
len_packet(packet));
dbg_dump_packet(packet);
len_packet(packet));
dbg_dump_packet(packet);
@@
-526,7
+526,7
@@
static int hvsi_load_chunk(struct hvsi_struct *hp, struct tty_struct **flip,
packet += len_packet(packet);
if (*hangup || *handshake) {
packet += len_packet(packet);
if (*hangup || *handshake) {
- pr_debug("%s: hangup or handshake\n", __
FUNCTION
__);
+ pr_debug("%s: hangup or handshake\n", __
func
__);
/*
* we need to send the hangup now before receiving any more data.
* If we get "data, hangup, data", we can't deliver the second
/*
* we need to send the hangup now before receiving any more data.
* If we get "data, hangup, data", we can't deliver the second
@@
-543,7
+543,7
@@
static int hvsi_load_chunk(struct hvsi_struct *hp, struct tty_struct **flip,
static void hvsi_send_overflow(struct hvsi_struct *hp)
{
static void hvsi_send_overflow(struct hvsi_struct *hp)
{
- pr_debug("%s: delivering %i bytes overflow\n", __
FUNCTION
__,
+ pr_debug("%s: delivering %i bytes overflow\n", __
func
__,
hp->n_throttle);
hvsi_insert_chars(hp, hp->throttle_buf, hp->n_throttle);
hp->n_throttle);
hvsi_insert_chars(hp, hp->throttle_buf, hp->n_throttle);
@@
-554,7
+554,7
@@
static void hvsi_send_overflow(struct hvsi_struct *hp)
* must get all pending data because we only get an irq on empty->non-empty
* transition
*/
* must get all pending data because we only get an irq on empty->non-empty
* transition
*/
-static irqreturn_t hvsi_interrupt(int irq, void *arg
, struct pt_regs *regs
)
+static irqreturn_t hvsi_interrupt(int irq, void *arg)
{
struct hvsi_struct *hp = (struct hvsi_struct *)arg;
struct tty_struct *flip;
{
struct hvsi_struct *hp = (struct hvsi_struct *)arg;
struct tty_struct *flip;
@@
-563,7
+563,7
@@
static irqreturn_t hvsi_interrupt(int irq, void *arg, struct pt_regs *regs)
unsigned long flags;
int again = 1;
unsigned long flags;
int again = 1;
- pr_debug("%s\n", __
FUNCTION
__);
+ pr_debug("%s\n", __
func
__);
while (again) {
spin_lock_irqsave(&hp->lock, flags);
while (again) {
spin_lock_irqsave(&hp->lock, flags);
@@
-615,7
+615,7
@@
static int __init poll_for_state(struct hvsi_struct *hp, int state)
unsigned long end_jiffies = jiffies + HVSI_TIMEOUT;
for (;;) {
unsigned long end_jiffies = jiffies + HVSI_TIMEOUT;
for (;;) {
- hvsi_interrupt(hp->virq, (void *)hp
, NULL
); /* get pending data */
+ hvsi_interrupt(hp->virq, (void *)hp); /* get pending data */
if (hp->state == state)
return 0;
if (hp->state == state)
return 0;
@@
-647,7
+647,7
@@
static int hvsi_query(struct hvsi_struct *hp, uint16_t verb)
packet.seqno = atomic_inc_return(&hp->seqno);
packet.verb = verb;
packet.seqno = atomic_inc_return(&hp->seqno);
packet.verb = verb;
- pr_debug("%s: sending %i bytes\n", __
FUNCTION
__, packet.len);
+ pr_debug("%s: sending %i bytes\n", __
func
__, packet.len);
dbg_dump_hex((uint8_t*)&packet, packet.len);
wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.len);
dbg_dump_hex((uint8_t*)&packet, packet.len);
wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.len);
@@
-674,7
+674,7
@@
static int hvsi_get_mctrl(struct hvsi_struct *hp)
return ret;
}
return ret;
}
- pr_debug("%s: mctrl 0x%x\n", __
FUNCTION
__, hp->mctrl);
+ pr_debug("%s: mctrl 0x%x\n", __
func
__, hp->mctrl);
return 0;
}
return 0;
}
@@
-694,7
+694,7
@@
static int hvsi_set_mctrl(struct hvsi_struct *hp, uint16_t mctrl)
if (mctrl & TIOCM_DTR)
packet.word = HVSI_TSDTR;
if (mctrl & TIOCM_DTR)
packet.word = HVSI_TSDTR;
- pr_debug("%s: sending %i bytes\n", __
FUNCTION
__, packet.len);
+ pr_debug("%s: sending %i bytes\n", __
func
__, packet.len);
dbg_dump_hex((uint8_t*)&packet, packet.len);
wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.len);
dbg_dump_hex((uint8_t*)&packet, packet.len);
wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.len);
@@
-743,9
+743,10
@@
static int hvsi_handshake(struct hvsi_struct *hp)
return 0;
}
return 0;
}
-static void hvsi_handshaker(
void *arg
)
+static void hvsi_handshaker(
struct work_struct *work
)
{
{
- struct hvsi_struct *hp = (struct hvsi_struct *)arg;
+ struct hvsi_struct *hp =
+ container_of(work, struct hvsi_struct, handshaker);
if (hvsi_handshake(hp) >= 0)
return;
if (hvsi_handshake(hp) >= 0)
return;
@@
-789,7
+790,7
@@
static void hvsi_close_protocol(struct hvsi_struct *hp)
packet.len = 6;
packet.verb = VSV_CLOSE_PROTOCOL;
packet.len = 6;
packet.verb = VSV_CLOSE_PROTOCOL;
- pr_debug("%s: sending %i bytes\n", __
FUNCTION
__, packet.len);
+ pr_debug("%s: sending %i bytes\n", __
func
__, packet.len);
dbg_dump_hex((uint8_t*)&packet, packet.len);
hvc_put_chars(hp->vtermno, (char *)&packet, packet.len);
dbg_dump_hex((uint8_t*)&packet, packet.len);
hvc_put_chars(hp->vtermno, (char *)&packet, packet.len);
@@
-802,7
+803,7
@@
static int hvsi_open(struct tty_struct *tty, struct file *filp)
int line = tty->index;
int ret;
int line = tty->index;
int ret;
- pr_debug("%s\n", __
FUNCTION
__);
+ pr_debug("%s\n", __
func
__);
if (line < 0 || line >= hvsi_count)
return -ENODEV;
if (line < 0 || line >= hvsi_count)
return -ENODEV;
@@
-867,7
+868,7
@@
static void hvsi_close(struct tty_struct *tty, struct file *filp)
struct hvsi_struct *hp = tty->driver_data;
unsigned long flags;
struct hvsi_struct *hp = tty->driver_data;
unsigned long flags;
- pr_debug("%s\n", __
FUNCTION
__);
+ pr_debug("%s\n", __
func
__);
if (tty_hung_up_p(filp))
return;
if (tty_hung_up_p(filp))
return;
@@
-919,7
+920,7
@@
static void hvsi_hangup(struct tty_struct *tty)
struct hvsi_struct *hp = tty->driver_data;
unsigned long flags;
struct hvsi_struct *hp = tty->driver_data;
unsigned long flags;
- pr_debug("%s\n", __
FUNCTION
__);
+ pr_debug("%s\n", __
func
__);
spin_lock_irqsave(&hp->lock, flags);
spin_lock_irqsave(&hp->lock, flags);
@@
-941,7
+942,7
@@
static void hvsi_push(struct hvsi_struct *hp)
n = hvsi_put_chars(hp, hp->outbuf, hp->n_outbuf);
if (n > 0) {
/* success */
n = hvsi_put_chars(hp, hp->outbuf, hp->n_outbuf);
if (n > 0) {
/* success */
- pr_debug("%s: wrote %i chars\n", __
FUNCTION
__, n);
+ pr_debug("%s: wrote %i chars\n", __
func
__, n);
hp->n_outbuf = 0;
} else if (n == -EIO) {
__set_state(hp, HVSI_FSP_DIED);
hp->n_outbuf = 0;
} else if (n == -EIO) {
__set_state(hp, HVSI_FSP_DIED);
@@
-950,9
+951,10
@@
static void hvsi_push(struct hvsi_struct *hp)
}
/* hvsi_write_worker will keep rescheduling itself until outbuf is empty */
}
/* hvsi_write_worker will keep rescheduling itself until outbuf is empty */
-static void hvsi_write_worker(
void *arg
)
+static void hvsi_write_worker(
struct work_struct *work
)
{
{
- struct hvsi_struct *hp = (struct hvsi_struct *)arg;
+ struct hvsi_struct *hp =
+ container_of(work, struct hvsi_struct, writer.work);
unsigned long flags;
#ifdef DEBUG
static long start_j = 0;
unsigned long flags;
#ifdef DEBUG
static long start_j = 0;
@@
-963,7
+965,7
@@
static void hvsi_write_worker(void *arg)
spin_lock_irqsave(&hp->lock, flags);
spin_lock_irqsave(&hp->lock, flags);
- pr_debug("%s: %i chars in buffer\n", __
FUNCTION
__, hp->n_outbuf);
+ pr_debug("%s: %i chars in buffer\n", __
func
__, hp->n_outbuf);
if (!is_open(hp)) {
/*
if (!is_open(hp)) {
/*
@@
-981,15
+983,12
@@
static void hvsi_write_worker(void *arg)
schedule_delayed_work(&hp->writer, 10);
else {
#ifdef DEBUG
schedule_delayed_work(&hp->writer, 10);
else {
#ifdef DEBUG
- pr_debug("%s: outbuf emptied after %li jiffies\n", __
FUNCTION
__,
+ pr_debug("%s: outbuf emptied after %li jiffies\n", __
func
__,
jiffies - start_j);
start_j = 0;
#endif /* DEBUG */
wake_up_all(&hp->emptyq);
jiffies - start_j);
start_j = 0;
#endif /* DEBUG */
wake_up_all(&hp->emptyq);
- if (test_bit(TTY_DO_WRITE_WAKEUP, &hp->tty->flags)
- && hp->tty->ldisc.write_wakeup)
- hp->tty->ldisc.write_wakeup(hp->tty);
- wake_up_interruptible(&hp->tty->write_wait);
+ tty_wakeup(hp->tty);
}
out:
}
out:
@@
-1021,11
+1020,11
@@
static int hvsi_write(struct tty_struct *tty,
spin_lock_irqsave(&hp->lock, flags);
spin_lock_irqsave(&hp->lock, flags);
- pr_debug("%s: %i chars in buffer\n", __
FUNCTION
__, hp->n_outbuf);
+ pr_debug("%s: %i chars in buffer\n", __
func
__, hp->n_outbuf);
if (!is_open(hp)) {
/* we're either closing or not yet open; don't accept data */
if (!is_open(hp)) {
/* we're either closing or not yet open; don't accept data */
- pr_debug("%s: not open\n", __
FUNCTION
__);
+ pr_debug("%s: not open\n", __
func
__);
goto out;
}
goto out;
}
@@
-1059,7
+1058,7
@@
out:
spin_unlock_irqrestore(&hp->lock, flags);
if (total != origcount)
spin_unlock_irqrestore(&hp->lock, flags);
if (total != origcount)
- pr_debug("%s: wanted %i, only wrote %i\n", __
FUNCTION
__, origcount,
+ pr_debug("%s: wanted %i, only wrote %i\n", __
func
__, origcount,
total);
return total;
total);
return total;
@@
-1073,7
+1072,7
@@
static void hvsi_throttle(struct tty_struct *tty)
{
struct hvsi_struct *hp = (struct hvsi_struct *)tty->driver_data;
{
struct hvsi_struct *hp = (struct hvsi_struct *)tty->driver_data;
- pr_debug("%s\n", __
FUNCTION
__);
+ pr_debug("%s\n", __
func
__);
h_vio_signal(hp->vtermno, VIO_IRQ_DISABLE);
}
h_vio_signal(hp->vtermno, VIO_IRQ_DISABLE);
}
@@
-1084,7
+1083,7
@@
static void hvsi_unthrottle(struct tty_struct *tty)
unsigned long flags;
int shouldflip = 0;
unsigned long flags;
int shouldflip = 0;
- pr_debug("%s\n", __
FUNCTION
__);
+ pr_debug("%s\n", __
func
__);
spin_lock_irqsave(&hp->lock, flags);
if (hp->n_throttle) {
spin_lock_irqsave(&hp->lock, flags);
if (hp->n_throttle) {
@@
-1132,7
+1131,7
@@
static int hvsi_tiocmset(struct tty_struct *tty, struct file *file,
}
}
-static struct tty_operations hvsi_ops = {
+static
const
struct tty_operations hvsi_ops = {
.open = hvsi_open,
.close = hvsi_close,
.write = hvsi_write,
.open = hvsi_open,
.close = hvsi_close,
.write = hvsi_write,
@@
-1161,6
+1160,8
@@
static int __init hvsi_init(void)
hvsi_driver->type = TTY_DRIVER_TYPE_SYSTEM;
hvsi_driver->init_termios = tty_std_termios;
hvsi_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL;
hvsi_driver->type = TTY_DRIVER_TYPE_SYSTEM;
hvsi_driver->init_termios = tty_std_termios;
hvsi_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL;
+ hvsi_driver->init_termios.c_ispeed = 9600;
+ hvsi_driver->init_termios.c_ospeed = 9600;
hvsi_driver->flags = TTY_DRIVER_REAL_RAW;
tty_set_operations(hvsi_driver, &hvsi_ops);
hvsi_driver->flags = TTY_DRIVER_REAL_RAW;
tty_set_operations(hvsi_driver, &hvsi_ops);
@@
-1276,11
+1277,10
@@
static int __init hvsi_console_init(void)
vty != NULL;
vty = of_find_compatible_node(vty, "serial", "hvterm-protocol")) {
struct hvsi_struct *hp;
vty != NULL;
vty = of_find_compatible_node(vty, "serial", "hvterm-protocol")) {
struct hvsi_struct *hp;
- uint32_t *vtermno;
- uint32_t *irq;
+ const uint32_t *vtermno, *irq;
- vtermno =
(uint32_t *)
get_property(vty, "reg", NULL);
- irq =
(uint32_t *)
get_property(vty, "interrupts", NULL);
+ vtermno =
of_
get_property(vty, "reg", NULL);
+ irq =
of_
get_property(vty, "interrupts", NULL);
if (!vtermno || !irq)
continue;
if (!vtermno || !irq)
continue;
@@
-1290,8
+1290,8
@@
static int __init hvsi_console_init(void)
}
hp = &hvsi_ports[hvsi_count];
}
hp = &hvsi_ports[hvsi_count];
- INIT_
WORK(&hp->writer, hvsi_write_worker, hp
);
- INIT_WORK(&hp->handshaker, hvsi_handshaker
, hp
);
+ INIT_
DELAYED_WORK(&hp->writer, hvsi_write_worker
);
+ INIT_WORK(&hp->handshaker, hvsi_handshaker);
init_waitqueue_head(&hp->emptyq);
init_waitqueue_head(&hp->stateq);
spin_lock_init(&hp->lock);
init_waitqueue_head(&hp->emptyq);
init_waitqueue_head(&hp->stateq);
spin_lock_init(&hp->lock);
@@
-1299,13
+1299,12
@@
static int __init hvsi_console_init(void)
hp->inbuf_end = hp->inbuf;
hp->state = HVSI_CLOSED;
hp->vtermno = *vtermno;
hp->inbuf_end = hp->inbuf;
hp->state = HVSI_CLOSED;
hp->vtermno = *vtermno;
- hp->virq =
virt_irq_create_mapping(
irq[0]);
+ hp->virq =
irq_create_mapping(NULL,
irq[0]);
if (hp->virq == NO_IRQ) {
printk(KERN_ERR "%s: couldn't create irq mapping for 0x%x\n",
if (hp->virq == NO_IRQ) {
printk(KERN_ERR "%s: couldn't create irq mapping for 0x%x\n",
- __
FUNCTION__, hp->virq
);
+ __
func__, irq[0]
);
continue;
continue;
- } else
- hp->virq = irq_offset_up(hp->virq);
+ }
hvsi_count++;
}
hvsi_count++;
}