All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>
To: johannes@sipsolutions.net
Cc: backports@vger.kernel.org, "Luis R. Rodriguez" <mcgrof@do-not-panic.com>
Subject: [PATCH 16/18] backports: add udev rules if required for backported firmware_class
Date: Wed, 10 Apr 2013 04:35:26 -0700	[thread overview]
Message-ID: <1365593728-5720-17-git-send-email-mcgrof@do-not-panic.com> (raw)
In-Reply-To: <1365593728-5720-1-git-send-email-mcgrof@do-not-panic.com>

From: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
 backport/Makefile.real                     |    2 +-
 backport/scripts/backport_firmware_install |   21 +++++++++++++++++
 backport/udev/50-compat_firmware.rules     |    4 ++++
 backport/udev/compat_firmware.sh           |   35 ++++++++++++++++++++++++++++
 backport/udev/ubuntu/compat_firmware.sh    |   29 +++++++++++++++++++++++
 gentree.py                                 |    2 +-
 6 files changed, 91 insertions(+), 2 deletions(-)
 create mode 100755 backport/scripts/backport_firmware_install
 create mode 100644 backport/udev/50-compat_firmware.rules
 create mode 100755 backport/udev/compat_firmware.sh
 create mode 100755 backport/udev/ubuntu/compat_firmware.sh

diff --git a/backport/Makefile.real b/backport/Makefile.real
index f70932e..3eb92a7 100644
--- a/backport/Makefile.real
+++ b/backport/Makefile.real
@@ -94,6 +94,7 @@ install: modules
 			gzip -9 $$driver				;\
 	done )
 	@./scripts/check_depmod
+	@./scripts/backport_firmware_install
 	@/sbin/depmod -ae
 	@echo
 	@echo Your backported driver modules should be installed now.
@@ -101,4 +102,3 @@ install: modules
 	@echo
 # FIXME:
 #	install/load/unload/... scripts?
