libdigiapix: add rule for PWM channels to be owned by digiapix group
The exported PWM channels now report the channel name under udev EXPORT parameter. Add the 'change' udev action type to the udev rules and use that parameter to change the group ownership of the PWM channels to digiapix group, so they can be used by non-root user. Signed-off-by: Hector Palacios <hector.palacios@digi.com>
This commit is contained in:
parent
6c38b38f95
commit
8fc279fe65
|
|
@ -19,4 +19,4 @@ SUBSYSTEM=="spidev", GROUP="digiapix", MODE="0660"
|
|||
SUBSYSTEM=="gpio", KERNEL=="gpiochip0", ACTION=="add", RUN="/etc/udev/scripts/digiapix.sh"
|
||||
SUBSYSTEM=="gpio", KERNEL!="gpiochip*", ACTION=="add", RUN="/etc/udev/scripts/digiapix.sh"
|
||||
|
||||
SUBSYSTEM=="pwm", ACTION=="add", RUN="/etc/udev/scripts/digiapix.sh"
|
||||
SUBSYSTEM=="pwm", ACTION=="add|change", RUN="/etc/udev/scripts/digiapix.sh"
|
||||
|
|
|
|||
|
|
@ -19,13 +19,17 @@ if basename "${DEVPATH}" | grep -qs "gpiochip0$"; then
|
|||
# Use 'gpiochip0' event to set group and mode for 'export/unexport' files
|
||||
chown root:digiapix /sys/class/gpio/export /sys/class/gpio/unexport
|
||||
chmod g+w /sys/class/gpio/export /sys/class/gpio/unexport
|
||||
elif basename "${DEVPATH}" | grep -qs "pwmchip[0-9]\+$"; then
|
||||
elif basename "${DEVPATH}" | grep -qs "pwmchip[0-9]\+$" && [ "${ACTION}" = "add" ] ; then
|
||||
# Set group and mode for pwmchip's 'export/unexport' files
|
||||
chown root:digiapix /sys${DEVPATH}/export /sys${DEVPATH}/unexport
|
||||
chmod g+w /sys${DEVPATH}/export /sys${DEVPATH}/unexport
|
||||
elif basename "${DEVPATH}" | grep -qs "pwmchip[0-9]\+$" && [ "${ACTION}" = "change" ] ; then
|
||||
# Set group and mode for 'pwmX' channel and all files inside it...
|
||||
chown root:digiapix /sys${DEVPATH}/${EXPORT} /sys${DEVPATH}/${EXPORT}/*
|
||||
chmod g+w /sys${DEVPATH}/${EXPORT}/*
|
||||
else
|
||||
# Change group and mode of the sysfs files created whenever a 'gpioX'
|
||||
# or 'pwmX' is exported
|
||||
# is exported
|
||||
chown -h root:digiapix /sys${DEVPATH}/*
|
||||
chmod g+w /sys${DEVPATH}/*
|
||||
fi
|
||||
|
|
|
|||
Loading…
Reference in New Issue