1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2024-12-17 04:51:31 +03:00
mobile-nixos/devices/asus-dumo/fixup_sdhci_arasan_task.rb
Samuel Dionne-Riel cd2287be99 asus-dumo: Move MMC fixup task into a file
It shouldn't have been made inline from the beginning.
2021-01-30 23:07:57 -05:00

42 lines
1.0 KiB
Ruby

# This hack unbinds and rebinds the currently problematic storage driver.
class Tasks::FixupSDHCIArasan < SingletonTask
MAX = 60;
NAME = "fe330000.sdhci"
DRIVER = "/sys/bus/platform/drivers/sdhci-arasan"
GLOB = "#{DRIVER}/#{NAME}/mmc_host/mmc*/mmc*/block"
def initialize()
add_dependency(:Mount, "/sys")
add_dependency(:Files, DRIVER)
#add_dependency(:Target, :Environment)
end
def run()
tries = 0
$stdout.print " -> Waiting for #{NAME}"
$stdout.flush
until Dir.glob(GLOB).length > 0 do
$stdout.print "."
$stdout.flush
tries += 1
begin
System.write(File.join(DRIVER, "unbind"), NAME)
rescue => e
$logger.fatal(e.inspect)
end
begin
System.write(File.join(DRIVER, "bind"), NAME)
rescue => e
$logger.fatal(e.inspect)
end
sleep(1)
raise "Couldn't get #{NAME} up in #{tries} tries." if tries > MAX
end
$stdout.puts "!\n"
log("Took #{tries} tries for #{NAME} to appear...")
end
end