[PATCH v6 2/2] staging: axis-fifo: refactor device tree parsing

From: Gustavo Piaz da Silva

Date: Mon Feb 02 2026 - 09:29:46 EST


Refactor the device tree parsing logic in axis_fifo_probe() to reduce
verbosity and simplify error handling.

Remove the verbose error logging and goto logic. Instead, check
of_property_read_u32() return values directly and propagate error codes
immediately. This aligns the driver with modern kernel standards by
removing unnecessary error messages during probe.

Signed-off-by: Gustavo Piaz da Silva <gustavopiazdasilva2102@xxxxxxxxx>
---
Changes in v6:
- Removed axis_fifo_get_u32() helper function entirely.
- Kept 'node' local variable to avoid checkpatch line length warnings.
- Removed dev_err() calls in parse_dt as requested by Greg KH.
- Fixed checkpatch style warning (missing blank line after declarations).
- Ensured newline at end of file.

Changes in v5:
- Added missing newline at the end of the file.

Changes in v4:
- Removed extra blank lines in the commit message.
- Added "rx" and "tx" prefixes to error messages (now removed in v6).

Changes in v3:
- Split the original v2 patch into two separate patches.

drivers/staging/axis-fifo/axis-fifo.c | 78 +++++++++------------------
1 file changed, 26 insertions(+), 52 deletions(-)

diff --git a/drivers/staging/axis-fifo/axis-fifo.c b/drivers/staging/axis-fifo/axis-fifo.c
index 7bc7bf191250..c482611bbde7 100644
--- a/drivers/staging/axis-fifo/axis-fifo.c
+++ b/drivers/staging/axis-fifo/axis-fifo.c
@@ -484,66 +484,40 @@ static void axis_fifo_debugfs_init(struct axis_fifo *fifo)

static int axis_fifo_parse_dt(struct axis_fifo *fifo)
{
- int ret;
- unsigned int value;
struct device_node *node = fifo->dt_device->of_node;
+ int ret;
+ u32 width;

- ret = of_property_read_u32(node, "xlnx,axi-str-rxd-tdata-width",
- &value);
- if (ret) {
- dev_err(fifo->dt_device, "missing xlnx,axi-str-rxd-tdata-width property\n");
- goto end;
- } else if (value != 32) {
- dev_err(fifo->dt_device, "xlnx,axi-str-rxd-tdata-width only supports 32 bits\n");
- ret = -EIO;
- goto end;
- }
+ ret = of_property_read_u32(node, "xlnx,axi-str-rxd-tdata-width", &width);

- ret = of_property_read_u32(node, "xlnx,axi-str-txd-tdata-width",
- &value);
- if (ret) {
- dev_err(fifo->dt_device, "missing xlnx,axi-str-txd-tdata-width property\n");
- goto end;
- } else if (value != 32) {
- dev_err(fifo->dt_device, "xlnx,axi-str-txd-tdata-width only supports 32 bits\n");
- ret = -EIO;
- goto end;
- }
+ if (ret)
+ return ret;
+ if (width != 32)
+ return -EINVAL;

- ret = of_property_read_u32(node, "xlnx,rx-fifo-depth",
- &fifo->rx_fifo_depth);
- if (ret) {
- dev_err(fifo->dt_device, "missing xlnx,rx-fifo-depth property\n");
- ret = -EIO;
- goto end;
- }
+ ret = of_property_read_u32(node, "xlnx,axi-str-txd-tdata-width", &width);
+ if (ret)
+ return ret;
+ if (width != 32)
+ return -EINVAL;

- ret = of_property_read_u32(node, "xlnx,tx-fifo-depth",
- &fifo->tx_fifo_depth);
- if (ret) {
- dev_err(fifo->dt_device, "missing xlnx,tx-fifo-depth property\n");
- ret = -EIO;
- goto end;
- }
+ ret = of_property_read_u32(node, "xlnx,rx-fifo-depth", &fifo->rx_fifo_depth);
+ if (ret)
+ return ret;

- ret = of_property_read_u32(node, "xlnx,use-rx-data",
- &fifo->has_rx_fifo);
- if (ret) {
- dev_err(fifo->dt_device, "missing xlnx,use-rx-data property\n");
- ret = -EIO;
- goto end;
- }
+ ret = of_property_read_u32(node, "xlnx,tx-fifo-depth", &fifo->tx_fifo_depth);
+ if (ret)
+ return ret;

- ret = of_property_read_u32(node, "xlnx,use-tx-data",
- &fifo->has_tx_fifo);
- if (ret) {
- dev_err(fifo->dt_device, "missing xlnx,use-tx-data property\n");
- ret = -EIO;
- goto end;
- }
+ ret = of_property_read_u32(node, "xlnx,use-rx-data", &fifo->has_rx_fifo);
+ if (ret)
+ return ret;

-end:
- return ret;
+ ret = of_property_read_u32(node, "xlnx,use-tx-data", &fifo->has_tx_fifo);
+ if (ret)
+ return ret;
+
+ return 0;
}

static int axis_fifo_probe(struct platform_device *pdev)
--
2.52.0