Commit d5888a1e authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Marc Kleine-Budde

can: peak_usb: remove some 'struct timeval' users

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: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent 201c78e0
...@@ -408,7 +408,6 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n, ...@@ -408,7 +408,6 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n,
{ {
struct sk_buff *skb; struct sk_buff *skb;
struct can_frame *cf; struct can_frame *cf;
struct timeval tv;
enum can_state new_state; enum can_state new_state;
/* ignore this error until 1st ts received */ /* 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, ...@@ -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) { if (status_len & PCAN_USB_STATUSLEN_TIMESTAMP) {
struct skb_shared_hwtstamps *hwts = skb_hwtstamps(skb); struct skb_shared_hwtstamps *hwts = skb_hwtstamps(skb);
peak_usb_get_ts_tv(&mc->pdev->time_ref, mc->ts16, &tv); peak_usb_get_ts_time(&mc->pdev->time_ref, mc->ts16,
hwts->hwtstamp = timeval_to_ktime(tv); &hwts->hwtstamp);
} }
mc->netdev->stats.rx_packets++; mc->netdev->stats.rx_packets++;
...@@ -610,7 +609,6 @@ static int pcan_usb_decode_data(struct pcan_usb_msg_context *mc, u8 status_len) ...@@ -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; u8 rec_len = status_len & PCAN_USB_STATUSLEN_DLC;
struct sk_buff *skb; struct sk_buff *skb;
struct can_frame *cf; struct can_frame *cf;
struct timeval tv;
struct skb_shared_hwtstamps *hwts; struct skb_shared_hwtstamps *hwts;
skb = alloc_can_skb(mc->netdev, &cf); 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) ...@@ -658,9 +656,8 @@ static int pcan_usb_decode_data(struct pcan_usb_msg_context *mc, u8 status_len)
} }
/* convert timestamp into kernel time */ /* convert timestamp into kernel time */
peak_usb_get_ts_tv(&mc->pdev->time_ref, mc->ts16, &tv);
hwts = skb_hwtstamps(skb); 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 */ /* update statistics */
mc->netdev->stats.rx_packets++; mc->netdev->stats.rx_packets++;
......
...@@ -148,11 +148,11 @@ void peak_usb_set_ts_now(struct peak_time_ref *time_ref, u32 ts_now) ...@@ -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 * compute timeval according to current ts and time_ref data
*/ */
void peak_usb_get_ts_tv(struct peak_time_ref *time_ref, u32 ts, void peak_usb_get_ts_time(struct peak_time_ref *time_ref, u32 ts, ktime_t *time)
struct timeval *tv)
{ {
/* protect from getting timeval before setting now */ /* protect from getting timeval before setting now */
if (time_ref->tv_host.tv_sec > 0) { if (time_ref->tv_host.tv_sec > 0) {
struct timeval tv;
u64 delta_us; u64 delta_us;
delta_us = ts - time_ref->ts_dev_2; 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, ...@@ -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_scale;
delta_us >>= time_ref->adapter->us_per_ts_shift; delta_us >>= time_ref->adapter->us_per_ts_shift;
*tv = time_ref->tv_host_0; tv = time_ref->tv_host_0;
peak_usb_add_us(tv, (u32)delta_us); peak_usb_add_us(&tv, (u32)delta_us);
*time = timeval_to_ktime(tv);
} else { } else {
*tv = ktime_to_timeval(ktime_get()); *time = ktime_get();
} }
} }
...@@ -178,10 +179,8 @@ int peak_usb_netif_rx(struct sk_buff *skb, ...@@ -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 peak_time_ref *time_ref, u32 ts_low, u32 ts_high)
{ {
struct skb_shared_hwtstamps *hwts = skb_hwtstamps(skb); struct skb_shared_hwtstamps *hwts = skb_hwtstamps(skb);
struct timeval tv;
peak_usb_get_ts_tv(time_ref, ts_low, &tv); peak_usb_get_ts_time(time_ref, ts_low, &hwts->hwtstamp);
hwts->hwtstamp = timeval_to_ktime(tv);
return netif_rx(skb); return netif_rx(skb);
} }
......
...@@ -151,8 +151,7 @@ void peak_usb_init_time_ref(struct peak_time_ref *time_ref, ...@@ -151,8 +151,7 @@ void peak_usb_init_time_ref(struct peak_time_ref *time_ref,
const struct peak_usb_adapter *adapter); const struct peak_usb_adapter *adapter);
void peak_usb_update_ts_now(struct peak_time_ref *time_ref, u32 ts_now); 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_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, void peak_usb_get_ts_time(struct peak_time_ref *time_ref, u32 ts, ktime_t *tv);
struct timeval *tv);
int peak_usb_netif_rx(struct sk_buff *skb, int peak_usb_netif_rx(struct sk_buff *skb,
struct peak_time_ref *time_ref, u32 ts_low, u32 ts_high); struct peak_time_ref *time_ref, u32 ts_low, u32 ts_high);
void peak_usb_async_complete(struct urb *urb); void peak_usb_async_complete(struct urb *urb);
......
...@@ -531,7 +531,6 @@ static int pcan_usb_pro_handle_canmsg(struct pcan_usb_pro_interface *usb_if, ...@@ -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 net_device *netdev = dev->netdev;
struct can_frame *can_frame; struct can_frame *can_frame;
struct sk_buff *skb; struct sk_buff *skb;
struct timeval tv;
struct skb_shared_hwtstamps *hwts; struct skb_shared_hwtstamps *hwts;
skb = alloc_can_skb(netdev, &can_frame); 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, ...@@ -549,9 +548,9 @@ static int pcan_usb_pro_handle_canmsg(struct pcan_usb_pro_interface *usb_if,
else else
memcpy(can_frame->data, rx->data, can_frame->can_dlc); 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 = 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_packets++;
netdev->stats.rx_bytes += can_frame->can_dlc; 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, ...@@ -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; enum can_state new_state = CAN_STATE_ERROR_ACTIVE;
u8 err_mask = 0; u8 err_mask = 0;
struct sk_buff *skb; struct sk_buff *skb;
struct timeval tv;
struct skb_shared_hwtstamps *hwts; struct skb_shared_hwtstamps *hwts;
/* nothing should be sent while in BUS_OFF state */ /* 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, ...@@ -667,9 +665,8 @@ static int pcan_usb_pro_handle_error(struct pcan_usb_pro_interface *usb_if,
dev->can.state = new_state; 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 = 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_packets++;
netdev->stats.rx_bytes += can_frame->can_dlc; netdev->stats.rx_bytes += can_frame->can_dlc;
netif_rx(skb); netif_rx(skb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment