mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-31 04:01:48 -04:00
nvmem: add type attribute
Add a type attribute so userspace is able to know how the data is stored as this can help taking the correct decision when selecting which device to use. This will also help program display the proper warnings when burning fuses for example. Signed-off-by: Alexandre Belloni <[email protected]> Signed-off-by: Srinivas Kandagatla <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
This commit is contained in:
parent
ecd589d8f5
commit
1668845366
2 changed files with 37 additions and 0 deletions
|
|
@ -28,6 +28,7 @@ struct nvmem_device {
|
|||
size_t size;
|
||||
bool read_only;
|
||||
int flags;
|
||||
enum nvmem_type type;
|
||||
struct bin_attribute eeprom;
|
||||
struct device *base_dev;
|
||||
struct list_head cells;
|
||||
|
|
@ -83,6 +84,21 @@ static int nvmem_reg_write(struct nvmem_device *nvmem, unsigned int offset,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
static ssize_t type_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct nvmem_device *nvmem = to_nvmem_device(dev);
|
||||
|
||||
return sprintf(buf, "%s\n", nvmem_type_str[nvmem->type]);
|
||||
}
|
||||
|
||||
static DEVICE_ATTR_RO(type);
|
||||
|
||||
static struct attribute *nvmem_attrs[] = {
|
||||
&dev_attr_type.attr,
|
||||
NULL,
|
||||
};
|
||||
|
||||
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)
|
||||
|
|
@ -168,6 +184,7 @@ static struct bin_attribute *nvmem_bin_rw_attributes[] = {
|
|||
|
||||
static const struct attribute_group nvmem_bin_rw_group = {
|
||||
.bin_attrs = nvmem_bin_rw_attributes,
|
||||
.attrs = nvmem_attrs,
|
||||
};
|
||||
|
||||
static const struct attribute_group *nvmem_rw_dev_groups[] = {
|
||||
|
|
@ -191,6 +208,7 @@ static struct bin_attribute *nvmem_bin_ro_attributes[] = {
|
|||
|
||||
static const struct attribute_group nvmem_bin_ro_group = {
|
||||
.bin_attrs = nvmem_bin_ro_attributes,
|
||||
.attrs = nvmem_attrs,
|
||||
};
|
||||
|
||||
static const struct attribute_group *nvmem_ro_dev_groups[] = {
|
||||
|
|
@ -215,6 +233,7 @@ static struct bin_attribute *nvmem_bin_rw_root_attributes[] = {
|
|||
|
||||
static const struct attribute_group nvmem_bin_rw_root_group = {
|
||||
.bin_attrs = nvmem_bin_rw_root_attributes,
|
||||
.attrs = nvmem_attrs,
|
||||
};
|
||||
|
||||
static const struct attribute_group *nvmem_rw_root_dev_groups[] = {
|
||||
|
|
@ -238,6 +257,7 @@ static struct bin_attribute *nvmem_bin_ro_root_attributes[] = {
|
|||
|
||||
static const struct attribute_group nvmem_bin_ro_root_group = {
|
||||
.bin_attrs = nvmem_bin_ro_root_attributes,
|
||||
.attrs = nvmem_attrs,
|
||||
};
|
||||
|
||||
static const struct attribute_group *nvmem_ro_root_dev_groups[] = {
|
||||
|
|
@ -605,6 +625,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
|
|||
nvmem->dev.bus = &nvmem_bus_type;
|
||||
nvmem->dev.parent = config->dev;
|
||||
nvmem->priv = config->priv;
|
||||
nvmem->type = config->type;
|
||||
nvmem->reg_read = config->reg_read;
|
||||
nvmem->reg_write = config->reg_write;
|
||||
nvmem->dev.of_node = config->dev->of_node;
|
||||
|
|
|
|||
Loading…
Reference in a new issue