Ethernet Driver Compile Error (C)

So, I'm not sure how much help I'll be able to get here, but, since I can't find anything on the error, I figure I'll try here.

Itus Shield (Octeon3, mips64), not officially supported, compiled from master (4.19.123)

rivers/net/ethernet/cavium/octeon/octeon3-core.c: In function 'octeon3_eth_probe':
drivers/net/ethernet/cavium/octeon/octeon3-core.c:1934:27: error: assignment to 'int (*)(struct ptp_clock_info *, struct timespec64 *)' from incompatible pointer type 'int (*)(struct ptp_clock_info *, struct timespec *)' [-Werror=incompatible-pointer-types]
  priv->ptp_info.gettime64 = octeon3_gettime;
                           ^
drivers/net/ethernet/cavium/octeon/octeon3-core.c:1935:27: error: assignment to 'int (*)(struct ptp_clock_info *, const struct timespec64 *)' from incompatible pointer type 'int (*)(struct ptp_clock_info *, const struct timespec *)' [-Werror=incompatible-pointer-types]
  priv->ptp_info.settime64 = octeon3_settime;
                           ^
cc1: some warnings being treated as errors
make[10]: *** [scripts/Makefile.build:304: drivers/net/ethernet/cavium/octeon/octeon3-core.o] Error 1

From drivers/net/ethernet/cavium/octeon/octeon3-core.c:

static int octeon3_gettime(struct ptp_clock_info *ptp, struct timespec *ts)
{
        struct octeon3_ethernet *priv;
        unsigned long flags;
        u32 remainder;
        u64 ns;

        priv = container_of(ptp, struct octeon3_ethernet, ptp_info);

        spin_lock_irqsave(&priv->ptp_lock, flags);
        ns = timecounter_read(&priv->tc);
        spin_unlock_irqrestore(&priv->ptp_lock, flags);
        ts->tv_sec = div_u64_rem(ns, 1000000000ULL, &remainder);
        ts->tv_nsec = remainder;

        return 0;
}

static int octeon3_settime(struct ptp_clock_info *ptp,
                           const struct timespec *ts)
{
        struct octeon3_ethernet *priv;
        unsigned long flags;
        u64 ns;

        priv = container_of(ptp, struct octeon3_ethernet, ptp_info);
        ns = timespec_to_ns(ts);

        spin_lock_irqsave(&priv->ptp_lock, flags);
        timecounter_init(&priv->tc, &priv->cc, ns);
        spin_unlock_irqrestore(&priv->ptp_lock, flags);

        return 0;
}

Also in drivers/net/ethernet/cavium/octeon3-core.c:

        priv->ptp_info.gettime64 = octeon3_gettime;
        priv->ptp_info.settime64 = octeon3_settime;

I'm not proficient in C/C++, but I can understand things :smiley: I know the error is a pointer issue, but beyond that.....

Thanks for any help anyone can provide!

I guess you need to change from "struct timespec *ts" to "struct timespec64 *ts" in the function signatures, and from timespec_to_ns to timespec64_to_ns.

1 Like

I appreciate the help! The Octeon3 isn't widely supported, so not many places I can go to find the folks who know what they are doing :wink:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.