diff options
-rw-r--r-- | drivers/media/rc/ene_ir.c | 4 | ||||
-rw-r--r-- | drivers/media/rc/ene_ir.h | 2 | ||||
-rw-r--r-- | drivers/media/rc/ir-lirc-codec.c | 15 | ||||
-rw-r--r-- | drivers/media/rc/ite-cir.c | 5 | ||||
-rw-r--r-- | drivers/media/rc/mceusb.c | 10 | ||||
-rw-r--r-- | drivers/media/rc/nuvoton-cir.c | 12 | ||||
-rw-r--r-- | drivers/media/rc/rc-loopback.c | 13 | ||||
-rw-r--r-- | drivers/media/rc/winbond-cir.c | 6 | ||||
-rw-r--r-- | include/media/rc-core.h | 2 |
9 files changed, 25 insertions, 44 deletions
diff --git a/drivers/media/rc/ene_ir.c b/drivers/media/rc/ene_ir.c index a43ed6c41bfc..2b9c2569d74a 100644 --- a/drivers/media/rc/ene_ir.c +++ b/drivers/media/rc/ene_ir.c | |||
@@ -953,13 +953,13 @@ static void ene_set_idle(struct rc_dev *rdev, bool idle) | |||
953 | } | 953 | } |
954 | 954 | ||
955 | /* outside interface: transmit */ | 955 | /* outside interface: transmit */ |
956 | static int ene_transmit(struct rc_dev *rdev, int *buf, u32 n) | 956 | static int ene_transmit(struct rc_dev *rdev, unsigned *buf, unsigned n) |
957 | { | 957 | { |
958 | struct ene_device *dev = rdev->priv; | 958 | struct ene_device *dev = rdev->priv; |
959 | unsigned long flags; | 959 | unsigned long flags; |
960 | 960 | ||
961 | dev->tx_buffer = buf; | 961 | dev->tx_buffer = buf; |
962 | dev->tx_len = n / sizeof(int); | 962 | dev->tx_len = n; |
963 | dev->tx_pos = 0; | 963 | dev->tx_pos = 0; |
964 | dev->tx_reg = 0; | 964 | dev->tx_reg = 0; |
965 | dev->tx_done = 0; | 965 | dev->tx_done = 0; |
diff --git a/drivers/media/rc/ene_ir.h b/drivers/media/rc/ene_ir.h index 337a41d4450b..017c209cdf8a 100644 --- a/drivers/media/rc/ene_ir.h +++ b/drivers/media/rc/ene_ir.h | |||
@@ -235,7 +235,7 @@ struct ene_device { | |||
235 | bool tx_sample_pulse; /* current sample is pulse */ | 235 | bool tx_sample_pulse; /* current sample is pulse */ |
236 | 236 | ||
237 | /* TX buffer */ | 237 | /* TX buffer */ |
238 | int *tx_buffer; /* input samples buffer*/ | 238 | unsigned *tx_buffer; /* input samples buffer*/ |
239 | int tx_pos; /* position in that bufer */ | 239 | int tx_pos; /* position in that bufer */ |
240 | int tx_len; /* current len of tx buffer */ | 240 | int tx_len; /* current len of tx buffer */ |
241 | int tx_done; /* done transmitting */ | 241 | int tx_done; /* done transmitting */ |
diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c index 1c5cc65ea1e1..e5eeec4da76e 100644 --- a/drivers/media/rc/ir-lirc-codec.c +++ b/drivers/media/rc/ir-lirc-codec.c | |||
@@ -103,19 +103,19 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char *buf, | |||
103 | { | 103 | { |
104 | struct lirc_codec *lirc; | 104 | struct lirc_codec *lirc; |
105 | struct rc_dev *dev; | 105 | struct rc_dev *dev; |
106 | int *txbuf; /* buffer with values to transmit */ | 106 | unsigned int *txbuf; /* buffer with values to transmit */ |
107 | int ret = 0; | 107 | ssize_t ret = 0; |
108 | size_t count; | 108 | size_t count; |
109 | 109 | ||
110 | lirc = lirc_get_pdata(file); | 110 | lirc = lirc_get_pdata(file); |
111 | if (!lirc) | 111 | if (!lirc) |
112 | return -EFAULT; | 112 | return -EFAULT; |
113 | 113 | ||
114 | if (n % sizeof(int)) | 114 | if (n < sizeof(unsigned) || n % sizeof(unsigned)) |
115 | return -EINVAL; | 115 | return -EINVAL; |
116 | 116 | ||
117 | count = n / sizeof(int); | 117 | count = n / sizeof(unsigned); |
118 | if (count > LIRCBUF_SIZE || count % 2 == 0 || n % sizeof(int) != 0) | 118 | if (count > LIRCBUF_SIZE || count % 2 == 0) |
119 | return -EINVAL; | 119 | return -EINVAL; |
120 | 120 | ||
121 | txbuf = memdup_user(buf, n); | 121 | txbuf = memdup_user(buf, n); |
@@ -129,7 +129,10 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char *buf, | |||
129 | } | 129 | } |
130 | 130 | ||
131 | if (dev->tx_ir) | 131 | if (dev->tx_ir) |
132 | ret = dev->tx_ir(dev, txbuf, (u32)n); | 132 | ret = dev->tx_ir(dev, txbuf, count); |
133 | |||
134 | if (ret > 0) | ||
135 | ret *= sizeof(unsigned); | ||
133 | 136 | ||
134 | out: | 137 | out: |
135 | kfree(txbuf); | 138 | kfree(txbuf); |
diff --git a/drivers/media/rc/ite-cir.c b/drivers/media/rc/ite-cir.c index ecd3d0280768..1cee20761a3f 100644 --- a/drivers/media/rc/ite-cir.c +++ b/drivers/media/rc/ite-cir.c | |||
@@ -383,7 +383,7 @@ static int ite_set_tx_duty_cycle(struct rc_dev *rcdev, u32 duty_cycle) | |||
383 | /* transmit out IR pulses; what you get here is a batch of alternating | 383 | /* transmit out IR pulses; what you get here is a batch of alternating |
384 | * pulse/space/pulse/space lengths that we should write out completely through | 384 | * pulse/space/pulse/space lengths that we should write out completely through |
385 | * the FIFO, blocking on a full FIFO */ | 385 | * the FIFO, blocking on a full FIFO */ |
386 | static int ite_tx_ir(struct rc_dev *rcdev, int *txbuf, u32 n) | 386 | static int ite_tx_ir(struct rc_dev *rcdev, unsigned *txbuf, unsigned n) |
387 | { | 387 | { |
388 | unsigned long flags; | 388 | unsigned long flags; |
389 | struct ite_dev *dev = rcdev->priv; | 389 | struct ite_dev *dev = rcdev->priv; |
@@ -399,9 +399,6 @@ static int ite_tx_ir(struct rc_dev *rcdev, int *txbuf, u32 n) | |||
399 | /* clear the array just in case */ | 399 | /* clear the array just in case */ |
400 | memset(last_sent, 0, ARRAY_SIZE(last_sent)); | 400 | memset(last_sent, 0, ARRAY_SIZE(last_sent)); |
401 | 401 | ||
402 | /* n comes in bytes; convert to ints */ | ||
403 | n /= sizeof(int); | ||
404 | |||
405 | spin_lock_irqsave(&dev->lock, flags); | 402 | spin_lock_irqsave(&dev->lock, flags); |
406 | 403 | ||
407 | /* let everybody know we're now transmitting */ | 404 | /* let everybody know we're now transmitting */ |
diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c index ec972dc25790..85ff9a1ffb39 100644 --- a/drivers/media/rc/mceusb.c +++ b/drivers/media/rc/mceusb.c | |||
@@ -692,20 +692,18 @@ static void mce_flush_rx_buffer(struct mceusb_dev *ir, int size) | |||
692 | } | 692 | } |
693 | 693 | ||
694 | /* Send data out the IR blaster port(s) */ | 694 | /* Send data out the IR blaster port(s) */ |
695 | static int mceusb_tx_ir(struct rc_dev *dev, int *txbuf, u32 n) | 695 | static int mceusb_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned count) |
696 | { | 696 | { |
697 | struct mceusb_dev *ir = dev->priv; | 697 | struct mceusb_dev *ir = dev->priv; |
698 | int i, ret = 0; | 698 | int i, ret = 0; |
699 | int count, cmdcount = 0; | 699 | int cmdcount = 0; |
700 | unsigned char *cmdbuf; /* MCE command buffer */ | 700 | unsigned char *cmdbuf; /* MCE command buffer */ |
701 | long signal_duration = 0; /* Singnal length in us */ | 701 | long signal_duration = 0; /* Singnal length in us */ |
702 | struct timeval start_time, end_time; | 702 | struct timeval start_time, end_time; |
703 | 703 | ||
704 | do_gettimeofday(&start_time); | 704 | do_gettimeofday(&start_time); |
705 | 705 | ||
706 | count = n / sizeof(int); | 706 | cmdbuf = kzalloc(sizeof(unsigned) * MCE_CMDBUF_SIZE, GFP_KERNEL); |
707 | |||
708 | cmdbuf = kzalloc(sizeof(int) * MCE_CMDBUF_SIZE, GFP_KERNEL); | ||
709 | if (!cmdbuf) | 707 | if (!cmdbuf) |
710 | return -ENOMEM; | 708 | return -ENOMEM; |
711 | 709 | ||
@@ -774,7 +772,7 @@ static int mceusb_tx_ir(struct rc_dev *dev, int *txbuf, u32 n) | |||
774 | 772 | ||
775 | out: | 773 | out: |
776 | kfree(cmdbuf); | 774 | kfree(cmdbuf); |
777 | return ret ? ret : n; | 775 | return ret ? ret : count; |
778 | } | 776 | } |
779 | 777 | ||
780 | /* Sets active IR outputs -- mce devices typically have two */ | 778 | /* Sets active IR outputs -- mce devices typically have two */ |
diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c index ce595f9ab4c7..eae05b500476 100644 --- a/drivers/media/rc/nuvoton-cir.c +++ b/drivers/media/rc/nuvoton-cir.c | |||
@@ -546,24 +546,18 @@ static int nvt_set_tx_carrier(struct rc_dev *dev, u32 carrier) | |||
546 | * number may larger than TXFCONT (0xff). So in interrupt_handler, it has to | 546 | * number may larger than TXFCONT (0xff). So in interrupt_handler, it has to |
547 | * set TXFCONT as 0xff, until buf_count less than 0xff. | 547 | * set TXFCONT as 0xff, until buf_count less than 0xff. |
548 | */ | 548 | */ |
549 | static int nvt_tx_ir(struct rc_dev *dev, int *txbuf, u32 n) | 549 | static int nvt_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned n) |
550 | { | 550 | { |
551 | struct nvt_dev *nvt = dev->priv; | 551 | struct nvt_dev *nvt = dev->priv; |
552 | unsigned long flags; | 552 | unsigned long flags; |
553 | size_t cur_count; | ||
554 | unsigned int i; | 553 | unsigned int i; |
555 | u8 iren; | 554 | u8 iren; |
556 | int ret; | 555 | int ret; |
557 | 556 | ||
558 | spin_lock_irqsave(&nvt->tx.lock, flags); | 557 | spin_lock_irqsave(&nvt->tx.lock, flags); |
559 | 558 | ||
560 | if (n >= TX_BUF_LEN) { | 559 | ret = min((unsigned)(TX_BUF_LEN / sizeof(unsigned)), n); |
561 | nvt->tx.buf_count = cur_count = TX_BUF_LEN; | 560 | nvt->tx.buf_count = (ret * sizeof(unsigned)); |
562 | ret = TX_BUF_LEN; | ||
563 | } else { | ||
564 | nvt->tx.buf_count = cur_count = n; | ||
565 | ret = n; | ||
566 | } | ||
567 | 561 | ||
568 | memcpy(nvt->tx.buf, txbuf, nvt->tx.buf_count); | 562 | memcpy(nvt->tx.buf, txbuf, nvt->tx.buf_count); |
569 | 563 | ||
diff --git a/drivers/media/rc/rc-loopback.c b/drivers/media/rc/rc-loopback.c index cc846b2619cf..efc6a514348a 100644 --- a/drivers/media/rc/rc-loopback.c +++ b/drivers/media/rc/rc-loopback.c | |||
@@ -101,21 +101,14 @@ static int loop_set_rx_carrier_range(struct rc_dev *dev, u32 min, u32 max) | |||
101 | return 0; | 101 | return 0; |
102 | } | 102 | } |
103 | 103 | ||
104 | static int loop_tx_ir(struct rc_dev *dev, int *txbuf, u32 n) | 104 | static int loop_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned count) |
105 | { | 105 | { |
106 | struct loopback_dev *lodev = dev->priv; | 106 | struct loopback_dev *lodev = dev->priv; |
107 | u32 rxmask; | 107 | u32 rxmask; |
108 | unsigned count; | ||
109 | unsigned total_duration = 0; | 108 | unsigned total_duration = 0; |
110 | unsigned i; | 109 | unsigned i; |
111 | DEFINE_IR_RAW_EVENT(rawir); | 110 | DEFINE_IR_RAW_EVENT(rawir); |
112 | 111 | ||
113 | if (n == 0 || n % sizeof(int)) { | ||
114 | dprintk("invalid tx buffer size\n"); | ||
115 | return -EINVAL; | ||
116 | } | ||
117 | |||
118 | count = n / sizeof(int); | ||
119 | for (i = 0; i < count; i++) | 112 | for (i = 0; i < count; i++) |
120 | total_duration += abs(txbuf[i]); | 113 | total_duration += abs(txbuf[i]); |
121 | 114 | ||
@@ -142,7 +135,7 @@ static int loop_tx_ir(struct rc_dev *dev, int *txbuf, u32 n) | |||
142 | 135 | ||
143 | for (i = 0; i < count; i++) { | 136 | for (i = 0; i < count; i++) { |
144 | rawir.pulse = i % 2 ? false : true; | 137 | rawir.pulse = i % 2 ? false : true; |
145 | rawir.duration = abs(txbuf[i]) * 1000; | 138 | rawir.duration = txbuf[i] * 1000; |
146 | if (rawir.duration) | 139 | if (rawir.duration) |
147 | ir_raw_event_store_with_filter(dev, &rawir); | 140 | ir_raw_event_store_with_filter(dev, &rawir); |
148 | } | 141 | } |
@@ -158,7 +151,7 @@ out: | |||
158 | /* Lirc expects this function to take as long as the total duration */ | 151 | /* Lirc expects this function to take as long as the total duration */ |
159 | set_current_state(TASK_INTERRUPTIBLE); | 152 | set_current_state(TASK_INTERRUPTIBLE); |
160 | schedule_timeout(usecs_to_jiffies(total_duration)); | 153 | schedule_timeout(usecs_to_jiffies(total_duration)); |
161 | return n; | 154 | return count; |
162 | } | 155 | } |
163 | 156 | ||
164 | static void loop_set_idle(struct rc_dev *dev, bool enable) | 157 | static void loop_set_idle(struct rc_dev *dev, bool enable) |
diff --git a/drivers/media/rc/winbond-cir.c b/drivers/media/rc/winbond-cir.c index 18e70d104f80..bec8abc965f7 100644 --- a/drivers/media/rc/winbond-cir.c +++ b/drivers/media/rc/winbond-cir.c | |||
@@ -577,16 +577,12 @@ wbcir_txmask(struct rc_dev *dev, u32 mask) | |||
577 | } | 577 | } |
578 | 578 | ||
579 | static int | 579 | static int |
580 | wbcir_tx(struct rc_dev *dev, int *buf, u32 bufsize) | 580 | wbcir_tx(struct rc_dev *dev, unsigned *buf, unsigned count) |
581 | { | 581 | { |
582 | struct wbcir_data *data = dev->priv; | 582 | struct wbcir_data *data = dev->priv; |
583 | u32 count; | ||
584 | unsigned i; | 583 | unsigned i; |
585 | unsigned long flags; | 584 | unsigned long flags; |
586 | 585 | ||
587 | /* bufsize has been sanity checked by the caller */ | ||
588 | count = bufsize / sizeof(int); | ||
589 | |||
590 | /* Not sure if this is possible, but better safe than sorry */ | 586 | /* Not sure if this is possible, but better safe than sorry */ |
591 | spin_lock_irqsave(&data->spinlock, flags); | 587 | spin_lock_irqsave(&data->spinlock, flags); |
592 | if (data->txstate != WBCIR_TXSTATE_INACTIVE) { | 588 | if (data->txstate != WBCIR_TXSTATE_INACTIVE) { |
diff --git a/include/media/rc-core.h b/include/media/rc-core.h index 60536c74c1ea..b1f19b77ecd4 100644 --- a/include/media/rc-core.h +++ b/include/media/rc-core.h | |||
@@ -117,7 +117,7 @@ struct rc_dev { | |||
117 | int (*s_tx_carrier)(struct rc_dev *dev, u32 carrier); | 117 | int (*s_tx_carrier)(struct rc_dev *dev, u32 carrier); |
118 | int (*s_tx_duty_cycle)(struct rc_dev *dev, u32 duty_cycle); | 118 | int (*s_tx_duty_cycle)(struct rc_dev *dev, u32 duty_cycle); |
119 | int (*s_rx_carrier_range)(struct rc_dev *dev, u32 min, u32 max); | 119 | int (*s_rx_carrier_range)(struct rc_dev *dev, u32 min, u32 max); |
120 | int (*tx_ir)(struct rc_dev *dev, int *txbuf, u32 n); | 120 | int (*tx_ir)(struct rc_dev *dev, unsigned *txbuf, unsigned n); |
121 | void (*s_idle)(struct rc_dev *dev, bool enable); | 121 | void (*s_idle)(struct rc_dev *dev, bool enable); |
122 | int (*s_learning_mode)(struct rc_dev *dev, int enable); | 122 | int (*s_learning_mode)(struct rc_dev *dev, int enable); |
123 | int (*s_carrier_report) (struct rc_dev *dev, int enable); | 123 | int (*s_carrier_report) (struct rc_dev *dev, int enable); |