Home | History | Annotate | Download | only in SUNWatheros
      1 #! /usr/bin/sh
      2 #
      3 # CDDL HEADER START
      4 #
      5 # The contents of this file are subject to the terms of the
      6 # Common Development and Distribution License (the "License").
      7 # You may not use this file except in compliance with the License.
      8 #
      9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     10 # or http://www.opensolaris.org/os/licensing.
     11 # See the License for the specific language governing permissions
     12 # and limitations under the License.
     13 #
     14 # When distributing Covered Code, include this CDDL HEADER in each
     15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     16 # If applicable, add the following below this CDDL HEADER, with the
     17 # fields enclosed by brackets "[]" replaced with your own identifying
     18 # information: Portions Copyright [yyyy] [name of copyright owner]
     19 #
     20 # CDDL HEADER END
     21 #
     22 
     23 #
     24 # Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
     25 # Use is subject to license terms.
     26 #
     27 # ident	"%Z%%M%	%I%	%E% SMI"
     28 #
     29 
     30 # Driver info
     31 DRV=ath
     32 DRVALIAS='"pci168c,12" "pci168c,13" "pci168c,1014" "pci168c,1a" "pci168c,1b"'
     33 
     34 BASEDIR=${BASEDIR:-/}
     35 
     36 # Function: check_add_drv()
     37 #
     38 # This function will check if add_drv has been executed.
     39 # If not simply calls add_drv. Otherwise adds entries to
     40 # driver_aliases, driver_classes and minor_perm if necessary.
     41 # The syntax of this function is the same as add_drv. 
     42 
     43 check_add_drv()
     44 {
     45 	CMD="add_drv"
     46 
     47 	ALIAS=""
     48 	ALIASDIR="${BASEDIR}"/etc/driver_aliases
     49 	while getopts i:b: opt 2>/dev/null; do
     50 		case "$opt" in
     51 		i)	CMD="${CMD} -i ${OPTARG}"
     52 			ALIAS=`echo ${OPTARG} | /usr/bin/sed -e "s/'//g"`
     53 			;;
     54 		b)	if [ "${OPTARG}" != "/" ]; then
     55 				# On a client
     56 				# modify the sytem files and touch
     57 				# /reconfigure for reconfigure reboot
     58 				CMD="${CMD} -b \"${OPTARG}\""
     59 			fi
     60 			;;
     61 		\?)	echo "check_add_drv(): Unknown option $opt"
     62 			return
     63 			;;
     64 		esac
     65 	done
     66 	shift `/usr/bin/expr ${OPTIND} - 1`
     67 	DRIVER=$1
     68 	CMD="${CMD} ${DRIVER}"
     69 
     70 	# Make sure add_drv has not been previously executed
     71 	# before attempting to add the driver
     72 	/usr/bin/egrep -s "^${DRIVER}[ 	]" "$BASEDIR"/etc/name_to_major
     73 
     74 	if [ $? -ne 0 ]; then
     75 		eval ${CMD}
     76 		if [ $? -ne 0 ]; then
     77 			echo "Failed add_drv ${DRIVER}!\n" >&2
     78 			exit 1
     79 		fi
     80 	else
     81 		# Add driver entry if necessary
     82 		if [ -n "${ALIAS}" ]; then
     83 			for i in ${ALIAS}; do
     84 				/usr/bin/egrep -s "^${DRIVER}[ 	]+$i" ${ALIASDIR}
     85 				if [ $? -ne 0 ]; then
     86 					echo "${DRIVER} $i" >> ${ALIASDIR}
     87 				fi
     88 			done
     89 		fi
     90 	fi
     91 }
     92 
     93 check_add_drv -b "${BASEDIR}" -i "'${DRVALIAS}'" ${DRV}
     94