Merge tag 'xfs-for-linus-v3.12-rc1-2' of git://oss.sgi.com/xfs/xfs
[cascardo/linux.git] / drivers / firmware / dmi_scan.c
index 232fa8f..fa0affb 100644 (file)
@@ -14,7 +14,7 @@
  * of and an antecedent to, SMBIOS, which stands for System
  * Management BIOS.  See further: http://www.dmtf.org/standards
  */
-static char dmi_empty_string[] = "        ";
+static const char dmi_empty_string[] = "        ";
 
 static u16 __initdata dmi_ver;
 /*
@@ -49,7 +49,7 @@ static const char * __init dmi_string_nosave(const struct dmi_header *dm, u8 s)
        return "";
 }
 
-static char * __init dmi_string(const struct dmi_header *dm, u8 s)
+static const char * __init dmi_string(const struct dmi_header *dm, u8 s)
 {
        const char *bp = dmi_string_nosave(dm, s);
        char *str;
@@ -62,8 +62,6 @@ static char * __init dmi_string(const struct dmi_header *dm, u8 s)
        str = dmi_alloc(len);
        if (str != NULL)
                strcpy(str, bp);
-       else
-               printk(KERN_ERR "dmi_string: cannot allocate %Zu bytes.\n", len);
 
        return str;
 }
@@ -133,17 +131,18 @@ static int __init dmi_checksum(const u8 *buf, u8 len)
        return sum == 0;
 }
 
-static char *dmi_ident[DMI_STRING_MAX];
+static const char *dmi_ident[DMI_STRING_MAX];
 static LIST_HEAD(dmi_devices);
 int dmi_available;
 
 /*
  *     Save a DMI string
  */
