Re: [PATCH] nvmem: sc27xx: add sc2730 efuse support

From: Srinivas Kandagatla
Date: Mon Jun 15 2020 - 05:39:27 EST




On 15/06/2020 04:23, Chunyan Zhang wrote:
From: Freeman Liu <freeman.liu@xxxxxxxxxx>

Add support to the new efuse IP which is integrated in the SC2730
which includes multiple blocks in a single chip.

Signed-off-by: Freeman Liu <freeman.liu@xxxxxxxxxx>
Signed-off-by: Chunyan Zhang <chunyan.zhang@xxxxxxxxxx>
---
drivers/nvmem/sc27xx-efuse.c | 34 +++++++++++++++++++++++++++++++---
1 file changed, 31 insertions(+), 3 deletions(-)

diff --git a/drivers/nvmem/sc27xx-efuse.c b/drivers/nvmem/sc27xx-efuse.c
index ab5e7e0bc3d8..7d453c9d80da 100644
--- a/drivers/nvmem/sc27xx-efuse.c
+++ b/drivers/nvmem/sc27xx-efuse.c

...

@@ -187,8 +206,15 @@ static int sc27xx_efuse_probe(struct platform_device *pdev)
struct nvmem_config econfig = { };
struct nvmem_device *nvmem;
struct sc27xx_efuse *efuse;
+ const struct sc27xx_efuse_variant_data *pdata;
int ret;
+ pdata = of_device_get_match_data(&pdev->dev);
+ if (!pdata) {

This check is totally unnecessary as you would not end up here unless there is a matching compatible!


You could move this after kmalloc and assign efuse->var_data directly!!


--srini

+ dev_err(&pdev->dev, "No matching driver data found\n");
+ return -EINVAL;
+ }
+
efuse = devm_kzalloc(&pdev->dev, sizeof(*efuse), GFP_KERNEL);
if (!efuse)
return -ENOMEM;
@@ -219,6 +245,7 @@ static int sc27xx_efuse_probe(struct platform_device *pdev)
mutex_init(&efuse->mutex);
efuse->dev = &pdev->dev;
+ efuse->var_data = pdata;