|
@@ -15,7 +15,6 @@
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
|
#include <media/rc-core.h>
|
|
#include <media/rc-core.h>
|
|
-#include <linux/atomic.h>
|
|
|
|
#include <linux/spinlock.h>
|
|
#include <linux/spinlock.h>
|
|
#include <linux/delay.h>
|
|
#include <linux/delay.h>
|
|
#include <linux/input.h>
|
|
#include <linux/input.h>
|
|
@@ -934,8 +933,8 @@ static bool lirc_is_present(void)
|
|
* It returns the protocol names of supported protocols.
|
|
* It returns the protocol names of supported protocols.
|
|
* Enabled protocols are printed in brackets.
|
|
* Enabled protocols are printed in brackets.
|
|
*
|
|
*
|
|
- * dev->lock is taken to guard against races between device
|
|
|
|
- * registration, store_protocols and show_protocols.
|
|
|
|
|
|
+ * dev->lock is taken to guard against races between
|
|
|
|
+ * store_protocols and show_protocols.
|
|
*/
|
|
*/
|
|
static ssize_t show_protocols(struct device *device,
|
|
static ssize_t show_protocols(struct device *device,
|
|
struct device_attribute *mattr, char *buf)
|
|
struct device_attribute *mattr, char *buf)
|
|
@@ -945,13 +944,6 @@ static ssize_t show_protocols(struct device *device,
|
|
char *tmp = buf;
|
|
char *tmp = buf;
|
|
int i;
|
|
int i;
|
|
|
|
|
|
- /* Device is being removed */
|
|
|
|
- if (!dev)
|
|
|
|
- return -EINVAL;
|
|
|
|
-
|
|
|
|
- if (!atomic_read(&dev->initialized))
|
|
|
|
- return -ERESTARTSYS;
|
|
|
|
-
|
|
|
|
mutex_lock(&dev->lock);
|
|
mutex_lock(&dev->lock);
|
|
|
|
|
|
enabled = dev->enabled_protocols;
|
|
enabled = dev->enabled_protocols;
|
|
@@ -1106,8 +1098,8 @@ static void ir_raw_load_modules(u64 *protocols)
|
|
* See parse_protocol_change() for the valid commands.
|
|
* See parse_protocol_change() for the valid commands.
|
|
* Returns @len on success or a negative error code.
|
|
* Returns @len on success or a negative error code.
|
|
*
|
|
*
|
|
- * dev->lock is taken to guard against races between device
|
|
|
|
- * registration, store_protocols and show_protocols.
|
|
|
|
|
|
+ * dev->lock is taken to guard against races between
|
|
|
|
+ * store_protocols and show_protocols.
|
|
*/
|
|
*/
|
|
static ssize_t store_protocols(struct device *device,
|
|
static ssize_t store_protocols(struct device *device,
|
|
struct device_attribute *mattr,
|
|
struct device_attribute *mattr,
|
|
@@ -1119,13 +1111,6 @@ static ssize_t store_protocols(struct device *device,
|
|
u64 old_protocols, new_protocols;
|
|
u64 old_protocols, new_protocols;
|
|
ssize_t rc;
|
|
ssize_t rc;
|
|
|
|
|
|
- /* Device is being removed */
|
|
|
|
- if (!dev)
|
|
|
|
- return -EINVAL;
|
|
|
|
-
|
|
|
|
- if (!atomic_read(&dev->initialized))
|
|
|
|
- return -ERESTARTSYS;
|
|
|
|
-
|
|
|
|
IR_dprintk(1, "Normal protocol change requested\n");
|
|
IR_dprintk(1, "Normal protocol change requested\n");
|
|
current_protocols = &dev->enabled_protocols;
|
|
current_protocols = &dev->enabled_protocols;
|
|
filter = &dev->scancode_filter;
|
|
filter = &dev->scancode_filter;
|
|
@@ -1200,7 +1185,7 @@ out:
|
|
* Bits of the filter value corresponding to set bits in the filter mask are
|
|
* Bits of the filter value corresponding to set bits in the filter mask are
|
|
* compared against input scancodes and non-matching scancodes are discarded.
|
|
* compared against input scancodes and non-matching scancodes are discarded.
|
|
*
|
|
*
|
|
- * dev->lock is taken to guard against races between device registration,
|
|
|
|
|
|
+ * dev->lock is taken to guard against races between
|
|
* store_filter and show_filter.
|
|
* store_filter and show_filter.
|
|
*/
|
|
*/
|
|
static ssize_t show_filter(struct device *device,
|
|
static ssize_t show_filter(struct device *device,
|
|
@@ -1212,13 +1197,6 @@ static ssize_t show_filter(struct device *device,
|
|
struct rc_scancode_filter *filter;
|
|
struct rc_scancode_filter *filter;
|
|
u32 val;
|
|
u32 val;
|
|
|
|
|
|
- /* Device is being removed */
|
|
|
|
- if (!dev)
|
|
|
|
- return -EINVAL;
|
|
|
|
-
|
|
|
|
- if (!atomic_read(&dev->initialized))
|
|
|
|
- return -ERESTARTSYS;
|
|
|
|
-
|
|
|
|
mutex_lock(&dev->lock);
|
|
mutex_lock(&dev->lock);
|
|
|
|
|
|
if (fattr->type == RC_FILTER_NORMAL)
|
|
if (fattr->type == RC_FILTER_NORMAL)
|
|
@@ -1251,7 +1229,7 @@ static ssize_t show_filter(struct device *device,
|
|
* Bits of the filter value corresponding to set bits in the filter mask are
|
|
* Bits of the filter value corresponding to set bits in the filter mask are
|
|
* compared against input scancodes and non-matching scancodes are discarded.
|
|
* compared against input scancodes and non-matching scancodes are discarded.
|
|
*
|
|
*
|
|
- * dev->lock is taken to guard against races between device registration,
|
|
|
|
|
|
+ * dev->lock is taken to guard against races between
|
|
* store_filter and show_filter.
|
|
* store_filter and show_filter.
|
|
*/
|
|
*/
|
|
static ssize_t store_filter(struct device *device,
|
|
static ssize_t store_filter(struct device *device,
|
|
@@ -1265,13 +1243,6 @@ static ssize_t store_filter(struct device *device,
|
|
unsigned long val;
|
|
unsigned long val;
|
|
int (*set_filter)(struct rc_dev *dev, struct rc_scancode_filter *filter);
|
|
int (*set_filter)(struct rc_dev *dev, struct rc_scancode_filter *filter);
|
|
|
|
|
|
- /* Device is being removed */
|
|
|
|
- if (!dev)
|
|
|
|
- return -EINVAL;
|
|
|
|
-
|
|
|
|
- if (!atomic_read(&dev->initialized))
|
|
|
|
- return -ERESTARTSYS;
|
|
|
|
-
|
|
|
|
ret = kstrtoul(buf, 0, &val);
|
|
ret = kstrtoul(buf, 0, &val);
|
|
if (ret < 0)
|
|
if (ret < 0)
|
|
return ret;
|
|
return ret;
|
|
@@ -1372,8 +1343,8 @@ static const char * const proto_variant_names[] = {
|
|
* It returns the protocol names of supported protocols.
|
|
* It returns the protocol names of supported protocols.
|
|
* The enabled protocols are printed in brackets.
|
|
* The enabled protocols are printed in brackets.
|
|
*
|
|
*
|
|
- * dev->lock is taken to guard against races between device
|
|
|
|
- * registration, store_protocols and show_protocols.
|
|
|
|
|
|
+ * dev->lock is taken to guard against races between
|
|
|
|
+ * store_wakeup_protocols and show_wakeup_protocols.
|
|
*/
|
|
*/
|
|
static ssize_t show_wakeup_protocols(struct device *device,
|
|
static ssize_t show_wakeup_protocols(struct device *device,
|
|
struct device_attribute *mattr,
|
|
struct device_attribute *mattr,
|
|
@@ -1385,13 +1356,6 @@ static ssize_t show_wakeup_protocols(struct device *device,
|
|
char *tmp = buf;
|
|
char *tmp = buf;
|
|
int i;
|
|
int i;
|
|
|
|
|
|
- /* Device is being removed */
|
|
|
|
- if (!dev)
|
|
|
|
- return -EINVAL;
|
|
|
|
-
|
|
|
|
- if (!atomic_read(&dev->initialized))
|
|
|
|
- return -ERESTARTSYS;
|
|
|
|
-
|
|
|
|
mutex_lock(&dev->lock);
|
|
mutex_lock(&dev->lock);
|
|
|
|
|
|
allowed = dev->allowed_wakeup_protocols;
|
|
allowed = dev->allowed_wakeup_protocols;
|
|
@@ -1431,8 +1395,8 @@ static ssize_t show_wakeup_protocols(struct device *device,
|
|
* It is trigged by writing to /sys/class/rc/rc?/wakeup_protocols.
|
|
* It is trigged by writing to /sys/class/rc/rc?/wakeup_protocols.
|
|
* Returns @len on success or a negative error code.
|
|
* Returns @len on success or a negative error code.
|
|
*
|
|
*
|
|
- * dev->lock is taken to guard against races between device
|
|
|
|
- * registration, store_protocols and show_protocols.
|
|
|
|
|
|
+ * dev->lock is taken to guard against races between
|
|
|
|
+ * store_wakeup_protocols and show_wakeup_protocols.
|
|
*/
|
|
*/
|
|
static ssize_t store_wakeup_protocols(struct device *device,
|
|
static ssize_t store_wakeup_protocols(struct device *device,
|
|
struct device_attribute *mattr,
|
|
struct device_attribute *mattr,
|
|
@@ -1444,13 +1408,6 @@ static ssize_t store_wakeup_protocols(struct device *device,
|
|
u64 allowed;
|
|
u64 allowed;
|
|
int i;
|
|
int i;
|
|
|
|
|
|
- /* Device is being removed */
|
|
|
|
- if (!dev)
|
|
|
|
- return -EINVAL;
|
|
|
|
-
|
|
|
|
- if (!atomic_read(&dev->initialized))
|
|
|
|
- return -ERESTARTSYS;
|
|
|
|
-
|
|
|
|
mutex_lock(&dev->lock);
|
|
mutex_lock(&dev->lock);
|
|
|
|
|
|
allowed = dev->allowed_wakeup_protocols;
|
|
allowed = dev->allowed_wakeup_protocols;
|
|
@@ -1773,7 +1730,6 @@ int rc_register_device(struct rc_dev *dev)
|
|
dev->minor = minor;
|
|
dev->minor = minor;
|
|
dev_set_name(&dev->dev, "rc%u", dev->minor);
|
|
dev_set_name(&dev->dev, "rc%u", dev->minor);
|
|
dev_set_drvdata(&dev->dev, dev);
|
|
dev_set_drvdata(&dev->dev, dev);
|
|
- atomic_set(&dev->initialized, 0);
|
|
|
|
|
|
|
|
dev->dev.groups = dev->sysfs_groups;
|
|
dev->dev.groups = dev->sysfs_groups;
|
|
if (dev->driver_type != RC_DRIVER_IR_RAW_TX)
|
|
if (dev->driver_type != RC_DRIVER_IR_RAW_TX)
|
|
@@ -1819,9 +1775,6 @@ int rc_register_device(struct rc_dev *dev)
|
|
goto out_rx;
|
|
goto out_rx;
|
|
}
|
|
}
|
|
|
|
|
|
- /* Allow the RC sysfs nodes to be accessible */
|
|
|
|
- atomic_set(&dev->initialized, 1);
|
|
|
|
-
|
|
|
|
IR_dprintk(1, "Registered rc%u (driver: %s)\n",
|
|
IR_dprintk(1, "Registered rc%u (driver: %s)\n",
|
|
dev->minor,
|
|
dev->minor,
|
|
dev->driver_name ? dev->driver_name : "unknown");
|
|
dev->driver_name ? dev->driver_name : "unknown");
|