diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-03-21 14:16:20 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-06-11 12:23:39 -0400 |
commit | ba004239e008a442bc327a57e227600fc1bd5ee7 (patch) | |
tree | cae3c13d48cd0ddb95220c6adb4eb221db0be1c9 /drivers/edac | |
parent | 7a623c039075e4ea21648d88133fafa6dcfd113d (diff) |
mpc85xx_edac: convert sysfs logic to use struct device
Now that the EDAC core supports struct device, there's no sense on
having any logic at the EDAC core to simulate it. So, instead of adding
such logic there, change the logic at mpc85xx_edac to use it
compile-tested only.
Reviewed-by: Aristeu Rozanski <arozansk@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Shaohui Xie <Shaohui.Xie@freescale.com>
Cc: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/edac')
-rw-r--r-- | drivers/edac/mpc85xx_edac.c | 93 |
1 files changed, 55 insertions, 38 deletions
diff --git a/drivers/edac/mpc85xx_edac.c b/drivers/edac/mpc85xx_edac.c index 67fb3280f333..d132dbbd9bd7 100644 --- a/drivers/edac/mpc85xx_edac.c +++ b/drivers/edac/mpc85xx_edac.c | |||
@@ -49,34 +49,45 @@ static u32 orig_hid1[2]; | |||
49 | 49 | ||
50 | /************************ MC SYSFS parts ***********************************/ | 50 | /************************ MC SYSFS parts ***********************************/ |
51 | 51 | ||
52 | static ssize_t mpc85xx_mc_inject_data_hi_show(struct mem_ctl_info *mci, | 52 | #define to_mci(k) container_of(k, struct mem_ctl_info, dev) |
53 | |||
54 | static ssize_t mpc85xx_mc_inject_data_hi_show(struct device *dev, | ||
55 | struct device_attribute *mattr, | ||
53 | char *data) | 56 | char *data) |
54 | { | 57 | { |
58 | struct mem_ctl_info *mci = to_mci(dev); | ||
55 | struct mpc85xx_mc_pdata *pdata = mci->pvt_info; | 59 | struct mpc85xx_mc_pdata *pdata = mci->pvt_info; |
56 | return sprintf(data, "0x%08x", | 60 | return sprintf(data, "0x%08x", |
57 | in_be32(pdata->mc_vbase + | 61 | in_be32(pdata->mc_vbase + |
58 | MPC85XX_MC_DATA_ERR_INJECT_HI)); | 62 | MPC85XX_MC_DATA_ERR_INJECT_HI)); |
59 | } | 63 | } |
60 | 64 | ||
61 | static ssize_t mpc85xx_mc_inject_data_lo_show(struct mem_ctl_info *mci, | 65 | static ssize_t mpc85xx_mc_inject_data_lo_show(struct device *dev, |
66 | struct device_attribute *mattr, | ||
62 | char *data) | 67 | char *data) |
63 | { | 68 | { |
69 | struct mem_ctl_info *mci = to_mci(dev); | ||
64 | struct mpc85xx_mc_pdata *pdata = mci->pvt_info; | 70 | struct mpc85xx_mc_pdata *pdata = mci->pvt_info; |
65 | return sprintf(data, "0x%08x", | 71 | return sprintf(data, "0x%08x", |
66 | in_be32(pdata->mc_vbase + | 72 | in_be32(pdata->mc_vbase + |
67 | MPC85XX_MC_DATA_ERR_INJECT_LO)); | 73 | MPC85XX_MC_DATA_ERR_INJECT_LO)); |
68 | } | 74 | } |
69 | 75 | ||
70 | static ssize_t mpc85xx_mc_inject_ctrl_show(struct mem_ctl_info *mci, char *data) | 76 | static ssize_t mpc85xx_mc_inject_ctrl_show(struct device *dev, |
77 | struct device_attribute *mattr, | ||
78 | char *data) | ||
71 | { | 79 | { |
80 | struct mem_ctl_info *mci = to_mci(dev); | ||
72 | struct mpc85xx_mc_pdata *pdata = mci->pvt_info; | 81 | struct mpc85xx_mc_pdata *pdata = mci->pvt_info; |
73 | return sprintf(data, "0x%08x", | 82 | return sprintf(data, "0x%08x", |
74 | in_be32(pdata->mc_vbase + MPC85XX_MC_ECC_ERR_INJECT)); | 83 | in_be32(pdata->mc_vbase + MPC85XX_MC_ECC_ERR_INJECT)); |
75 | } | 84 | } |
76 | 85 | ||
77 | static ssize_t mpc85xx_mc_inject_data_hi_store(struct mem_ctl_info *mci, | 86 | static ssize_t mpc85xx_mc_inject_data_hi_store(struct device *dev, |
87 | struct device_attribute *mattr, | ||
78 | const char *data, size_t count) | 88 | const char *data, size_t count) |
79 | { | 89 | { |
90 | struct mem_ctl_info *mci = to_mci(dev); | ||
80 | struct mpc85xx_mc_pdata *pdata = mci->pvt_info; | 91 | struct mpc85xx_mc_pdata *pdata = mci->pvt_info; |
81 | if (isdigit(*data)) { | 92 | if (isdigit(*data)) { |
82 | out_be32(pdata->mc_vbase + MPC85XX_MC_DATA_ERR_INJECT_HI, | 93 | out_be32(pdata->mc_vbase + MPC85XX_MC_DATA_ERR_INJECT_HI, |
@@ -86,9 +97,11 @@ static ssize_t mpc85xx_mc_inject_data_hi_store(struct mem_ctl_info *mci, | |||
86 | return 0; | 97 | return 0; |
87 | } | 98 | } |
88 | 99 | ||
89 | static ssize_t mpc85xx_mc_inject_data_lo_store(struct mem_ctl_info *mci, | 100 | static ssize_t mpc85xx_mc_inject_data_lo_store(struct device *dev, |
101 | struct device_attribute *mattr, | ||
90 | const char *data, size_t count) | 102 | const char *data, size_t count) |
91 | { | 103 | { |
104 | struct mem_ctl_info *mci = to_mci(dev); | ||
92 | struct mpc85xx_mc_pdata *pdata = mci->pvt_info; | 105 | struct mpc85xx_mc_pdata *pdata = mci->pvt_info; |
93 | if (isdigit(*data)) { | 106 | if (isdigit(*data)) { |
94 | out_be32(pdata->mc_vbase + MPC85XX_MC_DATA_ERR_INJECT_LO, | 107 | out_be32(pdata->mc_vbase + MPC85XX_MC_DATA_ERR_INJECT_LO, |
@@ -98,9 +111,11 @@ static ssize_t mpc85xx_mc_inject_data_lo_store(struct mem_ctl_info *mci, | |||
98 | return 0; | 111 | return 0; |
99 | } | 112 | } |
100 | 113 | ||
101 | static ssize_t mpc85xx_mc_inject_ctrl_store(struct mem_ctl_info *mci, | 114 | static ssize_t mpc85xx_mc_inject_ctrl_store(struct device *dev, |
102 | const char *data, size_t count) | 115 | struct device_attribute *mattr, |
116 | const char *data, size_t count) | ||
103 | { | 117 | { |
118 | struct mem_ctl_info *mci = to_mci(dev); | ||
104 | struct mpc85xx_mc_pdata *pdata = mci->pvt_info; | 119 | struct mpc85xx_mc_pdata *pdata = mci->pvt_info; |
105 | if (isdigit(*data)) { | 120 | if (isdigit(*data)) { |
106 | out_be32(pdata->mc_vbase + MPC85XX_MC_ECC_ERR_INJECT, | 121 | out_be32(pdata->mc_vbase + MPC85XX_MC_ECC_ERR_INJECT, |
@@ -110,38 +125,35 @@ static ssize_t mpc85xx_mc_inject_ctrl_store(struct mem_ctl_info *mci, | |||
110 | return 0; | 125 | return 0; |
111 | } | 126 | } |
112 | 127 | ||
113 | static struct mcidev_sysfs_attribute mpc85xx_mc_sysfs_attributes[] = { | 128 | DEVICE_ATTR(inject_data_hi, S_IRUGO | S_IWUSR, |
114 | { | 129 | mpc85xx_mc_inject_data_hi_show, mpc85xx_mc_inject_data_hi_store); |
115 | .attr = { | 130 | DEVICE_ATTR(inject_data_lo, S_IRUGO | S_IWUSR, |
116 | .name = "inject_data_hi", | 131 | mpc85xx_mc_inject_data_lo_show, mpc85xx_mc_inject_data_lo_store); |
117 | .mode = (S_IRUGO | S_IWUSR) | 132 | DEVICE_ATTR(inject_ctrl, S_IRUGO | S_IWUSR, |
118 | }, | 133 | mpc85xx_mc_inject_ctrl_show, mpc85xx_mc_inject_ctrl_store); |
119 | .show = mpc85xx_mc_inject_data_hi_show, | ||
120 | .store = mpc85xx_mc_inject_data_hi_store}, | ||
121 | { | ||
122 | .attr = { | ||
123 | .name = "inject_data_lo", | ||
124 | .mode = (S_IRUGO | S_IWUSR) | ||
125 | }, | ||
126 | .show = mpc85xx_mc_inject_data_lo_show, | ||
127 | .store = mpc85xx_mc_inject_data_lo_store}, | ||
128 | { | ||
129 | .attr = { | ||
130 | .name = "inject_ctrl", | ||
131 | .mode = (S_IRUGO | S_IWUSR) | ||
132 | }, | ||
133 | .show = mpc85xx_mc_inject_ctrl_show, | ||
134 | .store = mpc85xx_mc_inject_ctrl_store}, | ||
135 | 134 | ||
136 | /* End of list */ | 135 | static int mpc85xx_create_sysfs_attributes(struct mem_ctl_info *mci) |
137 | { | 136 | { |
138 | .attr = {.name = NULL} | 137 | int rc; |
139 | } | 138 | |
140 | }; | 139 | rc = device_create_file(&mci->dev, &dev_attr_inject_data_hi); |
140 | if (rc < 0) | ||
141 | return rc; | ||
142 | rc = device_create_file(&mci->dev, &dev_attr_inject_data_lo); | ||
143 | if (rc < 0) | ||
144 | return rc; | ||
145 | rc = device_create_file(&mci->dev, &dev_attr_inject_ctrl); | ||
146 | if (rc < 0) | ||
147 | return rc; | ||
141 | 148 | ||
142 | static void mpc85xx_set_mc_sysfs_attributes(struct mem_ctl_info *mci) | 149 | return 0; |
150 | } | ||
151 | |||
152 | static void mpc85xx_remove_sysfs_attributes(struct mem_ctl_info *mci) | ||
143 | { | 153 | { |
144 | mci->mc_driver_sysfs_attributes = mpc85xx_mc_sysfs_attributes; | 154 | device_remove_file(&mci->dev, &dev_attr_inject_data_hi); |
155 | device_remove_file(&mci->dev, &dev_attr_inject_data_lo); | ||
156 | device_remove_file(&mci->dev, &dev_attr_inject_ctrl); | ||
145 | } | 157 | } |
146 | 158 | ||
147 | /**************************** PCI Err device ***************************/ | 159 | /**************************** PCI Err device ***************************/ |
@@ -1040,8 +1052,6 @@ static int __devinit mpc85xx_mc_err_probe(struct platform_device *op) | |||
1040 | 1052 | ||
1041 | mci->scrub_mode = SCRUB_SW_SRC; | 1053 | mci->scrub_mode = SCRUB_SW_SRC; |
1042 | 1054 | ||
1043 | mpc85xx_set_mc_sysfs_attributes(mci); | ||
1044 | |||
1045 | mpc85xx_init_csrows(mci); | 1055 | mpc85xx_init_csrows(mci); |
1046 | 1056 | ||
1047 | /* store the original error disable bits */ | 1057 | /* store the original error disable bits */ |
@@ -1057,6 +1067,12 @@ static int __devinit mpc85xx_mc_err_probe(struct platform_device *op) | |||
1057 | goto err; | 1067 | goto err; |
1058 | } | 1068 | } |
1059 | 1069 | ||
1070 | if (mpc85xx_create_sysfs_attributes(mci)) { | ||
1071 | edac_mc_del_mc(mci->pdev); | ||
1072 | debugf3("%s(): failed edac_mc_add_mc()\n", __func__); | ||
1073 | goto err; | ||
1074 | } | ||
1075 | |||
1060 | if (edac_op_state == EDAC_OPSTATE_INT) { | 1076 | if (edac_op_state == EDAC_OPSTATE_INT) { |
1061 | out_be32(pdata->mc_vbase + MPC85XX_MC_ERR_INT_EN, | 1077 | out_be32(pdata->mc_vbase + MPC85XX_MC_ERR_INT_EN, |
1062 | DDR_EIE_MBEE | DDR_EIE_SBEE); | 1078 | DDR_EIE_MBEE | DDR_EIE_SBEE); |
@@ -1116,6 +1132,7 @@ static int mpc85xx_mc_err_remove(struct platform_device *op) | |||
1116 | orig_ddr_err_disable); | 1132 | orig_ddr_err_disable); |
1117 | out_be32(pdata->mc_vbase + MPC85XX_MC_ERR_SBE, orig_ddr_err_sbe); | 1133 | out_be32(pdata->mc_vbase + MPC85XX_MC_ERR_SBE, orig_ddr_err_sbe); |
1118 | 1134 | ||
1135 | mpc85xx_remove_sysfs_attributes(mci); | ||
1119 | edac_mc_del_mc(&op->dev); | 1136 | edac_mc_del_mc(&op->dev); |
1120 | edac_mc_free(mci); | 1137 | edac_mc_free(mci); |
1121 | return 0; | 1138 | return 0; |