Li Zhijian
68ea60a796
coccinelle: device_attr_show: Adapt to the latest Documentation/filesystems/sysfs.rst
...
Adapt description, warning message and MODE=patch according to the latest
Documentation/filesystems/sysfs.rst:
> show() should only use sysfs_emit() or sysfs_emit_at() when formatting
> the value to be returned to user space.
After this patch:
When MODE=report,
$ make coccicheck COCCI=scripts/coccinelle/api/device_attr_show.cocci M=drivers/hid/hid-picolcd_core.c MODE=report
<...snip...>
drivers/hid/hid-picolcd_core.c:304:8-16: WARNING: please use sysfs_emit or sysfs_emit_at
drivers/hid/hid-picolcd_core.c:259:9-17: WARNING: please use sysfs_emit or sysfs_emit_at
When MODE=patch,
$ make coccicheck COCCI=scripts/coccinelle/api/device_attr_show.cocci M=drivers/hid/hid-picolcd_core.c MODE=patch
<...snip...>
diff -u -p a/drivers/hid/hid-picolcd_core.c b/drivers/hid/hid-picolcd_core.c
--- a/drivers/hid/hid-picolcd_core.c
+++ b/drivers/hid/hid-picolcd_core.c
@@ -255,10 +255,12 @@ static ssize_t picolcd_operation_mode_sh
{
struct picolcd_data *data = dev_get_drvdata(dev);
- if (data->status & PICOLCD_BOOTLOADER)
- return snprintf(buf, PAGE_SIZE, "[bootloader] lcd\n");
- else
- return snprintf(buf, PAGE_SIZE, "bootloader [lcd]\n");
+ if (data->status & PICOLCD_BOOTLOADER) {
+ return sysfs_emit(buf, "[bootloader] lcd\n");
+ }
+ else {
+ return sysfs_emit(buf, "bootloader [lcd]\n");
+ }
}
static ssize_t picolcd_operation_mode_store(struct device *dev,
@@ -301,7 +303,7 @@ static ssize_t picolcd_operation_mode_de
{
struct picolcd_data *data = dev_get_drvdata(dev);
- return snprintf(buf, PAGE_SIZE, "hello world\n");
+ return sysfs_emit(buf, "hello world\n");
}
static ssize_t picolcd_operation_mode_delay_store(struct device *dev,
CC: Julia Lawall <Julia.Lawall@inria.fr>
CC: Nicolas Palix <nicolas.palix@imag.fr>
CC: cocci@inria.fr
Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
2024-01-19 21:52:09 +01:00
..
2023-10-09 18:14:15 +02:00
2023-06-22 21:21:06 +09:00
2023-12-23 23:24:03 +09:00
2024-01-19 21:52:09 +01:00
2023-11-09 11:56:39 -06:00
2023-11-01 23:24:56 +09:00
2023-11-27 16:30:05 -08:00
2024-01-18 17:57:07 -08:00
2023-11-28 11:22:50 +09:00
2023-12-29 22:25:20 +09:00
2023-12-10 15:34:37 +09:00
2024-01-10 20:39:47 +09:00
2022-09-20 14:12:25 -04:00
2023-02-18 14:34:09 -05:00
2023-07-19 09:32:53 -06:00
2023-01-26 12:41:38 +09:00
2023-04-21 08:58:00 -07:00
2023-08-21 13:46:25 -07:00
2023-08-31 13:56:31 +02:00
2023-04-24 10:18:32 -07:00
2021-09-08 11:50:28 -07:00
2023-03-16 22:46:12 +09:00
2023-05-23 21:43:26 -07:00
2023-12-29 22:25:20 +09:00
2021-08-10 09:13:25 +09:00
2023-01-26 12:43:33 +09:00
2024-01-17 16:47:17 -08:00
2023-12-29 12:22:28 -08:00
2023-03-23 17:18:32 -07:00
2021-08-05 20:55:39 +09:00
2023-02-25 20:11:06 +01:00
2023-10-12 17:14:11 +02:00
2024-01-12 15:20:46 -08:00
2023-12-29 12:22:25 -08:00
2023-08-29 22:38:23 +09:00
2023-01-26 12:43:33 +09:00
2021-10-26 09:42:29 -06:00
2022-08-29 13:58:47 +09:00
2023-10-23 08:36:46 -07:00
2022-05-08 01:33:07 -07:00
2023-08-20 22:54:32 +02:00
2022-09-28 09:02:45 +02:00
2024-01-03 14:02:17 -07:00
2022-06-30 12:22:17 -06:00
2023-12-31 10:57:42 -08:00
2023-06-19 13:19:32 -07:00
2023-12-29 22:25:20 +09:00
2023-12-03 18:51:48 +09:00
2023-11-23 10:38:58 +01:00
2022-05-11 21:45:53 +09:00
2023-01-16 20:15:20 +09:00
2023-07-29 15:57:32 +09:00
2023-01-22 23:43:33 +09:00
2023-01-26 12:41:38 +09:00
2024-01-11 19:46:52 -08:00
2023-03-29 06:52:08 -04:00
2023-04-30 11:32:53 -07:00
2023-07-19 09:32:53 -06:00
2022-11-22 23:40:02 +09:00
2023-10-28 21:10:08 +09:00
2023-12-14 20:14:01 +01:00
2023-07-01 09:24:31 -07:00
2023-06-25 23:12:20 +09:00
2023-07-01 09:24:31 -07:00
2022-11-21 10:18:39 +09:00
2023-02-13 20:18:28 +01:00
2023-06-21 07:51:08 -06:00
2024-01-18 17:57:07 -08:00
2022-08-16 12:25:53 -07:00
2023-10-14 18:26:28 +09:00
2023-04-18 16:29:43 -07:00
2021-12-09 16:42:27 -08:00
2022-10-03 14:03:19 -07:00
2023-12-10 15:34:37 +09:00
2023-10-28 21:10:08 +09:00
2023-09-25 16:01:05 +09:00
2023-07-25 00:59:32 +09:00
2023-12-10 15:34:37 +09:00
2022-05-08 01:33:07 -07:00
2023-05-16 13:57:14 -07:00
2023-11-01 23:26:01 +09:00
2023-12-23 23:24:03 +09:00
2023-10-20 13:02:23 +02:00
2023-10-20 11:46:59 +02:00
2023-12-21 19:40:26 +01:00
2023-01-22 23:43:33 +09:00
2022-09-29 04:40:15 +09:00
2023-06-27 08:35:43 +09:00
2022-11-09 18:06:35 +00:00
2022-12-14 15:42:40 +09:00
2022-06-08 20:14:13 +09:00
2022-06-05 06:20:57 +09:00
2023-04-14 16:08:28 +02:00
2023-06-16 17:17:42 +02:00
2022-02-02 11:19:33 +01:00
2022-05-11 21:46:38 +09:00
2023-12-03 18:51:48 +09:00
2021-06-18 09:09:17 -04:00
2023-12-03 18:51:48 +09:00
2023-04-19 07:46:31 -07:00
2023-10-03 20:49:09 +09:00
2022-09-28 09:02:06 +02:00
2023-08-10 01:18:34 +02:00
2023-08-10 01:18:34 +02:00
2023-07-19 09:32:53 -06:00
2023-07-19 09:32:53 -06:00
2023-08-08 01:08:54 +09:00
2023-10-18 14:43:23 -07:00
2023-12-13 12:55:11 -08:00
2022-12-14 08:36:11 +08:00
2023-03-23 23:18:58 +01:00
2022-06-01 09:32:45 -06:00
2022-05-18 15:34:33 +02:00
2022-05-18 15:35:42 +02:00
2023-12-10 17:21:33 -08:00
2023-12-15 08:36:33 -07:00
2022-06-03 20:09:27 +08:00
2021-07-09 04:00:39 +09:00
2021-08-10 09:13:25 +09:00
2021-07-09 04:00:39 +09:00
2024-01-04 17:01:15 +01:00
2022-02-13 16:50:06 -08:00
2023-04-17 11:23:06 +09:00
2021-08-10 09:13:25 +09:00
2023-12-03 18:51:48 +09:00