diff options
author | Alexander Gordeev <lasaine@lvk.cs.msu.su> | 2011-01-12 20:00:51 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-13 11:03:19 -0500 |
commit | 5e196d34a776420278e4117b4742cd9d3f2350ed (patch) | |
tree | 86187af6a600876506261758a00c7c42e6037283 /drivers/pps/clients/pps-ktimer.c | |
parent | 6f4229b51106cbc859e9d8209b22c8a2ec749e64 (diff) |
pps: access pps device by direct pointer
Using device index as a pointer needs some unnecessary work to be done
every time the pointer is needed (in irq handler for example). Using a
direct pointer is much more easy (and safe as well).
Signed-off-by: Alexander Gordeev <lasaine@lvk.cs.msu.su>
Acked-by: Rodolfo Giometti <giometti@linux.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/pps/clients/pps-ktimer.c')
-rw-r--r-- | drivers/pps/clients/pps-ktimer.c | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/drivers/pps/clients/pps-ktimer.c b/drivers/pps/clients/pps-ktimer.c index e1bdd8bc8c9c..966ead188ee2 100644 --- a/drivers/pps/clients/pps-ktimer.c +++ b/drivers/pps/clients/pps-ktimer.c | |||
@@ -31,7 +31,7 @@ | |||
31 | * Global variables | 31 | * Global variables |
32 | */ | 32 | */ |
33 | 33 | ||
34 | static int source; | 34 | static struct pps_device *pps; |
35 | static struct timer_list ktimer; | 35 | static struct timer_list ktimer; |
36 | 36 | ||
37 | /* | 37 | /* |
@@ -47,7 +47,7 @@ static void pps_ktimer_event(unsigned long ptr) | |||
47 | 47 | ||
48 | pr_info("PPS event at %lu\n", jiffies); | 48 | pr_info("PPS event at %lu\n", jiffies); |
49 | 49 | ||
50 | pps_event(source, &ts, PPS_CAPTUREASSERT, NULL); | 50 | pps_event(pps, &ts, PPS_CAPTUREASSERT, NULL); |
51 | 51 | ||
52 | mod_timer(&ktimer, jiffies + HZ); | 52 | mod_timer(&ktimer, jiffies + HZ); |
53 | } | 53 | } |
@@ -56,12 +56,11 @@ static void pps_ktimer_event(unsigned long ptr) | |||
56 | * The echo function | 56 | * The echo function |
57 | */ | 57 | */ |
58 | 58 | ||
59 | static void pps_ktimer_echo(int source, int event, void *data) | 59 | static void pps_ktimer_echo(struct pps_device *pps, int event, void *data) |
60 | { | 60 | { |
61 | pr_info("echo %s %s for source %d\n", | 61 | dev_info(pps->dev, "echo %s %s\n", |
62 | event & PPS_CAPTUREASSERT ? "assert" : "", | 62 | event & PPS_CAPTUREASSERT ? "assert" : "", |
63 | event & PPS_CAPTURECLEAR ? "clear" : "", | 63 | event & PPS_CAPTURECLEAR ? "clear" : ""); |
64 | source); | ||
65 | } | 64 | } |
66 | 65 | ||
67 | /* | 66 | /* |
@@ -84,30 +83,27 @@ static struct pps_source_info pps_ktimer_info = { | |||
84 | 83 | ||
85 | static void __exit pps_ktimer_exit(void) | 84 | static void __exit pps_ktimer_exit(void) |
86 | { | 85 | { |
87 | del_timer_sync(&ktimer); | 86 | dev_info(pps->dev, "ktimer PPS source unregistered\n"); |
88 | pps_unregister_source(source); | ||
89 | 87 | ||
90 | pr_info("ktimer PPS source unregistered\n"); | 88 | del_timer_sync(&ktimer); |
89 | pps_unregister_source(pps); | ||
91 | } | 90 | } |
92 | 91 | ||
93 | static int __init pps_ktimer_init(void) | 92 | static int __init pps_ktimer_init(void) |
94 | { | 93 | { |
95 | int ret; | 94 | pps = pps_register_source(&pps_ktimer_info, |
96 | |||
97 | ret = pps_register_source(&pps_ktimer_info, | ||
98 | PPS_CAPTUREASSERT | PPS_OFFSETASSERT); | 95 | PPS_CAPTUREASSERT | PPS_OFFSETASSERT); |
99 | if (ret < 0) { | 96 | if (pps == NULL) { |
100 | printk(KERN_ERR "cannot register ktimer source\n"); | 97 | printk(KERN_ERR "cannot register ktimer source\n"); |
101 | return ret; | 98 | return -ENOMEM; |
102 | } | 99 | } |
103 | source = ret; | ||
104 | 100 | ||
105 | setup_timer(&ktimer, pps_ktimer_event, 0); | 101 | setup_timer(&ktimer, pps_ktimer_event, 0); |
106 | mod_timer(&ktimer, jiffies + HZ); | 102 | mod_timer(&ktimer, jiffies + HZ); |
107 | 103 | ||
108 | pr_info("ktimer PPS source registered at %d\n", source); | 104 | dev_info(pps->dev, "ktimer PPS source registered\n"); |
109 | 105 | ||
110 | return 0; | 106 | return 0; |
111 | } | 107 | } |
112 | 108 | ||
113 | module_init(pps_ktimer_init); | 109 | module_init(pps_ktimer_init); |