#!/bin/bash

# vi: ts=8 sw=8

# TI 3410/5052 USB Serial Driver Make Devices
#
# Copyright (C) 2004 Texas Instruments
#
# 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.
#
# For questions or problems with this driver, contact Texas Instruments
# technical support, or Al Borchers <alborchers@steinerpoint.com>, or
# Peter Berger <pberger@brimson.com>.
# 
# $Id: make_devices,v 1.6 2004/10/11 16:46:33 borchers Exp $

DEVICE_NAME=/dev/ttyTIUSB
DEVICE_COUNT=16
DEVICE_GROUP=
DEVICE_PERMISSIONS=0600

if test $# -eq 0 -o "$1" = "add"
then
	major=`cat /proc/devices | fgrep ttyTIUSB | cut -d" " -f1`
	if test -z "$major"
	then
		logger -p user.error "$0: cannot create ${DEVICE_NAME}* files, device not found"
		exit 1
	fi

	minor=0
	while test $minor -lt $DEVICE_COUNT
	do
		rm -f $DEVICE_NAME$minor
		mknod -m $DEVICE_PERMISSIONS $DEVICE_NAME$minor c $major $minor
		if test -n "$DEVICE_GROUP"
		then
			chgrp $DEVICE_GROUP $DEVICE_NAME$minor
		fi
		minor=`expr $minor + 1`
	done

elif test "$1" = "remove"
then
	minor=0
	while test $minor -lt $DEVICE_COUNT
	do
		rm -f $DEVICE_NAME$minor
		minor=`expr $minor + 1`
	done
fi
