Re: [PATCH 09/10] rc-core: lirc use unsigned int

2011-06-11 Thread Mauro Carvalho Chehab
Em 06-05-2011 06:46, David Härdeman escreveu:
 On Wed, 04 May 2011 12:23:03 -0300, Mauro Carvalho Chehab
 mche...@redhat.com wrote:
 Em 28-04-2011 12:13, David Härdeman escreveu:
 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.

 Patch looked ok to me (except for one small issue - see bellow). 

 ...
 diff --git a/drivers/media/rc/ene_ir.c b/drivers/media/rc/ene_ir.c
 index 569b07b..2b1d2df 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)
  }
  
  /* 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;

 That hunk seems wrong to me. Or is it a bug fix that you're solving?
 
 My fault, I didn't mention in the patch description that the third
 argument of the tx function is also changed to mean array size rather
 than size in number of bytes.

Sorry for the long delay. Got sidetracked with other things.

Patch applied.

Thanks,
Mauro
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 09/10] rc-core: lirc use unsigned int

2011-05-06 Thread David Härdeman
On Wed, 04 May 2011 12:23:03 -0300, Mauro Carvalho Chehab
mche...@redhat.com wrote:
 Em 28-04-2011 12:13, David Härdeman escreveu:
 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.
 
 Patch looked ok to me (except for one small issue - see bellow). 
 
...
 diff --git a/drivers/media/rc/ene_ir.c b/drivers/media/rc/ene_ir.c
 index 569b07b..2b1d2df 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)
  }
  
  /* 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;
 
 That hunk seems wrong to me. Or is it a bug fix that you're solving?

My fault, I didn't mention in the patch description that the third
argument of the tx function is also changed to mean array size rather
than size in number of bytes.

-- 
David Härdeman
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 09/10] rc-core: lirc use unsigned int

2011-05-04 Thread Mauro Carvalho Chehab
Em 28-04-2011 12:13, David Härdeman escreveu:
 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.

Patch looked ok to me (except for one small issue - see bellow). 

 
 Signed-off-by: David Härdeman da...@hardeman.nu
 ---
  drivers/media/rc/ene_ir.c|4 ++--
  drivers/media/rc/ene_ir.h|2 +-
  drivers/media/rc/ir-lirc-codec.c |   15 +--
  drivers/media/rc/ite-cir.c   |5 +
  drivers/media/rc/mceusb.c|   10 --
  drivers/media/rc/nuvoton-cir.c   |   12 +++-
  drivers/media/rc/rc-loopback.c   |   13 +++--
  drivers/media/rc/winbond-cir.c   |6 +-
  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 569b07b..2b1d2df 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)
  }
  
  /* 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;

That hunk seems wrong to me. Or is it a bug fix that you're solving?

   dev-tx_pos = 0;
   dev-tx_reg = 0;
   dev-tx_done = 0;
 diff --git a/drivers/media/rc/ene_ir.h b/drivers/media/rc/ene_ir.h
 index 337a41d..017c209 100644
 --- a/drivers/media/rc/ene_ir.h
 +++ b/drivers/media/rc/ene_ir.h
 @@ -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 */
 diff --git a/drivers/media/rc/ir-lirc-codec.c 
 b/drivers/media/rc/ir-lirc-codec.c
 index b4119f8..ac54139 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,
  {
   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);
 diff --git a/drivers/media/rc/ite-cir.c b/drivers/media/rc/ite-cir.c
 index 3d13fcb..e8f7847 100644
 --- a/drivers/media/rc/ite-cir.c
 +++ b/drivers/media/rc/ite-cir.c
 @@ -381,7 +381,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;
 @@ -397,9 +397,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 */
 diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c
 index c51e7c2..c1cd00d 100644
 --- a/drivers/media/rc/mceusb.c
 +++ b/drivers/media/rc/mceusb.c
 @@ -665,20 +665,18 @@ static void mce_sync_in(struct mceusb_dev *ir, unsigned 
 char *data, int size)
  }
  
  /* Send data out the IR blaster port(s) */
 -static int 

[PATCH 09/10] rc-core: lirc use unsigned int

2011-04-28 Thread David Härdeman
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: David Härdeman da...@hardeman.nu
---
 drivers/media/rc/ene_ir.c|4 ++--
 drivers/media/rc/ene_ir.h|2 +-
 drivers/media/rc/ir-lirc-codec.c |   15 +--
 drivers/media/rc/ite-cir.c   |5 +
 drivers/media/rc/mceusb.c|   10 --
 drivers/media/rc/nuvoton-cir.c   |   12 +++-
 drivers/media/rc/rc-loopback.c   |   13 +++--
 drivers/media/rc/winbond-cir.c   |6 +-
 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 569b07b..2b1d2df 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)
 }
 
 /* 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;
diff --git a/drivers/media/rc/ene_ir.h b/drivers/media/rc/ene_ir.h
index 337a41d..017c209 100644
--- a/drivers/media/rc/ene_ir.h
+++ b/drivers/media/rc/ene_ir.h
@@ -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 */
diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c
index b4119f8..ac54139 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,
 {
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);
diff --git a/drivers/media/rc/ite-cir.c b/drivers/media/rc/ite-cir.c
index 3d13fcb..e8f7847 100644
--- a/drivers/media/rc/ite-cir.c
+++ b/drivers/media/rc/ite-cir.c
@@ -381,7 +381,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;
@@ -397,9 +397,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 */
diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c
index c51e7c2..c1cd00d 100644
--- a/drivers/media/rc/mceusb.c
+++ b/drivers/media/rc/mceusb.c
@@ -665,20 +665,18 @@ static void mce_sync_in(struct mceusb_dev *ir, unsigned 
char *data, 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