Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

driver model: constify attribute groups

Let attribute group vectors be declared "const". We'd
like to let most attribute metadata live in read-only
sections... this is a start.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

David Brownell and committed by
Greg Kroah-Hartman
a4dbd674 5b2ea2f1

+39 -39
+1 -1
block/genhd.c
··· 903 903 .attrs = disk_attrs, 904 904 }; 905 905 906 - static struct attribute_group *disk_attr_groups[] = { 906 + static const struct attribute_group *disk_attr_groups[] = { 907 907 &disk_attr_group, 908 908 NULL 909 909 };
+2 -2
drivers/base/core.c
··· 341 341 } 342 342 343 343 static int device_add_groups(struct device *dev, 344 - struct attribute_group **groups) 344 + const struct attribute_group **groups) 345 345 { 346 346 int error = 0; 347 347 int i; ··· 361 361 } 362 362 363 363 static void device_remove_groups(struct device *dev, 364 - struct attribute_group **groups) 364 + const struct attribute_group **groups) 365 365 { 366 366 int i; 367 367
+2 -2
drivers/base/driver.c
··· 181 181 EXPORT_SYMBOL_GPL(put_driver); 182 182 183 183 static int driver_add_groups(struct device_driver *drv, 184 - struct attribute_group **groups) 184 + const struct attribute_group **groups) 185 185 { 186 186 int error = 0; 187 187 int i; ··· 201 201 } 202 202 203 203 static void driver_remove_groups(struct device_driver *drv, 204 - struct attribute_group **groups) 204 + const struct attribute_group **groups) 205 205 { 206 206 int i; 207 207
+1 -1
drivers/block/cciss.c
··· 572 572 .attrs = cciss_dev_attrs, 573 573 }; 574 574 575 - static struct attribute_group *cciss_dev_attr_groups[] = { 575 + static const struct attribute_group *cciss_dev_attr_groups[] = { 576 576 &cciss_dev_attr_group, 577 577 NULL 578 578 };
+1 -1
drivers/firewire/core-device.c
··· 312 312 group->groups[0] = &group->group; 313 313 group->groups[1] = NULL; 314 314 group->group.attrs = group->attrs; 315 - dev->groups = group->groups; 315 + dev->groups = (const struct attribute_group **) group->groups; 316 316 } 317 317 318 318 static ssize_t modalias_show(struct device *dev,
+1 -1
drivers/firmware/dmi-id.c
··· 139 139 .attrs = sys_dmi_attributes, 140 140 }; 141 141 142 - static struct attribute_group* sys_dmi_attribute_groups[] = { 142 + static const struct attribute_group* sys_dmi_attribute_groups[] = { 143 143 &sys_dmi_attribute_group, 144 144 NULL 145 145 };
+1 -1
drivers/infiniband/hw/ehca/ehca_main.c
··· 623 623 .attrs = ehca_drv_attrs 624 624 }; 625 625 626 - static struct attribute_group *ehca_drv_attr_groups[] = { 626 + static const struct attribute_group *ehca_drv_attr_groups[] = { 627 627 &ehca_drv_attr_grp, 628 628 NULL, 629 629 };
+1 -1
drivers/infiniband/hw/ipath/ipath_kernel.h
··· 1286 1286 1287 1287 extern const char ib_ipath_version[]; 1288 1288 1289 - extern struct attribute_group *ipath_driver_attr_groups[]; 1289 + extern const struct attribute_group *ipath_driver_attr_groups[]; 1290 1290 1291 1291 int ipath_device_create_group(struct device *, struct ipath_devdata *); 1292 1292 void ipath_device_remove_group(struct device *, struct ipath_devdata *);
+1 -1
drivers/infiniband/hw/ipath/ipath_sysfs.c
··· 1069 1069 return ret; 1070 1070 } 1071 1071 1072 - struct attribute_group *ipath_driver_attr_groups[] = { 1072 + const struct attribute_group *ipath_driver_attr_groups[] = { 1073 1073 &driver_attr_group, 1074 1074 NULL, 1075 1075 };
+1 -1
drivers/input/input.c
··· 1144 1144 .attrs = input_dev_caps_attrs, 1145 1145 }; 1146 1146 1147 - static struct attribute_group *input_dev_attr_groups[] = { 1147 + static const struct attribute_group *input_dev_attr_groups[] = { 1148 1148 &input_dev_attr_group, 1149 1149 &input_dev_id_attr_group, 1150 1150 &input_dev_caps_attr_group,
+2 -2
drivers/misc/enclosure.c
··· 238 238 put_device(dev->parent); 239 239 } 240 240 241 - static struct attribute_group *enclosure_groups[]; 241 + static const struct attribute_group *enclosure_groups[]; 242 242 243 243 /** 244 244 * enclosure_component_register - add a particular component to an enclosure ··· 536 536 .attrs = enclosure_component_attrs, 537 537 }; 538 538 539 - static struct attribute_group *enclosure_groups[] = { 539 + static const struct attribute_group *enclosure_groups[] = { 540 540 &enclosure_group, 541 541 NULL 542 542 };
+1 -1
drivers/mmc/core/mmc.c
··· 276 276 .attrs = mmc_std_attrs, 277 277 }; 278 278 279 - static struct attribute_group *mmc_attr_groups[] = { 279 + static const struct attribute_group *mmc_attr_groups[] = { 280 280 &mmc_std_attr_group, 281 281 NULL, 282 282 };
+1 -1
drivers/mmc/core/sd.c
··· 314 314 .attrs = sd_std_attrs, 315 315 }; 316 316 317 - static struct attribute_group *sd_attr_groups[] = { 317 + static const struct attribute_group *sd_attr_groups[] = { 318 318 &sd_std_attr_group, 319 319 NULL, 320 320 };
+1 -1
drivers/mtd/mtdcore.c
··· 217 217 .attrs = mtd_attrs, 218 218 }; 219 219 220 - struct attribute_group *mtd_groups[] = { 220 + const struct attribute_group *mtd_groups[] = { 221 221 &mtd_group, 222 222 NULL, 223 223 };
+1 -1
drivers/s390/cio/css.c
··· 266 266 .attrs = subch_attrs, 267 267 }; 268 268 269 - static struct attribute_group *default_subch_attr_groups[] = { 269 + static const struct attribute_group *default_subch_attr_groups[] = { 270 270 &subch_attr_group, 271 271 NULL, 272 272 };
+1 -1
drivers/s390/cio/device.c
··· 656 656 .attrs = ccwdev_attrs, 657 657 }; 658 658 659 - static struct attribute_group *ccwdev_attr_groups[] = { 659 + static const struct attribute_group *ccwdev_attr_groups[] = { 660 660 &ccwdev_attr_group, 661 661 NULL, 662 662 };
+1 -1
drivers/s390/net/netiucv.c
··· 2159 2159 .attrs = netiucv_drv_attrs, 2160 2160 }; 2161 2161 2162 - static struct attribute_group *netiucv_drv_attr_groups[] = { 2162 + static const struct attribute_group *netiucv_drv_attr_groups[] = { 2163 2163 &netiucv_drv_attr_group, 2164 2164 NULL, 2165 2165 };
+1 -1
drivers/scsi/scsi_priv.h
··· 132 132 extern void __scsi_remove_device(struct scsi_device *); 133 133 134 134 extern struct bus_type scsi_bus_type; 135 - extern struct attribute_group *scsi_sysfs_shost_attr_groups[]; 135 + extern const struct attribute_group *scsi_sysfs_shost_attr_groups[]; 136 136 137 137 /* scsi_netlink.c */ 138 138 #ifdef CONFIG_SCSI_NETLINK
+2 -2
drivers/scsi/scsi_sysfs.c
··· 275 275 .attrs = scsi_sysfs_shost_attrs, 276 276 }; 277 277 278 - struct attribute_group *scsi_sysfs_shost_attr_groups[] = { 278 + const struct attribute_group *scsi_sysfs_shost_attr_groups[] = { 279 279 &scsi_shost_attr_group, 280 280 NULL 281 281 }; ··· 745 745 .attrs = scsi_sdev_attrs, 746 746 }; 747 747 748 - static struct attribute_group *scsi_sdev_attr_groups[] = { 748 + static const struct attribute_group *scsi_sdev_attr_groups[] = { 749 749 &scsi_sdev_attr_group, 750 750 NULL 751 751 };
+1 -1
drivers/usb/core/endpoint.c
··· 154 154 static struct attribute_group ep_dev_attr_grp = { 155 155 .attrs = ep_dev_attrs, 156 156 }; 157 - static struct attribute_group *ep_dev_groups[] = { 157 + static const struct attribute_group *ep_dev_groups[] = { 158 158 &ep_dev_attr_grp, 159 159 NULL 160 160 };
+2 -2
drivers/usb/core/sysfs.c
··· 573 573 .is_visible = dev_string_attrs_are_visible, 574 574 }; 575 575 576 - struct attribute_group *usb_device_groups[] = { 576 + const struct attribute_group *usb_device_groups[] = { 577 577 &dev_attr_grp, 578 578 &dev_string_attr_grp, 579 579 NULL ··· 799 799 .is_visible = intf_assoc_attrs_are_visible, 800 800 }; 801 801 802 - struct attribute_group *usb_interface_groups[] = { 802 + const struct attribute_group *usb_interface_groups[] = { 803 803 &intf_attr_grp, 804 804 &intf_assoc_attr_grp, 805 805 NULL
+2 -2
drivers/usb/core/usb.h
··· 152 152 extern const char *usbcore_name; 153 153 154 154 /* sysfs stuff */ 155 - extern struct attribute_group *usb_device_groups[]; 156 - extern struct attribute_group *usb_interface_groups[]; 155 + extern const struct attribute_group *usb_device_groups[]; 156 + extern const struct attribute_group *usb_interface_groups[]; 157 157 158 158 /* usbfs stuff */ 159 159 extern struct mutex usbfs_mutex;
+1 -1
drivers/uwb/lc-dev.c
··· 255 255 .attrs = dev_attrs, 256 256 }; 257 257 258 - static struct attribute_group *groups[] = { 258 + static const struct attribute_group *groups[] = { 259 259 &dev_attr_group, 260 260 NULL, 261 261 };
+1 -1
fs/partitions/check.c
··· 312 312 .attrs = part_attrs, 313 313 }; 314 314 315 - static struct attribute_group *part_attr_groups[] = { 315 + static const struct attribute_group *part_attr_groups[] = { 316 316 &part_attr_group, 317 317 #ifdef CONFIG_BLK_DEV_IO_TRACE 318 318 &blk_trace_attr_group,
+1 -1
include/linux/attribute_container.h
··· 17 17 struct list_head node; 18 18 struct klist containers; 19 19 struct class *class; 20 - struct attribute_group *grp; 20 + const struct attribute_group *grp; 21 21 struct device_attribute **attrs; 22 22 int (*match)(struct attribute_container *, struct device *); 23 23 #define ATTRIBUTE_CONTAINER_NO_CLASSDEVS 0x01
+3 -3
include/linux/device.h
··· 131 131 void (*shutdown) (struct device *dev); 132 132 int (*suspend) (struct device *dev, pm_message_t state); 133 133 int (*resume) (struct device *dev); 134 - struct attribute_group **groups; 134 + const struct attribute_group **groups; 135 135 136 136 const struct dev_pm_ops *pm; 137 137 ··· 288 288 */ 289 289 struct device_type { 290 290 const char *name; 291 - struct attribute_group **groups; 291 + const struct attribute_group **groups; 292 292 int (*uevent)(struct device *dev, struct kobj_uevent_env *env); 293 293 char *(*nodename)(struct device *dev); 294 294 void (*release)(struct device *dev); ··· 412 412 413 413 struct klist_node knode_class; 414 414 struct class *class; 415 - struct attribute_group **groups; /* optional groups */ 415 + const struct attribute_group **groups; /* optional groups */ 416 416 417 417 void (*release)(struct device *dev); 418 418 };
+1 -1
include/linux/netdevice.h
··· 895 895 /* class/net/name entry */ 896 896 struct device dev; 897 897 /* space for optional statistics and wireless sysfs groups */ 898 - struct attribute_group *sysfs_groups[3]; 898 + const struct attribute_group *sysfs_groups[3]; 899 899 900 900 /* rtnetlink link ops */ 901 901 const struct rtnl_link_ops *rtnl_link_ops;
+1 -1
include/linux/transport_class.h
··· 55 55 56 56 struct transport_container { 57 57 struct attribute_container ac; 58 - struct attribute_group *statistics; 58 + const struct attribute_group *statistics; 59 59 }; 60 60 61 61 #define attribute_container_to_transport_container(x) \
+2 -2
net/bluetooth/hci_sysfs.c
··· 68 68 .attrs = bt_link_attrs, 69 69 }; 70 70 71 - static struct attribute_group *bt_link_groups[] = { 71 + static const struct attribute_group *bt_link_groups[] = { 72 72 &bt_link_group, 73 73 NULL 74 74 }; ··· 392 392 .attrs = bt_host_attrs, 393 393 }; 394 394 395 - static struct attribute_group *bt_host_groups[] = { 395 + static const struct attribute_group *bt_host_groups[] = { 396 396 &bt_host_group, 397 397 NULL 398 398 };
+1 -1
net/core/net-sysfs.c
··· 493 493 int netdev_register_kobject(struct net_device *net) 494 494 { 495 495 struct device *dev = &(net->dev); 496 - struct attribute_group **groups = net->sysfs_groups; 496 + const struct attribute_group **groups = net->sysfs_groups; 497 497 498 498 dev->class = &net_class; 499 499 dev->platform_data = net;