mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/4] bus: remove dead code
@ 2011-02-10  3:31 Jean-Christophe PLAGNIOL-VILLARD
  2011-02-10  3:31 ` [PATCH 2/4] bus/driver: move from lib to drivers/base Jean-Christophe PLAGNIOL-VILLARD
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-02-10  3:31 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 lib/bus.c |   13 -------------
 1 files changed, 0 insertions(+), 13 deletions(-)

diff --git a/lib/bus.c b/lib/bus.c
index e0dd9ea..c34982e 100644
--- a/lib/bus.c
+++ b/lib/bus.c
@@ -43,16 +43,3 @@ struct bus_type platform_bus = {
 	.probe = platform_probe,
 	.remove = platform_remove,
 };
-
-#if 0
-LIST_HEAD(bus_list);
-EXPORT_SYMBOL(bus_list);
-
-int bus_register(struct bus_type *bus)
-{
-	list_add_tail(&bus->list, &bus_list);
-
-	return 0;
-}
-#endif
-
-- 
1.7.2.3


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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/4] bus/driver: move from lib to drivers/base
  2011-02-10  3:31 [PATCH 1/4] bus: remove dead code Jean-Christophe PLAGNIOL-VILLARD
@ 2011-02-10  3:31 ` Jean-Christophe PLAGNIOL-VILLARD
  2011-02-10  3:31 ` [PATCH 3/4] driver/memmap: fix generic_memmap_rw and generic_memmap_ro Jean-Christophe PLAGNIOL-VILLARD
  2011-02-10  3:32 ` [PATCH 4/4] devices_shutdown: move remove call to bus Jean-Christophe PLAGNIOL-VILLARD
  2 siblings, 0 replies; 7+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-02-10  3:31 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 drivers/Makefile        |    1 +
 drivers/base/Makefile   |    2 +
 drivers/base/driver.c   |  380 +++++++++++++++++++++++++++++++++++++++++++++++
 drivers/base/platform.c |   45 ++++++
 lib/Makefile            |    2 -
 lib/bus.c               |   45 ------
 lib/driver.c            |  380 -----------------------------------------------
 7 files changed, 428 insertions(+), 427 deletions(-)
 create mode 100644 drivers/base/Makefile
 create mode 100644 drivers/base/driver.c
 create mode 100644 drivers/base/platform.c
 delete mode 100644 lib/bus.c
 delete mode 100644 lib/driver.c

diff --git a/drivers/Makefile b/drivers/Makefile
index b1b402f..9a90434 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -1,3 +1,4 @@
+obj-y	+= base/
 obj-y	+= net/
 obj-y	+= serial/
 obj-y	+= mtd/
