FreeBSD/sys/arm/ti/am335x/am335x_dmtpps.c
/*
 * See if our tunable is set to the name of the input pin.  If not, that's NOT
 * an error, return 0.  If so, try to configure that pin as a timer capture
 * input pin, and if that works, then we have our timer unit number and if it
 * fails that IS an error, return -1.
 */
See if our tunable is set to the name of the input pin.  If not, that's NOT
an error, return 0.  If so, try to configure that pin as a timer capture
input pin, and if that works, then we have our timer unit number and if it
fails that IS an error, return -1.
See if our tunable is set to the name of the input pin . If not that ' s NOT an error return 0 . If so try to configure that pin as a timer capture input pin and if that works then we have our timer unit number and if it fails that IS an error return - 1 .
static int
dmtpps_find_tmr_num_by_tunable()
{
	struct padinfo *pi;
	char iname[20];
	char muxmode[12];
	const char * ballname;
	int err;
	if (!TUNABLE_STR_FETCH("hw.am335x_dmtpps.input", iname, sizeof(iname)))
		return (0);
	ballname = dmtpps_translate_nickname(iname);
	for (pi = dmtpps_padinfo; pi->ballname != NULL; pi++) {
		if (strcmp(ballname, pi->ballname) != 0)
			continue;
		snprintf(muxmode, sizeof(muxmode), "timer%d", pi->tmr_num);
		err = ti_pinmux_padconf_set(pi->ballname, muxmode,
		    PADCONF_INPUT);
		if (err != 0) {
			printf("am335x_dmtpps: unable to configure capture pin "
			    "for %s to input mode\n", muxmode);
			return (-1);
		} else if (bootverbose) {
			printf("am335x_dmtpps: configured pin %s as input "
			    "for %s\n", iname, muxmode);
		}
		return (pi->tmr_num);
	}
	printf("am335x_dmtpps: unknown pin name '%s'\n", iname);
	return (-1);
}
static int dmtpps_find_tmr_num_by_tunable ( ) { struct padinfo * pi ; char iname [ 20 ] ; char muxmode [ 12 ] ; const char * ballname ; int err ; if ( ! TUNABLE_STR_FETCH ( " " , iname , sizeof ( iname ) ) ) return ( 0 ) ; ballname = dmtpps_translate_nickname ( iname ) ; for ( pi = dmtpps_padinfo ; pi -> ballname != NULL ; pi ++ ) { if ( strcmp ( ballname , pi -> ballname ) != 0 ) continue ; snprintf ( muxmode , sizeof ( muxmode ) , " " , pi -> tmr_num ) ; err = ti_pinmux_padconf_set ( pi -> ballname , muxmode , PADCONF_INPUT ) ; if ( err != 0 ) { printf ( " " " \n " , muxmode ) ; return ( -1 ) ; } else if ( bootverbose ) { printf ( " " " \n " , iname , muxmode ) ; } return ( pi -> tmr_num ) ; } printf ( " \n " , iname ) ; return ( -1 ) ; }
See if our tunable is set to the name of the input pin.
See if our tunable is set to the name of the input pin .
/* Invalid name in the tunable, that's an error. */