input: sensors: add self test interface for sensors class
The self test interface is a generic interface for sensor self test. Add the interface for user space applications to test sensors. Drivers using sensors class should try to implement the callback if needed. Change-Id: I008198534940c1357cfb1c7c4ff9b9b37beffdee Signed-off-by: Oliver Wang <mengmeng@codeaurora.org>
This commit is contained in:
parent
3fc0e7942f
commit
c4d842e406
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
|
@ -176,6 +176,24 @@ static ssize_t sensors_delay_show(struct device *dev,
|
|||
sensors_cdev->delay_msec);
|
||||
}
|
||||
|
||||
static ssize_t sensors_test_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct sensors_classdev *sensors_cdev = dev_get_drvdata(dev);
|
||||
int ret;
|
||||
|
||||
if (sensors_cdev->sensors_self_test == NULL) {
|
||||
dev_err(dev, "Invalid sensor class self test handle\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = sensors_cdev->sensors_self_test(sensors_cdev);
|
||||
if (ret)
|
||||
dev_warn(dev, "self test failed.(%d)\n", ret);
|
||||
|
||||
return snprintf(buf, PAGE_SIZE, "%s\n",
|
||||
ret ? "fail" : "pass");
|
||||
}
|
||||
|
||||
static struct device_attribute sensors_class_attrs[] = {
|
||||
__ATTR(name, 0444, sensors_name_show, NULL),
|
||||
|
@ -191,6 +209,7 @@ static struct device_attribute sensors_class_attrs[] = {
|
|||
__ATTR(fifo_max_event_count, 0444, sensors_fifo_max_show, NULL),
|
||||
__ATTR(enable, 0664, sensors_enable_show, sensors_enable_store),
|
||||
__ATTR(poll_delay, 0664, sensors_delay_show, sensors_delay_store),
|
||||
__ATTR(self_test, 0440, sensors_test_show, NULL),
|
||||
__ATTR_NULL,
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
|
@ -96,6 +96,7 @@ struct sensors_classdev {
|
|||
unsigned int enabled);
|
||||
int (*sensors_poll_delay)(struct sensors_classdev *sensors_cdev,
|
||||
unsigned int delay_msec);
|
||||
int (*sensors_self_test)(struct sensors_classdev *sensors_cdev);
|
||||
};
|
||||
|
||||
extern int sensors_classdev_register(struct device *parent,
|
||||
|
|
Loading…
Reference in New Issue