diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2011-07-21 13:47:16 +0800 |
---|---|---|
committer | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2011-07-21 13:47:16 +0800 |
commit | 6ae6553e1a82923033d940bb44aa5048d78e16d4 (patch) | |
tree | 0b74f210438db1879c4252feb7446cf48b725831 /drivers | |
parent | 85283965dc0977496d2159cbe7f25ac3d96187dd (diff) | |
download | barebox-6ae6553e1a82923033d940bb44aa5048d78e16d4.tar.gz barebox-6ae6553e1a82923033d940bb44aa5048d78e16d4.tar.xz |
drivers: move resource generic management to driver/base/resource.c
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/base/Makefile | 1 | ||||
-rw-r--r-- | drivers/base/resource.c | 46 |
2 files changed, 47 insertions, 0 deletions
diff --git a/drivers/base/Makefile b/drivers/base/Makefile index 2d94723f90..957ca5ac2a 100644 --- a/drivers/base/Makefile +++ b/drivers/base/Makefile @@ -1,2 +1,3 @@ obj-y += driver.o obj-y += platform.o +obj-y += resource.o diff --git a/drivers/base/resource.c b/drivers/base/resource.c new file mode 100644 index 0000000000..7b0020bb69 --- /dev/null +++ b/drivers/base/resource.c @@ -0,0 +1,46 @@ +/* + * (C) Copyright 2000 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + * + * 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 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. + * + * 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> +#include <xfuncs.h> + +struct device_d *add_mem_device(const char *name, resource_size_t start, + resource_size_t size, unsigned int flags) +{ + struct device_d *dev; + + dev = xzalloc(sizeof(*dev)); + strcpy(dev->name, "mem"); + dev->id = -1; + dev->resource = xzalloc(sizeof(struct resource)); + dev->num_resources = 1; + dev->resource[0].name = xstrdup(name); + dev->resource[0].start = start; + dev->resource[0].size = size; + dev->resource[0].flags = IORESOURCE_MEM | flags; + + register_device(dev); + + return dev; +} |