-#	compat firmware class udev stuff
diff --git a/backport/scripts/backport_firmware_install b/backport/scripts/backport_firmware_install
new file mode 100755
index 0000000..e4b9fb0
--- /dev/null
+++ b/backport/scripts/backport_firmware_install
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+if [ -f /usr/bin/lsb_release ]; then
+	LSB_RED_ID=$(/usr/bin/lsb_release -i -s)
+else
+	LSB_RED_ID="Unknown"
+fi
+
+case $LSB_RED_ID in
+"Ubuntu")
+	mkdir -p /lib/udev/ /lib/udev/rules.d/
+	cp udev/ubuntu/compat_firmware.sh /lib/udev/
+	cp udev/50-compat_firmware.rules /lib/udev/rules.d/
+        ;;
+*)
+	mkdir -p /lib/udev/ /lib/udev/rules.d/
+	cp udev/compat_firmware.sh /lib/udev/
+	cp udev/50-compat_firmware.rules /lib/udev/rules.d/
+        ;;
+esac
+
diff --git a/backport/udev/50-compat_firmware.rules b/backport/udev/50-compat_firmware.rules
new file mode 100644
index 0000000..6473788
--- /dev/null
+++ b/backport/udev/50-compat_firmware.rules
@@ -0,0 +1,4 @@
+# do not edit this file, it will be overwritten on update
+
+# compat_firmware-class requests, copies files into the kernel
+SUBSYSTEM=="compat_firmware", ACTION=="add", RUN+="compat_firmware.sh"
diff --git a/backport/udev/compat_firmware.sh b/backport/udev/compat_firmware.sh
new file mode 100755
index 0000000..ef609e7
--- /dev/null
+++ b/backport/udev/compat_firmware.sh
@@ -0,0 +1,35 @@
+#!/bin/sh -e
+
+# This is ported from Ubuntu but ubuntu uses these directories which
+# other distributions don't care about:
+# FIRMWARE_DIRS="/lib/firmware/updates/$(uname -r) /lib/firmware/updates \
+#               /lib/firmware/$(uname -r) /lib/firmware"
+# If your distribution looks for firmware in other directories
+# feel free to extend this and add your own directory here.
+#
+FIRMWARE_DIRS="/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
diff --git a/backport/udev/ubuntu/compat_firmware.sh b/backport/udev/ubuntu/compat_firmware.sh
new file mode 100755
index 0000000..9d4659a
--- /dev/null
+++ b/backport/udev/ubuntu/compat_firmware.sh
@@ -0,0 +1,29 @@
+#!/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
diff --git a/gentree.py b/gentree.py
index 3f875c7..dc54e4b 100755
--- a/gentree.py
+++ b/gentree.py
@@ -324,7 +324,7 @@ def process(kerneldir, outdir, copy_list_file, git_revision=None,
     backport_files = [(x, x) for x in [
         'Kconfig', 'Makefile', 'Makefile.build', 'Makefile.kernel', '.gitignore',
         'Makefile.real', 'compat/', 'include/', 'kconfig/', 'defconfigs/',
-	'scripts/', '.blacklist.map',
+	'scripts/', '.blacklist.map', 'udev/',
     ]]
     if not args.git_revision:
         logwrite('Copy original source files ...')
-- 
1.7.10.4


  parent reply	other threads:[~2013-04-10 11:36 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-10 11:35 [PATCH 00/18] backports: pending patches for Luis Luis R. Rodriguez
2013-04-10 11:35 ` [PATCH 01/18] backports: enable DRM_NOUVEAU for 3.2 Luis R. Rodriguez
2013-04-10 13:15   ` Johannes Berg
2013-04-10 11:35 ` [PATCH 02/18] compat: backport dev_level_ratelimited() Luis R. Rodriguez
2013-04-10 13:16   ` Johannes Berg
2013-04-10 17:07     ` Luis R. Rodriguez
2013-04-10 17:15       ` Johannes Berg
2013-04-11 14:44         ` taking backports out of compat-*.h (was: [PATCH 02/18] compat: backport dev_level_ratelimited()) Johannes Berg
2013-04-11 14:56           ` taking backports out of compat-*.h Hauke Mehrtens
2013-04-10 11:35 ` [PATCH 03/18] compat: backport __i2c_transfer() Luis R. Rodriguez
2013-04-10 13:20   ` Johannes Berg
2013-04-10 11:35 ` [PATCH 04/18] compat: backport devm_regmap_init() Luis R. Rodriguez
2013-04-10 13:19   ` Johannes Berg
2013-04-10 11:35 ` [PATCH 05/18] compat: backport GPIOF_OPEN_DRAIN definition Luis R. Rodriguez
2013-04-10 13:18   ` Johannes Berg
2013-04-10 17:10     ` Luis R. Rodriguez
2013-04-10 11:35 ` [PATCH 06/18] compat: backport ASYNC_DOMAIN_EXCLUSIVE() Luis R. Rodriguez
2013-04-10 13:22   ` Johannes Berg
2013-04-10 17:13     ` Luis R. Rodriguez
2013-04-10 17:20       ` Johannes Berg
2013-04-10 17:26         ` Luis R. Rodriguez
2013-04-10 18:20           ` Johannes Berg
2013-04-10 19:19             ` Luis R. Rodriguez
2013-04-10 19:27               ` Johannes Berg
2013-04-10 19:32                 ` Luis R. Rodriguez
2013-04-10 19:39                   ` Johannes Berg
2013-04-10 19:40                     ` Luis R. Rodriguez
2013-04-10 11:35 ` [PATCH 07/18] compat: backport devres_release() Luis R. Rodriguez
2013-04-10 11:35 ` [PATCH 08/18] compat: backport dev_get_regmap() Luis R. Rodriguez
2013-04-10 11:35 ` [PATCH 09/18] compat: backport devm_ioremap_resource() Luis R. Rodriguez
2013-04-10 11:35 ` [PATCH 10/18] compat: backport module_platform_driver_probe() Luis R. Rodriguez
2013-04-10 11:35 ` [PATCH 11/18] compat: add helpers to aid backport of generic DMA changes for v4l Luis R. Rodriguez
2013-04-10 11:35 ` [PATCH 12/18] compat: backport dma_get_sgtable() Luis R. Rodriguez
2013-04-10 13:26   ` Johannes Berg
2013-04-10 11:35 ` [PATCH 13/18] backports: add blacklist module support Luis R. Rodriguez
2013-04-10 13:35   ` Johannes Berg
2013-04-10 19:57     ` Luis R. Rodriguez
2013-04-10 20:00       ` Johannes Berg
2013-04-10 11:35 ` [PATCH 14/18] backports: add support for module compression Luis R. Rodriguez
2013-04-10 13:40   ` Johannes Berg
2013-04-10 11:35 ` [PATCH 15/18] backports: add check_depmod to look for module search path Luis R. Rodriguez
2013-04-10 13:43   ` Johannes Berg
2013-04-10 11:35 ` Luis R. Rodriguez [this message]
2013-04-10 13:45   ` [PATCH 16/18] backports: add udev rules if required for backported firmware_class Johannes Berg
2013-04-10 13:47   ` Johannes Berg
2013-04-10 20:12     ` Luis R. Rodriguez
2013-04-10 11:35 ` [PATCH 17/18] backports: use depmod -a Luis R. Rodriguez
2013-04-10 13:46   ` Johannes Berg
2013-04-10 11:35 ` [PATCH 18/18] backports: add update-initramfs support Luis R. Rodriguez
2013-04-10 13:48   ` Johannes Berg
2013-04-10 20:12     ` Luis R. Rodriguez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1365593728-5720-17-git-send-email-mcgrof@do-not-panic.com \
    --to=mcgrof@do-not-panic.com \
    --cc=backports@vger.kernel.org \
    --cc=johannes@sipsolutions.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.