All of lore.kernel.org
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
To: linux-kernel@vger.kernel.org, xen-devel@lists.xen.org
Cc: david.vrabel@citrix.com, boris.ostrovsky@oracle.com,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH 01/12] xen: introduce xenbus_read_unsigned()
Date: Mon, 31 Oct 2016 17:48:19 +0100	[thread overview]
Message-ID: <1477932510-28594-2-git-send-email-jgross@suse.com> (raw)
In-Reply-To: <1477932510-28594-1-git-send-email-jgross@suse.com>

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: Juergen Gross <jgross@suse.com>
---
 drivers/xen/xenbus/xenbus_xs.c | 15 +++++++++++++++
 include/xen/xenbus.h           |  4 ++++
 2 files changed, 19 insertions(+)

diff --git a/drivers/xen/xenbus/xenbus_xs.c b/drivers/xen/xenbus/xenbus_xs.c
index 22f7cd7..99dfdfa 100644
--- a/drivers/xen/xenbus/xenbus_xs.c
+++ b/drivers/xen/xenbus/xenbus_xs.c
@@ -559,6 +559,21 @@ int xenbus_scanf(struct xenbus_transaction t,
 }
 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. */
 int xenbus_printf(struct xenbus_transaction t,
 		  const char *dir, const char *node, const char *fmt, ...)
