lkml.org 
[lkml]   [2022]   [Aug]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v1 11/14] nvmem: core: export nvmem device size
    Date
    Export the size of the nvmem device. NVMEM layout drivers might need it
    and might not have access to the device which is registering the NVMEM
    device.

    Signed-off-by: Michael Walle <michael@walle.cc>
    ---
    drivers/nvmem/core.c | 13 +++++++++++++
    include/linux/nvmem-consumer.h | 6 ++++++
    2 files changed, 19 insertions(+)

    diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
    index cbfbe6264e6c..f46ae358fe88 100644
    --- a/drivers/nvmem/core.c
    +++ b/drivers/nvmem/core.c
    @@ -2031,6 +2031,19 @@ const char *nvmem_dev_name(struct nvmem_device *nvmem)
    }
    EXPORT_SYMBOL_GPL(nvmem_dev_name);

    +/**
    + * nvmem_device_size() - Get the size of a given nvmem device.
    + *
    + * @nvmem: nvmem device.
    + *
    + * Return: size of the nvmem device.
    + */
    +size_t nvmem_device_size(struct nvmem_device *nvmem)
    +{
    + return nvmem->size;
    +}
    +EXPORT_SYMBOL_GPL(nvmem_device_size);
    +
    static int __init nvmem_init(void)
    {
    return bus_register(&nvmem_bus_type);
    diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h
    index 761b8ef78adc..6b2a80a5fdd5 100644
    --- a/include/linux/nvmem-consumer.h
    +++ b/include/linux/nvmem-consumer.h
    @@ -90,6 +90,7 @@ ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem,
    struct nvmem_cell_info *info, void *buf);
    int nvmem_device_cell_write(struct nvmem_device *nvmem,
    struct nvmem_cell_info *info, void *buf);
    +size_t nvmem_device_size(struct nvmem_device *nvmem);

    const char *nvmem_dev_name(struct nvmem_device *nvmem);

    @@ -219,6 +220,11 @@ static inline int nvmem_device_write(struct nvmem_device *nvmem,
    return -EOPNOTSUPP;
    }

    +static inline size_t nvmem_device_size(struct nvmem_device *nvmem)
    +{
    + return 0;
    +}
    +
    static inline const char *nvmem_dev_name(struct nvmem_device *nvmem)
    {
    return NULL;
    --
    2.30.2
    \
     
     \ /
      Last update: 2022-08-25 23:47    [W:2.854 / U:0.716 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site