Bläddra i källkod

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>
David Brownell 16 år sedan
förälder
incheckning
a4dbd6740d

+ 1 - 1
block/genhd.c

@@ -903,7 +903,7 @@ static struct attribute_group disk_attr_group = {
 	.attrs = disk_attrs,
 	.attrs = disk_attrs,
 };
 };
 
 
-static struct attribute_group *disk_attr_groups[] = {
+static const struct attribute_group *disk_attr_groups[] = {
 	&disk_attr_group,
 	&disk_attr_group,
 	NULL
 	NULL
 };
 };

+ 2 - 2
drivers/base/core.c

@@ -341,7 +341,7 @@ static void device_remove_attributes(struct device *dev,
 }
 }
 
 
 static int device_add_groups(struct device *dev,
 static int device_add_groups(struct device *dev,
-			     struct attribute_group **groups)
+			     const struct attribute_group **groups)
 {
 {
 	int error = 0;
 	int error = 0;
 	int i;
 	int i;
@@ -361,7 +361,7 @@ static int device_add_groups(struct device *dev,
 }
 }
 
 
 static void device_remove_groups(struct device *dev,
 static void device_remove_groups(struct device *dev,
-				 struct attribute_group **groups)
+				 const struct attribute_group **groups)
 {
 {
 	int i;
 	int i;
 
 

+ 2 - 2
drivers/base/driver.c

@@ -181,7 +181,7 @@ void put_driver(struct device_driver *drv)
 EXPORT_SYMBOL_GPL(put_driver);
 EXPORT_SYMBOL_GPL(put_driver);
 
 
 static int driver_add_groups(struct device_driver *drv,
 static int driver_add_groups(struct device_driver *drv,
-			     struct attribute_group **groups)
+			     const struct attribute_group **groups)
 {
 {
 	int error = 0;
 	int error = 0;
 	int i;
 	int i;
@@ -201,7 +201,7 @@ static int driver_add_groups(struct device_driver *drv,
 }
 }
 
 
 static void driver_remove_groups(struct device_driver *drv,
 static void driver_remove_groups(struct device_driver *drv,
-				 struct attribute_group **groups)
+				 const struct attribute_group **groups)
 {
 {
 	int i;
 	int i;
 
 

+ 1 - 1
drivers/block/cciss.c

@@ -572,7 +572,7 @@ static struct attribute_group cciss_dev_attr_group = {
 	.attrs = cciss_dev_attrs,
 	.attrs = cciss_dev_attrs,
 };
 };
 
 
-static struct attribute_group *cciss_dev_attr_groups[] = {
+static const struct attribute_group *cciss_dev_attr_groups[] = {
 	&cciss_dev_attr_group,
 	&cciss_dev_attr_group,
 	NULL
 	NULL
 };
 };

+ 1 - 1
drivers/firewire/core-device.c

@@ -312,7 +312,7 @@ static void init_fw_attribute_group(struct device *dev,
 	group->groups[0] = &group->group;
 	group->groups[0] = &group->group;
 	group->groups[1] = NULL;
 	group->groups[1] = NULL;
 	group->group.attrs = group->attrs;
 	group->group.attrs = group->attrs;
-	dev->groups = group->groups;
+	dev->groups = (const struct attribute_group **) group->groups;
 }
 }
 
 
 static ssize_t modalias_show(struct device *dev,
 static ssize_t modalias_show(struct device *dev,

+ 1 - 1
drivers/firmware/dmi-id.c

@@ -139,7 +139,7 @@ static struct attribute_group sys_dmi_attribute_group = {
 	.attrs = sys_dmi_attributes,
 	.attrs = sys_dmi_attributes,
 };
 };
 
 
-static struct attribute_group* sys_dmi_attribute_groups[] = {
+static const struct attribute_group* sys_dmi_attribute_groups[] = {
 	&sys_dmi_attribute_group,
 	&sys_dmi_attribute_group,
 	NULL
 	NULL
 };
 };

+ 1 - 1
drivers/infiniband/hw/ehca/ehca_main.c

@@ -623,7 +623,7 @@ static struct attribute_group ehca_drv_attr_grp = {
 	.attrs = ehca_drv_attrs
 	.attrs = ehca_drv_attrs
 };
 };
 
 
-static struct attribute_group *ehca_drv_attr_groups[] = {
+static const struct attribute_group *ehca_drv_attr_groups[] = {
 	&ehca_drv_attr_grp,
 	&ehca_drv_attr_grp,
 	NULL,
 	NULL,
 };
 };

+ 1 - 1
drivers/infiniband/hw/ipath/ipath_kernel.h

@@ -1286,7 +1286,7 @@ struct device_driver;
 
 
 extern const char ib_ipath_version[];
 extern const char ib_ipath_version[];
 
 
-extern struct attribute_group *ipath_driver_attr_groups[];
+extern const struct attribute_group *ipath_driver_attr_groups[];
 
 
 int ipath_device_create_group(struct device *, struct ipath_devdata *);
 int ipath_device_create_group(struct device *, struct ipath_devdata *);
 void ipath_device_remove_group(struct device *, struct ipath_devdata *);
 void ipath_device_remove_group(struct device *, struct ipath_devdata *);

+ 1 - 1
drivers/infiniband/hw/ipath/ipath_sysfs.c

@@ -1069,7 +1069,7 @@ static ssize_t show_tempsense(struct device *dev,
 	return ret;
 	return ret;
 }
 }
 
 
-struct attribute_group *ipath_driver_attr_groups[] = {
+const struct attribute_group *ipath_driver_attr_groups[] = {
 	&driver_attr_group,
 	&driver_attr_group,
 	NULL,
 	NULL,
 };
 };

+ 1 - 1
drivers/input/input.c

@@ -1144,7 +1144,7 @@ static struct attribute_group input_dev_caps_attr_group = {
 	.attrs	= input_dev_caps_attrs,
 	.attrs	= input_dev_caps_attrs,
 };
 };
 
 
-static struct attribute_group *input_dev_attr_groups[] = {
+static const struct attribute_group *input_dev_attr_groups[] = {
 	&input_dev_attr_group,
 	&input_dev_attr_group,
 	&input_dev_id_attr_group,
 	&input_dev_id_attr_group,
 	&input_dev_caps_attr_group,
 	&input_dev_caps_attr_group,

+ 2 - 2
drivers/misc/enclosure.c

@@ -238,7 +238,7 @@ static void enclosure_component_release(struct device *dev)
 	put_device(dev->parent);
 	put_device(dev->parent);
 }
 }
 
 
-static struct attribute_group *enclosure_groups[];
+static const struct attribute_group *enclosure_groups[];
 
 
 /**
 /**
  * enclosure_component_register - add a particular component to an enclosure
  * enclosure_component_register - add a particular component to an enclosure
@@ -536,7 +536,7 @@ static struct attribute_group enclosure_group = {
 	.attrs = enclosure_component_attrs,
 	.attrs = enclosure_component_attrs,
 };
 };
 
 
-static struct attribute_group *enclosure_groups[] = {
+static const struct attribute_group *enclosure_groups[] = {
 	&enclosure_group,
 	&enclosure_group,
 	NULL
 	NULL
 };
 };

+ 1 - 1
drivers/mmc/core/mmc.c

@@ -276,7 +276,7 @@ static struct attribute_group mmc_std_attr_group = {
 	.attrs = mmc_std_attrs,
 	.attrs = mmc_std_attrs,
 };
 };
 
 
-static struct attribute_group *mmc_attr_groups[] = {
+static const struct attribute_group *mmc_attr_groups[] = {
 	&mmc_std_attr_group,
 	&mmc_std_attr_group,
 	NULL,
 	NULL,
 };
 };

+ 1 - 1
drivers/mmc/core/sd.c

@@ -314,7 +314,7 @@ static struct attribute_group sd_std_attr_group = {
 	.attrs = sd_std_attrs,
 	.attrs = sd_std_attrs,
 };
 };
 
 
-static struct attribute_group *sd_attr_groups[] = {
+static const struct attribute_group *sd_attr_groups[] = {
 	&sd_std_attr_group,
 	&sd_std_attr_group,
 	NULL,
 	NULL,
 };
 };

+ 1 - 1
drivers/mtd/mtdcore.c

@@ -217,7 +217,7 @@ struct attribute_group mtd_group = {
 	.attrs		= mtd_attrs,
 	.attrs		= mtd_attrs,
 };
 };
 
 
-struct attribute_group *mtd_groups[] = {
+const struct attribute_group *mtd_groups[] = {
 	&mtd_group,
 	&mtd_group,
 	NULL,
 	NULL,
 };
 };

+ 1 - 1
drivers/s390/cio/css.c

@@ -266,7 +266,7 @@ static struct attribute_group subch_attr_group = {
 	.attrs = subch_attrs,
 	.attrs = subch_attrs,
 };
 };
 
 
-static struct attribute_group *default_subch_attr_groups[] = {
+static const struct attribute_group *default_subch_attr_groups[] = {
 	&subch_attr_group,
 	&subch_attr_group,
 	NULL,
 	NULL,
 };
 };

+ 1 - 1
drivers/s390/cio/device.c

@@ -656,7 +656,7 @@ static struct attribute_group ccwdev_attr_group = {
 	.attrs = ccwdev_attrs,
 	.attrs = ccwdev_attrs,
 };
 };
 
 
-static struct attribute_group *ccwdev_attr_groups[] = {
+static const struct attribute_group *ccwdev_attr_groups[] = {
 	&ccwdev_attr_group,
 	&ccwdev_attr_group,
 	NULL,
 	NULL,
 };
 };

+ 1 - 1
drivers/s390/net/netiucv.c

@@ -2159,7 +2159,7 @@ static struct attribute_group netiucv_drv_attr_group = {
 	.attrs = netiucv_drv_attrs,
 	.attrs = netiucv_drv_attrs,
 };
 };
 
 
-static struct attribute_group *netiucv_drv_attr_groups[] = {
+static const struct attribute_group *netiucv_drv_attr_groups[] = {
 	&netiucv_drv_attr_group,
 	&netiucv_drv_attr_group,
 	NULL,
 	NULL,
 };
 };

+ 1 - 1
drivers/scsi/scsi_priv.h

@@ -132,7 +132,7 @@ extern struct scsi_transport_template blank_transport_template;
 extern void __scsi_remove_device(struct scsi_device *);
 extern void __scsi_remove_device(struct scsi_device *);
 
 
 extern struct bus_type scsi_bus_type;
 extern struct bus_type scsi_bus_type;
-extern struct attribute_group *scsi_sysfs_shost_attr_groups[];
+extern const struct attribute_group *scsi_sysfs_shost_attr_groups[];
 
 
 /* scsi_netlink.c */
 /* scsi_netlink.c */
 #ifdef CONFIG_SCSI_NETLINK
 #ifdef CONFIG_SCSI_NETLINK

+ 2 - 2
drivers/scsi/scsi_sysfs.c

@@ -275,7 +275,7 @@ struct attribute_group scsi_shost_attr_group = {
 	.attrs =	scsi_sysfs_shost_attrs,
 	.attrs =	scsi_sysfs_shost_attrs,
 };
 };
 
 
-struct attribute_group *scsi_sysfs_shost_attr_groups[] = {
+const struct attribute_group *scsi_sysfs_shost_attr_groups[] = {
 	&scsi_shost_attr_group,
 	&scsi_shost_attr_group,
 	NULL
 	NULL
 };
 };
@@ -745,7 +745,7 @@ static struct attribute_group scsi_sdev_attr_group = {
 	.attrs =	scsi_sdev_attrs,
 	.attrs =	scsi_sdev_attrs,
 };
 };
 
 
-static struct attribute_group *scsi_sdev_attr_groups[] = {
+static const struct attribute_group *scsi_sdev_attr_groups[] = {
 	&scsi_sdev_attr_group,
 	&scsi_sdev_attr_group,
 	NULL
 	NULL
 };
 };

+ 1 - 1
drivers/usb/core/endpoint.c

@@ -154,7 +154,7 @@ static struct attribute *ep_dev_attrs[] = {
 static struct attribute_group ep_dev_attr_grp = {
 static struct attribute_group ep_dev_attr_grp = {
 	.attrs = ep_dev_attrs,
 	.attrs = ep_dev_attrs,
 };
 };
-static struct attribute_group *ep_dev_groups[] = {
+static const struct attribute_group *ep_dev_groups[] = {
 	&ep_dev_attr_grp,
 	&ep_dev_attr_grp,
 	NULL
 	NULL
 };
 };

+ 2 - 2
drivers/usb/core/sysfs.c

@@ -573,7 +573,7 @@ static struct attribute_group dev_string_attr_grp = {
 	.is_visible =	dev_string_attrs_are_visible,
 	.is_visible =	dev_string_attrs_are_visible,
 };
 };
 
 
-struct attribute_group *usb_device_groups[] = {
+const struct attribute_group *usb_device_groups[] = {
 	&dev_attr_grp,
 	&dev_attr_grp,
 	&dev_string_attr_grp,
 	&dev_string_attr_grp,
 	NULL
 	NULL
@@ -799,7 +799,7 @@ static struct attribute_group intf_assoc_attr_grp = {
 	.is_visible =	intf_assoc_attrs_are_visible,
 	.is_visible =	intf_assoc_attrs_are_visible,
 };
 };
 
 
-struct attribute_group *usb_interface_groups[] = {
+const struct attribute_group *usb_interface_groups[] = {
 	&intf_attr_grp,
 	&intf_attr_grp,
 	&intf_assoc_attr_grp,
 	&intf_assoc_attr_grp,
 	NULL
 	NULL

+ 2 - 2
drivers/usb/core/usb.h

@@ -152,8 +152,8 @@ static inline int is_active(const struct usb_interface *f)
 extern const char *usbcore_name;
 extern const char *usbcore_name;
 
 
 /* sysfs stuff */
 /* sysfs stuff */
-extern struct attribute_group *usb_device_groups[];
-extern struct attribute_group *usb_interface_groups[];
+extern const struct attribute_group *usb_device_groups[];
+extern const struct attribute_group *usb_interface_groups[];
 
 
 /* usbfs stuff */
 /* usbfs stuff */
 extern struct mutex usbfs_mutex;
 extern struct mutex usbfs_mutex;

+ 1 - 1
drivers/uwb/lc-dev.c

@@ -255,7 +255,7 @@ static struct attribute_group dev_attr_group = {
 	.attrs = dev_attrs,
 	.attrs = dev_attrs,
 };
 };
 
 
-static struct attribute_group *groups[] = {
+static const struct attribute_group *groups[] = {
 	&dev_attr_group,
 	&dev_attr_group,
 	NULL,
 	NULL,
 };
 };

+ 1 - 1
fs/partitions/check.c

@@ -312,7 +312,7 @@ static struct attribute_group part_attr_group = {
 	.attrs = part_attrs,
 	.attrs = part_attrs,
 };
 };
 
 
-static struct attribute_group *part_attr_groups[] = {
+static const struct attribute_group *part_attr_groups[] = {
 	&part_attr_group,
 	&part_attr_group,
 #ifdef CONFIG_BLK_DEV_IO_TRACE
 #ifdef CONFIG_BLK_DEV_IO_TRACE
 	&blk_trace_attr_group,
 	&blk_trace_attr_group,

+ 1 - 1
include/linux/attribute_container.h

@@ -17,7 +17,7 @@ struct attribute_container {
 	struct list_head	node;
 	struct list_head	node;
 	struct klist		containers;
 	struct klist		containers;
 	struct class		*class;
 	struct class		*class;
-	struct attribute_group	*grp;
+	const struct attribute_group *grp;
 	struct device_attribute **attrs;
 	struct device_attribute **attrs;
 	int (*match)(struct attribute_container *, struct device *);
 	int (*match)(struct attribute_container *, struct device *);
 #define	ATTRIBUTE_CONTAINER_NO_CLASSDEVS	0x01
 #define	ATTRIBUTE_CONTAINER_NO_CLASSDEVS	0x01

+ 3 - 3
include/linux/device.h

@@ -131,7 +131,7 @@ struct device_driver {
 	void (*shutdown) (struct device *dev);
 	void (*shutdown) (struct device *dev);
 	int (*suspend) (struct device *dev, pm_message_t state);
 	int (*suspend) (struct device *dev, pm_message_t state);
 	int (*resume) (struct device *dev);
 	int (*resume) (struct device *dev);
-	struct attribute_group **groups;
+	const struct attribute_group **groups;
 
 
 	const struct dev_pm_ops *pm;
 	const struct dev_pm_ops *pm;
 
 
@@ -288,7 +288,7 @@ extern void class_destroy(struct class *cls);
  */
  */
 struct device_type {
 struct device_type {
 	const char *name;
 	const char *name;
-	struct attribute_group **groups;
+	const struct attribute_group **groups;
 	int (*uevent)(struct device *dev, struct kobj_uevent_env *env);
 	int (*uevent)(struct device *dev, struct kobj_uevent_env *env);
 	char *(*nodename)(struct device *dev);
 	char *(*nodename)(struct device *dev);
 	void (*release)(struct device *dev);
 	void (*release)(struct device *dev);
@@ -412,7 +412,7 @@ struct device {
 
 
 	struct klist_node	knode_class;
 	struct klist_node	knode_class;
 	struct class		*class;
 	struct class		*class;
-	struct attribute_group	**groups;	/* optional groups */
+	const struct attribute_group **groups;	/* optional groups */
 
 
 	void	(*release)(struct device *dev);
 	void	(*release)(struct device *dev);
 };
 };

+ 1 - 1
include/linux/netdevice.h

@@ -895,7 +895,7 @@ struct net_device
 	/* class/net/name entry */
 	/* class/net/name entry */
 	struct device		dev;
 	struct device		dev;
 	/* space for optional statistics and wireless sysfs groups */
 	/* space for optional statistics and wireless sysfs groups */
-	struct attribute_group  *sysfs_groups[3];
+	const struct attribute_group *sysfs_groups[3];
 
 
 	/* rtnetlink link ops */
 	/* rtnetlink link ops */
 	const struct rtnl_link_ops *rtnl_link_ops;
 	const struct rtnl_link_ops *rtnl_link_ops;

+ 1 - 1
include/linux/transport_class.h

@@ -55,7 +55,7 @@ struct anon_transport_class cls = {				\
 
 
 struct transport_container {
 struct transport_container {
 	struct attribute_container ac;
 	struct attribute_container ac;
-	struct attribute_group *statistics;
+	const struct attribute_group *statistics;
 };
 };
 
 
 #define attribute_container_to_transport_container(x) \
 #define attribute_container_to_transport_container(x) \

+ 2 - 2
net/bluetooth/hci_sysfs.c

@@ -68,7 +68,7 @@ static struct attribute_group bt_link_group = {
 	.attrs = bt_link_attrs,
 	.attrs = bt_link_attrs,
 };
 };
 
 
-static struct attribute_group *bt_link_groups[] = {
+static const struct attribute_group *bt_link_groups[] = {
 	&bt_link_group,
 	&bt_link_group,
 	NULL
 	NULL
 };
 };
@@ -392,7 +392,7 @@ static struct attribute_group bt_host_group = {
 	.attrs = bt_host_attrs,
 	.attrs = bt_host_attrs,
 };
 };
 
 
-static struct attribute_group *bt_host_groups[] = {
+static const struct attribute_group *bt_host_groups[] = {
 	&bt_host_group,
 	&bt_host_group,
 	NULL
 	NULL
 };
 };

+ 1 - 1
net/core/net-sysfs.c

@@ -493,7 +493,7 @@ void netdev_unregister_kobject(struct net_device * net)
 int netdev_register_kobject(struct net_device *net)
 int netdev_register_kobject(struct net_device *net)
 {
 {
 	struct device *dev = &(net->dev);
 	struct device *dev = &(net->dev);
-	struct attribute_group **groups = net->sysfs_groups;
+	const struct attribute_group **groups = net->sysfs_groups;
 
 
 	dev->class = &net_class;
 	dev->class = &net_class;
 	dev->platform_data = net;
 	dev->platform_data = net;