mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 04/11] move devinfo command to its own file
Date: Fri, 27 Sep 2013 08:47:35 +0200	[thread overview]
Message-ID: <1380264462-27614-5-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1380264462-27614-1-git-send-email-s.hauer@pengutronix.de>

Just like nearly all other commands are in individual files.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 commands/Makefile     |   1 +
 commands/devinfo.c    | 158 ++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/base/driver.c | 142 ---------------------------------------------
 3 files changed, 159 insertions(+), 142 deletions(-)
 create mode 100644 commands/devinfo.c

diff --git a/commands/Makefile b/commands/Makefile
index 6acffc8..e027112 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -91,3 +91,4 @@ obj-$(CONFIG_CMD_FILETYPE)	+= filetype.o
 obj-$(CONFIG_CMD_BAREBOX_UPDATE)+= barebox-update.o
 obj-$(CONFIG_CMD_MIITOOL)	+= miitool.o
 obj-$(CONFIG_CMD_DETECT)	+= detect.o
+obj-$(CONFIG_CMD_DEVINFO)	+= devinfo.o
diff --git a/commands/devinfo.c b/commands/devinfo.c
new file mode 100644
index 0000000..806e45c
--- /dev/null
+++ b/commands/devinfo.c
@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2013 Sascha Hauer, Pengutronix
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <command.h>
+#include <common.h>
+#include <complete.h>
+#include <driver.h>
+
+static int do_devinfo_subtree(struct device_d *dev, int depth)
+{
+	struct device_d *child;
+	struct cdev *cdev;
+	int i;
+
+	for (i = 0; i < depth; i++)
+		printf("     ");
+
+	printf("`---- %s", dev_name(dev));
+	if (!list_empty(&dev->cdevs)) {
+		printf("\n");
+		list_for_each_entry(cdev, &dev->cdevs, devices_list) {
+			for (i = 0; i < depth + 1; i++)
+				printf("     ");
+			printf("`---- 0x%08llx-0x%08llx: /dev/%s\n",
+					cdev->offset,
+					cdev->offset + cdev->size - 1,
+					cdev->name);
+		}
+	} else {
+		printf("\n");
+	}
+
+	if (!list_empty(&dev->children)) {
+		device_for_each_child(dev, child) {
+			do_devinfo_subtree(child, depth + 1);
+		}
+	}
+
+	return 0;
+}
+
+static int do_devinfo(int argc, char *argv[])
+{
+	struct device_d *dev;
+	struct driver_d *drv;
+	struct param_d *param;
+	int i;
+	struct resource *res;
+
+	if (argc == 1) {
+		printf("devices:\n");
+
+		for_each_device(dev) {
+			if (!dev->parent)
+				do_devinfo_subtree(dev, 0);
+		}
+
+		printf("\ndrivers:\n");
+		for_each_driver(drv)
+			printf("%s\n",drv->name);
+	} else {
+		dev = get_device_by_name(argv[1]);
+
+		if (!dev) {
+			printf("no such device: %s\n",argv[1]);
+			return -1;
+		}
+
+		printf("resources:\n");
+		for (i = 0; i < dev->num_resources; i++) {
+			res = &dev->resource[i];
+			printf("num   : %d\n", i);
+			if (res->name)
+				printf("name  : %s\n", res->name);
+			printf("start : " PRINTF_CONVERSION_RESOURCE "\nsize  : "
+					PRINTF_CONVERSION_RESOURCE "\n",
+			       res->start, resource_size(res));
+		}
+
+		printf("driver: %s\n", dev->driver ?
+				dev->driver->name : "none");
+
+		printf("bus: %s\n\n", dev->bus ?
+				dev->bus->name : "none");
+
+		if (dev->info)
+			dev->info(dev);
+
+		printf("%s\n", list_empty(&dev->parameters) ?
+				"no parameters available" : "Parameters:");
+
+		list_for_each_entry(param, &dev->parameters, list) {
+			printf("%16s = %s", param->name, dev_get_param(dev, param->name));
+			if (param->info)
+				param->info(param);
+			printf("\n");
+		}
+#ifdef CONFIG_OFDEVICE
+		if (dev->device_node) {
+			printf("\ndevice node: %s\n", dev->device_node->full_name);
+			of_print_nodes(dev->device_node, 0);
+		}
+#endif
+	}
+
+	return 0;
+}
+
+BAREBOX_CMD_HELP_START(devinfo)
+BAREBOX_CMD_HELP_USAGE("devinfo [DEVICE]\n")
+BAREBOX_CMD_HELP_SHORT("Output device information.\n")
+BAREBOX_CMD_HELP_END
+
+/**
+ * @page devinfo_command
+
+If called without arguments, devinfo shows a summary of the known
+devices and drivers.
+
+If called with a device path being the argument, devinfo shows more
+default information about this device and its parameters.
+
+Example from an MPC5200 based system:
+
+@verbatim
+  barebox:/ devinfo /dev/eth0
+  base  : 0x1002b000
+  size  : 0x00000000
+  driver: fec_mpc5xxx
+
+  no info available for eth0
+  Parameters:
+      ipaddr = 192.168.23.197
+     ethaddr = 80:81:82:83:84:86
+     gateway = 192.168.23.1
+     netmask = 255.255.255.0
+    serverip = 192.168.23.2
+@endverbatim
+ */
+
+BAREBOX_CMD_START(devinfo)
+	.cmd		= do_devinfo,
+	.usage		= "Show information about devices and drivers.",
+	BAREBOX_CMD_HELP(cmd_devinfo_help)
+	BAREBOX_CMD_COMPLETE(device_complete)
+BAREBOX_CMD_END
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 16b7f06..8b70e9f 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -413,145 +413,3 @@ int dev_get_drvdata(struct device_d *dev, unsigned long *data)
 
 	return -ENODEV;
 }
