diff options
| author | John Ogness <john.ogness@linutronix.de> | 2017-12-19 10:53:07 +0100 |
|---|---|---|
| committer | John Ogness <john.ogness@linutronix.de> | 2017-12-19 10:53:07 +0100 |
| commit | 27209bb802048f4803d9cd9a5c2f99d613986446 (patch) | |
| tree | 54f36042b79f63ce0a19be18e82a7d189a41686b /schulung_tools/drivers/modules/hellodriver/patch-add-sysfs.diff | |
| parent | 0f172d0b022f1a2ec3d7465eb7272828ee083f6e (diff) | |
import drivers from devel/jogness
Simple drivers for use in the Linux Advanced schulung were only
available in the devel/jogness branch. Push them to master so
they are easily accessible to any trainer.
Signed-off-by: John Ogness <john.ogness@linutronix.de>
Diffstat (limited to 'schulung_tools/drivers/modules/hellodriver/patch-add-sysfs.diff')
| -rw-r--r-- | schulung_tools/drivers/modules/hellodriver/patch-add-sysfs.diff | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/schulung_tools/drivers/modules/hellodriver/patch-add-sysfs.diff b/schulung_tools/drivers/modules/hellodriver/patch-add-sysfs.diff new file mode 100644 index 0000000..703b6e0 --- /dev/null +++ b/schulung_tools/drivers/modules/hellodriver/patch-add-sysfs.diff @@ -0,0 +1,48 @@ +--- a/hello.c 2016-06-08 20:21:26.751180497 +0200 ++++ b/hello.c 2016-06-08 20:19:31.655178050 +0200 +@@ -76,6 +76,30 @@ + .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; +@@ -178,6 +202,8 @@ + goto err_out1; + } + ++ hello_class->dev_groups = hello_device_groups; ++ + ret = platform_driver_register(&hello_driver); + if (ret != 0) + goto err_out2; +@@ -206,4 +232,4 @@ + MODULE_AUTHOR("John Ogness <john.ogness@linutronix.de>"); + MODULE_DESCRIPTION("a great module for hello-ing!"); + MODULE_LICENSE("GPL v2"); +-MODULE_VERSION("20160607"); ++MODULE_VERSION("20160608"); |
