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/patch-add-sysfs.diff | |
| 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/patch-add-sysfs.diff')
| -rw-r--r-- | schulung_tools/drivers/hellodriver/patch-add-sysfs.diff | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/schulung_tools/drivers/hellodriver/patch-add-sysfs.diff b/schulung_tools/drivers/hellodriver/patch-add-sysfs.diff new file mode 100644 index 0000000..44c913e --- /dev/null +++ b/schulung_tools/drivers/hellodriver/patch-add-sysfs.diff @@ -0,0 +1,57 @@ +From 9ec20c5b243d6f1f83b38b57474cf532c4575a02 Mon Sep 17 00:00:00 2001 +From: John Ogness <john.ogness@linutronix.de> +Date: Fri, 15 Feb 2019 12:58:25 +0106 +Subject: [PATCH] hello: add custom sysfs files + +Signed-off-by: John Ogness <john.ogness@linutronix.de> +--- + hello.c | 26 ++++++++++++++++++++++ + 1 file changed, 26 insertions(+) + +diff --git a/hello.c b/hello.c +index 7f78d06..4c7989a 100644 +--- a/hello.c ++++ b/hello.c +@@ -77,6 +77,30 @@ static const struct file_operations hello_fops = { + .write = hello_write, + }; + ++static ssize_t major_show(struct device *dev, ++ struct device_attribute *attr, char *buf) ++{ ++ return sprintf(buf, "%d\n", MAJOR(hello_devt)); ++} ++static DEVICE_ATTR_RO(major); ++ ++static ssize_t minor_show(struct device *dev, ++ struct device_attribute *attr, char *buf) ++{ ++ struct platform_device *pdev = to_platform_device(dev); ++ struct hello_dev *hello = platform_get_drvdata(pdev); ++ ++ return sprintf(buf, "%d\n", hello->minor); ++} ++static DEVICE_ATTR_RO(minor); ++ ++static struct attribute *hello_device_attrs[] = { ++ &dev_attr_major.attr, ++ &dev_attr_minor.attr, ++ NULL, ++}; ++ATTRIBUTE_GROUPS(hello_device); ++ + static int hello_probe(struct platform_device *pdev) + { + struct hello_dev *hello; +@@ -187,6 +211,8 @@ static int __init hello_init(void) + goto err_region; + } + ++ hello_class->dev_groups = hello_device_groups; ++ + ret = platform_driver_register(&hello_driver); + if (ret != 0) + goto err_class; +-- +2.1.4 + |
