]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/acpi/fan.c
driver core: fix a lot of printk usages of bus_id
[linux-2.6-omap-h63xx.git] / drivers / acpi / fan.c
index c8e3cba423ef19d7548b63bfdb041d266454d4e1..2655bc1b4eebc7cbb02a16afc715e703dd0e3499 100644 (file)
@@ -148,7 +148,7 @@ acpi_fan_write_state(struct file *file, const char __user * buffer,
        int result = 0;
        struct seq_file *m = file->private_data;
        struct acpi_device *device = m->private;
-       char state_string[12] = { '\0' };
+       char state_string[3] = { '\0' };
 
        if (count > sizeof(state_string) - 1)
                return -EINVAL;
@@ -157,6 +157,12 @@ acpi_fan_write_state(struct file *file, const char __user * buffer,
                return -EFAULT;
 
        state_string[count] = '\0';
+       if ((state_string[0] < '0') || (state_string[0] > '3'))
+               return -EINVAL;
+       if (state_string[1] == '\n')
+               state_string[1] = '\0';
+       if (state_string[1] != '\0')
+               return -EINVAL;
 
        result = acpi_bus_set_power(device->handle,
                                    simple_strtoul(state_string, NULL, 0));
@@ -192,17 +198,13 @@ static int acpi_fan_add_fs(struct acpi_device *device)
        }
 
        /* 'status' [R/W] */
-       entry = create_proc_entry(ACPI_FAN_FILE_STATE,
-                                 S_IFREG | S_IRUGO | S_IWUSR,
-                                 acpi_device_dir(device));
+       entry = proc_create_data(ACPI_FAN_FILE_STATE,
+                                S_IFREG | S_IRUGO | S_IWUSR,
+                                acpi_device_dir(device),
+                                &acpi_fan_state_ops,
+                                device);
        if (!entry)
                return -ENODEV;
-       else {
-               entry->proc_fops = &acpi_fan_state_ops;
-               entry->data = device;
-               entry->owner = THIS_MODULE;
-       }
-
        return 0;
 }
 
@@ -260,24 +262,23 @@ static int acpi_fan_add(struct acpi_device *device)
                result = PTR_ERR(cdev);
                goto end;
        }
-       if (cdev) {
-               printk(KERN_INFO PREFIX
-                       "%s is registered as cooling_device%d\n",
-                       device->dev.bus_id, cdev->id);
-
-               acpi_driver_data(device) = cdev;
-               result = sysfs_create_link(&device->dev.kobj,
-                                          &cdev->device.kobj,
-                                          "thermal_cooling");
-               if (result)
-                       return result;
-
-               result = sysfs_create_link(&cdev->device.kobj,
-                                          &device->dev.kobj,
-                                          "device");
-               if (result)
-                       return result;
-       }
+
+       dev_info(&device->dev, "registered as cooling_device%d\n", cdev->id);
+
+       acpi_driver_data(device) = cdev;
+       result = sysfs_create_link(&device->dev.kobj,
+                                  &cdev->device.kobj,
+                                  "thermal_cooling");
+       if (result)
+               dev_err(&device->dev, "Failed to create sysfs link "
+                       "'thermal_cooling'\n");
+
+       result = sysfs_create_link(&cdev->device.kobj,
+                                  &device->dev.kobj,
+                                  "device");
+       if (result)
+               dev_err(&device->dev, "Failed to create sysfs link "
+                       "'device'\n");
 
        result = acpi_fan_add_fs(device);
        if (result)