• Rafał Miłecki's avatar
    nvmem: core: support specifying both: cell raw data & post read lengths · 55d4980c
    Rafał Miłecki authored
    Callback .read_post_process() is designed to modify raw cell content
    before providing it to the consumer. So far we were dealing with
    modifications that didn't affect cell size (length). In some cases
    however cell content needs to be reformatted and resized.
    
    It's required e.g. to provide properly formatted MAC address in case
    it's stored in a non-binary format (e.g. using ASCII).
    
    There were few discussions how to optimally handle that. Following
    possible solutions were considered:
    1. Allow .read_post_process() to realloc (resize) content buffer
    2. Allow .read_post_process() to adjust (decrease) just buffer length
    3. Register NVMEM cells using post-read sizes
    
    The preferred solution was the last one. The problem is that simply
    adjusting "bytes" in NVMEM providers would result in core code NOT
    passing whole raw data to .read_post_process() callbacks. It means
    callback functions couldn't do their job without somehow manually
    reading original cell content on their own.
    
    This patch deals with that by registering NVMEM cells with both lengths:
    raw content one and post read one. It allows:
    1. Core code to read whole raw cell content
    2. Callbacks to return content they want
    Signed-off-by: default avatarRafał Miłecki <rafal@milecki.pl>
    Signed-off-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
    Link: https://lore.kernel.org/r/20230404172148.82422-35-srinivas.kandagatla@linaro.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    55d4980c
core.c 48.3 KB