403Webshell
Server IP : 104.21.38.3  /  Your IP : 162.158.88.156
Web Server : Apache
System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64
User : www ( 1000)
PHP Version : 7.4.33
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/src/linux-headers-5.15.0-142/tools/testing/selftests/gpio/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/src/linux-headers-5.15.0-142/tools/testing/selftests/gpio/gpio-mockup-sysfs.sh
# SPDX-License-Identifier: GPL-2.0

# Overrides functions in gpio-mockup.sh to test using the GPIO SYSFS uAPI

SYSFS=`grep -w sysfs /proc/mounts | cut -f2 -d' '`
[ -d "$SYSFS" ] || skip "sysfs is not mounted"

GPIO_SYSFS="${SYSFS}/class/gpio"
[ -d "$GPIO_SYSFS" ] || skip "CONFIG_GPIO_SYSFS is not selected"

PLATFORM_SYSFS=$SYSFS/devices/platform

sysfs_nr=
sysfs_ldir=

# determine the sysfs GPIO number given the $chip and $offset
# e.g. gpiochip1:32
find_sysfs_nr()
{
	# e.g. /sys/devices/platform/gpio-mockup.1/gpiochip1
	local platform=$(find $PLATFORM_SYSFS -mindepth 2 -maxdepth 2 -type d -name $chip)
	[ "$platform" ] || fail "can't find platform of $chip"
	# e.g. /sys/devices/platform/gpio-mockup.1/gpio/gpiochip508/base
	local base=$(find ${platform%/*}/gpio/ -mindepth 2 -maxdepth 2 -type f -name base)
	[ "$base" ] || fail "can't find base of $chip"
	sysfs_nr=$(($(< "$base") + $offset))
	sysfs_ldir="$GPIO_SYSFS/gpio$sysfs_nr"
}

acquire_line()
{
	[ "$sysfs_nr" ] && return
	find_sysfs_nr
	echo "$sysfs_nr" > "$GPIO_SYSFS/export"
}

# The helpers being overridden...
get_line()
{
	[ -e "$sysfs_ldir/value" ] && echo $(< "$sysfs_ldir/value")
}

set_line()
{
	acquire_line

	for option in $*; do
		case $option in
		active-high)
			echo 0 > "$sysfs_ldir/active_low"
			;;
		active-low)
			echo 1 > "$sysfs_ldir/active_low"
			;;
		input)
			echo "in" > "$sysfs_ldir/direction"
			;;
		0)
			echo "out" > "$sysfs_ldir/direction"
			echo 0 > "$sysfs_ldir/value"
			;;
		1)
			echo "out" > "$sysfs_ldir/direction"
			echo 1 > "$sysfs_ldir/value"
			;;
		esac
	done
}

release_line()
{
	[ "$sysfs_nr" ] || return 0
	echo "$sysfs_nr" > "$GPIO_SYSFS/unexport"
	sysfs_nr=
	sysfs_ldir=
}

Youez - 2016 - github.com/yon3zu
LinuXploit