#include <linux/device.h>
#include <linux/export.h>
#include <linux/fs.h>
#include <linux/idr.h>
#include <linux/init.h>
#include <linux/kref.h>
#include <linux/module.h>
#include <linux/nvmem-consumer.h>
#include <linux/nvmem-provider.h>
#include <linux/gpio/consumer.h>
#include <linux/of.h>
#include <linux/slab.h>
#include "internals.h"
#define to_nvmem_device(d) …
#define FLAG_COMPAT …
struct nvmem_cell_entry { … };
struct nvmem_cell { … };
static DEFINE_MUTEX(nvmem_mutex);
static DEFINE_IDA(nvmem_ida);
static DEFINE_MUTEX(nvmem_cell_mutex);
static LIST_HEAD(nvmem_cell_tables);
static DEFINE_MUTEX(nvmem_lookup_mutex);
static LIST_HEAD(nvmem_lookup_list);
static BLOCKING_NOTIFIER_HEAD(nvmem_notifier);
static int __nvmem_reg_read(struct nvmem_device *nvmem, unsigned int offset,
void *val, size_t bytes)
{ … }
static int __nvmem_reg_write(struct nvmem_device *nvmem, unsigned int offset,
void *val, size_t bytes)
{ … }
static int nvmem_access_with_keepouts(struct nvmem_device *nvmem,
unsigned int offset, void *val,
size_t bytes, int write)
{ … }
static int nvmem_reg_read(struct nvmem_device *nvmem, unsigned int offset,
void *val, size_t bytes)
{ … }
static int nvmem_reg_write(struct nvmem_device *nvmem, unsigned int offset,
void *val, size_t bytes)
{ … }
#ifdef CONFIG_NVMEM_SYSFS
static const char * const nvmem_type_str[] = …;
#ifdef CONFIG_DEBUG_LOCK_ALLOC
static struct lock_class_key eeprom_lock_key;
#endif
static ssize_t type_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RO(type);
static ssize_t force_ro_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static ssize_t force_ro_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static DEVICE_ATTR_RW(force_ro);
static struct attribute *nvmem_attrs[] = …;
static ssize_t bin_attr_nvmem_read(struct file *filp, struct kobject *kobj,
struct bin_attribute *attr, char *buf,
loff_t pos, size_t count)
{ … }
static ssize_t bin_attr_nvmem_write(struct file *filp, struct kobject *kobj,
struct bin_attribute *attr, char *buf,
loff_t pos, size_t count)
{ … }
static umode_t nvmem_bin_attr_get_umode(struct nvmem_device *nvmem)
{ … }
static umode_t nvmem_bin_attr_is_visible(struct kobject *kobj,
struct bin_attribute *attr, int i)
{ … }
static umode_t nvmem_attr_is_visible(struct kobject *kobj,
struct attribute *attr, int i)
{ … }
static struct nvmem_cell *nvmem_create_cell(struct nvmem_cell_entry *entry,
const char *id, int index);
static ssize_t nvmem_cell_attr_read(struct file *filp, struct kobject *kobj,
struct bin_attribute *attr, char *buf,
loff_t pos, size_t count)
{ … }
static struct bin_attribute bin_attr_rw_nvmem = …;
static struct bin_attribute *nvmem_bin_attributes[] = …;
static const struct attribute_group nvmem_bin_group = …;
static const struct attribute_group *nvmem_dev_groups[] = …;
static struct bin_attribute bin_attr_nvmem_eeprom_compat = …;
static int nvmem_sysfs_setup_compat(struct nvmem_device *nvmem,
const struct nvmem_config *config)
{ … }
static void nvmem_sysfs_remove_compat(struct nvmem_device *nvmem,
const struct nvmem_config *config)
{ … }
static int nvmem_populate_sysfs_cells(struct nvmem_device *nvmem)
{ … }
#else
static int nvmem_sysfs_setup_compat(struct nvmem_device *nvmem,
const struct nvmem_config *config)
{
return -ENOSYS;
}
static void nvmem_sysfs_remove_compat(struct nvmem_device *nvmem,
const struct nvmem_config *config)
{
}
#endif
static void nvmem_release(struct device *dev)
{ … }
static const struct device_type nvmem_provider_type = …;
static struct bus_type nvmem_bus_type = …;
static void nvmem_cell_entry_drop(struct nvmem_cell_entry *cell)
{ … }
static void nvmem_device_remove_all_cells(const struct nvmem_device *nvmem)
{ … }
static void nvmem_cell_entry_add(struct nvmem_cell_entry *cell)
{ … }
static int nvmem_cell_info_to_nvmem_cell_entry_nodup(struct nvmem_device *nvmem,
const struct nvmem_cell_info *info,
struct nvmem_cell_entry *cell)
{ … }
static int nvmem_cell_info_to_nvmem_cell_entry(struct nvmem_device *nvmem,
const struct nvmem_cell_info *info,
struct nvmem_cell_entry *cell)
{ … }
int nvmem_add_one_cell(struct nvmem_device *nvmem,
const struct nvmem_cell_info *info)
{ … }
EXPORT_SYMBOL_GPL(…);
static int nvmem_add_cells(struct nvmem_device *nvmem,
const struct nvmem_cell_info *info,
int ncells)
{ … }
int nvmem_register_notifier(struct notifier_block *nb)
{ … }
EXPORT_SYMBOL_GPL(…);
int nvmem_unregister_notifier(struct notifier_block *nb)
{ … }
EXPORT_SYMBOL_GPL(…);
static int nvmem_add_cells_from_table(struct nvmem_device *nvmem)
{ … }
static struct nvmem_cell_entry *
nvmem_find_cell_entry_by_name(struct nvmem_device *nvmem, const char *cell_id)
{ … }
static int nvmem_validate_keepouts(struct nvmem_device *nvmem)
{ … }
static int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_node *np)
{ … }
static int nvmem_add_cells_from_legacy_of(struct nvmem_device *nvmem)
{ … }
static int nvmem_add_cells_from_fixed_layout(struct nvmem_device *nvmem)
{ … }
int nvmem_layout_register(struct nvmem_layout *layout)
{ … }
EXPORT_SYMBOL_GPL(…);
void nvmem_layout_unregister(struct nvmem_layout *layout)
{ … }
EXPORT_SYMBOL_GPL(…);
struct nvmem_device *nvmem_register(const struct nvmem_config *config)
{ … }
EXPORT_SYMBOL_GPL(…);
static void nvmem_device_release(struct kref *kref)
{ … }
void nvmem_unregister(struct nvmem_device *nvmem)
{ … }
EXPORT_SYMBOL_GPL(…);
static void devm_nvmem_unregister(void *nvmem)
{ … }
struct nvmem_device *devm_nvmem_register(struct device *dev,
const struct nvmem_config *config)
{ … }
EXPORT_SYMBOL_GPL(…);
static struct nvmem_device *__nvmem_device_get(void *data,
int (*match)(struct device *dev, const void *data))
{ … }
static void __nvmem_device_put(struct nvmem_device *nvmem)
{ … }
#if IS_ENABLED(CONFIG_OF)
struct nvmem_device *of_nvmem_device_get(struct device_node *np, const char *id)
{ … }
EXPORT_SYMBOL_GPL(…);
#endif
struct nvmem_device *nvmem_device_get(struct device *dev, const char *dev_name)
{ … }
EXPORT_SYMBOL_GPL(…);
struct nvmem_device *nvmem_device_find(void *data,
int (*match)(struct device *dev, const void *data))
{ … }
EXPORT_SYMBOL_GPL(…);
static int devm_nvmem_device_match(struct device *dev, void *res, void *data)
{ … }
static void devm_nvmem_device_release(struct device *dev, void *res)
{ … }
void devm_nvmem_device_put(struct device *dev, struct nvmem_device *nvmem)
{ … }
EXPORT_SYMBOL_GPL(…);
void nvmem_device_put(struct nvmem_device *nvmem)
{ … }
EXPORT_SYMBOL_GPL(…);
struct nvmem_device *devm_nvmem_device_get(struct device *dev, const char *id)
{ … }
EXPORT_SYMBOL_GPL(…);
static struct nvmem_cell *nvmem_create_cell(struct nvmem_cell_entry *entry,
const char *id, int index)
{ … }
static struct nvmem_cell *
nvmem_cell_get_from_lookup(struct device *dev, const char *con_id)
{ … }
static void nvmem_layout_module_put(struct nvmem_device *nvmem)
{ … }
#if IS_ENABLED(CONFIG_OF)
static struct nvmem_cell_entry *
nvmem_find_cell_entry_by_node(struct nvmem_device *nvmem, struct device_node *np)
{ … }
static int nvmem_layout_module_get_optional(struct nvmem_device *nvmem)
{ … }
struct nvmem_cell *of_nvmem_cell_get(struct device_node *np, const char *id)
{ … }
EXPORT_SYMBOL_GPL(…);
#endif
struct nvmem_cell *nvmem_cell_get(struct device *dev, const char *id)
{ … }
EXPORT_SYMBOL_GPL(…);
static void devm_nvmem_cell_release(struct device *dev, void *res)
{ … }
struct nvmem_cell *devm_nvmem_cell_get(struct device *dev, const char *id)
{ … }
EXPORT_SYMBOL_GPL(…);
static int devm_nvmem_cell_match(struct device *dev, void *res, void *data)
{ … }
void devm_nvmem_cell_put(struct device *dev, struct nvmem_cell *cell)
{ … }
EXPORT_SYMBOL(…);
void nvmem_cell_put(struct nvmem_cell *cell)
{ … }
EXPORT_SYMBOL_GPL(…);
static void nvmem_shift_read_buffer_in_place(struct nvmem_cell_entry *cell, void *buf)
{ … }
static int __nvmem_cell_read(struct nvmem_device *nvmem,
struct nvmem_cell_entry *cell,
void *buf, size_t *len, const char *id, int index)
{ … }
void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len)
{ … }
EXPORT_SYMBOL_GPL(…);
static void *nvmem_cell_prepare_write_buffer(struct nvmem_cell_entry *cell,
u8 *_buf, int len)
{ … }
static int __nvmem_cell_entry_write(struct nvmem_cell_entry *cell, void *buf, size_t len)
{ … }
int nvmem_cell_write(struct nvmem_cell *cell, void *buf, size_t len)
{ … }
EXPORT_SYMBOL_GPL(…);
static int nvmem_cell_read_common(struct device *dev, const char *cell_id,
void *val, size_t count)
{ … }
int nvmem_cell_read_u8(struct device *dev, const char *cell_id, u8 *val)
{ … }
EXPORT_SYMBOL_GPL(…);
int nvmem_cell_read_u16(struct device *dev, const char *cell_id, u16 *val)
{ … }
EXPORT_SYMBOL_GPL(…);
int nvmem_cell_read_u32(struct device *dev, const char *cell_id, u32 *val)
{ … }
EXPORT_SYMBOL_GPL(…);
int nvmem_cell_read_u64(struct device *dev, const char *cell_id, u64 *val)
{ … }
EXPORT_SYMBOL_GPL(…);
static const void *nvmem_cell_read_variable_common(struct device *dev,
const char *cell_id,
size_t max_len, size_t *len)
{ … }
int nvmem_cell_read_variable_le_u32(struct device *dev, const char *cell_id,
u32 *val)
{ … }
EXPORT_SYMBOL_GPL(…);
int nvmem_cell_read_variable_le_u64(struct device *dev, const char *cell_id,
u64 *val)
{ … }
EXPORT_SYMBOL_GPL(…);
ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem,
struct nvmem_cell_info *info, void *buf)
{ … }
EXPORT_SYMBOL_GPL(…);
int nvmem_device_cell_write(struct nvmem_device *nvmem,
struct nvmem_cell_info *info, void *buf)
{ … }
EXPORT_SYMBOL_GPL(…);
int nvmem_device_read(struct nvmem_device *nvmem,
unsigned int offset,
size_t bytes, void *buf)
{ … }
EXPORT_SYMBOL_GPL(…);
int nvmem_device_write(struct nvmem_device *nvmem,
unsigned int offset,
size_t bytes, void *buf)
{ … }
EXPORT_SYMBOL_GPL(…);
void nvmem_add_cell_table(struct nvmem_cell_table *table)
{ … }
EXPORT_SYMBOL_GPL(…);
void nvmem_del_cell_table(struct nvmem_cell_table *table)
{ … }
EXPORT_SYMBOL_GPL(…);
void nvmem_add_cell_lookups(struct nvmem_cell_lookup *entries, size_t nentries)
{ … }
EXPORT_SYMBOL_GPL(…);
void nvmem_del_cell_lookups(struct nvmem_cell_lookup *entries, size_t nentries)
{ … }
EXPORT_SYMBOL_GPL(…);
const char *nvmem_dev_name(struct nvmem_device *nvmem)
{ … }
EXPORT_SYMBOL_GPL(…);
size_t nvmem_dev_size(struct nvmem_device *nvmem)
{ … }
EXPORT_SYMBOL_GPL(…);
static int __init nvmem_init(void)
{ … }
static void __exit nvmem_exit(void)
{ … }
subsys_initcall(nvmem_init);
module_exit(nvmem_exit);
MODULE_AUTHOR(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;