Commit c0d197d5 authored by Joe Perches's avatar Joe Perches Committed by Boris Ostrovsky

xenbus: Neaten xenbus_va_dev_error

This function error patch can be simplified, so do so.

Remove fail: label and somewhat obfuscating, used once "error_path"
function.
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
parent 7a1c44eb
...@@ -259,53 +259,34 @@ int xenbus_frontend_closed(struct xenbus_device *dev) ...@@ -259,53 +259,34 @@ int xenbus_frontend_closed(struct xenbus_device *dev)
} }
EXPORT_SYMBOL_GPL(xenbus_frontend_closed); EXPORT_SYMBOL_GPL(xenbus_frontend_closed);
/**
* Return the path to the error node for the given device, or NULL on failure.
* If the value returned is non-NULL, then it is the caller's to kfree.
*/
static char *error_path(struct xenbus_device *dev)
{
return kasprintf(GFP_KERNEL, "error/%s", dev->nodename);
}
static void xenbus_va_dev_error(struct xenbus_device *dev, int err, static void xenbus_va_dev_error(struct xenbus_device *dev, int err,
const char *fmt, va_list ap) const char *fmt, va_list ap)
{ {
unsigned int len; unsigned int len;
char *printf_buffer = NULL; char *printf_buffer;
char *path_buffer = NULL; char *path_buffer;
#define PRINTF_BUFFER_SIZE 4096 #define PRINTF_BUFFER_SIZE 4096
printf_buffer = kmalloc(PRINTF_BUFFER_SIZE, GFP_KERNEL); printf_buffer = kmalloc(PRINTF_BUFFER_SIZE, GFP_KERNEL);
if (printf_buffer == NULL) if (!printf_buffer)
goto fail; return;
len = sprintf(printf_buffer, "%i ", -err); len = sprintf(printf_buffer, "%i ", -err);
vsnprintf(printf_buffer+len, PRINTF_BUFFER_SIZE-len, fmt, ap); vsnprintf(printf_buffer + len, PRINTF_BUFFER_SIZE - len, fmt, ap);
dev_err(&dev->dev, "%s\n", printf_buffer); dev_err(&dev->dev, "%s\n", printf_buffer);
path_buffer = error_path(dev); path_buffer = kasprintf(GFP_KERNEL, "error/%s", dev->nodename);
if (!path_buffer ||
if (path_buffer == NULL) { xenbus_write(XBT_NIL, path_buffer, "error", printf_buffer))
dev_err(&dev->dev, "failed to write error node for %s (%s)\n", dev_err(&dev->dev, "failed to write error node for %s (%s)\n",
dev->nodename, printf_buffer); dev->nodename, printf_buffer);
goto fail;
}
if (xenbus_write(XBT_NIL, path_buffer, "error", printf_buffer) != 0) {
dev_err(&dev->dev, "failed to write error node for %s (%s)\n",
dev->nodename, printf_buffer);
goto fail;
}
fail:
kfree(printf_buffer); kfree(printf_buffer);
kfree(path_buffer); kfree(path_buffer);
} }
/** /**
* xenbus_dev_error * xenbus_dev_error
* @dev: xenbus device * @dev: xenbus device
......
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