nvmem: mtk-efuse: use stack for nvmem_config instead of malloc'ing it
nvmem_register() copies all the members of nvmem_config to nvmem_device. So, nvmem_config is one-time use data during probing. There is no point to keep it until the driver detach. Using stack should be no problem because nvmem_config is pretty small. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Acked-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
01d35cabd5
commit
4dd5f60e9a
|
@ -49,7 +49,7 @@ static int mtk_efuse_probe(struct platform_device *pdev)
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
struct resource *res;
|
struct resource *res;
|
||||||
struct nvmem_device *nvmem;
|
struct nvmem_device *nvmem;
|
||||||
struct nvmem_config *econfig;
|
struct nvmem_config econfig = {};
|
||||||
void __iomem *base;
|
void __iomem *base;
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||||
|
@ -57,19 +57,15 @@ static int mtk_efuse_probe(struct platform_device *pdev)
|
||||||
if (IS_ERR(base))
|
if (IS_ERR(base))
|
||||||
return PTR_ERR(base);
|
return PTR_ERR(base);
|
||||||
|
|
||||||
econfig = devm_kzalloc(dev, sizeof(*econfig), GFP_KERNEL);
|
econfig.stride = 4;
|
||||||
if (!econfig)
|
econfig.word_size = 4;
|
||||||
return -ENOMEM;
|
econfig.reg_read = mtk_reg_read;
|
||||||
|
econfig.reg_write = mtk_reg_write;
|
||||||
econfig->stride = 4;
|
econfig.size = resource_size(res);
|
||||||
econfig->word_size = 4;
|
econfig.priv = base;
|
||||||
econfig->reg_read = mtk_reg_read;
|
econfig.dev = dev;
|
||||||
econfig->reg_write = mtk_reg_write;
|
econfig.owner = THIS_MODULE;
|
||||||
econfig->size = resource_size(res);
|
nvmem = nvmem_register(&econfig);
|
||||||
econfig->priv = base;
|
|
||||||
econfig->dev = dev;
|
|
||||||
econfig->owner = THIS_MODULE;
|
|
||||||
nvmem = nvmem_register(econfig);
|
|
||||||
if (IS_ERR(nvmem))
|
if (IS_ERR(nvmem))
|
||||||
return PTR_ERR(nvmem);
|
return PTR_ERR(nvmem);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue