mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
ASoC: tas2781: Use of_property_read_reg()
[ Upstream commit 31a45f9190b5b4f5cd8cdec8471babd5215eee04 ] 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/20240702215402.839673-1-robh@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org> Stable-dep-of: c2c0b67dca3c ("ASoC: tas2781-i2c: Drop weird GPIO code") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
c0f6521806
commit
ac7976b672
1 changed files with 10 additions and 22 deletions
|
@ -21,6 +21,7 @@
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
|
#include <linux/of_address.h>
|
||||||
#include <linux/of_gpio.h>
|
#include <linux/of_gpio.h>
|
||||||
#include <linux/of_irq.h>
|
#include <linux/of_irq.h>
|
||||||
#include <linux/regmap.h>
|
#include <linux/regmap.h>
|
||||||
|
@ -633,34 +634,21 @@ static void tasdevice_parse_dt(struct tasdevice_priv *tas_priv)
|
||||||
|
|
||||||
tas_priv->irq_info.irq_gpio =
|
tas_priv->irq_info.irq_gpio =
|
||||||
acpi_dev_gpio_irq_get(ACPI_COMPANION(&client->dev), 0);
|
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;
|
struct device_node *np = tas_priv->dev->of_node;
|
||||||
#ifdef CONFIG_OF
|
u64 addr;
|
||||||
const __be32 *reg, *reg_end;
|
|
||||||
int len, sw, aw;
|
|
||||||
|
|
||||||
aw = of_n_addr_cells(np);
|
for (i = 0; i < TASDEVICE_MAX_CHANNELS; i++) {
|
||||||
sw = of_n_size_cells(np);
|
if (of_property_read_reg(np, i, &addr, NULL))
|
||||||
if (sw == 0) {
|
break;
|
||||||
reg = (const __be32 *)of_get_property(np,
|
dev_addrs[ndev++] = addr;
|
||||||
"reg", &len);
|
}
|
||||||
reg_end = reg + len/sizeof(*reg);
|
|
||||||
ndev = 0;
|
tas_priv->irq_info.irq_gpio = of_irq_get(np, 0);
|
||||||
do {
|
|
||||||
dev_addrs[ndev] = of_read_number(reg, aw);
|
|
||||||
reg += aw;
|
|
||||||
ndev++;
|
|
||||||
} while (reg < reg_end);
|
|
||||||
} else {
|
} else {
|
||||||
ndev = 1;
|
ndev = 1;
|
||||||
dev_addrs[0] = client->addr;
|
dev_addrs[0] = client->addr;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
ndev = 1;
|
|
||||||
dev_addrs[0] = client->addr;
|
|
||||||
#endif
|
|
||||||
tas_priv->irq_info.irq_gpio = of_irq_get(np, 0);
|
|
||||||
}
|
|
||||||
tas_priv->ndev = ndev;
|
tas_priv->ndev = ndev;
|
||||||
for (i = 0; i < ndev; i++)
|
for (i = 0; i < ndev; i++)
|
||||||
tas_priv->tasdevice[i].dev_addr = dev_addrs[i];
|
tas_priv->tasdevice[i].dev_addr = dev_addrs[i];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue