Skip to contentSkip to conversation

constify struct kobj_type's default_attrs (against -mm)

PATCH In review Jan Beulich 1 participant 1 message Jan 22, 2008

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

PATCH 2/3 constify struct kobj_type's default_attrs (against -mm)

In the EDAC code, I took the opportunity to replace the explicit cast initializer with a safer, cast-less mechanism (as used elsewhere), which makes this patch somewhat larger than it would have been otherwise.

Again, the patch doesn't change all instances where 'const' could have been added as a result of the base structure changes, only where the change has a real effect (the module loader doesn't enforce read-only section attributes at present, so only built-in files matter).

Cc Tony Luck <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Jens Axboe <[email protected]>
Cc Doug Thompson <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 Documentation/kobject.txt               |    2 -
 arch/ia64/kernel/topology.c             |    2 -
 arch/x86/kernel/cpu/intel_cacheinfo.c   |    2 -
 arch/x86/kernel/cpu/mcheck/mce_amd_64.c |    2 -
 block/ll_rw_blk.c                       |    2 -
 drivers/block/pktcdvd.c                 |    4 +-
 drivers/cpufreq/cpufreq.c               |    2 -
 drivers/cpuidle/sysfs.c                 |    2 -
 drivers/edac/edac_device_sysfs.c        |   28 ++++++++---------
 drivers/edac/edac_mc_sysfs.c            |   50 ++++++++++++++++----------------
 drivers/edac/edac_pci_sysfs.c           |   24 +++++++--------
 drivers/firmware/edd.c                  |    2 -
 drivers/firmware/efivars.c              |    2 -
 include/linux/kobject.h                 |    2 -
 14 files changed, 63 insertions(+), 63 deletions(-)
