diff options
author | Jarod Wilson <jarod@redhat.com> | 2011-01-06 14:59:36 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-01-19 08:45:52 -0500 |
commit | 5aad724280b9f8ffff3a55311ef0ba35ebb4099a (patch) | |
tree | 0f076e7baaf5d91cbcc6557d4c88208f83402145 /drivers | |
parent | 9ad77eb57b45f81ac3e12077d19e5f121c4cff6d (diff) |
[media] rc: fix up and genericize some time unit conversions
The ene_ir driver was using a private define of MS_TO_NS, which is meant
to be microseconds to nanoseconds. The mceusb driver copied it,
intending to use is a milliseconds to microseconds. Lets move the
defines to a common location, expand and standardize them a touch, so
that we now have:
MS_TO_NS - milliseconds to nanoseconds
MS_TO_US - milliseconds to microseconds
US_TO_NS - microseconds to nanoseconds
Reported-by: David Härdeman <david@hardeman.nu>
CC: Maxim Levitsky <maximlevitsky@gmail.com>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/rc/ene_ir.c | 16 | ||||
-rw-r--r-- | drivers/media/rc/ene_ir.h | 2 | ||||
-rw-r--r-- | drivers/media/rc/mceusb.c | 7 |
3 files changed, 11 insertions, 14 deletions
diff --git a/drivers/media/rc/ene_ir.c b/drivers/media/rc/ene_ir.c index 885abdddfaa8..1ac49139158d 100644 --- a/drivers/media/rc/ene_ir.c +++ b/drivers/media/rc/ene_ir.c | |||
@@ -446,27 +446,27 @@ static void ene_rx_setup(struct ene_device *dev) | |||
446 | 446 | ||
447 | select_timeout: | 447 | select_timeout: |
448 | if (dev->rx_fan_input_inuse) { | 448 | if (dev->rx_fan_input_inuse) { |
449 | dev->rdev->rx_resolution = MS_TO_NS(ENE_FW_SAMPLE_PERIOD_FAN); | 449 | dev->rdev->rx_resolution = US_TO_NS(ENE_FW_SAMPLE_PERIOD_FAN); |
450 | 450 | ||
451 | /* Fan input doesn't support timeouts, it just ends the | 451 | /* Fan input doesn't support timeouts, it just ends the |
452 | input with a maximum sample */ | 452 | input with a maximum sample */ |
453 | dev->rdev->min_timeout = dev->rdev->max_timeout = | 453 | dev->rdev->min_timeout = dev->rdev->max_timeout = |
454 | MS_TO_NS(ENE_FW_SMPL_BUF_FAN_MSK * | 454 | US_TO_NS(ENE_FW_SMPL_BUF_FAN_MSK * |
455 | ENE_FW_SAMPLE_PERIOD_FAN); | 455 | ENE_FW_SAMPLE_PERIOD_FAN); |
456 | } else { | 456 | } else { |
457 | dev->rdev->rx_resolution = MS_TO_NS(sample_period); | 457 | dev->rdev->rx_resolution = US_TO_NS(sample_period); |
458 | 458 | ||
459 | /* Theoreticly timeout is unlimited, but we cap it | 459 | /* Theoreticly timeout is unlimited, but we cap it |
460 | * because it was seen that on one device, it | 460 | * because it was seen that on one device, it |
461 | * would stop sending spaces after around 250 msec. | 461 | * would stop sending spaces after around 250 msec. |
462 | * Besides, this is close to 2^32 anyway and timeout is u32. | 462 | * Besides, this is close to 2^32 anyway and timeout is u32. |
463 | */ | 463 | */ |
464 | dev->rdev->min_timeout = MS_TO_NS(127 * sample_period); | 464 | dev->rdev->min_timeout = US_TO_NS(127 * sample_period); |
465 | dev->rdev->max_timeout = MS_TO_NS(200000); | 465 | dev->rdev->max_timeout = US_TO_NS(200000); |
466 | } | 466 | } |
467 | 467 | ||
468 | if (dev->hw_learning_and_tx_capable) | 468 | if (dev->hw_learning_and_tx_capable) |
469 | dev->rdev->tx_resolution = MS_TO_NS(sample_period); | 469 | dev->rdev->tx_resolution = US_TO_NS(sample_period); |
470 | 470 | ||
471 | if (dev->rdev->timeout > dev->rdev->max_timeout) | 471 | if (dev->rdev->timeout > dev->rdev->max_timeout) |
472 | dev->rdev->timeout = dev->rdev->max_timeout; | 472 | dev->rdev->timeout = dev->rdev->max_timeout; |
@@ -801,7 +801,7 @@ static irqreturn_t ene_isr(int irq, void *data) | |||
801 | 801 | ||
802 | dbg("RX: %d (%s)", hw_sample, pulse ? "pulse" : "space"); | 802 | dbg("RX: %d (%s)", hw_sample, pulse ? "pulse" : "space"); |
803 | 803 | ||
804 | ev.duration = MS_TO_NS(hw_sample); | 804 | ev.duration = US_TO_NS(hw_sample); |
805 | ev.pulse = pulse; | 805 | ev.pulse = pulse; |
806 | ir_raw_event_store_with_filter(dev->rdev, &ev); | 806 | ir_raw_event_store_with_filter(dev->rdev, &ev); |
807 | } | 807 | } |
@@ -821,7 +821,7 @@ static void ene_setup_default_settings(struct ene_device *dev) | |||
821 | dev->learning_mode_enabled = learning_mode_force; | 821 | dev->learning_mode_enabled = learning_mode_force; |
822 | 822 | ||
823 | /* Set reasonable default timeout */ | 823 | /* Set reasonable default timeout */ |
824 | dev->rdev->timeout = MS_TO_NS(150000); | 824 | dev->rdev->timeout = US_TO_NS(150000); |
825 | } | 825 | } |
826 | 826 | ||
827 | /* Upload all hardware settings at once. Used at load and resume time */ | 827 | /* Upload all hardware settings at once. Used at load and resume time */ |
diff --git a/drivers/media/rc/ene_ir.h b/drivers/media/rc/ene_ir.h index c179baf34cb4..337a41d4450b 100644 --- a/drivers/media/rc/ene_ir.h +++ b/drivers/media/rc/ene_ir.h | |||
@@ -201,8 +201,6 @@ | |||
201 | #define dbg_verbose(format, ...) __dbg(2, format, ## __VA_ARGS__) | 201 | #define dbg_verbose(format, ...) __dbg(2, format, ## __VA_ARGS__) |
202 | #define dbg_regs(format, ...) __dbg(3, format, ## __VA_ARGS__) | 202 | #define dbg_regs(format, ...) __dbg(3, format, ## __VA_ARGS__) |
203 | 203 | ||
204 | #define MS_TO_NS(msec) ((msec) * 1000) | ||
205 | |||
206 | struct ene_device { | 204 | struct ene_device { |
207 | struct pnp_dev *pnp_dev; | 205 | struct pnp_dev *pnp_dev; |
208 | struct rc_dev *rdev; | 206 | struct rc_dev *rdev; |
diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c index 0fef6efad537..2d9113493cf0 100644 --- a/drivers/media/rc/mceusb.c +++ b/drivers/media/rc/mceusb.c | |||
@@ -48,7 +48,6 @@ | |||
48 | #define USB_BUFLEN 32 /* USB reception buffer length */ | 48 | #define USB_BUFLEN 32 /* USB reception buffer length */ |
49 | #define USB_CTRL_MSG_SZ 2 /* Size of usb ctrl msg on gen1 hw */ | 49 | #define USB_CTRL_MSG_SZ 2 /* Size of usb ctrl msg on gen1 hw */ |
50 | #define MCE_G1_INIT_MSGS 40 /* Init messages on gen1 hw to throw out */ | 50 | #define MCE_G1_INIT_MSGS 40 /* Init messages on gen1 hw to throw out */ |
51 | #define MS_TO_NS(msec) ((msec) * 1000) | ||
52 | 51 | ||
53 | /* MCE constants */ | 52 | /* MCE constants */ |
54 | #define MCE_CMDBUF_SIZE 384 /* MCE Command buffer length */ | 53 | #define MCE_CMDBUF_SIZE 384 /* MCE Command buffer length */ |
@@ -817,7 +816,7 @@ static void mceusb_handle_command(struct mceusb_dev *ir, int index) | |||
817 | switch (ir->buf_in[index]) { | 816 | switch (ir->buf_in[index]) { |
818 | /* 2-byte return value commands */ | 817 | /* 2-byte return value commands */ |
819 | case MCE_CMD_S_TIMEOUT: | 818 | case MCE_CMD_S_TIMEOUT: |
820 | ir->rc->timeout = MS_TO_NS((hi << 8 | lo) / 2); | 819 | ir->rc->timeout = MS_TO_US((hi << 8 | lo) / 2); |
821 | break; | 820 | break; |
822 | 821 | ||
823 | /* 1-byte return value commands */ | 822 | /* 1-byte return value commands */ |
@@ -858,7 +857,7 @@ static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len) | |||
858 | ir->rem--; | 857 | ir->rem--; |
859 | rawir.pulse = ((ir->buf_in[i] & MCE_PULSE_BIT) != 0); | 858 | rawir.pulse = ((ir->buf_in[i] & MCE_PULSE_BIT) != 0); |
860 | rawir.duration = (ir->buf_in[i] & MCE_PULSE_MASK) | 859 | rawir.duration = (ir->buf_in[i] & MCE_PULSE_MASK) |
861 | * MS_TO_NS(MCE_TIME_UNIT); | 860 | * MS_TO_US(MCE_TIME_UNIT); |
862 | 861 | ||
863 | dev_dbg(ir->dev, "Storing %s with duration %d\n", | 862 | dev_dbg(ir->dev, "Storing %s with duration %d\n", |
864 | rawir.pulse ? "pulse" : "space", | 863 | rawir.pulse ? "pulse" : "space", |
@@ -1061,7 +1060,7 @@ static struct rc_dev *mceusb_init_rc_dev(struct mceusb_dev *ir) | |||
1061 | rc->priv = ir; | 1060 | rc->priv = ir; |
1062 | rc->driver_type = RC_DRIVER_IR_RAW; | 1061 | rc->driver_type = RC_DRIVER_IR_RAW; |
1063 | rc->allowed_protos = RC_TYPE_ALL; | 1062 | rc->allowed_protos = RC_TYPE_ALL; |
1064 | rc->timeout = MS_TO_NS(1000); | 1063 | rc->timeout = MS_TO_US(1000); |
1065 | if (!ir->flags.no_tx) { | 1064 | if (!ir->flags.no_tx) { |
1066 | rc->s_tx_mask = mceusb_set_tx_mask; | 1065 | rc->s_tx_mask = mceusb_set_tx_mask; |
1067 | rc->s_tx_carrier = mceusb_set_tx_carrier; | 1066 | rc->s_tx_carrier = mceusb_set_tx_carrier; |