Skip to content

Commit 1141389

Browse files
gregkhsuryasaimadhu
authored andcommitted
EDAC: Use proper list of struct attribute for attributes
The EDAC sysfs code is doing some crazy casting of the list of attributes that is not necessary at all. Instead, properly point to the correct attribute structure in the lists, which removes the need to cast anything and the code is now properly typesafe (as much as sysfs attribute logic is typesafe...) Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Borislav Petkov <bp@suse.de> Link: https://lore.kernel.org/r/20220104112401.1067148-1-gregkh@linuxfoundation.org
1 parent e783362 commit 1141389

2 files changed

Lines changed: 26 additions & 26 deletions

File tree

drivers/edac/edac_device_sysfs.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,11 @@ CTL_INFO_ATTR(poll_msec, S_IRUGO | S_IWUSR,
163163
edac_device_ctl_poll_msec_show, edac_device_ctl_poll_msec_store);
164164

165165
/* Base Attributes of the EDAC_DEVICE ECC object */
166-
static struct ctl_info_attribute *device_ctrl_attr[] = {
167-
&attr_ctl_info_panic_on_ue,
168-
&attr_ctl_info_log_ue,
169-
&attr_ctl_info_log_ce,
170-
&attr_ctl_info_poll_msec,
166+
static struct attribute *device_ctrl_attr[] = {
167+
&attr_ctl_info_panic_on_ue.attr,
168+
&attr_ctl_info_log_ue.attr,
169+
&attr_ctl_info_log_ce.attr,
170+
&attr_ctl_info_poll_msec.attr,
171171
NULL,
172172
};
173173

@@ -217,7 +217,7 @@ static void edac_device_ctrl_master_release(struct kobject *kobj)
217217
static struct kobj_type ktype_device_ctrl = {
218218
.release = edac_device_ctrl_master_release,
219219
.sysfs_ops = &device_ctl_info_ops,
220-
.default_attrs = (struct attribute **)device_ctrl_attr,
220+
.default_attrs = device_ctrl_attr,
221221
};
222222

223223
/*
@@ -389,17 +389,17 @@ INSTANCE_ATTR(ce_count, S_IRUGO, instance_ce_count_show, NULL);
389389
INSTANCE_ATTR(ue_count, S_IRUGO, instance_ue_count_show, NULL);
390390

391391
/* list of edac_dev 'instance' attributes */
392-
static struct instance_attribute *device_instance_attr[] = {
393-
&attr_instance_ce_count,
394-
&attr_instance_ue_count,
392+
static struct attribute *device_instance_attr[] = {
393+
&attr_instance_ce_count.attr,
394+
&attr_instance_ue_count.attr,
395395
NULL,
396396
};
397397

398398
/* The 'ktype' for each edac_dev 'instance' */
399399
static struct kobj_type ktype_instance_ctrl = {
400400
.release = edac_device_ctrl_instance_release,
401401
.sysfs_ops = &device_instance_ops,
402-
.default_attrs = (struct attribute **)device_instance_attr,
402+
.default_attrs = device_instance_attr,
403403
};
404404

405405
/* edac_dev -> instance -> block information */
@@ -487,17 +487,17 @@ BLOCK_ATTR(ce_count, S_IRUGO, block_ce_count_show, NULL);
487487
BLOCK_ATTR(ue_count, S_IRUGO, block_ue_count_show, NULL);
488488

489489
/* list of edac_dev 'block' attributes */
490-
static struct edac_dev_sysfs_block_attribute *device_block_attr[] = {
491-
&attr_block_ce_count,
492-
&attr_block_ue_count,
490+
static struct attribute *device_block_attr[] = {
491+
&attr_block_ce_count.attr,
492+
&attr_block_ue_count.attr,
493493
NULL,
494494
};
495495

496496
/* The 'ktype' for each edac_dev 'block' */
497497
static struct kobj_type ktype_block_ctrl = {
498498
.release = edac_device_ctrl_block_release,
499499
.sysfs_ops = &device_block_ops,
500-
.default_attrs = (struct attribute **)device_block_attr,
500+
.default_attrs = device_block_attr,
501501
};
502502

503503
/* block ctor/dtor code */

drivers/edac/edac_pci_sysfs.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,17 @@ INSTANCE_ATTR(pe_count, S_IRUGO, instance_pe_count_show, NULL);
135135
INSTANCE_ATTR(npe_count, S_IRUGO, instance_npe_count_show, NULL);
136136

137137
/* pci instance attributes */
138-
static struct instance_attribute *pci_instance_attr[] = {
139-
&attr_instance_pe_count,
140-
&attr_instance_npe_count,
138+
static struct attribute *pci_instance_attr[] = {
139+
&attr_instance_pe_count.attr,
140+
&attr_instance_npe_count.attr,
141141
NULL
142142
};
143143

144144
/* the ktype for a pci instance */
145145
static struct kobj_type ktype_pci_instance = {
146146
.release = edac_pci_instance_release,
147147
.sysfs_ops = &pci_instance_ops,
148-
.default_attrs = (struct attribute **)pci_instance_attr,
148+
.default_attrs = pci_instance_attr,
149149
};
150150

151151
/*
@@ -292,13 +292,13 @@ EDAC_PCI_ATTR(pci_parity_count, S_IRUGO, edac_pci_int_show, NULL);
292292
EDAC_PCI_ATTR(pci_nonparity_count, S_IRUGO, edac_pci_int_show, NULL);
293293

294294
/* Base Attributes of the memory ECC object */
295-
static struct edac_pci_dev_attribute *edac_pci_attr[] = {
296-
&edac_pci_attr_check_pci_errors,
297-
&edac_pci_attr_edac_pci_log_pe,
298-
&edac_pci_attr_edac_pci_log_npe,
299-
&edac_pci_attr_edac_pci_panic_on_pe,
300-
&edac_pci_attr_pci_parity_count,
301-
&edac_pci_attr_pci_nonparity_count,
295+
static struct attribute *edac_pci_attr[] = {
296+
&edac_pci_attr_check_pci_errors.attr,
297+
&edac_pci_attr_edac_pci_log_pe.attr,
298+
&edac_pci_attr_edac_pci_log_npe.attr,
299+
&edac_pci_attr_edac_pci_panic_on_pe.attr,
300+
&edac_pci_attr_pci_parity_count.attr,
301+
&edac_pci_attr_pci_nonparity_count.attr,
302302
NULL,
303303
};
304304

@@ -327,7 +327,7 @@ static void edac_pci_release_main_kobj(struct kobject *kobj)
327327
static struct kobj_type ktype_edac_pci_main_kobj = {
328328
.release = edac_pci_release_main_kobj,
329329
.sysfs_ops = &edac_pci_sysfs_ops,
330-
.default_attrs = (struct attribute **)edac_pci_attr,
330+
.default_attrs = edac_pci_attr,
331331
};
332332

333333
/**

0 commit comments

Comments
 (0)