Message ID | 20190829042905.4850-1-uwe@kleine-koenig.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [RFC] i2c: imx: make use of format specifier %dE | expand |
On Thu, Aug 29, 2019 at 06:29:05AM +0200, Uwe Kleine-König wrote: > I created a patch that teaches printk et al to emit a symbolic error > name for an error valued integer[1]. With that applied > > dev_err(&pdev->dev, "can't enable I2C clock, ret=%dE\n", ret); > > emits > > ... can't enable I2C clock, ret=EIO > > if ret is -EIO. Petr Mladek (i.e. one of the printk maintainers) had > concerns if this would be well received and worth the effort. He asked > to present it to a few subsystems. So for now, this patch converting the > i2c-imx driver shouldn't be applied yet but it would be great to get > some feedback about if you think that being able to easily printk (for > example) "EIO" instead of "-5" is a good idea. Would it help you? Do you > think it helps your users? Yes, it would help me. And users, too, I am quite sure. For me, if I mix up two numbers while debugging, I am hunting ghosts for a while until I realize my mistake. So: Acked-by: Wolfram Sang <wsa@the-dreams.de> I think the main drawback is that ERRORCODES in vsprintf.c now need maintenance, but I think it is worth the effort. I'd be interested in the overhead in size this causes, but I also think it is worth the effort. (It could even be compiled out if we have some generic Kconfig symbol for smaller kernels). Thanks, Wolfram
On 29.08.19 22:39, Wolfram Sang wrote: > On Thu, Aug 29, 2019 at 06:29:05AM +0200, Uwe Kleine-König wrote: >> I created a patch that teaches printk et al to emit a symbolic error >> name for an error valued integer[1]. With that applied >> >> dev_err(&pdev->dev, "can't enable I2C clock, ret=%dE\n", ret); >> >> emits >> >> ... can't enable I2C clock, ret=EIO >> >> if ret is -EIO. Petr Mladek (i.e. one of the printk maintainers) had >> concerns if this would be well received and worth the effort. He asked >> to present it to a few subsystems. So for now, this patch converting the >> i2c-imx driver shouldn't be applied yet but it would be great to get >> some feedback about if you think that being able to easily printk (for >> example) "EIO" instead of "-5" is a good idea. Would it help you? Do you >> think it helps your users? > > Yes, it would help me. And users, too, I am quite sure. For me, if I mix > up two numbers while debugging, I am hunting ghosts for a while until I > realize my mistake. So: > > Acked-by: Wolfram Sang <wsa@the-dreams.de> > > I think the main drawback is that ERRORCODES in vsprintf.c now need > maintenance, but I think it is worth the effort. I'd be interested in > the overhead in size this causes, but I also think it is worth the > effort. (It could even be compiled out if we have some generic Kconfig > symbol for smaller kernels). I like it, at least it will safe me some time. I tested this patch together with the vprintf patch, so result looks like: [ 0.281843] imx-i2c 21a0000.i2c: can't enable I2C clock, ret=EIO [ 0.281891] imx-i2c: probe of 21a0000.i2c failed with error -5 Tested-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Kind regards, Oleksij Rempel
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index 15f6cde6452f..359e911cb891 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -289,7 +289,7 @@ static void i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx, if (IS_ERR(dma->chan_tx)) { ret = PTR_ERR(dma->chan_tx); if (ret != -ENODEV && ret != -EPROBE_DEFER) - dev_err(dev, "can't request DMA tx channel (%d)\n", ret); + dev_err(dev, "can't request DMA tx channel (%dE)\n", ret); goto fail_al; } @@ -300,7 +300,7 @@ static void i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx, dma_sconfig.direction = DMA_MEM_TO_DEV; ret = dmaengine_slave_config(dma->chan_tx, &dma_sconfig); if (ret < 0) { - dev_err(dev, "can't configure tx channel (%d)\n", ret); + dev_err(dev, "can't configure tx channel (%dE)\n", ret); goto fail_tx; } @@ -308,7 +308,7 @@ static void i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx, if (IS_ERR(dma->chan_rx)) { ret = PTR_ERR(dma->chan_rx); if (ret != -ENODEV && ret != -EPROBE_DEFER) - dev_err(dev, "can't request DMA rx channel (%d)\n", ret); + dev_err(dev, "can't request DMA rx channel (%dE)\n", ret); goto fail_tx; } @@ -319,7 +319,7 @@ static void i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx, dma_sconfig.direction = DMA_DEV_TO_MEM; ret = dmaengine_slave_config(dma->chan_rx, &dma_sconfig); if (ret < 0) { - dev_err(dev, "can't configure rx channel (%d)\n", ret); + dev_err(dev, "can't configure rx channel (%dE)\n", ret); goto fail_rx; } @@ -964,7 +964,7 @@ static int i2c_imx_xfer(struct i2c_adapter *adapter, pm_runtime_put_autosuspend(i2c_imx->adapter.dev.parent); out: - dev_dbg(&i2c_imx->adapter.dev, "<%s> exit with: %s: %d\n", __func__, + dev_dbg(&i2c_imx->adapter.dev, "<%s> exit with: %s: %dE\n", __func__, (result < 0) ? "error" : "success msg", (result < 0) ? result : num); return (result < 0) ? result : num; @@ -1100,7 +1100,7 @@ static int i2c_imx_probe(struct platform_device *pdev) ret = clk_prepare_enable(i2c_imx->clk); if (ret) { - dev_err(&pdev->dev, "can't enable I2C clock, ret=%d\n", ret); + dev_err(&pdev->dev, "can't enable I2C clock, ret=%dE\n", ret); return ret; } @@ -1108,7 +1108,7 @@ static int i2c_imx_probe(struct platform_device *pdev) ret = devm_request_irq(&pdev->dev, irq, i2c_imx_isr, IRQF_SHARED, pdev->name, i2c_imx); if (ret) { - dev_err(&pdev->dev, "can't claim irq %d\n", irq); + dev_err(&pdev->dev, "can't claim irq %dE\n", irq); goto clk_disable; } @@ -1230,7 +1230,7 @@ static int __maybe_unused i2c_imx_runtime_resume(struct device *dev) ret = clk_enable(i2c_imx->clk); if (ret) - dev_err(dev, "can't enable I2C clock, ret=%d\n", ret); + dev_err(dev, "can't enable I2C clock, ret=%dE\n", ret); return ret; }