]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
A default echo function has been provided so it is no longer an error when
authorJames Nuss <jamesnuss@nanometrics.ca>
Wed, 3 Aug 2011 00:53:04 +0000 (10:53 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 22 Aug 2011 03:27:18 +0000 (13:27 +1000)
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>
drivers/pps/clients/pps-ktimer.c
drivers/pps/clients/pps_parport.c
drivers/pps/kapi.c

index 82583b0ff82dac05efd9c1d495654ccd244419cc..436b4e4e71a149384c1246baa2a508e4dce21f72 100644 (file)
@@ -51,17 +51,6 @@ static void pps_ktimer_event(unsigned long ptr)
        mod_timer(&ktimer, jiffies + HZ);
 }
 
-/*
- * The echo function
- */
-
-static void pps_ktimer_echo(struct pps_device *pps, int event, void *data)
-{
-       dev_info(pps->dev, "echo %s %s\n",
-               event & PPS_CAPTUREASSERT ? "assert" : "",
-               event & PPS_CAPTURECLEAR ? "clear" : "");
-}
-
 /*
  * The PPS info struct
  */
@@ -72,7 +61,6 @@ static struct pps_source_info pps_ktimer_info = {
        .mode           = PPS_CAPTUREASSERT | PPS_OFFSETASSERT |
                          PPS_ECHOASSERT |
                          PPS_CANWAIT | PPS_TSFMT_TSPEC,
-       .echo           = pps_ktimer_echo,
        .owner          = THIS_MODULE,
 };
 
index c571d6dd8f61f626bdaeb6405de5a3f8aa7a30a6..e1b4705ae3ec83ec1beddfda1dc98d4259bd2a6d 100644 (file)
@@ -133,14 +133,6 @@ out_both:
        return;
 }
 
-/* the PPS echo function */
-static void pps_echo(struct pps_device *pps, int event, void *data)
-{
-       dev_info(pps->dev, "echo %s %s\n",
-               event & PPS_CAPTUREASSERT ? "assert" : "",
-               event & PPS_CAPTURECLEAR ? "clear" : "");
-}
-
 static void parport_attach(struct parport *port)
 {
        struct pps_client_pp *device;
@@ -151,7 +143,6 @@ static void parport_attach(struct parport *port)
                                  PPS_OFFSETASSERT | PPS_OFFSETCLEAR | \
                                  PPS_ECHOASSERT | PPS_ECHOCLEAR | \
                                  PPS_CANWAIT | PPS_TSFMT_TSPEC,
-               .echo           = pps_echo,
                .owner          = THIS_MODULE,
                .dev            = NULL
        };
index a4e8eb9fece6a53c7e2ade169df43dcd9a8696a0..f197e8ea185c4099abc1289cd1b6cf74947f3bed 100644 (file)
@@ -52,6 +52,14 @@ static void pps_add_offset(struct pps_ktime *ts, struct pps_ktime *offset)
        ts->sec += offset->sec;
 }
 
+static void pps_echo_client_default(struct pps_device *pps, int event,
+               void *data)
+{
+       dev_info(pps->dev, "echo %s %s\n",
+               event & PPS_CAPTUREASSERT ? "assert" : "",
+               event & PPS_CAPTURECLEAR ? "clear" : "");
+}
+
 /*
  * Exported functions
  */
@@ -80,13 +88,6 @@ struct pps_device *pps_register_source(struct pps_source_info *info,
                err = -EINVAL;
                goto pps_register_source_exit;
        }
-       if ((info->mode & (PPS_ECHOASSERT | PPS_ECHOCLEAR)) != 0 &&
-                       info->echo == NULL) {
-               pr_err("%s: echo function is not defined\n",
-                                       info->name);
-               err = -EINVAL;
-               goto pps_register_source_exit;
-       }
        if ((info->mode & (PPS_TSFMT_TSPEC | PPS_TSFMT_NTPFP)) == 0) {
                pr_err("%s: unspecified time format\n",
                                        info->name);
@@ -108,6 +109,11 @@ struct pps_device *pps_register_source(struct pps_source_info *info,
        pps->params.mode = default_params;
        pps->info = *info;
 
+       /* check for default echo function */
+       if ((pps->info.mode & (PPS_ECHOASSERT | PPS_ECHOCLEAR)) &&
+                       pps->info.echo == NULL)
+               pps->info.echo = pps_echo_client_default;
+
        init_waitqueue_head(&pps->queue);
        spin_lock_init(&pps->lock);