[PATCH] PCMCIA cardmgr improvements

"Maksim (Max) Krasnyanskiy" <[email protected]> Thu, 18 Jul 2002 09:34:14 -0700
Newsgroups gmane.linux.pcmcia.devel
Message-ID <[email protected]>
Hi David, Folks,

I was thinking about integrating Bluetooth pcmcia scripts into pcmcia-cs 
package
and ended up hacking cardmgr :). Once everything was working I decided to send
you guys a patch.

Here goes the story. As most of you probably know the majority of Bluetooth
pccards identify itself as a serial adapter. They are in fact uart based 
devices
and show up as a serial (ttyS) port when plugged in. In order to support 
them as
Bluetooth devices we have to attach a special line discipline to their ttys.
Some of the uart based Bluetooth devices require different uart initialization
(baud rate, protocol, etc). All this initialization is done in utility called
'hciattach'. Which we have to call when uart based Bluetooth card is 
plugged in.
We used to call hciattach from /etc/pcmcia/serial script but this solution is
pretty ugly and requires modification of the serial script.

Not that you know the story :) here goes the patch description.
Basically patch implements three following things:
- (#1) Support for multiple classes.
Currently any device defined in the pcmcia config can belong to only
one class. Patch extends config syntax and allows users to specify
multiple classes. Classes are added in the order specified in config.
Class[0] is considered a primary class. Class scripts are executed in
the same order (ie class[0], class[1], etc).
Usage example:

device "serial_cs"
   class "serial", "bluetooth" module "serial_cs"

card "Xircom CreditCard Bluetooth Adapter"
   version "Xircom", "*", "CBT"
   bind "serial_cs"

So, serial_cs now belongs to two classes "serial" and "bluetooth".
Card manager will execute /etc/pcmcia/bluetooth after executing
/etc/pcmcia/serial, and we can do Bluetooth specific initialization
there.

- (#2) Support for adding classes,modules,etc to already defined devices.
This is simply an extension of the above feature. Currently
if device is defined more then once cardmgr will simply allocate new
card_info_t for each definition and link it to the list. With the patch
it will actually add options,modules,etc to already defined device.
(which is imo more logical behavior anyway).
So, one can write something like this:

device "serial_cs"
   class "serial" module "serial_cs"

device "serial_cs"
   class "bluetooth"

This actually simplifies distribution of the Bluetooth packages.
/etc/pcmcia/config doesn't have to be modified. All we have to do
is install bluetooth.conf into /etc/pcmcia.
bluetooth.conf defines bunch of Bleutooth pccards and defines
device "serial_cs"
   class "bluetooth"

And last but not least :)
- (#3) Export card hw information in the environment variables.
As I mentioned above hciattach initializes baud rate and
other uart specific things. It's done based on the vendor and
devices ids. So, we used to call "cardctl ident socket#" and
parsed it's output. Since all that information is available in cardmgr
it makes sense to export couple of environment variables before
calling the script (it's certainly less expensive than calling
cardctl and parsing the output).
So, with the patch cardmgr exports
   VENDORID = "manfid,cardid"
   FUNCTION = "card function"
   CARDNAME = "card name"

All these features will probably be useful for other subsystems besides
Bluetooth.

bluetooth script that uses above features is available here
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/bluez/utils/pcmcia/bluetooth?rev=1.2&content-type=text/vnd.viewcvs-markup

Patch against 3.1.34 is here
http://bluez.sf.net/patches/patch.cardmgr-3.1.34.gz

Please apply.

Max
http://bluez.sf.net
http://vtun.sf.net



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf