From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 70443306B37 for ; Sat, 31 Jan 2026 14:58:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769871506; cv=none; b=f/pwhsJ8vKQHa5A6pgb6cw55xONL0wmOQHvz4Yc/QuxZGIT/l7awMRArgxQxif8WYLkfY2o9ainAMnITRfKyKN142u82QjBzX5Tq2PuXv0susvYCGRh1fqtWzJ1N9pCbZQxdAdBOctyIlyA6SmGEckieIws45Mf0TNfMDsNifWo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769871506; c=relaxed/simple; bh=VRoAWJf2eqyTsm72qlw+J05oM9WAqdPOZdmfJYyGlzE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=PRzOqA14xTuxPL6DcXTo7ck8ShDLQZlvj7NP9/vuQoMFXpDHAO1VBfpHME/Y/ykmbTbpM9cKyrX7OLkiZ+RqUsOJrR8HkbBTPrAyNmIi5fqYZyF9UUJrRLILQnY0+DpZF4slVflLy39eJB1wvtYqdDGqN/74W3DgIKiqtoZiaDE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Fe4bVV4Q; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Fe4bVV4Q" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4801d7c72a5so23530055e9.0 for ; Sat, 31 Jan 2026 06:58:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1769871503; x=1770476303; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=UbmntDA2CNBCUun3JC3lcQU9JD6a7apau1HQQEXFXjw=; b=Fe4bVV4QQBhu+p6QWDMaKh3ChhWu71P58zTpDYDj+vZrRGMKjknBTTL/ExYWB/jmao AyU3fx1XwBAz99thcTKJggiQ0bEhh/8w0HAfladCuZqpx+puYmw09MMQyUisWvHs5Len 5P2JQ3F+kqhHlHMDg0CS3n+SAokpnq2J0c7B1K/lEbPaOosJhx7J52hmclrSqBrNkBrw 4ofKbe5OoIl03VWklnRmTlYAsUOT0BZWOgpE3pdBKdmTLvKTjb2YIQM7Yase77/QY5gG EnMPI9PAlnGdHsyUG+caWXQv1baiVFpkvEHxvEsm7dlMZK4W0H/qta0OWFZpPM0mgDRG nHZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769871503; x=1770476303; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UbmntDA2CNBCUun3JC3lcQU9JD6a7apau1HQQEXFXjw=; b=ddV6aptAj/RUxeNowG6GVADxaaruv85hHZGsUmGyIPAIDXILDG0y2NkyGgVj5yQq7P AGGWAJ32jJHJGU10dkRlI6rDDSvEZKD+nkL7vwHHltiaRVuxr90hQnV44LWuPqcVCM2C ULumHlJPePPytRD+CZmypGRq7GgJ2wier30Dr/F4KaOA4bZURMKLQKJ2gqpk0kpgV7tB RLJEkcFly3rWo7ZrBJkpPJz3IJjtRCn1f54bmTrBwEvVsGNCtr6QUjm7ou7tpaSue3dg 4GENXs6tiMlHZdRQ2bzYiMohtpcrs54Pcs8svr7b+D+V1GIqXSvgUwIxSv5D4jA6VNfQ yhBA== X-Forwarded-Encrypted: i=1; AJvYcCWWuPLNS0C0E5Hj8CPM83Sec23Va77WAFdu/W77n64qbeWIvuutUrHn2t4vOzB50fSVcrXuZDbBCXAobH4=@vger.kernel.org X-Gm-Message-State: AOJu0YzwNV0oxiNqUL/lsQSdwvy1K5+JzuTANRmEQb/9Xfhh+LNn9twg yc7D5oYjdmUSYCexJ8S/icek5rCvmIw90KG8tvnYGSAKbI6nTlGUsn2sdDMnBpL5F9k= X-Gm-Gg: AZuq6aLuD4TtSRQN4HQcq1j8zwC8U3mbY67Gy3mtQyoGwGWmQsf0/dhIBPdmusS9XtN Y7Litla2dXm0glud+DcFTsmv91A+mnbaxQ7s6rjm19wlVIm5xQq+5Lfkkwvog7ynCS1bjMSO4oU tZDedpKp1NzM2tse+r7clRjFuc+9h56dHOF6sTWucclnGTWLV9A2QExrQKBzNvCi1wfwyiCBZW7 tDxGdHJbdf1ecAIpRIW3BDoFXZIVkzbUpTDyxBpVrk8kxHZSnm+dEC4yelpxT3WleJj8K55r/Uf nK8qFoHlBzTIroy/AAkVYx331gaDCiy+xi6I8TbvJfuahffTGl+Nek5qU4hJD6FwLbQItEqErqm 7wU0zNV3osZT40iMz2Q053lCu1xS4fUIWWVPN5npjBBf7dOsfVdVoA93gilvJyW2rAGKWShE5ak gSrGuT9N9z+r7lHp5L X-Received: by 2002:a05:600c:870c:b0:47f:1a8d:4f30 with SMTP id 5b1f17b1804b1-482db4e2501mr72494205e9.26.1769871502705; Sat, 31 Jan 2026 06:58:22 -0800 (PST) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-482dbc7f580sm58014725e9.2.2026.01.31.06.58.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 31 Jan 2026 06:58:22 -0800 (PST) Date: Sat, 31 Jan 2026 17:58:19 +0300 From: Dan Carpenter To: Gustavo Piaz da Silva Cc: gregkh@linuxfoundation.org, ovidiu.panait.oss@gmail.com, gshahrouzi@gmail.com, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH] staging: axis-fifo: refactor device tree parsing Message-ID: References: <20260131140517.29771-1-gustavopiazdasilva2102@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260131140517.29771-1-gustavopiazdasilva2102@gmail.com> On Sat, Jan 31, 2026 at 11:05:17AM -0300, Gustavo Piaz da Silva wrote: > Refactor the device tree parsing logic in axis_fifo_probe() to reduce code duplication and improve readability. > > Create a helper function axis_fifo_get_u32() to handle property reading and error checking, replacing repetitive of_property_read_u32() calls. > > This change reduces the verbosity of the probe function and consolidates error logging for missing properties. > Line wrap the commit message at 72 characters. > Signed-off-by: Gustavo Piaz da Silva > --- > drivers/staging/axis-fifo/axis-fifo.c | 76 +++++++++------------------ > 1 file changed, 24 insertions(+), 52 deletions(-) > > diff --git a/drivers/staging/axis-fifo/axis-fifo.c b/drivers/staging/axis-fifo/axis-fifo.c > index 509d620d6ce7..258bb95f03d4 100644 > --- a/drivers/staging/axis-fifo/axis-fifo.c > +++ b/drivers/staging/axis-fifo/axis-fifo.c > @@ -482,68 +482,41 @@ static void axis_fifo_debugfs_init(struct axis_fifo *fifo) > &axis_fifo_debugfs_regs_fops); > } > > -static int axis_fifo_parse_dt(struct axis_fifo *fifo) > +static int axis_fifo_get_u32(struct axis_fifo *fifo, const char *prop, u32 *val) > { > - int ret; > - unsigned int value; > - struct device_node *node = fifo->dt_device->of_node; > + int ret = of_property_read_u32(fifo->dt_device->of_node, prop, val); > > - 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; > + dev_err(fifo->dt_device, "missing %s property\n", prop); > + return ret; > } > + return 0; > +} > > - 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; > - } > +static int axis_fifo_parse_dt(struct axis_fifo *fifo) > +{ > + u32 width; > > - 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; > + if (axis_fifo_get_u32(fifo, "xlnx,axi-str-rxd-tdata-width", &width) || width != 32) > goto end; > - } > - > - 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; > + if (axis_fifo_get_u32(fifo, "xlnx,axi-str-txd-tdata-width", &width) || width != 32) > goto end; This goto end stuff is weird. I get why you did it (because the error message is the same both times). But it's like I have to think about why these have a goto and the others are direct returns and I don't like that. I think I probably would have just changed the strings to be slightly different which solves the problem in a different way. > - } > > - 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; > - } > + if (axis_fifo_get_u32(fifo, "xlnx,rx-fifo-depth", &fifo->rx_fifo_depth)) > + return -EIO; > + if (axis_fifo_get_u32(fifo, "xlnx,tx-fifo-depth", &fifo->tx_fifo_depth)) > + return -EIO; > > - 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; > - } > + if (axis_fifo_get_u32(fifo, "xlnx,use-rx-data", (u32 *)&fifo->has_rx_fifo)) > + return -EIO; > + if (axis_fifo_get_u32(fifo, "xlnx,use-tx-data", (u32 *)&fifo->has_tx_fifo)) > + return -EIO; These casts weren't there in the original code. I hate these casts. We could just change the type from int to u32. Or we could leave the casts out like the original code did. > + > + return 0; > > end: > - return ret; > + dev_err(fifo->dt_device, "tdata-width only supports 32 bits\n"); > + return -EIO; > } > > static int axis_fifo_probe(struct platform_device *pdev) > @@ -646,8 +619,7 @@ static int axis_fifo_probe(struct platform_device *pdev) > > static void axis_fifo_remove(struct platform_device *pdev) > { > - struct device *dev = &pdev->dev; > - struct axis_fifo *fifo = dev_get_drvdata(dev); > + struct axis_fifo *fifo = platform_get_drvdata(pdev); This is unrelated. regards, dan carpenter > > debugfs_remove(fifo->debugfs_dir); > misc_deregister(&fifo->miscdev); > -- > 2.52.0 >