diff options
author | Rob Herring (Arm) <robh@kernel.org> | 2024-07-03 00:53:49 +0300 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2024-07-03 01:35:52 +0300 |
commit | 4aad1d9471108a5023e224422b2522323521174c (patch) | |
tree | 0d6b655c46ec44d1981ae2bc751ef899a866761b /sound/soc/codecs | |
parent | d06432b04603ea6f1b99bc0a933aa264b2fb6f4b (diff) | |
download | linux-4aad1d9471108a5023e224422b2522323521174c.tar.xz |
ASoC: PCM6240: Use of_property_read_reg()
Replace the open-coded parsing of "reg" with of_property_read_reg().
The #ifdef is also easily replaced with IS_ENABLED().
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Link: https://patch.msgid.link/20240702215349.839350-1-robh@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/codecs')
-rw-r--r-- | sound/soc/codecs/pcm6240.c | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/sound/soc/codecs/pcm6240.c b/sound/soc/codecs/pcm6240.c index 8f7057e689fb..5faf5e97a105 100644 --- a/sound/soc/codecs/pcm6240.c +++ b/sound/soc/codecs/pcm6240.c @@ -18,6 +18,7 @@ #include <linux/i2c.h> #include <linux/module.h> #include <linux/of_irq.h> +#include <linux/of_address.h> #include <linux/regmap.h> #include <sound/pcm_params.h> #include <sound/soc.h> @@ -2081,10 +2082,6 @@ static int pcmdevice_i2c_probe(struct i2c_client *i2c) struct device_node *np; unsigned int dev_addrs[PCMDEVICE_MAX_I2C_DEVICES]; int ret = 0, i = 0, ndev = 0; -#ifdef CONFIG_OF - const __be32 *reg, *reg_end; - int len, sw, aw; -#endif pcm_dev = devm_kzalloc(&i2c->dev, sizeof(*pcm_dev), GFP_KERNEL); if (!pcm_dev) @@ -2118,27 +2115,19 @@ static int pcmdevice_i2c_probe(struct i2c_client *i2c) i2c_set_clientdata(i2c, pcm_dev); mutex_init(&pcm_dev->codec_lock); np = pcm_dev->dev->of_node; -#ifdef CONFIG_OF - aw = of_n_addr_cells(np); - sw = of_n_size_cells(np); - if (sw == 0) { - reg = (const __be32 *)of_get_property(np, - "reg", &len); - reg_end = reg + len/sizeof(*reg); - ndev = 0; - do { - dev_addrs[ndev] = of_read_number(reg, aw); - reg += aw; - ndev++; - } while (reg < reg_end); + + if (IS_ENABLED(CONFIG_OF)) { + u64 addr; + + for (i = 0; i < PCMDEVICE_MAX_I2C_DEVICES; i++) { + if (of_property_read_reg(np, i, &addr, NULL)) + break; + dev_addrs[ndev++] = addr; + } } else { ndev = 1; dev_addrs[0] = i2c->addr; } -#else - ndev = 1; - dev_addrs[0] = i2c->addr; -#endif pcm_dev->irq_info.gpio = of_irq_get(np, 0); for (i = 0; i < ndev; i++) |