edac_device.c (bd86d2ea369be2e768b58cba590e70b8bdc6f86a) edac_device.c (cec669ff716cc83505c77b242aecf6f7baad869d)
1
2/*
3 * edac_device.c
4 * (C) 2007 www.douglaskthompson.com
5 *
6 * This file may be distributed under the terms of the
7 * GNU General Public License.
8 *

--- 20 unchanged lines hidden (view full) ---

29#include "edac_module.h"
30
31/* lock for the list: 'edac_device_list', manipulation of this list
32 * is protected by the 'device_ctls_mutex' lock
33 */
34static DEFINE_MUTEX(device_ctls_mutex);
35static LIST_HEAD(edac_device_list);
36
1
2/*
3 * edac_device.c
4 * (C) 2007 www.douglaskthompson.com
5 *
6 * This file may be distributed under the terms of the
7 * GNU General Public License.
8 *

--- 20 unchanged lines hidden (view full) ---

29#include "edac_module.h"
30
31/* lock for the list: 'edac_device_list', manipulation of this list
32 * is protected by the 'device_ctls_mutex' lock
33 */
34static DEFINE_MUTEX(device_ctls_mutex);
35static LIST_HEAD(edac_device_list);
36
37/* Default workqueue processing interval on this instance, in msecs */
38#define DEFAULT_POLL_INTERVAL 1000
39
37#ifdef CONFIG_EDAC_DEBUG
38static void edac_device_dump_device(struct edac_device_ctl_info *edac_dev)
39{
40 edac_dbg(3, "\tedac_dev = %p dev_idx=%d\n",
41 edac_dev, edac_dev->dev_idx);
42 edac_dbg(4, "\tedac_dev->edac_check = %p\n", edac_dev->edac_check);
43 edac_dbg(3, "\tdev = %p\n", edac_dev->dev);
44 edac_dbg(3, "\tmod_name:ctl_name = %s:%s\n",

--- 286 unchanged lines hidden (view full) ---

331
332 mutex_unlock(&device_ctls_mutex);
333
334 /* Reschedule the workq for the next time period to start again
335 * if the number of msec is for 1 sec, then adjust to the next
336 * whole one second to save timers firing all over the period
337 * between integral seconds
338 */
40#ifdef CONFIG_EDAC_DEBUG
41static void edac_device_dump_device(struct edac_device_ctl_info *edac_dev)
42{
43 edac_dbg(3, "\tedac_dev = %p dev_idx=%d\n",
44 edac_dev, edac_dev->dev_idx);
45 edac_dbg(4, "\tedac_dev->edac_check = %p\n", edac_dev->edac_check);
46 edac_dbg(3, "\tdev = %p\n", edac_dev->dev);
47 edac_dbg(3, "\tmod_name:ctl_name = %s:%s\n",

--- 286 unchanged lines hidden (view full) ---

334
335 mutex_unlock(&device_ctls_mutex);
336
337 /* Reschedule the workq for the next time period to start again
338 * if the number of msec is for 1 sec, then adjust to the next
339 * whole one second to save timers firing all over the period
340 * between integral seconds
341 */
339 if (edac_dev->poll_msec == 1000)
342 if (edac_dev->poll_msec == DEFAULT_POLL_INTERVAL)
340 edac_queue_work(&edac_dev->work, round_jiffies_relative(edac_dev->delay));
341 else
342 edac_queue_work(&edac_dev->work, edac_dev->delay);
343}
344
345/*
346 * edac_device_workq_setup
347 * initialize a workq item for this edac_device instance

--- 13 unchanged lines hidden (view full) ---

361
362 INIT_DELAYED_WORK(&edac_dev->work, edac_device_workq_function);
363
364 /* optimize here for the 1 second case, which will be normal value, to
365 * fire ON the 1 second time event. This helps reduce all sorts of
366 * timers firing on sub-second basis, while they are happy
367 * to fire together on the 1 second exactly
368 */
343 edac_queue_work(&edac_dev->work, round_jiffies_relative(edac_dev->delay));
344 else
345 edac_queue_work(&edac_dev->work, edac_dev->delay);
346}
347
348/*
349 * edac_device_workq_setup
350 * initialize a workq item for this edac_device instance

--- 13 unchanged lines hidden (view full) ---

364
365 INIT_DELAYED_WORK(&edac_dev->work, edac_device_workq_function);
366
367 /* optimize here for the 1 second case, which will be normal value, to
368 * fire ON the 1 second time event. This helps reduce all sorts of
369 * timers firing on sub-second basis, while they are happy
370 * to fire together on the 1 second exactly
371 */
369 if (edac_dev->poll_msec == 1000)
372 if (edac_dev->poll_msec == DEFAULT_POLL_INTERVAL)
370 edac_queue_work(&edac_dev->work, round_jiffies_relative(edac_dev->delay));
371 else
372 edac_queue_work(&edac_dev->work, edac_dev->delay);
373}
374
375/*
376 * edac_device_workq_teardown
377 * stop the workq processing on this edac_dev

--- 17 unchanged lines hidden (view full) ---

395 */
396void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
397 unsigned long msec)
398{
399 edac_dev->poll_msec = msec;
400 edac_dev->delay = msecs_to_jiffies(msec);
401
402 /* See comment in edac_device_workq_setup() above */
373 edac_queue_work(&edac_dev->work, round_jiffies_relative(edac_dev->delay));
374 else
375 edac_queue_work(&edac_dev->work, edac_dev->delay);
376}
377
378/*
379 * edac_device_workq_teardown
380 * stop the workq processing on this edac_dev

--- 17 unchanged lines hidden (view full) ---

398 */
399void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
400 unsigned long msec)
401{
402 edac_dev->poll_msec = msec;
403 edac_dev->delay = msecs_to_jiffies(msec);
404
405 /* See comment in edac_device_workq_setup() above */
403 if (edac_dev->poll_msec == 1000)
406 if (edac_dev->poll_msec == DEFAULT_POLL_INTERVAL)
404 edac_mod_work(&edac_dev->work, round_jiffies_relative(edac_dev->delay));
405 else
406 edac_mod_work(&edac_dev->work, edac_dev->delay);
407}
408
409int edac_device_alloc_index(void)
410{
411 static atomic_t device_indexes = ATOMIC_INIT(0);

--- 25 unchanged lines hidden (view full) ---

437 goto fail1;
438 }
439
440 /* If there IS a check routine, then we are running POLLED */
441 if (edac_dev->edac_check != NULL) {
442 /* This instance is NOW RUNNING */
443 edac_dev->op_state = OP_RUNNING_POLL;
444
407 edac_mod_work(&edac_dev->work, round_jiffies_relative(edac_dev->delay));
408 else
409 edac_mod_work(&edac_dev->work, edac_dev->delay);
410}
411
412int edac_device_alloc_index(void)
413{
414 static atomic_t device_indexes = ATOMIC_INIT(0);

--- 25 unchanged lines hidden (view full) ---

440 goto fail1;
441 }
442
443 /* If there IS a check routine, then we are running POLLED */
444 if (edac_dev->edac_check != NULL) {
445 /* This instance is NOW RUNNING */
446 edac_dev->op_state = OP_RUNNING_POLL;
447
445 /*
446 * enable workq processing on this instance,
447 * default = 1000 msec
448 */
449 edac_device_workq_setup(edac_dev, 1000);
448 edac_device_workq_setup(edac_dev, edac_dev->poll_msec ?: DEFAULT_POLL_INTERVAL);
450 } else {
451 edac_dev->op_state = OP_RUNNING_INTERRUPT;
452 }
453
454 /* Report action taken */
455 edac_device_printk(edac_dev, KERN_INFO,
456 "Giving out device to module %s controller %s: DEV %s (%s)\n",
457 edac_dev->mod_name, edac_dev->ctl_name, edac_dev->dev_name,

--- 165 unchanged lines hidden ---
449 } else {
450 edac_dev->op_state = OP_RUNNING_INTERRUPT;
451 }
452
453 /* Report action taken */
454 edac_device_printk(edac_dev, KERN_INFO,
455 "Giving out device to module %s controller %s: DEV %s (%s)\n",
456 edac_dev->mod_name, edac_dev->ctl_name, edac_dev->dev_name,

--- 165 unchanged lines hidden ---