mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-22 10:58:18 +07:00
17eb18d674
All nvmem drivers are supposed to set the owner field of struct nvmem_config, but this matches nvmem->dev->driver->owner. As far as I see in drivers/nvmem/ directory, all the drivers are the case. So, make nvmem_register() set the nvmem's owner to the associated driver's owner unless nvmem_config sets otherwise. Remove .owner settings in the drivers that are now redundant. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
93 lines
2.2 KiB
C
93 lines
2.2 KiB
C
/*
|
|
* Amlogic Meson GX eFuse Driver
|
|
*
|
|
* Copyright (c) 2016 Endless Computers, Inc.
|
|
* Author: Carlo Caione <carlo@endlessm.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms of version 2 of the GNU General Public License as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
* more details.
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/nvmem-provider.h>
|
|
#include <linux/of.h>
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/firmware/meson/meson_sm.h>
|
|
|
|
static int meson_efuse_read(void *context, unsigned int offset,
|
|
void *val, size_t bytes)
|
|
{
|
|
u8 *buf = val;
|
|
int ret;
|
|
|
|
ret = meson_sm_call_read(buf, bytes, SM_EFUSE_READ, offset,
|
|
bytes, 0, 0, 0);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static struct nvmem_config econfig = {
|
|
.name = "meson-efuse",
|
|
.stride = 1,
|
|
.word_size = 1,
|
|
.read_only = true,
|
|
};
|
|
|
|
static const struct of_device_id meson_efuse_match[] = {
|
|
{ .compatible = "amlogic,meson-gxbb-efuse", },
|
|
{ /* sentinel */ },
|
|
};
|
|
MODULE_DEVICE_TABLE(of, meson_efuse_match);
|
|
|
|
static int meson_efuse_probe(struct platform_device *pdev)
|
|
{
|
|
struct nvmem_device *nvmem;
|
|
unsigned int size;
|
|
|
|
if (meson_sm_call(SM_EFUSE_USER_MAX, &size, 0, 0, 0, 0, 0) < 0)
|
|
return -EINVAL;
|
|
|
|
econfig.dev = &pdev->dev;
|
|
econfig.reg_read = meson_efuse_read;
|
|
econfig.size = size;
|
|
|
|
nvmem = nvmem_register(&econfig);
|
|
if (IS_ERR(nvmem))
|
|
return PTR_ERR(nvmem);
|
|
|
|
platform_set_drvdata(pdev, nvmem);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int meson_efuse_remove(struct platform_device *pdev)
|
|
{
|
|
struct nvmem_device *nvmem = platform_get_drvdata(pdev);
|
|
|
|
return nvmem_unregister(nvmem);
|
|
}
|
|
|
|
static struct platform_driver meson_efuse_driver = {
|
|
.probe = meson_efuse_probe,
|
|
.remove = meson_efuse_remove,
|
|
.driver = {
|
|
.name = "meson-efuse",
|
|
.of_match_table = meson_efuse_match,
|
|
},
|
|
};
|
|
|
|
module_platform_driver(meson_efuse_driver);
|
|
|
|
MODULE_AUTHOR("Carlo Caione <carlo@endlessm.com>");
|
|
MODULE_DESCRIPTION("Amlogic Meson GX NVMEM driver");
|
|
MODULE_LICENSE("GPL v2");
|