diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2010-08-05 14:18:03 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-08-05 14:18:03 -0700 |
commit | e9563355ac1175dd3440dc2ea5c28b27ed51a283 (patch) | |
tree | 8546d55832714b5d19ba4c7799266918ca04882e /drivers/staging/memrar/memrar_handler.c | |
parent | cdd854bc42b5e6c79bbbc40c6600d995ffe6e747 (diff) | |
parent | b12d1995f650e92f26184afd28e6cf40bf64467a (diff) | |
download | linux-stable-e9563355ac1175dd3440dc2ea5c28b27ed51a283.tar.gz linux-stable-e9563355ac1175dd3440dc2ea5c28b27ed51a283.tar.bz2 linux-stable-e9563355ac1175dd3440dc2ea5c28b27ed51a283.zip |
Staging: Merge staging-next into Linus's tree
Conflicts:
drivers/staging/Kconfig
drivers/staging/batman-adv/bat_sysfs.c
drivers/staging/batman-adv/device.c
drivers/staging/batman-adv/hard-interface.c
drivers/staging/cx25821/cx25821-audups11.c
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/memrar/memrar_handler.c')
-rw-r--r-- | drivers/staging/memrar/memrar_handler.c | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/drivers/staging/memrar/memrar_handler.c b/drivers/staging/memrar/memrar_handler.c index 41876f2b0e54..a98b3f1f11e0 100644 --- a/drivers/staging/memrar/memrar_handler.c +++ b/drivers/staging/memrar/memrar_handler.c @@ -278,19 +278,10 @@ static int memrar_init_rar_resources(int rarnum, char const *devname) BUG_ON(!memrar_is_valid_rar_type(rarnum)); BUG_ON(rar->allocated); - mutex_init(&rar->lock); - - /* - * Initialize the process table before we reach any - * code that exit on failure since the finalization - * code requires an initialized list. - */ - INIT_LIST_HEAD(&rar->buffers.list); - if (rar_get_address(rarnum, &low, &high) != 0) /* No RAR is available. */ return -ENODEV; - + if (low == 0 || high == 0) { rar->base = 0; rar->length = 0; @@ -310,7 +301,8 @@ static int memrar_init_rar_resources(int rarnum, char const *devname) /* Claim RAR memory as our own. */ if (request_mem_region(low, rar->length, devname) == NULL) { rar->length = 0; - pr_err("%s: Unable to claim RAR[%d] memory.\n", devname, rarnum); + pr_err("%s: Unable to claim RAR[%d] memory.\n", + devname, rarnum); pr_err("%s: RAR[%d] disabled.\n", devname, rarnum); return -EBUSY; } @@ -346,7 +338,7 @@ static int memrar_init_rar_resources(int rarnum, char const *devname) } pr_info("%s: BRAR[%d] bus address range = [0x%lx, 0x%lx]\n", - devname, rarnum, (unsigned long) low, (unsigned long) high); + devname, rarnum, (unsigned long) low, (unsigned long) high); pr_info("%s: BRAR[%d] size = %zu KiB\n", devname, rarnum, rar->allocator->capacity / 1024); @@ -530,7 +522,7 @@ static long memrar_get_stat(struct RAR_stat *r) { struct memrar_allocator *allocator; - if (!memrar_is_valid_rar_type(r->type)) + if (!memrar_is_valid_rar_type(r->type)) return -EINVAL; if (!memrars[r->type].allocated) @@ -939,9 +931,28 @@ static int memrar_registration_callback(unsigned long rar) static int __init memrar_init(void) { int err; + int i; printk(banner); + /* + * Some delayed initialization is performed in this driver. + * Make sure resources that are used during driver clean-up + * (e.g. during driver's release() function) are fully + * initialized before first use. This is particularly + * important for the case when the delayed initialization + * isn't completed, leaving behind a partially initialized + * driver. + * + * Such a scenario can occur when RAR is not available on the + * platform, and the driver is release()d. + */ + for (i = 0; i != ARRAY_SIZE(memrars); ++i) { + struct memrar_rar_info * const rar = &memrars[i]; + mutex_init(&rar->lock); + INIT_LIST_HEAD(&rar->buffers.list); + } + err = misc_register(&memrar_miscdev); if (err) return err; |