提交 70cd8121 编写于 作者: A Andy Shevchenko 提交者: Jiri Kosina

HID: picolcd: Convert to use sysfs_streq()

Convert to use sysfs_streq() instead of custom approach.
Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: NJiri Kosina <jkosina@suse.cz>
上级 c6400e5c
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/string.h>
#include "hid-picolcd.h" #include "hid-picolcd.h"
...@@ -275,27 +276,20 @@ static ssize_t picolcd_operation_mode_store(struct device *dev, ...@@ -275,27 +276,20 @@ static ssize_t picolcd_operation_mode_store(struct device *dev,
{ {
struct picolcd_data *data = dev_get_drvdata(dev); struct picolcd_data *data = dev_get_drvdata(dev);
struct hid_report *report = NULL; struct hid_report *report = NULL;
size_t cnt = count;
int timeout = data->opmode_delay; int timeout = data->opmode_delay;
unsigned long flags; unsigned long flags;
if (cnt >= 3 && strncmp("lcd", buf, 3) == 0) { if (sysfs_streq(buf, "lcd")) {
if (data->status & PICOLCD_BOOTLOADER) if (data->status & PICOLCD_BOOTLOADER)
report = picolcd_out_report(REPORT_EXIT_FLASHER, data->hdev); report = picolcd_out_report(REPORT_EXIT_FLASHER, data->hdev);
buf += 3; } else if (sysfs_streq(buf, "bootloader")) {
cnt -= 3;
} else if (cnt >= 10 && strncmp("bootloader", buf, 10) == 0) {
if (!(data->status & PICOLCD_BOOTLOADER)) if (!(data->status & PICOLCD_BOOTLOADER))
report = picolcd_out_report(REPORT_EXIT_KEYBOARD, data->hdev); report = picolcd_out_report(REPORT_EXIT_KEYBOARD, data->hdev);
buf += 10; } else {
cnt -= 10;
}
if (!report || report->maxfield != 1)
return -EINVAL; return -EINVAL;
}
while (cnt > 0 && (buf[cnt-1] == '\n' || buf[cnt-1] == '\r')) if (!report || report->maxfield != 1)
cnt--;
if (cnt != 0)
return -EINVAL; return -EINVAL;
spin_lock_irqsave(&data->lock, flags); spin_lock_irqsave(&data->lock, flags);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册