#!/bin/sh

# 01:08.0 Class 0700: 12b9:1008 (rev 01) (prog-if 02)
#        Subsystem: 12b9:00ad
#        Flags: medium devsel, IRQ 11
#        I/O ports at dff0
#        Capabilities: [dc] Power Management version 2

# A nasty hack to make the USR/3COM pci modem work.

#Scan the pci bus exit if no modem.
/sbin/lspci -d 12b9:1008 | /bin/grep -q "US Robotics" || exit

#Figure out what resources we need.
ioport=`/sbin/lspci -nvd 12b9:1008 | /bin/grep "I/O ports" | awk '{ print $4 }'`
irq=`/sbin/lspci -nvd 12b9:1008 | /bin/grep " IRQ " | awk '{ print $5 }'`

#Use the ttyS3 device, COM 4 under DOS.
serport=/dev/ttyS3

#Bind modem to device.
/bin/setserial $serport irq $irq port 0x$ioport ^fourport ^auto_irq skip_test autoconfig spd_vhi
/bin/setserial $serport skip_test autoconfig 

#check for symlink /dev/modem
if [ -L /dev/modem ]; then
	#if it exists bail out
	exit 0
	else
	#if not set the symlink. 
	ln -s $serport /dev/modem
fi
#In the unlikely event /dev/modem is not a symlink this will produce an error.

