]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
can: peak_usb: remove some 'struct timeval' users
authorArnd Bergmann <arnd@arndb.de>
Fri, 3 Nov 2017 16:31:36 +0000 (17:31 +0100)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Fri, 1 Dec 2017 08:14:22 +0000 (09:14 +0100)
We want to remove 'struct timeval' and related interfaces since this is
generally not safe for use beyond 2038.

For peak_usb, we can simplify the internal interface by using ktime_t
directly. This should not change any behavior, but it avoids a few
conversions.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/usb/peak_usb/pcan_usb.c
drivers/net/can/usb/peak_usb/pcan_usb_core.c
drivers/net/can/usb/peak_usb/pcan_usb_core.h
drivers/net/can/usb/peak_usb/pcan_usb_pro.c

index 25a9b79cc42d2c11583a3ee85e63f386ff589f24..f530a80f505115675e01cb60223e06016e5e4a9b 100644 (file)
@@ -408,7 +408,6 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n,
 {
        struct sk_buff *skb;
        struct can_frame *cf;
-       struct timeval tv;
        enum can_state new_state;
 
        /* ignore this error until 1st ts received */
@@ -525,8 +524,8 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n,
        if (status_len & PCAN_USB_STATUSLEN_TIMESTAMP) {
                struct skb_shared_hwtstamps *hwts = skb_hwtstamps(skb);
 
-               peak_usb_get_ts_tv(&mc->pdev->time_ref, mc->ts16, &tv);
-               hwts->hwtstamp = timeval_to_ktime(tv);
+               peak_usb_get_ts_time(&mc->pdev->time_ref, mc->ts16,
+                                    &hwts->hwtstamp);
        }
 
        mc->netdev->stats.rx_packets++;
@@ -610,7 +609,6 @@ static int pcan_usb_decode_data(struct pcan_usb_msg_context *mc, u8 status_len)
        u8 rec_len = status_len & PCAN_USB_STATUSLEN_DLC;
        struct sk_buff *skb;
        struct can_frame *cf;
-       struct timeval tv;
        struct skb_shared_hwtstamps *hwts;
 
        skb = alloc_can_skb(mc->netdev, &cf);
@@ -658,9 +656,8 @@ static int pcan_usb_decode_data(struct pcan_usb_msg_context *mc, u8 status_len)
        }
 
        /* convert timestamp into kernel time */
-       peak_usb_get_ts_tv(&mc->pdev->time_ref, mc->ts16, &tv);
        hwts = skb_hwtstamps(skb);
-       hwts->hwtstamp = timeval_to_ktime(tv);
+       peak_usb_get_ts_time(&mc->pdev->time_ref, mc->ts16, &hwts->hwtstamp);
 
        /* update statistics */
        mc->netdev->stats.rx_packets++;
index 1ca76e03e965ce0b1185c3220a86cb306d89e3e5..695a75a9b4bb645e0d4c86466ac04ca622a90c20 100644 (file)
@@ -148,11 +148,11 @@ void peak_usb_set_ts_now(struct peak_time_ref *time_ref, u32 ts_now)
 /*
  * compute timeval according to current ts and time_ref data
  */