diff --git a/drivers/base/Makefile b/drivers/base/Makefile
new file mode 100644
index 0000000..dcec449
--- /dev/null
+++ b/drivers/base/Makefile
@@ -0,0 +1,2 @@
+obj-y			+= driver.o
+obj-y			+= platform.o
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
new file mode 100644
index 0000000..ff92e44
--- /dev/null
+++ b/drivers/base/driver.c
@@ -0,0 +1,380 @@
+/*
+ * driver.c - barebox driver model
+ *
+ * Copyright (c) 2007 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+/**
+ * @file
+ * @brief barebox's driver model, and devinfo command
+ */
+
+#include <common.h>
+#include <command.h>
+#include <driver.h>
+#include <malloc.h>
+#include <linux/ctype.h>
+#include <errno.h>
+#include <fs.h>
+#include <linux/list.h>
+
+LIST_HEAD(device_list);
+EXPORT_SYMBOL(device_list);
+
+LIST_HEAD(driver_list);
+EXPORT_SYMBOL(driver_list);
+
+static LIST_HEAD(active);
+
+struct device_d *get_device_by_name(const char *name)
+{
+	struct device_d *dev;
+
+	for_each_device(dev) {
+		if(!strcmp(dev_name(dev), name))
+			return dev;
+	}
+
+	return NULL;
+}
+
+static struct device_d *get_device_by_name_id(const char *name, int id)
+{
+	struct device_d *dev;
+
+	for_each_device(dev) {
+		if(!strcmp(dev->name, name) && id == dev->id)
+			return dev;
+	}
+
+	return NULL;
+}
+
+int get_free_deviceid(const char *name_template)
+{
+	int i = 0;
+
+	while (1) {
+		if (!get_device_by_name_id(name_template, i))
+			return i;
+		i++;
+	};
+}
+
+static int match(struct driver_d *drv, struct device_d *dev)
+{
+	if (dev->driver)
+		return -1;
+
+	dev->driver = drv;
+
+	if (dev->bus != drv->bus)
+		goto err_out;
+	if (dev->bus->match(dev, drv))
+		goto err_out;
+	if (dev->bus->probe(dev))
+		goto err_out;
+
+	list_add(&dev->active, &active);
+
+	return 0;
+err_out:
+	dev->driver = NULL;
+	return -1;
+}
+
+int register_device(struct device_d *new_device)
+{
+	struct driver_d *drv;
+
+	if (new_device->id < 0) {
+		new_device->id = get_free_deviceid(new_device->name);
+	} else {
+		if (get_device_by_name_id(new_device->name, new_device->id)) {
+			eprintf("register_device: already registered %s\n",
+				dev_name(new_device));
+			return -EINVAL;
+		}
+	}
+
+	debug ("register_device: %s\n", dev_name(new_device));
+
+	if (!new_device->bus) {
+//		dev_err(new_device, "no bus type associated. Needs fixup\n");
+		new_device->bus = &platform_bus;
+	}
+
+	list_add_tail(&new_device->list, &device_list);
+	INIT_LIST_HEAD(&new_device->children);
+	INIT_LIST_HEAD(&new_device->cdevs);
+	INIT_LIST_HEAD(&new_device->parameters);
+
+	for_each_driver(drv) {
+		if (!match(drv, new_device))
+			break;
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL(register_device);
+
+int unregister_device(struct device_d *old_dev)
+{
+	debug("unregister_device: %s\n", dev_name(old_dev));
+
+	if (!list_empty(&old_dev->children)) {
+		errno = -EBUSY;
+		return errno;
+	}
+
+	if (old_dev->driver)
+		old_dev->bus->remove(old_dev);
+
+	list_del(&old_dev->list);
+
+	/* remove device from parents child list */
+	if (old_dev->parent)
+		list_del(&old_dev->sibling);
+
+	return 0;
+}
+EXPORT_SYMBOL(unregister_device);
+
+int dev_add_child(struct device_d *dev, struct device_d *child)
+{
+	child->parent = dev;
+
+	list_add_tail(&child->sibling, &dev->children);
+
+	return 0;
+}
+EXPORT_SYMBOL(dev_add_child);
+
+struct driver_d *get_driver_by_name(const char *name)
+{
+	struct driver_d *drv;
+
+	for_each_driver(drv) {
+		if(!strcmp(name, drv->name))
+			return drv;
+	}
+
+	return NULL;
+}
+
+static void noinfo(struct device_d *dev)
+{
+	printf("no info available for %s\n", dev_name(dev));
+}
+
+static void noshortinfo(struct device_d *dev)
+{
+}
+
+int register_driver(struct driver_d *drv)
+{
+	struct device_d *dev = NULL;
+
+	debug("register_driver: %s\n", drv->name);
+
+	if (!drv->bus) {
+//		pr_err("driver %s has no bus type associated. Needs fixup\n", drv->name);
+		drv->bus = &platform_bus;
+	}
+
+	list_add_tail(&drv->list, &driver_list);
+
+	if (!drv->info)
+		drv->info = noinfo;
+	if (!drv->shortinfo)
+		drv->shortinfo = noshortinfo;
+
+	for_each_device(dev)
+		match(drv, dev);
+
+	return 0;
+}
+EXPORT_SYMBOL(register_driver);
+
+int dev_protect(struct device_d *dev, size_t count, unsigned long offset, int prot)
+{
+	printf("%s: currently broken\n", __func__);
+	return -EINVAL;
+}
+
+int generic_memmap_ro(struct cdev *cdev, void **map, int flags)
+{
+	if (!cdev->dev)
+		return -EINVAL;
+
+	if (flags & PROT_WRITE)
+		return -EACCES;
+	*map = (void *)cdev->dev->map_base;
+	return 0;
+}
+
+int generic_memmap_rw(struct cdev *cdev, void **map, int flags)
+{
+	if (!cdev->dev)
+		return -EINVAL;
+
+	*map = (void *)cdev->dev->map_base;
+	return 0;
+}
+
+int dummy_probe(struct device_d *dev)
+{
+	return 0;
+}
+EXPORT_SYMBOL(dummy_probe);
+
+const char *dev_id(const struct device_d *dev)
+{
+	static char buf[sizeof(unsigned long) * 2];
+
+	sprintf(buf, FORMAT_DRIVER_MANE_ID, dev->name, dev->id);
+
+	return buf;
+}
+
+void devices_shutdown(void)
+{
+	struct device_d *dev;
+
+	list_for_each_entry(dev, &active, active) {
+		if (dev->driver->remove)
+			dev->driver->remove(dev);
+	}
+}
+
+#ifdef CONFIG_CMD_DEVINFO
+static int do_devinfo_subtree(struct device_d *dev, int depth, char edge)
+{
+	struct device_d *child;
+	struct cdev *cdev;
+	int i;
+
+	for (i = 0; i < depth; i++)
+		printf("|    ");
+
+	printf("%c----%s", edge, dev_name(dev));
+	if (!list_empty(&dev->cdevs)) {
+		printf(" (");
+		list_for_each_entry(cdev, &dev->cdevs, devices_list) {
+			printf("%s", cdev->name);
+			if (!list_is_last(&cdev->devices_list, &dev->cdevs))
+				printf(", ");
+		}
+		printf(")");
+	}
+	printf("\n");
+
+	if (!list_empty(&dev->children)) {
+		device_for_each_child(dev, child) {
+			do_devinfo_subtree(child, depth + 1,
+					list_is_last(&child->sibling,
+						&dev->children) ? '`' : '|');
+		}
+	}
+
+	return 0;
+}
+
+static int do_devinfo(struct command *cmdtp, int argc, char *argv[])
+{
+	struct device_d *dev;
+	struct driver_d *drv;
+	struct param_d *param;
+
+	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("%10s\n",drv->name);
+	} else {
+		dev = get_device_by_name(argv[1]);
+
+		if (!dev) {
+			printf("no such device: %s\n",argv[1]);
+			return -1;
+		}
+
+		printf("base  : 0x%08x\nsize  : 0x%08x\ndriver: %s\n\n",
+			dev->map_base, dev->size,
+			dev->driver ? 
+				dev->driver->name : "none");
+
+		if (dev->driver)
+			dev->driver->info(dev);
+
+		printf("%s\n", list_empty(&dev->parameters) ?
+				"no parameters available" : "Parameters:");
+
+		list_for_each_entry(param, &dev->parameters, list)
+			printf("%16s = %s\n", param->name, param->value);
+	}
+
+	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_END
+#endif
+
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
new file mode 100644
index 0000000..f1ee38c
--- /dev/null
+++ b/drivers/base/platform.c
@@ -0,0 +1,45 @@
+/*
+ * platform.c - barebox platform driver model
+ *
+ * Copyright (c) 2009 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#include <common.h>
+#include <driver.h>
+
+static int platform_match(struct device_d *dev, struct driver_d *drv)
+{
+	return strcmp(dev->name, drv->name) ? -1 : 0;
+}
+
+static int platform_probe(struct device_d *dev)
+{
+	return dev->driver->probe(dev);
+}
+
+static void platform_remove(struct device_d *dev)
+{
+	dev->driver->remove(dev);
+}
+
+struct bus_type platform_bus = {
+	.name = "platform",
+	.match = platform_match,
+	.probe = platform_probe,
+	.remove = platform_remove,
+};
diff --git a/lib/Makefile b/lib/Makefile
index 8b986d2..d96cfe7 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -5,8 +5,6 @@ obj-y			+= string.o
 obj-y			+= vsprintf.o
 obj-y			+= div64.o
 obj-y			+= misc.o
-obj-y			+= driver.o
-obj-y			+= bus.o
 obj-y			+= parameter.o
 obj-y			+= xfuncs.o
 obj-y			+= getopt.o
diff --git a/lib/bus.c b/lib/bus.c
deleted file mode 100644
index c34982e..0000000
--- a/lib/bus.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * bus.c - barebox driver model
- *
- * Copyright (c) 2009 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.
- *
- * 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.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include <common.h>
-#include <driver.h>
-
-static int platform_match(struct device_d *dev, struct driver_d *drv)
-{
-	return strcmp(dev->name, drv->name) ? -1 : 0;
-}
-
-static int platform_probe(struct device_d *dev)
-{
-	return dev->driver->probe(dev);
-}
-
-static void platform_remove(struct device_d *dev)
-{
-	dev->driver->remove(dev);
-}
-
-struct bus_type platform_bus = {
-	.name = "platform",
-	.match = platform_match,
-	.probe = platform_probe,
-	.remove = platform_remove,
-};
diff --git a/lib/driver.c b/lib/driver.c
deleted file mode 100644
index ff92e44..0000000
--- a/lib/driver.c
+++ /dev/null
@@ -1,380 +0,0 @@
-/*
- * driver.c - barebox driver model
- *
- * Copyright (c) 2007 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.
- *
- * 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.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/**
- * @file
- * @brief barebox's driver model, and devinfo command
- */
-
-#include <common.h>
-#include <command.h>
-#include <driver.h>
-#include <malloc.h>
-#include <linux/ctype.h>
-#include <errno.h>
-#include <fs.h>
-#include <linux/list.h>
-
-LIST_HEAD(device_list);
-EXPORT_SYMBOL(device_list);
-
-LIST_HEAD(driver_list);
-EXPORT_SYMBOL(driver_list);
-
-static LIST_HEAD(active);
-
-struct device_d *get_device_by_name(const char *name)
-{
-	struct device_d *dev;
-
-	for_each_device(dev) {
-		if(!strcmp(dev_name(dev), name))
-			return dev;
-	}
-
-	return NULL;
-}
-
-static struct device_d *get_device_by_name_id(const char *name, int id)
-{
-	struct device_d *dev;
-
-	for_each_device(dev) {
-		if(!strcmp(dev->name, name) && id == dev->id)
-			return dev;
-	}
-
-	return NULL;
-}
-
-int get_free_deviceid(const char *name_template)
-{
-	int i = 0;
-
-	while (1) {
-		if (!get_device_by_name_id(name_template, i))
-			return i;
-		i++;
-	};
-}
-
-static int match(struct driver_d *drv, struct device_d *dev)
-{
-	if (dev->driver)
-		return -1;
-
-	dev->driver = drv;
-
-	if (dev->bus != drv->bus)
-		goto err_out;
-	if (dev->bus->match(dev, drv))
-		goto err_out;
-	if (dev->bus->probe(dev))
-		goto err_out;
-
-	list_add(&dev->active, &active);
-
-	return 0;
-err_out:
-	dev->driver = NULL;
-	return -1;
-}
-
-int register_device(struct device_d *new_device)
-{
-	struct driver_d *drv;
-
-	if (new_device->id < 0) {
-		new_device->id = get_free_deviceid(new_device->name);
-	} else {
-		if (get_device_by_name_id(new_device->name, new_device->id)) {
-			eprintf("register_device: already registered %s\n",
-				dev_name(new_device));
-			return -EINVAL;
-		}
-	}
-
-	debug ("register_device: %s\n", dev_name(new_device));
-
-	if (!new_device->bus) {
-//		dev_err(new_device, "no bus type associated. Needs fixup\n");
-		new_device->bus = &platform_bus;
-	}
-
-	list_add_tail(&new_device->list, &device_list);
-	INIT_LIST_HEAD(&new_device->children);
-	INIT_LIST_HEAD(&new_device->cdevs);
-	INIT_LIST_HEAD(&new_device->parameters);
-
-	for_each_driver(drv) {
-		if (!match(drv, new_device))
-			break;
-	}
-
-	return 0;
-}
-EXPORT_SYMBOL(register_device);
-
-int unregister_device(struct device_d *old_dev)
-{
-	debug("unregister_device: %s\n", dev_name(old_dev));
-
-	if (!list_empty(&old_dev->children)) {
-		errno = -EBUSY;
-		return errno;
-	}
-
-	if (old_dev->driver)
-		old_dev->bus->remove(old_dev);
-
-	list_del(&old_dev->list);
-
-	/* remove device from parents child list */
-	if (old_dev->parent)
-		list_del(&old_dev->sibling);
-
-	return 0;
-}
-EXPORT_SYMBOL(unregister_device);
-
-int dev_add_child(struct device_d *dev, struct device_d *child)
-{
-	child->parent = dev;
-
-	list_add_tail(&child->sibling, &dev->children);
-
-	return 0;
-}
-EXPORT_SYMBOL(dev_add_child);
-
-struct driver_d *get_driver_by_name(const char *name)
-{
-	struct driver_d *drv;
-
-	for_each_driver(drv) {
-		if(!strcmp(name, drv->name))
-			return drv;
-	}
-
-	return NULL;
-}
-
-static void noinfo(struct device_d *dev)
-{
-	printf("no info available for %s\n", dev_name(dev));
-}
-
-static void noshortinfo(struct device_d *dev)
-{
-}
-
-int register_driver(struct driver_d *drv)
-{
-	struct device_d *dev = NULL;
-
-	debug("register_driver: %s\n", drv->name);
-
-	if (!drv->bus) {
-//		pr_err("driver %s has no bus type associated. Needs fixup\n", drv->name);
-		drv->bus = &platform_bus;
-	}
-
-	list_add_tail(&drv->list, &driver_list);
-
-	if (!drv->info)
-		drv->info = noinfo;
-	if (!drv->shortinfo)
-		drv->shortinfo = noshortinfo;
-
-	for_each_device(dev)
-		match(drv, dev);
-
-	return 0;
-}
-EXPORT_SYMBOL(register_driver);
-
-int dev_protect(struct device_d *dev, size_t count, unsigned long offset, int prot)
-{
-	printf("%s: currently broken\n", __func__);
-	return -EINVAL;
-}
-
-int generic_memmap_ro(struct cdev *cdev, void **map, int flags)
-{
-	if (!cdev->dev)
-		return -EINVAL;
-
-	if (flags & PROT_WRITE)
-		return -EACCES;
-	*map = (void *)cdev->dev->map_base;
-	return 0;
-}
-
-int generic_memmap_rw(struct cdev *cdev, void **map, int flags)
-{
-	if (!cdev->dev)
-		return -EINVAL;
-
-	*map = (void *)cdev->dev->map_base;
-	return 0;
-}
-
-int dummy_probe(struct device_d *dev)
-{
-	return 0;
-}
-EXPORT_SYMBOL(dummy_probe);
-
-const char *dev_id(const struct device_d *dev)
-{
-	static char buf[sizeof(unsigned long) * 2];
-
-	sprintf(buf, FORMAT_DRIVER_MANE_ID, dev->name, dev->id);
-
-	return buf;
-}
-
-void devices_shutdown(void)
-{
-	struct device_d *dev;
-
-	list_for_each_entry(dev, &active, active) {
-		if (dev->driver->remove)
-			dev->driver->remove(dev);
-	}
-}
-
-#ifdef CONFIG_CMD_DEVINFO
-static int do_devinfo_subtree(struct device_d *dev, int depth, char edge)
-{
-	struct device_d *child;
-	struct cdev *cdev;
-	int i;
-
-	for (i = 0; i < depth; i++)
-		printf("|    ");
-
-	printf("%c----%s", edge, dev_name(dev));
-	if (!list_empty(&dev->cdevs)) {
-		printf(" (");
-		list_for_each_entry(cdev, &dev->cdevs, devices_list) {
-			printf("%s", cdev->name);
-			if (!list_is_last(&cdev->devices_list, &dev->cdevs))
-				printf(", ");
-		}
-		printf(")");
-	}
-	printf("\n");
-
-	if (!list_empty(&dev->children)) {
-		device_for_each_child(dev, child) {
-			do_devinfo_subtree(child, depth + 1,
-					list_is_last(&child->sibling,
-						&dev->children) ? '`' : '|');
-		}
-	}
-
-	return 0;
-}
-
-static int do_devinfo(struct command *cmdtp, int argc, char *argv[])
-{
-	struct device_d *dev;
-	struct driver_d *drv;
-	struct param_d *param;
-
-	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("%10s\n",drv->name);
-	} else {
-		dev = get_device_by_name(argv[1]);
-
-		if (!dev) {
-			printf("no such device: %s\n",argv[1]);
-			return -1;
-		}
-
-		printf("base  : 0x%08x\nsize  : 0x%08x\ndriver: %s\n\n",
-			dev->map_base, dev->size,
-			dev->driver ? 
-				dev->driver->name : "none");
-
-		if (dev->driver)
-			dev->driver->info(dev);
-
-		printf("%s\n", list_empty(&dev->parameters) ?
-				"no parameters available" : "Parameters:");
-
-		list_for_each_entry(param, &dev->parameters, list)
-			printf("%16s = %s\n", param->name, param->value);
-	}
-
-	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_END
-#endif
-
-- 
1.7.2.3


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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 3/4] driver/memmap: fix generic_memmap_rw and generic_memmap_ro
  2011-02-10  3:31 [PATCH 1/4] bus: remove dead code Jean-Christophe PLAGNIOL-VILLARD
  2011-02-10  3:31 ` [PATCH 2/4] bus/driver: move from lib to drivers/base Jean-Christophe PLAGNIOL-VILLARD
@ 2011-02-10  3:31 ` Jean-Christophe PLAGNIOL-VILLARD
  2011-02-10  7:12   ` Sascha Hauer
  2011-02-10  3:32 ` [PATCH 4/4] devices_shutdown: move remove call to bus Jean-Christophe PLAGNIOL-VILLARD
  2 siblings, 1 reply; 7+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-02-10  3:31 UTC (permalink / raw)
  To: barebox

we check before the RW access for generic_memmap_ro instead of
generic_memmap_rw

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 drivers/base/driver.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index ff92e44..bd7464e 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -223,8 +223,6 @@ int generic_memmap_ro(struct cdev *cdev, void **map, int flags)
 	if (!cdev->dev)
 		return -EINVAL;
 
-	if (flags & PROT_WRITE)
-		return -EACCES;
 	*map = (void *)cdev->dev->map_base;
 	return 0;
 }
