Skip to contentSkip to conversation

Staging: media: lirc: Use setup_timer

PATCH Superseded Vaishali Thakkar 3 participants 6 messages Feb 17, 2015 – Feb 18, 2015

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: media: lirc: Use setup_timer

This patch introduces the use of function setup_timer.

This is done using Coccinelle and semantic patch used is as follows:

@@
expression x,y,z;
@@

- init_timer (&x);
+ setup_timer (&x, y, z);
- x.function = y;
- x.data = z;

---
 drivers/staging/media/lirc/lirc_sir.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/media/lirc/lirc_sir.c +1 -3
index 39f4733..d1ada8c 100644
@@ -683,9 +683,7 @@ static int init_port(void)
 	}
 	pr_info("I/O port 0x%.4x, IRQ %d.\n", io, irq);
 
-	init_timer(&timerlist);
-	timerlist.function = sir_timeout;
-	timerlist.data = 0xabadcafe;
+	setup_timer(&timerlist, sir_timeout, 0xabadcafe);
 
 	return 0;
 }
Signature · 1 line
1.9.1
#1 lore raw
Quoted 9 lines · On Tuesday 17 February 2015 10:21:49 Vaishali Thakkar wrote:

This patch introduces the use of function setup_timer.

This is done using Coccinelle and semantic patch used is as follows:

@@
expression x,y,z;
@@

Quoted 6 lines

- init_timer (&x);
+ setup_timer (&x, y, z);
- x.function = y;
- x.data = z;

The patch looks great to me, but try to be more explicit about why this change is done in the description. Rather than just repeating the subject in the patch description here, explain why this is useful. In particular, is the only benefit to shorten the function by two lines and make it more readable, or is there also a functional change where the new code avoid a potential problem?

Arnd

#2 lore raw
Quoted 17 lines · Arnd Bergmann
Quoted 9 lines · On Tuesday 17 February 2015 10:21:49 Vaishali Thakkar wrote:

This patch introduces the use of function setup_timer.

This is done using Coccinelle and semantic patch used is as follows:

@@
expression x,y,z;
@@

Quoted 6 lines

- init_timer (&x);
+ setup_timer (&x, y, z);
- x.function = y;
- x.data = z;

Quoted 7 lines

The patch looks great to me, but try to be more explicit about why this change is done in the description. Rather than just repeating the subject in the patch description here, explain why this is useful. In particular, is the only benefit to shorten the function by two lines and make it more readable, or is there also a functional change where the new code avoid a potential problem?

Another question is that the data value is 0xabadcafe. This looks at least sort of like a nonsense value, and indeed the timer handler function doesn't use it. Would 0 be a better choice?

julia

#3 lore raw
Quoted 27 lines · On Tuesday 17 February 2015 10:02:53 Julia Lawall wrote:
Quoted 17 lines · Arnd Bergmann
Quoted 9 lines · On Tuesday 17 February 2015 10:21:49 Vaishali Thakkar wrote:

This patch introduces the use of function setup_timer.

This is done using Coccinelle and semantic patch used is as follows:

@@
expression x,y,z;
@@

Quoted 6 lines

- init_timer (&x);
+ setup_timer (&x, y, z);
- x.function = y;
- x.data = z;

Quoted 7 lines

The patch looks great to me, but try to be more explicit about why this change is done in the description. Rather than just repeating the subject in the patch description here, explain why this is useful. In particular, is the only benefit to shorten the function by two lines and make it more readable, or is there also a functional change where the new code avoid a potential problem?

Quoted 4 lines

Another question is that the data value is 0xabadcafe. This looks at least sort of like a nonsense value, and indeed the timer handler function doesn't use it. Would 0 be a better choice?

I guess ideally we'd use the data to pass a pointer to a per-device structure and remove the global variables such as 'io', 'irq', 'hardware_lock', etc. At this point it is of course no longer a trivial task to change.

Arnd

#4 lore raw
Quoted 33 lines · Arnd Bergmann
Quoted 27 lines · On Tuesday 17 February 2015 10:02:53 Julia Lawall wrote:
Quoted 17 lines · Arnd Bergmann
Quoted 9 lines · On Tuesday 17 February 2015 10:21:49 Vaishali Thakkar wrote:

This patch introduces the use of function setup_timer.

This is done using Coccinelle and semantic patch used is as follows:

@@
expression x,y,z;
@@

Quoted 6 lines

- init_timer (&x);
+ setup_timer (&x, y, z);
- x.function = y;
- x.data = z;

Quoted 7 lines

The patch looks great to me, but try to be more explicit about why this change is done in the description. Rather than just repeating the subject in the patch description here, explain why this is useful. In particular, is the only benefit to shorten the function by two lines and make it more readable, or is there also a functional change where the new code avoid a potential problem?

Quoted 4 lines

Another question is that the data value is 0xabadcafe. This looks at least sort of like a nonsense value, and indeed the timer handler function doesn't use it. Would 0 be a better choice?

Quoted 4 lines

I guess ideally we'd use the data to pass a pointer to a per-device structure and remove the global variables such as 'io', 'irq', 'hardware_lock', etc. At this point it is of course no longer a trivial task to change.

Oh. Then what can be done with this case?? I thought may be using NULL or 0 could be good choice.

Quoted 1 line

Arnd

Signature · 1 line
Vaishali
#5 lore raw
Quoted 34 lines · Vaishali Thakkar
Quoted 33 lines · Arnd Bergmann
Quoted 31 lines · On Tuesday 17 February 2015 10:02:53 Julia Lawall wrote:
Quoted 17 lines · Arnd Bergmann
Quoted 9 lines · On Tuesday 17 February 2015 10:21:49 Vaishali Thakkar wrote:

This patch introduces the use of function setup_timer.

This is done using Coccinelle and semantic patch used is as follows:

@@
expression x,y,z;
@@

Quoted 6 lines

- init_timer (&x);
+ setup_timer (&x, y, z);
- x.function = y;
- x.data = z;

Quoted 7 lines

The patch looks great to me, but try to be more explicit about why this change is done in the description. Rather than just repeating the subject in the patch description here, explain why this is useful. In particular, is the only benefit to shorten the function by two lines and make it more readable, or is there also a functional change where the new code avoid a potential problem?

Another question is that the data value is 0xabadcafe. This looks at least sort of like a nonsense value, and indeed the timer handler function doesn't use it. Would 0 be a better choice?

Quoted 7 lines
Quoted 4 lines

I guess ideally we'd use the data to pass a pointer to a per-device structure and remove the global variables such as 'io', 'irq', 'hardware_lock', etc. At this point it is of course no longer a trivial task to change.

Oh. Then what can be done with this case?? I thought may be using NULL or 0 could be good choice.

With respect to Arnd's suggestion, you can look and see if the variables he mentions are also available in some available data structure. Often a driver has a private structure that contains this sort of generally useful information. If that is the case, then you could pass the private structure to start_timer.

Otherwise, 0 would be a better choice than NULL, because actually the type is unsigned long, not pointer.

julia