Show
Ignore:
Timestamp:
10/12/09 13:34:30 (2 years ago)
Author:
arnonym
Message:

Backport the changes to ffado-diag to better detect the firewire stack.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/libffado-2.0/support/tools/ffado_diag_helpers.py

    r1665 r1686  
    4646 
    4747# modules 
    48 def check_for_module_loaded(modulename): 
    49     log.info("Checking if module '%s' is loaded... " % modulename
    50     f = open('/proc/modules'
     48def check_for_module_loaded(modulename, procfile): 
     49    log.info("Checking if module '%s' is present in %s... " % (modulename, procfile)
     50    f = open(procfile
    5151    lines = f.readlines() 
    5252    f.close() 
    5353    for l in lines: 
    54         mod = l.split()[0] 
    55         if mod == modulename or mod == modulename.replace('-', '_'): 
     54        if l.find(modulename) > -1 or l.find(modulename.replace('-', '_')) > -1: 
    5655            log.info(" found") 
    5756            return True 
     
    7271        return True 
    7372 
     73def check_1394oldstack_active(): 
     74    return check_for_module_loaded('ohci1394', '/proc/interrupts') 
     75 
     76def check_1394oldstack_linked(): 
     77    return os.access('/sys/module/ohci1394', os.F_OK) and \ 
     78           os.access('/sys/module/raw1394',  os.F_OK) 
     79 
    7480def check_1394oldstack_loaded(): 
    7581    retval = True 
    76     if not check_for_module_loaded('ieee1394'): 
    77         retval = False 
    78     if not check_for_module_loaded('ohci1394'): 
    79         retval = False 
    80     if not check_for_module_loaded('raw1394'): 
    81         retval = False 
     82    for modulename in ('ieee1394', 'ohci1394', 'raw1394'): 
     83        if not check_for_module_loaded(modulename, '/proc/modules'): 
     84            retval = False 
    8285    return retval 
    8386 
    8487def check_1394oldstack_present(): 
    8588    retval = True 
    86     if not check_for_module_present('ieee1394'): 
    87         retval = False 
    88     if not check_for_module_present('ohci1394'): 
    89         retval = False 
    90     if not check_for_module_present('raw1394'): 
    91         retval = False 
     89    for modulename in ('ieee1394', 'ohci1394', 'raw1394'): 
     90        if not check_for_module_present(modulename): 
     91            retval = False 
    9292    return retval 
     93 
     94def check_1394newstack_active(): 
     95    return check_for_module_loaded('firewire_ohci', '/proc/interrupts') 
     96 
     97def check_1394newstack_linked(): 
     98    return os.access('/sys/module/firewire_ohci', os.F_OK) 
    9399 
    94100def check_1394newstack_loaded(): 
    95101    retval = True 
    96     if not check_for_module_loaded('firewire-core'): 
    97         retval = False 
    98     if not check_for_module_loaded('firewire-ohci'): 
    99         retval = False 
     102    for modulename in ('firewire_core', 'firewire_ohci'): 
     103        if not check_for_module_loaded(modulename, '/proc/modules'): 
     104            retval = False 
    100105    return retval 
    101106 
    102107def check_1394newstack_present(): 
    103108    retval = True 
    104     if not check_for_module_present('firewire-core'): 
    105         retval = False 
    106     if not check_for_module_present('firewire-ohci'): 
    107         retval = False 
     109    for modulename in ('firewire-core', 'firewire-ohci'): 
     110        if not check_for_module_present(modulename): 
     111            retval = False 
    108112    return retval 
    109113