Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5588dc2b authored by David Härdeman's avatar David Härdeman Committed by Mauro Carvalho Chehab
Browse files

[media] rc-core: lirc use unsigned int



Durations can never be negative, so it makes sense to consistently use
unsigned int for LIRC transmission. Contrary to the initial impression,
this shouldn't actually change the userspace API.

Signed-off-by: default avatarDavid Härdeman <david@hardeman.nu>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 8a8cc952
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -953,13 +953,13 @@ static void ene_set_idle(struct rc_dev *rdev, bool idle)
}

/* outside interface: transmit */
static int ene_transmit(struct rc_dev *rdev, int *buf, u32 n)
static int ene_transmit(struct rc_dev *rdev, unsigned *buf, unsigned n)
{
	struct ene_device *dev = rdev->priv;
	unsigned long flags;

	dev->tx_buffer = buf;
	dev->tx_len = n / sizeof(int);
	dev->tx_len = n;
	dev->tx_pos = 0;
	dev->tx_reg = 0;
	dev->tx_done = 0;
+1 −1
Original line number Diff line number Diff line
@@ -235,7 +235,7 @@ struct ene_device {
	bool tx_sample_pulse;			/* current sample is pulse */

	/* TX buffer */
	int *tx_buffer;				/* input samples buffer*/
	unsigned *tx_buffer;			/* input samples buffer*/
	int tx_pos;				/* position in that bufer */
	int tx_len;				/* current len of tx buffer */
	int tx_done;				/* done transmitting */
+9 −6
Original line number Diff line number Diff line
@@ -103,19 +103,19 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char *buf,
{
	struct lirc_codec *lirc;
	struct rc_dev *dev;
	int *txbuf; /* buffer with values to transmit */
	int ret = 0;
	unsigned int *txbuf; /* buffer with values to transmit */
	ssize_t ret = 0;
	size_t count;

	lirc = lirc_get_pdata(file);
	if (!lirc)
		return -EFAULT;

	if (n % sizeof(int))
	if (n < sizeof(unsigned) || n % sizeof(unsigned))
		return -EINVAL;

	count = n / sizeof(int);
	if (count > LIRCBUF_SIZE || count % 2 == 0 || n % sizeof(int) != 0)
	count = n / sizeof(unsigned);
	if (count > LIRCBUF_SIZE || count % 2 == 0)
		return -EINVAL;

	txbuf = memdup_user(buf, n);
@@ -129,7 +129,10 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char *buf,
	}

	if (dev->tx_ir)
		ret = dev->tx_ir(dev, txbuf, (u32)n);
		ret = dev->tx_ir(dev, txbuf, count);

	if (ret > 0)
		ret *= sizeof(unsigned);

out:
	kfree(txbuf);
+1 −4
Original line number Diff line number Diff line
@@ -383,7 +383,7 @@ static int ite_set_tx_duty_cycle(struct rc_dev *rcdev, u32 duty_cycle)
/* transmit out IR pulses; what you get here is a batch of alternating
 * pulse/space/pulse/space lengths that we should write out completely through
 * the FIFO, blocking on a full FIFO */
static int ite_tx_ir(struct rc_dev *rcdev, int *txbuf, u32 n)
static int ite_tx_ir(struct rc_dev *rcdev, unsigned *txbuf, unsigned n)
{
	unsigned long flags;
	struct ite_dev *dev = rcdev->priv;
@@ -399,9 +399,6 @@ static int ite_tx_ir(struct rc_dev *rcdev, int *txbuf, u32 n)
	/* clear the array just in case */
	memset(last_sent, 0, ARRAY_SIZE(last_sent));

	/* n comes in bytes; convert to ints */
	n /= sizeof(int);

	spin_lock_irqsave(&dev->lock, flags);

	/* let everybody know we're now transmitting */
+4 −6
Original line number Diff line number Diff line
@@ -692,20 +692,18 @@ static void mce_flush_rx_buffer(struct mceusb_dev *ir, int size)
}

/* Send data out the IR blaster port(s) */
static int mceusb_tx_ir(struct rc_dev *dev, int *txbuf, u32 n)
static int mceusb_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned count)
{
	struct mceusb_dev *ir = dev->priv;
	int i, ret = 0;
	int count, cmdcount = 0;
	int cmdcount = 0;
	unsigned char *cmdbuf; /* MCE command buffer */
	long signal_duration = 0; /* Singnal length in us */
	struct timeval start_time, end_time;

	do_gettimeofday(&start_time);

	count = n / sizeof(int);

	cmdbuf = kzalloc(sizeof(int) * MCE_CMDBUF_SIZE, GFP_KERNEL);
	cmdbuf = kzalloc(sizeof(unsigned) * MCE_CMDBUF_SIZE, GFP_KERNEL);
	if (!cmdbuf)
		return -ENOMEM;

@@ -774,7 +772,7 @@ static int mceusb_tx_ir(struct rc_dev *dev, int *txbuf, u32 n)

out:
	kfree(cmdbuf);
	return ret ? ret : n;
	return ret ? ret : count;
}

/* Sets active IR outputs -- mce devices typically have two */
Loading