diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2011-07-16 12:54:22 +0800 |
---|---|---|
committer | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2011-07-18 07:57:49 +0800 |
commit | 126c9b69cf6241673e0ccecc542ed3b9935308df (patch) | |
tree | da48f9af736913ca9805c140024f06dcf01d5b34 /lib | |
parent | f4f952faa4047bfeb80ba6b960d331724807d52a (diff) | |
download | barebox-126c9b69cf6241673e0ccecc542ed3b9935308df.tar.gz barebox-126c9b69cf6241673e0ccecc542ed3b9935308df.tar.xz |
device: introduce resource structure to simplify resource declaration
and add multi resource per device support
for now we keep the old map_base and size temporary but will switch all of
the used step by step to them resource way
and mirror the first resource to the map_base and size if available
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/driver.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/driver.c b/lib/driver.c index 4c10a49c7c..7b381ab890 100644 --- a/lib/driver.c +++ b/lib/driver.c @@ -103,6 +103,25 @@ int register_device(struct device_d *new_device) { struct driver_d *drv; + /* if no map_base available use the first resource if available + * so we do not need to duplicate it + * Temporary fixup until we get rid of map_base and size + */ + if (new_device->map_base) { + if (new_device->resource) { + dev_err(new_device, "map_base and resource specifed\n"); + return -EIO; + } + dev_warn(new_device, "uses map_base. Please convert to use resources\n"); + new_device->resource = xzalloc(sizeof(struct resource)); + new_device->resource[0].start = new_device->map_base; + new_device->resource[0].size = new_device->size; + new_device->num_resources = 1; + } else if (new_device->resource) { + new_device->map_base = new_device->resource[0].start; + new_device->size = new_device->resource[0].size; + } + if (new_device->id < 0) { new_device->id = get_free_deviceid(new_device->name); } else { |