aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/rc/lirc_dev.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2016-07-13[media] lirc_dev: use LIRC_CAN_REC() define to check if the device can receiveAndi Shyti1-2/+2
The LIRC_CAN_REC() returns a boolean "flag & LIRC_CAN_REC_MASK" to check whether the device can receive data. Signed-off-by: Andi Shyti <andi.shyti@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-07-13[media] lirc_dev: fix potential segfaultAndi Shyti1-3/+8
When opening or closing a lirc character device, the framework provides to the user the possibility to keep track of opening or closing of the device by calling two functions: - set_use_inc() when opening the device - set_use_dec() when closing the device if those are not set by the lirc user, the system segfaults. Check the pointer value before calling the above functions. Signed-off-by: Andi Shyti <andi.shyti@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-07-13[media] lirc_dev: extremely trivial comment style fixAndi Shyti1-1/+2
Signed-off-by: Andi Shyti <andi.shyti@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-07-13[media] lirc_dev: fix error return valueAndi Shyti1-4/+4
If ioctl is called, it cannot be a case of invalid system call number (ENOSYS), that is a ENOTTY case which means that the device doesn't support that specific ioctl command. So, replace ENOSYS with ENOTTY. Signed-off-by: Andi Shyti <andi.shyti@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-07-13[media] lirc_dev: fix variable constant comparisonsAndi Shyti1-3/+3
When comparing a variable with a constant, the comparison should start from the variable and not from the constant. It's also written in the human DNA. Swap the terms of comparisons whenever the constant comes first and fix the following checkpatch warning: WARNING: Comparisons should place the constant on the right side of the test Signed-off-by: Andi Shyti <andi.shyti@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-07-13[media] lirc_dev: merge three if statements in only oneAndi Shyti1-8/+3
The three if statements check the same thing, merge them in only one statement. Signed-off-by: Andi Shyti <andi.shyti@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-07-13[media] lirc_dev: remove double if ... else statementAndi Shyti1-7/+5
There are two if ... else which check the same thing in different part of the code, they can be merged in a single check. Signed-off-by: Andi Shyti <andi.shyti@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-07-13[media] lirc_dev: simplify if statement in lirc_add_to_bufAndi Shyti1-16/+15
The whole function is inside an 'if' statement ("if (ir->d.add_to_buf)"). Check the opposite of that statement at the beginning and exit, this way we can have one level less of indentation. Signed-off-by: Andi Shyti <andi.shyti@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-07-13[media] lirc_dev: do not use goto to create loopsAndi Shyti1-6/+4
... use "do .. while" instead. Signed-off-by: Andi Shyti <andi.shyti@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-07-13[media] lirc_dev: simplify goto pathsAndi Shyti1-22/+12
The code can be rearranged so that some goto paths can be removed Signed-off-by: Andi Shyti <andi.shyti@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-07-13[media] lirc_dev: replace printk with pr_* or dev_*Andi Shyti1-45/+34
This patch mutes also all the checkpatch warnings related to printk. Reword all the printouts so that the string doesn't need to be split, which fixes the following checkpatch warning: WARNING: quoted string split across lines Signed-off-by: Andi Shyti <andi.shyti@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-07-13[media] lirc_dev: remove unnecessary debug printsAndi Shyti1-25/+0
Signed-off-by: Andi Shyti <andi.shyti@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-07-13[media] lirc_dev: allow bufferless driver registrationAndi Shyti1-10/+30
Transmitters don't necessarily need to have a FIFO managed buffer for their transfers. When registering the driver, before allocating the buffer, check whether the device is a transmitter or receiver. Allocate the buffer only for receivers. Signed-off-by: Andi Shyti <andi.shyti@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-07-13[media] lirc_dev: place buffer allocation on separate functionAndi Shyti1-23/+34
During the driver registration, move the buffer allocation on a separate function. Signed-off-by: Andi Shyti <andi.shyti@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-03-01[media] lirc_dev: avoid double mutex unlockMauro Carvalho Chehab1-2/+5
We can only unlock if mutex_lock() succeeds. Fixes the following warning: drivers/media/rc/lirc_dev.c:535 lirc_dev_fop_close() error: double unlock 'mutex:&lirc_dev_lock' Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03[media] lirc_dev: avoid potential null-dereferenceAndy Shevchenko1-3/+3
We have to check pointer for NULL and then dereference it. Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-11-25[media] rc: Deletion of unnecessary checks before two function callsMarkus Elfring1-2/+1
The functions input_free_device() and rc_close() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-09-03[media] lirc_dev: fix sparse warningsHans Verkuil1-7/+7
drivers/media/rc/lirc_dev.c:598:26: warning: incorrect type in argument 1 (different address spaces) drivers/media/rc/lirc_dev.c:606:26: warning: incorrect type in argument 1 (different address spaces) drivers/media/rc/lirc_dev.c:616:26: warning: incorrect type in argument 1 (different address spaces) drivers/media/rc/lirc_dev.c:625:26: warning: incorrect type in argument 1 (different address spaces) drivers/media/rc/lirc_dev.c:634:26: warning: incorrect type in argument 1 (different address spaces) drivers/media/rc/lirc_dev.c:643:26: warning: incorrect type in argument 1 (different address spaces) drivers/media/rc/lirc_dev.c:739:45: warning: cast removes address space of expression drivers/media/rc/lirc_dev.c:739:58: warning: incorrect type in argument 1 (different address spaces) Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2013-07-31[media] media: lirc: Allow lirc dev to talk to rc deviceSrinivas Kandagatla1-0/+10
The use case is simple, if any rc device has allowed protocols = RC_TYPE_LIRC and map_name = RC_MAP_LIRC set, the driver open will be never called. The reason for this is, all of the key maps except lirc have some KEYS in there map, so during rc_register_device process these keys are matched against the input drivers and open is performed, so for the case of RC_MAP_EMPTY, a vt/keyboard is matched and the driver open is performed. In case of lirc, there is no match and result is that there is no open performed, however the lirc-dev will go ahead and create a /dev/lirc0 node. Now when lircd/mode2 opens this device, no data is available because the driver was never opened. Other case pointed by Sean Young, As rc device gets opened via the input interface. If the input device is never opened (e.g. embedded with no console) then the rc open is never called and lirc will not work either. So that's another case. lirc_dev seems to have no link with actual rc device w.r.t open/close. This patch adds rc_dev pointer to lirc_driver structure for cases like this, so that it can do the open/close of the real driver in accordance to lircd/mode2 open/close. Without this patch its impossible to open a rc device which has RC_TYPE_LIRC ad RC_MAP_LIRC set. Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@st.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2013-04-09constify a bunch of struct file_operations instancesAl Viro1-1/+1
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2013-02-26lirc: get rid of bogus checksAl Viro1-10/+1
file argument is a struct file being passed to ->open() or already opened; none of the checks in lirc_get_pdata() can fail. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2013-02-22new helper: file_inode(file)Al Viro1-7/+7
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-01-13module_param: make bool parameters really bool (drivers & misc)Rusty Russell1-1/+1
module_param(bool) used to counter-intuitively take an int. In fddd5201 (mid-2009) we allowed bool or int/unsigned int using a messy trick. It's time to remove the int/unsigned int option. For this version it'll simply give a warning, but it'll break next kernel version. Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-06-11[media] lirc_dev: store cdev in irctl, up maxdevsJarod Wilson1-10/+27
Store the cdev pointer in struct irctl, allocated dynamically as needed, rather than having a static array. At the same time, recycle some of the saved memory to nudge the maximum number of lirc devices supported up a ways -- its not that uncommon these days, now that we have the rc-core lirc bridge driver, to see a system with at least 4 raw IR receivers. (consider a mythtv backend with several video capture devices and the possible need for IR transmit hardware). Signed-off-by: Jarod Wilson <jarod@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-12-29[media] media: rc: lirc_dev: check kobject_set_name() resultVasiliy Kulikov1-1/+3
kobject_set_name() may fail with -ENOMEM, check for it. Signed-off-by: Vasiliy Kulikov <segoon@openwall.com> Acked-by: Jarod Wilson <jarod@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-12-29[media] lirc_dev: add some __user annotationsDan Carpenter1-2/+2
Sparse complains because there are no __user annotations. drivers/media/rc/lirc_dev.c:156:27: warning: incorrect type in initializer (incompatible argument 2 (different address spaces)) drivers/media/rc/lirc_dev.c:156:27: expected int ( *read )( ... ) drivers/media/rc/lirc_dev.c:156:27: got int ( extern [toplevel] *<noident> )( ... ) Signed-off-by: Dan Carpenter <error27@gmail.com> Acked-by: Jarod Wilson <jarod@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-12-29[media] rename drivers/media/IR to drives/media/rcMauro Carvalho Chehab1-0/+814
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>