On Thu, Mar 19, 2015 at 01:45:07PM +0800, Baolin Wang wrote:

> diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
> index 296b0ec..46425ad 100644
> --- a/drivers/ptp/ptp_clock.c
> +++ b/drivers/ptp/ptp_clock.c
> @@ -106,14 +106,30 @@ static int ptp_clock_getres(struct posix_clock *pc, 
> struct timespec *tp)
>  
>  static int ptp_clock_settime(struct posix_clock *pc, const struct timespec 
> *tp)
>  {
> +     ktime_t kt;
>       struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock);
> -     return ptp->info->settime(ptp->info, tp);
> +
> +     if (ptp->info->setktime) {
> +             kt = timespec_to_ktime(*tp);
> +             return ptp->info->setktime(ptp->info, kt);
> +     } else {
> +             return ptp->info->settime(ptp->info, tp);
> +     }

This conditional is just the kind of thing I *don't* want to see.  In
Documentation/ptp/ptp.txt we read:

   ** Writing clock drivers

   Clock drivers include include/linux/ptp_clock_kernel.h and register
   themselves by presenting a 'struct ptp_clock_info' to the
   registration method. Clock drivers must implement all of the
   functions in the interface. If a clock does not offer a particular
   ancillary feature, then the driver should just return -EOPNOTSUPP
   from those functions.

Please don't litter the code with tests for NULL methods everywhere.

Thanks,
Richard
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to