Re: [PATCH] memory: Use device_get_match_data()

From: Rob Herring
Date: Mon Oct 09 2023 - 08:11:45 EST


On Sun, Oct 8, 2023 at 6:33 AM Krzysztof Kozlowski
<krzysztof.kozlowski@xxxxxxxxxx> wrote:
>
> On 07/10/2023 00:44, Rob Herring wrote:
> > 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@xxxxxxxxxx>
> > ---
>
> ...
>
> > enum ccf_version {
> > CCF1,
> > @@ -172,14 +170,9 @@ static irqreturn_t ccf_irq(int irq, void *dev_id)
> > static int ccf_probe(struct platform_device *pdev)
> > {
> > struct ccf_private *ccf;
> > - const struct of_device_id *match;
> > u32 errinten;
> > int ret, irq;
> >
> > - match = of_match_device(ccf_matches, &pdev->dev);
> > - if (WARN_ON(!match))
> > - return -ENODEV;
> > -
> > ccf = devm_kzalloc(&pdev->dev, sizeof(*ccf), GFP_KERNEL);
> > if (!ccf)
> > return -ENOMEM;
> > @@ -189,7 +182,7 @@ static int ccf_probe(struct platform_device *pdev)
> > return PTR_ERR(ccf->regs);
> >
> > ccf->dev = &pdev->dev;
> > - ccf->info = match->data;
> > + ccf->info = device_get_match_data(&pdev->dev);
>
> This part is no equivalent. You miss here if (WARN_ON(!ccf->info)).

Checking for match failed was pointless. We already matched in order
to probe and DT is the only way we match.

Rob