From nobody Thu Nov 28 20:00:51 2024 Received: from mail.manjaro.org (mail.manjaro.org [116.203.91.91]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBF54381C7; Sat, 28 Sep 2024 04:13:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=116.203.91.91 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727496788; cv=none; b=Y2vJnXosVAEewACsGu7+FpAVmbvKu5t4IhV6PYnILunqyvqhnVUFU0q8hVs/ds6/2j2ijJQfZxBN299lLLzsv4N13l9Bxw5vI5tPhVifeVBVyOQYHnaE55HI6PHw3V6S9pk+S2AgGODDb3L42+EcBqnY5jZrM2o9XmggrwiqHDU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727496788; c=relaxed/simple; bh=nJq456f64c+e8kZN0NWzv3Ow9HI5KlTRIj9SThuwtKQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oz1AKpSo1GSrQvMYB7hqERLdtyg7NX0KxaAG5yZ/m0heinM71H4yRAIURFPQHbSRoOxIF1J3p/hHihKVSdW7dIfD04sfeni+SxPQ90VilH4FbMxprmzZobFcj38mmdOjbNibdgCiG53ySlXGsUy9P3jl/9LsX374qhXeLcmK1GY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manjaro.org; spf=pass smtp.mailfrom=manjaro.org; dkim=pass (2048-bit key) header.d=manjaro.org header.i=@manjaro.org header.b=ebROR9Er; arc=none smtp.client-ip=116.203.91.91 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manjaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=manjaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=manjaro.org header.i=@manjaro.org header.b="ebROR9Er" From: Dragan Simic DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manjaro.org; s=2021; t=1727496778; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GpUUSCEgG6i2JX+Qd6833mlykOrIc+MfZyPBIOvg7Ao=; b=ebROR9ErceR5vLV6cjmxcAfhWeSaIi+Yaw6kiOKzhN2gRBUoNd0WAzLvX9dDvV7besTMnm CqC7FI16ocPrGYHG2aQpdXNcUDXhMv+LkTHNvryfbBIAQN5jj141TOKRtOKVYRS+1JpLcA h+klMWa3REEoMjBMGnHeNnpxERAAUtv+QNeOloEiCRrnv1x71Uv62isl02CdF9njwwNfKH 40YVJYnOzIShI08RuypKroKj0RaRbYlzsZBmuGZJsffwKEFW+BYeXqg5kn0VKe3jbE4WGm IjvTyQTP46pTPIUoUSfIDhbhrvAaNNHMtqB/BosoynekID7D/vAaLTe5CVucng== To: linux-spi@vger.kernel.org, linux-rockchip@lists.infradead.org Cc: broonie@kernel.org, heiko@sntech.de, gregkh@linuxfoundation.org, rafael@kernel.org, oss@helene.moe, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/5] spi: rockchip: Perform trivial code cleanups Date: Sat, 28 Sep 2024 06:12:45 +0200 Message-Id: <1b55380a0b9f0e8fe1a09611636b30e232b95d08.1727496560.git.dsimic@manjaro.org> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: ORIGINATING; auth=pass smtp.auth=dsimic@manjaro.org smtp.mailfrom=dsimic@manjaro.org Content-Type: text/plain; charset="utf-8" Perform a few trivial code cleanups, to obey the reverse Christmas tree rul= e, to avoid unnecessary line wrapping by using the 100-column width better, to actually obey the 100-column width in one case, and to make the way a couple of wrapped function arguments are indented a bit more readable. No intended functional changes are introduced by these code cleanups. Reviewed-by: Heiko Stuebner Signed-off-by: Dragan Simic --- drivers/spi/spi-rockchip.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c index e1ecd96c7858..81f2a966c124 100644 --- a/drivers/spi/spi-rockchip.c +++ b/drivers/spi/spi-rockchip.c @@ -742,34 +742,32 @@ static int rockchip_spi_setup(struct spi_device *spi) =20 static int rockchip_spi_probe(struct platform_device *pdev) { - int ret; - struct rockchip_spi *rs; + struct device_node *np =3D pdev->dev.of_node; struct spi_controller *ctlr; + struct rockchip_spi *rs; struct resource *mem; - struct device_node *np =3D pdev->dev.of_node; u32 rsd_nsecs, num_cs; bool target_mode; + int ret; =20 target_mode =3D of_property_read_bool(np, "spi-slave"); =20 if (target_mode) - ctlr =3D spi_alloc_target(&pdev->dev, - sizeof(struct rockchip_spi)); + ctlr =3D spi_alloc_target(&pdev->dev, sizeof(struct rockchip_spi)); else - ctlr =3D spi_alloc_host(&pdev->dev, - sizeof(struct rockchip_spi)); + ctlr =3D spi_alloc_host(&pdev->dev, sizeof(struct rockchip_spi)); =20 if (!ctlr) return -ENOMEM; =20 platform_set_drvdata(pdev, ctlr); =20 rs =3D spi_controller_get_devdata(ctlr); =20 /* Get basic io resource and map it */ rs->regs =3D devm_platform_get_and_ioremap_resource(pdev, 0, &mem); if (IS_ERR(rs->regs)) { - ret =3D PTR_ERR(rs->regs); + ret =3D PTR_ERR(rs->regs); goto err_put_ctlr; } =20 @@ -794,26 +792,25 @@ static int rockchip_spi_probe(struct platform_device = *pdev) goto err_put_ctlr; =20 ret =3D devm_request_threaded_irq(&pdev->dev, ret, rockchip_spi_isr, NULL, - IRQF_ONESHOT, dev_name(&pdev->dev), ctlr); + IRQF_ONESHOT, dev_name(&pdev->dev), ctlr); if (ret) goto err_put_ctlr; =20 rs->dev =3D &pdev->dev; rs->freq =3D clk_get_rate(rs->spiclk); =20 if (!of_property_read_u32(pdev->dev.of_node, "rx-sample-delay-ns", &rsd_nsecs)) { /* rx sample delay is expressed in parent clock cycles (max 3) */ - u32 rsd =3D DIV_ROUND_CLOSEST(rsd_nsecs * (rs->freq >> 8), - 1000000000 >> 8); + u32 rsd =3D DIV_ROUND_CLOSEST(rsd_nsecs * (rs->freq >> 8), 1000000000 >>= 8); if (!rsd) { dev_warn(rs->dev, "%u Hz are too slow to express %u ns delay\n", - rs->freq, rsd_nsecs); + rs->freq, rsd_nsecs); } else if (rsd > CR0_RSD_MAX) { rsd =3D CR0_RSD_MAX; - dev_warn(rs->dev, "%u Hz are too fast to express %u ns delay, clamping = at %u ns\n", - rs->freq, rsd_nsecs, - CR0_RSD_MAX * 1000000000U / rs->freq); + dev_warn(rs->dev, + "%u Hz are too fast to express %u ns delay, clamping at %u ns\n", + rs->freq, rsd_nsecs, CR0_RSD_MAX * 1000000000U / rs->freq); } rs->rsd =3D rsd; } From nobody Thu Nov 28 20:00:51 2024 Received: from mail.manjaro.org (mail.manjaro.org [116.203.91.91]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B07B741A8E; Sat, 28 Sep 2024 04:13:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=116.203.91.91 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727496788; cv=none; b=Gh1mkihvlEXP6eJsc4n4qIrG+ogkTgIDU31VQv8NsvoKFX1QxcpHscavgCC9tAkNwFnd92WZddRdCSdZFFK+jD4H8grUrZa6xTaL4tyHTn+ahxztGXKOQsnAxd8P5zw+NhGqF+wwOWZvuledjlZp2Vawpk6HqqFmZ6lhWdko8WA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727496788; c=relaxed/simple; bh=OJMCpEnmFHPuM97NunQ+AwWatqDlRkg/lqivaMWdtgA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=M5e9TjZmB2jIVoRbuKYvcKAbmKk/BHDeqp0+IzApqRMI/NhBGgpzvj5lodugqhOJJogSv77eKqzkJugzin745IFUQIqKbOlUJtyrPLvYAPKiVAyotiu/rKpm6RgjPMDwsAYV4ZvNRZ5zeei9d2KMI+C5KD+IQxO9AcKHIUCXOqc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manjaro.org; spf=pass smtp.mailfrom=manjaro.org; dkim=pass (2048-bit key) header.d=manjaro.org header.i=@manjaro.org header.b=JnGYul6u; arc=none smtp.client-ip=116.203.91.91 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manjaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=manjaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=manjaro.org header.i=@manjaro.org header.b="JnGYul6u" From: Dragan Simic DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manjaro.org; s=2021; t=1727496778; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PzI75TzRgrrI3vePx8GcUC6PxrksxLdMlke7DoZMVao=; b=JnGYul6uDOplCqctSuf5bvqetwg66f/91a8ohgP0bOYM7g2sNJsNtQCO8aqKmu+8VU+LEC s101dSaNobXOqpGb8QN6KS4quZcTfH8EYHAJj0BO2h1wiKi2dQpGhhqa6rudMhnY9dAU8o XhrBC4kLuqkcTKDmFQqVjlEPxqCInfkDodIN9BDzcgxB61pQ0J3+f7DALHJB9BJ6etSuYr oVvC76fqcyR7IpwtYJ8woVuu+uFJDUfZxACsojB4kIBfwIBoUDkqJtWtPfPCnAw/wT7txn CS0tkTJe3oaaicttE8pLhWy+KPSmHfD7pkxvOuJypqAsQEq5xFaTK3+wgVr7kQ== To: linux-spi@vger.kernel.org, linux-rockchip@lists.infradead.org Cc: broonie@kernel.org, heiko@sntech.de, gregkh@linuxfoundation.org, rafael@kernel.org, oss@helene.moe, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/5] spi: rockchip-sfc: Perform trivial code cleanups Date: Sat, 28 Sep 2024 06:12:46 +0200 Message-Id: <4dcd5d9cc4a20c9c6ad504d945475b767399b32f.1727496560.git.dsimic@manjaro.org> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: ORIGINATING; auth=pass smtp.auth=dsimic@manjaro.org smtp.mailfrom=dsimic@manjaro.org Content-Type: text/plain; charset="utf-8" Perform a couple of trivial code cleanups, to avoid unnecessary line wrappi= ng by using the 100-column width a bit better, and to drop a stray empty line. No intended functional changes are introduced by these code cleanups. Reviewed-by: Heiko Stuebner Signed-off-by: Dragan Simic --- drivers/spi/spi-rockchip-sfc.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/spi/spi-rockchip-sfc.c b/drivers/spi/spi-rockchip-sfc.c index 0d7fadcd4ed3..505d5089bf03 100644 --- a/drivers/spi/spi-rockchip-sfc.c +++ b/drivers/spi/spi-rockchip-sfc.c @@ -591,19 +591,17 @@ static int rockchip_sfc_probe(struct platform_device = *pdev) return PTR_ERR(sfc->hclk); } =20 - sfc->use_dma =3D !of_property_read_bool(sfc->dev->of_node, - "rockchip,sfc-no-dma"); + sfc->use_dma =3D !of_property_read_bool(sfc->dev->of_node, "rockchip,sfc-= no-dma"); =20 if (sfc->use_dma) { ret =3D dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32)); if (ret) { dev_warn(dev, "Unable to set dma mask\n"); return ret; } =20 sfc->buffer =3D dmam_alloc_coherent(dev, SFC_MAX_IOSIZE_VER3, - &sfc->dma_buffer, - GFP_KERNEL); + &sfc->dma_buffer, GFP_KERNEL); if (!sfc->buffer) return -ENOMEM; } @@ -629,7 +627,6 @@ static int rockchip_sfc_probe(struct platform_device *p= dev) 0, pdev->name, sfc); if (ret) { dev_err(dev, "Failed to request irq\n"); - goto err_irq; } From nobody Thu Nov 28 20:00:51 2024 Received: from mail.manjaro.org (mail.manjaro.org [116.203.91.91]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 80BB7155392; Sat, 28 Sep 2024 04:13:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=116.203.91.91 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727496789; cv=none; b=jdmdb0PxEM5vk3g3PkCeaugin4RfHQY3QHUkRCPMNJUB+y1AsbBkZVYd0z0+nIKG5D4b55nOO/qvwWsC/WcKlgJlJIIFuZq/r3F0Zb213VaUOdA3iGUqMgpueUhKlxhbZrn4davUFQAe4THw91W7D6OJj+OymroT3YIado/WV0k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727496789; c=relaxed/simple; bh=eOSms0RrfzCYSAMEM6NoxcLBKIPZ26cWiwWq5KKyFPw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=O0WO0JSIhmCjNX4Hu0+qldQKR7sYpLusWa/pVUljoxFcf+FDLZh4/K6gj0UstMVlFM5+OjLh+X+a2HKV3TFSGvmcQoMG0ueHRHjs7Bs9foV7jF+WL9Jc+LA+i4tXzQPFlq7q58AOROEpKkFWQ41UimOI2hfvjG3ux/5uHtD718E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manjaro.org; spf=pass smtp.mailfrom=manjaro.org; dkim=pass (2048-bit key) header.d=manjaro.org header.i=@manjaro.org header.b=dq4vJao9; arc=none smtp.client-ip=116.203.91.91 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manjaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=manjaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=manjaro.org header.i=@manjaro.org header.b="dq4vJao9" From: Dragan Simic DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manjaro.org; s=2021; t=1727496779; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kpp3peXn8LwBEdMA5eGMOZGlK98YLfThf9954gFiyVA=; b=dq4vJao9v1H1On37KKnAyjL/JXzcBBU0ER0bqG8NiLt3toH5r8EUbEipCsjWkgOZkMO29F 3yWLBuMFI++RjdR2bvMkkH+Qro52jL71Twh84HI8swopZJIg1kWSIytbZ5pU+O64yq/6Ce glfpVze2l6wyxwNfR0HvCreslfe5C5iW/3VDhoZ8eLoeAsCRmxofFAncYE5tiD7HXeOHXh 2GFLMOlsC0KeDdadlDip6Zf9hpZ7i66ndbEKVzhqbqXqLuQ/9g0nOU3RLcDJ5zTwPvizk/ N6Z0muHXB6H+B2GevNkmVrGF3NiTPofohGHMUD9gsQadWUqCF56J/RU5aPg7tQ== To: linux-spi@vger.kernel.org, linux-rockchip@lists.infradead.org Cc: broonie@kernel.org, heiko@sntech.de, gregkh@linuxfoundation.org, rafael@kernel.org, oss@helene.moe, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/5] spi: rockchip-sfc: Use dev_err_probe() in the probe path Date: Sat, 28 Sep 2024 06:12:47 +0200 Message-Id: <398229ef316e64dc0c27944ea793dcddef1ead4e.1727496560.git.dsimic@manjaro.org> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: ORIGINATING; auth=pass smtp.auth=dsimic@manjaro.org smtp.mailfrom=dsimic@manjaro.org Content-Type: text/plain; charset="utf-8" Use function dev_err_probe() in the probe path instead of dev_err() where appropriate, to make the code a bit more uniform and compact. Reviewed-by: Heiko Stuebner Signed-off-by: Dragan Simic --- drivers/spi/spi-rockchip-sfc.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spi-rockchip-sfc.c b/drivers/spi/spi-rockchip-sfc.c index 505d5089bf03..7e0fb4944a34 100644 --- a/drivers/spi/spi-rockchip-sfc.c +++ b/drivers/spi/spi-rockchip-sfc.c @@ -580,16 +580,14 @@ static int rockchip_sfc_probe(struct platform_device = *pdev) return PTR_ERR(sfc->regbase); =20 sfc->clk =3D devm_clk_get(&pdev->dev, "clk_sfc"); - if (IS_ERR(sfc->clk)) { - dev_err(&pdev->dev, "Failed to get sfc interface clk\n"); - return PTR_ERR(sfc->clk); - } + if (IS_ERR(sfc->clk)) + return dev_err_probe(&pdev->dev, PTR_ERR(sfc->clk), + "Failed to get sfc interface clk\n"); =20 sfc->hclk =3D devm_clk_get(&pdev->dev, "hclk_sfc"); - if (IS_ERR(sfc->hclk)) { - dev_err(&pdev->dev, "Failed to get sfc ahb clk\n"); - return PTR_ERR(sfc->hclk); - } + if (IS_ERR(sfc->hclk)) + return dev_err_probe(&pdev->dev, PTR_ERR(sfc->hclk), + "Failed to get sfc ahb clk\n"); =20 sfc->use_dma =3D !of_property_read_bool(sfc->dev->of_node, "rockchip,sfc-= no-dma"); From nobody Thu Nov 28 20:00:51 2024 Received: from mail.manjaro.org (mail.manjaro.org [116.203.91.91]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BD71154454; Sat, 28 Sep 2024 04:13:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=116.203.91.91 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727496789; cv=none; b=mgNM5rALO3vFHGkVIsv1aJAVL4sWwy96fTRl1HPWQaUJ8eYsj6YbEfyHLmfLpqdCuYnrhXqSQUODXi5zQ9UO/tGs3CnUXyuvd4+wbYu4pl8bztQO/Mr7Ol/dxqFemf6EB8Vnis1QiDiNuTL41jhFRkbrZXda8Tu6PjhNcB3hUzM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727496789; c=relaxed/simple; bh=T4b5SCDbPtpznM3ly/UqgYB98QDVOVTAORg7GBHsgrI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZPTrS5Wc/3/H2RsExG1IrTonDEaMkNMbWRr4F7c8/LYpSH8PeYRSI3cooDFrkfBs1ZZ+mjyAKzkfPGYdidLs1GnQIVN/WBPt7mb9xCdX3+QGQLZRKjBrtAbq7BvcvnIBXasPCHcvd9FV2CfUdbpEIXKk09QIZORX4xpzhE/pSlA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manjaro.org; spf=pass smtp.mailfrom=manjaro.org; dkim=pass (2048-bit key) header.d=manjaro.org header.i=@manjaro.org header.b=y2WoFxeF; arc=none smtp.client-ip=116.203.91.91 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manjaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=manjaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=manjaro.org header.i=@manjaro.org header.b="y2WoFxeF" From: Dragan Simic DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manjaro.org; s=2021; t=1727496780; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rKsTa/7rhm4a+RlN32Byj4tfrxf7+of7JzY7hJesRZ4=; b=y2WoFxeFfI2AKDIiPU6N0JB5zuc5QehUTZ35W2W1yLQNoFk7BdxJHHjy/ylXFRmZVttB4X ZMCfcuC9tqWEg9nbfEoY6DHtRp5Ogbe3l8hteoNlQEhGmvXIpuwSvO5S+ybexoC0AwkFf6 I6aMHf4TX8kNHavMvxzIGLlPgnXi5z1twYr6xRDGnNBDwv27cRbUgJK9jxxoZMuRxOR1fu l7tmbTxqoZ491jQRH+lEdmqG/4rKPIEsnFcT7+58fUssip0THFtN38ptRHWgBhdWW9NXpl 8F++KnEbrpMk0/uO5jGrIgYvNAhfDUQYV6myNXHG/YstnNPWNgiIYdmUMvPrVg== To: linux-spi@vger.kernel.org, linux-rockchip@lists.infradead.org Cc: broonie@kernel.org, heiko@sntech.de, gregkh@linuxfoundation.org, rafael@kernel.org, oss@helene.moe, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/5] driver core: Add device probe log helper dev_warn_probe() Date: Sat, 28 Sep 2024 06:12:48 +0200 Message-Id: <2fd9a60e0efe906dc7a203cd652c8d0b7f932470.1727496560.git.dsimic@manjaro.org> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: ORIGINATING; auth=pass smtp.auth=dsimic@manjaro.org smtp.mailfrom=dsimic@manjaro.org Content-Type: text/plain; charset="utf-8" Some drivers can still provide their functionality to a certain extent even some of their resource acquisitions eventually fail. In such cases, emitti= ng errors isn't the desired action, but warnings should be emitted instead. To solve this, introduce dev_warn_probe() as a new device probe log helper, which behaves identically as the already existing dev_err_probe(), while it produces warnings instead of errors. The intended use is with the resources that are actually optional for a particular driver. While there, copyedit the kerneldoc for dev_err_probe() a bit, to simplify its wording a bit, and reuse it as the kerneldoc for dev_warn_probe(), with the necessary wording adjustments, of course. Signed-off-by: Dragan Simic --- drivers/base/core.c | 110 ++++++++++++++++++++++++++++--------- include/linux/dev_printk.h | 1 + 2 files changed, 84 insertions(+), 27 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 8c0733d3aad8..a4592b7ffa5d 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -4982,71 +4982,127 @@ define_dev_printk_level(_dev_info, KERN_INFO); =20 #endif =20 +static int dev_probe_failed(const struct device *dev, int err, bool fatal, + const char *fmt, va_list args) +{ + struct va_format vaf; + + vaf.fmt =3D fmt; + vaf.va =3D &args; + + switch (err) { + case -EPROBE_DEFER: + device_set_deferred_probe_reason(dev, &vaf); + dev_dbg(dev, "error %pe: %pV", ERR_PTR(err), &vaf); + break; + + case -ENOMEM: + /* Don't print anything on -ENOMEM, there's already enough output */ + break; + + default: + /* Log fatal final failures as errors, otherwise produce warnings */ + if (fatal) + dev_err(dev, "error %pe: %pV", ERR_PTR(err), &vaf); + else + dev_warn(dev, "error %pe: %pV", ERR_PTR(err), &vaf); + break; + } + + return err; +} + /** * dev_err_probe - probe error check and log helper * @dev: the pointer to the struct device * @err: error value to test * @fmt: printf-style format string * @...: arguments as specified in the format string * * This helper implements common pattern present in probe functions for er= ror * checking: print debug or error message depending if the error value is * -EPROBE_DEFER and propagate error upwards. * In case of -EPROBE_DEFER it sets also defer probe reason, which can be * checked later by reading devices_deferred debugfs attribute. - * It replaces code sequence:: + * It replaces the following code sequence:: * * if (err !=3D -EPROBE_DEFER) * dev_err(dev, ...); * else * dev_dbg(dev, ...); * return err; * * with:: * * return dev_err_probe(dev, err, ...); * - * Using this helper in your probe function is totally fine even if @err is - * known to never be -EPROBE_DEFER. + * Using this helper in your probe function is totally fine even if @err + * is known to never be -EPROBE_DEFER. * The benefit compared to a normal dev_err() is the standardized format - * of the error code, it being emitted symbolically (i.e. you get "EAGAIN" - * instead of "-35") and the fact that the error code is returned which al= lows - * more compact error paths. + * of the error code, which is emitted symbolically (i.e. you get "EAGAIN" + * instead of "-35"), and having the error code returned allows more + * compact error paths. * * Returns @err. */ int dev_err_probe(const struct device *dev, int err, const char *fmt, ...) { - struct va_format vaf; va_list args; =20 va_start(args, fmt); - vaf.fmt =3D fmt; - vaf.va =3D &args; =20 - switch (err) { - case -EPROBE_DEFER: - device_set_deferred_probe_reason(dev, &vaf); - dev_dbg(dev, "error %pe: %pV", ERR_PTR(err), &vaf); - break; + /* Use dev_err() for logging when err doesn't equal -EPROBE_DEFER */ + dev_probe_failed(dev, err, true, fmt, args); =20 - case -ENOMEM: - /* - * We don't print anything on -ENOMEM, there is already enough - * output. - */ - break; + va_end(args); +} +EXPORT_SYMBOL_GPL(dev_err_probe); =20 - default: - dev_err(dev, "error %pe: %pV", ERR_PTR(err), &vaf); - break; - } +/** + * dev_warn_probe - probe error check and log helper + * @dev: the pointer to the struct device + * @err: error value to test + * @fmt: printf-style format string + * @...: arguments as specified in the format string + * + * This helper implements common pattern present in probe functions for er= ror + * checking: print debug or warning message depending if the error value is + * -EPROBE_DEFER and propagate error upwards. + * In case of -EPROBE_DEFER it sets also defer probe reason, which can be + * checked later by reading devices_deferred debugfs attribute. + * It replaces the following code sequence:: + * + * if (err !=3D -EPROBE_DEFER) + * dev_warn(dev, ...); + * else + * dev_dbg(dev, ...); + * return err; + * + * with:: + * + * return dev_warn_probe(dev, err, ...); + * + * Using this helper in your probe function is totally fine even if @err + * is known to never be -EPROBE_DEFER. + * The benefit compared to a normal dev_warn() is the standardized format + * of the error code, which is emitted symbolically (i.e. you get "EAGAIN" + * instead of "-35"), and having the error code returned allows more + * compact error paths. + * + * Returns @err. + */ +int dev_warn_probe(const struct device *dev, int err, const char *fmt, ...) +{ + va_list args; =20 - va_end(args); + va_start(args, fmt); =20 - return err; + /* Use dev_warn() for logging when err doesn't equal -EPROBE_DEFER */ + dev_probe_failed(dev, err, false, fmt, args); + + va_end(args); } -EXPORT_SYMBOL_GPL(dev_err_probe); +EXPORT_SYMBOL_GPL(dev_warn_probe); =20 static inline bool fwnode_is_primary(struct fwnode_handle *fwnode) { diff --git a/include/linux/dev_printk.h b/include/linux/dev_printk.h index ca32b5bb28eb..eb2094e43050 100644 --- a/include/linux/dev_printk.h +++ b/include/linux/dev_printk.h @@ -276,6 +276,7 @@ do { \ dev_driver_string(dev), dev_name(dev), ## arg) =20 __printf(3, 4) int dev_err_probe(const struct device *dev, int err, const = char *fmt, ...); +__printf(3, 4) int dev_warn_probe(const struct device *dev, int err, const= char *fmt, ...); =20 /* Simple helper for dev_err_probe() when ERR_PTR() is to be returned. */ #define dev_err_ptr_probe(dev, ___err, fmt, ...) \ From nobody Thu Nov 28 20:00:51 2024 Received: from mail.manjaro.org (mail.manjaro.org [116.203.91.91]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F1435165F04; Sat, 28 Sep 2024 04:13:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=116.203.91.91 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727496791; cv=none; b=ZtaEpCsZ+T0dtAEizY0hVr95g//aBLcQgo5UWQwqEVPrqIx7uCwxxr6JVOqGOUGUYUlGoWTMYHr4Q4f95IAHweFsuENFKCoG24sBuQyJURkQe24Vvcs7cRGkdX1TADOFVG+duJmDN907plODgRzolq7BoleEdB9JISUD7saKp+k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727496791; c=relaxed/simple; bh=/0dqEeVI0kdnBedaeCOmkKYW/KlhzVR3w6RZjjLJeNI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=gOT0fNUO9zecVSHIx+O3fcIZImgp7XMADofvtpkW4SXlcoqYnbmTKj2zVp8eBteEbjof9yJKonTB3oLiDKF1F8ZdZ8swGkuFUfLl4AcsIYQm7ML97NzTjtG+nRibLxzZjbC1BAjgMobo9aoBwhjx++/39waXDxzLYQofaSI8jTE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manjaro.org; spf=pass smtp.mailfrom=manjaro.org; dkim=pass (2048-bit key) header.d=manjaro.org header.i=@manjaro.org header.b=dGdOAyY2; arc=none smtp.client-ip=116.203.91.91 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manjaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=manjaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=manjaro.org header.i=@manjaro.org header.b="dGdOAyY2" From: Dragan Simic DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manjaro.org; s=2021; t=1727496781; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/j3wHuSvKpQWX/VU5AEDYXLGtmoTcj7Rhg34WD2kMcg=; b=dGdOAyY2RpRJ/zO5zBPDSKb+SEjR9m2ong/UfCBAPqC3XoUki1n9i3k5oNsBnqVvNxLFJ6 57ju1SsECm5VXqR3TjmEqIRCZs2FOR0Fjo7u7E/QO4VcVUfaISg5a77WD73kFUMGkIJ996 xO+bGaU883XhiKl+t60UvIQQYvGBYWsGF8Axpg8URy9d4m7gtNP53SORnpQuCuqHVdFDQz FUUgr9wSfjtukAq1vs/VIV5n1g9NE45GLf9FsPcWQ2BRMhPM4xIQXrwrCbN37krgFT49dB q4RIe9D3/ecNUgJpEoDbgXzC3lWiDQf8H96OyvTzASWNj51I27gVwd6RiAk5SQ== To: linux-spi@vger.kernel.org, linux-rockchip@lists.infradead.org Cc: broonie@kernel.org, heiko@sntech.de, gregkh@linuxfoundation.org, rafael@kernel.org, oss@helene.moe, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/5] spi: rockchip: Use dev_{err,warn}_probe() in the probe path Date: Sat, 28 Sep 2024 06:12:49 +0200 Message-Id: In-Reply-To: References: 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="utf-8" Content-Transfer-Encoding: quoted-printable Authentication-Results: ORIGINATING; auth=pass smtp.auth=dsimic@manjaro.org smtp.mailfrom=dsimic@manjaro.org Use function dev_err_probe() in the probe path instead of dev_err() where appropriate, to make the code a bit more uniform and compact. Use the new function dev_warn_probe() to improve error handling for the TX and RX DMA channel requests, which are actually optional, and tweak the logged warnings a bit to additionally describe their optional nature. Previously, deferred requests for the TX and RX DMA channels produced no debug messages, and the final error messages didn't include the error codes, which are all highly useful when debugging permanently failed DMA channel requests, such as when the required drivers aren't enabled. Suggested-by: H=C3=A9lene Vulquin Signed-off-by: Dragan Simic --- drivers/spi/spi-rockchip.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c index 81f2a966c124..055cd6066466 100644 --- a/drivers/spi/spi-rockchip.c +++ b/drivers/spi/spi-rockchip.c @@ -773,15 +773,15 @@ static int rockchip_spi_probe(struct platform_device = *pdev) =20 rs->apb_pclk =3D devm_clk_get_enabled(&pdev->dev, "apb_pclk"); if (IS_ERR(rs->apb_pclk)) { - dev_err(&pdev->dev, "Failed to get apb_pclk\n"); - ret =3D PTR_ERR(rs->apb_pclk); + ret =3D dev_err_probe(&pdev->dev, PTR_ERR(rs->apb_pclk), + "Failed to get apb_pclk\n"); goto err_put_ctlr; } =20 rs->spiclk =3D devm_clk_get_enabled(&pdev->dev, "spiclk"); if (IS_ERR(rs->spiclk)) { - dev_err(&pdev->dev, "Failed to get spi_pclk\n"); - ret =3D PTR_ERR(rs->spiclk); + ret =3D dev_err_probe(&pdev->dev, PTR_ERR(rs->spiclk), + "Failed to get spi_pclk\n"); goto err_put_ctlr; } =20 @@ -817,8 +817,7 @@ static int rockchip_spi_probe(struct platform_device *p= dev) =20 rs->fifo_len =3D get_fifo_len(rs); if (!rs->fifo_len) { - dev_err(&pdev->dev, "Failed to get fifo length\n"); - ret =3D -EINVAL; + ret =3D dev_err_probe(&pdev->dev, -EINVAL, "Failed to get fifo length\n"= ); goto err_put_ctlr; } =20 @@ -858,22 +857,21 @@ static int rockchip_spi_probe(struct platform_device = *pdev) =20 ctlr->dma_tx =3D dma_request_chan(rs->dev, "tx"); if (IS_ERR(ctlr->dma_tx)) { - /* Check tx to see if we need defer probing driver */ - if (PTR_ERR(ctlr->dma_tx) =3D=3D -EPROBE_DEFER) { - ret =3D -EPROBE_DEFER; + /* Check tx to see if we need to defer driver probing */ + ret =3D dev_warn_probe(rs->dev, PTR_ERR(ctlr->dma_tx), + "Failed to request optional TX DMA channel\n"); + if (ret =3D=3D -EPROBE_DEFER) goto err_disable_pm_runtime; - } - dev_warn(rs->dev, "Failed to request TX DMA channel\n"); ctlr->dma_tx =3D NULL; } =20 ctlr->dma_rx =3D dma_request_chan(rs->dev, "rx"); if (IS_ERR(ctlr->dma_rx)) { - if (PTR_ERR(ctlr->dma_rx) =3D=3D -EPROBE_DEFER) { - ret =3D -EPROBE_DEFER; + /* Check rx to see if we need to defer driver probing */ + ret =3D dev_warn_probe(rs->dev, PTR_ERR(ctlr->dma_rx), + "Failed to request optional RX DMA channel\n"); + if (ret =3D=3D -EPROBE_DEFER) goto err_free_dma_tx; - } - dev_warn(rs->dev, "Failed to request RX DMA channel\n"); ctlr->dma_rx =3D NULL; } =20