Commit 31a45f91 authored by Rob Herring (Arm)'s avatar Rob Herring (Arm) Committed by Mark Brown

ASoC: tas2781: 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: default avatarRob Herring (Arm) <robh@kernel.org>
Link: https://patch.msgid.link/20240702215402.839673-1-robh@kernel.orgSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 4aad1d94
......@@ -21,6 +21,7 @@
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_gpio.h>
#include <linux/of_irq.h>
#include <linux/regmap.h>
......@@ -647,33 +648,20 @@ static void tasdevice_parse_dt(struct tasdevice_priv *tas_priv)
tas_priv->irq_info.irq_gpio =
acpi_dev_gpio_irq_get(ACPI_COMPANION(&client->dev), 0);
} else {
} else if (IS_ENABLED(CONFIG_OF)) {
struct device_node *np = tas_priv->dev->of_node;
#ifdef CONFIG_OF
const __be32 *reg, *reg_end;
int len, sw, aw;
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);
} else {
ndev = 1;
dev_addrs[0] = client->addr;
u64 addr;
for (i = 0; i < TASDEVICE_MAX_CHANNELS; i++) {
if (of_property_read_reg(np, i, &addr, NULL))
break;
dev_addrs[ndev++] = addr;
}
#else
tas_priv->irq_info.irq_gpio = of_irq_get(np, 0);
} else {
ndev = 1;
dev_addrs[0] = client->addr;
#endif
tas_priv->irq_info.irq_gpio = of_irq_get(np, 0);
}
tas_priv->ndev = ndev;
for (i = 0; i < ndev; i++)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment