nvmem: Use device_get_match_data()
authorRob Herring <robh@kernel.org>
Fri, 20 Oct 2023 10:55:45 +0000 (11:55 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 21 Oct 2023 17:19:15 +0000 (19:19 +0200)
Use preferred device_get_match_data() instead of of_match_device() to
get the driver match data. With this, adjust the includes to explicitly
include the correct headers.

Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20231020105545.216052-7-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/nvmem/mxs-ocotp.c
drivers/nvmem/stm32-romem.c

index 588ab56d75b79aebbcf1b1f7b79b005472508e94..7b78f18f9545951f3de27e7b7f390ac9887acdfe 100644 (file)
@@ -13,8 +13,9 @@
 #include <linux/io.h>
 #include <linux/module.h>
 #include <linux/nvmem-provider.h>
-#include <linux/of_device.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/slab.h>
 #include <linux/stmp_device.h>
 
@@ -140,11 +141,10 @@ static int mxs_ocotp_probe(struct platform_device *pdev)
        struct device *dev = &pdev->dev;
        const struct mxs_data *data;
        struct mxs_ocotp *otp;
-       const struct of_device_id *match;
        int ret;
 
-       match = of_match_device(dev->driver->of_match_table, dev);
-       if (!match || !match->data)
+       data = device_get_match_data(dev);
+       if (!data)
                return -EINVAL;
 
        otp = devm_kzalloc(dev, sizeof(*otp), GFP_KERNEL);
@@ -169,8 +169,6 @@ static int mxs_ocotp_probe(struct platform_device *pdev)
        if (ret)
                return ret;
 
-       data = match->data;
-
        ocotp_config.size = data->size;
        ocotp_config.priv = otp;
        ocotp_config.dev = dev;
index 1541c20709d25b00c8bbad2f5dbcaa682a5ec4dc..8a553b1799a8523a23666b82251a50617643b1f8 100644 (file)
@@ -10,7 +10,9 @@
 #include <linux/io.h>
 #include <linux/module.h>
 #include <linux/nvmem-provider.h>
-#include <linux/of_device.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/tee_drv.h>
 
 #include "stm32-bsec-optee-ta.h"
@@ -211,8 +213,7 @@ static int stm32_romem_probe(struct platform_device *pdev)
 
        priv->lower = 0;
 
-       cfg = (const struct stm32_romem_cfg *)
-               of_match_device(dev->driver->of_match_table, dev)->data;
+       cfg = device_get_match_data(dev);
        if (!cfg) {
                priv->cfg.read_only = true;
                priv->cfg.size = resource_size(res);