diff options
author | David Brownell <dbrownell@users.sourceforge.net> | 2008-06-12 15:13:55 -0400 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2008-06-24 09:33:40 -0400 |
commit | 7d5789616dd3090fe8486fbb849da3e9d9f36bb9 (patch) | |
tree | bf78d2c5670facb0413a4126b1684eab7e865fb9 /drivers/pcmcia/rsrc_nonstatic.c | |
parent | 785e821eb679c171f453722f15c6791de0c1abe1 (diff) |
pcmcia: simplify rsrc_nonstatic attributes
Simplify sysfs attribute registration for sockets without static
resource mappings by using an attribute_group. This shrinks object
size a bit: use loops in sysfs code, but have more data.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/pcmcia/rsrc_nonstatic.c')
-rw-r--r-- | drivers/pcmcia/rsrc_nonstatic.c | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c index 0fcf763b9175..4123155e2f7a 100644 --- a/drivers/pcmcia/rsrc_nonstatic.c +++ b/drivers/pcmcia/rsrc_nonstatic.c | |||
@@ -1008,41 +1008,34 @@ static ssize_t store_mem_db(struct device *dev, | |||
1008 | } | 1008 | } |
1009 | static DEVICE_ATTR(available_resources_mem, 0600, show_mem_db, store_mem_db); | 1009 | static DEVICE_ATTR(available_resources_mem, 0600, show_mem_db, store_mem_db); |
1010 | 1010 | ||
1011 | static struct device_attribute *pccard_rsrc_attributes[] = { | 1011 | static struct attribute *pccard_rsrc_attributes[] = { |
1012 | &dev_attr_available_resources_io, | 1012 | &dev_attr_available_resources_io.attr, |
1013 | &dev_attr_available_resources_mem, | 1013 | &dev_attr_available_resources_mem.attr, |
1014 | NULL, | 1014 | NULL, |
1015 | }; | 1015 | }; |
1016 | 1016 | ||
1017 | static const struct attribute_group rsrc_attributes = { | ||
1018 | .attrs = pccard_rsrc_attributes, | ||
1019 | }; | ||
1020 | |||
1017 | static int __devinit pccard_sysfs_add_rsrc(struct device *dev, | 1021 | static int __devinit pccard_sysfs_add_rsrc(struct device *dev, |
1018 | struct class_interface *class_intf) | 1022 | struct class_interface *class_intf) |
1019 | { | 1023 | { |
1020 | struct pcmcia_socket *s = dev_get_drvdata(dev); | 1024 | struct pcmcia_socket *s = dev_get_drvdata(dev); |
1021 | struct device_attribute **attr; | 1025 | |
1022 | int ret = 0; | ||
1023 | if (s->resource_ops != &pccard_nonstatic_ops) | 1026 | if (s->resource_ops != &pccard_nonstatic_ops) |
1024 | return 0; | 1027 | return 0; |
1025 | 1028 | return sysfs_create_group(&dev->kobj, &rsrc_attributes); | |
1026 | for (attr = pccard_rsrc_attributes; *attr; attr++) { | ||
1027 | ret = device_create_file(dev, *attr); | ||
1028 | if (ret) | ||
1029 | break; | ||
1030 | } | ||
1031 | |||
1032 | return ret; | ||
1033 | } | 1029 | } |
1034 | 1030 | ||
1035 | static void __devexit pccard_sysfs_remove_rsrc(struct device *dev, | 1031 | static void __devexit pccard_sysfs_remove_rsrc(struct device *dev, |
1036 | struct class_interface *class_intf) | 1032 | struct class_interface *class_intf) |
1037 | { | 1033 | { |
1038 | struct pcmcia_socket *s = dev_get_drvdata(dev); | 1034 | struct pcmcia_socket *s = dev_get_drvdata(dev); |
1039 | struct device_attribute **attr; | ||
1040 | 1035 | ||
1041 | if (s->resource_ops != &pccard_nonstatic_ops) | 1036 | if (s->resource_ops != &pccard_nonstatic_ops) |
1042 | return; | 1037 | return; |
1043 | 1038 | sysfs_remove_group(&dev->kobj, &rsrc_attributes); | |
1044 | for (attr = pccard_rsrc_attributes; *attr; attr++) | ||
1045 | device_remove_file(dev, *attr); | ||
1046 | } | 1039 | } |
1047 | 1040 | ||
1048 | static struct class_interface pccard_rsrc_interface __refdata = { | 1041 | static struct class_interface pccard_rsrc_interface __refdata = { |