From: Martin Pitt <martin.pitt@ubuntu.com>
To: linux-hotplug@vger.kernel.org
Subject: Re: [PATCH] keymap: support for force_release quirk
Date: Mon, 14 Dec 2009 09:14:50 +0000 [thread overview]
Message-ID: <20091214091450.GC1943@piware.de> (raw)
In-Reply-To: <20091214001219.GA17792@sig21.net>
[-- Attachment #1: Type: text/plain, Size: 2682 bytes --]
Hello Johannes,
thanks for working on this, and sorry for the late response (had a
busy week..)
Some remarks:
> --- /dev/null
> +++ b/extras/keymap/95-keyboard-force-release.rules
> @@ -0,0 +1,24 @@
> +# Set model specific atkbd force_release quirk
> +#
> +# Serveral laptops have hotkeys which don't generate release events,
Typo → "Several"
> +ACTION!="add", GOTO="force_release_end"
Can we please also do this on "change", so that rule changes can be
picked up on package upgrades? Packages which ship udev rules should
usually do something like
udevadm trigger --action=change --subsystem-match=...
> +ENV{DMI_VENDOR}=="[sS][aA][mM][sS][uU][nN][gG]*", ATTR{[dmi/id]product_name}=="*N130*", RUN+="keyboard-force-release.sh $sys$devpath samsung-other"
For consistency, can we just use $devpath here, and care for
prepending /sys in the callout?
> --- /dev/null
> +++ b/extras/keymap/keyboard-force-release.sh
> @@ -0,0 +1,22 @@
> +#!/bin/sh -e
> +# read list of scancodes, convert hex to decimal and
> +# append to the atkbd force_release sysfs attribute
> +# $1 sysfs devpath for serioX
> +# $2 file with scancode list (hex or dec)
> +
> +case "$2" in
> + /*) scf="$2" ;;
> + *) scf="${0%keyboard-force-release.sh}/keymaps/force-release/$2" ;;
I don't think we should really tie the callout path to the map
directory. Just hardcoding /lib/udev/keymaps/force-release/ seems
cleaner to me.
> +attr=`cat "$1/force_release"`
Please use "read" to avoid calling an external program and a subshell.
The script is -e already (as it should be), so I think the error
message if the file doesn't exist (older kernels) will be okay.
> +while read scancode dummy; do
> + case "$scancode" in
> + \#*) ;;
> + *)
> + scancode=$(($scancode))
> + [ -n "$attr" ] && attr="$attr,$scancode" || attr="$scancode"
> + ;;
> + esac
> +done <"$scf"
> +echo "$attr" >"$1/force_release"
Corresponding to comment above, please use /sys/$1 here.
A gotcha that I see here is that the force_release only ever gets
appended to. I. e. whenever we run udevtrigger, we'd append the same
keys again. POSIX shell doesn't have elaborate substring matching
capabilities like bash's ${x/pattern/string}, so it might not be too
easy to check if we already have a key in POSIX sh. (But please don't
call grep in a loop; let's rather rewrite this bit in C). There might
be some trickery with splitting by IFS=, into an array or so, if you
want to keep using sh?
Thanks!
Martin
--
Martin Pitt | http://www.piware.de
Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org)
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
next prev parent reply other threads:[~2009-12-14 9:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-14 0:12 [PATCH] keymap: support for force_release quirk Johannes Stezenbach
2009-12-14 9:14 ` Martin Pitt [this message]
2009-12-14 10:28 ` Johannes Stezenbach
2009-12-14 10:34 ` Kay Sievers
2009-12-14 12:37 ` Johannes Stezenbach
2009-12-14 12:45 ` Martin Pitt
2009-12-14 12:50 ` Kay Sievers
2009-12-14 12:55 ` Johannes Stezenbach
2009-12-14 13:32 ` Martin Pitt
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=20091214091450.GC1943@piware.de \
--to=martin.pitt@ubuntu.com \
--cc=linux-hotplug@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).