diff options
author | James Nuss <jamesnuss@nanometrics.ca> | 2011-11-02 16:39:34 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-11-02 19:07:02 -0400 |
commit | 437c53418616973071fd2d7c87497780944d8fdb (patch) | |
tree | e5b7e380194bf17a80bb1a828da3edd373bb2e95 /drivers/pps/kapi.c | |
parent | 842fa69f3e0c9a178b294e7af7c07f4c9d9e7af2 (diff) |
pps: default echo function
A default echo function has been provided so it is no longer an error when
you specify PPS_ECHOASSERT or PPS_ECHOCLEAR without an explicit echo
function. This allows some code re-use and also makes it easier to write
client drivers since the default echo function does not normally need to
change.
Signed-off-by: James Nuss <jamesnuss@nanometrics.ca>
Reviewed-by: Ben Gardiner <bengardiner@nanometrics.ca>
Acked-by: Rodolfo Giometti <giometti@linux.it>
Cc: Ricardo Martins <rasm@fe.up.pt>
Cc: Alexander Gordeev <lasaine@lvk.cs.msu.su>
Cc: Igor Plyatov <plyatov@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/pps/kapi.c')
-rw-r--r-- | drivers/pps/kapi.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/drivers/pps/kapi.c b/drivers/pps/kapi.c index a4e8eb9fece6..f197e8ea185c 100644 --- a/drivers/pps/kapi.c +++ b/drivers/pps/kapi.c | |||
@@ -52,6 +52,14 @@ static void pps_add_offset(struct pps_ktime *ts, struct pps_ktime *offset) | |||
52 | ts->sec += offset->sec; | 52 | ts->sec += offset->sec; |
53 | } | 53 | } |
54 | 54 | ||
55 | static void pps_echo_client_default(struct pps_device *pps, int event, | ||
56 | void *data) | ||
57 | { | ||
58 | dev_info(pps->dev, "echo %s %s\n", | ||
59 | event & PPS_CAPTUREASSERT ? "assert" : "", | ||
60 | event & PPS_CAPTURECLEAR ? "clear" : ""); | ||
61 | } | ||
62 | |||
55 | /* | 63 | /* |
56 | * Exported functions | 64 | * Exported functions |
57 | */ | 65 | */ |
@@ -80,13 +88,6 @@ struct pps_device *pps_register_source(struct pps_source_info *info, | |||
80 | err = -EINVAL; | 88 | err = -EINVAL; |
81 | goto pps_register_source_exit; | 89 | goto pps_register_source_exit; |
82 | } | 90 | } |
83 | if ((info->mode & (PPS_ECHOASSERT | PPS_ECHOCLEAR)) != 0 && | ||
84 | info->echo == NULL) { | ||
85 | pr_err("%s: echo function is not defined\n", | ||
86 | info->name); | ||
87 | err = -EINVAL; | ||
88 | goto pps_register_source_exit; | ||
89 | } | ||
90 | if ((info->mode & (PPS_TSFMT_TSPEC | PPS_TSFMT_NTPFP)) == 0) { | 91 | if ((info->mode & (PPS_TSFMT_TSPEC | PPS_TSFMT_NTPFP)) == 0) { |
91 | pr_err("%s: unspecified time format\n", | 92 | pr_err("%s: unspecified time format\n", |
92 | info->name); | 93 | info->name); |
@@ -108,6 +109,11 @@ struct pps_device *pps_register_source(struct pps_source_info *info, | |||
108 | pps->params.mode = default_params; | 109 | pps->params.mode = default_params; |
109 | pps->info = *info; | 110 | pps->info = *info; |
110 | 111 | ||
112 | /* check for default echo function */ | ||
113 | if ((pps->info.mode & (PPS_ECHOASSERT | PPS_ECHOCLEAR)) && | ||
114 | pps->info.echo == NULL) | ||
115 | pps->info.echo = pps_echo_client_default; | ||
116 | |||
111 | init_waitqueue_head(&pps->queue); | 117 | init_waitqueue_head(&pps->queue); |
112 | spin_lock_init(&pps->lock); | 118 | spin_lock_init(&pps->lock); |
113 | 119 | ||