Skip to content

Commit 70cd812

Browse files
andy-shevJiri Kosina
authored andcommitted
HID: picolcd: Convert to use sysfs_streq()
Convert to use sysfs_streq() instead of custom approach. Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent c6400e5 commit 70cd812

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

drivers/hid/hid-picolcd_core.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <linux/completion.h>
2929
#include <linux/uaccess.h>
3030
#include <linux/module.h>
31+
#include <linux/string.h>
3132

3233
#include "hid-picolcd.h"
3334

@@ -275,27 +276,20 @@ static ssize_t picolcd_operation_mode_store(struct device *dev,
275276
{
276277
struct picolcd_data *data = dev_get_drvdata(dev);
277278
struct hid_report *report = NULL;
278-
size_t cnt = count;
279279
int timeout = data->opmode_delay;
280280
unsigned long flags;
281281

282-
if (cnt >= 3 && strncmp("lcd", buf, 3) == 0) {
282+
if (sysfs_streq(buf, "lcd")) {
283283
if (data->status & PICOLCD_BOOTLOADER)
284284
report = picolcd_out_report(REPORT_EXIT_FLASHER, data->hdev);
285-
buf += 3;
286-
cnt -= 3;
287-
} else if (cnt >= 10 && strncmp("bootloader", buf, 10) == 0) {
285+
} else if (sysfs_streq(buf, "bootloader")) {
288286
if (!(data->status & PICOLCD_BOOTLOADER))
289287
report = picolcd_out_report(REPORT_EXIT_KEYBOARD, data->hdev);
290-
buf += 10;
291-
cnt -= 10;
292-
}
293-
if (!report || report->maxfield != 1)
288+
} else {
294289
return -EINVAL;
290+
}
295291

296-
while (cnt > 0 && (buf[cnt-1] == '\n' || buf[cnt-1] == '\r'))
297-
cnt--;
298-
if (cnt != 0)
292+
if (!report || report->maxfield != 1)
299293
return -EINVAL;
300294

301295
spin_lock_irqsave(&data->lock, flags);

0 commit comments

Comments
 (0)