lkml.org 
[lkml]   [2022]   [Jul]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v1 2/2] iio: adc: npcm: Add NPCM8XX support
On Mon, Jul 11, 2022 at 3:59 PM Tomer Maimon <tmaimon77@gmail.com> wrote:
>
> Adding ADC NPCM8XX support to NPCM ADC driver.
> ADC NPCM8XX uses a different resolution and voltage reference.
>
> As part of adding NPCM8XX support:
> - Add NPCM8XX specific compatible string.
> - Add data to handle architecture-specific ADC parameters.

Good patch, but one change can make it even better!

...

> struct device *dev = &pdev->dev;
> + const struct of_device_id *match;
>
> indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info));
> if (!indio_dev)
> return -ENOMEM;
> info = iio_priv(indio_dev);
>
> - mutex_init(&info->lock);
> + match = of_match_node(npcm_adc_match, pdev->dev.of_node);
> + if (!match || !match->data) {
> + dev_err(dev, "Failed getting npcm_adc_data\n");
> + return -ENODEV;
> + }
>
> + info->data = (struct npcm_adc_info *)match->data;

Instead of above

info->data = device_get_match_data(dev);
if (!info->data)
return -ENODEV;

--
With Best Regards,
Andy Shevchenko

\
 
 \ /
  Last update: 2022-07-11 16:16    [W:0.062 / U:0.672 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site