Skip to contentSkip to conversation

staging: vc04_services: Convert timers to use timer_setup()

PATCH In review Kees Cook 2 participants 2 messages Oct 24, 2017 – Oct 28, 2017

Subsystems (2)
lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 staging: vc04_services: Convert timers to use timer_setup()

In preparation for unconditionally passing the struct timer_list pointer to all timer callbacks, switch to using the new timer_setup() and from_timer() to pass the timer pointer explicitly.

Cc Greg Kroah-Hartman <[email protected]>
Cc Eric Anholt <[email protected]>
Cc Stefan Wahren <[email protected]>
Cc Michael Zoran <[email protected]>
Cc Keerthi Reddy <[email protected]>
Cc linux-rpi-kernel at lists.infradead.org
Cc linux-arm-kernel at lists.infradead.org
Cc devel at driverdev.osuosl.org
---
 .../staging/vc04_services/interface/vchiq_arm/vchiq_arm.c   | 13 +++++++------
 .../staging/vc04_services/interface/vchiq_arm/vchiq_arm.h   |  1 +
 2 files changed, 8 insertions(+), 6 deletions(-)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +7 -6
index 6fcc62603580..6d16cc036c0c 100644
@@ -109,7 +109,7 @@ static const char *const resume_state_names[] = {
  * requested */
 #define FORCE_SUSPEND_TIMEOUT_MS 200
 
-static void suspend_timer_callback(unsigned long context);
+static void suspend_timer_callback(struct timer_list *t);
 
 typedef struct user_service_struct {
 	VCHIQ_SERVICE_T *service;
@@ -2184,8 +2184,9 @@ vchiq_arm_init_state(VCHIQ_STATE_T *state, VCHIQ_ARM_STATE_T *arm_state)
 
 		arm_state->suspend_timer_timeout = SUSPEND_TIMER_TIMEOUT_MS;
 		arm_state->suspend_timer_running = 0;
-		setup_timer(&arm_state->suspend_timer, suspend_timer_callback,
-			    (unsigned long)(state));
+		arm_state->state = state;
+		timer_setup(&arm_state->suspend_timer, suspend_timer_callback,
+			    0);
 
 		arm_state->first_connect = 0;
 
@@ -3017,10 +3018,10 @@ vchiq_instance_set_trace(VCHIQ_INSTANCE_T instance, int trace)
 	instance->trace = (trace != 0);
 }
 
-static void suspend_timer_callback(unsigned long context)
+static void suspend_timer_callback(struct timer_list *t)
 {
-	VCHIQ_STATE_T *state = (VCHIQ_STATE_T *)context;
-	VCHIQ_ARM_STATE_T *arm_state = vchiq_platform_get_arm_state(state);
+	VCHIQ_ARM_STATE_T *arm_state = from_timer(arm_state, t, suspend_timer);
+	VCHIQ_STATE_T *state = arm_state->state;
 
 	if (!arm_state)
 		goto out;
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h +1 -0
index a4cc0db899be..40bb0c63b1a9 100644
@@ -83,6 +83,7 @@ typedef struct vchiq_arm_state_struct {
 
 	unsigned int wake_address;
 
+	VCHIQ_STATE_T *state;
 	struct timer_list suspend_timer;
 	int suspend_timer_timeout;
 	int suspend_timer_running;
Signature · 6 lines
2.7.4


-- 
Kees Cook
Pixel Security
Tested-by on v1 1/1
#1 lore raw
Quoted 8 lines

Kees Cook <[email protected]> hat am 24. Oktober 2017 um 10:26 geschrieben:

In preparation for unconditionally passing the struct timer_list pointer to all timer callbacks, switch to using the new timer_setup() and from_timer() to pass the timer pointer explicitly.

Quoted 9 lines
Cc Greg Kroah-Hartman <[email protected]>
Cc Eric Anholt <[email protected]>
Cc Stefan Wahren <[email protected]>
Cc Michael Zoran <[email protected]>
Cc Keerthi Reddy <[email protected]>
Cc linux-rpi-kernel at lists.infradead.org
Cc linux-arm-kernel at lists.infradead.org
Cc devel at driverdev.osuosl.org