diff options
| author | John Ogness <john.ogness@linutronix.de> | 2019-02-15 13:16:28 +0106 |
|---|---|---|
| committer | John Ogness <john.ogness@linutronix.de> | 2019-02-15 13:16:28 +0106 |
| commit | f19259fb36ffe74a11325c14ee2260a8e323b8ee (patch) | |
| tree | 6cf02a4fcedfa1451c164f6c3a44a0781f41a571 /schulung_tools/drivers/hellodriver/patches-leds/0003-hello-add-led-toggling-via-chardev-read-write.patch | |
| parent | 9fffe2a41d0aa2b47c589db2523707a9e14ab5a1 (diff) | |
schulung_tools: drivers: remove modules subdir
There is no need for the extra directory level. Move all the
example modules to the parent "drivers" directory and delete
the modules directory.
Signed-off-by: John Ogness <john.ogness@linutronix.de>
Diffstat (limited to 'schulung_tools/drivers/hellodriver/patches-leds/0003-hello-add-led-toggling-via-chardev-read-write.patch')
| -rw-r--r-- | schulung_tools/drivers/hellodriver/patches-leds/0003-hello-add-led-toggling-via-chardev-read-write.patch | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/schulung_tools/drivers/hellodriver/patches-leds/0003-hello-add-led-toggling-via-chardev-read-write.patch b/schulung_tools/drivers/hellodriver/patches-leds/0003-hello-add-led-toggling-via-chardev-read-write.patch new file mode 100644 index 0000000..8f81e39 --- /dev/null +++ b/schulung_tools/drivers/hellodriver/patches-leds/0003-hello-add-led-toggling-via-chardev-read-write.patch @@ -0,0 +1,56 @@ +From c7a4c4448632af43383818654dd79d2251b27e3e Mon Sep 17 00:00:00 2001 +From: John Ogness <john.ogness@linutronix.de> +Date: Fri, 15 Feb 2019 11:04:56 +0106 +Subject: [PATCH 4/7] hello: add led toggling via chardev read/write + +Signed-off-by: John Ogness <john.ogness@linutronix.de> +--- + hello.c | 28 +++++++++++++++++++++++++++- + 1 file changed, 27 insertions(+), 1 deletion(-) + +diff --git a/hello.c b/hello.c +index 58a64e5..f664121 100644 +--- a/hello.c ++++ b/hello.c +@@ -61,11 +61,37 @@ static ssize_t hello_read(struct file *f, char __user *u, size_t s, loff_t *l) + return len; + } + ++static void toggle_led(struct hello_dev *hello, int offset) ++{ ++ if (readb(hello->mem + offset)) ++ writeb(0, hello->mem + offset); ++ else ++ writeb(0xff, hello->mem + offset); ++} ++ + static ssize_t hello_write(struct file *f, const char __user *u, size_t s, + loff_t *l) + { + struct hello_dev *hello = f->private_data; +- dev_info(hello->dev, "%s: size=%zu offset=%llu\n", __func__, s, *l); ++ size_t sz = s; ++ char buf[32]; ++ ++ if (sz >= sizeof(buf)) ++ sz = sizeof(buf) - 1; ++ if (copy_from_user(buf, u, sz) != 0) ++ return -EFAULT; ++ buf[sz] = 0; ++ ++ dev_info(hello->dev, "%s: size=%zu offset=%llu buf=%s\n", __func__, ++ s, *l, buf); ++ ++ if (strstarts(buf, "heartbeat")) ++ toggle_led(hello, 0); ++ else if (strstarts(buf, "net")) ++ toggle_led(hello, 1); ++ else if (strstarts(buf, "disk")) ++ toggle_led(hello, 2); ++ + return s; + } + +-- +2.11.0 + |
