[media] staging/lirc: ioctl portability fixups
Signed-off-by: Jarod Wilson <jarod@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
be1f985ffa
commit
a126681810
@ -239,8 +239,7 @@ static ssize_t lirc_write(struct file *file, const char *buf,
|
|||||||
static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
|
static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
unsigned long value = 0;
|
__u32 value = 0;
|
||||||
unsigned int ivalue;
|
|
||||||
unsigned long hw_flags;
|
unsigned long hw_flags;
|
||||||
|
|
||||||
if (cmd == LIRC_GET_FEATURES)
|
if (cmd == LIRC_GET_FEATURES)
|
||||||
@ -256,24 +255,24 @@ static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
|
|||||||
case LIRC_GET_FEATURES:
|
case LIRC_GET_FEATURES:
|
||||||
case LIRC_GET_SEND_MODE:
|
case LIRC_GET_SEND_MODE:
|
||||||
case LIRC_GET_REC_MODE:
|
case LIRC_GET_REC_MODE:
|
||||||
retval = put_user(value, (unsigned long *) arg);
|
retval = put_user(value, (__u32 *) arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LIRC_SET_SEND_MODE:
|
case LIRC_SET_SEND_MODE:
|
||||||
case LIRC_SET_REC_MODE:
|
case LIRC_SET_REC_MODE:
|
||||||
retval = get_user(value, (unsigned long *) arg);
|
retval = get_user(value, (__u32 *) arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LIRC_SET_SEND_CARRIER:
|
case LIRC_SET_SEND_CARRIER:
|
||||||
retval = get_user(ivalue, (unsigned int *) arg);
|
retval = get_user(value, (__u32 *) arg);
|
||||||
if (retval)
|
if (retval)
|
||||||
return retval;
|
return retval;
|
||||||
ivalue /= 1000;
|
value /= 1000;
|
||||||
if (ivalue > IT87_CIR_FREQ_MAX ||
|
if (value > IT87_CIR_FREQ_MAX ||
|
||||||
ivalue < IT87_CIR_FREQ_MIN)
|
value < IT87_CIR_FREQ_MIN)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
it87_freq = ivalue;
|
it87_freq = value;
|
||||||
|
|
||||||
spin_lock_irqsave(&hardware_lock, hw_flags);
|
spin_lock_irqsave(&hardware_lock, hw_flags);
|
||||||
outb(((inb(io + IT87_CIR_TCR2) & IT87_CIR_TCR2_TXMPW) |
|
outb(((inb(io + IT87_CIR_TCR2) & IT87_CIR_TCR2_TXMPW) |
|
||||||
|
@ -102,8 +102,8 @@ struct ite8709_device {
|
|||||||
int io;
|
int io;
|
||||||
int irq;
|
int irq;
|
||||||
spinlock_t hardware_lock;
|
spinlock_t hardware_lock;
|
||||||
unsigned long long acc_pulse;
|
__u64 acc_pulse;
|
||||||
unsigned long long acc_space;
|
__u64 acc_space;
|
||||||
char lastbit;
|
char lastbit;
|
||||||
struct timeval last_tv;
|
struct timeval last_tv;
|
||||||
struct lirc_driver driver;
|
struct lirc_driver driver;
|
||||||
@ -220,7 +220,7 @@ static void ite8709_set_use_dec(void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void ite8709_add_read_queue(struct ite8709_device *dev, int flag,
|
static void ite8709_add_read_queue(struct ite8709_device *dev, int flag,
|
||||||
unsigned long long val)
|
__u64 val)
|
||||||
{
|
{
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
|
@ -301,9 +301,9 @@ static void irq_handler(void *blah)
|
|||||||
|
|
||||||
if (signal != 0) {
|
if (signal != 0) {
|
||||||
/* ajust value to usecs */
|
/* ajust value to usecs */
|
||||||
unsigned long long helper;
|
__u64 helper;
|
||||||
|
|
||||||
helper = ((unsigned long long) signal)*1000000;
|
helper = ((__u64) signal)*1000000;
|
||||||
do_div(helper, timer);
|
do_div(helper, timer);
|
||||||
signal = (long) helper;
|
signal = (long) helper;
|
||||||
|
|
||||||
@ -404,9 +404,9 @@ static ssize_t lirc_write(struct file *filep, const char *buf, size_t n,
|
|||||||
|
|
||||||
/* adjust values from usecs */
|
/* adjust values from usecs */
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
unsigned long long helper;
|
__u64 helper;
|
||||||
|
|
||||||
helper = ((unsigned long long) wbuf[i])*timer;
|
helper = ((__u64) wbuf[i])*timer;
|
||||||
do_div(helper, 1000000);
|
do_div(helper, 1000000);
|
||||||
wbuf[i] = (int) helper;
|
wbuf[i] = (int) helper;
|
||||||
}
|
}
|
||||||
@ -464,48 +464,48 @@ static unsigned int lirc_poll(struct file *file, poll_table *wait)
|
|||||||
static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
|
static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
unsigned long features = LIRC_CAN_SET_TRANSMITTER_MASK |
|
__u32 features = LIRC_CAN_SET_TRANSMITTER_MASK |
|
||||||
LIRC_CAN_SEND_PULSE | LIRC_CAN_REC_MODE2;
|
LIRC_CAN_SEND_PULSE | LIRC_CAN_REC_MODE2;
|
||||||
unsigned long mode;
|
__u32 mode;
|
||||||
unsigned int ivalue;
|
__u32 value;
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case LIRC_GET_FEATURES:
|
case LIRC_GET_FEATURES:
|
||||||
result = put_user(features, (unsigned long *) arg);
|
result = put_user(features, (__u32 *) arg);
|
||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
break;
|
break;
|
||||||
case LIRC_GET_SEND_MODE:
|
case LIRC_GET_SEND_MODE:
|
||||||
result = put_user(LIRC_MODE_PULSE, (unsigned long *) arg);
|
result = put_user(LIRC_MODE_PULSE, (__u32 *) arg);
|
||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
break;
|
break;
|
||||||
case LIRC_GET_REC_MODE:
|
case LIRC_GET_REC_MODE:
|
||||||
result = put_user(LIRC_MODE_MODE2, (unsigned long *) arg);
|
result = put_user(LIRC_MODE_MODE2, (__u32 *) arg);
|
||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
break;
|
break;
|
||||||
case LIRC_SET_SEND_MODE:
|
case LIRC_SET_SEND_MODE:
|
||||||
result = get_user(mode, (unsigned long *) arg);
|
result = get_user(mode, (__u32 *) arg);
|
||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
if (mode != LIRC_MODE_PULSE)
|
if (mode != LIRC_MODE_PULSE)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
break;
|
break;
|
||||||
case LIRC_SET_REC_MODE:
|
case LIRC_SET_REC_MODE:
|
||||||
result = get_user(mode, (unsigned long *) arg);
|
result = get_user(mode, (__u32 *) arg);
|
||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
if (mode != LIRC_MODE_MODE2)
|
if (mode != LIRC_MODE_MODE2)
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
break;
|
break;
|
||||||
case LIRC_SET_TRANSMITTER_MASK:
|
case LIRC_SET_TRANSMITTER_MASK:
|
||||||
result = get_user(ivalue, (unsigned int *) arg);
|
result = get_user(value, (__u32 *) arg);
|
||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
if ((ivalue & LIRC_PARALLEL_TRANSMITTER_MASK) != ivalue)
|
if ((value & LIRC_PARALLEL_TRANSMITTER_MASK) != value)
|
||||||
return LIRC_PARALLEL_MAX_TRANSMITTERS;
|
return LIRC_PARALLEL_MAX_TRANSMITTERS;
|
||||||
tx_mask = ivalue;
|
tx_mask = value;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return -ENOIOCTLCMD;
|
return -ENOIOCTLCMD;
|
||||||
|
@ -372,7 +372,7 @@ static unsigned long conv_us_to_clocks;
|
|||||||
static int init_timing_params(unsigned int new_duty_cycle,
|
static int init_timing_params(unsigned int new_duty_cycle,
|
||||||
unsigned int new_freq)
|
unsigned int new_freq)
|
||||||
{
|
{
|
||||||
unsigned long long loops_per_sec, work;
|
__u64 loops_per_sec, work;
|
||||||
|
|
||||||
duty_cycle = new_duty_cycle;
|
duty_cycle = new_duty_cycle;
|
||||||
freq = new_freq;
|
freq = new_freq;
|
||||||
@ -987,8 +987,7 @@ static ssize_t lirc_write(struct file *file, const char *buf,
|
|||||||
static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
|
static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
unsigned long value;
|
__u32 value;
|
||||||
unsigned int ivalue;
|
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case LIRC_GET_SEND_MODE:
|
case LIRC_GET_SEND_MODE:
|
||||||
@ -997,7 +996,7 @@ static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
|
|||||||
|
|
||||||
result = put_user(LIRC_SEND2MODE
|
result = put_user(LIRC_SEND2MODE
|
||||||
(hardware[type].features&LIRC_CAN_SEND_MASK),
|
(hardware[type].features&LIRC_CAN_SEND_MASK),
|
||||||
(unsigned long *) arg);
|
(__u32 *) arg);
|
||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
break;
|
break;
|
||||||
@ -1006,7 +1005,7 @@ static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
|
|||||||
if (!(hardware[type].features&LIRC_CAN_SEND_MASK))
|
if (!(hardware[type].features&LIRC_CAN_SEND_MASK))
|
||||||
return -ENOIOCTLCMD;
|
return -ENOIOCTLCMD;
|
||||||
|
|
||||||
result = get_user(value, (unsigned long *) arg);
|
result = get_user(value, (__u32 *) arg);
|
||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
/* only LIRC_MODE_PULSE supported */
|
/* only LIRC_MODE_PULSE supported */
|
||||||
@ -1023,12 +1022,12 @@ static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
|
|||||||
if (!(hardware[type].features&LIRC_CAN_SET_SEND_DUTY_CYCLE))
|
if (!(hardware[type].features&LIRC_CAN_SET_SEND_DUTY_CYCLE))
|
||||||
return -ENOIOCTLCMD;
|
return -ENOIOCTLCMD;
|
||||||
|
|
||||||
result = get_user(ivalue, (unsigned int *) arg);
|
result = get_user(value, (__u32 *) arg);
|
||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
if (ivalue <= 0 || ivalue > 100)
|
if (value <= 0 || value > 100)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
return init_timing_params(ivalue, freq);
|
return init_timing_params(value, freq);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LIRC_SET_SEND_CARRIER:
|
case LIRC_SET_SEND_CARRIER:
|
||||||
@ -1036,12 +1035,12 @@ static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
|
|||||||
if (!(hardware[type].features&LIRC_CAN_SET_SEND_CARRIER))
|
if (!(hardware[type].features&LIRC_CAN_SET_SEND_CARRIER))
|
||||||
return -ENOIOCTLCMD;
|
return -ENOIOCTLCMD;
|
||||||
|
|
||||||
result = get_user(ivalue, (unsigned int *) arg);
|
result = get_user(value, (__u32 *) arg);
|
||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
if (ivalue > 500000 || ivalue < 20000)
|
if (value > 500000 || value < 20000)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
return init_timing_params(duty_cycle, ivalue);
|
return init_timing_params(duty_cycle, value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -336,9 +336,8 @@ static ssize_t lirc_write(struct file *file, const char *buf, size_t n,
|
|||||||
static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
|
static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
unsigned long value = 0;
|
__u32 value = 0;
|
||||||
#ifdef LIRC_ON_SA1100
|
#ifdef LIRC_ON_SA1100
|
||||||
unsigned int ivalue;
|
|
||||||
|
|
||||||
if (cmd == LIRC_GET_FEATURES)
|
if (cmd == LIRC_GET_FEATURES)
|
||||||
value = LIRC_CAN_SEND_PULSE |
|
value = LIRC_CAN_SEND_PULSE |
|
||||||
@ -362,22 +361,22 @@ static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
|
|||||||
case LIRC_GET_FEATURES:
|
case LIRC_GET_FEATURES:
|
||||||
case LIRC_GET_SEND_MODE:
|
case LIRC_GET_SEND_MODE:
|
||||||
case LIRC_GET_REC_MODE:
|
case LIRC_GET_REC_MODE:
|
||||||
retval = put_user(value, (unsigned long *) arg);
|
retval = put_user(value, (__u32 *) arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LIRC_SET_SEND_MODE:
|
case LIRC_SET_SEND_MODE:
|
||||||
case LIRC_SET_REC_MODE:
|
case LIRC_SET_REC_MODE:
|
||||||
retval = get_user(value, (unsigned long *) arg);
|
retval = get_user(value, (__u32 *) arg);
|
||||||
break;
|
break;
|
||||||
#ifdef LIRC_ON_SA1100
|
#ifdef LIRC_ON_SA1100
|
||||||
case LIRC_SET_SEND_DUTY_CYCLE:
|
case LIRC_SET_SEND_DUTY_CYCLE:
|
||||||
retval = get_user(ivalue, (unsigned int *) arg);
|
retval = get_user(value, (__u32 *) arg);
|
||||||
if (retval)
|
if (retval)
|
||||||
return retval;
|
return retval;
|
||||||
if (ivalue <= 0 || ivalue > 100)
|
if (value <= 0 || value > 100)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
/* (ivalue/100)*(1000000/freq) */
|
/* (value/100)*(1000000/freq) */
|
||||||
duty_cycle = ivalue;
|
duty_cycle = value;
|
||||||
pulse_width = (unsigned long) duty_cycle*10000/freq;
|
pulse_width = (unsigned long) duty_cycle*10000/freq;
|
||||||
space_width = (unsigned long) 1000000L/freq-pulse_width;
|
space_width = (unsigned long) 1000000L/freq-pulse_width;
|
||||||
if (pulse_width >= LIRC_ON_SA1100_TRANSMITTER_LATENCY)
|
if (pulse_width >= LIRC_ON_SA1100_TRANSMITTER_LATENCY)
|
||||||
@ -386,12 +385,12 @@ static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
|
|||||||
space_width -= LIRC_ON_SA1100_TRANSMITTER_LATENCY;
|
space_width -= LIRC_ON_SA1100_TRANSMITTER_LATENCY;
|
||||||
break;
|
break;
|
||||||
case LIRC_SET_SEND_CARRIER:
|
case LIRC_SET_SEND_CARRIER:
|
||||||
retval = get_user(ivalue, (unsigned int *) arg);
|
retval = get_user(value, (__u32 *) arg);
|
||||||
if (retval)
|
if (retval)
|
||||||
return retval;
|
return retval;
|
||||||
if (ivalue > 500000 || ivalue < 20000)
|
if (value > 500000 || value < 20000)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
freq = ivalue;
|
freq = value;
|
||||||
pulse_width = (unsigned long) duty_cycle*10000/freq;
|
pulse_width = (unsigned long) duty_cycle*10000/freq;
|
||||||
space_width = (unsigned long) 1000000L/freq-pulse_width;
|
space_width = (unsigned long) 1000000L/freq-pulse_width;
|
||||||
if (pulse_width >= LIRC_ON_SA1100_TRANSMITTER_LATENCY)
|
if (pulse_width >= LIRC_ON_SA1100_TRANSMITTER_LATENCY)
|
||||||
|
Loading…
Reference in New Issue
Block a user