static int nvmem_sysfs_setup_compat()

in core.c [359:392]


static int nvmem_sysfs_setup_compat(struct nvmem_device *nvmem,
				    const struct nvmem_config *config)
{
	int rval;

	if (!config->compat)
		return 0;

	if (!config->base_dev)
		return -EINVAL;

	if (config->type == NVMEM_TYPE_FRAM)
		bin_attr_nvmem_eeprom_compat.attr.name = "fram";

	nvmem->eeprom = bin_attr_nvmem_eeprom_compat;
	nvmem->eeprom.attr.mode = nvmem_bin_attr_get_umode(nvmem);
	nvmem->eeprom.size = nvmem->size;
#ifdef CONFIG_DEBUG_LOCK_ALLOC
	nvmem->eeprom.attr.key = &eeprom_lock_key;
#endif
	nvmem->eeprom.private = &nvmem->dev;
	nvmem->base_dev = config->base_dev;

	rval = device_create_bin_file(nvmem->base_dev, &nvmem->eeprom);
	if (rval) {
		dev_err(&nvmem->dev,
			"Failed to create eeprom binary file %d\n", rval);
		return rval;
	}

	nvmem->flags |= FLAG_COMPAT;

	return 0;
}