linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: md@Linux.IT (Marco d'Itri)
To: linux-hotplug@vger.kernel.org
Subject: Re: [PATCH] The Mandriva Collection
Date: Wed, 21 Dec 2005 18:04:08 +0000	[thread overview]
Message-ID: <20051221180408.GB11094@wonderland.linux.it> (raw)
In-Reply-To: <m3k6eaqki0.fsf@dynamo.mandriva.com>

[-- Attachment #1: Type: text/plain, Size: 764 bytes --]

On Dec 21, Olivier Blin <oblin@mandriva.com> wrote:

> It's often more convenient to write hotplug maps, because it allows to
> gather all devices IDs in one file, without RUN settings duplication.
If you want to go for convenience then you should just have a list of
VID/PID pairs to be used to generate maps and rules, which is what most
applications apparently do.

> You have some perl program to write the rules, what does it take as
> input? Maybe it can packaged with udev (IIRC, you're currently
> shipping this script in all your packages using it).
My program just parses the file provided by the package with the list
of supported devices and is barely about the "quick hack" level, I do
not think it's much interesting but here it is.

-- 
ciao,
Marco

[-- Attachment #2: build_rules.pl --]
[-- Type: text/x-perl, Size: 1393 bytes --]

#!/usr/bin/perl -w
# build a udev rules file from the devices list in modules.db

use strict;

my %seen;

print <<END;
BUS!="usb", ACTION!="add", GOTO="eciadsl_usb_add_end"

END

while (<STDIN>) {
	chomp;
	next if /^#/ or /^$/;

	s/\t(\(#\d\))\t/ $1\t/;
	/^([^\t]+)\t+([\da-fA-F]{4})\t+([\da-fA-F]{4})\t+([\da-fA-F]{4})\t+([\da-fA-F]{4})\t+(GS\d{4})\t+(\d)\t+(\d)$/
		or die "Cannot parse the following line:\n$_\n";
	my ($device, $vid1, $pid1, $vid2, $pid2, $chip, $altsync, $altpppoeci)
		= ($1, $2, $3, $4, $5, $6, $7, $8);

	# suppress duplicated devices
	next if $seen{$vid1.$pid1.$vid2.$pid2.$chip.$altsync.$altpppoeci};
	$seen{$vid1.$pid1.$vid2.$pid2.$chip.$altsync.$altpppoeci} = 1;

	# Some devices have the same VID and PID but require different alt
	# parameters. Their owners are out of luck, and will need to manually
	# fix their configuration.
	next if $device =~ /^Linkmax HSA 100$/;

	# sanity check
	die "DUPLICATE: $device!\n" if $seen{$vid1.$pid1} or $seen{$vid2.$pid2};
	$seen{$vid1.$pid1} = 1; $seen{$vid2.$pid2} = 1;

	print "# $device\n";

	print <<"END" if $vid1.$pid1 ne $vid2.$pid2;
SYSFS{idVendor}=="$vid1", SYSFS{idProduct}=="$pid1", \\
	RUN+="/lib/hotplug/eciadsl stage1"
END

	print <<"END";
SYSFS{idVendor}=="$vid2", SYSFS{idProduct}=="$pid2", \\
	RUN+="/lib/hotplug/eciadsl stage2 $altsync $chip"

END
}

print <<END;
LABEL="eciadsl_usb_add_end"
END

exit 0;


  parent reply	other threads:[~2005-12-21 18:04 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-12 17:43 [PATCH] The Mandriva Collection Olivier Blin
2005-12-12 18:21 ` Marco d'Itri
2005-12-12 18:25 ` Scott James Remnant
2005-12-12 18:37 ` Olivier Blin
2005-12-12 18:47 ` Marco d'Itri
2005-12-12 19:13 ` Olivier Blin
2005-12-12 19:17 ` Marco d'Itri
2005-12-12 19:44 ` Olivier Blin
2005-12-12 21:45 ` Olivier Blin
2005-12-13  0:49 ` Marco d'Itri
2005-12-13  5:08 ` Kay Sievers
2005-12-21 17:46 ` Olivier Blin
2005-12-21 17:47 ` Marco d'Itri
2005-12-21 17:51 ` Olivier Blin
2005-12-21 18:04 ` Marco d'Itri [this message]
2006-01-03 19:55 ` Olivier Blin
2006-01-04  1:20 ` Kay Sievers

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=20051221180408.GB11094@wonderland.linux.it \
    --to=md@linux.it \
    --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).