summaryrefslogtreecommitdiffstats
path: root/arch/um/drivers/chan_kern.c
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2007-02-10 01:43:53 -0800
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-11 10:51:21 -0800
commitf28169d2000177e8b72ccc6d72887be779dceca8 (patch)
tree0ef842014c67d8a136cc26c99113b69e2ede87ea /arch/um/drivers/chan_kern.c
parentd79a580936396bbcd2f4fae2c6215f9cf81e3c0d (diff)
downloadop-kernel-dev-f28169d2000177e8b72ccc6d72887be779dceca8.zip
op-kernel-dev-f28169d2000177e8b72ccc6d72887be779dceca8.tar.gz
[PATCH] uml: return hotplug errors to host
I noticed that errors happening while hotplugging devices from the host were never returned back to the mconsole client. In some cases, success was returned instead of even an information-free error. This patch cleans that up by having the low-level configuration code pass back an error string along with an error code. At the top level, which knows whether it is early boot time or responding to an mconsole request, the string is printk'd or returned to the mconsole client. There are also whitespace and trivial code cleanups in the surrounding code. Signed-off-by: Jeff Dike <jdike@addtoit.com> Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/um/drivers/chan_kern.c')
-rw-r--r--arch/um/drivers/chan_kern.c77
1 files changed, 23 insertions, 54 deletions
diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c
index 7d4190e..4e7e3cf 100644
--- a/arch/um/drivers/chan_kern.c
+++ b/arch/um/drivers/chan_kern.c
@@ -19,44 +19,11 @@
#include "line.h"
#include "os.h"
-/* XXX: could well be moved to somewhere else, if needed. */
-static int my_printf(const char * fmt, ...)
- __attribute__ ((format (printf, 1, 2)));
-
-static int my_printf(const char * fmt, ...)
-{
- /* Yes, can be called on atomic context.*/
- char *buf = kmalloc(4096, GFP_ATOMIC);
- va_list args;
- int r;
-
- if (!buf) {
- /* We print directly fmt.
- * Yes, yes, yes, feel free to complain. */
- r = strlen(fmt);
- } else {
- va_start(args, fmt);
- r = vsprintf(buf, fmt, args);
- va_end(args);
- fmt = buf;
- }
-
- if (r)
- r = os_write_file(1, fmt, r);
- return r;
-
-}
-
#ifdef CONFIG_NOCONFIG_CHAN
-/* Despite its name, there's no added trailing newline. */
-static int my_puts(const char * buf)
+static void *not_configged_init(char *str, int device,
+ const struct chan_opts *opts)
{
- return os_write_file(1, buf, strlen(buf));
-}
-
-static void *not_configged_init(char *str, int device, struct chan_opts *opts)
-{
- my_puts("Using a channel type which is configured out of "
+ printk("Using a channel type which is configured out of "
"UML\n");
return NULL;
}
@@ -64,34 +31,34 @@ static void *not_configged_init(char *str, int device, struct chan_opts *opts)
static int not_configged_open(int input, int output, int primary, void *data,
char **dev_out)
{
- my_puts("Using a channel type which is configured out of "
+ printk("Using a channel type which is configured out of "
"UML\n");
return -ENODEV;
}
static void not_configged_close(int fd, void *data)
{
- my_puts("Using a channel type which is configured out of "
+ printk("Using a channel type which is configured out of "
"UML\n");
}
static int not_configged_read(int fd, char *c_out, void *data)
{
- my_puts("Using a channel type which is configured out of "
+ printk("Using a channel type which is configured out of "
"UML\n");
return -EIO;
}
static int not_configged_write(int fd, const char *buf, int len, void *data)
{
- my_puts("Using a channel type which is configured out of "
+ printk("Using a channel type which is configured out of "
"UML\n");
return -EIO;
}
static int not_configged_console_write(int fd, const char *buf, int len)
{
- my_puts("Using a channel type which is configured out of "
+ printk("Using a channel type which is configured out of "
"UML\n");
return -EIO;
}
@@ -99,14 +66,14 @@ static int not_configged_console_write(int fd, const char *buf, int len)
static int not_configged_window_size(int fd, void *data, unsigned short *rows,
unsigned short *cols)
{
- my_puts("Using a channel type which is configured out of "
+ printk("Using a channel type which is configured out of "
"UML\n");
return -ENODEV;
}
static void not_configged_free(void *data)
{
- my_puts("Using a channel type which is configured out of "
+ printk("Using a channel type which is configured out of "
"UML\n");
}
@@ -534,7 +501,7 @@ static const struct chan_type chan_table[] = {
};
static struct chan *parse_chan(struct line *line, char *str, int device,
- const struct chan_opts *opts)
+ const struct chan_opts *opts, char **error_out)
{
const struct chan_type *entry;
const struct chan_ops *ops;
@@ -553,19 +520,21 @@ static struct chan *parse_chan(struct line *line, char *str, int device,
}
}
if(ops == NULL){
- my_printf("parse_chan couldn't parse \"%s\"\n",
- str);
+ *error_out = "No match for configured backends";
return NULL;
}
- if(ops->init == NULL)
- return NULL;
+
data = (*ops->init)(str, device, opts);
- if(data == NULL)
+ if(data == NULL){
+ *error_out = "Configuration failed";
return NULL;
+ }
chan = kmalloc(sizeof(*chan), GFP_ATOMIC);
- if(chan == NULL)
+ if(chan == NULL){
+ *error_out = "Memory allocation failed";
return NULL;
+ }
*chan = ((struct chan) { .list = LIST_HEAD_INIT(chan->list),
.free_list =
LIST_HEAD_INIT(chan->free_list),
@@ -582,7 +551,7 @@ static struct chan *parse_chan(struct line *line, char *str, int device,
}
int parse_chan_pair(char *str, struct line *line, int device,
- const struct chan_opts *opts)
+ const struct chan_opts *opts, char **error_out)
{
struct list_head *chans = &line->chan_list;
struct chan *new, *chan;
@@ -599,14 +568,14 @@ int parse_chan_pair(char *str, struct line *line, int device,
in = str;
*out = '\0';
out++;
- new = parse_chan(line, in, device, opts);
+ new = parse_chan(line, in, device, opts, error_out);
if(new == NULL)
return -1;
new->input = 1;
list_add(&new->list, chans);
- new = parse_chan(line, out, device, opts);
+ new = parse_chan(line, out, device, opts, error_out);
if(new == NULL)
return -1;
@@ -614,7 +583,7 @@ int parse_chan_pair(char *str, struct line *line, int device,
new->output = 1;
}
else {
- new = parse_chan(line, str, device, opts);
+ new = parse_chan(line, str, device, opts, error_out);
if(new == NULL)
return -1;
OpenPOWER on IntegriCloud