aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorAlexey Starikovskiy <astarikovskiy@suse.de>2007-10-22 06:19:15 -0400
committerLen Brown <len.brown@intel.com>2007-10-25 16:31:31 -0400
commit968fc5dc2699434ea1cbddaf189f19c4eb4dbe55 (patch)
tree9f602bb0d7f678962aecf12110798825b3a01550 /drivers/acpi
parentc35923bc558074d4f5e6f9706e4cb9811ae55775 (diff)
ACPI: Fan: fan device does not need own structure
Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de> Acked-by: Rafael J. Wysocki <rjw@sisk.pl> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/fan.c32
1 files changed, 7 insertions, 25 deletions
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index c81f6bdb68b8..a6e149d692cb 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -68,10 +68,6 @@ static struct acpi_driver acpi_fan_driver = {
68 }, 68 },
69}; 69};
70 70
71struct acpi_fan {
72 struct acpi_device * device;
73};
74
75/* -------------------------------------------------------------------------- 71/* --------------------------------------------------------------------------
76 FS Interface (/proc) 72 FS Interface (/proc)
77 -------------------------------------------------------------------------- */ 73 -------------------------------------------------------------------------- */
@@ -80,12 +76,12 @@ static struct proc_dir_entry *acpi_fan_dir;
80 76
81static int acpi_fan_read_state(struct seq_file *seq, void *offset) 77static int acpi_fan_read_state(struct seq_file *seq, void *offset)
82{ 78{
83 struct acpi_fan *fan = seq->private; 79 struct acpi_device *device = seq->private;
84 int state = 0; 80 int state = 0;
85 81
86 82
87 if (fan) { 83 if (device) {
88 if (acpi_bus_get_power(fan->device->handle, &state)) 84 if (acpi_bus_get_power(device->handle, &state))
89 seq_printf(seq, "status: ERROR\n"); 85 seq_printf(seq, "status: ERROR\n");
90 else 86 else
91 seq_printf(seq, "status: %s\n", 87 seq_printf(seq, "status: %s\n",
@@ -105,11 +101,10 @@ acpi_fan_write_state(struct file *file, const char __user * buffer,
105{ 101{
106 int result = 0; 102 int result = 0;
107 struct seq_file *m = file->private_data; 103 struct seq_file *m = file->private_data;
108 struct acpi_fan *fan = m->private; 104 struct acpi_device *device = m->private;
109 char state_string[12] = { '\0' }; 105 char state_string[12] = { '\0' };
110 106
111 107 if (count > sizeof(state_string) - 1)
112 if (!fan || (count > sizeof(state_string) - 1))
113 return -EINVAL; 108 return -EINVAL;
114 109
115 if (copy_from_user(state_string, buffer, count)) 110 if (copy_from_user(state_string, buffer, count))
@@ -117,7 +112,7 @@ acpi_fan_write_state(struct file *file, const char __user * buffer,
117 112
118 state_string[count] = '\0'; 113 state_string[count] = '\0';
119 114
120 result = acpi_bus_set_power(fan->device->handle, 115 result = acpi_bus_set_power(device->handle,
121 simple_strtoul(state_string, NULL, 0)); 116 simple_strtoul(state_string, NULL, 0));
122 if (result) 117 if (result)
123 return result; 118 return result;
@@ -158,7 +153,7 @@ static int acpi_fan_add_fs(struct acpi_device *device)
158 return -ENODEV; 153 return -ENODEV;
159 else { 154 else {
160 entry->proc_fops = &acpi_fan_state_ops; 155 entry->proc_fops = &acpi_fan_state_ops;
161 entry->data = acpi_driver_data(device); 156 entry->data = device;
162 entry->owner = THIS_MODULE; 157 entry->owner = THIS_MODULE;
163 } 158 }
164 159
@@ -191,14 +186,8 @@ static int acpi_fan_add(struct acpi_device *device)
191 if (!device) 186 if (!device)
192 return -EINVAL; 187 return -EINVAL;
193 188
194 fan = kzalloc(sizeof(struct acpi_fan), GFP_KERNEL);
195 if (!fan)
196 return -ENOMEM;
197
198 fan->device = device;
199 strcpy(acpi_device_name(device), "Fan"); 189 strcpy(acpi_device_name(device), "Fan");
200 strcpy(acpi_device_class(device), ACPI_FAN_CLASS); 190 strcpy(acpi_device_class(device), ACPI_FAN_CLASS);
201 acpi_driver_data(device) = fan;
202 191
203 result = acpi_bus_get_power(device->handle, &state); 192 result = acpi_bus_get_power(device->handle, &state);
204 if (result) { 193 if (result) {
@@ -227,18 +216,11 @@ static int acpi_fan_add(struct acpi_device *device)
227 216
228static int acpi_fan_remove(struct acpi_device *device, int type) 217static int acpi_fan_remove(struct acpi_device *device, int type)
229{ 218{
230 struct acpi_fan *fan = NULL;
231
232
233 if (!device || !acpi_driver_data(device)) 219 if (!device || !acpi_driver_data(device))
234 return -EINVAL; 220 return -EINVAL;
235 221
236 fan = acpi_driver_data(device);
237
238 acpi_fan_remove_fs(device); 222 acpi_fan_remove_fs(device);
239 223
240 kfree(fan);
241
242 return 0; 224 return 0;
243} 225}
244 226