-
-#ifdef CONFIG_CMD_DEVINFO
-static int do_devinfo_subtree(struct device_d *dev, int depth)
-{
-	struct device_d *child;
-	struct cdev *cdev;
-	int i;
-
-	for (i = 0; i < depth; i++)
-		printf("     ");
-
-	printf("`---- %s", dev_name(dev));
-	if (!list_empty(&dev->cdevs)) {
-		printf("\n");
-		list_for_each_entry(cdev, &dev->cdevs, devices_list) {
-			for (i = 0; i < depth + 1; i++)
-				printf("     ");
-			printf("`---- 0x%08llx-0x%08llx: /dev/%s\n",
-					cdev->offset,
-					cdev->offset + cdev->size - 1,
-					cdev->name);
-		}
-	} else {
-		printf("\n");
-	}
-
-	if (!list_empty(&dev->children)) {
-		device_for_each_child(dev, child) {
-			do_devinfo_subtree(child, depth + 1);
-		}
-	}
-
-	return 0;
-}
-
-static int do_devinfo(int argc, char *argv[])
-{
-	struct device_d *dev;
-	struct driver_d *drv;
-	struct param_d *param;
-	int i;
-	struct resource *res;
-
-	if (argc == 1) {
-		printf("devices:\n");
-
-		for_each_device(dev) {
-			if (!dev->parent)
-				do_devinfo_subtree(dev, 0);
-		}
-
-		printf("\ndrivers:\n");
-		for_each_driver(drv)
-			printf("%s\n",drv->name);
-	} else {
-		dev = get_device_by_name(argv[1]);
-
-		if (!dev) {
-			printf("no such device: %s\n",argv[1]);
-			return -1;
-		}
-
-		printf("resources:\n");
-		for (i = 0; i < dev->num_resources; i++) {
-			res = &dev->resource[i];
-			printf("num   : %d\n", i);
-			if (res->name)
-				printf("name  : %s\n", res->name);
-			printf("start : " PRINTF_CONVERSION_RESOURCE "\nsize  : "
-					PRINTF_CONVERSION_RESOURCE "\n",
-			       res->start, resource_size(res));
-		}
-
-		printf("driver: %s\n", dev->driver ?
-				dev->driver->name : "none");
-
-		printf("bus: %s\n\n", dev->bus ?
-				dev->bus->name : "none");
-
-		if (dev->info)
-			dev->info(dev);
-
-		printf("%s\n", list_empty(&dev->parameters) ?
-				"no parameters available" : "Parameters:");
-
-		list_for_each_entry(param, &dev->parameters, list) {
-			printf("%16s = %s", param->name, dev_get_param(dev, param->name));
-			if (param->info)
-				param->info(param);
-			printf("\n");
-		}
-#ifdef CONFIG_OFDEVICE
-		if (dev->device_node) {
-			printf("\ndevice node: %s\n", dev->device_node->full_name);
-			of_print_nodes(dev->device_node, 0);
-		}
-#endif
-	}
-
-	return 0;
-}
-
-BAREBOX_CMD_HELP_START(devinfo)
-BAREBOX_CMD_HELP_USAGE("devinfo [DEVICE]\n")
-BAREBOX_CMD_HELP_SHORT("Output device information.\n")
-BAREBOX_CMD_HELP_END
-
-/**
- * @page devinfo_command
-
-If called without arguments, devinfo shows a summary of the known
-devices and drivers.
-
-If called with a device path being the argument, devinfo shows more
-default information about this device and its parameters.
-
-Example from an MPC5200 based system:
-
-@verbatim
-  barebox:/ devinfo /dev/eth0
-  base  : 0x1002b000
-  size  : 0x00000000
-  driver: fec_mpc5xxx
-
-  no info available for eth0
-  Parameters:
-      ipaddr = 192.168.23.197
-     ethaddr = 80:81:82:83:84:86
-     gateway = 192.168.23.1
-     netmask = 255.255.255.0
-    serverip = 192.168.23.2
-@endverbatim
- */
-
-BAREBOX_CMD_START(devinfo)
-	.cmd		= do_devinfo,
-	.usage		= "Show information about devices and drivers.",
-	BAREBOX_CMD_HELP(cmd_devinfo_help)
-	BAREBOX_CMD_COMPLETE(device_complete)
-BAREBOX_CMD_END
-#endif
-
-- 
1.8.4.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2013-09-27  6:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-27  6:47 misc patches Sascha Hauer
2013-09-27  6:47 ` [PATCH 01/11] ARM: pfla02: Fix compiler warning Sascha Hauer
2013-09-27  6:47 ` [PATCH 02/11] detect command: Add missing help text for -a option Sascha Hauer
2013-09-27  6:47 ` [PATCH 03/11] ata: ide-sff: Add missing wait for ready in write function Sascha Hauer
2013-09-27  6:47 ` Sascha Hauer [this message]
2013-09-27  6:47 ` [PATCH 05/11] usb: Turn some printf into pr_* Sascha Hauer
2013-09-27  6:47 ` [PATCH 06/11] globalvar: Do not modify already existing variables Sascha Hauer
2013-09-27  6:47 ` [PATCH 07/11] scripts/Makefile: cleanup Sascha Hauer
2013-09-27  6:47 ` [PATCH 08/11] scripts/Makefile: implement targetprogs-y Sascha Hauer
2013-09-27  6:47 ` [PATCH 09/11] scripts: Move omap4_usbboot to its own directory Sascha Hauer
2013-09-27  6:47 ` [PATCH 10/11] bootm needs uImage support. Select it Sascha Hauer
2013-09-27  6:47 ` [PATCH 11/11] defenv-2: Do not overwrite previously existing global variables Sascha Hauer

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=1380264462-27614-5-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@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