public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Brian Norris <computersforpeace@gmail.com>
To: <linux-mtd@lists.infradead.org>
Cc: Brian Norris <computersforpeace@gmail.com>,
	Artem Bityutskiy <dedekind1@gmail.com>
Subject: [PATCH 1/2] libubi: make `ubi_dev_present()' a library function
Date: Wed, 25 Jan 2012 23:31:49 -0800	[thread overview]
Message-ID: <1327563110-23966-1-git-send-email-computersforpeace@gmail.com> (raw)

We will use this function in ubinfo.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
 ubi-utils/include/libubi.h |    9 +++++++++
 ubi-utils/libubi.c         |   12 +++---------
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/ubi-utils/include/libubi.h b/ubi-utils/include/libubi.h
index 02017e8..dc03d02 100644
--- a/ubi-utils/include/libubi.h
+++ b/ubi-utils/include/libubi.h
@@ -346,6 +346,15 @@ int ubi_get_dev_info(libubi_t desc, const char *node,
 		     struct ubi_dev_info *info);
 
 /**
+ * ubi_dev_present - check whether an UBI device is present.
+ * @desc: UBI library descriptor
+ * @dev_num: UBI device number to check
+ *
+ * This function returns %1 if UBI device is present and %0 if not.
+ */
+int ubi_dev_present(libubi_t desc, int dev_num);
+
+/**
  * ubi_get_dev_info1 - get UBI device information.
  * @desc: UBI library descriptor
  * @dev_num: UBI device number to fetch information about
diff --git a/ubi-utils/libubi.c b/ubi-utils/libubi.c
index 4d5f316..c898e36 100644
--- a/ubi-utils/libubi.c
+++ b/ubi-utils/libubi.c
@@ -1121,16 +1121,10 @@ int ubi_leb_change_start(libubi_t desc, int fd, int lnum, int bytes, int dtype)
 	return 0;
 }
 
-/**
- * dev_present - check whether an UBI device is present.
- * @lib: libubi descriptor
- * @dev_num: UBI device number to check
- *
- * This function returns %1 if UBI device is present and %0 if not.
- */
-static int dev_present(struct libubi *lib, int dev_num)
+int ubi_dev_present(libubi_t desc, int dev_num)
 {
 	struct stat st;
+	struct libubi *lib = (struct libubi *)desc;
 	char file[strlen(lib->ubi_dev) + 50];
 
 	sprintf(file, lib->ubi_dev, dev_num);
@@ -1146,7 +1140,7 @@ int ubi_get_dev_info1(libubi_t desc, int dev_num, struct ubi_dev_info *info)
 	memset(info, 0, sizeof(struct ubi_dev_info));
 	info->dev_num = dev_num;
 
-	if (!dev_present(lib, dev_num))
+	if (!ubi_dev_present(desc, dev_num))
 		return -1;
 
 	sysfs_ubi = opendir(lib->sysfs_ubi);
-- 
1.7.5.4

             reply	other threads:[~2012-01-26  7:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-26  7:31 Brian Norris [this message]
2012-01-26  7:31 ` [PATCH 2/2] ubinfo: fix `--all' for non-consecutive device numbers Brian Norris
2012-01-26  8:53   ` Brian Foster
2012-01-27 18:28     ` Brian Norris
2012-01-30  8:32       ` Brian Foster
2012-01-27 14:51 ` [PATCH 1/2] libubi: make `ubi_dev_present()' a library function Artem Bityutskiy

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=1327563110-23966-1-git-send-email-computersforpeace@gmail.com \
    --to=computersforpeace@gmail.com \
    --cc=dedekind1@gmail.com \
    --cc=linux-mtd@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox