Skip to content

Commit

Permalink
Merge branch 'irda-next'
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
David S. Miller committed Jan 12, 2015
2 parents f3cd7a2 + 497ec1f commit ef5ba4a
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 89 deletions.
11 changes: 3 additions & 8 deletions drivers/net/irda/ali-ircc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1462,17 +1462,12 @@ static netdev_tx_t ali_ircc_fir_hard_xmit(struct sk_buff *skb,
if (mtt)
{
/* Check how much time we have used already */
do_gettimeofday(&self->now);

diff = self->now.tv_usec - self->stamp.tv_usec;
diff = ktime_us_delta(ktime_get(), self->stamp);
/* self->stamp is set from ali_ircc_dma_receive_complete() */

pr_debug("%s(), ******* diff = %d *******\n",
__func__, diff);

if (diff < 0)
diff += 1000000;


/* Check if the mtt is larger than the time we have
* already used by all the protocol processing
*/
Expand Down Expand Up @@ -1884,7 +1879,7 @@ static int ali_ircc_dma_receive_complete(struct ali_ircc_cb *self)
* reduce the min turn time a bit since we will know
* how much time we have used for protocol processing
*/
do_gettimeofday(&self->stamp);
self->stamp = ktime_get();

skb = dev_alloc_skb(len+1);
if (skb == NULL)
Expand Down
5 changes: 2 additions & 3 deletions drivers/net/irda/ali-ircc.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#ifndef ALI_IRCC_H
#define ALI_IRCC_H

#include <linux/time.h>
#include <linux/ktime.h>

#include <linux/spinlock.h>
#include <linux/pm.h>
Expand Down Expand Up @@ -209,8 +209,7 @@ struct ali_ircc_cb {

unsigned char rcvFramesOverflow;

struct timeval stamp;
struct timeval now;
ktime_t stamp;

spinlock_t lock; /* For serializing operations */

Expand Down
3 changes: 0 additions & 3 deletions drivers/net/irda/au1k_ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/time.h>
#include <linux/types.h>
#include <linux/ioport.h>

Expand Down Expand Up @@ -163,8 +162,6 @@ struct au1k_private {
iobuff_t rx_buff;

struct net_device *netdev;
struct timeval stamp;
struct timeval now;
struct qos_info qos;
struct irlap_cb *irlap;

Expand Down
10 changes: 2 additions & 8 deletions drivers/net/irda/irda-usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,18 +495,12 @@ static netdev_tx_t irda_usb_hard_xmit(struct sk_buff *skb,
mtt = irda_get_mtt(skb);
if (mtt) {
int diff;
do_gettimeofday(&self->now);
diff = self->now.tv_usec - self->stamp.tv_usec;
diff = ktime_us_delta(ktime_get(), self->stamp);
#ifdef IU_USB_MIN_RTT
/* Factor in USB delays -> Get rid of udelay() that
* would be lost in the noise - Jean II */
diff += IU_USB_MIN_RTT;
#endif /* IU_USB_MIN_RTT */
/* If the usec counter did wraparound, the diff will
* go negative (tv_usec is a long), so we need to
* correct it by one second. Jean II */
if (diff < 0)
diff += 1000000;

/* Check if the mtt is larger than the time we have
* already used by all the protocol processing
Expand Down Expand Up @@ -869,7 +863,7 @@ static void irda_usb_receive(struct urb *urb)
* reduce the min turn time a bit since we will know
* how much time we have used for protocol processing
*/
do_gettimeofday(&self->stamp);
self->stamp = ktime_get();

/* Check if we need to copy the data to a new skb or not.
* For most frames, we use ZeroCopy and pass the already
Expand Down
5 changes: 2 additions & 3 deletions drivers/net/irda/irda-usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*
*****************************************************************************/

#include <linux/time.h>
#include <linux/ktime.h>

#include <net/irda/irda.h>
#include <net/irda/irda_device.h> /* struct irlap_cb */
Expand Down Expand Up @@ -157,8 +157,7 @@ struct irda_usb_cb {
char *speed_buff; /* Buffer for speed changes */
char *tx_buff;

struct timeval stamp;
struct timeval now;
ktime_t stamp;

spinlock_t lock; /* For serializing Tx operations */

Expand Down
3 changes: 0 additions & 3 deletions drivers/net/irda/kingsun-sir.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ struct kingsun_cb {
(usually 8) */

iobuff_t rx_buff; /* receive unwrap state machine */
struct timeval rx_time;
spinlock_t lock;
int receiving;

Expand Down Expand Up @@ -235,7 +234,6 @@ static void kingsun_rcv_irq(struct urb *urb)
&kingsun->netdev->stats,
&kingsun->rx_buff, bytes[i]);
}
do_gettimeofday(&kingsun->rx_time);
kingsun->receiving =
(kingsun->rx_buff.state != OUTSIDE_FRAME)
? 1 : 0;
Expand Down Expand Up @@ -273,7 +271,6 @@ static int kingsun_net_open(struct net_device *netdev)

skb_reserve(kingsun->rx_buff.skb, 1);
kingsun->rx_buff.head = kingsun->rx_buff.skb->data;
do_gettimeofday(&kingsun->rx_time);

kingsun->rx_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!kingsun->rx_urb)
Expand Down
3 changes: 0 additions & 3 deletions drivers/net/irda/ks959-sir.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ struct ks959_cb {
__u8 *rx_buf;
__u8 rx_variable_xormask;
iobuff_t rx_unwrap_buff;
struct timeval rx_time;

struct usb_ctrlrequest *speed_setuprequest;
struct urb *speed_urb;
Expand Down Expand Up @@ -476,7 +475,6 @@ static void ks959_rcv_irq(struct urb *urb)
bytes[i]);
}
}
do_gettimeofday(&kingsun->rx_time);
kingsun->receiving =
(kingsun->rx_unwrap_buff.state != OUTSIDE_FRAME) ? 1 : 0;
}
Expand Down Expand Up @@ -514,7 +512,6 @@ static int ks959_net_open(struct net_device *netdev)

skb_reserve(kingsun->rx_unwrap_buff.skb, 1);
kingsun->rx_unwrap_buff.head = kingsun->rx_unwrap_buff.skb->data;
do_gettimeofday(&kingsun->rx_time);

kingsun->rx_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!kingsun->rx_urb)
Expand Down
2 changes: 0 additions & 2 deletions drivers/net/irda/mcs7780.c
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,6 @@ static int mcs_net_open(struct net_device *netdev)

skb_reserve(mcs->rx_buff.skb, 1);
mcs->rx_buff.head = mcs->rx_buff.skb->data;
do_gettimeofday(&mcs->rx_time);

/*
* Now that everything should be initialized properly,
Expand Down Expand Up @@ -799,7 +798,6 @@ static void mcs_receive_irq(struct urb *urb)
mcs_unwrap_fir(mcs, urb->transfer_buffer,
urb->actual_length);
}
do_gettimeofday(&mcs->rx_time);
}

ret = usb_submit_urb(urb, GFP_ATOMIC);
Expand Down
1 change: 0 additions & 1 deletion drivers/net/irda/mcs7780.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ struct mcs_cb {
__u8 *fifo_status;

iobuff_t rx_buff; /* receive unwrap state machine */
struct timeval rx_time;
spinlock_t lock;
int receiving;

Expand Down
7 changes: 2 additions & 5 deletions drivers/net/irda/nsc-ircc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1501,10 +1501,7 @@ static netdev_tx_t nsc_ircc_hard_xmit_fir(struct sk_buff *skb,
mtt = irda_get_mtt(skb);
if (mtt) {
/* Check how much time we have used already */
do_gettimeofday(&self->now);
diff = self->now.tv_usec - self->stamp.tv_usec;
if (diff < 0)
diff += 1000000;
diff = ktime_us_delta(ktime_get(), self->stamp);

/* Check if the mtt is larger than the time we have
* already used by all the protocol processing
Expand Down Expand Up @@ -1867,7 +1864,7 @@ static int nsc_ircc_dma_receive_complete(struct nsc_ircc_cb *self, int iobase)
* reduce the min turn time a bit since we will know
* how much time we have used for protocol processing
*/
do_gettimeofday(&self->stamp);
self->stamp = ktime_get();

skb = dev_alloc_skb(len+1);
if (skb == NULL) {
Expand Down
5 changes: 2 additions & 3 deletions drivers/net/irda/nsc-ircc.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#ifndef NSC_IRCC_H
#define NSC_IRCC_H

#include <linux/time.h>
#include <linux/ktime.h>

#include <linux/spinlock.h>
#include <linux/pm.h>
Expand Down Expand Up @@ -263,8 +263,7 @@ struct nsc_ircc_cb {

__u8 ier; /* Interrupt enable register */

struct timeval stamp;
struct timeval now;
ktime_t stamp;

spinlock_t lock; /* For serializing operations */

Expand Down
16 changes: 7 additions & 9 deletions drivers/net/irda/stir4200.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <linux/moduleparam.h>

#include <linux/kernel.h>
#include <linux/ktime.h>
#include <linux/types.h>
#include <linux/time.h>
#include <linux/skbuff.h>
Expand Down Expand Up @@ -174,7 +175,7 @@ struct stir_cb {
__u8 *fifo_status;

iobuff_t rx_buff; /* receive unwrap state machine */
struct timeval rx_time;
ktime_t rx_time;
int receiving;
struct urb *rx_urb;
};
Expand Down Expand Up @@ -650,15 +651,12 @@ static int fifo_txwait(struct stir_cb *stir, int space)
static void turnaround_delay(const struct stir_cb *stir, long us)
{
long ticks;
struct timeval now;

if (us <= 0)
return;

do_gettimeofday(&now);
if (now.tv_sec - stir->rx_time.tv_sec > 0)
us -= USEC_PER_SEC;
us -= now.tv_usec - stir->rx_time.tv_usec;
us -= ktime_us_delta(ktime_get(), stir->rx_time);

if (us < 10)
return;

Expand Down Expand Up @@ -823,8 +821,8 @@ static void stir_rcv_irq(struct urb *urb)
pr_debug("receive %d\n", urb->actual_length);
unwrap_chars(stir, urb->transfer_buffer,
urb->actual_length);
do_gettimeofday(&stir->rx_time);

stir->rx_time = ktime_get();
}

/* kernel thread is stopping receiver don't resubmit */
Expand Down Expand Up @@ -876,7 +874,7 @@ static int stir_net_open(struct net_device *netdev)

skb_reserve(stir->rx_buff.skb, 1);
stir->rx_buff.head = stir->rx_buff.skb->data;
do_gettimeofday(&stir->rx_time);
stir->rx_time = ktime_get();

stir->rx_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!stir->rx_urb)
Expand Down
4 changes: 0 additions & 4 deletions drivers/net/irda/via-ircc.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ this program; if not, see <http://www.gnu.org/licenses/>.
********************************************************************/
#ifndef via_IRCC_H
#define via_IRCC_H
#include <linux/time.h>
#include <linux/spinlock.h>
#include <linux/pm.h>
#include <linux/types.h>
Expand Down Expand Up @@ -106,9 +105,6 @@ struct via_ircc_cb {

__u8 ier; /* Interrupt enable register */

struct timeval stamp;
struct timeval now;

spinlock_t lock; /* For serializing operations */

__u32 flags; /* Interface flags */
Expand Down
Loading

0 comments on commit ef5ba4a

Please sign in to comment.