@@ -234,6 +232,9 @@ int generic_memmap_rw(struct cdev *cdev, void **map, int flags)
 	if (!cdev->dev)
 		return -EINVAL;
 
+	if (flags & PROT_WRITE)
+		return -EACCES;
+
 	*map = (void *)cdev->dev->map_base;
 	return 0;
 }
-- 
1.7.2.3


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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 4/4] devices_shutdown: move remove call to bus
  2011-02-10  3:31 [PATCH 1/4] bus: remove dead code Jean-Christophe PLAGNIOL-VILLARD
  2011-02-10  3:31 ` [PATCH 2/4] bus/driver: move from lib to drivers/base Jean-Christophe PLAGNIOL-VILLARD
  2011-02-10  3:31 ` [PATCH 3/4] driver/memmap: fix generic_memmap_rw and generic_memmap_ro Jean-Christophe PLAGNIOL-VILLARD
@ 2011-02-10  3:32 ` Jean-Christophe PLAGNIOL-VILLARD
  2 siblings, 0 replies; 7+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-02-10  3:32 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 drivers/base/driver.c   |    4 ++--
 drivers/base/platform.c |    3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index bd7464e..6ad61f7 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -259,8 +259,8 @@ void devices_shutdown(void)
 	struct device_d *dev;
 
 	list_for_each_entry(dev, &active, active) {
-		if (dev->driver->remove)
-			dev->driver->remove(dev);
+		if (dev->bus->remove)
+			dev->bus->remove(dev);
 	}
 }
 
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index f1ee38c..e0a83b9 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -34,7 +34,8 @@ static int platform_probe(struct device_d *dev)
 
 static void platform_remove(struct device_d *dev)
 {
-	dev->driver->remove(dev);
+	if (dev->driver->remove)
+		dev->driver->remove(dev);
 }
 
 struct bus_type platform_bus = {
-- 
1.7.2.3


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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/4] driver/memmap: fix generic_memmap_rw and generic_memmap_ro
  2011-02-10  3:31 ` [PATCH 3/4] driver/memmap: fix generic_memmap_rw and generic_memmap_ro Jean-Christophe PLAGNIOL-VILLARD
