• Hans de Goede's avatar
    leds: led-class: Add generic [devm_]led_get() · abc3100f
    Hans de Goede authored
    Add a generic [devm_]led_get() method which can be used on both devicetree
    and non devicetree platforms to get a LED classdev associated with
    a specific function on a specific device, e.g. the privacy LED associated
    with a specific camera sensor.
    
    Note unlike of_led_get() this takes a string describing the function
    rather then an index. This is done because e.g. camera sensors might
    have a privacy LED, or a flash LED, or both and using an index
    approach leaves it unclear what the function of index 0 is if there is
    only 1 LED.
    
    This uses a lookup-table mechanism for non devicetree platforms.
    This allows the platform code to map specific LED class_dev-s to a specific
    device,function combinations this way.
    
    For devicetree platforms getting the LED by function-name could be made
    to work using the standard devicetree pattern of adding a -names string
    array to map names to the indexes.
    Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
    Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
    Signed-off-by: default avatarLee Jones <lee@kernel.org>
    Link: https://lore.kernel.org/r/20230120114524.408368-5-hdegoede@redhat.com
    abc3100f
led-class.c 15.5 KB