diff options
author | David S. Miller <davem@davemloft.net> | 2015-01-11 21:40:07 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-01-11 21:40:07 -0500 |
commit | ef5ba4aff9b55a4cf51e83af3f4dbc5cb4e471fa (patch) | |
tree | 12931bcf7d7bbdb8c6fe58a42b23de4d5e925bef | |
parent | f3cd7a264bb001a701e68c7234a3b1cdb3a83f5f (diff) | |
parent | 497ec1f2a086878d6a42334eda72bfef079dd484 (diff) |
Merge branch 'irda-next'
Chunyan Zhang says:
====================
irda: Use ktime_t instead of timeval
This patch-set removed all uses of timeval and used ktime_t instead if
needed, since 32-bit time types will break in the year 2038.
This patch-set also used the ktime_xxx functions accordingly.
e.g.
* Used ktime_get to get the current time instead of do_gettimeofday.
* And, used ktime_us_delta to get the elapsed time directly.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/irda/ali-ircc.c | 11 | ||||
-rw-r--r-- | drivers/net/irda/ali-ircc.h | 5 | ||||
-rw-r--r-- | drivers/net/irda/au1k_ir.c | 3 | ||||
-rw-r--r-- | drivers/net/irda/irda-usb.c | 10 | ||||
-rw-r--r-- | drivers/net/irda/irda-usb.h | 5 | ||||
-rw-r--r-- | drivers/net/irda/kingsun-sir.c | 3 | ||||
-rw-r--r-- | drivers/net/irda/ks959-sir.c | 3 | ||||
-rw-r--r-- | drivers/net/irda/mcs7780.c | 2 | ||||
-rw-r--r-- | drivers/net/irda/mcs7780.h | 1 | ||||
-rw-r--r-- | drivers/net/irda/nsc-ircc.c | 7 | ||||
-rw-r--r-- | drivers/net/irda/nsc-ircc.h | 5 | ||||
-rw-r--r-- | drivers/net/irda/stir4200.c | 16 | ||||
-rw-r--r-- | drivers/net/irda/via-ircc.h | 4 | ||||
-rw-r--r-- | drivers/net/irda/vlsi_ir.c | 46 | ||||
-rw-r--r-- | drivers/net/irda/vlsi_ir.h | 2 |
15 files changed, 34 insertions, 89 deletions
diff --git a/drivers/net/irda/ali-ircc.c b/drivers/net/irda/ali-ircc.c index 58f98f4de773..58ae11a14bb6 100644 --- a/drivers/net/irda/ali-ircc.c +++ b/drivers/net/irda/ali-ircc.c | |||
@@ -1462,17 +1462,12 @@ static netdev_tx_t ali_ircc_fir_hard_xmit(struct sk_buff *skb, | |||
1462 | if (mtt) | 1462 | if (mtt) |
1463 | { | 1463 | { |
1464 | /* Check how much time we have used already */ | 1464 | /* Check how much time we have used already */ |
1465 | do_gettimeofday(&self->now); | 1465 | diff = ktime_us_delta(ktime_get(), self->stamp); |
1466 | |||
1467 | diff = self->now.tv_usec - self->stamp.tv_usec; | ||
1468 | /* self->stamp is set from ali_ircc_dma_receive_complete() */ | 1466 | /* self->stamp is set from ali_ircc_dma_receive_complete() */ |
1469 | 1467 | ||
1470 | pr_debug("%s(), ******* diff = %d *******\n", | 1468 | pr_debug("%s(), ******* diff = %d *******\n", |
1471 | __func__, diff); | 1469 | __func__, diff); |
1472 | 1470 | ||
1473 | if (diff < 0) | ||
1474 | diff += 1000000; | ||
1475 | |||
1476 | /* Check if the mtt is larger than the time we have | 1471 | /* Check if the mtt is larger than the time we have |
1477 | * already used by all the protocol processing | 1472 | * already used by all the protocol processing |
1478 | */ | 1473 | */ |
@@ -1884,7 +1879,7 @@ static int ali_ircc_dma_receive_complete(struct ali_ircc_cb *self) | |||
1884 | * reduce the min turn time a bit since we will know | 1879 | * reduce the min turn time a bit since we will know |
1885 | * how much time we have used for protocol processing | 1880 | * how much time we have used for protocol processing |
1886 | */ | 1881 | */ |
1887 | do_gettimeofday(&self->stamp); | 1882 | self->stamp = ktime_get(); |
1888 | 1883 | ||
1889 | skb = dev_alloc_skb(len+1); | 1884 | skb = dev_alloc_skb(len+1); |
1890 | if (skb == NULL) | 1885 | if (skb == NULL) |
diff --git a/drivers/net/irda/ali-ircc.h b/drivers/net/irda/ali-ircc.h index 0c8edb41bd0a..c2d9747a5108 100644 --- a/drivers/net/irda/ali-ircc.h +++ b/drivers/net/irda/ali-ircc.h | |||
@@ -22,7 +22,7 @@ | |||
22 | #ifndef ALI_IRCC_H | 22 | #ifndef ALI_IRCC_H |
23 | #define ALI_IRCC_H | 23 | #define ALI_IRCC_H |
24 | 24 | ||
25 | #include <linux/time.h> | 25 | #include <linux/ktime.h> |
26 | 26 | ||
27 | #include <linux/spinlock.h> | 27 | #include <linux/spinlock.h> |
28 | #include <linux/pm.h> | 28 | #include <linux/pm.h> |
@@ -209,8 +209,7 @@ struct ali_ircc_cb { | |||
209 | 209 | ||
210 | unsigned char rcvFramesOverflow; | 210 | unsigned char rcvFramesOverflow; |
211 | 211 | ||
212 | struct timeval stamp; | 212 | ktime_t stamp; |
213 | struct timeval now; | ||
214 | 213 | ||
215 | spinlock_t lock; /* For serializing operations */ | 214 | spinlock_t lock; /* For serializing operations */ |
216 | 215 | ||
diff --git a/drivers/net/irda/au1k_ir.c b/drivers/net/irda/au1k_ir.c index e151205281e2..44e4f386a5dc 100644 --- a/drivers/net/irda/au1k_ir.c +++ b/drivers/net/irda/au1k_ir.c | |||
@@ -24,7 +24,6 @@ | |||
24 | #include <linux/interrupt.h> | 24 | #include <linux/interrupt.h> |
25 | #include <linux/platform_device.h> | 25 | #include <linux/platform_device.h> |
26 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
27 | #include <linux/time.h> | ||
28 | #include <linux/types.h> | 27 | #include <linux/types.h> |
29 | #include <linux/ioport.h> | 28 | #include <linux/ioport.h> |
30 | 29 | ||
@@ -163,8 +162,6 @@ struct au1k_private { | |||
163 | iobuff_t rx_buff; | 162 | iobuff_t rx_buff; |
164 | 163 | ||
165 | struct net_device *netdev; | 164 | struct net_device *netdev; |
166 | struct timeval stamp; | ||
167 | struct timeval now; | ||
168 | struct qos_info qos; | 165 | struct qos_info qos; |
169 | struct irlap_cb *irlap; | 166 | struct irlap_cb *irlap; |
170 | 167 | ||
diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c index 48b2f9a321b7..f6c916312577 100644 --- a/drivers/net/irda/irda-usb.c +++ b/drivers/net/irda/irda-usb.c | |||
@@ -495,18 +495,12 @@ static netdev_tx_t irda_usb_hard_xmit(struct sk_buff *skb, | |||
495 | mtt = irda_get_mtt(skb); | 495 | mtt = irda_get_mtt(skb); |
496 | if (mtt) { | 496 | if (mtt) { |
497 | int diff; | 497 | int diff; |
498 | do_gettimeofday(&self->now); | 498 | diff = ktime_us_delta(ktime_get(), self->stamp); |
499 | diff = self->now.tv_usec - self->stamp.tv_usec; | ||
500 | #ifdef IU_USB_MIN_RTT | 499 | #ifdef IU_USB_MIN_RTT |
501 | /* Factor in USB delays -> Get rid of udelay() that | 500 | /* Factor in USB delays -> Get rid of udelay() that |
502 | * would be lost in the noise - Jean II */ | 501 | * would be lost in the noise - Jean II */ |
503 | diff += IU_USB_MIN_RTT; | 502 | diff += IU_USB_MIN_RTT; |
504 | #endif /* IU_USB_MIN_RTT */ | 503 | #endif /* IU_USB_MIN_RTT */ |
505 | /* If the usec counter did wraparound, the diff will | ||
506 | * go negative (tv_usec is a long), so we need to | ||
507 | * correct it by one second. Jean II */ | ||
508 | if (diff < 0) | ||
509 | diff += 1000000; | ||
510 | 504 | ||
511 | /* Check if the mtt is larger than the time we have | 505 | /* Check if the mtt is larger than the time we have |
512 | * already used by all the protocol processing | 506 | * already used by all the protocol processing |
@@ -869,7 +863,7 @@ static void irda_usb_receive(struct urb *urb) | |||
869 | * reduce the min turn time a bit since we will know | 863 | * reduce the min turn time a bit since we will know |
870 | * how much time we have used for protocol processing | 864 | * how much time we have used for protocol processing |
871 | */ | 865 | */ |
872 | do_gettimeofday(&self->stamp); | 866 | self->stamp = ktime_get(); |
873 | 867 | ||
874 | /* Check if we need to copy the data to a new skb or not. | 868 | /* Check if we need to copy the data to a new skb or not. |
875 | * For most frames, we use ZeroCopy and pass the already | 869 | * For most frames, we use ZeroCopy and pass the already |
diff --git a/drivers/net/irda/irda-usb.h b/drivers/net/irda/irda-usb.h index 58ddb5214916..8ac389fa9348 100644 --- a/drivers/net/irda/irda-usb.h +++ b/drivers/net/irda/irda-usb.h | |||
@@ -29,7 +29,7 @@ | |||
29 | * | 29 | * |
30 | *****************************************************************************/ | 30 | *****************************************************************************/ |
31 | 31 | ||
32 | #include <linux/time.h> | 32 | #include <linux/ktime.h> |
33 | 33 | ||
34 | #include <net/irda/irda.h> | 34 | #include <net/irda/irda.h> |
35 | #include <net/irda/irda_device.h> /* struct irlap_cb */ | 35 | #include <net/irda/irda_device.h> /* struct irlap_cb */ |
@@ -157,8 +157,7 @@ struct irda_usb_cb { | |||
157 | char *speed_buff; /* Buffer for speed changes */ | 157 | char *speed_buff; /* Buffer for speed changes */ |
158 | char *tx_buff; | 158 | char *tx_buff; |
159 | 159 | ||
160 | struct timeval stamp; | 160 | ktime_t stamp; |
161 | struct timeval now; | ||
162 | 161 | ||
163 | spinlock_t lock; /* For serializing Tx operations */ | 162 | spinlock_t lock; /* For serializing Tx operations */ |
164 | 163 | ||
diff --git a/drivers/net/irda/kingsun-sir.c b/drivers/net/irda/kingsun-sir.c index e638893e98a9..fb5d162ec7d2 100644 --- a/drivers/net/irda/kingsun-sir.c +++ b/drivers/net/irda/kingsun-sir.c | |||
@@ -114,7 +114,6 @@ struct kingsun_cb { | |||
114 | (usually 8) */ | 114 | (usually 8) */ |
115 | 115 | ||
116 | iobuff_t rx_buff; /* receive unwrap state machine */ | 116 | iobuff_t rx_buff; /* receive unwrap state machine */ |
117 | struct timeval rx_time; | ||
118 | spinlock_t lock; | 117 | spinlock_t lock; |
119 | int receiving; | 118 | int receiving; |
120 | 119 | ||
@@ -235,7 +234,6 @@ static void kingsun_rcv_irq(struct urb *urb) | |||
235 | &kingsun->netdev->stats, | 234 | &kingsun->netdev->stats, |
236 | &kingsun->rx_buff, bytes[i]); | 235 | &kingsun->rx_buff, bytes[i]); |
237 | } | 236 | } |
238 | do_gettimeofday(&kingsun->rx_time); | ||
239 | kingsun->receiving = | 237 | kingsun->receiving = |
240 | (kingsun->rx_buff.state != OUTSIDE_FRAME) | 238 | (kingsun->rx_buff.state != OUTSIDE_FRAME) |
241 | ? 1 : 0; | 239 | ? 1 : 0; |
@@ -273,7 +271,6 @@ static int kingsun_net_open(struct net_device *netdev) | |||
273 | 271 | ||
274 | skb_reserve(kingsun->rx_buff.skb, 1); | 272 | skb_reserve(kingsun->rx_buff.skb, 1); |
275 | kingsun->rx_buff.head = kingsun->rx_buff.skb->data; | 273 | kingsun->rx_buff.head = kingsun->rx_buff.skb->data; |
276 | do_gettimeofday(&kingsun->rx_time); | ||
277 | 274 | ||
278 | kingsun->rx_urb = usb_alloc_urb(0, GFP_KERNEL); | 275 | kingsun->rx_urb = usb_alloc_urb(0, GFP_KERNEL); |
279 | if (!kingsun->rx_urb) | 276 | if (!kingsun->rx_urb) |
diff --git a/drivers/net/irda/ks959-sir.c b/drivers/net/irda/ks959-sir.c index e6b3804edacd..8e6e0edf2440 100644 --- a/drivers/net/irda/ks959-sir.c +++ b/drivers/net/irda/ks959-sir.c | |||
@@ -187,7 +187,6 @@ struct ks959_cb { | |||
187 | __u8 *rx_buf; | 187 | __u8 *rx_buf; |
188 | __u8 rx_variable_xormask; | 188 | __u8 rx_variable_xormask; |
189 | iobuff_t rx_unwrap_buff; | 189 | iobuff_t rx_unwrap_buff; |
190 | struct timeval rx_time; | ||
191 | 190 | ||
192 | struct usb_ctrlrequest *speed_setuprequest; | 191 | struct usb_ctrlrequest *speed_setuprequest; |
193 | struct urb *speed_urb; | 192 | struct urb *speed_urb; |
@@ -476,7 +475,6 @@ static void ks959_rcv_irq(struct urb *urb) | |||
476 | bytes[i]); | 475 | bytes[i]); |
477 | } | 476 | } |
478 | } | 477 | } |
479 | do_gettimeofday(&kingsun->rx_time); | ||
480 | kingsun->receiving = | 478 | kingsun->receiving = |
481 | (kingsun->rx_unwrap_buff.state != OUTSIDE_FRAME) ? 1 : 0; | 479 | (kingsun->rx_unwrap_buff.state != OUTSIDE_FRAME) ? 1 : 0; |
482 | } | 480 | } |
@@ -514,7 +512,6 @@ static int ks959_net_open(struct net_device *netdev) | |||
514 | 512 | ||
515 | skb_reserve(kingsun->rx_unwrap_buff.skb, 1); | 513 | skb_reserve(kingsun->rx_unwrap_buff.skb, 1); |
516 | kingsun->rx_unwrap_buff.head = kingsun->rx_unwrap_buff.skb->data; | 514 | kingsun->rx_unwrap_buff.head = kingsun->rx_unwrap_buff.skb->data; |
517 | do_gettimeofday(&kingsun->rx_time); | ||
518 | 515 | ||
519 | kingsun->rx_urb = usb_alloc_urb(0, GFP_KERNEL); | 516 | kingsun->rx_urb = usb_alloc_urb(0, GFP_KERNEL); |
520 | if (!kingsun->rx_urb) | 517 | if (!kingsun->rx_urb) |
diff --git a/drivers/net/irda/mcs7780.c b/drivers/net/irda/mcs7780.c index e4d678fbeb2f..bca6a1e72d1d 100644 --- a/drivers/net/irda/mcs7780.c +++ b/drivers/net/irda/mcs7780.c | |||
@@ -722,7 +722,6 @@ static int mcs_net_open(struct net_device *netdev) | |||
722 | 722 | ||
723 | skb_reserve(mcs->rx_buff.skb, 1); | 723 | skb_reserve(mcs->rx_buff.skb, 1); |
724 | mcs->rx_buff.head = mcs->rx_buff.skb->data; | 724 | mcs->rx_buff.head = mcs->rx_buff.skb->data; |
725 | do_gettimeofday(&mcs->rx_time); | ||
726 | 725 | ||
727 | /* | 726 | /* |
728 | * Now that everything should be initialized properly, | 727 | * Now that everything should be initialized properly, |
@@ -799,7 +798,6 @@ static void mcs_receive_irq(struct urb *urb) | |||
799 | mcs_unwrap_fir(mcs, urb->transfer_buffer, | 798 | mcs_unwrap_fir(mcs, urb->transfer_buffer, |
800 | urb->actual_length); | 799 | urb->actual_length); |
801 | } | 800 | } |
802 | do_gettimeofday(&mcs->rx_time); | ||
803 | } | 801 | } |
804 | 802 | ||
805 | ret = usb_submit_urb(urb, GFP_ATOMIC); | 803 | ret = usb_submit_urb(urb, GFP_ATOMIC); |
diff --git a/drivers/net/irda/mcs7780.h b/drivers/net/irda/mcs7780.h index b10689b2887c..a6e8f7dbafc9 100644 --- a/drivers/net/irda/mcs7780.h +++ b/drivers/net/irda/mcs7780.h | |||
@@ -116,7 +116,6 @@ struct mcs_cb { | |||
116 | __u8 *fifo_status; | 116 | __u8 *fifo_status; |
117 | 117 | ||
118 | iobuff_t rx_buff; /* receive unwrap state machine */ | 118 | iobuff_t rx_buff; /* receive unwrap state machine */ |
119 | struct timeval rx_time; | ||
120 | spinlock_t lock; | 119 | spinlock_t lock; |
121 | int receiving; | 120 | int receiving; |
122 | 121 | ||
diff --git a/drivers/net/irda/nsc-ircc.c b/drivers/net/irda/nsc-ircc.c index e7317b104bfb..dc0dbd8dd0b5 100644 --- a/drivers/net/irda/nsc-ircc.c +++ b/drivers/net/irda/nsc-ircc.c | |||
@@ -1501,10 +1501,7 @@ static netdev_tx_t nsc_ircc_hard_xmit_fir(struct sk_buff *skb, | |||
1501 | mtt = irda_get_mtt(skb); | 1501 | mtt = irda_get_mtt(skb); |
1502 | if (mtt) { | 1502 | if (mtt) { |
1503 | /* Check how much time we have used already */ | 1503 | /* Check how much time we have used already */ |
1504 | do_gettimeofday(&self->now); | 1504 | diff = ktime_us_delta(ktime_get(), self->stamp); |
1505 | diff = self->now.tv_usec - self->stamp.tv_usec; | ||
1506 | if (diff < 0) | ||
1507 | diff += 1000000; | ||
1508 | 1505 | ||
1509 | /* Check if the mtt is larger than the time we have | 1506 | /* Check if the mtt is larger than the time we have |
1510 | * already used by all the protocol processing | 1507 | * already used by all the protocol processing |
@@ -1867,7 +1864,7 @@ static int nsc_ircc_dma_receive_complete(struct nsc_ircc_cb *self, int iobase) | |||
1867 | * reduce the min turn time a bit since we will know | 1864 | * reduce the min turn time a bit since we will know |
1868 | * how much time we have used for protocol processing | 1865 | * how much time we have used for protocol processing |
1869 | */ | 1866 | */ |
1870 | do_gettimeofday(&self->stamp); | 1867 | self->stamp = ktime_get(); |
1871 | 1868 | ||
1872 | skb = dev_alloc_skb(len+1); | 1869 | skb = dev_alloc_skb(len+1); |
1873 | if (skb == NULL) { | 1870 | if (skb == NULL) { |
diff --git a/drivers/net/irda/nsc-ircc.h b/drivers/net/irda/nsc-ircc.h index 32fa58211fad..7be5acb56532 100644 --- a/drivers/net/irda/nsc-ircc.h +++ b/drivers/net/irda/nsc-ircc.h | |||
@@ -28,7 +28,7 @@ | |||
28 | #ifndef NSC_IRCC_H | 28 | #ifndef NSC_IRCC_H |
29 | #define NSC_IRCC_H | 29 | #define NSC_IRCC_H |
30 | 30 | ||
31 | #include <linux/time.h> | 31 | #include <linux/ktime.h> |
32 | 32 | ||
33 | #include <linux/spinlock.h> | 33 | #include <linux/spinlock.h> |
34 | #include <linux/pm.h> | 34 | #include <linux/pm.h> |
@@ -263,8 +263,7 @@ struct nsc_ircc_cb { | |||
263 | 263 | ||
264 | __u8 ier; /* Interrupt enable register */ | 264 | __u8 ier; /* Interrupt enable register */ |
265 | 265 | ||
266 | struct timeval stamp; | 266 | ktime_t stamp; |
267 | struct timeval now; | ||
268 | 267 | ||
269 | spinlock_t lock; /* For serializing operations */ | 268 | spinlock_t lock; /* For serializing operations */ |
270 | 269 | ||
diff --git a/drivers/net/irda/stir4200.c b/drivers/net/irda/stir4200.c index dd1bd1060ec9..83cc48a01802 100644 --- a/drivers/net/irda/stir4200.c +++ b/drivers/net/irda/stir4200.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #include <linux/moduleparam.h> | 40 | #include <linux/moduleparam.h> |
41 | 41 | ||
42 | #include <linux/kernel.h> | 42 | #include <linux/kernel.h> |
43 | #include <linux/ktime.h> | ||
43 | #include <linux/types.h> | 44 | #include <linux/types.h> |
44 | #include <linux/time.h> | 45 | #include <linux/time.h> |
45 | #include <linux/skbuff.h> | 46 | #include <linux/skbuff.h> |
@@ -174,7 +175,7 @@ struct stir_cb { | |||
174 | __u8 *fifo_status; | 175 | __u8 *fifo_status; |
175 | 176 | ||
176 | iobuff_t rx_buff; /* receive unwrap state machine */ | 177 | iobuff_t rx_buff; /* receive unwrap state machine */ |
177 | struct timeval rx_time; | 178 | ktime_t rx_time; |
178 | int receiving; | 179 | int receiving; |
179 | struct urb *rx_urb; | 180 | struct urb *rx_urb; |
180 | }; | 181 | }; |
@@ -650,15 +651,12 @@ static int fifo_txwait(struct stir_cb *stir, int space) | |||
650 | static void turnaround_delay(const struct stir_cb *stir, long us) | 651 | static void turnaround_delay(const struct stir_cb *stir, long us) |
651 | { | 652 | { |
652 | long ticks; | 653 | long ticks; |
653 | struct timeval now; | ||
654 | 654 | ||
655 | if (us <= 0) | 655 | if (us <= 0) |
656 | return; | 656 | return; |
657 | 657 | ||
658 | do_gettimeofday(&now); | 658 | us -= ktime_us_delta(ktime_get(), stir->rx_time); |
659 | if (now.tv_sec - stir->rx_time.tv_sec > 0) | 659 | |
660 | us -= USEC_PER_SEC; | ||
661 | us -= now.tv_usec - stir->rx_time.tv_usec; | ||
662 | if (us < 10) | 660 | if (us < 10) |
663 | return; | 661 | return; |
664 | 662 | ||
@@ -823,8 +821,8 @@ static void stir_rcv_irq(struct urb *urb) | |||
823 | pr_debug("receive %d\n", urb->actual_length); | 821 | pr_debug("receive %d\n", urb->actual_length); |
824 | unwrap_chars(stir, urb->transfer_buffer, | 822 | unwrap_chars(stir, urb->transfer_buffer, |
825 | urb->actual_length); | 823 | urb->actual_length); |
826 | 824 | ||
827 | do_gettimeofday(&stir->rx_time); | 825 | stir->rx_time = ktime_get(); |
828 | } | 826 | } |
829 | 827 | ||
830 | /* kernel thread is stopping receiver don't resubmit */ | 828 | /* kernel thread is stopping receiver don't resubmit */ |
@@ -876,7 +874,7 @@ static int stir_net_open(struct net_device *netdev) | |||
876 | 874 | ||
877 | skb_reserve(stir->rx_buff.skb, 1); | 875 | skb_reserve(stir->rx_buff.skb, 1); |
878 | stir->rx_buff.head = stir->rx_buff.skb->data; | 876 | stir->rx_buff.head = stir->rx_buff.skb->data; |
879 | do_gettimeofday(&stir->rx_time); | 877 | stir->rx_time = ktime_get(); |
880 | 878 | ||
881 | stir->rx_urb = usb_alloc_urb(0, GFP_KERNEL); | 879 | stir->rx_urb = usb_alloc_urb(0, GFP_KERNEL); |
882 | if (!stir->rx_urb) | 880 | if (!stir->rx_urb) |
diff --git a/drivers/net/irda/via-ircc.h b/drivers/net/irda/via-ircc.h index 7ce820ecc361..ac1525573398 100644 --- a/drivers/net/irda/via-ircc.h +++ b/drivers/net/irda/via-ircc.h | |||
@@ -29,7 +29,6 @@ this program; if not, see <http://www.gnu.org/licenses/>. | |||
29 | ********************************************************************/ | 29 | ********************************************************************/ |
30 | #ifndef via_IRCC_H | 30 | #ifndef via_IRCC_H |
31 | #define via_IRCC_H | 31 | #define via_IRCC_H |
32 | #include <linux/time.h> | ||
33 | #include <linux/spinlock.h> | 32 | #include <linux/spinlock.h> |
34 | #include <linux/pm.h> | 33 | #include <linux/pm.h> |
35 | #include <linux/types.h> | 34 | #include <linux/types.h> |
@@ -106,9 +105,6 @@ struct via_ircc_cb { | |||
106 | 105 | ||
107 | __u8 ier; /* Interrupt enable register */ | 106 | __u8 ier; /* Interrupt enable register */ |
108 | 107 | ||
109 | struct timeval stamp; | ||
110 | struct timeval now; | ||
111 | |||
112 | spinlock_t lock; /* For serializing operations */ | 108 | spinlock_t lock; /* For serializing operations */ |
113 | 109 | ||
114 | __u32 flags; /* Interface flags */ | 110 | __u32 flags; /* Interface flags */ |
diff --git a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c index ac39d9f33d5f..a0849f49bbec 100644 --- a/drivers/net/irda/vlsi_ir.c +++ b/drivers/net/irda/vlsi_ir.c | |||
@@ -33,6 +33,7 @@ MODULE_LICENSE("GPL"); | |||
33 | /********************************************************/ | 33 | /********************************************************/ |
34 | 34 | ||
35 | #include <linux/kernel.h> | 35 | #include <linux/kernel.h> |
36 | #include <linux/ktime.h> | ||
36 | #include <linux/init.h> | 37 | #include <linux/init.h> |
37 | #include <linux/interrupt.h> | 38 | #include <linux/interrupt.h> |
38 | #include <linux/pci.h> | 39 | #include <linux/pci.h> |
@@ -40,9 +41,9 @@ MODULE_LICENSE("GPL"); | |||
40 | #include <linux/netdevice.h> | 41 | #include <linux/netdevice.h> |
41 | #include <linux/skbuff.h> | 42 | #include <linux/skbuff.h> |
42 | #include <linux/delay.h> | 43 | #include <linux/delay.h> |
43 | #include <linux/time.h> | ||
44 | #include <linux/proc_fs.h> | 44 | #include <linux/proc_fs.h> |
45 | #include <linux/seq_file.h> | 45 | #include <linux/seq_file.h> |
46 | #include <linux/math64.h> | ||
46 | #include <linux/mutex.h> | 47 | #include <linux/mutex.h> |
47 | #include <asm/uaccess.h> | 48 | #include <asm/uaccess.h> |
48 | #include <asm/byteorder.h> | 49 | #include <asm/byteorder.h> |
@@ -180,8 +181,7 @@ static void vlsi_proc_ndev(struct seq_file *seq, struct net_device *ndev) | |||
180 | vlsi_irda_dev_t *idev = netdev_priv(ndev); | 181 | vlsi_irda_dev_t *idev = netdev_priv(ndev); |
181 | u8 byte; | 182 | u8 byte; |
182 | u16 word; | 183 | u16 word; |
183 | unsigned delta1, delta2; | 184 | s32 sec, usec; |
184 | struct timeval now; | ||
185 | unsigned iobase = ndev->base_addr; | 185 | unsigned iobase = ndev->base_addr; |
186 | 186 | ||
187 | seq_printf(seq, "\n%s link state: %s / %s / %s / %s\n", ndev->name, | 187 | seq_printf(seq, "\n%s link state: %s / %s / %s / %s\n", ndev->name, |
@@ -277,17 +277,9 @@ static void vlsi_proc_ndev(struct seq_file *seq, struct net_device *ndev) | |||
277 | seq_printf(seq, "\nsw-state:\n"); | 277 | seq_printf(seq, "\nsw-state:\n"); |
278 | seq_printf(seq, "IrPHY setup: %d baud - %s encoding\n", idev->baud, | 278 | seq_printf(seq, "IrPHY setup: %d baud - %s encoding\n", idev->baud, |
279 | (idev->mode==IFF_SIR)?"SIR":((idev->mode==IFF_MIR)?"MIR":"FIR")); | 279 | (idev->mode==IFF_SIR)?"SIR":((idev->mode==IFF_MIR)?"MIR":"FIR")); |
280 | do_gettimeofday(&now); | 280 | sec = div_s64_rem(ktime_us_delta(ktime_get(), idev->last_rx), |
281 | if (now.tv_usec >= idev->last_rx.tv_usec) { | 281 | USEC_PER_SEC, &usec); |
282 | delta2 = now.tv_usec - idev->last_rx.tv_usec; | 282 | seq_printf(seq, "last rx: %ul.%06u sec\n", sec, usec); |
283 | delta1 = 0; | ||
284 | } | ||
285 | else { | ||
286 | delta2 = 1000000 + now.tv_usec - idev->last_rx.tv_usec; | ||
287 | delta1 = 1; | ||
288 | } | ||
289 | seq_printf(seq, "last rx: %lu.%06u sec\n", | ||
290 | now.tv_sec - idev->last_rx.tv_sec - delta1, delta2); | ||
291 | 283 | ||
292 | seq_printf(seq, "RX: packets=%lu / bytes=%lu / errors=%lu / dropped=%lu", | 284 | seq_printf(seq, "RX: packets=%lu / bytes=%lu / errors=%lu / dropped=%lu", |
293 | ndev->stats.rx_packets, ndev->stats.rx_bytes, ndev->stats.rx_errors, | 285 | ndev->stats.rx_packets, ndev->stats.rx_bytes, ndev->stats.rx_errors, |
@@ -661,7 +653,7 @@ static void vlsi_rx_interrupt(struct net_device *ndev) | |||
661 | } | 653 | } |
662 | } | 654 | } |
663 | 655 | ||
664 | do_gettimeofday(&idev->last_rx); /* remember "now" for later mtt delay */ | 656 | idev->last_rx = ktime_get(); /* remember "now" for later mtt delay */ |
665 | 657 | ||
666 | vlsi_fill_rx(r); | 658 | vlsi_fill_rx(r); |
667 | 659 | ||
@@ -858,9 +850,8 @@ static netdev_tx_t vlsi_hard_start_xmit(struct sk_buff *skb, | |||
858 | unsigned iobase = ndev->base_addr; | 850 | unsigned iobase = ndev->base_addr; |
859 | u8 status; | 851 | u8 status; |
860 | u16 config; | 852 | u16 config; |
861 | int mtt; | 853 | int mtt, diff; |
862 | int len, speed; | 854 | int len, speed; |
863 | struct timeval now, ready; | ||
864 | char *msg = NULL; | 855 | char *msg = NULL; |
865 | 856 | ||
866 | speed = irda_get_next_speed(skb); | 857 | speed = irda_get_next_speed(skb); |
@@ -940,21 +931,10 @@ static netdev_tx_t vlsi_hard_start_xmit(struct sk_buff *skb, | |||
940 | spin_unlock_irqrestore(&idev->lock, flags); | 931 | spin_unlock_irqrestore(&idev->lock, flags); |
941 | 932 | ||
942 | if ((mtt = irda_get_mtt(skb)) > 0) { | 933 | if ((mtt = irda_get_mtt(skb)) > 0) { |
943 | 934 | diff = ktime_us_delta(ktime_get(), idev->last_rx); | |
944 | ready.tv_usec = idev->last_rx.tv_usec + mtt; | 935 | if (mtt > diff) |
945 | ready.tv_sec = idev->last_rx.tv_sec; | 936 | udelay(mtt - diff); |
946 | if (ready.tv_usec >= 1000000) { | ||
947 | ready.tv_usec -= 1000000; | ||
948 | ready.tv_sec++; /* IrLAP 1.1: mtt always < 1 sec */ | ||
949 | } | ||
950 | for(;;) { | ||
951 | do_gettimeofday(&now); | ||
952 | if (now.tv_sec > ready.tv_sec || | ||
953 | (now.tv_sec==ready.tv_sec && now.tv_usec>=ready.tv_usec)) | ||
954 | break; | ||
955 | udelay(100); | ||
956 | /* must not sleep here - called under netif_tx_lock! */ | 937 | /* must not sleep here - called under netif_tx_lock! */ |
957 | } | ||
958 | } | 938 | } |
959 | 939 | ||
960 | /* tx buffer already owned by CPU due to pci_dma_sync_single_for_cpu() | 940 | /* tx buffer already owned by CPU due to pci_dma_sync_single_for_cpu() |
@@ -1333,7 +1313,7 @@ static int vlsi_start_hw(vlsi_irda_dev_t *idev) | |||
1333 | 1313 | ||
1334 | vlsi_fill_rx(idev->rx_ring); | 1314 | vlsi_fill_rx(idev->rx_ring); |
1335 | 1315 | ||
1336 | do_gettimeofday(&idev->last_rx); /* first mtt may start from now on */ | 1316 | idev->last_rx = ktime_get(); /* first mtt may start from now on */ |
1337 | 1317 | ||
1338 | outw(0, iobase+VLSI_PIO_PROMPT); /* kick hw state machine */ | 1318 | outw(0, iobase+VLSI_PIO_PROMPT); /* kick hw state machine */ |
1339 | 1319 | ||
@@ -1520,7 +1500,7 @@ static int vlsi_open(struct net_device *ndev) | |||
1520 | if (!idev->irlap) | 1500 | if (!idev->irlap) |
1521 | goto errout_free_ring; | 1501 | goto errout_free_ring; |
1522 | 1502 | ||
1523 | do_gettimeofday(&idev->last_rx); /* first mtt may start from now on */ | 1503 | idev->last_rx = ktime_get(); /* first mtt may start from now on */ |
1524 | 1504 | ||
1525 | idev->new_baud = 9600; /* start with IrPHY using 9600(SIR) mode */ | 1505 | idev->new_baud = 9600; /* start with IrPHY using 9600(SIR) mode */ |
1526 | 1506 | ||
diff --git a/drivers/net/irda/vlsi_ir.h b/drivers/net/irda/vlsi_ir.h index f9119c6d2a09..f9db2ce4c5c6 100644 --- a/drivers/net/irda/vlsi_ir.h +++ b/drivers/net/irda/vlsi_ir.h | |||
@@ -723,7 +723,7 @@ typedef struct vlsi_irda_dev { | |||
723 | void *virtaddr; | 723 | void *virtaddr; |
724 | struct vlsi_ring *tx_ring, *rx_ring; | 724 | struct vlsi_ring *tx_ring, *rx_ring; |
725 | 725 | ||
726 | struct timeval last_rx; | 726 | ktime_t last_rx; |
727 | 727 | ||
728 | spinlock_t lock; | 728 | spinlock_t lock; |
729 | struct mutex mtx; | 729 | struct mutex mtx; |