diff options
Diffstat (limited to 'drivers/staging/lirc')
-rw-r--r-- | drivers/staging/lirc/Kconfig | 2 | ||||
-rw-r--r-- | drivers/staging/lirc/lirc_igorplugusb.c | 190 | ||||
-rw-r--r-- | drivers/staging/lirc/lirc_imon.c | 16 | ||||
-rw-r--r-- | drivers/staging/lirc/lirc_it87.c | 23 | ||||
-rw-r--r-- | drivers/staging/lirc/lirc_ite8709.c | 6 | ||||
-rw-r--r-- | drivers/staging/lirc/lirc_parallel.c | 62 | ||||
-rw-r--r-- | drivers/staging/lirc/lirc_sasem.c | 15 | ||||
-rw-r--r-- | drivers/staging/lirc/lirc_serial.c | 24 | ||||
-rw-r--r-- | drivers/staging/lirc/lirc_sir.c | 24 | ||||
-rw-r--r-- | drivers/staging/lirc/lirc_zilog.c | 13 |
10 files changed, 192 insertions, 183 deletions
diff --git a/drivers/staging/lirc/Kconfig b/drivers/staging/lirc/Kconfig index 100c4d4b8125..fa790db75d7e 100644 --- a/drivers/staging/lirc/Kconfig +++ b/drivers/staging/lirc/Kconfig @@ -53,7 +53,7 @@ config LIRC_ITE8709 config LIRC_PARALLEL tristate "Homebrew Parallel Port Receiver" - depends on LIRC_STAGING && PARPORT && !SMP + depends on LIRC_STAGING && PARPORT help Driver for Homebrew Parallel Port Receivers diff --git a/drivers/staging/lirc/lirc_igorplugusb.c b/drivers/staging/lirc/lirc_igorplugusb.c index bce600ede263..0dc2c2b22c2b 100644 --- a/drivers/staging/lirc/lirc_igorplugusb.c +++ b/drivers/staging/lirc/lirc_igorplugusb.c @@ -54,10 +54,10 @@ /* module identification */ -#define DRIVER_VERSION "0.1" +#define DRIVER_VERSION "0.2" #define DRIVER_AUTHOR \ "Jan M. Hochstein <hochstein@algo.informatik.tu-darmstadt.de>" -#define DRIVER_DESC "USB remote driver for LIRC" +#define DRIVER_DESC "Igorplug USB remote driver for LIRC" #define DRIVER_NAME "lirc_igorplugusb" /* debugging support */ @@ -201,7 +201,6 @@ struct igorplug { /* usb */ struct usb_device *usbdev; - struct urb *urb_in; int devnum; unsigned char *buf_in; @@ -216,28 +215,36 @@ struct igorplug { /* handle sending (init strings) */ int send_flags; - wait_queue_head_t wait_out; }; static int unregister_from_lirc(struct igorplug *ir) { - struct lirc_driver *d = ir->d; + struct lirc_driver *d; int devnum; - if (!ir->d) + if (!ir) { + printk(KERN_ERR "%s: called with NULL device struct!\n", + __func__); return -EINVAL; + } devnum = ir->devnum; - dprintk(DRIVER_NAME "[%d]: unregister from lirc called\n", devnum); + d = ir->d; - lirc_unregister_driver(d->minor); + if (!d) { + printk(KERN_ERR "%s: called with NULL lirc driver struct!\n", + __func__); + return -EINVAL; + } - printk(DRIVER_NAME "[%d]: usb remote disconnected\n", devnum); + dprintk(DRIVER_NAME "[%d]: calling lirc_unregister_driver\n", devnum); + lirc_unregister_driver(d->minor); kfree(d); ir->d = NULL; kfree(ir); - return 0; + + return devnum; } static int set_use_inc(void *data) @@ -248,6 +255,7 @@ static int set_use_inc(void *data) printk(DRIVER_NAME "[?]: set_use_inc called with no context\n"); return -EIO; } + dprintk(DRIVER_NAME "[%d]: set use inc\n", ir->devnum); if (!ir->usbdev) @@ -264,9 +272,29 @@ static void set_use_dec(void *data) printk(DRIVER_NAME "[?]: set_use_dec called with no context\n"); return; } + dprintk(DRIVER_NAME "[%d]: set use dec\n", ir->devnum); } +static void send_fragment(struct igorplug *ir, struct lirc_buffer *buf, + int i, int max) +{ + int code; + + /* MODE2: pulse/space (PULSE_BIT) in 1us units */ + while (i < max) { + /* 1 Igor-tick = 85.333333 us */ + code = (unsigned int)ir->buf_in[i] * 85 + + (unsigned int)ir->buf_in[i] / 3; + ir->last_time.tv_usec += code; + if (ir->in_space) + code |= PULSE_BIT; + lirc_buffer_write(buf, (unsigned char *)&code); + /* 1 chunk = CODE_LENGTH bytes */ + ir->in_space ^= 1; + ++i; + } +} /** * Called in user context. @@ -274,41 +302,32 @@ static void set_use_dec(void *data) * -ENODATA if none was available. This should add some number of bits * evenly divisible by code_length to the buffer */ -static int usb_remote_poll(void *data, struct lirc_buffer *buf) +static int igorplugusb_remote_poll(void *data, struct lirc_buffer *buf) { int ret; struct igorplug *ir = (struct igorplug *)data; - if (!ir->usbdev) /* Has the device been removed? */ + if (!ir || !ir->usbdev) /* Has the device been removed? */ return -ENODEV; memset(ir->buf_in, 0, ir->len_in); - ret = usb_control_msg( - ir->usbdev, usb_rcvctrlpipe(ir->usbdev, 0), - GET_INFRACODE, USB_TYPE_VENDOR|USB_DIR_IN, - 0/* offset */, /*unused*/0, - ir->buf_in, ir->len_in, - /*timeout*/HZ * USB_CTRL_GET_TIMEOUT); + ret = usb_control_msg(ir->usbdev, usb_rcvctrlpipe(ir->usbdev, 0), + GET_INFRACODE, USB_TYPE_VENDOR | USB_DIR_IN, + 0/* offset */, /*unused*/0, + ir->buf_in, ir->len_in, + /*timeout*/HZ * USB_CTRL_GET_TIMEOUT); if (ret > 0) { - int i = DEVICE_HEADERLEN; int code, timediff; struct timeval now; - if (ret <= 1) /* ACK packet has 1 byte --> ignore */ + /* ACK packet has 1 byte --> ignore */ + if (ret < DEVICE_HEADERLEN) return -ENODATA; dprintk(DRIVER_NAME ": Got %d bytes. Header: %02x %02x %02x\n", ret, ir->buf_in[0], ir->buf_in[1], ir->buf_in[2]); - if (ir->buf_in[2] != 0) { - printk(DRIVER_NAME "[%d]: Device buffer overrun.\n", - ir->devnum); - /* start at earliest byte */ - i = DEVICE_HEADERLEN + ir->buf_in[2]; - /* where are we now? space, gap or pulse? */ - } - do_gettimeofday(&now); timediff = now.tv_sec - ir->last_time.tv_sec; if (timediff + 1 > PULSE_MASK / 1000000) @@ -325,18 +344,20 @@ static int usb_remote_poll(void *data, struct lirc_buffer *buf) lirc_buffer_write(buf, (unsigned char *)&code); ir->in_space = 1; /* next comes a pulse */ - /* MODE2: pulse/space (PULSE_BIT) in 1us units */ - - while (i < ret) { - /* 1 Igor-tick = 85.333333 us */ - code = (unsigned int)ir->buf_in[i] * 85 - + (unsigned int)ir->buf_in[i] / 3; - if (ir->in_space) - code |= PULSE_BIT; - lirc_buffer_write(buf, (unsigned char *)&code); - /* 1 chunk = CODE_LENGTH bytes */ - ir->in_space ^= 1; - ++i; + if (ir->buf_in[2] == 0) + send_fragment(ir, buf, DEVICE_HEADERLEN, ret); + else { + printk(KERN_WARNING DRIVER_NAME + "[%d]: Device buffer overrun.\n", ir->devnum); + /* HHHNNNNNNNNNNNOOOOOOOO H = header + <---[2]---> N = newer + <---------ret--------> O = older */ + ir->buf_in[2] %= ret - DEVICE_HEADERLEN; /* sanitize */ + /* keep even-ness to not desync pulse/pause */ + send_fragment(ir, buf, DEVICE_HEADERLEN + + ir->buf_in[2] - (ir->buf_in[2] & 1), ret); + send_fragment(ir, buf, DEVICE_HEADERLEN, + DEVICE_HEADERLEN + ir->buf_in[2]); } ret = usb_control_msg( @@ -358,12 +379,12 @@ static int usb_remote_poll(void *data, struct lirc_buffer *buf) -static int usb_remote_probe(struct usb_interface *intf, - const struct usb_device_id *id) +static int igorplugusb_remote_probe(struct usb_interface *intf, + const struct usb_device_id *id) { struct usb_device *dev = NULL; struct usb_host_interface *idesc = NULL; - struct usb_host_endpoint *ep_ctl2; + struct usb_endpoint_descriptor *ep; struct igorplug *ir = NULL; struct lirc_driver *driver = NULL; int devnum, pipe, maxp; @@ -380,20 +401,21 @@ static int usb_remote_probe(struct usb_interface *intf, if (idesc->desc.bNumEndpoints != 1) return -ENODEV; - ep_ctl2 = idesc->endpoint; - if (((ep_ctl2->desc.bEndpointAddress & USB_ENDPOINT_DIR_MASK) + + ep = &idesc->endpoint->desc; + if (((ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) != USB_DIR_IN) - || (ep_ctl2->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) + || (ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_CONTROL) return -ENODEV; - pipe = usb_rcvctrlpipe(dev, ep_ctl2->desc.bEndpointAddress); + + pipe = usb_rcvctrlpipe(dev, ep->bEndpointAddress); devnum = dev->devnum; maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); - dprintk(DRIVER_NAME "[%d]: bytes_in_key=%lu maxp=%d\n", + dprintk(DRIVER_NAME "[%d]: bytes_in_key=%zu maxp=%d\n", devnum, CODE_LENGTH, maxp); - mem_failure = 0; ir = kzalloc(sizeof(struct igorplug), GFP_KERNEL); if (!ir) { @@ -406,9 +428,8 @@ static int usb_remote_probe(struct usb_interface *intf, goto mem_failure_switch; } - ir->buf_in = usb_alloc_coherent(dev, - DEVICE_BUFLEN+DEVICE_HEADERLEN, - GFP_ATOMIC, &ir->dma_in); + ir->buf_in = usb_alloc_coherent(dev, DEVICE_BUFLEN + DEVICE_HEADERLEN, + GFP_ATOMIC, &ir->dma_in); if (!ir->buf_in) { mem_failure = 3; goto mem_failure_switch; @@ -424,12 +445,10 @@ static int usb_remote_probe(struct usb_interface *intf, driver->set_use_inc = &set_use_inc; driver->set_use_dec = &set_use_dec; driver->sample_rate = sample_rate; /* per second */ - driver->add_to_buf = &usb_remote_poll; + driver->add_to_buf = &igorplugusb_remote_poll; driver->dev = &intf->dev; driver->owner = THIS_MODULE; - init_waitqueue_head(&ir->wait_out); - minor = lirc_register_driver(driver); if (minor < 0) mem_failure = 9; @@ -438,7 +457,7 @@ mem_failure_switch: switch (mem_failure) { case 9: - usb_free_coherent(dev, DEVICE_BUFLEN+DEVICE_HEADERLEN, + usb_free_coherent(dev, DEVICE_BUFLEN + DEVICE_HEADERLEN, ir->buf_in, ir->dma_in); case 3: kfree(driver); @@ -454,7 +473,7 @@ mem_failure_switch: ir->d = driver; ir->devnum = devnum; ir->usbdev = dev; - ir->len_in = DEVICE_BUFLEN+DEVICE_HEADERLEN; + ir->len_in = DEVICE_BUFLEN + DEVICE_HEADERLEN; ir->in_space = 1; /* First mode2 event is a space. */ do_gettimeofday(&ir->last_time); @@ -484,63 +503,64 @@ mem_failure_switch: } -static void usb_remote_disconnect(struct usb_interface *intf) +static void igorplugusb_remote_disconnect(struct usb_interface *intf) { - struct usb_device *dev = interface_to_usbdev(intf); + struct usb_device *usbdev = interface_to_usbdev(intf); struct igorplug *ir = usb_get_intfdata(intf); + struct device *dev = &intf->dev; + int devnum; + usb_set_intfdata(intf, NULL); if (!ir || !ir->d) return; ir->usbdev = NULL; - wake_up_all(&ir->wait_out); - usb_free_coherent(dev, ir->len_in, ir->buf_in, ir->dma_in); + usb_free_coherent(usbdev, ir->len_in, ir->buf_in, ir->dma_in); + + devnum = unregister_from_lirc(ir); - unregister_from_lirc(ir); + dev_info(dev, DRIVER_NAME "[%d]: %s done\n", devnum, __func__); } -static struct usb_device_id usb_remote_id_table[] = { +static struct usb_device_id igorplugusb_remote_id_table[] = { /* Igor Plug USB (Atmel's Manufact. ID) */ { USB_DEVICE(0x03eb, 0x0002) }, + /* Fit PC2 Infrared Adapter */ + { USB_DEVICE(0x03eb, 0x21fe) }, /* Terminating entry */ { } }; -static struct usb_driver usb_remote_driver = { +static struct usb_driver igorplugusb_remote_driver = { .name = DRIVER_NAME, - .probe = usb_remote_probe, - .disconnect = usb_remote_disconnect, - .id_table = usb_remote_id_table + .probe = igorplugusb_remote_probe, + .disconnect = igorplugusb_remote_disconnect, + .id_table = igorplugusb_remote_id_table }; -static int __init usb_remote_init(void) +static int __init igorplugusb_remote_init(void) { - int i; + int ret = 0; - printk(KERN_INFO "\n" - DRIVER_NAME ": " DRIVER_DESC " v" DRIVER_VERSION "\n"); - printk(DRIVER_NAME ": " DRIVER_AUTHOR "\n"); - dprintk(DRIVER_NAME ": debug mode enabled\n"); + dprintk(DRIVER_NAME ": loaded, debug mode enabled\n"); - i = usb_register(&usb_remote_driver); - if (i < 0) { - printk(DRIVER_NAME ": usb register failed, result = %d\n", i); - return -ENODEV; - } + ret = usb_register(&igorplugusb_remote_driver); + if (ret) + printk(KERN_ERR DRIVER_NAME ": usb register failed!\n"); - return 0; + return ret; } -static void __exit usb_remote_exit(void) +static void __exit igorplugusb_remote_exit(void) { - usb_deregister(&usb_remote_driver); + usb_deregister(&igorplugusb_remote_driver); } -module_init(usb_remote_init); -module_exit(usb_remote_exit); +module_init(igorplugusb_remote_init); +module_exit(igorplugusb_remote_exit); #include <linux/vermagic.h> MODULE_INFO(vermagic, VERMAGIC_STRING); @@ -548,8 +568,10 @@ MODULE_INFO(vermagic, VERMAGIC_STRING); MODULE_DESCRIPTION(DRIVER_DESC); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_LICENSE("GPL"); -MODULE_DEVICE_TABLE(usb, usb_remote_id_table); +MODULE_DEVICE_TABLE(usb, igorplugusb_remote_id_table); module_param(sample_rate, int, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(sample_rate, "Sampling rate in Hz (default: 100)"); +module_param(debug, bool, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(debug, "Debug enabled or not"); diff --git a/drivers/staging/lirc/lirc_imon.c b/drivers/staging/lirc/lirc_imon.c index ed5c5fe022c9..0da6b9518af9 100644 --- a/drivers/staging/lirc/lirc_imon.c +++ b/drivers/staging/lirc/lirc_imon.c @@ -278,7 +278,7 @@ static int display_close(struct inode *inode, struct file *file) struct imon_context *context = NULL; int retval = 0; - context = (struct imon_context *)file->private_data; + context = file->private_data; if (!context) { err("%s: no context for device", __func__); @@ -321,7 +321,6 @@ static int send_packet(struct imon_context *context) unsigned int pipe; int interval = 0; int retval = 0; - struct usb_ctrlrequest *control_req = NULL; /* Check if we need to use control or interrupt urb */ pipe = usb_sndintpipe(context->usbdev, @@ -356,8 +355,6 @@ static int send_packet(struct imon_context *context) err("%s: packet tx failed (%d)", __func__, retval); } - kfree(control_req); - return retval; } @@ -384,7 +381,7 @@ static ssize_t vfd_write(struct file *file, const char *buf, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF }; int *data_buf; - context = (struct imon_context *)file->private_data; + context = file->private_data; if (!context) { err("%s: no context for device", __func__); return -ENODEV; @@ -600,7 +597,7 @@ static void imon_incoming_packet(struct imon_context *context, struct device *dev = context->driver->dev; int octet, bit; unsigned char mask; - int i, chunk_num; + int i; /* * just bail out if no listening IR client @@ -659,7 +656,7 @@ static void imon_incoming_packet(struct imon_context *context, } } - if (chunk_num == 10) { + if (buf[7] == 10) { if (context->rx.count) { submit_data(context); context->rx.count = 0; @@ -877,7 +874,7 @@ static int imon_probe(struct usb_interface *interface, if (lirc_minor < 0) { err("%s: lirc_register_driver failed", __func__); alloc_status = 7; - goto alloc_status_switch; + goto unlock; } else dev_info(dev, "Registered iMON driver " "(lirc minor: %d)\n", lirc_minor); @@ -933,8 +930,9 @@ static int imon_probe(struct usb_interface *interface, "usb<%d:%d> initialized\n", vendor, product, ifnum, usbdev->bus->busnum, usbdev->devnum); -alloc_status_switch: +unlock: mutex_unlock(&context->ctx_lock); +alloc_status_switch: switch (alloc_status) { case 7: diff --git a/drivers/staging/lirc/lirc_it87.c b/drivers/staging/lirc/lirc_it87.c index 543c5c3bf907..929ae5795467 100644 --- a/drivers/staging/lirc/lirc_it87.c +++ b/drivers/staging/lirc/lirc_it87.c @@ -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) { int retval = 0; - unsigned long value = 0; - unsigned int ivalue; + __u32 value = 0; unsigned long hw_flags; 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_SEND_MODE: case LIRC_GET_REC_MODE: - retval = put_user(value, (unsigned long *) arg); + retval = put_user(value, (__u32 *) arg); break; case LIRC_SET_SEND_MODE: case LIRC_SET_REC_MODE: - retval = get_user(value, (unsigned long *) arg); + retval = get_user(value, (__u32 *) arg); break; case LIRC_SET_SEND_CARRIER: - retval = get_user(ivalue, (unsigned int *) arg); + retval = get_user(value, (__u32 *) arg); if (retval) return retval; - ivalue /= 1000; - if (ivalue > IT87_CIR_FREQ_MAX || - ivalue < IT87_CIR_FREQ_MIN) + value /= 1000; + if (value > IT87_CIR_FREQ_MAX || + value < IT87_CIR_FREQ_MIN) return -EINVAL; - it87_freq = ivalue; + it87_freq = value; spin_lock_irqsave(&hardware_lock, hw_flags); outb(((inb(io + IT87_CIR_TCR2) & IT87_CIR_TCR2_TXMPW) | @@ -340,6 +339,9 @@ static const struct file_operations lirc_fops = { .write = lirc_write, .poll = lirc_poll, .unlocked_ioctl = lirc_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = lirc_ioctl, +#endif .open = lirc_open, .release = lirc_close, .llseek = noop_llseek, @@ -964,10 +966,11 @@ static void __exit lirc_it87_exit(void) printk(KERN_INFO LIRC_DRIVER_NAME ": Uninstalled.\n"); } -/* SECTION: PNP for ITE8704/18 */ +/* SECTION: PNP for ITE8704/13/18 */ static const struct pnp_device_id pnp_dev_table[] = { {"ITE8704", 0}, + {"ITE8713", 0}, {} }; diff --git a/drivers/staging/lirc/lirc_ite8709.c b/drivers/staging/lirc/lirc_ite8709.c index 9352f45bbece..cb20cfdcfadd 100644 --- a/drivers/staging/lirc/lirc_ite8709.c +++ b/drivers/staging/lirc/lirc_ite8709.c @@ -102,8 +102,8 @@ struct ite8709_device { int io; int irq; spinlock_t hardware_lock; - unsigned long long acc_pulse; - unsigned long long acc_space; + __u64 acc_pulse; + __u64 acc_space; char lastbit; struct timeval last_tv; 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, - unsigned long long val) + __u64 val) { int value; diff --git a/drivers/staging/lirc/lirc_parallel.c b/drivers/staging/lirc/lirc_parallel.c index 6da4a8c6ebc3..dfd2c447e67d 100644 --- a/drivers/staging/lirc/lirc_parallel.c +++ b/drivers/staging/lirc/lirc_parallel.c @@ -24,10 +24,6 @@ /*** Includes ***/ -#ifdef CONFIG_SMP -#error "--- Sorry, this driver is not SMP safe. ---" -#endif - #include <linux/module.h> #include <linux/sched.h> #include <linux/errno.h> @@ -40,7 +36,6 @@ #include <linux/delay.h> #include <linux/io.h> -#include <linux/signal.h> #include <linux/irq.h> #include <linux/uaccess.h> #include <asm/div64.h> @@ -301,9 +296,9 @@ static void irq_handler(void *blah) if (signal != 0) { /* ajust value to usecs */ - unsigned long long helper; + __u64 helper; - helper = ((unsigned long long) signal)*1000000; + helper = ((__u64) signal)*1000000; do_div(helper, timer); signal = (long) helper; @@ -404,9 +399,9 @@ static ssize_t lirc_write(struct file *filep, const char *buf, size_t n, /* adjust values from usecs */ 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); wbuf[i] = (int) helper; } @@ -464,48 +459,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) { int result; - unsigned long features = LIRC_CAN_SET_TRANSMITTER_MASK | - LIRC_CAN_SEND_PULSE | LIRC_CAN_REC_MODE2; - unsigned long mode; - unsigned int ivalue; + __u32 features = LIRC_CAN_SET_TRANSMITTER_MASK | + LIRC_CAN_SEND_PULSE | LIRC_CAN_REC_MODE2; + __u32 mode; + __u32 value; switch (cmd) { case LIRC_GET_FEATURES: - result = put_user(features, (unsigned long *) arg); + result = put_user(features, (__u32 *) arg); if (result) return result; break; case LIRC_GET_SEND_MODE: - result = put_user(LIRC_MODE_PULSE, (unsigned long *) arg); + result = put_user(LIRC_MODE_PULSE, (__u32 *) arg); if (result) return result; break; case LIRC_GET_REC_MODE: - result = put_user(LIRC_MODE_MODE2, (unsigned long *) arg); + result = put_user(LIRC_MODE_MODE2, (__u32 *) arg); if (result) return result; break; case LIRC_SET_SEND_MODE: - result = get_user(mode, (unsigned long *) arg); + result = get_user(mode, (__u32 *) arg); if (result) return result; if (mode != LIRC_MODE_PULSE) return -EINVAL; break; case LIRC_SET_REC_MODE: - result = get_user(mode, (unsigned long *) arg); + result = get_user(mode, (__u32 *) arg); if (result) return result; if (mode != LIRC_MODE_MODE2) return -ENOSYS; break; case LIRC_SET_TRANSMITTER_MASK: - result = get_user(ivalue, (unsigned int *) arg); + result = get_user(value, (__u32 *) arg); if (result) return result; - if ((ivalue & LIRC_PARALLEL_TRANSMITTER_MASK) != ivalue) + if ((value & LIRC_PARALLEL_TRANSMITTER_MASK) != value) return LIRC_PARALLEL_MAX_TRANSMITTERS; - tx_mask = ivalue; + tx_mask = value; break; default: return -ENOIOCTLCMD; @@ -546,6 +541,9 @@ static const struct file_operations lirc_fops = { .write = lirc_write, .poll = lirc_poll, .unlocked_ioctl = lirc_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = lirc_ioctl, +#endif .open = lirc_open, .release = lirc_close }; @@ -576,28 +574,6 @@ static struct lirc_driver driver = { static int pf(void *handle); static void kf(void *handle); -static struct timer_list poll_timer; -static void poll_state(unsigned long ignored); - -static void poll_state(unsigned long ignored) -{ - printk(KERN_NOTICE "%s: time\n", - LIRC_DRIVER_NAME); - del_timer(&poll_timer); - if (is_claimed) - return; - kf(NULL); - if (!is_claimed) { - printk(KERN_NOTICE "%s: could not claim port, giving up\n", - LIRC_DRIVER_NAME); - init_timer(&poll_timer); - poll_timer.expires = jiffies + HZ; - poll_timer.data = (unsigned long)current; - poll_timer.function = poll_state; - add_timer(&poll_timer); - } -} - static int pf(void *handle) { parport_disable_irq(pport); diff --git a/drivers/staging/lirc/lirc_sasem.c b/drivers/staging/lirc/lirc_sasem.c index 8f72a84f34ec..998485ebdbce 100644 --- a/drivers/staging/lirc/lirc_sasem.c +++ b/drivers/staging/lirc/lirc_sasem.c @@ -387,8 +387,10 @@ static ssize_t vfd_write(struct file *file, const char *buf, } data_buf = memdup_user(buf, n_bytes); - if (PTR_ERR(data_buf)) - return PTR_ERR(data_buf); + if (IS_ERR(data_buf)) { + retval = PTR_ERR(data_buf); + goto exit; + } memcpy(context->tx.data_buf, data_buf, n_bytes); @@ -513,7 +515,7 @@ exit: mutex_unlock(&context->ctx_lock); mutex_unlock(&disconnect_lock); - return 0; + return retval; } /** @@ -804,7 +806,8 @@ static int sasem_probe(struct usb_interface *interface, if (lirc_minor < 0) { err("%s: lirc_register_driver failed", __func__); alloc_status = 7; - mutex_unlock(&context->ctx_lock); + retval = lirc_minor; + goto unlock; } else printk(KERN_INFO "%s: Registered Sasem driver (minor:%d)\n", __func__, lirc_minor); @@ -829,7 +832,7 @@ alloc_status_switch: context = NULL; case 1: retval = -ENOMEM; - goto exit; + goto unlock; } /* Needed while unregistering! */ @@ -860,7 +863,7 @@ alloc_status_switch: printk(KERN_INFO "%s: Sasem device on usb<%d:%d> initialized\n", __func__, dev->bus->busnum, dev->devnum); - +unlock: mutex_unlock(&context->ctx_lock); exit: return retval; diff --git a/drivers/staging/lirc/lirc_serial.c b/drivers/staging/lirc/lirc_serial.c index 8da382492612..971844bbee28 100644 --- a/drivers/staging/lirc/lirc_serial.c +++ b/drivers/staging/lirc/lirc_serial.c @@ -372,7 +372,7 @@ static unsigned long conv_us_to_clocks; static int init_timing_params(unsigned int new_duty_cycle, unsigned int new_freq) { - unsigned long long loops_per_sec, work; + __u64 loops_per_sec, work; duty_cycle = new_duty_cycle; 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) { int result; - unsigned long value; - unsigned int ivalue; + __u32 value; switch (cmd) { 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 (hardware[type].features&LIRC_CAN_SEND_MASK), - (unsigned long *) arg); + (__u32 *) arg); if (result) return result; 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)) return -ENOIOCTLCMD; - result = get_user(value, (unsigned long *) arg); + result = get_user(value, (__u32 *) arg); if (result) return result; /* 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)) return -ENOIOCTLCMD; - result = get_user(ivalue, (unsigned int *) arg); + result = get_user(value, (__u32 *) arg); if (result) return result; - if (ivalue <= 0 || ivalue > 100) + if (value <= 0 || value > 100) return -EINVAL; - return init_timing_params(ivalue, freq); + return init_timing_params(value, freq); break; 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)) return -ENOIOCTLCMD; - result = get_user(ivalue, (unsigned int *) arg); + result = get_user(value, (__u32 *) arg); if (result) return result; - if (ivalue > 500000 || ivalue < 20000) + if (value > 500000 || value < 20000) return -EINVAL; - return init_timing_params(duty_cycle, ivalue); + return init_timing_params(duty_cycle, value); break; default: @@ -1054,6 +1053,9 @@ static const struct file_operations lirc_fops = { .owner = THIS_MODULE, .write = lirc_write, .unlocked_ioctl = lirc_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = lirc_ioctl, +#endif .read = lirc_dev_fop_read, .poll = lirc_dev_fop_poll, .open = lirc_dev_fop_open, diff --git a/drivers/staging/lirc/lirc_sir.c b/drivers/staging/lirc/lirc_sir.c index 2478871bd95e..c553ab626238 100644 --- a/drivers/staging/lirc/lirc_sir.c +++ b/drivers/staging/lirc/lirc_sir.c @@ -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) { int retval = 0; - unsigned long value = 0; + __u32 value = 0; #ifdef LIRC_ON_SA1100 - unsigned int ivalue; if (cmd == LIRC_GET_FEATURES) 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_SEND_MODE: case LIRC_GET_REC_MODE: - retval = put_user(value, (unsigned long *) arg); + retval = put_user(value, (__u32 *) arg); break; case LIRC_SET_SEND_MODE: case LIRC_SET_REC_MODE: - retval = get_user(value, (unsigned long *) arg); + retval = get_user(value, (__u32 *) arg); break; #ifdef LIRC_ON_SA1100 case LIRC_SET_SEND_DUTY_CYCLE: - retval = get_user(ivalue, (unsigned int *) arg); + retval = get_user(value, (__u32 *) arg); if (retval) return retval; - if (ivalue <= 0 || ivalue > 100) + if (value <= 0 || value > 100) return -EINVAL; - /* (ivalue/100)*(1000000/freq) */ - duty_cycle = ivalue; + /* (value/100)*(1000000/freq) */ + duty_cycle = value; pulse_width = (unsigned long) duty_cycle*10000/freq; space_width = (unsigned long) 1000000L/freq-pulse_width; 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; break; case LIRC_SET_SEND_CARRIER: - retval = get_user(ivalue, (unsigned int *) arg); + retval = get_user(value, (__u32 *) arg); if (retval) return retval; - if (ivalue > 500000 || ivalue < 20000) + if (value > 500000 || value < 20000) return -EINVAL; - freq = ivalue; + freq = value; pulse_width = (unsigned long) duty_cycle*10000/freq; space_width = (unsigned long) 1000000L/freq-pulse_width; if (pulse_width >= LIRC_ON_SA1100_TRANSMITTER_LATENCY) @@ -457,6 +456,9 @@ static const struct file_operations lirc_fops = { .write = lirc_write, .poll = lirc_poll, .unlocked_ioctl = lirc_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = lirc_ioctl, +#endif .open = lirc_dev_fop_open, .release = lirc_dev_fop_close, .llseek = no_llseek, diff --git a/drivers/staging/lirc/lirc_zilog.c b/drivers/staging/lirc/lirc_zilog.c index 100caab10451..f0076eb025f1 100644 --- a/drivers/staging/lirc/lirc_zilog.c +++ b/drivers/staging/lirc/lirc_zilog.c @@ -716,7 +716,7 @@ static loff_t lseek(struct file *filep, loff_t offset, int orig) /* copied from lirc_dev */ static ssize_t read(struct file *filep, char *outbuf, size_t n, loff_t *ppos) { - struct IR *ir = (struct IR *)filep->private_data; + struct IR *ir = filep->private_data; unsigned char buf[ir->buf.chunk_size]; int ret = 0, written = 0; DECLARE_WAITQUEUE(wait, current); @@ -898,7 +898,7 @@ done: static ssize_t write(struct file *filep, const char *buf, size_t n, loff_t *ppos) { - struct IR *ir = (struct IR *)filep->private_data; + struct IR *ir = filep->private_data; size_t i; int failures = 0; @@ -972,7 +972,7 @@ static ssize_t write(struct file *filep, const char *buf, size_t n, /* copied from lirc_dev */ static unsigned int poll(struct file *filep, poll_table *wait) { - struct IR *ir = (struct IR *)filep->private_data; + struct IR *ir = filep->private_data; unsigned int ret; dprintk("poll called\n"); @@ -994,7 +994,7 @@ static unsigned int poll(struct file *filep, poll_table *wait) static long ioctl(struct file *filep, unsigned int cmd, unsigned long arg) { - struct IR *ir = (struct IR *)filep->private_data; + struct IR *ir = filep->private_data; int result; unsigned long mode, features = 0; @@ -1086,7 +1086,7 @@ static int open(struct inode *node, struct file *filep) static int close(struct inode *node, struct file *filep) { /* find our IR struct */ - struct IR *ir = (struct IR *)filep->private_data; + struct IR *ir = filep->private_data; if (ir == NULL) { zilog_error("close: no private_data attached to the file!\n"); return -ENODEV; @@ -1139,6 +1139,9 @@ static const struct file_operations lirc_fops = { .write = write, .poll = poll, .unlocked_ioctl = ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = ioctl, +#endif .open = open, .release = close }; |