diff options
Diffstat (limited to 'drivers/tty/hvc')
| -rw-r--r-- | drivers/tty/hvc/hvc_console.c | 19 | ||||
| -rw-r--r-- | drivers/tty/hvc/hvc_dcc.c | 63 | ||||
| -rw-r--r-- | drivers/tty/hvc/hvc_iucv.c | 106 | ||||
| -rw-r--r-- | drivers/tty/hvc/hvc_opal.c | 34 | ||||
| -rw-r--r-- | drivers/tty/hvc/hvc_rtas.c | 12 | ||||
| -rw-r--r-- | drivers/tty/hvc/hvc_tile.c | 10 | ||||
| -rw-r--r-- | drivers/tty/hvc/hvc_udbg.c | 9 | ||||
| -rw-r--r-- | drivers/tty/hvc/hvc_vio.c | 5 | ||||
| -rw-r--r-- | drivers/tty/hvc/hvc_xen.c | 37 | ||||
| -rw-r--r-- | drivers/tty/hvc/hvsi_lib.c | 26 | 
10 files changed, 200 insertions, 121 deletions
diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c index 9eba119bcdd..4fcec1d793a 100644 --- a/drivers/tty/hvc/hvc_console.c +++ b/drivers/tty/hvc/hvc_console.c @@ -31,6 +31,7 @@  #include <linux/list.h>  #include <linux/module.h>  #include <linux/major.h> +#include <linux/atomic.h>  #include <linux/sysrq.h>  #include <linux/tty.h>  #include <linux/tty_flip.h> @@ -70,6 +71,9 @@ static struct task_struct *hvc_task;  /* Picks up late kicks after list walk but before schedule() */  static int hvc_kicked; +/* hvc_init is triggered from hvc_alloc, i.e. only when actually used */ +static atomic_t hvc_needs_init __read_mostly = ATOMIC_INIT(-1); +  static int hvc_init(void);  #ifdef CONFIG_MAGIC_SYSRQ @@ -186,7 +190,7 @@ static struct tty_driver *hvc_console_device(struct console *c, int *index)  	return hvc_driver;  } -static int __init hvc_console_setup(struct console *co, char *options) +static int hvc_console_setup(struct console *co, char *options)  {	  	if (co->index < 0 || co->index >= MAX_NR_HVC_CONSOLES)  		return -ENODEV; @@ -756,10 +760,17 @@ static int khvcd(void *unused)  			if (poll_mask == 0)  				schedule();  			else { +				unsigned long j_timeout; +  				if (timeout < MAX_TIMEOUT)  					timeout += (timeout >> 6) + 1; -				msleep_interruptible(timeout); +				/* +				 * We don't use msleep_interruptible otherwise +				 * "kick" will fail to wake us up +				 */ +				j_timeout = msecs_to_jiffies(timeout) + 1; +				schedule_timeout_interruptible(j_timeout);  			}  		}  		__set_current_state(TASK_RUNNING); @@ -788,7 +799,7 @@ static int hvc_tiocmset(struct tty_struct *tty,  }  #ifdef CONFIG_CONSOLE_POLL -int hvc_poll_init(struct tty_driver *driver, int line, char *options) +static int hvc_poll_init(struct tty_driver *driver, int line, char *options)  {  	return 0;  } @@ -851,7 +862,7 @@ struct hvc_struct *hvc_alloc(uint32_t vtermno, int data,  	int i;  	/* We wait until a driver actually comes along */ -	if (!hvc_driver) { +	if (atomic_inc_not_zero(&hvc_needs_init)) {  		int err = hvc_init();  		if (err)  			return ERR_PTR(err); diff --git a/drivers/tty/hvc/hvc_dcc.c b/drivers/tty/hvc/hvc_dcc.c index 44fbebab507..809920d80a6 100644 --- a/drivers/tty/hvc/hvc_dcc.c +++ b/drivers/tty/hvc/hvc_dcc.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2010, Code Aurora Forum. All rights reserved. +/* Copyright (c) 2010, 2014 The Linux Foundation. All rights reserved.   *   * This program is free software; you can redistribute it and/or modify   * it under the terms of the GNU General Public License version 2 and @@ -8,20 +8,11 @@   * but WITHOUT ANY WARRANTY; without even the implied warranty of   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA.   */ -#include <linux/console.h> -#include <linux/delay.h> -#include <linux/err.h>  #include <linux/init.h> -#include <linux/moduleparam.h> -#include <linux/types.h> +#include <asm/dcc.h>  #include <asm/processor.h>  #include "hvc_console.h" @@ -30,35 +21,6 @@  #define DCC_STATUS_RX		(1 << 30)  #define DCC_STATUS_TX		(1 << 29) -static inline u32 __dcc_getstatus(void) -{ -	u32 __ret; -	asm volatile("mrc p14, 0, %0, c0, c1, 0	@ read comms ctrl reg" -		: "=r" (__ret) : : "cc"); - -	return __ret; -} - - -static inline char __dcc_getchar(void) -{ -	char __c; - -	asm volatile("mrc p14, 0, %0, c0, c5, 0	@ read comms data reg" -		: "=r" (__c)); -	isb(); - -	return __c; -} - -static inline void __dcc_putchar(char c) -{ -	asm volatile("mcr p14, 0, %0, c0, c5, 0	@ write a char" -		: /* no output register */ -		: "r" (c)); -	isb(); -} -  static int hvc_dcc_put_chars(uint32_t vt, const char *buf, int count)  {  	int i; @@ -86,6 +48,21 @@ static int hvc_dcc_get_chars(uint32_t vt, char *buf, int count)  	return i;  } +static bool hvc_dcc_check(void) +{ +	unsigned long time = jiffies + (HZ / 10); + +	/* Write a test character to check if it is handled */ +	__dcc_putchar('\n'); + +	while (time_is_after_jiffies(time)) { +		if (!(__dcc_getstatus() & DCC_STATUS_TX)) +			return true; +	} + +	return false; +} +  static const struct hv_ops hvc_dcc_get_put_ops = {  	.get_chars = hvc_dcc_get_chars,  	.put_chars = hvc_dcc_put_chars, @@ -93,6 +70,9 @@ static const struct hv_ops hvc_dcc_get_put_ops = {  static int __init hvc_dcc_console_init(void)  { +	if (!hvc_dcc_check()) +		return -ENODEV; +  	hvc_instantiate(0, 0, &hvc_dcc_get_put_ops);  	return 0;  } @@ -100,6 +80,9 @@ console_initcall(hvc_dcc_console_init);  static int __init hvc_dcc_init(void)  { +	if (!hvc_dcc_check()) +		return -ENODEV; +  	hvc_alloc(0, 0, &hvc_dcc_get_put_ops, 128);  	return 0;  } diff --git a/drivers/tty/hvc/hvc_iucv.c b/drivers/tty/hvc/hvc_iucv.c index fd17a9b804b..ea74460f363 100644 --- a/drivers/tty/hvc/hvc_iucv.c +++ b/drivers/tty/hvc/hvc_iucv.c @@ -77,6 +77,7 @@ struct hvc_iucv_private {  	struct list_head	tty_outqueue;	/* outgoing IUCV messages */  	struct list_head	tty_inqueue;	/* incoming IUCV messages */  	struct device		*dev;		/* device structure */ +	u8			info_path[16];	/* IUCV path info (dev attr) */  };  struct iucv_tty_buffer { @@ -126,7 +127,7 @@ static struct iucv_handler hvc_iucv_handler = {   * This function returns the struct hvc_iucv_private instance that corresponds   * to the HVC virtual terminal number specified as parameter @num.   */ -struct hvc_iucv_private *hvc_iucv_get_private(uint32_t num) +static struct hvc_iucv_private *hvc_iucv_get_private(uint32_t num)  {  	if ((num < HVC_IUCV_MAGIC) || (num - HVC_IUCV_MAGIC > hvc_iucv_devices))  		return NULL; @@ -772,18 +773,37 @@ static int hvc_iucv_filter_connreq(u8 ipvmid[8])  static	int hvc_iucv_path_pending(struct iucv_path *path,  				  u8 ipvmid[8], u8 ipuser[16])  { -	struct hvc_iucv_private *priv; +	struct hvc_iucv_private *priv, *tmp; +	u8 wildcard[9] = "lnxhvc  "; +	int i, rc, find_unused;  	u8 nuser_data[16];  	u8 vm_user_id[9]; -	int i, rc; +	ASCEBC(wildcard, sizeof(wildcard)); +	find_unused = !memcmp(wildcard, ipuser, 8); + +	/* First, check if the pending path request is managed by this +	 * IUCV handler: +	 * - find a disconnected device if ipuser contains the wildcard +	 * - find the device that matches the terminal ID in ipuser +	 */  	priv = NULL; -	for (i = 0; i < hvc_iucv_devices; i++) -		if (hvc_iucv_table[i] && -		    (0 == memcmp(hvc_iucv_table[i]->srv_name, ipuser, 8))) { -			priv = hvc_iucv_table[i]; +	for (i = 0; i < hvc_iucv_devices; i++) { +		tmp = hvc_iucv_table[i]; +		if (!tmp) +			continue; + +		if (find_unused) { +			spin_lock(&tmp->lock); +			if (tmp->iucv_state == IUCV_DISCONN) +				priv = tmp; +			spin_unlock(&tmp->lock); + +		} else if (!memcmp(tmp->srv_name, ipuser, 8)) +				priv = tmp; +		if (priv)  			break; -		} +	}  	if (!priv)  		return -ENODEV; @@ -826,6 +846,10 @@ static	int hvc_iucv_path_pending(struct iucv_path *path,  	priv->path = path;  	priv->iucv_state = IUCV_CONNECTED; +	/* store path information */ +	memcpy(priv->info_path, ipvmid, 8); +	memcpy(priv->info_path + 8, ipuser + 8, 8); +  	/* flush buffered output data... */  	schedule_delayed_work(&priv->sndbuf_work, 5); @@ -960,6 +984,49 @@ static int hvc_iucv_pm_restore_thaw(struct device *dev)  	return 0;  } +static ssize_t hvc_iucv_dev_termid_show(struct device *dev, +					struct device_attribute *attr, +					char *buf) +{ +	struct hvc_iucv_private *priv = dev_get_drvdata(dev); +	size_t len; + +	len = sizeof(priv->srv_name); +	memcpy(buf, priv->srv_name, len); +	EBCASC(buf, len); +	buf[len++] = '\n'; +	return len; +} + +static ssize_t hvc_iucv_dev_state_show(struct device *dev, +					struct device_attribute *attr, +					char *buf) +{ +	struct hvc_iucv_private *priv = dev_get_drvdata(dev); +	return sprintf(buf, "%u:%u\n", priv->iucv_state, priv->tty_state); +} + +static ssize_t hvc_iucv_dev_peer_show(struct device *dev, +				      struct device_attribute *attr, +				      char *buf) +{ +	struct hvc_iucv_private *priv = dev_get_drvdata(dev); +	char vmid[9], ipuser[9]; + +	memset(vmid, 0, sizeof(vmid)); +	memset(ipuser, 0, sizeof(ipuser)); + +	spin_lock_bh(&priv->lock); +	if (priv->iucv_state == IUCV_CONNECTED) { +		memcpy(vmid, priv->info_path, 8); +		memcpy(ipuser, priv->info_path + 8, 8); +	} +	spin_unlock_bh(&priv->lock); +	EBCASC(ipuser, 8); + +	return sprintf(buf, "%s:%s\n", vmid, ipuser); +} +  /* HVC operations */  static const struct hv_ops hvc_iucv_ops = { @@ -985,6 +1052,25 @@ static struct device_driver hvc_iucv_driver = {  	.pm   = &hvc_iucv_pm_ops,  }; +/* IUCV HVC device attributes */ +static DEVICE_ATTR(termid, 0640, hvc_iucv_dev_termid_show, NULL); +static DEVICE_ATTR(state, 0640, hvc_iucv_dev_state_show, NULL); +static DEVICE_ATTR(peer, 0640, hvc_iucv_dev_peer_show, NULL); +static struct attribute *hvc_iucv_dev_attrs[] = { +	&dev_attr_termid.attr, +	&dev_attr_state.attr, +	&dev_attr_peer.attr, +	NULL, +}; +static struct attribute_group hvc_iucv_dev_attr_group = { +	.attrs = hvc_iucv_dev_attrs, +}; +static const struct attribute_group *hvc_iucv_dev_attr_groups[] = { +	&hvc_iucv_dev_attr_group, +	NULL, +}; + +  /**   * hvc_iucv_alloc() - Allocates a new struct hvc_iucv_private instance   * @id:			hvc_iucv_table index @@ -1046,6 +1132,7 @@ static int __init hvc_iucv_alloc(int id, unsigned int is_console)  	priv->dev->bus = &iucv_bus;  	priv->dev->parent = iucv_root;  	priv->dev->driver = &hvc_iucv_driver; +	priv->dev->groups = hvc_iucv_dev_attr_groups;  	priv->dev->release = (void (*)(struct device *)) kfree;  	rc = device_register(priv->dev);  	if (rc) { @@ -1354,8 +1441,7 @@ out_error_memory:  	mempool_destroy(hvc_iucv_mempool);  	kmem_cache_destroy(hvc_iucv_buffer_cache);  out_error: -	if (hvc_iucv_filter) -		kfree(hvc_iucv_filter); +	kfree(hvc_iucv_filter);  	hvc_iucv_devices = 0; /* ensure that we do not provide any device */  	return rc;  } diff --git a/drivers/tty/hvc/hvc_opal.c b/drivers/tty/hvc/hvc_opal.c index cd69b48f6df..a585079b4b3 100644 --- a/drivers/tty/hvc/hvc_opal.c +++ b/drivers/tty/hvc/hvc_opal.c @@ -61,6 +61,7 @@ static struct hvc_opal_priv *hvc_opal_privs[MAX_NR_HVC_CONSOLES];  /* For early boot console */  static struct hvc_opal_priv hvc_opal_boot_priv;  static u32 hvc_opal_boot_termno; +static bool hvc_opal_event_registered;  static const struct hv_ops hvc_opal_raw_ops = {  	.get_chars = opal_get_chars, @@ -161,6 +162,18 @@ static const struct hv_ops hvc_opal_hvsi_ops = {  	.tiocmset = hvc_opal_hvsi_tiocmset,  }; +static int hvc_opal_console_event(struct notifier_block *nb, +				  unsigned long events, void *change) +{ +	if (events & OPAL_EVENT_CONSOLE_INPUT) +		hvc_kick(); +	return 0; +} + +static struct notifier_block hvc_opal_console_nb = { +	.notifier_call	= hvc_opal_console_event, +}; +  static int hvc_opal_probe(struct platform_device *dev)  {  	const struct hv_ops *ops; @@ -170,6 +183,7 @@ static int hvc_opal_probe(struct platform_device *dev)  	unsigned int termno, boot = 0;  	const __be32 *reg; +  	if (of_device_is_compatible(dev->dev.of_node, "ibm,opal-console-raw")) {  		proto = HV_PROTOCOL_RAW;  		ops = &hvc_opal_raw_ops; @@ -213,12 +227,18 @@ static int hvc_opal_probe(struct platform_device *dev)  		dev->dev.of_node->full_name,  		boot ? " (boot console)" : ""); -	/* We don't do IRQ yet */ +	/* We don't do IRQ ... */  	hp = hvc_alloc(termno, 0, ops, MAX_VIO_PUT_CHARS);  	if (IS_ERR(hp))  		return PTR_ERR(hp);  	dev_set_drvdata(&dev->dev, hp); +	/* ...  but we use OPAL event to kick the console */ +	if (!hvc_opal_event_registered) { +		opal_notifier_register(&hvc_opal_console_nb); +		hvc_opal_event_registered = true; +	} +  	return 0;  } @@ -255,13 +275,7 @@ static int __init hvc_opal_init(void)  	/* Register as a vio device to receive callbacks */  	return platform_driver_register(&hvc_opal_driver);  } -module_init(hvc_opal_init); - -static void __exit hvc_opal_exit(void) -{ -	platform_driver_unregister(&hvc_opal_driver); -} -module_exit(hvc_opal_exit); +device_initcall(hvc_opal_init);  static void udbg_opal_putc(char c)  { @@ -329,7 +343,7 @@ static void udbg_init_opal_common(void)  void __init hvc_opal_init_early(void)  {  	struct device_node *stdout_node = NULL; -	const u32 *termno; +	const __be32 *termno;  	const char *name = NULL;  	const struct hv_ops *ops;  	u32 index; @@ -371,7 +385,7 @@ void __init hvc_opal_init_early(void)  	if (!stdout_node)  		return;  	termno = of_get_property(stdout_node, "reg", NULL); -	index = termno ? *termno : 0; +	index = termno ? be32_to_cpup(termno) : 0;  	if (index >= MAX_NR_HVC_CONSOLES)  		return;  	hvc_opal_privs[index] = &hvc_opal_boot_priv; diff --git a/drivers/tty/hvc/hvc_rtas.c b/drivers/tty/hvc/hvc_rtas.c index 0069bb86ba4..08c87920b74 100644 --- a/drivers/tty/hvc/hvc_rtas.c +++ b/drivers/tty/hvc/hvc_rtas.c @@ -102,17 +102,7 @@ static int __init hvc_rtas_init(void)  	return 0;  } -module_init(hvc_rtas_init); - -/* This will tear down the tty portion of the driver */ -static void __exit hvc_rtas_exit(void) -{ -	/* Really the fun isn't over until the worker thread breaks down and -	 * the tty cleans up */ -	if (hvc_rtas_dev) -		hvc_remove(hvc_rtas_dev); -} -module_exit(hvc_rtas_exit); +device_initcall(hvc_rtas_init);  /* This will happen prior to module init.  There is no tty at this time? */  static int __init hvc_rtas_console_init(void) diff --git a/drivers/tty/hvc/hvc_tile.c b/drivers/tty/hvc/hvc_tile.c index af8cdaa1dcb..df374860037 100644 --- a/drivers/tty/hvc/hvc_tile.c +++ b/drivers/tty/hvc/hvc_tile.c @@ -133,14 +133,14 @@ static int hvc_tile_probe(struct platform_device *pdev)  	int tile_hvc_irq;  	/* Create our IRQ and register it. */ -	tile_hvc_irq = create_irq(); -	if (tile_hvc_irq < 0) +	tile_hvc_irq = irq_alloc_hwirq(-1); +	if (!tile_hvc_irq)  		return -ENXIO;  	tile_irq_activate(tile_hvc_irq, TILE_IRQ_PERCPU);  	hp = hvc_alloc(0, tile_hvc_irq, &hvc_tile_get_put_ops, 128);  	if (IS_ERR(hp)) { -		destroy_irq(tile_hvc_irq); +		irq_free_hwirq(tile_hvc_irq);  		return PTR_ERR(hp);  	}  	dev_set_drvdata(&pdev->dev, hp); @@ -155,7 +155,7 @@ static int hvc_tile_remove(struct platform_device *pdev)  	rc = hvc_remove(hp);  	if (rc == 0) -		destroy_irq(hp->data); +		irq_free_hwirq(hp->data);  	return rc;  } @@ -196,7 +196,7 @@ static int __init hvc_tile_init(void)  #ifndef __tilegx__  	struct hvc_struct *hp;  	hp = hvc_alloc(0, 0, &hvc_tile_get_put_ops, 128); -	return IS_ERR(hp) ? PTR_ERR(hp) : 0; +	return PTR_ERR_OR_ZERO(hp);  #else  	platform_device_register(&hvc_tile_pdev);  	return platform_driver_register(&hvc_tile_driver); diff --git a/drivers/tty/hvc/hvc_udbg.c b/drivers/tty/hvc/hvc_udbg.c index 72228276fe3..9cf573d06a2 100644 --- a/drivers/tty/hvc/hvc_udbg.c +++ b/drivers/tty/hvc/hvc_udbg.c @@ -80,14 +80,7 @@ static int __init hvc_udbg_init(void)  	return 0;  } -module_init(hvc_udbg_init); - -static void __exit hvc_udbg_exit(void) -{ -	if (hvc_udbg_dev) -		hvc_remove(hvc_udbg_dev); -} -module_exit(hvc_udbg_exit); +device_initcall(hvc_udbg_init);  static int __init hvc_udbg_console_init(void)  { diff --git a/drivers/tty/hvc/hvc_vio.c b/drivers/tty/hvc/hvc_vio.c index c791b18cdd0..b594abfbf21 100644 --- a/drivers/tty/hvc/hvc_vio.c +++ b/drivers/tty/hvc/hvc_vio.c @@ -48,6 +48,7 @@  #include <asm/prom.h>  #include <asm/hvsi.h>  #include <asm/udbg.h> +#include <asm/machdep.h>  #include "hvc_console.h" @@ -457,7 +458,9 @@ void __init hvc_vio_init_early(void)  	if (hvterm_priv0.proto == HV_PROTOCOL_HVSI)  		goto out;  #endif -	add_preferred_console("hvc", 0, NULL); +	/* Check whether the user has requested a different console. */ +	if (!strstr(cmd_line, "console=")) +		add_preferred_console("hvc", 0, NULL);  	hvc_instantiate(0, 0, ops);  out:  	of_node_put(stdout_node); diff --git a/drivers/tty/hvc/hvc_xen.c b/drivers/tty/hvc/hvc_xen.c index e61c36cbb86..2dc2831840c 100644 --- a/drivers/tty/hvc/hvc_xen.c +++ b/drivers/tty/hvc/hvc_xen.c @@ -183,7 +183,7 @@ static int dom0_write_console(uint32_t vtermno, const char *str, int len)  {  	int rc = HYPERVISOR_console_io(CONSOLEIO_write, len, (char *)str);  	if (rc < 0) -		return 0; +		return rc;  	return len;  } @@ -561,18 +561,7 @@ static int __init xen_hvc_init(void)  #endif  	return r;  } - -static void __exit xen_hvc_fini(void) -{ -	struct xencons_info *entry, *next; - -	if (list_empty(&xenconsoles)) -			return; - -	list_for_each_entry_safe(entry, next, &xenconsoles, list) { -		xen_console_remove(entry); -	} -} +device_initcall(xen_hvc_init);  static int xen_cons_init(void)  { @@ -598,10 +587,6 @@ static int xen_cons_init(void)  	hvc_instantiate(HVC_COOKIE, 0, ops);  	return 0;  } - - -module_init(xen_hvc_init); -module_exit(xen_hvc_fini);  console_initcall(xen_cons_init);  #ifdef CONFIG_EARLY_PRINTK @@ -636,12 +621,28 @@ struct console xenboot_console = {  	.name		= "xenboot",  	.write		= xenboot_write_console,  	.flags		= CON_PRINTBUFFER | CON_BOOT | CON_ANYTIME, +	.index		= -1,  };  #endif	/* CONFIG_EARLY_PRINTK */  void xen_raw_console_write(const char *str)  { -	dom0_write_console(0, str, strlen(str)); +	ssize_t len = strlen(str); +	int rc = 0; + +	if (xen_domain()) { +		rc = dom0_write_console(0, str, len); +#ifdef CONFIG_X86 +		if (rc == -ENOSYS && xen_hvm_domain()) +			goto outb_print; + +	} else if (xen_cpuid_base()) { +		int i; +outb_print: +		for (i = 0; i < len; i++) +			outb(str[i], 0xe9); +#endif +	}  }  void xen_raw_printk(const char *fmt, ...) diff --git a/drivers/tty/hvc/hvsi_lib.c b/drivers/tty/hvc/hvsi_lib.c index ac2767100df..7ae6c293e51 100644 --- a/drivers/tty/hvc/hvsi_lib.c +++ b/drivers/tty/hvc/hvsi_lib.c @@ -1,5 +1,4 @@  #include <linux/types.h> -#include <linux/init.h>  #include <linux/delay.h>  #include <linux/slab.h>  #include <linux/console.h> @@ -9,7 +8,7 @@  static int hvsi_send_packet(struct hvsi_priv *pv, struct hvsi_header *packet)  { -	packet->seqno = atomic_inc_return(&pv->seqno); +	packet->seqno = cpu_to_be16(atomic_inc_return(&pv->seqno));  	/* Assumes that always succeeds, works in practice */  	return pv->put_chars(pv->termno, (char *)packet, packet->len); @@ -28,7 +27,7 @@ static void hvsi_start_handshake(struct hvsi_priv *pv)  	/* Send version query */  	q.hdr.type = VS_QUERY_PACKET_HEADER;  	q.hdr.len = sizeof(struct hvsi_query); -	q.verb = VSV_SEND_VERSION_NUMBER; +	q.verb = cpu_to_be16(VSV_SEND_VERSION_NUMBER);  	hvsi_send_packet(pv, &q.hdr);  } @@ -40,7 +39,7 @@ static int hvsi_send_close(struct hvsi_priv *pv)  	ctrl.hdr.type = VS_CONTROL_PACKET_HEADER;  	ctrl.hdr.len = sizeof(struct hvsi_control); -	ctrl.verb = VSV_CLOSE_PROTOCOL; +	ctrl.verb = cpu_to_be16(VSV_CLOSE_PROTOCOL);  	return hvsi_send_packet(pv, &ctrl.hdr);  } @@ -69,14 +68,14 @@ static void hvsi_got_control(struct hvsi_priv *pv)  {  	struct hvsi_control *pkt = (struct hvsi_control *)pv->inbuf; -	switch (pkt->verb) { +	switch (be16_to_cpu(pkt->verb)) {  	case VSV_CLOSE_PROTOCOL:  		/* We restart the handshaking */  		hvsi_start_handshake(pv);  		break;  	case VSV_MODEM_CTL_UPDATE:  		/* Transition of carrier detect */ -		hvsi_cd_change(pv, pkt->word & HVSI_TSCD); +		hvsi_cd_change(pv, be32_to_cpu(pkt->word) & HVSI_TSCD);  		break;  	}  } @@ -87,7 +86,7 @@ static void hvsi_got_query(struct hvsi_priv *pv)  	struct hvsi_query_response r;  	/* We only handle version queries */ -	if (pkt->verb != VSV_SEND_VERSION_NUMBER) +	if (be16_to_cpu(pkt->verb) != VSV_SEND_VERSION_NUMBER)  		return;  	pr_devel("HVSI@%x: Got version query, sending response...\n", @@ -96,7 +95,7 @@ static void hvsi_got_query(struct hvsi_priv *pv)  	/* Send version response */  	r.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER;  	r.hdr.len = sizeof(struct hvsi_query_response); -	r.verb = VSV_SEND_VERSION_NUMBER; +	r.verb = cpu_to_be16(VSV_SEND_VERSION_NUMBER);  	r.u.version = HVSI_VERSION;  	r.query_seqno = pkt->hdr.seqno;  	hvsi_send_packet(pv, &r.hdr); @@ -112,7 +111,7 @@ static void hvsi_got_response(struct hvsi_priv *pv)  	switch(r->verb) {  	case VSV_SEND_MODEM_CTL_STATUS: -		hvsi_cd_change(pv, r->u.mctrl_word & HVSI_TSCD); +		hvsi_cd_change(pv, be32_to_cpu(r->u.mctrl_word) & HVSI_TSCD);  		pv->mctrl_update = 1;  		break;  	} @@ -265,8 +264,7 @@ int hvsilib_read_mctrl(struct hvsi_priv *pv)  	pv->mctrl_update = 0;  	q.hdr.type = VS_QUERY_PACKET_HEADER;  	q.hdr.len = sizeof(struct hvsi_query); -	q.hdr.seqno = atomic_inc_return(&pv->seqno); -	q.verb = VSV_SEND_MODEM_CTL_STATUS; +	q.verb = cpu_to_be16(VSV_SEND_MODEM_CTL_STATUS);  	rc = hvsi_send_packet(pv, &q.hdr);  	if (rc <= 0) {  		pr_devel("HVSI@%x: Error %d...\n", pv->termno, rc); @@ -304,9 +302,9 @@ int hvsilib_write_mctrl(struct hvsi_priv *pv, int dtr)  	ctrl.hdr.type = VS_CONTROL_PACKET_HEADER,  	ctrl.hdr.len = sizeof(struct hvsi_control); -	ctrl.verb = VSV_SET_MODEM_CTL; -	ctrl.mask = HVSI_TSDTR; -	ctrl.word = dtr ? HVSI_TSDTR : 0; +	ctrl.verb = cpu_to_be16(VSV_SET_MODEM_CTL); +	ctrl.mask = cpu_to_be32(HVSI_TSDTR); +	ctrl.word = cpu_to_be32(dtr ? HVSI_TSDTR : 0);  	return hvsi_send_packet(pv, &ctrl.hdr);  }  | 
