summaryrefslogtreecommitdiff
path: root/flash_info.c
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2011-06-06 14:22:15 -0400
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2011-06-07 08:02:57 +0300
commit0c9b09bc1e1b0aad1877fd3fbb23421f9c229123 (patch)
tree37a13dda0c50b2433db2e68e64ed6a95e6ba4863 /flash_info.c
parenta204ad243f4f07b757742ff30924e3fea0ec5d3e (diff)
flash_info: allow people to get info on multiple devices
Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'flash_info.c')
-rw-r--r--flash_info.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/flash_info.c b/flash_info.c
index d4887da..6c518b2 100644
--- a/flash_info.c
+++ b/flash_info.c
@@ -18,39 +18,45 @@
static void usage(int status)
{
fprintf(status ? stderr : stdout,
- "Usage: %s <device>\n",
+ "Usage: %s <device> [devices]\n",
PROGRAM_NAME);
exit(status);
}
int main(int argc, char *argv[])
{
- int regcount;
- int fd;
+ int fd, i, regcount;
if (argc < 2)
usage(1);
if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))
usage(0);
- /* Open and size the device */
- fd = open(argv[1], O_RDONLY);
- if (fd < 0)
- sys_errmsg_die("could not open: %s", argv[1]);
-
- if (ioctl(fd, MEMGETREGIONCOUNT, &regcount) == 0) {
- int i;
+ for (i = 1; i < argc; ++i) {
+ const char *dev = argv[i];
+ int r;
region_info_t reginfo;
- printf("Device %s has %d erase regions\n", argv[1], regcount);
- for (i = 0; i < regcount; i++) {
- reginfo.regionindex = i;
+
+ /* Open and size the device */
+ fd = open(dev, O_RDONLY);
+ if (fd < 0) {
+ sys_errmsg("could not open: %s", dev);
+ continue;
+ }
+
+ if (ioctl(fd, MEMGETREGIONCOUNT, &regcount))
+ continue;
+
+ printf("%s: %d erase regions\n", dev, regcount);
+ for (r = 0; r < regcount; ++r) {
+ reginfo.regionindex = r;
if (ioctl(fd, MEMGETREGIONINFO, &reginfo) == 0) {
printf("Region %d is at 0x%x with size 0x%x and "
- "has 0x%x blocks\n", i, reginfo.offset,
+ "has 0x%x blocks\n", r, reginfo.offset,
reginfo.erasesize, reginfo.numblocks);
} else {
warnmsg("can not read region %d from a %d region device",
- i, regcount);
+ r, regcount);
}
}
}