Skip to content

Commit

Permalink
i2c: tegra_nvec: Use dev_read_addr_ptr/u32_default
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas Chauvet <kwizart@gmail.com>
  • Loading branch information
kwizart committed Nov 19, 2021
1 parent 915de20 commit e8ecf7b
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions drivers/i2c/tegra_nvec.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,7 @@ static void nvec_init_i2c_slave(struct nvec_t *nvec)
* @param config structure to store fdt config into
* @return 0 if ok, -ve on error
*/
static int nvec_decode_fdt(const void *blob, int node,
struct nvec_t *nvec)
static int nvec_decode_fdt(const void *dev)
{
// int ret;

Expand All @@ -396,22 +395,19 @@ static int nvec_decode_fdt(const void *blob, int node,
// return -ENOENT;
// }

nvec->base = (void __iomem *)fdtdec_get_addr(blob, node, "reg");
if (nvec->base == (void __iomem *)FDT_ADDR_T_NONE) {
error("No NVEC controller address");
return -ENOENT;
}
nvec->i2c_addr = fdtdec_get_int(blob, node, "slave-addr", -1);
nvec->i2c_clk = fdtdec_get_int(blob, node, "clock-frequency", -1);
dev->base = dev_read_addr_ptr(dev);
if (!dev->base)
return -ENOMEM;

dev->i2c_addr = dev_read_u32_default(dev, "slave-addr", -1);
dev->i2c_clk = dev_read_u32_default(dev, "clock-frequency", -1);

return 0;
}

static int nvec_probe(struct udevice *dev)
{
struct nvec_t *nvec = dev_get_priv(dev);
const void *blob = gd->fdt_blob;
int node = dev->node_.of_offset;
int res;

TRACE();
Expand All @@ -425,7 +421,7 @@ static int nvec_probe(struct udevice *dev)

debug("NVEC initialization...\n");

if (nvec_decode_fdt(blob, node, nvec_data)) {
if (nvec_decode_fdt(nvec_data) {
error("Failed to decode fdt");
return -EBUSY;
}
Expand Down

0 comments on commit e8ecf7b

Please sign in to comment.