aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/brcm2708/patches-4.19/950-0279-pwm-Send-a-uevent-on-the-pwmchip-device-upon-channel.patch
diff options
context:
space:
mode:
authorÁlvaro Fernández Rojas <noltari@gmail.com>2019-12-23 13:42:55 +0100
committerÁlvaro Fernández Rojas <noltari@gmail.com>2019-12-24 18:49:44 +0100
commit67dcc43f3a22dc3a7ac07a7065971b426feeb043 (patch)
tree0b647356dce45d2c79fd46cf201daa5089cc0934 /target/linux/brcm2708/patches-4.19/950-0279-pwm-Send-a-uevent-on-the-pwmchip-device-upon-channel.patch
parent47a93a810f78adce5a130d287f82b28e9b54313c (diff)
downloadupstream-67dcc43f3a22dc3a7ac07a7065971b426feeb043.tar.gz
upstream-67dcc43f3a22dc3a7ac07a7065971b426feeb043.tar.bz2
upstream-67dcc43f3a22dc3a7ac07a7065971b426feeb043.zip
brcm2708: organize kernel patches
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Diffstat (limited to 'target/linux/brcm2708/patches-4.19/950-0279-pwm-Send-a-uevent-on-the-pwmchip-device-upon-channel.patch')
-rw-r--r--target/linux/brcm2708/patches-4.19/950-0279-pwm-Send-a-uevent-on-the-pwmchip-device-upon-channel.patch86
1 files changed, 86 insertions, 0 deletions
diff --git a/target/linux/brcm2708/patches-4.19/950-0279-pwm-Send-a-uevent-on-the-pwmchip-device-upon-channel.patch b/target/linux/brcm2708/patches-4.19/950-0279-pwm-Send-a-uevent-on-the-pwmchip-device-upon-channel.patch
new file mode 100644
index 0000000000..8136e3ffa0
--- /dev/null
+++ b/target/linux/brcm2708/patches-4.19/950-0279-pwm-Send-a-uevent-on-the-pwmchip-device-upon-channel.patch
@@ -0,0 +1,86 @@
+From 20a5b38305df30e25b4429e0e34e35235dd57228 Mon Sep 17 00:00:00 2001
+From: Fabrice Gasnier <fabrice.gasnier@st.com>
+Date: Mon, 1 Oct 2018 15:23:57 +0200
+Subject: [PATCH] pwm: Send a uevent on the pwmchip device upon channel
+ sysfs (un)export
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+commit 552c02e3e7cfe2744b59de285aaea70021ae95c9 upstream.
+
+This patch sends a uevent (KOBJ_CHANGE) on the pwmchipN device,
+everytime a pwmX channel has been exported/unexported via sysfs. This
+allows udev to implement rules on such events, like:
+
+SUBSYSTEM=="pwm*", PROGRAM="/bin/sh -c '\
+ chown -R root:gpio /sys/class/pwm && chmod -R 770 /sys/class/pwm;\
+ chown -R root:gpio
+/sys/devices/platform/soc/*.pwm/pwm/pwmchip* && chmod -R 770
+/sys/devices/platform/soc/*.pwm/pwm/pwmchip*\
+'"
+
+This is a replacement patch for commit 7e5d1fd75c3d ("pwm: Set class for
+exported channels in sysfs"), see [1].
+
+basic testing:
+$ udevadm monitor --environment &
+$ echo 0 > /sys/class/pwm/pwmchip0/export
+KERNEL[197.321736] change /devices/.../pwm/pwmchip0 (pwm)
+ACTION=change
+DEVPATH=/devices/.../pwm/pwmchip0
+EXPORT=pwm0
+SEQNUM=2045
+SUBSYSTEM=pwm
+
+[1] https://lkml.org/lkml/2018/9/25/713
+
+Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
+Tested-by: Gottfried Haider <gottfried.haider@gmail.com>
+Tested-by: Michal Vokáč <michal.vokac@ysoft.com>
+Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
+---
+ drivers/pwm/sysfs.c | 11 +++++++++++
+ 1 file changed, 11 insertions(+)
+
+--- a/drivers/pwm/sysfs.c
++++ b/drivers/pwm/sysfs.c
+@@ -249,6 +249,7 @@ static void pwm_export_release(struct de
+ static int pwm_export_child(struct device *parent, struct pwm_device *pwm)
+ {
+ struct pwm_export *export;
++ char *pwm_prop[2];
+ int ret;
+
+ if (test_and_set_bit(PWMF_EXPORTED, &pwm->flags))
+@@ -276,6 +277,10 @@ static int pwm_export_child(struct devic
+ export = NULL;
+ return ret;
+ }
++ pwm_prop[0] = kasprintf(GFP_KERNEL, "EXPORT=pwm%u", pwm->hwpwm);
++ pwm_prop[1] = NULL;
++ kobject_uevent_env(&parent->kobj, KOBJ_CHANGE, pwm_prop);
++ kfree(pwm_prop[0]);
+
+ return 0;
+ }
+@@ -288,6 +293,7 @@ static int pwm_unexport_match(struct dev
+ static int pwm_unexport_child(struct device *parent, struct pwm_device *pwm)
+ {
+ struct device *child;
++ char *pwm_prop[2];
+
+ if (!test_and_clear_bit(PWMF_EXPORTED, &pwm->flags))
+ return -ENODEV;
+@@ -296,6 +302,11 @@ static int pwm_unexport_child(struct dev
+ if (!child)
+ return -ENODEV;
+
++ pwm_prop[0] = kasprintf(GFP_KERNEL, "UNEXPORT=pwm%u", pwm->hwpwm);
++ pwm_prop[1] = NULL;
++ kobject_uevent_env(&parent->kobj, KOBJ_CHANGE, pwm_prop);
++ kfree(pwm_prop[0]);
++
+ /* for device_find_child() */
+ put_device(child);
+ device_unregister(child);