Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nvmem: sunxi-sid: remove nvmem regmap dependency

This patch moves to nvmem support in the driver to use callback
instead of regmap.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Srinivas Kandagatla and committed by
Greg Kroah-Hartman
9c7b16eb 2c0235c6

+9 -46
-1
drivers/nvmem/Kconfig
··· 83 83 config NVMEM_SUNXI_SID 84 84 tristate "Allwinner SoCs SID support" 85 85 depends on ARCH_SUNXI 86 - select REGMAP_MMIO 87 86 help 88 87 This is a driver for the 'security ID' available on various Allwinner 89 88 devices.
+9 -45
drivers/nvmem/sunxi_sid.c
··· 21 21 #include <linux/nvmem-provider.h> 22 22 #include <linux/of.h> 23 23 #include <linux/platform_device.h> 24 - #include <linux/regmap.h> 25 24 #include <linux/slab.h> 26 25 #include <linux/random.h> 27 26 28 27 static struct nvmem_config econfig = { 29 28 .name = "sunxi-sid", 30 29 .read_only = true, 30 + .stride = 4, 31 + .word_size = 1, 31 32 .owner = THIS_MODULE, 32 33 }; 33 34 ··· 52 51 return sid_key; /* Only return the last byte */ 53 52 } 54 53 55 - static int sunxi_sid_read(void *context, 56 - const void *reg, size_t reg_size, 57 - void *val, size_t val_size) 54 + static int sunxi_sid_read(void *context, unsigned int offset, 55 + void *val, size_t bytes) 58 56 { 59 57 struct sunxi_sid *sid = context; 60 - unsigned int offset = *(u32 *)reg; 61 58 u8 *buf = val; 62 59 63 - while (val_size) { 64 - *buf++ = sunxi_sid_read_byte(sid, offset); 65 - val_size--; 66 - offset++; 67 - } 60 + while (bytes--) 61 + *buf++ = sunxi_sid_read_byte(sid, offset++); 68 62 69 63 return 0; 70 64 } 71 - 72 - static int sunxi_sid_write(void *context, const void *data, size_t count) 73 - { 74 - /* Unimplemented, dummy to keep regmap core happy */ 75 - return 0; 76 - } 77 - 78 - static struct regmap_bus sunxi_sid_bus = { 79 - .read = sunxi_sid_read, 80 - .write = sunxi_sid_write, 81 - .reg_format_endian_default = REGMAP_ENDIAN_NATIVE, 82 - .val_format_endian_default = REGMAP_ENDIAN_NATIVE, 83 - }; 84 - 85 - static bool sunxi_sid_writeable_reg(struct device *dev, unsigned int reg) 86 - { 87 - return false; 88 - } 89 - 90 - static struct regmap_config sunxi_sid_regmap_config = { 91 - .reg_bits = 32, 92 - .val_bits = 8, 93 - .reg_stride = 1, 94 - .writeable_reg = sunxi_sid_writeable_reg, 95 - }; 96 65 97 66 static int sunxi_sid_probe(struct platform_device *pdev) 98 67 { 99 68 struct device *dev = &pdev->dev; 100 69 struct resource *res; 101 70 struct nvmem_device *nvmem; 102 - struct regmap *regmap; 103 71 struct sunxi_sid *sid; 104 72 int ret, i, size; 105 73 char *randomness; ··· 83 113 return PTR_ERR(sid->base); 84 114 85 115 size = resource_size(res) - 1; 86 - sunxi_sid_regmap_config.max_register = size; 87 - 88 - regmap = devm_regmap_init(dev, &sunxi_sid_bus, sid, 89 - &sunxi_sid_regmap_config); 90 - if (IS_ERR(regmap)) { 91 - dev_err(dev, "regmap init failed\n"); 92 - return PTR_ERR(regmap); 93 - } 94 - 116 + econfig.size = resource_size(res); 95 117 econfig.dev = dev; 118 + econfig.reg_read = sunxi_sid_read; 119 + econfig.priv = sid; 96 120 nvmem = nvmem_register(&econfig); 97 121 if (IS_ERR(nvmem)) 98 122 return PTR_ERR(nvmem);