powerpc/pseries: Serialize cpu hotplug operations during deactivate Vs deallocate
[safe/jmp/linux-2.6] / arch / powerpc / kernel / nvram_64.c
index ada50aa..ad461e7 100644 (file)
 
 #undef DEBUG_NVRAM
 
-static int nvram_scan_partitions(void);
-static int nvram_setup_partition(void);
-static int nvram_create_os_partition(void);
-static int nvram_remove_os_partition(void);
-
 static struct nvram_partition * nvram_part;
 static long nvram_error_log_index = -1;
 static long nvram_error_log_size = 0;
 
-int no_logging = 1;    /* Until we initialize everything,
-                        * make sure we don't try logging
-                        * anything */
-
-extern volatile int error_log_cnt;
-
 struct err_log_info {
        int error_type;
        unsigned int seq_num;
@@ -150,8 +139,8 @@ out:
 
 }
 
-static int dev_nvram_ioctl(struct inode *inode, struct file *file,
-       unsigned int cmd, unsigned long arg)
+static long dev_nvram_ioctl(struct file *file, unsigned int cmd,
+                           unsigned long arg)
 {
        switch(cmd) {
 #ifdef CONFIG_PPC_PMAC
@@ -179,12 +168,12 @@ static int dev_nvram_ioctl(struct inode *inode, struct file *file,
        }
 }
 
-struct file_operations nvram_fops = {
-       .owner =        THIS_MODULE,
-       .llseek =       dev_nvram_llseek,
-       .read =         dev_nvram_read,
-       .write =        dev_nvram_write,
-       .ioctl =        dev_nvram_ioctl,
+const struct file_operations nvram_fops = {
+       .owner          = THIS_MODULE,
+       .llseek         = dev_nvram_llseek,
+       .read           = dev_nvram_read,
+       .write          = dev_nvram_write,
+       .unlocked_ioctl = dev_nvram_ioctl,
 };
 
 static struct miscdevice nvram_dev = {
@@ -195,7 +184,7 @@ static struct miscdevice nvram_dev = {
 
 
 #ifdef DEBUG_NVRAM
-static void nvram_print_partitions(char * label)
+static void __init nvram_print_partitions(char * label)
 {
        struct list_head * p;
        struct nvram_partition * tmp_part;
@@ -204,7 +193,7 @@ static void nvram_print_partitions(char * label)
        printk(KERN_WARNING "indx\t\tsig\tchks\tlen\tname\n");
        list_for_each(p, &nvram_part->partition) {
                tmp_part = list_entry(p, struct nvram_partition, partition);
-               printk(KERN_WARNING "%d    \t%02x\t%02x\t%d\t%s\n",
+               printk(KERN_WARNING "%4d    \t%02x\t%02x\t%d\t%s\n",
                       tmp_part->index, tmp_part->header.signature,
                       tmp_part->header.checksum, tmp_part->header.length,
                       tmp_part->header.name);
@@ -213,7 +202,7 @@ static void nvram_print_partitions(char * label)
 #endif
 
 
-static int nvram_write_header(struct nvram_partition * part)
+static int __init nvram_write_header(struct nvram_partition * part)
 {
        loff_t tmp_index;
        int rc;
@@ -225,7 +214,7 @@ static int nvram_write_header(struct nvram_partition * part)
 }
 
 
-static unsigned char nvram_checksum(struct nvram_header *p)
+static unsigned char __init nvram_checksum(struct nvram_header *p)
 {
        unsigned int c_sum, c_sum2;
        unsigned short *sp = (unsigned short *)p->name; /* assume 6 shorts */
@@ -239,32 +228,7 @@ static unsigned char nvram_checksum(struct nvram_header *p)
        return c_sum;
 }
 
-
-/*
- * Find an nvram partition, sig can be 0 for any
- * partition or name can be NULL for any name, else
- * tries to match both
- */
-struct nvram_partition *nvram_find_partition(int sig, const char *name)
-{
-       struct nvram_partition * part;
-       struct list_head * p;
-
-       list_for_each(p, &nvram_part->partition) {
-               part = list_entry(p, struct nvram_partition, partition);
-
-               if (sig && part->header.signature != sig)
-                       continue;
-               if (name && 0 != strncmp(name, part->header.name, 12))
-                       continue;
-               return part; 
-       }
-       return NULL;
-}
-EXPORT_SYMBOL(nvram_find_partition);
-
-
-static int nvram_remove_os_partition(void)
+static int __init nvram_remove_os_partition(void)
 {
        struct list_head *i;
        struct list_head *j;
@@ -330,7 +294,7 @@ static int nvram_remove_os_partition(void)
  * Will create a partition starting at the first free
  * space found if space has enough room.
  */
-static int nvram_create_os_partition(void)
+static int __init nvram_create_os_partition(void)
 {
        struct nvram_partition *part;
        struct nvram_partition *new_part;
@@ -433,7 +397,7 @@ static int nvram_create_os_partition(void)
  * 5.) If the max chunk cannot be allocated then try finding a chunk
  * that will satisfy the minum needed (NVRAM_MIN_REQ).
  */
-static int nvram_setup_partition(void)
+static int __init nvram_setup_partition(void)
 {
        struct list_head * p;
        struct nvram_partition * part;
@@ -491,7 +455,7 @@ static int nvram_setup_partition(void)
 }
 
 
-static int nvram_scan_partitions(void)
+static int __init nvram_scan_partitions(void)
 {
        loff_t cur_index = 0;
        struct nvram_header phead;
@@ -505,7 +469,7 @@ static int nvram_scan_partitions(void)
                return -ENODEV;
        total_size = ppc_md.nvram_size();
        
-       header = (char *) kmalloc(NVRAM_HEADER_LEN, GFP_KERNEL);
+       header = kmalloc(NVRAM_HEADER_LEN, GFP_KERNEL);
        if (!header) {
                printk(KERN_ERR "nvram_scan_partitions: Failed kmalloc\n");
                return -ENOMEM;
@@ -574,7 +538,7 @@ static int __init nvram_init(void)
        }
        
        /* initialize our anchor for the nvram partition list */
-       nvram_part = (struct nvram_partition *) kmalloc(sizeof(struct nvram_partition), GFP_KERNEL);
+       nvram_part = kmalloc(sizeof(struct nvram_partition), GFP_KERNEL);
        if (!nvram_part) {
                printk(KERN_ERR "nvram_init: Failed kmalloc\n");
                return -ENOMEM;
@@ -636,16 +600,13 @@ void __exit nvram_cleanup(void)
  * sequence #: The unique sequence # for each event. (until it wraps)
  * error log: The error log from event_scan
  */
-int nvram_write_error_log(char * buff, int length, unsigned int err_type)
+int nvram_write_error_log(char * buff, int length,
+                          unsigned int err_type, unsigned int error_log_cnt)
 {
        int rc;
        loff_t tmp_index;
        struct err_log_info info;
        
-       if (no_logging) {
-               return -EPERM;
-       }
-
        if (nvram_error_log_index == -1) {
                return -ESPIPE;
        }
@@ -678,7 +639,8 @@ int nvram_write_error_log(char * buff, int length, unsigned int err_type)
  *
  * Reads nvram for error log for at most 'length'
  */
-int nvram_read_error_log(char * buff, int length, unsigned int * err_type)
+int nvram_read_error_log(char * buff, int length,
+                         unsigned int * err_type, unsigned int * error_log_cnt)
 {
        int rc;
        loff_t tmp_index;
@@ -704,7 +666,7 @@ int nvram_read_error_log(char * buff, int length, unsigned int * err_type)
                return rc;
        }
 
-       error_log_cnt = info.seq_num;
+       *error_log_cnt = info.seq_num;
        *err_type = info.error_type;
 
        return 0;
@@ -719,6 +681,9 @@ int nvram_clear_error_log(void)
        int clear_word = ERR_FLAG_ALREADY_LOGGED;
        int rc;
 
+       if (nvram_error_log_index == -1)
+               return -1;
+
        tmp_index = nvram_error_log_index;
        
        rc = ppc_md.nvram_write((char *)&clear_word, sizeof(int), &tmp_index);