: Convert firmware.sh to C
PATCH 1/1 : Convert firmware.sh to C
Hi,
This patch removes firmware.sh and adds a firmware.c to do the same job. The patch also changes 50-firmware.rules to use the new binary (with a bit changed syntax).
The binary loads the firmware file to device. If the firmware
file isn't found, it creates the a broken symlink under/dev/.udev/firmware, like the shell script does. If in a next load the firmware file is found, the symlink is removed.
Many thanks to Kay that helps with fixes and sugestions in this code.
Hope I have understand those tips and it is OK now. :)
Piter Punk
Makefile.am +9 -7
@@ -181,15 +181,9 @@ udev_test_udev_SOURCES = \ udev_test_udev_LDADD = libudev/libudev-private.la # ------------------------------------------------------------------------------ -# firmware.sh - firmware loading -# ------------------------------------------------------------------------------ -dist_libexec_SCRIPTS = extras/firmware/firmware.sh -dist_udevrules_DATA += extras/firmware/50-firmware.rules - -# ------------------------------------------------------------------------------ # rule_generator - persistent network and optical device rule generator # ------------------------------------------------------------------------------ -dist_libexec_SCRIPTS += \ +dist_libexec_SCRIPTS = \ extras/rule_generator/write_cd_rules \ extras/rule_generator/write_net_rules
@@ -272,6 +266,14 @@ extras_usb_id_usb_id_LDADD = libudev/libudev-private.la libexec_PROGRAMS += extras/usb_id/usb_id # ------------------------------------------------------------------------------ +# firmware - Firmware loading +# ------------------------------------------------------------------------------ +extras_firmware_firmware_SOURCES = extras/firmware/firmware.c +extras_firmware_firmware_LDADD = libudev/libudev-private.la +libexec_PROGRAMS += extras/firmware/firmware +dist_udevrules_DATA += extras/firmware/50-firmware.rules + +# ------------------------------------------------------------------------------ # v4l_id - video4linux capabilities # ------------------------------------------------------------------------------ extras_v4l_id_v4l_id_SOURCES = extras/v4l_id/v4l_id.c
TODO +0 -1
@@ -1,5 +1,4 @@ - o convert firmware.sh to C o get rid of braindead "scan all devices to find myself" libusb interface if it can not be fixed, drop libusb entirely o drop all support for the DEPRECATED sysfs layout
extras/firmware/50-firmware.rules +1 -1
@@ -1,4 +1,4 @@ # do not edit this file, it will be overwritten on update # firmware-class requests, copies files into the kernel -SUBSYSTEM=="firmware", ACTION=="add", RUN+="firmware.sh" +SUBSYSTEM=="firmware", ACTION=="add", RUN+="firmware -f $env{FIRMWARE} %p"
extras/firmware/firmware.c new file +214 -0
214 lines not on this page · raw message
extras/firmware/firmware.sh deleted +0 -29
@@ -1,29 +0,0 @@ -#!/bin/sh -e - -FIRMWARE_DIRS="/lib/firmware/updates/$(uname -r) /lib/firmware/updates \ - /lib/firmware/$(uname -r) /lib/firmware" - -err() { - echo "$@" >&2 - logger -t "${0##*/}[$$]" "$@" 2>/dev/null || true -} - -if [ ! -e /sys$DEVPATH/loading ]; then - err "udev firmware loader misses sysfs directory" - exit 1 -fi - -for DIR in $FIRMWARE_DIRS; do - [ -e "$DIR/$FIRMWARE" ] || continue - echo 1 > /sys$DEVPATH/loading - cat "$DIR/$FIRMWARE" > /sys$DEVPATH/data - echo 0 > /sys$DEVPATH/loading - exit 0 -done - -echo -1 > /sys$DEVPATH/loading -err "Cannot find firmware file '$FIRMWARE'" -mkdir -p /dev/.udev/firmware-missing -file=$(echo "$FIRMWARE" | sed 's:/:\\x2f:g') -ln -s -f "$DEVPATH" /dev/.udev/firmware-missing/$file -exit 1
Quoted 2 lines · Piter PUNK
This patch removes
firmware.shand adds afirmware.cto do the same job.
It is still not clear to me why this would be desirable.
Signature · 2 lines
ciao, Marco