@ 2011-02-10  7:12   ` Sascha Hauer
  2011-02-10 11:50     ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 7+ messages in thread
From: Sascha Hauer @ 2011-02-10  7:12 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Thu, Feb 10, 2011 at 04:31:59AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> we check before the RW access for generic_memmap_ro instead of
> generic_memmap_rw
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
>  drivers/base/driver.c |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/base/driver.c b/drivers/base/driver.c
> index ff92e44..bd7464e 100644
> --- a/drivers/base/driver.c
> +++ b/drivers/base/driver.c
> @@ -223,8 +223,6 @@ int generic_memmap_ro(struct cdev *cdev, void **map, int flags)
>  	if (!cdev->dev)
>  		return -EINVAL;
>  
> -	if (flags & PROT_WRITE)
> -		return -EACCES;
>  	*map = (void *)cdev->dev->map_base;
>  	return 0;
>  }
> @@ -234,6 +232,9 @@ int generic_memmap_rw(struct cdev *cdev, void **map, int flags)
>  	if (!cdev->dev)
>  		return -EINVAL;
>  
> +	if (flags & PROT_WRITE)
> +		return -EACCES;
> +

So instead of allowing write access in the read/write function we now
allow it in the readonly function? I'm afraid I don't understand this.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/4] driver/memmap: fix generic_memmap_rw and generic_memmap_ro
  2011-02-10  7:12   ` Sascha Hauer
