Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9c53a179 authored by Juergen Gross's avatar Juergen Gross
Browse files

xen: introduce xenbus_read_unsigned()



There are multiple instances of code reading an optional unsigned
parameter from Xenstore via xenbus_scanf(). Instead of repeating the
same code over and over add a service function doing the job.

Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
Reviewed-by: default avatarDavid Vrabel <david.vrabel@citrix.com>
parent bc33b0ca
Loading
Loading
Loading
Loading
+15 −0
Original line number Original line Diff line number Diff line
@@ -559,6 +559,21 @@ int xenbus_scanf(struct xenbus_transaction t,
}
}
EXPORT_SYMBOL_GPL(xenbus_scanf);
EXPORT_SYMBOL_GPL(xenbus_scanf);


/* Read an (optional) unsigned value. */
unsigned int xenbus_read_unsigned(const char *dir, const char *node,
				  unsigned int default_val)
{
	unsigned int val;
	int ret;

	ret = xenbus_scanf(XBT_NIL, dir, node, "%u", &val);
	if (ret <= 0)
		val = default_val;

	return val;
}
EXPORT_SYMBOL_GPL(xenbus_read_unsigned);

/* Single printf and write: returns -errno or 0. */
/* Single printf and write: returns -errno or 0. */
int xenbus_printf(struct xenbus_transaction t,
int xenbus_printf(struct xenbus_transaction t,
		  const char *dir, const char *node, const char *fmt, ...)
		  const char *dir, const char *node, const char *fmt, ...)
+4 −0
Original line number Original line Diff line number Diff line
@@ -151,6 +151,10 @@ __scanf(4, 5)
int xenbus_scanf(struct xenbus_transaction t,
int xenbus_scanf(struct xenbus_transaction t,
		 const char *dir, const char *node, const char *fmt, ...);
		 const char *dir, const char *node, const char *fmt, ...);


/* Read an (optional) unsigned value. */
unsigned int xenbus_read_unsigned(const char *dir, const char *node,
				  unsigned int default_val);

/* Single printf and write: returns -errno or 0. */
/* Single printf and write: returns -errno or 0. */
__printf(4, 5)
__printf(4, 5)
int xenbus_printf(struct xenbus_transaction t,
int xenbus_printf(struct xenbus_transaction t,