-void peak_usb_get_ts_tv(struct peak_time_ref *time_ref, u32 ts,
-                       struct timeval *tv)
+void peak_usb_get_ts_time(struct peak_time_ref *time_ref, u32 ts, ktime_t *time)
 {
        /* protect from getting timeval before setting now */
        if (time_ref->tv_host.tv_sec > 0) {
+               struct timeval tv;
                u64 delta_us;
 
                delta_us = ts - time_ref->ts_dev_2;
@@ -164,10 +164,11 @@ void peak_usb_get_ts_tv(struct peak_time_ref *time_ref, u32 ts,
                delta_us *= time_ref->adapter->us_per_ts_scale;
                delta_us >>= time_ref->adapter->us_per_ts_shift;
 
-               *tv = time_ref->tv_host_0;
-               peak_usb_add_us(tv, (u32)delta_us);
+               tv = time_ref->tv_host_0;
+               peak_usb_add_us(&tv, (u32)delta_us);
+               *time = timeval_to_ktime(tv);
        } else {
-               *tv = ktime_to_timeval(ktime_get());
+               *time = ktime_get();
        }
 }
 
@@ -178,10 +179,8 @@ int peak_usb_netif_rx(struct sk_buff *skb,
                      struct peak_time_ref *time_ref, u32 ts_low, u32 ts_high)
 {
        struct skb_shared_hwtstamps *hwts = skb_hwtstamps(skb);
-       struct timeval tv;
 
-       peak_usb_get_ts_tv(time_ref, ts_low, &tv);
-       hwts->hwtstamp = timeval_to_ktime(tv);
+       peak_usb_get_ts_time(time_ref, ts_low, &hwts->hwtstamp);
 
        return netif_rx(skb);
 }
index c01316cac354b364a422b3312efa7756771223b8..b9a221ea7e5cb138d5ab9ee0c5d73907b68ad41b 100644 (file)
@@ -151,8 +151,7 @@ void peak_usb_init_time_ref(struct peak_time_ref *time_ref,
                            const struct peak_usb_adapter *adapter);
 void peak_usb_update_ts_now(struct peak_time_ref *time_ref, u32 ts_now);
 void peak_usb_set_ts_now(struct peak_time_ref *time_ref, u32 ts_now);
-void peak_usb_get_ts_tv(struct peak_time_ref *time_ref, u32 ts,
-                       struct timeval *tv);
+void peak_usb_get_ts_time(struct peak_time_ref *time_ref, u32 ts, ktime_t *tv);
 int peak_usb_netif_rx(struct sk_buff *skb,
                      struct peak_time_ref *time_ref, u32 ts_low, u32 ts_high);
 void peak_usb_async_complete(struct urb *urb);
index bbdd6058cd2f5af5465e8360456adeb88e668da4..0105fbfea273ad4c874006d72e5c0e94dbfb8b95 100644 (file)
@@ -531,7 +531,6 @@ static int pcan_usb_pro_handle_canmsg(struct pcan_usb_pro_interface *usb_if,
        struct net_device *netdev = dev->netdev;
        struct can_frame *can_frame;
        struct sk_buff *skb;
-       struct timeval tv;
        struct skb_shared_hwtstamps *hwts;
 
        skb = alloc_can_skb(netdev, &can_frame);
@@ -549,9 +548,9 @@ static int pcan_usb_pro_handle_canmsg(struct pcan_usb_pro_interface *usb_if,
        else
                memcpy(can_frame->data, rx->data, can_frame->can_dlc);
 
-       peak_usb_get_ts_tv(&usb_if->time_ref, le32_to_cpu(rx->ts32), &tv);
        hwts = skb_hwtstamps(skb);
-       hwts->hwtstamp = timeval_to_ktime(tv);
+       peak_usb_get_ts_time(&usb_if->time_ref, le32_to_cpu(rx->ts32),
+                            &hwts->hwtstamp);
 
        netdev->stats.rx_packets++;
        netdev->stats.rx_bytes += can_frame->can_dlc;
@@ -571,7 +570,6 @@ static int pcan_usb_pro_handle_error(struct pcan_usb_pro_interface *usb_if,
        enum can_state new_state = CAN_STATE_ERROR_ACTIVE;
        u8 err_mask = 0;
        struct sk_buff *skb;
-       struct timeval tv;
        struct skb_shared_hwtstamps *hwts;
 
        /* nothing should be sent while in BUS_OFF state */
@@ -667,9 +665,8 @@ static int pcan_usb_pro_handle_error(struct pcan_usb_pro_interface *usb_if,
 
        dev->can.state = new_state;
 
-       peak_usb_get_ts_tv(&usb_if->time_ref, le32_to_cpu(er->ts32), &tv);
        hwts = skb_hwtstamps(skb);
-       hwts->hwtstamp = timeval_to_ktime(tv);
+       peak_usb_get_ts_time(&usb_if->time_ref, le32_to_cpu(er->ts32), &hwts->hwtstamp);
        netdev->stats.rx_packets++;
        netdev->stats.rx_bytes += can_frame->can_dlc;
        netif_rx(skb);