@ 2011-02-10 11:50     ` Jean-Christophe PLAGNIOL-VILLARD
  2011-02-10 12:01       ` Sascha Hauer
  0 siblings, 1 reply; 7+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-02-10 11:50 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 08:12 Thu 10 Feb     , Sascha Hauer wrote:
> On Thu, Feb 10, 2011 at 04:31:59AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > we check before the RW access for generic_memmap_ro instead of
> > generic_memmap_rw
> > 
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > ---
> >  drivers/base/driver.c |    5 +++--
> >  1 files changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/base/driver.c b/drivers/base/driver.c
> > index ff92e44..bd7464e 100644
> > --- a/drivers/base/driver.c
> > +++ b/drivers/base/driver.c
> > @@ -223,8 +223,6 @@ int generic_memmap_ro(struct cdev *cdev, void **map, int flags)
> >  	if (!cdev->dev)
> >  		return -EINVAL;
> >  
> > -	if (flags & PROT_WRITE)
> > -		return -EACCES;
> >  	*map = (void *)cdev->dev->map_base;
> >  	return 0;
> >  }
> > @@ -234,6 +232,9 @@ int generic_memmap_rw(struct cdev *cdev, void **map, int flags)
> >  	if (!cdev->dev)
> >  		return -EINVAL;
> >  
> > +	if (flags & PROT_WRITE)
> > +		return -EACCES;
> > +
> 
> So instead of allowing write access in the read/write function we now
> allow it in the readonly function? I'm afraid I don't understand this.
PROT_WRITE means ro no?

