Skip to content

Commit 09de369

Browse files
robherringkrzk
authored andcommitted
memory: Use device_get_match_data()
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> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> Link: https://lore.kernel.org/r/20231006224402.442078-1-robh@kernel.org Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
1 parent 9def28f commit 09de369

3 files changed

Lines changed: 12 additions & 22 deletions

File tree

drivers/memory/atmel-ebi.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
#include <linux/mfd/syscon/atmel-matrix.h>
1313
#include <linux/mfd/syscon/atmel-smc.h>
1414
#include <linux/init.h>
15-
#include <linux/of_device.h>
15+
#include <linux/of.h>
16+
#include <linux/of_platform.h>
17+
#include <linux/platform_device.h>
18+
#include <linux/property.h>
1619
#include <linux/regmap.h>
1720
#include <soc/at91/atmel-sfr.h>
1821

@@ -515,24 +518,21 @@ static int atmel_ebi_probe(struct platform_device *pdev)
515518
{
516519
struct device *dev = &pdev->dev;
517520
struct device_node *child, *np = dev->of_node, *smc_np;
518-
const struct of_device_id *match;
519521
struct atmel_ebi *ebi;
520522
int ret, reg_cells;
521523
struct clk *clk;
522524
u32 val;
523525

524-
match = of_match_device(atmel_ebi_id_table, dev);
525-
if (!match || !match->data)
526-
return -EINVAL;
527-
528526
ebi = devm_kzalloc(dev, sizeof(*ebi), GFP_KERNEL);
529527
if (!ebi)
530528
return -ENOMEM;
531529

532530
platform_set_drvdata(pdev, ebi);
533531

534532
INIT_LIST_HEAD(&ebi->devs);
535-
ebi->caps = match->data;
533+
ebi->caps = device_get_match_data(dev);
534+
if (!ebi->caps)
535+
return -EINVAL;
536536
ebi->dev = dev;
537537

538538
clk = devm_clk_get(dev, NULL);

drivers/memory/brcmstb_memc.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
#include <linux/io.h>
99
#include <linux/kernel.h>
1010
#include <linux/module.h>
11-
#include <linux/of_device.h>
11+
#include <linux/of.h>
1212
#include <linux/platform_device.h>
13+
#include <linux/property.h>
1314

1415
#define REG_MEMC_CNTRLR_CONFIG 0x00
1516
#define CNTRLR_CONFIG_LPDDR4_SHIFT 5
@@ -121,12 +122,9 @@ static struct attribute_group dev_attr_group = {
121122
.attrs = dev_attrs,
122123
};
123124

124-
static const struct of_device_id brcmstb_memc_of_match[];
125-
126125
static int brcmstb_memc_probe(struct platform_device *pdev)
127126
{
128127
const struct brcmstb_memc_data *memc_data;
129-
const struct of_device_id *of_id;
130128
struct device *dev = &pdev->dev;
131129
struct brcmstb_memc *memc;
132130
int ret;
@@ -137,8 +135,7 @@ static int brcmstb_memc_probe(struct platform_device *pdev)
137135

138136
dev_set_drvdata(dev, memc);
139137

140-
of_id = of_match_device(brcmstb_memc_of_match, dev);
141-
memc_data = of_id->data;
138+
memc_data = device_get_match_data(dev);
142139
memc->srpd_offset = memc_data->srpd_offset;
143140

144141
memc->ddr_ctrl = devm_platform_ioremap_resource(pdev, 0);

drivers/memory/fsl-corenet-cf.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010
#include <linux/irq.h>
1111
#include <linux/module.h>
1212
#include <linux/of.h>
13-
#include <linux/of_address.h>
14-
#include <linux/of_device.h>
15-
#include <linux/of_irq.h>
1613
#include <linux/platform_device.h>
14+
#include <linux/property.h>
1715

1816
enum ccf_version {
1917
CCF1,
@@ -172,14 +170,9 @@ static irqreturn_t ccf_irq(int irq, void *dev_id)
172170
static int ccf_probe(struct platform_device *pdev)
173171
{
174172
struct ccf_private *ccf;
175-
const struct of_device_id *match;
176173
u32 errinten;
177174
int ret, irq;
178175

179-
match = of_match_device(ccf_matches, &pdev->dev);
180-
if (WARN_ON(!match))
181-
return -ENODEV;
182-
183176
ccf = devm_kzalloc(&pdev->dev, sizeof(*ccf), GFP_KERNEL);
184177
if (!ccf)
185178
return -ENOMEM;
@@ -189,7 +182,7 @@ static int ccf_probe(struct platform_device *pdev)
189182
return PTR_ERR(ccf->regs);
190183

191184
ccf->dev = &pdev->dev;
192-
ccf->info = match->data;
185+
ccf->info = device_get_match_data(&pdev->dev);
193186
ccf->err_regs = ccf->regs + ccf->info->err_reg_offs;
194187

195188
if (ccf->info->has_brr) {

0 commit comments

Comments
 (0)