static void dev_nvram_exit(void) { int order = 0; struct page *page, *end; if (nvram_class) { class_device_destroy(nvram_class, MKDEV(nvram_major, 0)); class_destroy(nvram_class); } if (nvram_major >= 0) unregister_chrdev(nvram_major, "nvram"); if (nvram_mtd) put_mtd_device(nvram_mtd); while ((PAGE_SIZE << order) < nvram_space) order++; end = virt_to_page(nvram_buf + (PAGE_SIZE << order) - 1); for (page = virt_to_page(nvram_buf); page <= end; page++) ClearPageReserved(page); _nvram_exit(); }
static void dev_nvram_exit(void) { int order = 0; struct page *page, *end; if (nvram_class) { #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36) class_device_destroy(nvram_class, MKDEV(nvram_major, 0)); #else /* 2.6.36 and up */ device_destroy(nvram_class, MKDEV(nvram_major, 0)); #endif class_destroy(nvram_class); } if (nvram_major >= 0) unregister_chrdev(nvram_major, "nvram"); if (nvram_mtd) put_mtd_device(nvram_mtd); while ((PAGE_SIZE << order) < MAX_NVRAM_SPACE) order++; end = virt_to_page(nvram_buf + (PAGE_SIZE << order) - 1); for (page = virt_to_page(nvram_buf); page <= end; page++) ClearPageReserved(page); _nvram_exit(); }
void BCMINITFN(nvram_exit)(void *si) { si_t *sih; sih = (si_t *)si; _nvram_exit(); }
void nvram_exit(void *sih) { if (nvram_header == NULL) { return; } _nvram_exit(); }
int BCMATTACHFN(nvram_init)(void *si) { bool isemb; int ret; si_t *sih; static int nvram_status = -1; #ifdef __ECOS if (!kernel_initial) return 0; #endif /* Check for previous 'restore defaults' condition */ if (nvram_status == 1) return 1; /* Check whether nvram already initilized */ if (nvram_status == 0 && !nvram_do_reset) return 0; sih = (si_t *)si; /* Restore defaults from embedded NVRAM if button held down */ if (nvram_do_reset) { /* Initialize with embedded NVRAM */ nvram_header = find_nvram(TRUE, &isemb); ret = _nvram_init(si); if (ret == 0) { nvram_status = 1; return 1; } nvram_status = -1; _nvram_exit(); } /* Find NVRAM */ nvram_header = find_nvram(FALSE, &isemb); ret = _nvram_init(si); if (ret == 0) { /* Restore defaults if embedded NVRAM used */ if (nvram_header && isemb) { ret = 1; } } nvram_status = ret; return ret; }
static void dev_nvram_exit(void) { int order = 0; struct page *page, *end; if (nvram_handle) devfs_unregister(nvram_handle); if (nvram_major >= 0) devfs_unregister_chrdev(nvram_major, "nvram"); if (nvram_mtd) put_mtd_device(nvram_mtd); while ((PAGE_SIZE << order) < NVRAM_SPACE) order++; end = virt_to_page(nvram_buf + (PAGE_SIZE << order) - 1); for (page = virt_to_page(nvram_buf); page <= end; page++) mem_map_unreserve(page); _nvram_exit(); }
void nvram_exit(void) { _nvram_exit(); }
int nvram_init(void *sbh) { #ifdef ASUS #else ulong offsets[] = { FLASH_BASE + 4 MB - NVRAM_SPACE, FLASH_BASE + 3 MB - NVRAM_SPACE, FLASH_BASE + 2 MB - NVRAM_SPACE, FLASH_BASE + 1 MB - NVRAM_SPACE, FLASH_BASE + 4 KB, FLASH_BASE + 1 KB, #ifdef _CFE_ (ulong) embedded_nvram, #endif }; int i, ret; #ifdef vxworks /* Initialize private semaphore */ if ((nvram_lock = semBCreate(SEM_Q_FIFO, SEM_FULL)) == NULL) { printf("nvram_init: semBCreate failed\n"); return ERROR; } #endif if (sbh) { for (i = 4; i < ARRAYSIZE(offsets); i++) { nvram_header = (struct nvram_header *) offsets[i]; if (nvram_header->magic == NVRAM_MAGIC) break; nvram_header = NULL; } /* Temporarily initialize with embedded NVRAM */ ret = _nvram_init(); if (ret == 0) { /* Restore defaults if button held down */ if (nvram_reset(sbh)) return 1; _nvram_exit(); } } /* Find NVRAM */ for (i = 0; i < ARRAYSIZE(offsets); i++) { nvram_header = (struct nvram_header *) offsets[i]; if (nvram_header->magic == NVRAM_MAGIC) break; nvram_header = NULL; } ret = _nvram_init(); if (ret == 0) { /* Restore defaults if embedded NVRAM used */ if (nvram_header && i >= 4) ret = 1; } return ret; #endif }