Re: [PATCH v3) posix-timers: make it configurable

From: Richard Cochran
Date: Fri Sep 16 2016 - 03:24:39 EST


On Thu, Sep 15, 2016 at 02:56:49PM -0700, Josh Triplett wrote:
> > I suspect there is more of a case for having net drivers _without_ ptp
> > support. This could be implemented with a ptp_clock_register() stub
> > returning NULL when ptp is not configured. I didn't look at most
> > drivers but at least broadcom/tg3.c seems to be fine with such an
> > approach.

(I wouldn't be suprised if some drivers fail to deal with NULL
gracefully, but those can always be fixed ;)

> > Alternatively, all those ethernet drivers currently selecting
> > PTP_1588_CLOCK could be banned from the kernel config when POSIX_TIMERS
> > is not selected.
> >
> > What do people prefer?
>
> If the stubs prove as simple as you suggest above (a static inline
> returning NULL), that sounds ideal. If this would require a non-trivial
> amount of stub code, then preventing those drivers from building without
> POSIX_TIMERS seems preferable to that.

I agree that stubs are the better solution. There are only five
functions that deal with 'struct ptp_clock' at all. The stubs could
be:

static inline
struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
struct device *parent) { return NULL; }

static inline
int ptp_clock_unregister(struct ptp_clock *ptp) { return -1; }

static inline
void ptp_clock_event(struct ptp_clock *ptp, struct ptp_clock_event *event) { }

static inline
int ptp_clock_index(struct ptp_clock *ptp) { return -1; }

static inline
int ptp_find_pin(struct ptp_clock *ptp,
enum ptp_pin_function func, unsigned int chan) { return -1; }

Thanks,
Richard