#!/bin/sh -efu

. guess-functions

if [ -s "$KERNEL_CONFIG" ]; then
	grep -qs '^[[:space:]]*CONFIG_USB_LIBUSUAL=y' "$KERNEL_CONFIG" ||
		exit 0
fi

found=
if [ -f "$SYSFS_PATH/$1"/uevent ]; then
	! egrep -qs '^DRIVER=(ub|usb-storage)$' "$SYSFS_PATH/$1"/uevent ||
		found=1
fi

if [ -z "$found" -a -e "$SYSFS_PATH/$1"/driver ]; then
	t="$(readlink -ev "$SYSFS_PATH/$1"/driver 2>/dev/null)" ||:
	case "${t##*/}" in
		ub|usb-storage) found=1
			;;
	esac
fi

[ -n "$found" ] ||
	exit 0

guess_module ub
guess_module usb-storage