diff --git a/include/xen/xenbus.h b/include/xen/xenbus.h
index 32b944b..271ba62 100644
--- a/include/xen/xenbus.h
+++ b/include/xen/xenbus.h
@@ -151,6 +151,10 @@ __scanf(4, 5)
 int xenbus_scanf(struct xenbus_transaction t,
 		 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. */
 __printf(4, 5)
 int xenbus_printf(struct xenbus_transaction t,
-- 
2.6.6

WARNING: multiple messages have this Message-ID (diff)
From: Juergen Gross <jgross@suse.com>
To: linux-kernel@vger.kernel.org, xen-devel@lists.xen.org
Cc: Juergen Gross <jgross@suse.com>,
	boris.ostrovsky@oracle.com, david.vrabel@citrix.com
Subject: [PATCH 01/12] xen: introduce xenbus_read_unsigned()
Date: Mon, 31 Oct 2016 17:48:19 +0100	[thread overview]
Message-ID: <1477932510-28594-2-git-send-email-jgross@suse.com> (raw)
In-Reply-To: <1477932510-28594-1-git-send-email-jgross@suse.com>

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: Juergen Gross <jgross@suse.com>
---
 drivers/xen/xenbus/xenbus_xs.c | 15 +++++++++++++++
 include/xen/xenbus.h           |  4 ++++
 2 files changed, 19 insertions(+)

diff --git a/drivers/xen/xenbus/xenbus_xs.c b/drivers/xen/xenbus/xenbus_xs.c
index 22f7cd7..99dfdfa 100644
--- a/drivers/xen/xenbus/xenbus_xs.c
+++ b/drivers/xen/xenbus/xenbus_xs.c
@@ -559,6 +559,21 @@ int xenbus_scanf(struct xenbus_transaction t,
 }
 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. */
 int xenbus_printf(struct xenbus_transaction t,
 		  const char *dir, const char *node, const char *fmt, ...)
diff --git a/include/xen/xenbus.h b/include/xen/xenbus.h
index 32b944b..271ba62 100644
--- a/include/xen/xenbus.h
+++ b/include/xen/xenbus.h
@@ -151,6 +151,10 @@ __scanf(4, 5)
 int xenbus_scanf(struct xenbus_transaction t,
 		 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. */
 __printf(4, 5)
 int xenbus_printf(struct xenbus_transaction t,
-- 
2.6.6


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2016-10-31 16:51 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-31 16:48 [PATCH 00/12] xen: add common function for reading optional value Juergen Gross
2016-10-31 16:48 ` Juergen Gross
2016-10-31 16:48 ` Juergen Gross [this message]
2016-10-31 16:48   ` [PATCH 01/12] xen: introduce xenbus_read_unsigned() Juergen Gross
2016-11-07 11:02   ` David Vrabel
2016-11-07 11:02   ` [Xen-devel] " David Vrabel
2016-10-31 16:48 ` [PATCH 02/12] xen: make use of xenbus_read_unsigned() in xen-blkback Juergen Gross
2016-10-31 16:48 ` Juergen Gross
2016-10-31 16:48 ` [PATCH 03/12] xen: make use of xenbus_read_unsigned() in xen-blkfront Juergen Gross
2016-10-31 16:48   ` Juergen Gross
2016-10-31 16:48 ` [PATCH 04/12] xen: make use of xenbus_read_unsigned() in xen-tpmfront Juergen Gross
2016-10-31 16:48   ` Juergen Gross
2016-11-02 10:34   ` Jarkko Sakkinen
2016-11-02 10:34     ` Jarkko Sakkinen
2016-11-02 10:34   ` Jarkko Sakkinen
2016-11-04  4:26   ` Jarkko Sakkinen
2016-11-04  4:26     ` Jarkko Sakkinen
2016-11-04  4:26   ` Jarkko Sakkinen
2016-10-31 16:48 ` [PATCH 05/12] xen: make use of xenbus_read_unsigned() in xen-kbdfront Juergen Gross
2016-11-09  0:29   ` Dmitry Torokhov
2016-11-09  0:29   ` Dmitry Torokhov
2016-10-31 16:48 ` Juergen Gross
2016-10-31 16:48 ` [PATCH 06/12] xen: make use of xenbus_read_unsigned() in xen-netback Juergen Gross
2016-11-01  9:42   ` Paul Durrant
2016-11-01  9:42   ` Paul Durrant
2016-10-31 16:48 ` Juergen Gross
2016-10-31 16:48 ` [PATCH 07/12] xen: make use of xenbus_read_unsigned() in xen-netfront Juergen Gross
2016-10-31 16:48 ` Juergen Gross
2016-10-31 16:48 ` [PATCH 08/12] xen: make use of xenbus_read_unsigned() in xen-pcifront Juergen Gross
2016-10-31 18:18   ` Bjorn Helgaas
2016-10-31 18:18   ` Bjorn Helgaas
2016-10-31 16:48 ` Juergen Gross
2016-10-31 16:48 ` [PATCH 09/12] xen: make use of xenbus_read_unsigned() in xen-scsifront Juergen Gross
2016-10-31 16:48   ` Juergen Gross
2016-10-31 16:48 ` [PATCH 10/12] xen: make use of xenbus_read_unsigned() in xen-fbfront Juergen Gross
2016-10-31 16:48   ` Juergen Gross
2016-10-31 16:48   ` Juergen Gross
2016-10-31 16:48 ` [PATCH 11/12] xen: make use of xenbus_read_unsigned() in xen-pciback Juergen Gross
2016-10-31 16:48   ` Juergen Gross
2016-10-31 16:48 ` [PATCH 12/12] xen: make use of xenbus_read_unsigned() in xenbus Juergen Gross
2016-10-31 16:48   ` Juergen Gross
2016-10-31 17:08 ` [PATCH 00/12] xen: add common function for reading optional value David Miller
2016-10-31 17:08   ` David Miller
2016-10-31 17:08   ` David Miller
2016-11-01  4:33   ` Juergen Gross
2016-11-01  4:33     ` Juergen Gross
2016-11-01  4:33   ` Juergen Gross
2016-11-07 11:08 ` David Vrabel
2016-11-07 11:08   ` David Vrabel
2016-11-07 11:08   ` David Vrabel
2016-11-07 16:20   ` Jarkko Sakkinen
2016-11-07 16:20   ` Jarkko Sakkinen
2016-11-07 16:20     ` Jarkko Sakkinen
2016-11-07 16:20     ` Jarkko Sakkinen
2016-11-07 11:08 ` David Vrabel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1477932510-28594-2-git-send-email-jgross@suse.com \
    --to=jgross@suse.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=david.vrabel@citrix.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.