Loading drivers/sensors/sensors_class.c +20 −1 Original line number Original line Diff line number Diff line /* 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 * 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 * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -176,6 +176,24 @@ static ssize_t sensors_delay_show(struct device *dev, sensors_cdev->delay_msec); 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[] = { static struct device_attribute sensors_class_attrs[] = { __ATTR(name, 0444, sensors_name_show, NULL), __ATTR(name, 0444, sensors_name_show, NULL), Loading @@ -191,6 +209,7 @@ static struct device_attribute sensors_class_attrs[] = { __ATTR(fifo_max_event_count, 0444, sensors_fifo_max_show, NULL), __ATTR(fifo_max_event_count, 0444, sensors_fifo_max_show, NULL), __ATTR(enable, 0664, sensors_enable_show, sensors_enable_store), __ATTR(enable, 0664, sensors_enable_show, sensors_enable_store), __ATTR(poll_delay, 0664, sensors_delay_show, sensors_delay_store), __ATTR(poll_delay, 0664, sensors_delay_show, sensors_delay_store), __ATTR(self_test, 0440, sensors_test_show, NULL), __ATTR_NULL, __ATTR_NULL, }; }; Loading include/linux/sensors.h +2 −1 Original line number Original line Diff line number Diff line /* 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 * 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 * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -96,6 +96,7 @@ struct sensors_classdev { unsigned int enabled); unsigned int enabled); int (*sensors_poll_delay)(struct sensors_classdev *sensors_cdev, int (*sensors_poll_delay)(struct sensors_classdev *sensors_cdev, unsigned int delay_msec); unsigned int delay_msec); int (*sensors_self_test)(struct sensors_classdev *sensors_cdev); }; }; extern int sensors_classdev_register(struct device *parent, extern int sensors_classdev_register(struct device *parent, Loading Loading
drivers/sensors/sensors_class.c +20 −1 Original line number Original line Diff line number Diff line /* 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 * 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 * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -176,6 +176,24 @@ static ssize_t sensors_delay_show(struct device *dev, sensors_cdev->delay_msec); 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[] = { static struct device_attribute sensors_class_attrs[] = { __ATTR(name, 0444, sensors_name_show, NULL), __ATTR(name, 0444, sensors_name_show, NULL), Loading @@ -191,6 +209,7 @@ static struct device_attribute sensors_class_attrs[] = { __ATTR(fifo_max_event_count, 0444, sensors_fifo_max_show, NULL), __ATTR(fifo_max_event_count, 0444, sensors_fifo_max_show, NULL), __ATTR(enable, 0664, sensors_enable_show, sensors_enable_store), __ATTR(enable, 0664, sensors_enable_show, sensors_enable_store), __ATTR(poll_delay, 0664, sensors_delay_show, sensors_delay_store), __ATTR(poll_delay, 0664, sensors_delay_show, sensors_delay_store), __ATTR(self_test, 0440, sensors_test_show, NULL), __ATTR_NULL, __ATTR_NULL, }; }; Loading
include/linux/sensors.h +2 −1 Original line number Original line Diff line number Diff line /* 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 * 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 * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -96,6 +96,7 @@ struct sensors_classdev { unsigned int enabled); unsigned int enabled); int (*sensors_poll_delay)(struct sensors_classdev *sensors_cdev, int (*sensors_poll_delay)(struct sensors_classdev *sensors_cdev, unsigned int delay_msec); unsigned int delay_msec); int (*sensors_self_test)(struct sensors_classdev *sensors_cdev); }; }; extern int sensors_classdev_register(struct device *parent, extern int sensors_classdev_register(struct device *parent, Loading