-static void __init dmi_save_ident(const struct dmi_header *dm, int slot, int string)
+static void __init dmi_save_ident(const struct dmi_header *dm, int slot,
+               int string)
 {
-       const char *d = (const char*) dm;
-       char *p;
+       const char *d = (const char *) dm;
+       const char *p;
 
        if (dmi_ident[slot])
                return;
@@ -155,9 +154,10 @@ static void __init dmi_save_ident(const struct dmi_header *dm, int slot, int str
        dmi_ident[slot] = p;
 }
 
-static void __init dmi_save_uuid(const struct dmi_header *dm, int slot, int index)
+static void __init dmi_save_uuid(const struct dmi_header *dm, int slot,
+               int index)
 {
-       const u8 *d = (u8*) dm + index;
+       const u8 *d = (u8 *) dm + index;
        char *s;
        int is_ff = 1, is_00 = 1, i;
 
@@ -188,12 +188,13 @@ static void __init dmi_save_uuid(const struct dmi_header *dm, int slot, int inde
        else
                sprintf(s, "%pUB", d);
 
-        dmi_ident[slot] = s;
+       dmi_ident[slot] = s;
 }
 
-static void __init dmi_save_type(const struct dmi_header *dm, int slot, int index)
+static void __init dmi_save_type(const struct dmi_header *dm, int slot,
+               int index)
 {
-       const u8 *d = (u8*) dm + index;
+       const u8 *d = (u8 *) dm + index;
        char *s;
 
        if (dmi_ident[slot])
@@ -216,10 +217,8 @@ static void __init dmi_save_one_device(int type, const char *name)
                return;
 
        dev = dmi_alloc(sizeof(*dev) + strlen(name) + 1);
-       if (!dev) {
-               printk(KERN_ERR "dmi_save_one_device: out of memory.\n");
+       if (!dev)
                return;
-       }
 
        dev->type = type;
        strcpy((char *)(dev + 1), name);
@@ -249,17 +248,14 @@ static void __init dmi_save_oem_strings_devices(const struct dmi_header *dm)
        struct dmi_device *dev;
 
        for (i = 1; i <= count; i++) {
-               char *devname = dmi_string(dm, i);
+               const char *devname = dmi_string(dm, i);
 
                if (devname == dmi_empty_string)
                        continue;
 
                dev = dmi_alloc(sizeof(*dev));
-               if (!dev) {
-                       printk(KERN_ERR
-                          "dmi_save_oem_strings_devices: out of memory.\n");
+               if (!dev)
                        break;
-               }
 
                dev->type = DMI_DEV_TYPE_OEM_STRING;
                dev->name = devname;
@@ -272,21 +268,17 @@ static void __init dmi_save_oem_strings_devices(const struct dmi_header *dm)
 static void __init dmi_save_ipmi_device(const struct dmi_header *dm)
 {
        struct dmi_device *dev;
-       void * data;
+       void *data;
 
        data = dmi_alloc(dm->length);
-       if (data == NULL) {
-               printk(KERN_ERR "dmi_save_ipmi_device: out of memory.\n");
+       if (data == NULL)
                return;
-       }
 
        memcpy(data, dm, dm->length);
 
        dev = dmi_alloc(sizeof(*dev));
-       if (!dev) {
-               printk(KERN_ERR "dmi_save_ipmi_device: out of memory.\n");
+       if (!dev)
                return;
-       }
 
        dev->type = DMI_DEV_TYPE_IPMI;
        dev->name = "IPMI controller";
@@ -301,10 +293,9 @@ static void __init dmi_save_dev_onboard(int instance, int segment, int bus,
        struct dmi_dev_onboard *onboard_dev;
 
        onboard_dev = dmi_alloc(sizeof(*onboard_dev) + strlen(name) + 1);
-       if (!onboard_dev) {
-               printk(KERN_ERR "dmi_save_dev_onboard: out of memory.\n");
+       if (!onboard_dev)
                return;
-       }
+
        onboard_dev->instance = instance;
        onboard_dev->segment = segment;
        onboard_dev->bus = bus;
@@ -320,7 +311,7 @@ static void __init dmi_save_dev_onboard(int instance, int segment, int bus,
 
 static void __init dmi_save_extended_devices(const struct dmi_header *dm)
 {
-       const u8 *d = (u8*) dm + 5;
+       const u8 *d = (u8 *) dm + 5;
 
        /* Skip disabled device */
        if ((*d & 0x80) == 0)
@@ -338,7 +329,7 @@ static void __init dmi_save_extended_devices(const struct dmi_header *dm)
  */
 static void __init dmi_decode(const struct dmi_header *dm, void *dummy)
 {
-       switch(dm->type) {
+       switch (dm->type) {
        case 0:         /* BIOS Information */
                dmi_save_ident(dm, DMI_BIOS_VENDOR, 4);
                dmi_save_ident(dm, DMI_BIOS_VERSION, 5);
@@ -502,13 +493,7 @@ void __init dmi_scan_machine(void)
                        dmi_available = 1;
                        goto out;
                }
-       }
-       else {
-               /*
-                * no iounmap() for that ioremap(); it would be a no-op, but
-                * it's so early in setup that sucker gets confused into doing
-                * what it shouldn't if we actually call it.
-                */
+       } else {
                p = dmi_ioremap(0xF0000, 0x10000);
                if (p == NULL)
                        goto error;
@@ -533,7 +518,7 @@ void __init dmi_scan_machine(void)
                dmi_iounmap(p, 0x10000);
        }
  error:
-       printk(KERN_INFO "DMI not present or invalid.\n");
+       pr_info("DMI not present or invalid.\n");
  out:
        dmi_initialized = 1;
 }
@@ -669,7 +654,7 @@ int dmi_name_in_serial(const char *str)
 
 /**
  *     dmi_name_in_vendors - Check if string is in the DMI system or board vendor name
- *     @str:   Case sensitive Name
+ *     @str: Case sensitive Name
  */
 int dmi_name_in_vendors(const char *str)
 {
@@ -696,13 +681,13 @@ EXPORT_SYMBOL(dmi_name_in_vendors);
  *     A new search is initiated by passing %NULL as the @from argument.
  *     If @from is not %NULL, searches continue from next device.
  */
-const struct dmi_device * dmi_find_device(int type, const char *name,
+const struct dmi_device *dmi_find_device(int type, const char *name,
                                    const struct dmi_device *from)
 {
        const struct list_head *head = from ? &from->list : &dmi_devices;
        struct list_head *d;
 
-       for(d = head->next; d != &dmi_devices; d = d->next) {
+       for (d = head->next; d != &dmi_devices; d = d->next) {
                const struct dmi_device *dev =
                        list_entry(d, struct dmi_device, list);