Best Regards,
J.

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/4] driver/memmap: fix generic_memmap_rw and generic_memmap_ro
  2011-02-10 11:50     ` Jean-Christophe PLAGNIOL-VILLARD
@ 2011-02-10 12:01       ` Sascha Hauer
  0 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2011-02-10 12:01 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Thu, Feb 10, 2011 at 12:50:14PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 08:12 Thu 10 Feb     , Sascha Hauer wrote:
> > On Thu, Feb 10, 2011 at 04:31:59AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > we check before the RW access for generic_memmap_ro instead of
> > > generic_memmap_rw
> > > 
> > > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > > ---
> > >  drivers/base/driver.c |    5 +++--
> > >  1 files changed, 3 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/drivers/base/driver.c b/drivers/base/driver.c
> > > index ff92e44..bd7464e 100644
> > > --- a/drivers/base/driver.c
> > > +++ b/drivers/base/driver.c
> > > @@ -223,8 +223,6 @@ int generic_memmap_ro(struct cdev *cdev, void **map, int flags)
> > >  	if (!cdev->dev)
> > >  		return -EINVAL;
> > >  
> > > -	if (flags & PROT_WRITE)
> > > -		return -EACCES;
> > >  	*map = (void *)cdev->dev->map_base;
> > >  	return 0;
> > >  }
> > > @@ -234,6 +232,9 @@ int generic_memmap_rw(struct cdev *cdev, void **map, int flags)
> > >  	if (!cdev->dev)
> > >  		return -EINVAL;
> > >  
> > > +	if (flags & PROT_WRITE)
> > > +		return -EACCES;
> > > +
> > 
> > So instead of allowing write access in the read/write function we now
> > allow it in the readonly function? I'm afraid I don't understand this.
> PROT_WRITE means ro no?

No. The semantics are from mmap(2):

	PROT_EXEC  Pages may be executed.

	PROT_READ  Pages may be read.

	PROT_WRITE Pages may be written.

	PROT_NONE  Pages may not be accessed.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-02-10 12:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-10  3:31 [PATCH 1/4] bus: remove dead code Jean-Christophe PLAGNIOL-VILLARD
2011-02-10  3:31 ` [PATCH 2/4] bus/driver: move from lib to drivers/base Jean-Christophe PLAGNIOL-VILLARD
2011-02-10  3:31 ` [PATCH 3/4] driver/memmap: fix generic_memmap_rw and generic_memmap_ro Jean-Christophe PLAGNIOL-VILLARD
2011-02-10  7:12   ` Sascha Hauer
2011-02-10 11:50     ` Jean-Christophe PLAGNIOL-VILLARD
2011-02-10 12:01       ` Sascha Hauer
2011-02-10  3:32 ` [PATCH 4/4] devices_shutdown: move remove call to bus Jean-Christophe PLAGNIOL-VILLARD

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox