Eliminate all checkpatch.pl warnings and checks from these files. Signed-off-by: Benjamin Romer <benjamin.romer@xxxxxxxxxx> --- drivers/staging/unisys/include/periodic_work.h | 25 ++-- drivers/staging/unisys/visorutil/periodic_work.c | 155 +++++++++++------------ 2 files changed, 83 insertions(+), 97 deletions(-) diff --git a/drivers/staging/unisys/include/periodic_work.h b/drivers/staging/unisys/include/periodic_work.h index 418ba63..2f8e984 100644 --- a/drivers/staging/unisys/include/periodic_work.h +++ b/drivers/staging/unisys/include/periodic_work.h @@ -20,21 +20,20 @@ #include "timskmod.h" - - -/* PERIODIC_WORK an opaque structure to users. +/* periodic_work an opaque structure to users. * Fields are declared only in the implementation .c files. */ -typedef struct PERIODIC_WORK_Tag PERIODIC_WORK; +struct periodic_work; -PERIODIC_WORK *visor_periodic_work_create(ulong jiffy_interval, - struct workqueue_struct *workqueue, - void (*workfunc)(void *), - void *workfuncarg, - const char *devnam); -void visor_periodic_work_destroy(PERIODIC_WORK *periodic_work); -BOOL visor_periodic_work_nextperiod(PERIODIC_WORK *periodic_work); -BOOL visor_periodic_work_start(PERIODIC_WORK *periodic_work); -BOOL visor_periodic_work_stop(PERIODIC_WORK *periodic_work); +struct periodic_work * + visor_periodic_work_create(ulong jiffy_interval, + struct workqueue_struct *workqueue, + void (*workfunc)(void *), + void *workfuncarg, + const char *devnam); +void visor_periodic_work_destroy(struct periodic_work *periodic_work); +BOOL visor_periodic_work_nextperiod(struct periodic_work *periodic_work); +BOOL visor_periodic_work_start(struct periodic_work *periodic_work); +BOOL visor_periodic_work_stop(struct periodic_work *periodic_work); #endif diff --git a/drivers/staging/unisys/visorutil/periodic_work.c b/drivers/staging/unisys/visorutil/periodic_work.c index 38a60ce..22aedd0 100644 --- a/drivers/staging/unisys/visorutil/periodic_work.c +++ b/drivers/staging/unisys/visorutil/periodic_work.c @@ -25,9 +25,7 @@ #define MYDRVNAME "periodic_work" - - -struct PERIODIC_WORK_Tag { +struct periodic_work { rwlock_t lock; struct delayed_work work; void (*workfunc)(void *); @@ -39,123 +37,111 @@ struct PERIODIC_WORK_Tag { const char *devnam; }; - - static void periodic_work_func(struct work_struct *work) { - PERIODIC_WORK *periodic_work = - container_of(work, struct PERIODIC_WORK_Tag, work.work); - (*periodic_work->workfunc)(periodic_work->workfuncarg); -} - + struct periodic_work *pw = + container_of(work, struct periodic_work, work.work); + (*pw->workfunc)(pw->workfuncarg); +} -PERIODIC_WORK *visor_periodic_work_create(ulong jiffy_interval, - struct workqueue_struct *workqueue, - void (*workfunc)(void *), - void *workfuncarg, - const char *devnam) +struct periodic_work * + visor_periodic_work_create(ulong jiffy_interval, + struct workqueue_struct *workqueue, + void (*workfunc)(void *), + void *workfuncarg, + const char *devnam) { - PERIODIC_WORK *periodic_work = kzalloc(sizeof(PERIODIC_WORK), - GFP_KERNEL | __GFP_NORETRY); - if (periodic_work == NULL) { + struct periodic_work *pw = kzalloc(sizeof(struct periodic_work), + GFP_KERNEL | __GFP_NORETRY); + + if (pw == NULL) { ERRDRV("periodic_work allocation failed "); return NULL; } - rwlock_init(&periodic_work->lock); - periodic_work->jiffy_interval = jiffy_interval; - periodic_work->workqueue = workqueue; - periodic_work->workfunc = workfunc; - periodic_work->workfuncarg = workfuncarg; - periodic_work->devnam = devnam; - return periodic_work; + rwlock_init(&pw->lock); + pw->jiffy_interval = jiffy_interval; + pw->workqueue = workqueue; + pw->workfunc = workfunc; + pw->workfuncarg = workfuncarg; + pw->devnam = devnam; + return pw; } EXPORT_SYMBOL_GPL(visor_periodic_work_create); - - -void visor_periodic_work_destroy(PERIODIC_WORK *periodic_work) +void visor_periodic_work_destroy(struct periodic_work *pw) { - if (periodic_work == NULL) + if (pw == NULL) return; - kfree(periodic_work); + kfree(pw); } EXPORT_SYMBOL_GPL(visor_periodic_work_destroy); - - /** Call this from your periodic work worker function to schedule the next * call. * If this function returns FALSE, there was a failure and the * periodic work is no longer scheduled */ -BOOL visor_periodic_work_nextperiod(PERIODIC_WORK *periodic_work) +BOOL visor_periodic_work_nextperiod(struct periodic_work *pw) { BOOL rc = FALSE; - write_lock(&periodic_work->lock); - if (periodic_work->want_to_stop) { - periodic_work->is_scheduled = FALSE; - periodic_work->want_to_stop = FALSE; + write_lock(&pw->lock); + if (pw->want_to_stop) { + pw->is_scheduled = FALSE; + pw->want_to_stop = FALSE; rc = TRUE; /* yes, TRUE; see visor_periodic_work_stop() */ - goto Away; - } else if (queue_delayed_work(periodic_work->workqueue, - &periodic_work->work, - periodic_work->jiffy_interval) < 0) { - ERRDEV(periodic_work->devnam, "queue_delayed_work failed!"); - periodic_work->is_scheduled = FALSE; + goto away; + } else if (queue_delayed_work(pw->workqueue, &pw->work, + pw->jiffy_interval) < 0) { + ERRDEV(pw->devnam, "queue_delayed_work failed!"); + pw->is_scheduled = FALSE; rc = FALSE; - goto Away; + goto away; } rc = TRUE; -Away: - write_unlock(&periodic_work->lock); +away: + write_unlock(&pw->lock); return rc; } EXPORT_SYMBOL_GPL(visor_periodic_work_nextperiod); - - /** This function returns TRUE iff new periodic work was actually started. * If this function returns FALSE, then no work was started * (either because it was already started, or because of a failure). */ -BOOL visor_periodic_work_start(PERIODIC_WORK *periodic_work) +BOOL visor_periodic_work_start(struct periodic_work *pw) { BOOL rc = FALSE; - write_lock(&periodic_work->lock); - if (periodic_work->is_scheduled) { + write_lock(&pw->lock); + if (pw->is_scheduled) { rc = FALSE; - goto Away; + goto away; } - if (periodic_work->want_to_stop) { - ERRDEV(periodic_work->devnam, + if (pw->want_to_stop) { + ERRDEV(pw->devnam, "dev_start_periodic_work failed!"); rc = FALSE; - goto Away; + goto away; } - INIT_DELAYED_WORK(&periodic_work->work, &periodic_work_func); - if (queue_delayed_work(periodic_work->workqueue, - &periodic_work->work, - periodic_work->jiffy_interval) < 0) { - ERRDEV(periodic_work->devnam, + INIT_DELAYED_WORK(&pw->work, &periodic_work_func); + if (queue_delayed_work(pw->workqueue, + &pw->work, + pw->jiffy_interval) < 0) { + ERRDEV(pw->devnam, "%s queue_delayed_work failed!", __func__); rc = FALSE; - goto Away; + goto away; } - periodic_work->is_scheduled = TRUE; + pw->is_scheduled = TRUE; rc = TRUE; -Away: - write_unlock(&periodic_work->lock); +away: + write_unlock(&pw->lock); return rc; - } EXPORT_SYMBOL_GPL(visor_periodic_work_start); - - - /** This function returns TRUE iff your call actually stopped the periodic * work. * @@ -190,21 +176,21 @@ EXPORT_SYMBOL_GPL(visor_periodic_work_start); * this deadlock, you will get hung up in an infinite loop saying * "waiting for delayed work...". */ -BOOL visor_periodic_work_stop(PERIODIC_WORK *periodic_work) +BOOL visor_periodic_work_stop(struct periodic_work *pw) { BOOL stopped_something = FALSE; - write_lock(&periodic_work->lock); - stopped_something = periodic_work->is_scheduled && - (!periodic_work->want_to_stop); - while (periodic_work->is_scheduled) { - periodic_work->want_to_stop = TRUE; - if (cancel_delayed_work(&periodic_work->work)) { + write_lock(&pw->lock); + stopped_something = pw->is_scheduled && + (!pw->want_to_stop); + while (pw->is_scheduled) { + pw->want_to_stop = TRUE; + if (cancel_delayed_work(&pw->work)) { /* We get here if the delayed work was pending as * delayed work, but was NOT run. */ - ASSERT(periodic_work->is_scheduled); - periodic_work->is_scheduled = FALSE; + ASSERT(pw->is_scheduled); + pw->is_scheduled = FALSE; } else { /* If we get here, either the delayed work: * - was run, OR, @@ -216,9 +202,9 @@ BOOL visor_periodic_work_stop(PERIODIC_WORK *periodic_work) * explains the loop... */ } - if (periodic_work->is_scheduled) { - write_unlock(&periodic_work->lock); - WARNDEV(periodic_work->devnam, + if (pw->is_scheduled) { + write_unlock(&pw->lock); + WARNDEV(pw->devnam, "waiting for delayed work..."); /* We rely on the delayed work function running here, * and eventually calling @@ -227,11 +213,12 @@ BOOL visor_periodic_work_stop(PERIODIC_WORK *periodic_work) * subsequently clear is_scheduled. */ SLEEPJIFFIES(10); - write_lock(&periodic_work->lock); - } else - periodic_work->want_to_stop = FALSE; + write_lock(&pw->lock); + } else { + pw->want_to_stop = FALSE; + } } - write_unlock(&periodic_work->lock); + write_unlock(&pw->lock); return stopped_something; } EXPORT_SYMBOL_GPL(visor_periodic_work_stop); -- 1.9.1 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel