mbox series

[0/3] driver core: add probe error check helper

Message ID 20181016072244.1216-1-a.hajda@samsung.com (mailing list archive)
Headers show
Series driver core: add probe error check helper | expand

Message

Andrzej Hajda Oct. 16, 2018, 7:22 a.m. UTC
Hi Greg, Rafael,

This patchset proposes probe helper function which should simplify little bit
resource acquisition error handling, it also extend it with adding defer probe
reason to devices_deferred property:

# cat /sys/kernel/debug/devices_deferred
exynos-hdmi 13970000.hdmi: cannot find out bridge
arizona-extcon
tm2-audio sound: Unable to get codec_dai_name

The last patch was generated by cocci script to show the gain for the most
obvious probe_err usage scenarios. Of course there are many more places where it
could be used.
If the 1st patch will be accepted I can split 3rd one per subsystems if neccessary.

Regards
Andrzej


Andrzej Hajda (3):
  driver core: add probe_err log helper
  driver core: add deferring probe reason to devices_deferred property
  drivers: use probe_err function in obvious cases

 drivers/ata/libahci_platform.c                |  7 +-
 drivers/base/base.h                           |  3 +
 drivers/base/core.c                           | 40 +++++++++++
 drivers/base/dd.c                             | 34 +++++++++-
 drivers/base/power/domain.c                   | 10 ++-
 drivers/bus/fsl-mc/fsl-mc-bus.c               |  8 +--
 drivers/bus/ts-nbus.c                         |  8 +--
 drivers/clk/qcom/clk-spmi-pmic-div.c          |  9 +--
 drivers/clk/sunxi-ng/ccu-sun8i-de2.c          | 16 ++---
 drivers/clk/sunxi-ng/ccu-sun9i-a80-de.c       | 11 ++--
 drivers/clk/sunxi-ng/ccu-sun9i-a80-usb.c      |  5 +-
 drivers/cpufreq/qcom-cpufreq-kryo.c           | 10 ++-
 drivers/crypto/caam/caamalg_qi2.c             |  3 +-
 drivers/firmware/arm_scmi/driver.c            |  9 +--
 drivers/firmware/imx/imx-scu.c                |  7 +-
 drivers/gpio/gpio-pca953x.c                   |  4 +-
 drivers/gpio/gpio-pisosr.c                    |  9 +--
 .../gpu/drm/omapdrm/displays/encoder-opa362.c |  8 +--
 .../gpu/drm/omapdrm/displays/encoder-tfp410.c |  8 +--
 .../drm/omapdrm/displays/encoder-tpd12s015.c  |  8 +--
 drivers/gpu/drm/omapdrm/dss/dpi.c             |  8 +--
 drivers/gpu/drm/omapdrm/dss/dsi.c             |  8 +--
 drivers/gpu/drm/omapdrm/dss/hdmi4.c           |  8 +--
 drivers/gpu/drm/omapdrm/dss/hdmi5.c           |  8 +--
 drivers/gpu/drm/omapdrm/dss/sdi.c             |  8 +--
 drivers/gpu/drm/omapdrm/dss/venc.c            |  8 +--
 drivers/gpu/drm/panel/panel-lvds.c            | 10 ++-
 drivers/gpu/drm/panel/panel-simple.c          |  5 +-
 drivers/gpu/drm/rcar-du/rcar_du_drv.c         |  5 +-
 drivers/gpu/drm/vc4/vc4_dsi.c                 | 23 +++----
 drivers/hid/i2c-hid/i2c-hid-core.c            |  9 +--
 drivers/hwmon/pwm-fan.c                       |  7 +-
 drivers/i2c/busses/i2c-bcm2835.c              |  8 +--
 drivers/i2c/busses/i2c-rk3x.c                 | 10 ++-
 drivers/i2c/muxes/i2c-arb-gpio-challenge.c    | 30 +++------
 drivers/i2c/muxes/i2c-mux-gpmux.c             | 16 ++---
 drivers/iio/adc/envelope-detector.c           | 23 +++----
 drivers/iio/adc/rcar-gyroadc.c                |  5 +-
 drivers/iio/afe/iio-rescale.c                 |  8 +--
 drivers/iio/dac/dpot-dac.c                    | 16 ++---
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c    | 11 ++--
 drivers/iio/multiplexer/iio-mux.c             | 16 ++---
 drivers/input/keyboard/bcm-keypad.c           |  8 +--
 drivers/input/misc/pwm-beeper.c               | 12 ++--
 drivers/input/misc/pwm-vibra.c                | 18 ++---
 drivers/input/mouse/elan_i2c_core.c           |  6 +-
 drivers/input/touchscreen/bu21029_ts.c        | 14 ++--
 drivers/input/touchscreen/chipone_icn8318.c   |  5 +-
 drivers/input/touchscreen/ektf2127.c          |  5 +-
 drivers/input/touchscreen/elants_i2c.c        | 16 ++---
 drivers/input/touchscreen/pixcir_i2c_ts.c     | 10 ++-
 drivers/input/touchscreen/raydium_i2c_ts.c    | 20 +++---
 .../input/touchscreen/resistive-adc-touch.c   |  9 +--
 drivers/input/touchscreen/silead.c            | 15 ++---
 drivers/input/touchscreen/sis_i2c.c           | 12 ++--
 drivers/input/touchscreen/surface3_spi.c      |  9 +--
 drivers/leds/leds-pwm.c                       |  7 +-
 drivers/media/i2c/ad5820.c                    |  9 +--
 drivers/media/i2c/tc358743.c                  | 10 ++-
 drivers/media/platform/omap3isp/isp.c         |  3 +-
 drivers/media/platform/video-mux.c            |  4 +-
 drivers/media/rc/gpio-ir-recv.c               |  5 +-
 drivers/media/rc/gpio-ir-tx.c                 | 10 ++-
 drivers/mfd/madera-core.c                     |  6 +-
 drivers/mmc/host/bcm2835.c                    |  3 +-
 drivers/mmc/host/davinci_mmc.c                |  5 +-
 drivers/mmc/host/dw_mmc-zx.c                  |  6 +-
 drivers/mmc/host/jz4740_mmc.c                 |  5 +-
 drivers/mmc/host/meson-gx-mmc.c               | 17 ++---
 drivers/mmc/host/sdhci-of-arasan.c            |  8 +--
 drivers/mtd/nand/onenand/omap2.c              |  5 +-
 drivers/mtd/nand/raw/atmel/nand-controller.c  | 20 +++---
 drivers/mux/gpio.c                            |  9 +--
 drivers/net/dsa/lantiq_gswip.c                |  8 +--
 drivers/net/ethernet/renesas/sh_eth.c         |  3 +-
 .../stmicro/stmmac/dwmac-dwc-qos-eth.c        | 10 +--
 .../ethernet/stmicro/stmmac/dwmac-meson8b.c   |  9 +--
 .../ethernet/stmicro/stmmac/stmmac_platform.c | 10 +--
 drivers/net/ethernet/ti/cpsw.c                |  9 ++-
 drivers/net/ieee802154/mcr20a.c               |  5 +-
 drivers/net/phy/mdio-mux-mmioreg.c            |  9 +--
 drivers/opp/core.c                            | 12 ++--
 drivers/pci/controller/pcie-rockchip.c        | 66 +++++++------------
 drivers/phy/amlogic/phy-meson-gxl-usb2.c      |  9 +--
 drivers/phy/amlogic/phy-meson-gxl-usb3.c      |  9 +--
 drivers/phy/lantiq/phy-lantiq-rcu-usb2.c      |  8 +--
 drivers/phy/qualcomm/phy-qcom-qmp.c           | 21 +++---
 drivers/phy/qualcomm/phy-qcom-qusb2.c         | 19 ++----
 drivers/phy/rockchip/phy-rockchip-inno-usb2.c |  8 +--
 drivers/phy/rockchip/phy-rockchip-pcie.c      |  9 +--
 drivers/phy/st/phy-stm32-usbphyc.c            | 10 ++-
 drivers/platform/x86/intel_cht_int33fe.c      |  8 +--
 drivers/power/supply/lego_ev3_battery.c       | 24 +++----
 drivers/pwm/pwm-rockchip.c                    | 11 ++--
 drivers/regulator/gpio-regulator.c            |  7 +-
 drivers/remoteproc/da8xx_remoteproc.c         | 11 ++--
 drivers/remoteproc/qcom_q6v5.c                | 55 ++++++----------
 drivers/remoteproc/qcom_q6v5_adsp.c           |  9 +--
 drivers/remoteproc/qcom_q6v5_mss.c            | 11 ++--
 drivers/remoteproc/qcom_q6v5_pas.c            | 19 ++----
 drivers/remoteproc/qcom_wcnss_iris.c          |  8 +--
 drivers/reset/reset-meson-audio-arb.c         |  8 +--
 drivers/rtc/rtc-rk808.c                       | 10 ++-
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c        |  7 +-
 drivers/soc/amlogic/meson-gx-pwrc-vpu.c       |  8 +--
 drivers/soc/imx/gpcv2.c                       |  9 ++-
 drivers/soc/lantiq/gphy.c                     |  8 +--
 drivers/soc/qcom/rpmh-rsc.c                   |  9 +--
 drivers/soc/qcom/smem.c                       |  8 +--
 drivers/soc/qcom/smp2p.c                      |  9 +--
 drivers/spi/spi-tegra114.c                    |  6 +-
 drivers/spi/spi-tegra20-slink.c               |  6 +-
 .../clocking-wizard/clk-xlnx-clock-wizard.c   | 16 ++---
 drivers/thermal/broadcom/bcm2835_thermal.c    |  5 +-
 drivers/thermal/hisi_thermal.c                |  5 +-
 drivers/tty/serial/8250/8250_dw.c             |  7 +-
 drivers/tty/serial/8250/8250_ingenic.c        | 12 ++--
 drivers/tty/serial/amba-pl011.c               |  7 +-
 drivers/usb/chipidea/ci_hdrc_imx.c            |  5 +-
 drivers/usb/chipidea/ci_hdrc_msm.c            |  3 +-
 drivers/usb/chipidea/ci_hdrc_usb2.c           |  7 +-
 drivers/usb/dwc3/core.c                       | 24 +++----
 drivers/usb/host/ehci-mv.c                    |  3 +-
 drivers/usb/host/ehci-omap.c                  |  5 +-
 drivers/usb/host/ohci-da8xx.c                 |  6 +-
 drivers/usb/musb/da8xx.c                      |  8 +--
 drivers/usb/musb/musb_cppi41.c                |  5 +-
 drivers/usb/typec/tcpm/fusb302.c              |  3 +-
 drivers/video/backlight/gpio_backlight.c      | 12 +---
 drivers/video/backlight/pwm_bl.c              |  3 +-
 drivers/watchdog/davinci_wdt.c                |  8 +--
 include/linux/device.h                        |  2 +
 sound/soc/atmel/tse850-pcm5142.c              | 32 ++++-----
 sound/soc/codecs/es7241.c                     | 13 ++--
 sound/soc/codecs/max9759.c                    | 15 ++---
 sound/soc/codecs/max9860.c                    |  8 +--
 sound/soc/codecs/pcm3168a.c                   |  8 +--
 sound/soc/codecs/sgtl5000.c                   |  5 +-
 sound/soc/codecs/simple-amplifier.c           |  5 +-
 sound/soc/codecs/ssm2305.c                    |  6 +-
 sound/soc/davinci/davinci-mcasp.c             | 11 ++--
 sound/soc/generic/audio-graph-card.c          |  3 +-
 sound/soc/generic/audio-graph-scu-card.c      |  3 +-
 sound/soc/generic/simple-card.c               |  3 +-
 sound/soc/generic/simple-scu-card.c           |  3 +-
 sound/soc/img/img-i2s-in.c                    |  8 +--
 sound/soc/img/img-i2s-out.c                   | 24 +++----
 sound/soc/img/img-parallel-out.c              | 24 +++----
 sound/soc/img/img-spdif-in.c                  |  8 +--
 sound/soc/img/img-spdif-out.c                 | 24 +++----
 sound/soc/img/pistachio-internal-dac.c        |  6 +-
 sound/soc/meson/axg-card.c                    |  7 +-
 sound/soc/meson/axg-fifo.c                    | 20 +++---
 sound/soc/meson/axg-pdm.c                     | 12 +---
 sound/soc/meson/axg-spdifout.c                |  8 +--
 sound/soc/meson/axg-tdm-formatter.c           | 22 ++-----
 sound/soc/meson/axg-tdm-interface.c           |  8 +--
 sound/soc/mxs/mxs-sgtl5000.c                  |  9 +--
 sound/soc/sunxi/sun4i-codec.c                 |  5 +-
 159 files changed, 658 insertions(+), 1031 deletions(-)

Comments

Javier Martinez Canillas Oct. 16, 2018, 9:52 a.m. UTC | #1
Hello Andrzej,

On 10/16/2018 09:22 AM, Andrzej Hajda wrote:
> The patch replaces obviously matching code with probe_err function.
> There are many more places where probe_err could be used.
> The patch shows how the new function should be used, and how it
> improves the code.
> 
> It was generated by cocci script (little bit dirty):
>

This is great! I guess the easier would be to split these by kernel releases,
maybe patch #1 and #2 can land in one kernel release and then each subsystem
can merge the changes for their drivers with the dependency already in place.

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

Best regards,
Andy Shevchenko Oct. 16, 2018, 1:51 p.m. UTC | #2
On Tue, Oct 16, 2018 at 10:22 AM Andrzej Hajda <a.hajda@samsung.com> wrote:
>
> The patch replaces obviously matching code with probe_err function.
> There are many more places where probe_err could be used.
> The patch shows how the new function should be used, and how it
> improves the code.

> --- a/drivers/gpio/gpio-pca953x.c
> +++ b/drivers/gpio/gpio-pca953x.c
> @@ -824,9 +824,7 @@ static int pca953x_probe(struct i2c_client *client,
>         reg = devm_regulator_get(&client->dev, "vcc");
>         if (IS_ERR(reg)) {
>                 ret = PTR_ERR(reg);
> -               if (ret != -EPROBE_DEFER)
> -                       dev_err(&client->dev, "reg get err: %d\n", ret);
> -               return ret;
> +               return probe_err(&client->dev, ret, "reg get err: %d\n", ret);

No need to assign ret above.
As I mentioned, better to print a value for everyone.

>         }

Please, split it at least one patch per subsystem.
Andrzej Hajda Oct. 17, 2018, 9:10 a.m. UTC | #3
On 16.10.2018 15:51, Andy Shevchenko wrote:
> On Tue, Oct 16, 2018 at 10:22 AM Andrzej Hajda <a.hajda@samsung.com> wrote:
>> The patch replaces obviously matching code with probe_err function.
>> There are many more places where probe_err could be used.
>> The patch shows how the new function should be used, and how it
>> improves the code.
>> --- a/drivers/gpio/gpio-pca953x.c
>> +++ b/drivers/gpio/gpio-pca953x.c
>> @@ -824,9 +824,7 @@ static int pca953x_probe(struct i2c_client *client,
>>         reg = devm_regulator_get(&client->dev, "vcc");
>>         if (IS_ERR(reg)) {
>>                 ret = PTR_ERR(reg);
>> -               if (ret != -EPROBE_DEFER)
>> -                       dev_err(&client->dev, "reg get err: %d\n", ret);
>> -               return ret;
>> +               return probe_err(&client->dev, ret, "reg get err: %d\n", ret);
> No need to assign ret above.
> As I mentioned, better to print a value for everyone.

OK.

Thanks for all reviews. I have posted v2 of patches 1 and 2 as replies
in this thread.
As patch 3 requires splitting, adjusting arguments of probe_err (remove
err and newline), and depends on patch 1 I will prepare it and post
later, probably next cycle as suggested Javier.

Regards
Andrzej


>
>>         }
> Please, split it at least one patch per subsystem.
>