def validate_relays(relays):
    """
        Validate that each relay specifies either chip,line or name
    """
    for ident,cfg in relays.items():
        has_chip_line = "chip" in cfg and "line" in cfg
        has_name = "name" in cfg
        if has_chip_line and has_name:
            return (False, "Relay %s: cannot specify both GPIO name and chip name+line number" % ident)
        if not has_chip_line and not has_name:
            return (False, "Relay %s: must specify either GPIO name or chip name+line number" % ident)
    return (True, None)