aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/edac/edac_mc_sysfs.c
diff options
context:
space:
mode:
authorDouglas Thompson <dougthompson@xmission.com>2007-07-19 04:49:58 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-19 13:04:54 -0400
commit079708b9173595bf74b31b14c36e946359ae6c7e (patch)
tree79ed508a2ccdcf8d8095923cb4613594ed0af54d /drivers/edac/edac_mc_sysfs.c
parent4de78c6877ec21142582ac19453c2d453d1ea298 (diff)
drivers/edac: core Lindent cleanup
Run the EDAC CORE files through Lindent for cleanup Signed-off-by: Douglas Thompson <dougthompson@xmission.com> Signed-off-by: Dave Jiang <djiang@mvista.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/edac/edac_mc_sysfs.c')
-rw-r--r--drivers/edac/edac_mc_sysfs.c336
1 files changed, 143 insertions, 193 deletions
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index 7f8240f40db0..8eaa1d6a8a9f 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -48,14 +48,13 @@ module_param(edac_mc_panic_on_ue, int, 0644);
48MODULE_PARM_DESC(edac_mc_panic_on_ue, "Panic on uncorrected error: 0=off 1=on"); 48MODULE_PARM_DESC(edac_mc_panic_on_ue, "Panic on uncorrected error: 0=off 1=on");
49module_param(edac_mc_log_ue, int, 0644); 49module_param(edac_mc_log_ue, int, 0644);
50MODULE_PARM_DESC(edac_mc_log_ue, 50MODULE_PARM_DESC(edac_mc_log_ue,
51 "Log uncorrectable error to console: 0=off 1=on"); 51 "Log uncorrectable error to console: 0=off 1=on");
52module_param(edac_mc_log_ce, int, 0644); 52module_param(edac_mc_log_ce, int, 0644);
53MODULE_PARM_DESC(edac_mc_log_ce, 53MODULE_PARM_DESC(edac_mc_log_ce,
54 "Log correctable error to console: 0=off 1=on"); 54 "Log correctable error to console: 0=off 1=on");
55module_param(edac_mc_poll_msec, int, 0644); 55module_param(edac_mc_poll_msec, int, 0644);
56MODULE_PARM_DESC(edac_mc_poll_msec, "Polling period in milliseconds"); 56MODULE_PARM_DESC(edac_mc_poll_msec, "Polling period in milliseconds");
57 57
58
59/* 58/*
60 * various constants for Memory Controllers 59 * various constants for Memory Controllers
61 */ 60 */
@@ -116,13 +115,13 @@ static struct completion edac_memctrl_kobj_complete;
116 */ 115 */
117static ssize_t memctrl_int_show(void *ptr, char *buffer) 116static ssize_t memctrl_int_show(void *ptr, char *buffer)
118{ 117{
119 int *value = (int*) ptr; 118 int *value = (int *)ptr;
120 return sprintf(buffer, "%u\n", *value); 119 return sprintf(buffer, "%u\n", *value);
121} 120}
122 121
123static ssize_t memctrl_int_store(void *ptr, const char *buffer, size_t count) 122static ssize_t memctrl_int_store(void *ptr, const char *buffer, size_t count)
124{ 123{
125 int *value = (int*) ptr; 124 int *value = (int *)ptr;
126 125
127 if (isdigit(*buffer)) 126 if (isdigit(*buffer))
128 *value = simple_strtoul(buffer, NULL, 0); 127 *value = simple_strtoul(buffer, NULL, 0);
@@ -133,16 +132,16 @@ static ssize_t memctrl_int_store(void *ptr, const char *buffer, size_t count)
133struct memctrl_dev_attribute { 132struct memctrl_dev_attribute {
134 struct attribute attr; 133 struct attribute attr;
135 void *value; 134 void *value;
136 ssize_t (*show)(void *,char *); 135 ssize_t(*show) (void *, char *);
137 ssize_t (*store)(void *, const char *, size_t); 136 ssize_t(*store) (void *, const char *, size_t);
138}; 137};
139 138
140/* Set of show/store abstract level functions for memory control object */ 139/* Set of show/store abstract level functions for memory control object */
141static ssize_t memctrl_dev_show(struct kobject *kobj, 140static ssize_t memctrl_dev_show(struct kobject *kobj,
142 struct attribute *attr, char *buffer) 141 struct attribute *attr, char *buffer)
143{ 142{
144 struct memctrl_dev_attribute *memctrl_dev; 143 struct memctrl_dev_attribute *memctrl_dev;
145 memctrl_dev = (struct memctrl_dev_attribute*)attr; 144 memctrl_dev = (struct memctrl_dev_attribute *)attr;
146 145
147 if (memctrl_dev->show) 146 if (memctrl_dev->show)
148 return memctrl_dev->show(memctrl_dev->value, buffer); 147 return memctrl_dev->show(memctrl_dev->value, buffer);
@@ -151,10 +150,10 @@ static ssize_t memctrl_dev_show(struct kobject *kobj,
151} 150}
152 151
153static ssize_t memctrl_dev_store(struct kobject *kobj, struct attribute *attr, 152static ssize_t memctrl_dev_store(struct kobject *kobj, struct attribute *attr,
154 const char *buffer, size_t count) 153 const char *buffer, size_t count)
155{ 154{
156 struct memctrl_dev_attribute *memctrl_dev; 155 struct memctrl_dev_attribute *memctrl_dev;
157 memctrl_dev = (struct memctrl_dev_attribute*)attr; 156 memctrl_dev = (struct memctrl_dev_attribute *)attr;
158 157
159 if (memctrl_dev->store) 158 if (memctrl_dev->store)
160 return memctrl_dev->store(memctrl_dev->value, buffer, count); 159 return memctrl_dev->store(memctrl_dev->value, buffer, count);
@@ -163,8 +162,8 @@ static ssize_t memctrl_dev_store(struct kobject *kobj, struct attribute *attr,
163} 162}
164 163
165static struct sysfs_ops memctrlfs_ops = { 164static struct sysfs_ops memctrlfs_ops = {
166 .show = memctrl_dev_show, 165 .show = memctrl_dev_show,
167 .store = memctrl_dev_store 166 .store = memctrl_dev_store
168}; 167};
169 168
170#define MEMCTRL_ATTR(_name,_mode,_show,_store) \ 169#define MEMCTRL_ATTR(_name,_mode,_show,_store) \
@@ -185,24 +184,16 @@ static struct memctrl_dev_attribute attr_##_name = { \
185 184
186/* csrow<id> control files */ 185/* csrow<id> control files */
187MEMCTRL_ATTR(edac_mc_panic_on_ue, 186MEMCTRL_ATTR(edac_mc_panic_on_ue,
188 S_IRUGO | S_IWUSR, 187 S_IRUGO | S_IWUSR, memctrl_int_show, memctrl_int_store);
189 memctrl_int_show,
190 memctrl_int_store);
191 188
192MEMCTRL_ATTR(edac_mc_log_ue, 189MEMCTRL_ATTR(edac_mc_log_ue,
193 S_IRUGO|S_IWUSR, 190 S_IRUGO | S_IWUSR, memctrl_int_show, memctrl_int_store);
194 memctrl_int_show,
195 memctrl_int_store);
196 191
197MEMCTRL_ATTR(edac_mc_log_ce, 192MEMCTRL_ATTR(edac_mc_log_ce,
198 S_IRUGO|S_IWUSR, 193 S_IRUGO | S_IWUSR, memctrl_int_show, memctrl_int_store);
199 memctrl_int_show,
200 memctrl_int_store);
201 194
202MEMCTRL_ATTR(edac_mc_poll_msec, 195MEMCTRL_ATTR(edac_mc_poll_msec,
203 S_IRUGO|S_IWUSR, 196 S_IRUGO | S_IWUSR, memctrl_int_show, memctrl_int_store);
204 memctrl_int_show,
205 memctrl_int_store);
206 197
207/* Base Attributes of the memory ECC object */ 198/* Base Attributes of the memory ECC object */
208static struct memctrl_dev_attribute *memctrl_attr[] = { 199static struct memctrl_dev_attribute *memctrl_attr[] = {
@@ -223,7 +214,7 @@ static void edac_memctrl_master_release(struct kobject *kobj)
223static struct kobj_type ktype_memctrl = { 214static struct kobj_type ktype_memctrl = {
224 .release = edac_memctrl_master_release, 215 .release = edac_memctrl_master_release,
225 .sysfs_ops = &memctrlfs_ops, 216 .sysfs_ops = &memctrlfs_ops,
226 .default_attrs = (struct attribute **) memctrl_attr, 217 .default_attrs = (struct attribute **)memctrl_attr,
227}; 218};
228 219
229/* Initialize the main sysfs entries for edac: 220/* Initialize the main sysfs entries for edac:
@@ -249,25 +240,25 @@ int edac_sysfs_memctrl_setup(void)
249 } 240 }
250 241
251 /* Init the MC's kobject */ 242 /* Init the MC's kobject */
252 memset(&edac_memctrl_kobj, 0, sizeof (edac_memctrl_kobj)); 243 memset(&edac_memctrl_kobj, 0, sizeof(edac_memctrl_kobj));
253 edac_memctrl_kobj.parent = &edac_class->kset.kobj; 244 edac_memctrl_kobj.parent = &edac_class->kset.kobj;
254 edac_memctrl_kobj.ktype = &ktype_memctrl; 245 edac_memctrl_kobj.ktype = &ktype_memctrl;
255 246
256 /* generate sysfs "..../edac/mc" */ 247 /* generate sysfs "..../edac/mc" */
257 err = kobject_set_name(&edac_memctrl_kobj,"mc"); 248 err = kobject_set_name(&edac_memctrl_kobj, "mc");
258 if (err) { 249 if (err) {
259 debugf1("%s() Failed to set name '.../edac/mc'\n", __func__ ); 250 debugf1("%s() Failed to set name '.../edac/mc'\n", __func__);
260 return err; 251 return err;
261 } 252 }
262 253
263 /* FIXME: maybe new sysdev_create_subdir() */ 254 /* FIXME: maybe new sysdev_create_subdir() */
264 err = kobject_register(&edac_memctrl_kobj); 255 err = kobject_register(&edac_memctrl_kobj);
265 if (err) { 256 if (err) {
266 debugf1("%s() Failed to register '.../edac/mc'\n", __func__ ); 257 debugf1("%s() Failed to register '.../edac/mc'\n", __func__);
267 return err; 258 return err;
268 } 259 }
269 260
270 debugf1("%s() Registered '.../edac/mc' kobject\n",__func__); 261 debugf1("%s() Registered '.../edac/mc' kobject\n", __func__);
271 return 0; 262 return 0;
272} 263}
273 264
@@ -286,63 +277,61 @@ void edac_sysfs_memctrl_teardown(void)
286 wait_for_completion(&edac_memctrl_kobj_complete); 277 wait_for_completion(&edac_memctrl_kobj_complete);
287} 278}
288 279
289
290/* EDAC sysfs CSROW data structures and methods 280/* EDAC sysfs CSROW data structures and methods
291 */ 281 */
292 282
293/* Set of more default csrow<id> attribute show/store functions */ 283/* Set of more default csrow<id> attribute show/store functions */
294static ssize_t csrow_ue_count_show(struct csrow_info *csrow, char *data, 284static ssize_t csrow_ue_count_show(struct csrow_info *csrow, char *data,
295 int private) 285 int private)
296{ 286{
297 return sprintf(data,"%u\n", csrow->ue_count); 287 return sprintf(data, "%u\n", csrow->ue_count);
298} 288}
299 289
300static ssize_t csrow_ce_count_show(struct csrow_info *csrow, char *data, 290static ssize_t csrow_ce_count_show(struct csrow_info *csrow, char *data,
301 int private) 291 int private)
302{ 292{
303 return sprintf(data,"%u\n", csrow->ce_count); 293 return sprintf(data, "%u\n", csrow->ce_count);
304} 294}
305 295
306static ssize_t csrow_size_show(struct csrow_info *csrow, char *data, 296static ssize_t csrow_size_show(struct csrow_info *csrow, char *data,
307 int private) 297 int private)
308{ 298{
309 return sprintf(data,"%u\n", PAGES_TO_MiB(csrow->nr_pages)); 299 return sprintf(data, "%u\n", PAGES_TO_MiB(csrow->nr_pages));
310} 300}
311 301
312static ssize_t csrow_mem_type_show(struct csrow_info *csrow, char *data, 302static ssize_t csrow_mem_type_show(struct csrow_info *csrow, char *data,
313 int private) 303 int private)
314{ 304{
315 return sprintf(data,"%s\n", mem_types[csrow->mtype]); 305 return sprintf(data, "%s\n", mem_types[csrow->mtype]);
316} 306}
317 307
318static ssize_t csrow_dev_type_show(struct csrow_info *csrow, char *data, 308static ssize_t csrow_dev_type_show(struct csrow_info *csrow, char *data,
319 int private) 309 int private)
320{ 310{
321 return sprintf(data,"%s\n", dev_types[csrow->dtype]); 311 return sprintf(data, "%s\n", dev_types[csrow->dtype]);
322} 312}
323 313
324static ssize_t csrow_edac_mode_show(struct csrow_info *csrow, char *data, 314static ssize_t csrow_edac_mode_show(struct csrow_info *csrow, char *data,
325 int private) 315 int private)
326{ 316{
327 return sprintf(data,"%s\n", edac_caps[csrow->edac_mode]); 317 return sprintf(data, "%s\n", edac_caps[csrow->edac_mode]);
328} 318}
329 319
330/* show/store functions for DIMM Label attributes */ 320/* show/store functions for DIMM Label attributes */
331static ssize_t channel_dimm_label_show(struct csrow_info *csrow, 321static ssize_t channel_dimm_label_show(struct csrow_info *csrow,
332 char *data, int channel) 322 char *data, int channel)
333{ 323{
334 return snprintf(data, EDAC_MC_LABEL_LEN,"%s", 324 return snprintf(data, EDAC_MC_LABEL_LEN, "%s",
335 csrow->channels[channel].label); 325 csrow->channels[channel].label);
336} 326}
337 327
338static ssize_t channel_dimm_label_store(struct csrow_info *csrow, 328static ssize_t channel_dimm_label_store(struct csrow_info *csrow,
339 const char *data, 329 const char *data,
340 size_t count, 330 size_t count, int channel)
341 int channel)
342{ 331{
343 ssize_t max_size = 0; 332 ssize_t max_size = 0;
344 333
345 max_size = min((ssize_t)count,(ssize_t)EDAC_MC_LABEL_LEN-1); 334 max_size = min((ssize_t) count, (ssize_t) EDAC_MC_LABEL_LEN - 1);
346 strncpy(csrow->channels[channel].label, data, max_size); 335 strncpy(csrow->channels[channel].label, data, max_size);
347 csrow->channels[channel].label[max_size] = '\0'; 336 csrow->channels[channel].label[max_size] = '\0';
348 337
@@ -351,8 +340,7 @@ static ssize_t channel_dimm_label_store(struct csrow_info *csrow,
351 340
352/* show function for dynamic chX_ce_count attribute */ 341/* show function for dynamic chX_ce_count attribute */
353static ssize_t channel_ce_count_show(struct csrow_info *csrow, 342static ssize_t channel_ce_count_show(struct csrow_info *csrow,
354 char *data, 343 char *data, int channel)
355 int channel)
356{ 344{
357 return sprintf(data, "%u\n", csrow->channels[channel].ce_count); 345 return sprintf(data, "%u\n", csrow->channels[channel].ce_count);
358} 346}
@@ -360,9 +348,9 @@ static ssize_t channel_ce_count_show(struct csrow_info *csrow,
360/* csrow specific attribute structure */ 348/* csrow specific attribute structure */
361struct csrowdev_attribute { 349struct csrowdev_attribute {
362 struct attribute attr; 350 struct attribute attr;
363 ssize_t (*show)(struct csrow_info *,char *,int); 351 ssize_t(*show) (struct csrow_info *, char *, int);
364 ssize_t (*store)(struct csrow_info *, const char *,size_t,int); 352 ssize_t(*store) (struct csrow_info *, const char *, size_t, int);
365 int private; 353 int private;
366}; 354};
367 355
368#define to_csrow(k) container_of(k, struct csrow_info, kobj) 356#define to_csrow(k) container_of(k, struct csrow_info, kobj)
@@ -370,36 +358,33 @@ struct csrowdev_attribute {
370 358
371/* Set of show/store higher level functions for default csrow attributes */ 359/* Set of show/store higher level functions for default csrow attributes */
372static ssize_t csrowdev_show(struct kobject *kobj, 360static ssize_t csrowdev_show(struct kobject *kobj,
373 struct attribute *attr, 361 struct attribute *attr, char *buffer)
374 char *buffer)
375{ 362{
376 struct csrow_info *csrow = to_csrow(kobj); 363 struct csrow_info *csrow = to_csrow(kobj);
377 struct csrowdev_attribute *csrowdev_attr = to_csrowdev_attr(attr); 364 struct csrowdev_attribute *csrowdev_attr = to_csrowdev_attr(attr);
378 365
379 if (csrowdev_attr->show) 366 if (csrowdev_attr->show)
380 return csrowdev_attr->show(csrow, 367 return csrowdev_attr->show(csrow,
381 buffer, 368 buffer, csrowdev_attr->private);
382 csrowdev_attr->private);
383 return -EIO; 369 return -EIO;
384} 370}
385 371
386static ssize_t csrowdev_store(struct kobject *kobj, struct attribute *attr, 372static ssize_t csrowdev_store(struct kobject *kobj, struct attribute *attr,
387 const char *buffer, size_t count) 373 const char *buffer, size_t count)
388{ 374{
389 struct csrow_info *csrow = to_csrow(kobj); 375 struct csrow_info *csrow = to_csrow(kobj);
390 struct csrowdev_attribute * csrowdev_attr = to_csrowdev_attr(attr); 376 struct csrowdev_attribute *csrowdev_attr = to_csrowdev_attr(attr);
391 377
392 if (csrowdev_attr->store) 378 if (csrowdev_attr->store)
393 return csrowdev_attr->store(csrow, 379 return csrowdev_attr->store(csrow,
394 buffer, 380 buffer,
395 count, 381 count, csrowdev_attr->private);
396 csrowdev_attr->private);
397 return -EIO; 382 return -EIO;
398} 383}
399 384
400static struct sysfs_ops csrowfs_ops = { 385static struct sysfs_ops csrowfs_ops = {
401 .show = csrowdev_show, 386 .show = csrowdev_show,
402 .store = csrowdev_store 387 .store = csrowdev_store
403}; 388};
404 389
405#define CSROWDEV_ATTR(_name,_mode,_show,_store,_private) \ 390#define CSROWDEV_ATTR(_name,_mode,_show,_store,_private) \
@@ -411,12 +396,12 @@ static struct csrowdev_attribute attr_##_name = { \
411}; 396};
412 397
413/* default cwrow<id>/attribute files */ 398/* default cwrow<id>/attribute files */
414CSROWDEV_ATTR(size_mb,S_IRUGO,csrow_size_show,NULL,0); 399CSROWDEV_ATTR(size_mb, S_IRUGO, csrow_size_show, NULL, 0);
415CSROWDEV_ATTR(dev_type,S_IRUGO,csrow_dev_type_show,NULL,0); 400CSROWDEV_ATTR(dev_type, S_IRUGO, csrow_dev_type_show, NULL, 0);
416CSROWDEV_ATTR(mem_type,S_IRUGO,csrow_mem_type_show,NULL,0); 401CSROWDEV_ATTR(mem_type, S_IRUGO, csrow_mem_type_show, NULL, 0);
417CSROWDEV_ATTR(edac_mode,S_IRUGO,csrow_edac_mode_show,NULL,0); 402CSROWDEV_ATTR(edac_mode, S_IRUGO, csrow_edac_mode_show, NULL, 0);
418CSROWDEV_ATTR(ue_count,S_IRUGO,csrow_ue_count_show,NULL,0); 403CSROWDEV_ATTR(ue_count, S_IRUGO, csrow_ue_count_show, NULL, 0);
419CSROWDEV_ATTR(ce_count,S_IRUGO,csrow_ce_count_show,NULL,0); 404CSROWDEV_ATTR(ce_count, S_IRUGO, csrow_ce_count_show, NULL, 0);
420 405
421/* default attributes of the CSROW<id> object */ 406/* default attributes of the CSROW<id> object */
422static struct csrowdev_attribute *default_csrow_attr[] = { 407static struct csrowdev_attribute *default_csrow_attr[] = {
@@ -429,98 +414,68 @@ static struct csrowdev_attribute *default_csrow_attr[] = {
429 NULL, 414 NULL,
430}; 415};
431 416
432
433/* possible dynamic channel DIMM Label attribute files */ 417/* possible dynamic channel DIMM Label attribute files */
434CSROWDEV_ATTR(ch0_dimm_label,S_IRUGO|S_IWUSR, 418CSROWDEV_ATTR(ch0_dimm_label, S_IRUGO | S_IWUSR,
435 channel_dimm_label_show, 419 channel_dimm_label_show, channel_dimm_label_store, 0);
436 channel_dimm_label_store, 420CSROWDEV_ATTR(ch1_dimm_label, S_IRUGO | S_IWUSR,
437 0 ); 421 channel_dimm_label_show, channel_dimm_label_store, 1);
438CSROWDEV_ATTR(ch1_dimm_label,S_IRUGO|S_IWUSR, 422CSROWDEV_ATTR(ch2_dimm_label, S_IRUGO | S_IWUSR,
439 channel_dimm_label_show, 423 channel_dimm_label_show, channel_dimm_label_store, 2);
440 channel_dimm_label_store, 424CSROWDEV_ATTR(ch3_dimm_label, S_IRUGO | S_IWUSR,
441 1 ); 425 channel_dimm_label_show, channel_dimm_label_store, 3);
442CSROWDEV_ATTR(ch2_dimm_label,S_IRUGO|S_IWUSR, 426CSROWDEV_ATTR(ch4_dimm_label, S_IRUGO | S_IWUSR,
443 channel_dimm_label_show, 427 channel_dimm_label_show, channel_dimm_label_store, 4);
444 channel_dimm_label_store, 428CSROWDEV_ATTR(ch5_dimm_label, S_IRUGO | S_IWUSR,
445 2 ); 429 channel_dimm_label_show, channel_dimm_label_store, 5);
446CSROWDEV_ATTR(ch3_dimm_label,S_IRUGO|S_IWUSR,
447 channel_dimm_label_show,
448 channel_dimm_label_store,
449 3 );
450CSROWDEV_ATTR(ch4_dimm_label,S_IRUGO|S_IWUSR,
451 channel_dimm_label_show,
452 channel_dimm_label_store,
453 4 );
454CSROWDEV_ATTR(ch5_dimm_label,S_IRUGO|S_IWUSR,
455 channel_dimm_label_show,
456 channel_dimm_label_store,
457 5 );
458 430
459/* Total possible dynamic DIMM Label attribute file table */ 431/* Total possible dynamic DIMM Label attribute file table */
460static struct csrowdev_attribute *dynamic_csrow_dimm_attr[] = { 432static struct csrowdev_attribute *dynamic_csrow_dimm_attr[] = {
461 &attr_ch0_dimm_label, 433 &attr_ch0_dimm_label,
462 &attr_ch1_dimm_label, 434 &attr_ch1_dimm_label,
463 &attr_ch2_dimm_label, 435 &attr_ch2_dimm_label,
464 &attr_ch3_dimm_label, 436 &attr_ch3_dimm_label,
465 &attr_ch4_dimm_label, 437 &attr_ch4_dimm_label,
466 &attr_ch5_dimm_label 438 &attr_ch5_dimm_label
467}; 439};
468 440
469/* possible dynamic channel ce_count attribute files */ 441/* possible dynamic channel ce_count attribute files */
470CSROWDEV_ATTR(ch0_ce_count,S_IRUGO|S_IWUSR, 442CSROWDEV_ATTR(ch0_ce_count, S_IRUGO | S_IWUSR, channel_ce_count_show, NULL, 0);
471 channel_ce_count_show, 443CSROWDEV_ATTR(ch1_ce_count, S_IRUGO | S_IWUSR, channel_ce_count_show, NULL, 1);
472 NULL, 444CSROWDEV_ATTR(ch2_ce_count, S_IRUGO | S_IWUSR, channel_ce_count_show, NULL, 2);
473 0 ); 445CSROWDEV_ATTR(ch3_ce_count, S_IRUGO | S_IWUSR, channel_ce_count_show, NULL, 3);
474CSROWDEV_ATTR(ch1_ce_count,S_IRUGO|S_IWUSR, 446CSROWDEV_ATTR(ch4_ce_count, S_IRUGO | S_IWUSR, channel_ce_count_show, NULL, 4);
475 channel_ce_count_show, 447CSROWDEV_ATTR(ch5_ce_count, S_IRUGO | S_IWUSR, channel_ce_count_show, NULL, 5);
476 NULL,
477 1 );
478CSROWDEV_ATTR(ch2_ce_count,S_IRUGO|S_IWUSR,
479 channel_ce_count_show,
480 NULL,
481 2 );
482CSROWDEV_ATTR(ch3_ce_count,S_IRUGO|S_IWUSR,
483 channel_ce_count_show,
484 NULL,
485 3 );
486CSROWDEV_ATTR(ch4_ce_count,S_IRUGO|S_IWUSR,
487 channel_ce_count_show,
488 NULL,
489 4 );
490CSROWDEV_ATTR(ch5_ce_count,S_IRUGO|S_IWUSR,
491 channel_ce_count_show,
492 NULL,
493 5 );
494 448
495/* Total possible dynamic ce_count attribute file table */ 449/* Total possible dynamic ce_count attribute file table */
496static struct csrowdev_attribute *dynamic_csrow_ce_count_attr[] = { 450static struct csrowdev_attribute *dynamic_csrow_ce_count_attr[] = {
497 &attr_ch0_ce_count, 451 &attr_ch0_ce_count,
498 &attr_ch1_ce_count, 452 &attr_ch1_ce_count,
499 &attr_ch2_ce_count, 453 &attr_ch2_ce_count,
500 &attr_ch3_ce_count, 454 &attr_ch3_ce_count,
501 &attr_ch4_ce_count, 455 &attr_ch4_ce_count,
502 &attr_ch5_ce_count 456 &attr_ch5_ce_count
503}; 457};
504 458
505
506#define EDAC_NR_CHANNELS 6 459#define EDAC_NR_CHANNELS 6
507 460
508/* Create dynamic CHANNEL files, indexed by 'chan', under specifed CSROW */ 461/* Create dynamic CHANNEL files, indexed by 'chan', under specifed CSROW */
509static int edac_create_channel_files(struct kobject *kobj, int chan) 462static int edac_create_channel_files(struct kobject *kobj, int chan)
510{ 463{
511 int err=-ENODEV; 464 int err = -ENODEV;
512 465
513 if (chan >= EDAC_NR_CHANNELS) 466 if (chan >= EDAC_NR_CHANNELS)
514 return err; 467 return err;
515 468
516 /* create the DIMM label attribute file */ 469 /* create the DIMM label attribute file */
517 err = sysfs_create_file(kobj, 470 err = sysfs_create_file(kobj,
518 (struct attribute *) dynamic_csrow_dimm_attr[chan]); 471 (struct attribute *)
472 dynamic_csrow_dimm_attr[chan]);
519 473
520 if (!err) { 474 if (!err) {
521 /* create the CE Count attribute file */ 475 /* create the CE Count attribute file */
522 err = sysfs_create_file(kobj, 476 err = sysfs_create_file(kobj,
523 (struct attribute *)dynamic_csrow_ce_count_attr[chan]); 477 (struct attribute *)
478 dynamic_csrow_ce_count_attr[chan]);
524 } else { 479 } else {
525 debugf1("%s() dimm labels and ce_count files created", 480 debugf1("%s() dimm labels and ce_count files created",
526 __func__); 481 __func__);
@@ -542,14 +497,12 @@ static void edac_csrow_instance_release(struct kobject *kobj)
542static struct kobj_type ktype_csrow = { 497static struct kobj_type ktype_csrow = {
543 .release = edac_csrow_instance_release, 498 .release = edac_csrow_instance_release,
544 .sysfs_ops = &csrowfs_ops, 499 .sysfs_ops = &csrowfs_ops,
545 .default_attrs = (struct attribute **) default_csrow_attr, 500 .default_attrs = (struct attribute **)default_csrow_attr,
546}; 501};
547 502
548/* Create a CSROW object under specifed edac_mc_device */ 503/* Create a CSROW object under specifed edac_mc_device */
549static int edac_create_csrow_object( 504static int edac_create_csrow_object(struct kobject *edac_mci_kobj,
550 struct kobject *edac_mci_kobj, 505 struct csrow_info *csrow, int index)
551 struct csrow_info *csrow,
552 int index)
553{ 506{
554 int err = 0; 507 int err = 0;
555 int chan; 508 int chan;
@@ -562,7 +515,7 @@ static int edac_create_csrow_object(
562 csrow->kobj.ktype = &ktype_csrow; 515 csrow->kobj.ktype = &ktype_csrow;
563 516
564 /* name this instance of csrow<id> */ 517 /* name this instance of csrow<id> */
565 err = kobject_set_name(&csrow->kobj,"csrow%d",index); 518 err = kobject_set_name(&csrow->kobj, "csrow%d", index);
566 if (err) 519 if (err)
567 goto error_exit; 520 goto error_exit;
568 521
@@ -573,20 +526,20 @@ static int edac_create_csrow_object(
573 * namely, the DIMM labels and the channel ce_count 526 * namely, the DIMM labels and the channel ce_count
574 */ 527 */
575 for (chan = 0; chan < csrow->nr_channels; chan++) { 528 for (chan = 0; chan < csrow->nr_channels; chan++) {
576 err = edac_create_channel_files(&csrow->kobj,chan); 529 err = edac_create_channel_files(&csrow->kobj, chan);
577 if (err) 530 if (err)
578 break; 531 break;
579 } 532 }
580 } 533 }
581 534
582error_exit: 535 error_exit:
583 return err; 536 return err;
584} 537}
585 538
586/* default sysfs methods and data structures for the main MCI kobject */ 539/* default sysfs methods and data structures for the main MCI kobject */
587 540
588static ssize_t mci_reset_counters_store(struct mem_ctl_info *mci, 541static ssize_t mci_reset_counters_store(struct mem_ctl_info *mci,
589 const char *data, size_t count) 542 const char *data, size_t count)
590{ 543{
591 int row, chan; 544 int row, chan;
592 545
@@ -611,7 +564,7 @@ static ssize_t mci_reset_counters_store(struct mem_ctl_info *mci,
611 564
612/* memory scrubbing */ 565/* memory scrubbing */
613static ssize_t mci_sdram_scrub_rate_store(struct mem_ctl_info *mci, 566static ssize_t mci_sdram_scrub_rate_store(struct mem_ctl_info *mci,
614 const char *data, size_t count) 567 const char *data, size_t count)
615{ 568{
616 u32 bandwidth = -1; 569 u32 bandwidth = -1;
617 570
@@ -619,20 +572,20 @@ static ssize_t mci_sdram_scrub_rate_store(struct mem_ctl_info *mci,
619 572
620 memctrl_int_store(&bandwidth, data, count); 573 memctrl_int_store(&bandwidth, data, count);
621 574
622 if (!(*mci->set_sdram_scrub_rate)(mci, &bandwidth)) { 575 if (!(*mci->set_sdram_scrub_rate) (mci, &bandwidth)) {
623 edac_printk(KERN_DEBUG, EDAC_MC, 576 edac_printk(KERN_DEBUG, EDAC_MC,
624 "Scrub rate set successfully, applied: %d\n", 577 "Scrub rate set successfully, applied: %d\n",
625 bandwidth); 578 bandwidth);
626 } else { 579 } else {
627 /* FIXME: error codes maybe? */ 580 /* FIXME: error codes maybe? */
628 edac_printk(KERN_DEBUG, EDAC_MC, 581 edac_printk(KERN_DEBUG, EDAC_MC,
629 "Scrub rate set FAILED, could not apply: %d\n", 582 "Scrub rate set FAILED, could not apply: %d\n",
630 bandwidth); 583 bandwidth);
631 } 584 }
632 } else { 585 } else {
633 /* FIXME: produce "not implemented" ERROR for user-side. */ 586 /* FIXME: produce "not implemented" ERROR for user-side. */
634 edac_printk(KERN_WARNING, EDAC_MC, 587 edac_printk(KERN_WARNING, EDAC_MC,
635 "Memory scrubbing 'set'control is not implemented!\n"); 588 "Memory scrubbing 'set'control is not implemented!\n");
636 } 589 }
637 return count; 590 return count;
638} 591}
@@ -642,20 +595,20 @@ static ssize_t mci_sdram_scrub_rate_show(struct mem_ctl_info *mci, char *data)
642 u32 bandwidth = -1; 595 u32 bandwidth = -1;
643 596
644 if (mci->get_sdram_scrub_rate) { 597 if (mci->get_sdram_scrub_rate) {
645 if (!(*mci->get_sdram_scrub_rate)(mci, &bandwidth)) { 598 if (!(*mci->get_sdram_scrub_rate) (mci, &bandwidth)) {
646 edac_printk(KERN_DEBUG, EDAC_MC, 599 edac_printk(KERN_DEBUG, EDAC_MC,
647 "Scrub rate successfully, fetched: %d\n", 600 "Scrub rate successfully, fetched: %d\n",
648 bandwidth); 601 bandwidth);
649 } else { 602 } else {
650 /* FIXME: error codes maybe? */ 603 /* FIXME: error codes maybe? */
651 edac_printk(KERN_DEBUG, EDAC_MC, 604 edac_printk(KERN_DEBUG, EDAC_MC,
652 "Scrub rate fetch FAILED, got: %d\n", 605 "Scrub rate fetch FAILED, got: %d\n",
653 bandwidth); 606 bandwidth);
654 } 607 }
655 } else { 608 } else {
656 /* FIXME: produce "not implemented" ERROR for user-side. */ 609 /* FIXME: produce "not implemented" ERROR for user-side. */
657 edac_printk(KERN_WARNING, EDAC_MC, 610 edac_printk(KERN_WARNING, EDAC_MC,
658 "Memory scrubbing 'get' control is not implemented\n"); 611 "Memory scrubbing 'get' control is not implemented\n");
659 } 612 }
660 return sprintf(data, "%d\n", bandwidth); 613 return sprintf(data, "%d\n", bandwidth);
661} 614}
@@ -663,32 +616,32 @@ static ssize_t mci_sdram_scrub_rate_show(struct mem_ctl_info *mci, char *data)
663/* default attribute files for the MCI object */ 616/* default attribute files for the MCI object */
664static ssize_t mci_ue_count_show(struct mem_ctl_info *mci, char *data) 617static ssize_t mci_ue_count_show(struct mem_ctl_info *mci, char *data)
665{ 618{
666 return sprintf(data,"%d\n", mci->ue_count); 619 return sprintf(data, "%d\n", mci->ue_count);
667} 620}
668 621
669static ssize_t mci_ce_count_show(struct mem_ctl_info *mci, char *data) 622static ssize_t mci_ce_count_show(struct mem_ctl_info *mci, char *data)
670{ 623{
671 return sprintf(data,"%d\n", mci->ce_count); 624 return sprintf(data, "%d\n", mci->ce_count);
672} 625}
673 626
674static ssize_t mci_ce_noinfo_show(struct mem_ctl_info *mci, char *data) 627static ssize_t mci_ce_noinfo_show(struct mem_ctl_info *mci, char *data)
675{ 628{
676 return sprintf(data,"%d\n", mci->ce_noinfo_count); 629 return sprintf(data, "%d\n", mci->ce_noinfo_count);
677} 630}
678 631
679static ssize_t mci_ue_noinfo_show(struct mem_ctl_info *mci, char *data) 632static ssize_t mci_ue_noinfo_show(struct mem_ctl_info *mci, char *data)
680{ 633{
681 return sprintf(data,"%d\n", mci->ue_noinfo_count); 634 return sprintf(data, "%d\n", mci->ue_noinfo_count);
682} 635}
683 636
684static ssize_t mci_seconds_show(struct mem_ctl_info *mci, char *data) 637static ssize_t mci_seconds_show(struct mem_ctl_info *mci, char *data)
685{ 638{
686 return sprintf(data,"%ld\n", (jiffies - mci->start_time) / HZ); 639 return sprintf(data, "%ld\n", (jiffies - mci->start_time) / HZ);
687} 640}
688 641
689static ssize_t mci_ctl_name_show(struct mem_ctl_info *mci, char *data) 642static ssize_t mci_ctl_name_show(struct mem_ctl_info *mci, char *data)
690{ 643{
691 return sprintf(data,"%s\n", mci->ctl_name); 644 return sprintf(data, "%s\n", mci->ctl_name);
692} 645}
693 646
694static ssize_t mci_size_mb_show(struct mem_ctl_info *mci, char *data) 647static ssize_t mci_size_mb_show(struct mem_ctl_info *mci, char *data)
@@ -696,7 +649,7 @@ static ssize_t mci_size_mb_show(struct mem_ctl_info *mci, char *data)
696 int total_pages, csrow_idx; 649 int total_pages, csrow_idx;
697 650
698 for (total_pages = csrow_idx = 0; csrow_idx < mci->nr_csrows; 651 for (total_pages = csrow_idx = 0; csrow_idx < mci->nr_csrows;
699 csrow_idx++) { 652 csrow_idx++) {
700 struct csrow_info *csrow = &mci->csrows[csrow_idx]; 653 struct csrow_info *csrow = &mci->csrows[csrow_idx];
701 654
702 if (!csrow->nr_pages) 655 if (!csrow->nr_pages)
@@ -705,13 +658,13 @@ static ssize_t mci_size_mb_show(struct mem_ctl_info *mci, char *data)
705 total_pages += csrow->nr_pages; 658 total_pages += csrow->nr_pages;
706 } 659 }
707 660
708 return sprintf(data,"%u\n", PAGES_TO_MiB(total_pages)); 661 return sprintf(data, "%u\n", PAGES_TO_MiB(total_pages));
709} 662}
710 663
711struct mcidev_attribute { 664struct mcidev_attribute {
712 struct attribute attr; 665 struct attribute attr;
713 ssize_t (*show)(struct mem_ctl_info *,char *); 666 ssize_t(*show) (struct mem_ctl_info *, char *);
714 ssize_t (*store)(struct mem_ctl_info *, const char *,size_t); 667 ssize_t(*store) (struct mem_ctl_info *, const char *, size_t);
715}; 668};
716 669
717#define to_mci(k) container_of(k, struct mem_ctl_info, edac_mci_kobj) 670#define to_mci(k) container_of(k, struct mem_ctl_info, edac_mci_kobj)
@@ -719,10 +672,10 @@ struct mcidev_attribute {
719 672
720/* MCI show/store functions for top most object */ 673/* MCI show/store functions for top most object */
721static ssize_t mcidev_show(struct kobject *kobj, struct attribute *attr, 674static ssize_t mcidev_show(struct kobject *kobj, struct attribute *attr,
722 char *buffer) 675 char *buffer)
723{ 676{
724 struct mem_ctl_info *mem_ctl_info = to_mci(kobj); 677 struct mem_ctl_info *mem_ctl_info = to_mci(kobj);
725 struct mcidev_attribute * mcidev_attr = to_mcidev_attr(attr); 678 struct mcidev_attribute *mcidev_attr = to_mcidev_attr(attr);
726 679
727 if (mcidev_attr->show) 680 if (mcidev_attr->show)
728 return mcidev_attr->show(mem_ctl_info, buffer); 681 return mcidev_attr->show(mem_ctl_info, buffer);
@@ -731,10 +684,10 @@ static ssize_t mcidev_show(struct kobject *kobj, struct attribute *attr,
731} 684}
732 685
733static ssize_t mcidev_store(struct kobject *kobj, struct attribute *attr, 686static ssize_t mcidev_store(struct kobject *kobj, struct attribute *attr,
734 const char *buffer, size_t count) 687 const char *buffer, size_t count)
735{ 688{
736 struct mem_ctl_info *mem_ctl_info = to_mci(kobj); 689 struct mem_ctl_info *mem_ctl_info = to_mci(kobj);
737 struct mcidev_attribute * mcidev_attr = to_mcidev_attr(attr); 690 struct mcidev_attribute *mcidev_attr = to_mcidev_attr(attr);
738 691
739 if (mcidev_attr->store) 692 if (mcidev_attr->store)
740 return mcidev_attr->store(mem_ctl_info, buffer, count); 693 return mcidev_attr->store(mem_ctl_info, buffer, count);
@@ -755,20 +708,20 @@ static struct mcidev_attribute mci_attr_##_name = { \
755}; 708};
756 709
757/* default Control file */ 710/* default Control file */
758MCIDEV_ATTR(reset_counters,S_IWUSR,NULL,mci_reset_counters_store); 711MCIDEV_ATTR(reset_counters, S_IWUSR, NULL, mci_reset_counters_store);
759 712
760/* default Attribute files */ 713/* default Attribute files */
761MCIDEV_ATTR(mc_name,S_IRUGO,mci_ctl_name_show,NULL); 714MCIDEV_ATTR(mc_name, S_IRUGO, mci_ctl_name_show, NULL);
762MCIDEV_ATTR(size_mb,S_IRUGO,mci_size_mb_show,NULL); 715MCIDEV_ATTR(size_mb, S_IRUGO, mci_size_mb_show, NULL);
763MCIDEV_ATTR(seconds_since_reset,S_IRUGO,mci_seconds_show,NULL); 716MCIDEV_ATTR(seconds_since_reset, S_IRUGO, mci_seconds_show, NULL);
764MCIDEV_ATTR(ue_noinfo_count,S_IRUGO,mci_ue_noinfo_show,NULL); 717MCIDEV_ATTR(ue_noinfo_count, S_IRUGO, mci_ue_noinfo_show, NULL);
765MCIDEV_ATTR(ce_noinfo_count,S_IRUGO,mci_ce_noinfo_show,NULL); 718MCIDEV_ATTR(ce_noinfo_count, S_IRUGO, mci_ce_noinfo_show, NULL);
766MCIDEV_ATTR(ue_count,S_IRUGO,mci_ue_count_show,NULL); 719MCIDEV_ATTR(ue_count, S_IRUGO, mci_ue_count_show, NULL);
767MCIDEV_ATTR(ce_count,S_IRUGO,mci_ce_count_show,NULL); 720MCIDEV_ATTR(ce_count, S_IRUGO, mci_ce_count_show, NULL);
768 721
769/* memory scrubber attribute file */ 722/* memory scrubber attribute file */
770MCIDEV_ATTR(sdram_scrub_rate,S_IRUGO|S_IWUSR,mci_sdram_scrub_rate_show,\ 723MCIDEV_ATTR(sdram_scrub_rate, S_IRUGO | S_IWUSR, mci_sdram_scrub_rate_show,
771 mci_sdram_scrub_rate_store); 724 mci_sdram_scrub_rate_store);
772 725
773static struct mcidev_attribute *mci_attr[] = { 726static struct mcidev_attribute *mci_attr[] = {
774 &mci_attr_reset_counters, 727 &mci_attr_reset_counters,
@@ -798,10 +751,9 @@ static void edac_mci_instance_release(struct kobject *kobj)
798static struct kobj_type ktype_mci = { 751static struct kobj_type ktype_mci = {
799 .release = edac_mci_instance_release, 752 .release = edac_mci_instance_release,
800 .sysfs_ops = &mci_ops, 753 .sysfs_ops = &mci_ops,
801 .default_attrs = (struct attribute **) mci_attr, 754 .default_attrs = (struct attribute **)mci_attr,
802}; 755};
803 756
804
805#define EDAC_DEVICE_SYMLINK "device" 757#define EDAC_DEVICE_SYMLINK "device"
806 758
807/* 759/*
@@ -817,13 +769,13 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
817 int i; 769 int i;
818 int err; 770 int err;
819 struct csrow_info *csrow; 771 struct csrow_info *csrow;
820 struct kobject *edac_mci_kobj=&mci->edac_mci_kobj; 772 struct kobject *edac_mci_kobj = &mci->edac_mci_kobj;
821 773
822 debugf0("%s() idx=%d\n", __func__, mci->mc_idx); 774 debugf0("%s() idx=%d\n", __func__, mci->mc_idx);
823 memset(edac_mci_kobj, 0, sizeof(*edac_mci_kobj)); 775 memset(edac_mci_kobj, 0, sizeof(*edac_mci_kobj));
824 776
825 /* set the name of the mc<id> object */ 777 /* set the name of the mc<id> object */
826 err = kobject_set_name(edac_mci_kobj,"mc%d",mci->mc_idx); 778 err = kobject_set_name(edac_mci_kobj, "mc%d", mci->mc_idx);
827 if (err) 779 if (err)
828 return err; 780 return err;
829 781
@@ -850,7 +802,7 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
850 802
851 /* Only expose populated CSROWs */ 803 /* Only expose populated CSROWs */
852 if (csrow->nr_pages > 0) { 804 if (csrow->nr_pages > 0) {
853 err = edac_create_csrow_object(edac_mci_kobj,csrow,i); 805 err = edac_create_csrow_object(edac_mci_kobj, csrow, i);
854 if (err) 806 if (err)
855 goto fail1; 807 goto fail1;
856 } 808 }
@@ -859,8 +811,8 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
859 return 0; 811 return 0;
860 812
861 /* CSROW error: backout what has already been registered, */ 813 /* CSROW error: backout what has already been registered, */
862fail1: 814 fail1:
863 for ( i--; i >= 0; i--) { 815 for (i--; i >= 0; i--) {
864 if (csrow->nr_pages > 0) { 816 if (csrow->nr_pages > 0) {
865 init_completion(&csrow->kobj_complete); 817 init_completion(&csrow->kobj_complete);
866 kobject_unregister(&mci->csrows[i].kobj); 818 kobject_unregister(&mci->csrows[i].kobj);
@@ -868,7 +820,7 @@ fail1:
868 } 820 }
869 } 821 }
870 822
871fail0: 823 fail0:
872 init_completion(&mci->kobj_complete); 824 init_completion(&mci->kobj_complete);
873 kobject_unregister(edac_mci_kobj); 825 kobject_unregister(edac_mci_kobj);
874 wait_for_completion(&mci->kobj_complete); 826 wait_for_completion(&mci->kobj_complete);
@@ -898,5 +850,3 @@ void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci)
898 kobject_unregister(&mci->edac_mci_kobj); 850 kobject_unregister(&mci->edac_mci_kobj);
899 wait_for_completion(&mci->kobj_complete); 851 wait_for_completion(&mci->kobj_complete);
900} 852}
901
902