From: Nikolai Kondrashov <spbnick@gmail.com>
To: Jiri Kosina <jkosina@suse.cz>
Cc: Henrik Rydberg <rydberg@euromail.se>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/3] hid: Enable report fixup on rebind
Date: Sun, 06 May 2012 19:52:22 +0300 [thread overview]
Message-ID: <4FA6AC46.20701@gmail.com> (raw)
In-Reply-To: <alpine.LNX.2.00.1204222325380.1856@pobox.suse.cz>
[-- Attachment #1: Type: text/plain, Size: 1490 bytes --]
Hi Jiri, Henrik,
On 04/23/2012 12:27 AM, Jiri Kosina wrote:
> On Sun, 22 Apr 2012, Henrik Rydberg wrote:
>
>> This patchset contains a resolution to the problem with
>> driver-specific modification of the report descriptor. The core of the
>> problem lies with the dual semantics of hid_parse_report(), which is
>> therefore split into two functions. As a consequence, the hid core can
>> handle the rebind case internally, with no changes to the
>> drivers. Out-of-tree drivers will work fine as long as they operate in
>> the same way as the in-kernel drivers.
>>
>> The first two patches are bug fixes found in the process. I am hoping
>> for some test feedback on those. The third patch is the main one.
>
> Hi Henrik,
>
> thanks a lot for looking into this. I will look into the patches in more
> detail tomorrow. I am now just adding Nikolai to CC, as he was the first
> one to bring this up and actually has a driver that exposed the fact that
> just freeing/reinstatiating rdesc is not enough.
I've managed to throw together a script which rebinds a device to a specific
out-of-tree HID driver automatically. Please find it attached. I'll be
bundling it with the modules, probably.
I'm planning to use it with udev rules looking like this one:
SUBSYSTEM=="hid", ACTION=="add", ENV{HID_ID}=="0003:0000172F:*", \
RUN+="/usr/local/bin/digimend-rebind"
So, the out-of-tree HID module problem is finally solved, at least for my
current uses. Thanks a lot!
Sincerely,
Nick
[-- Attachment #2: digimend-rebind --]
[-- Type: text/plain, Size: 2255 bytes --]
#!/bin/sh
#
# DIGImend specific driver rebinding script. To be invoked by udev.
# Author: Nikolai Kondrashov <spbnick@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Write a string to a file, ignoring ENODEV.
write_ignore_enodev() {
local str="$1"
local path="$2"
local output=""
# Write the string with tee, capturing error output
if ! output="`(echo \"$str\" | tee \"$path\" >/dev/null) 2>&1`"; then
# Raise anything except ENODEV
if [ "${output##*: }" != "No such device" ]; then
echo "$output" >&2
return 1
fi
fi
}
(
set -e -u
progname="`basename \"$0\"`"
id="`basename $DEVPATH`"
current_driver_path="`readlink -v -f /sys${DEVPATH}/driver`"
if [ -e "$current_driver_path" ]; then
current_driver="`basename \"$current_driver_path\"`"
else
current_driver=""
fi
specific_module="`modprobe -R $MODALIAS`"
# Assume the driver would be called the same as module,
# but without the "hid_" or "hid-" prefix
specific_driver="${specific_module#hid[_-]}"
specific_driver_path="/sys/bus/hid/drivers/$specific_driver"
if [ "$current_driver" != "$specific_driver" ]; then
logger -p daemon.notice -t "$progname" "rebinding $DEVPATH"
# Ensure the specific driver module is loaded
modprobe "$specific_module"
# Unbind from the current driver, if any
if [ -n "$current_driver" ]; then
write_ignore_enodev "$id" "$current_driver_path/unbind"
fi
# Bind to the specific driver
write_ignore_enodev "$id" "$specific_driver_path/bind"
fi
) 2>&1 | logger -p daemon.warning -t "$progname"
next prev parent reply other threads:[~2012-05-06 16:52 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-22 12:21 [PATCH 0/3] hid: Enable report fixup on rebind Henrik Rydberg
2012-04-22 12:21 ` [PATCH 1/3] hid-hyperv: Do not use hid_parse_report() directly Henrik Rydberg
2012-04-27 8:53 ` Jiri Kosina
2012-04-30 20:15 ` KY Srinivasan
2012-04-22 12:21 ` [PATCH 2/3] hid-logitech: Collect report descriptors before sending Henrik Rydberg
[not found] ` <CAE7qMrqEJmBWo7JDHuB2DnWJ4vkvv9jya7RDJguiXsrs2xgadQ@mail.gmail.com>
2012-04-30 14:44 ` Benjamin Tissoires
2012-04-30 14:44 ` Benjamin Tissoires
2012-04-30 18:14 ` Henrik Rydberg
2012-04-22 12:21 ` [PATCH 3/3] hid: Handle driver-specific device descriptor in core Henrik Rydberg
2012-04-22 21:27 ` [PATCH 0/3] hid: Enable report fixup on rebind Jiri Kosina
2012-04-23 7:52 ` Nikolai Kondrashov
2012-04-29 15:33 ` Nikolai Kondrashov
2012-04-30 12:06 ` Henrik Rydberg
2012-04-30 12:06 ` Jiri Kosina
2012-04-30 12:25 ` Nikolai Kondrashov
2012-05-06 16:52 ` Nikolai Kondrashov [this message]
2012-05-06 16:54 ` Nikolai Kondrashov
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=4FA6AC46.20701@gmail.com \
--to=spbnick@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=jkosina@suse.cz \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rydberg@euromail.se \
/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.