Documentation/kobject.txt +1 -1
@@ -263,7 +263,7 @@ kobj_type:
     struct kobj_type {
 	    void (*release)(struct kobject *);
 	    struct sysfs_ops	*sysfs_ops;
-	    struct attribute	**default_attrs;
+	    struct attribute	*const *default_attrs;
     };
 
 This structure is used to describe a particular type of kobject (or, more
arch/ia64/kernel/topology.c +1 -1
@@ -242,7 +242,7 @@ define_one_ro(number_of_sets);
 define_one_ro(shared_cpu_map);
 define_one_ro(attributes);
 
-static struct attribute * cache_default_attrs[] = {
+static struct attribute *const cache_default_attrs[] = {
 	&type.attr,
 	&level.attr,
 	&coherency_line_size.attr,
arch/x86/kernel/cpu/intel_cacheinfo.c +1 -1
@@ -634,7 +634,7 @@ define_one_ro(number_of_sets);
 define_one_ro(size);
 define_one_ro(shared_cpu_map);
 
-static struct attribute * default_attrs[] = {
+static struct attribute *const default_attrs[] = {
 	&type.attr,
 	&level.attr,
 	&coherency_line_size.attr,
arch/x86/kernel/cpu/mcheck/mce_amd_64.c +1 -1
@@ -348,7 +348,7 @@ RW_ATTR(interrupt_enable);
 RW_ATTR(threshold_limit);
 RW_ATTR(error_count);
 
-static struct attribute *default_attrs[] = {
+static struct attribute *const default_attrs[] = {
 	&interrupt_enable.attr,
 	&threshold_limit.attr,
 	&error_count.attr,
block/ll_rw_blk.c +1 -1
@@ -4132,7 +4132,7 @@ static struct queue_sysfs_entry queue_io
 	.store = elv_iosched_store,
 };
 
-static struct attribute *default_attrs[] = {
+static struct attribute *const default_attrs[] = {
 	&queue_requests_entry.attr,
 	&queue_ra_entry.attr,
 	&queue_max_hw_sectors_entry.attr,
drivers/block/pktcdvd.c +2 -2
@@ -171,7 +171,7 @@ DEF_ATTR(kobj_pkt_attr_st4, "kb_written"
 DEF_ATTR(kobj_pkt_attr_st5, "kb_read", 0444);
 DEF_ATTR(kobj_pkt_attr_st6, "kb_read_gather", 0444);
 
-static struct attribute *kobj_pkt_attrs_stat[] = {
+static struct attribute *const kobj_pkt_attrs_stat[] = {
 	&kobj_pkt_attr_st1,
 	&kobj_pkt_attr_st2,
 	&kobj_pkt_attr_st3,
@@ -185,7 +185,7 @@ DEF_ATTR(kobj_pkt_attr_wq1, "size", 0444
 DEF_ATTR(kobj_pkt_attr_wq2, "congestion_off", 0644);
 DEF_ATTR(kobj_pkt_attr_wq3, "congestion_on",  0644);
 
-static struct attribute *kobj_pkt_attrs_wqueue[] = {
+static struct attribute *const kobj_pkt_attrs_wqueue[] = {
 	&kobj_pkt_attr_wq1,
 	&kobj_pkt_attr_wq2,
 	&kobj_pkt_attr_wq3,
drivers/cpufreq/cpufreq.c +1 -1
@@ -651,7 +651,7 @@ define_one_rw(scaling_max_freq);
 define_one_rw(scaling_governor);
 define_one_rw(scaling_setspeed);
 
-static struct attribute * default_attrs[] = {
+static struct attribute *const default_attrs[] = {
 	&cpuinfo_min_freq.attr,
 	&cpuinfo_max_freq.attr,
 	&scaling_min_freq.attr,
drivers/cpuidle/sysfs.c +1 -1
@@ -233,7 +233,7 @@ define_one_state_ro(power, show_state_po
 define_one_state_ro(usage, show_state_usage);
 define_one_state_ro(time, show_state_time);
 
-static struct attribute *cpuidle_state_default_attrs[] = {
+static struct attribute *const cpuidle_state_default_attrs[] = {
 	&attr_name.attr,
 	&attr_latency.attr,
 	&attr_power.attr,
drivers/edac/edac_device_sysfs.c +14 -14
@@ -161,11 +161,11 @@ CTL_INFO_ATTR(poll_msec, S_IRUGO | S_IWU
 	edac_device_ctl_poll_msec_show, edac_device_ctl_poll_msec_store);
 
 /* Base Attributes of the EDAC_DEVICE ECC object */
-static struct ctl_info_attribute *device_ctrl_attr[] = {
-	&attr_ctl_info_panic_on_ue,
-	&attr_ctl_info_log_ue,
-	&attr_ctl_info_log_ce,
-	&attr_ctl_info_poll_msec,
+static struct attribute *const device_ctrl_attr[] = {
+	&attr_ctl_info_panic_on_ue.attr,
+	&attr_ctl_info_log_ue.attr,
+	&attr_ctl_info_log_ce.attr,
+	&attr_ctl_info_poll_msec.attr,
 	NULL,
 };
 
@@ -215,7 +215,7 @@ static void edac_device_ctrl_master_rele
 static struct kobj_type ktype_device_ctrl = {
 	.release = edac_device_ctrl_master_release,
 	.sysfs_ops = &device_ctl_info_ops,
-	.default_attrs = (struct attribute **)device_ctrl_attr,
+	.default_attrs = device_ctrl_attr,
 };
 
 /*
@@ -394,9 +394,9 @@ INSTANCE_ATTR(ce_count, S_IRUGO, instanc
 INSTANCE_ATTR(ue_count, S_IRUGO, instance_ue_count_show, NULL);
 
 /* list of edac_dev 'instance' attributes */
-static struct instance_attribute *device_instance_attr[] = {
-	&attr_instance_ce_count,
-	&attr_instance_ue_count,
+static struct attribute *const device_instance_attr[] = {
+	&attr_instance_ce_count.attr,
+	&attr_instance_ue_count.attr,
 	NULL,
 };
 
@@ -404,7 +404,7 @@ static struct instance_attribute *device
 static struct kobj_type ktype_instance_ctrl = {
 	.release = edac_device_ctrl_instance_release,
 	.sysfs_ops = &device_instance_ops,
-	.default_attrs = (struct attribute **)device_instance_attr,
+	.default_attrs = device_instance_attr,
 };
 
 /* edac_dev -> instance -> block information */
@@ -492,9 +492,9 @@ BLOCK_ATTR(ce_count, S_IRUGO, block_ce_c
 BLOCK_ATTR(ue_count, S_IRUGO, block_ue_count_show, NULL);
 
 /* list of edac_dev 'block' attributes */
-static struct edac_dev_sysfs_block_attribute *device_block_attr[] = {
-	&attr_block_ce_count,
-	&attr_block_ue_count,
+static struct attribute *const device_block_attr[] = {
+	&attr_block_ce_count.attr,
+	&attr_block_ue_count.attr,
 	NULL,
 };
 
@@ -502,7 +502,7 @@ static struct edac_dev_sysfs_block_attri
 static struct kobj_type ktype_block_ctrl = {
 	.release = edac_device_ctrl_block_release,
 	.sysfs_ops = &device_block_ops,
-	.default_attrs = (struct attribute **)device_block_attr,
+	.default_attrs = device_block_attr,
 };
 
 /* block ctor/dtor  code */
drivers/edac/edac_mc_sysfs.c +25 -25

86 lines not on this page · raw message

drivers/edac/edac_pci_sysfs.c +12 -12
@@ -137,9 +137,9 @@ INSTANCE_ATTR(pe_count, S_IRUGO, instanc
 INSTANCE_ATTR(npe_count, S_IRUGO, instance_npe_count_show, NULL);
 
 /* pci instance attributes */
-static struct instance_attribute *pci_instance_attr[] = {
-	&attr_instance_pe_count,
-	&attr_instance_npe_count,
+static struct attribute *const pci_instance_attr[] = {
+	&attr_instance_pe_count.attr,
+	&attr_instance_npe_count.attr,
 	NULL
 };
 
@@ -147,7 +147,7 @@ static struct instance_attribute *pci_in
 static struct kobj_type ktype_pci_instance = {
 	.release = edac_pci_instance_release,
 	.sysfs_ops = &pci_instance_ops,
-	.default_attrs = (struct attribute **)pci_instance_attr,
+	.default_attrs = pci_instance_attr,
 };
 
 /*
@@ -294,13 +294,13 @@ EDAC_PCI_ATTR(pci_parity_count, S_IRUGO,
 EDAC_PCI_ATTR(pci_nonparity_count, S_IRUGO, edac_pci_int_show, NULL);
 
 /* Base Attributes of the memory ECC object */
-static struct edac_pci_dev_attribute *edac_pci_attr[] = {
-	&edac_pci_attr_check_pci_errors,
-	&edac_pci_attr_edac_pci_log_pe,
-	&edac_pci_attr_edac_pci_log_npe,
-	&edac_pci_attr_edac_pci_panic_on_pe,
-	&edac_pci_attr_pci_parity_count,
-	&edac_pci_attr_pci_nonparity_count,
+static struct attribute *const edac_pci_attr[] = {
+	&edac_pci_attr_check_pci_errors.attr,
+	&edac_pci_attr_edac_pci_log_pe.attr,
+	&edac_pci_attr_edac_pci_log_npe.attr,
+	&edac_pci_attr_edac_pci_panic_on_pe.attr,
+	&edac_pci_attr_pci_parity_count.attr,
+	&edac_pci_attr_pci_nonparity_count.attr,
 	NULL,
 };
 
@@ -328,7 +328,7 @@ static void edac_pci_release_main_kobj(s
 static struct kobj_type ktype_edac_pci_main_kobj = {
 	.release = edac_pci_release_main_kobj,
 	.sysfs_ops = &edac_pci_sysfs_ops,
-	.default_attrs = (struct attribute **)edac_pci_attr,
+	.default_attrs = edac_pci_attr,
 };
 
 /**
drivers/firmware/edd.c +1 -1
@@ -587,7 +587,7 @@ static EDD_DEVICE_ATTR(mbr_signature, 04
 /* These are default attributes that are added for every edd
  * device discovered.  There are none.
  */
-static struct attribute * def_attrs[] = {
+static struct attribute *const def_attrs[] = {
 	NULL,
 };
 
drivers/firmware/efivars.c +1 -1
@@ -380,7 +380,7 @@ static EFIVAR_ATTR(size, 0400, efivar_si
 static EFIVAR_ATTR(data, 0400, efivar_data_read, NULL);
 static EFIVAR_ATTR(raw_var, 0600, efivar_show_raw, efivar_store_raw);
 
-static struct attribute *def_attrs[] = {
+static struct attribute *const def_attrs[] = {
 	&efivar_attr_guid.attr,
 	&efivar_attr_size.attr,
 	&efivar_attr_attributes.attr,
include/linux/kobject.h +1 -1
@@ -108,7 +108,7 @@ extern char * kobject_get_path(struct ko
 struct kobj_type {
 	void (*release)(struct kobject *);
 	struct sysfs_ops	* sysfs_ops;
-	struct attribute	** default_attrs;
+	struct attribute	*const *default_attrs;
 };
 
 struct kobj_uevent_env {