Re: [PATCH 08/26] net: stmmac: dwmac-qcom-ethqos: use a helper variable for &pdev->dev

Andrew Halaney
2023-06-12T18:38:53Z

On Mon, Jun 12, 2023 at 11:23:37AM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> Shrink code and avoid line breaks by using a helper variable for
> &pdev->dev.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
> .../stmicro/stmmac/dwmac-qcom-ethqos.c | 48 ++++++++++---------
> 1 file changed, 26 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
> index 28d2514a8795..e19d142630d3 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
> @@ -123,25 +123,26 @@ static void rgmii_updatel(struct qcom_ethqos *ethqos,
> static void rgmii_dump(void *priv)
> {
> struct qcom_ethqos *ethqos = priv;
> + struct device *dev = &ethqos->pdev->dev;
>
> - dev_dbg(&ethqos->pdev->dev, "Rgmii register dump\n");
> - dev_dbg(&ethqos->pdev->dev, "RGMII_IO_MACRO_CONFIG: %x\n",
> + dev_dbg(dev, "Rgmii register dump\n");
> + dev_dbg(dev, "RGMII_IO_MACRO_CONFIG: %x\n",
> rgmii_readl(ethqos, RGMII_IO_MACRO_CONFIG));
> - dev_dbg(&ethqos->pdev->dev, "SDCC_HC_REG_DLL_CONFIG: %x\n",
> + dev_dbg(dev, "SDCC_HC_REG_DLL_CONFIG: %x\n",
> rgmii_readl(ethqos, SDCC_HC_REG_DLL_CONFIG));
> - dev_dbg(&ethqos->pdev->dev, "SDCC_HC_REG_DDR_CONFIG: %x\n",
> + dev_dbg(dev, "SDCC_HC_REG_DDR_CONFIG: %x\n",
> rgmii_readl(ethqos, SDCC_HC_REG_DDR_CONFIG));
> - dev_dbg(&ethqos->pdev->dev, "SDCC_HC_REG_DLL_CONFIG2: %x\n",
> + dev_dbg(dev, "SDCC_HC_REG_DLL_CONFIG2: %x\n",
> rgmii_readl(ethqos, SDCC_HC_REG_DLL_CONFIG2));
> - dev_dbg(&ethqos->pdev->dev, "SDC4_STATUS: %x\n",
> + dev_dbg(dev, "SDC4_STATUS: %x\n",
> rgmii_readl(ethqos, SDC4_STATUS));
> - dev_dbg(&ethqos->pdev->dev, "SDCC_USR_CTL: %x\n",
> + dev_dbg(dev, "SDCC_USR_CTL: %x\n",
> rgmii_readl(ethqos, SDCC_USR_CTL));
> - dev_dbg(&ethqos->pdev->dev, "RGMII_IO_MACRO_CONFIG2: %x\n",
> + dev_dbg(dev, "RGMII_IO_MACRO_CONFIG2: %x\n",
> rgmii_readl(ethqos, RGMII_IO_MACRO_CONFIG2));
> - dev_dbg(&ethqos->pdev->dev, "RGMII_IO_MACRO_DEBUG1: %x\n",
> + dev_dbg(dev, "RGMII_IO_MACRO_DEBUG1: %x\n",
> rgmii_readl(ethqos, RGMII_IO_MACRO_DEBUG1));
> - dev_dbg(&ethqos->pdev->dev, "EMAC_SYSTEM_LOW_POWER_DEBUG: %x\n",
> + dev_dbg(dev, "EMAC_SYSTEM_LOW_POWER_DEBUG: %x\n",
> rgmii_readl(ethqos, EMAC_SYSTEM_LOW_POWER_DEBUG));
> }
>
> @@ -242,6 +243,7 @@ static const struct ethqos_emac_driver_data emac_v3_0_0_data = {
>
> static int ethqos_dll_configure(struct qcom_ethqos *ethqos)
> {
> + struct device *dev = &ethqos->pdev->dev;
> unsigned int val;
> int retry = 1000;
>
> @@ -279,7 +281,7 @@ static int ethqos_dll_configure(struct qcom_ethqos *ethqos)
> retry--;
> } while (retry > 0);
> if (!retry)
> - dev_err(&ethqos->pdev->dev, "Clear CK_OUT_EN timedout\n");
> + dev_err(dev, "Clear CK_OUT_EN timedout\n");
>
> /* Set CK_OUT_EN */
> rgmii_updatel(ethqos, SDCC_DLL_CONFIG_CK_OUT_EN,
> @@ -296,7 +298,7 @@ static int ethqos_dll_configure(struct qcom_ethqos *ethqos)
> retry--;
> } while (retry > 0);
> if (!retry)
> - dev_err(&ethqos->pdev->dev, "Set CK_OUT_EN timedout\n");
> + dev_err(dev, "Set CK_OUT_EN timedout\n");
>
> /* Set DDR_CAL_EN */
> rgmii_updatel(ethqos, SDCC_DLL_CONFIG2_DDR_CAL_EN,
> @@ -322,12 +324,13 @@ static int ethqos_dll_configure(struct qcom_ethqos *ethqos)
>
> static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos)
> {
> + struct device *dev = &ethqos->pdev->dev;
> int phase_shift;
> int phy_mode;
> int loopback;
>
> /* Determine if the PHY adds a 2 ns TX delay or the MAC handles it */
> - phy_mode = device_get_phy_mode(&ethqos->pdev->dev);
> + phy_mode = device_get_phy_mode(dev);
> if (phy_mode == PHY_INTERFACE_MODE_RGMII_ID ||
> phy_mode == PHY_INTERFACE_MODE_RGMII_TXID)
> phase_shift = 0;
> @@ -468,7 +471,7 @@ static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos)
> loopback, RGMII_IO_MACRO_CONFIG);
> break;
> default:
> - dev_err(&ethqos->pdev->dev,
> + dev_err(dev,
> "Invalid speed %d\n", ethqos->speed);

nit: You could put this on the prior line now

With that in place, feel free to add:

Reviewed-by: Andrew Halaney <ahalaney@redhat.com>