* [PATCH v2 0/5] Add dev_warn_probe() and improve error handling in Rockchip SPI drivers
@ 2024-09-28 4:12 Dragan Simic
2024-09-28 4:12 ` [PATCH v2 1/5] spi: rockchip: Perform trivial code cleanups Dragan Simic
` (4 more replies)
0 siblings, 5 replies; 9+ messages in thread
From: Dragan Simic @ 2024-09-28 4:12 UTC (permalink / raw)
To: linux-spi, linux-rockchip
Cc: broonie, heiko, gregkh, rafael, oss, linux-arm-kernel,
linux-kernel
This is a small series that introduces dev_warn_probe() function, which
produces warnings on failed resource acquisitions, and improves error
handling in the probe paths of Rockchip SPI drivers, by using functions
dev_err_probe() and dev_warn_probe() properly in multiple places.
This series also performs a bunch of small, rather trivial code cleanups,
to make the code neater and a bit easier to read.
Changes in v2:
- Collected three Reviewed-by tags from Heiko [1][2][3]
- Dropped patch 3/5, [4] as suggested by Mark, [5] improved the check
to use dev_err_probe() and folded that into new patch 5/5
- Added new patch 4/5 that introduces function dev_warn_probe() that
produces warnings in probe paths, to avoid the promotion of logged
messages from warnings to errors, as noted by Heiko [6]
- Adjusted the description of the series and of the individual patches
a bit to reflect the changes, where appropriate
Link to v1: https://lore.kernel.org/linux-rockchip/cover.1727337732.git.dsimic@manjaro.org/T/#u
[1] https://lore.kernel.org/linux-rockchip/6085918.31tnzDBltd@phil/
[2] https://lore.kernel.org/linux-rockchip/2285557.3ZeAukHxDK@phil/
[3] https://lore.kernel.org/linux-rockchip/10409403.0AQdONaE2F@phil/
[4] https://lore.kernel.org/linux-rockchip/ce2e7f90e62b15adc2bed1f53122ad39c3a9b5ac.1727337732.git.dsimic@manjaro.org/
[5] https://lore.kernel.org/linux-rockchip/ZvUmk48R4hZYlO71@finisterre.sirena.org.uk/
[6] https://lore.kernel.org/linux-rockchip/6673004.tM3a2QDmDi@phil/
Dragan Simic (5):
spi: rockchip: Perform trivial code cleanups
spi: rockchip-sfc: Perform trivial code cleanups
spi: rockchip-sfc: Use dev_err_probe() in the probe path
driver core: Add device probe log helper dev_warn_probe()
spi: rockchip: Use dev_{err,warn}_probe() in the probe path
drivers/base/core.c | 110 +++++++++++++++++++++++++--------
drivers/spi/spi-rockchip-sfc.c | 21 +++----
drivers/spi/spi-rockchip.c | 55 ++++++++---------
include/linux/dev_printk.h | 1 +
4 files changed, 117 insertions(+), 70 deletions(-)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 1/5] spi: rockchip: Perform trivial code cleanups
2024-09-28 4:12 [PATCH v2 0/5] Add dev_warn_probe() and improve error handling in Rockchip SPI drivers Dragan Simic
@ 2024-09-28 4:12 ` Dragan Simic
2024-09-28 4:12 ` [PATCH v2 2/5] spi: rockchip-sfc: " Dragan Simic
` (3 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Dragan Simic @ 2024-09-28 4:12 UTC (permalink / raw)
To: linux-spi, linux-rockchip
Cc: broonie, heiko, gregkh, rafael, oss, linux-arm-kernel,
linux-kernel
Perform a few trivial code cleanups, to obey the reverse Christmas tree rule,
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 <heiko@sntech.de>
Signed-off-by: Dragan Simic <dsimic@manjaro.org>
---
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)
static int rockchip_spi_probe(struct platform_device *pdev)
{
- int ret;
- struct rockchip_spi *rs;
+ struct device_node *np = pdev->dev.of_node;
struct spi_controller *ctlr;
+ struct rockchip_spi *rs;
struct resource *mem;
- struct device_node *np = pdev->dev.of_node;
u32 rsd_nsecs, num_cs;
bool target_mode;
+ int ret;
target_mode = of_property_read_bool(np, "spi-slave");
if (target_mode)
- ctlr = spi_alloc_target(&pdev->dev,
- sizeof(struct rockchip_spi));
+ ctlr = spi_alloc_target(&pdev->dev, sizeof(struct rockchip_spi));
else
- ctlr = spi_alloc_host(&pdev->dev,
- sizeof(struct rockchip_spi));
+ ctlr = spi_alloc_host(&pdev->dev, sizeof(struct rockchip_spi));
if (!ctlr)
return -ENOMEM;
platform_set_drvdata(pdev, ctlr);
rs = spi_controller_get_devdata(ctlr);
/* Get basic io resource and map it */
rs->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &mem);
if (IS_ERR(rs->regs)) {
- ret = PTR_ERR(rs->regs);
+ ret = PTR_ERR(rs->regs);
goto err_put_ctlr;
}
@@ -794,26 +792,25 @@ static int rockchip_spi_probe(struct platform_device *pdev)
goto err_put_ctlr;
ret = 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;
rs->dev = &pdev->dev;
rs->freq = clk_get_rate(rs->spiclk);
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 = DIV_ROUND_CLOSEST(rsd_nsecs * (rs->freq >> 8),
- 1000000000 >> 8);
+ u32 rsd = 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 = 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 = rsd;
}
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 2/5] spi: rockchip-sfc: Perform trivial code cleanups
2024-09-28 4:12 [PATCH v2 0/5] Add dev_warn_probe() and improve error handling in Rockchip SPI drivers Dragan Simic
2024-09-28 4:12 ` [PATCH v2 1/5] spi: rockchip: Perform trivial code cleanups Dragan Simic
@ 2024-09-28 4:12 ` Dragan Simic
2024-09-28 4:12 ` [PATCH v2 3/5] spi: rockchip-sfc: Use dev_err_probe() in the probe path Dragan Simic
` (2 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Dragan Simic @ 2024-09-28 4:12 UTC (permalink / raw)
To: linux-spi, linux-rockchip
Cc: broonie, heiko, gregkh, rafael, oss, linux-arm-kernel,
linux-kernel
Perform a couple of trivial code cleanups, to avoid unnecessary line wrapping
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 <heiko@sntech.de>
Signed-off-by: Dragan Simic <dsimic@manjaro.org>
---
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);
}
- sfc->use_dma = !of_property_read_bool(sfc->dev->of_node,
- "rockchip,sfc-no-dma");
+ sfc->use_dma = !of_property_read_bool(sfc->dev->of_node, "rockchip,sfc-no-dma");
if (sfc->use_dma) {
ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
if (ret) {
dev_warn(dev, "Unable to set dma mask\n");
return ret;
}
sfc->buffer = 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 *pdev)
0, pdev->name, sfc);
if (ret) {
dev_err(dev, "Failed to request irq\n");
-
goto err_irq;
}
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 3/5] spi: rockchip-sfc: Use dev_err_probe() in the probe path
2024-09-28 4:12 [PATCH v2 0/5] Add dev_warn_probe() and improve error handling in Rockchip SPI drivers Dragan Simic
2024-09-28 4:12 ` [PATCH v2 1/5] spi: rockchip: Perform trivial code cleanups Dragan Simic
2024-09-28 4:12 ` [PATCH v2 2/5] spi: rockchip-sfc: " Dragan Simic
@ 2024-09-28 4:12 ` Dragan Simic
2024-09-28 4:12 ` [PATCH v2 4/5] driver core: Add device probe log helper dev_warn_probe() Dragan Simic
2024-09-28 4:12 ` [PATCH v2 5/5] spi: rockchip: Use dev_{err,warn}_probe() in the probe path Dragan Simic
4 siblings, 0 replies; 9+ messages in thread
From: Dragan Simic @ 2024-09-28 4:12 UTC (permalink / raw)
To: linux-spi, linux-rockchip
Cc: broonie, heiko, gregkh, rafael, oss, linux-arm-kernel,
linux-kernel
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 <heiko@sntech.de>
Signed-off-by: Dragan Simic <dsimic@manjaro.org>
---
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);
sfc->clk = 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");
sfc->hclk = 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");
sfc->use_dma = !of_property_read_bool(sfc->dev->of_node, "rockchip,sfc-no-dma");
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 4/5] driver core: Add device probe log helper dev_warn_probe()
2024-09-28 4:12 [PATCH v2 0/5] Add dev_warn_probe() and improve error handling in Rockchip SPI drivers Dragan Simic
` (2 preceding siblings ...)
2024-09-28 4:12 ` [PATCH v2 3/5] spi: rockchip-sfc: Use dev_err_probe() in the probe path Dragan Simic
@ 2024-09-28 4:12 ` Dragan Simic
2024-09-29 1:39 ` kernel test robot
` (2 more replies)
2024-09-28 4:12 ` [PATCH v2 5/5] spi: rockchip: Use dev_{err,warn}_probe() in the probe path Dragan Simic
4 siblings, 3 replies; 9+ messages in thread
From: Dragan Simic @ 2024-09-28 4:12 UTC (permalink / raw)
To: linux-spi, linux-rockchip
Cc: broonie, heiko, gregkh, rafael, oss, linux-arm-kernel,
linux-kernel
Some drivers can still provide their functionality to a certain extent even
some of their resource acquisitions eventually fail. In such cases, emitting
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 <dsimic@manjaro.org>
---
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);
#endif
+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 = fmt;
+ vaf.va = &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 error
* 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 != -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 allows
- * 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;
va_start(args, fmt);
- vaf.fmt = fmt;
- vaf.va = &args;
- 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);
- case -ENOMEM:
- /*
- * We don't print anything on -ENOMEM, there is already enough
- * output.
- */
- break;
+ va_end(args);
+}
+EXPORT_SYMBOL_GPL(dev_err_probe);
- 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 error
+ * 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 != -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;
- va_end(args);
+ va_start(args, fmt);
- 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);
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)
__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, ...);
/* Simple helper for dev_err_probe() when ERR_PTR() is to be returned. */
#define dev_err_ptr_probe(dev, ___err, fmt, ...) \
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 5/5] spi: rockchip: Use dev_{err,warn}_probe() in the probe path
2024-09-28 4:12 [PATCH v2 0/5] Add dev_warn_probe() and improve error handling in Rockchip SPI drivers Dragan Simic
` (3 preceding siblings ...)
2024-09-28 4:12 ` [PATCH v2 4/5] driver core: Add device probe log helper dev_warn_probe() Dragan Simic
@ 2024-09-28 4:12 ` Dragan Simic
4 siblings, 0 replies; 9+ messages in thread
From: Dragan Simic @ 2024-09-28 4:12 UTC (permalink / raw)
To: linux-spi, linux-rockchip
Cc: broonie, heiko, gregkh, rafael, oss, linux-arm-kernel,
linux-kernel
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élene Vulquin <oss@helene.moe>
Signed-off-by: Dragan Simic <dsimic@manjaro.org>
---
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)
rs->apb_pclk = 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 = PTR_ERR(rs->apb_pclk);
+ ret = dev_err_probe(&pdev->dev, PTR_ERR(rs->apb_pclk),
+ "Failed to get apb_pclk\n");
goto err_put_ctlr;
}
rs->spiclk = devm_clk_get_enabled(&pdev->dev, "spiclk");
if (IS_ERR(rs->spiclk)) {
- dev_err(&pdev->dev, "Failed to get spi_pclk\n");
- ret = PTR_ERR(rs->spiclk);
+ ret = dev_err_probe(&pdev->dev, PTR_ERR(rs->spiclk),
+ "Failed to get spi_pclk\n");
goto err_put_ctlr;
}
@@ -817,8 +817,7 @@ static int rockchip_spi_probe(struct platform_device *pdev)
rs->fifo_len = get_fifo_len(rs);
if (!rs->fifo_len) {
- dev_err(&pdev->dev, "Failed to get fifo length\n");
- ret = -EINVAL;
+ ret = dev_err_probe(&pdev->dev, -EINVAL, "Failed to get fifo length\n");
goto err_put_ctlr;
}
@@ -858,22 +857,21 @@ static int rockchip_spi_probe(struct platform_device *pdev)
ctlr->dma_tx = 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) == -EPROBE_DEFER) {
- ret = -EPROBE_DEFER;
+ /* Check tx to see if we need to defer driver probing */
+ ret = dev_warn_probe(rs->dev, PTR_ERR(ctlr->dma_tx),
+ "Failed to request optional TX DMA channel\n");
+ if (ret == -EPROBE_DEFER)
goto err_disable_pm_runtime;
- }
- dev_warn(rs->dev, "Failed to request TX DMA channel\n");
ctlr->dma_tx = NULL;
}
ctlr->dma_rx = dma_request_chan(rs->dev, "rx");
if (IS_ERR(ctlr->dma_rx)) {
- if (PTR_ERR(ctlr->dma_rx) == -EPROBE_DEFER) {
- ret = -EPROBE_DEFER;
+ /* Check rx to see if we need to defer driver probing */
+ ret = dev_warn_probe(rs->dev, PTR_ERR(ctlr->dma_rx),
+ "Failed to request optional RX DMA channel\n");
+ if (ret == -EPROBE_DEFER)
goto err_free_dma_tx;
- }
- dev_warn(rs->dev, "Failed to request RX DMA channel\n");
ctlr->dma_rx = NULL;
}
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 4/5] driver core: Add device probe log helper dev_warn_probe()
2024-09-28 4:12 ` [PATCH v2 4/5] driver core: Add device probe log helper dev_warn_probe() Dragan Simic
@ 2024-09-29 1:39 ` kernel test robot
2024-09-29 2:10 ` kernel test robot
2024-09-29 2:20 ` kernel test robot
2 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2024-09-29 1:39 UTC (permalink / raw)
To: Dragan Simic, linux-spi, linux-rockchip
Cc: oe-kbuild-all, broonie, heiko, gregkh, rafael, oss,
linux-arm-kernel, linux-kernel
Hi Dragan,
kernel test robot noticed the following build warnings:
[auto build test WARNING on rockchip/for-next]
[also build test WARNING on broonie-spi/for-next driver-core/driver-core-testing driver-core/driver-core-next driver-core/driver-core-linus linus/master v6.11 next-20240927]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Dragan-Simic/spi-rockchip-Perform-trivial-code-cleanups/20240928-121548
base: https://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip.git for-next
patch link: https://lore.kernel.org/r/2fd9a60e0efe906dc7a203cd652c8d0b7f932470.1727496560.git.dsimic%40manjaro.org
patch subject: [PATCH v2 4/5] driver core: Add device probe log helper dev_warn_probe()
config: openrisc-allnoconfig (https://download.01.org/0day-ci/archive/20240929/202409290956.jwLrcN1S-lkp@intel.com/config)
compiler: or1k-linux-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240929/202409290956.jwLrcN1S-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202409290956.jwLrcN1S-lkp@intel.com/
All warnings (new ones prefixed by >>):
drivers/base/core.c: In function 'dev_err_probe':
>> drivers/base/core.c:5055:1: warning: control reaches end of non-void function [-Wreturn-type]
5055 | }
| ^
drivers/base/core.c: In function 'dev_warn_probe':
drivers/base/core.c:5101:1: warning: control reaches end of non-void function [-Wreturn-type]
5101 | }
| ^
vim +5055 drivers/base/core.c
5011
5012 /**
5013 * dev_err_probe - probe error check and log helper
5014 * @dev: the pointer to the struct device
5015 * @err: error value to test
5016 * @fmt: printf-style format string
5017 * @...: arguments as specified in the format string
5018 *
5019 * This helper implements common pattern present in probe functions for error
5020 * checking: print debug or error message depending if the error value is
5021 * -EPROBE_DEFER and propagate error upwards.
5022 * In case of -EPROBE_DEFER it sets also defer probe reason, which can be
5023 * checked later by reading devices_deferred debugfs attribute.
5024 * It replaces the following code sequence::
5025 *
5026 * if (err != -EPROBE_DEFER)
5027 * dev_err(dev, ...);
5028 * else
5029 * dev_dbg(dev, ...);
5030 * return err;
5031 *
5032 * with::
5033 *
5034 * return dev_err_probe(dev, err, ...);
5035 *
5036 * Using this helper in your probe function is totally fine even if @err
5037 * is known to never be -EPROBE_DEFER.
5038 * The benefit compared to a normal dev_err() is the standardized format
5039 * of the error code, which is emitted symbolically (i.e. you get "EAGAIN"
5040 * instead of "-35"), and having the error code returned allows more
5041 * compact error paths.
5042 *
5043 * Returns @err.
5044 */
5045 int dev_err_probe(const struct device *dev, int err, const char *fmt, ...)
5046 {
5047 va_list args;
5048
5049 va_start(args, fmt);
5050
5051 /* Use dev_err() for logging when err doesn't equal -EPROBE_DEFER */
5052 dev_probe_failed(dev, err, true, fmt, args);
5053
5054 va_end(args);
> 5055 }
5056 EXPORT_SYMBOL_GPL(dev_err_probe);
5057
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 4/5] driver core: Add device probe log helper dev_warn_probe()
2024-09-28 4:12 ` [PATCH v2 4/5] driver core: Add device probe log helper dev_warn_probe() Dragan Simic
2024-09-29 1:39 ` kernel test robot
@ 2024-09-29 2:10 ` kernel test robot
2024-09-29 2:20 ` kernel test robot
2 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2024-09-29 2:10 UTC (permalink / raw)
To: Dragan Simic, linux-spi, linux-rockchip
Cc: llvm, oe-kbuild-all, broonie, heiko, gregkh, rafael, oss,
linux-arm-kernel, linux-kernel
Hi Dragan,
kernel test robot noticed the following build errors:
[auto build test ERROR on rockchip/for-next]
[also build test ERROR on broonie-spi/for-next driver-core/driver-core-testing driver-core/driver-core-next driver-core/driver-core-linus linus/master v6.11 next-20240927]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Dragan-Simic/spi-rockchip-Perform-trivial-code-cleanups/20240928-121548
base: https://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip.git for-next
patch link: https://lore.kernel.org/r/2fd9a60e0efe906dc7a203cd652c8d0b7f932470.1727496560.git.dsimic%40manjaro.org
patch subject: [PATCH v2 4/5] driver core: Add device probe log helper dev_warn_probe()
config: s390-allnoconfig (https://download.01.org/0day-ci/archive/20240929/202409290914.ODQyF8lR-lkp@intel.com/config)
compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 7773243d9916f98ba0ffce0c3a960e4aa9f03e81)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240929/202409290914.ODQyF8lR-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202409290914.ODQyF8lR-lkp@intel.com/
All error/warnings (new ones prefixed by >>):
In file included from drivers/base/core.c:11:
In file included from include/linux/acpi.h:14:
In file included from include/linux/device.h:32:
In file included from include/linux/device/driver.h:21:
In file included from include/linux/module.h:19:
In file included from include/linux/elf.h:6:
In file included from arch/s390/include/asm/elf.h:181:
In file included from arch/s390/include/asm/mmu_context.h:11:
In file included from arch/s390/include/asm/pgalloc.h:18:
In file included from include/linux/mm.h:2228:
include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
514 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
In file included from drivers/base/core.c:27:
In file included from include/linux/netdevice.h:38:
In file included from include/net/net_namespace.h:43:
In file included from include/linux/skbuff.h:28:
In file included from include/linux/dma-mapping.h:11:
In file included from include/linux/scatterlist.h:9:
In file included from arch/s390/include/asm/io.h:93:
include/asm-generic/io.h:548:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
548 | val = __raw_readb(PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:561:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
561 | val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:37:59: note: expanded from macro '__le16_to_cpu'
37 | #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
| ^
include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16'
102 | #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
| ^
In file included from drivers/base/core.c:27:
In file included from include/linux/netdevice.h:38:
In file included from include/net/net_namespace.h:43:
In file included from include/linux/skbuff.h:28:
In file included from include/linux/dma-mapping.h:11:
In file included from include/linux/scatterlist.h:9:
In file included from arch/s390/include/asm/io.h:93:
include/asm-generic/io.h:574:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
574 | val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:35:59: note: expanded from macro '__le32_to_cpu'
35 | #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
| ^
include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
115 | #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
| ^
In file included from drivers/base/core.c:27:
In file included from include/linux/netdevice.h:38:
In file included from include/net/net_namespace.h:43:
In file included from include/linux/skbuff.h:28:
In file included from include/linux/dma-mapping.h:11:
In file included from include/linux/scatterlist.h:9:
In file included from arch/s390/include/asm/io.h:93:
include/asm-generic/io.h:585:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
585 | __raw_writeb(value, PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:595:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
595 | __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:605:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
605 | __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:693:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
693 | readsb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:701:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
701 | readsw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:709:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
709 | readsl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:718:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
718 | writesb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:727:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
727 | writesw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:736:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
736 | writesl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
>> drivers/base/core.c:4988:9: error: incompatible pointer types assigning to 'va_list *' (aka '__builtin_va_list *') from 'struct __va_list_tag **' [-Werror,-Wincompatible-pointer-types]
4988 | vaf.va = &args;
| ^ ~~~~~
>> drivers/base/core.c:5055:1: warning: non-void function does not return a value [-Wreturn-type]
5055 | }
| ^
drivers/base/core.c:5101:1: warning: non-void function does not return a value [-Wreturn-type]
5101 | }
| ^
15 warnings and 1 error generated.
vim +4988 drivers/base/core.c
4981
4982 static int dev_probe_failed(const struct device *dev, int err, bool fatal,
4983 const char *fmt, va_list args)
4984 {
4985 struct va_format vaf;
4986
4987 vaf.fmt = fmt;
> 4988 vaf.va = &args;
4989
4990 switch (err) {
4991 case -EPROBE_DEFER:
4992 device_set_deferred_probe_reason(dev, &vaf);
4993 dev_dbg(dev, "error %pe: %pV", ERR_PTR(err), &vaf);
4994 break;
4995
4996 case -ENOMEM:
4997 /* Don't print anything on -ENOMEM, there's already enough output */
4998 break;
4999
5000 default:
5001 /* Log fatal final failures as errors, otherwise produce warnings */
5002 if (fatal)
5003 dev_err(dev, "error %pe: %pV", ERR_PTR(err), &vaf);
5004 else
5005 dev_warn(dev, "error %pe: %pV", ERR_PTR(err), &vaf);
5006 break;
5007 }
5008
5009 return err;
5010 }
5011
5012 /**
5013 * dev_err_probe - probe error check and log helper
5014 * @dev: the pointer to the struct device
5015 * @err: error value to test
5016 * @fmt: printf-style format string
5017 * @...: arguments as specified in the format string
5018 *
5019 * This helper implements common pattern present in probe functions for error
5020 * checking: print debug or error message depending if the error value is
5021 * -EPROBE_DEFER and propagate error upwards.
5022 * In case of -EPROBE_DEFER it sets also defer probe reason, which can be
5023 * checked later by reading devices_deferred debugfs attribute.
5024 * It replaces the following code sequence::
5025 *
5026 * if (err != -EPROBE_DEFER)
5027 * dev_err(dev, ...);
5028 * else
5029 * dev_dbg(dev, ...);
5030 * return err;
5031 *
5032 * with::
5033 *
5034 * return dev_err_probe(dev, err, ...);
5035 *
5036 * Using this helper in your probe function is totally fine even if @err
5037 * is known to never be -EPROBE_DEFER.
5038 * The benefit compared to a normal dev_err() is the standardized format
5039 * of the error code, which is emitted symbolically (i.e. you get "EAGAIN"
5040 * instead of "-35"), and having the error code returned allows more
5041 * compact error paths.
5042 *
5043 * Returns @err.
5044 */
5045 int dev_err_probe(const struct device *dev, int err, const char *fmt, ...)
5046 {
5047 va_list args;
5048
5049 va_start(args, fmt);
5050
5051 /* Use dev_err() for logging when err doesn't equal -EPROBE_DEFER */
5052 dev_probe_failed(dev, err, true, fmt, args);
5053
5054 va_end(args);
> 5055 }
5056 EXPORT_SYMBOL_GPL(dev_err_probe);
5057
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 4/5] driver core: Add device probe log helper dev_warn_probe()
2024-09-28 4:12 ` [PATCH v2 4/5] driver core: Add device probe log helper dev_warn_probe() Dragan Simic
2024-09-29 1:39 ` kernel test robot
2024-09-29 2:10 ` kernel test robot
@ 2024-09-29 2:20 ` kernel test robot
2 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2024-09-29 2:20 UTC (permalink / raw)
To: Dragan Simic, linux-spi, linux-rockchip
Cc: oe-kbuild-all, broonie, heiko, gregkh, rafael, oss,
linux-arm-kernel, linux-kernel
Hi Dragan,
kernel test robot noticed the following build errors:
[auto build test ERROR on rockchip/for-next]
[also build test ERROR on broonie-spi/for-next driver-core/driver-core-testing driver-core/driver-core-next driver-core/driver-core-linus linus/master v6.11 next-20240927]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Dragan-Simic/spi-rockchip-Perform-trivial-code-cleanups/20240928-121548
base: https://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip.git for-next
patch link: https://lore.kernel.org/r/2fd9a60e0efe906dc7a203cd652c8d0b7f932470.1727496560.git.dsimic%40manjaro.org
patch subject: [PATCH v2 4/5] driver core: Add device probe log helper dev_warn_probe()
config: powerpc-allnoconfig (https://download.01.org/0day-ci/archive/20240929/202409290910.55WdSCMH-lkp@intel.com/config)
compiler: powerpc-linux-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240929/202409290910.55WdSCMH-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202409290910.55WdSCMH-lkp@intel.com/
All errors (new ones prefixed by >>):
drivers/base/core.c: In function 'dev_probe_failed':
>> drivers/base/core.c:4988:16: error: assignment to '__va_list_tag (*)[1]' from incompatible pointer type '__va_list_tag **' [-Wincompatible-pointer-types]
4988 | vaf.va = &args;
| ^
drivers/base/core.c: In function 'dev_err_probe':
drivers/base/core.c:5055:1: warning: control reaches end of non-void function [-Wreturn-type]
5055 | }
| ^
drivers/base/core.c: In function 'dev_warn_probe':
drivers/base/core.c:5101:1: warning: control reaches end of non-void function [-Wreturn-type]
5101 | }
| ^
vim +4988 drivers/base/core.c
4981
4982 static int dev_probe_failed(const struct device *dev, int err, bool fatal,
4983 const char *fmt, va_list args)
4984 {
4985 struct va_format vaf;
4986
4987 vaf.fmt = fmt;
> 4988 vaf.va = &args;
4989
4990 switch (err) {
4991 case -EPROBE_DEFER:
4992 device_set_deferred_probe_reason(dev, &vaf);
4993 dev_dbg(dev, "error %pe: %pV", ERR_PTR(err), &vaf);
4994 break;
4995
4996 case -ENOMEM:
4997 /* Don't print anything on -ENOMEM, there's already enough output */
4998 break;
4999
5000 default:
5001 /* Log fatal final failures as errors, otherwise produce warnings */
5002 if (fatal)
5003 dev_err(dev, "error %pe: %pV", ERR_PTR(err), &vaf);
5004 else
5005 dev_warn(dev, "error %pe: %pV", ERR_PTR(err), &vaf);
5006 break;
5007 }
5008
5009 return err;
5010 }
5011
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-09-29 2:21 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-28 4:12 [PATCH v2 0/5] Add dev_warn_probe() and improve error handling in Rockchip SPI drivers Dragan Simic
2024-09-28 4:12 ` [PATCH v2 1/5] spi: rockchip: Perform trivial code cleanups Dragan Simic
2024-09-28 4:12 ` [PATCH v2 2/5] spi: rockchip-sfc: " Dragan Simic
2024-09-28 4:12 ` [PATCH v2 3/5] spi: rockchip-sfc: Use dev_err_probe() in the probe path Dragan Simic
2024-09-28 4:12 ` [PATCH v2 4/5] driver core: Add device probe log helper dev_warn_probe() Dragan Simic
2024-09-29 1:39 ` kernel test robot
2024-09-29 2:10 ` kernel test robot
2024-09-29 2:20 ` kernel test robot
2024-09-28 4:12 ` [PATCH v2 5/5] spi: rockchip: Use dev_{err,warn}_probe() in the probe path Dragan Simic
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).