aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86/tc1100-wmi.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2009-12-04 03:36:09 -0500
committerLen Brown <len.brown@intel.com>2009-12-16 12:52:49 -0500
commit0ad3dc3af8ba028368263b190a7a270f8d5cf5ae (patch)
tree162039f0cd9f5f79c04731f2a4e03781ef8852a9 /drivers/platform/x86/tc1100-wmi.c
parent22763c5cf3690a681551162c15d34d935308c8d7 (diff)
tc1100-wmi - switch to using attribute group
Sysfs attribute group takes care of proper creation of a set of attributes and implements proper error unwinding so the driver does not have to do it. Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/platform/x86/tc1100-wmi.c')
-rw-r--r--drivers/platform/x86/tc1100-wmi.c39
1 files changed, 11 insertions, 28 deletions
diff --git a/drivers/platform/x86/tc1100-wmi.c b/drivers/platform/x86/tc1100-wmi.c
index 44166003d4ef..0d53d5166574 100644
--- a/drivers/platform/x86/tc1100-wmi.c
+++ b/drivers/platform/x86/tc1100-wmi.c
@@ -183,30 +183,15 @@ static DEVICE_ATTR(value, S_IWUGO | S_IRUGO | S_IWUSR, \
183show_set_bool(wireless, TC1100_INSTANCE_WIRELESS); 183show_set_bool(wireless, TC1100_INSTANCE_WIRELESS);
184show_set_bool(jogdial, TC1100_INSTANCE_JOGDIAL); 184show_set_bool(jogdial, TC1100_INSTANCE_JOGDIAL);
185 185
186static void remove_fs(void) 186static struct attribute *tc1100_attributes[] = {
187{ 187 &dev_attr_wireless.attr,
188 device_remove_file(&tc1100_device->dev, &dev_attr_wireless); 188 &dev_attr_jogdial.attr,
189 device_remove_file(&tc1100_device->dev, &dev_attr_jogdial); 189 NULL
190} 190};
191
192static int add_fs(void)
193{
194 int ret;
195
196 ret = device_create_file(&tc1100_device->dev, &dev_attr_wireless);
197 if (ret)
198 goto add_sysfs_error;
199
200 ret = device_create_file(&tc1100_device->dev, &dev_attr_jogdial);
201 if (ret)
202 goto add_sysfs_error;
203
204 return ret;
205 191
206add_sysfs_error: 192static struct attribute_group tc1100_attribute_group = {
207 remove_fs(); 193 .attrs = tc1100_attributes,
208 return ret; 194};
209}
210 195
211/* -------------------------------------------------------------------------- 196/* --------------------------------------------------------------------------
212 Driver Model 197 Driver Model
@@ -214,16 +199,14 @@ add_sysfs_error:
214 199
215static int tc1100_probe(struct platform_device *device) 200static int tc1100_probe(struct platform_device *device)
216{ 201{
217 int result = 0; 202 return sysfs_create_group(&device->dev.kobj, &tc1100_attribute_group);
218
219 result = add_fs();
220 return result;
221} 203}
222 204
223 205
224static int tc1100_remove(struct platform_device *device) 206static int tc1100_remove(struct platform_device *device)
225{ 207{
226 remove_fs(); 208 sysfs_remove_group(&device->dev.kobj, &tc1100_attribute_group);
209
227 return 0; 210 return 0;
228} 211}
229 212