media: Switch to use dev_err_probe() helper

In the probe path, dev_err() can be replaced with dev_err_probe()
which will check if error code is -EPROBE_DEFER.

Reviewed-by: Sean Young <sean@mess.org>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
This commit is contained in:
Yang Yingliang 2022-09-19 23:58:43 +08:00 committed by Hans Verkuil
parent 96c1212a61
commit 6cb7d1b3ff
13 changed files with 41 additions and 84 deletions

View file

@ -288,12 +288,9 @@ static int stm32_cec_probe(struct platform_device *pdev)
return ret;
cec->clk_cec = devm_clk_get(&pdev->dev, "cec");
if (IS_ERR(cec->clk_cec)) {
if (PTR_ERR(cec->clk_cec) != -EPROBE_DEFER)
dev_err(&pdev->dev, "Cannot get cec clock\n");
return PTR_ERR(cec->clk_cec);
}
if (IS_ERR(cec->clk_cec))
return dev_err_probe(&pdev->dev, PTR_ERR(cec->clk_cec),
"Cannot get cec clock\n");
ret = clk_prepare(cec->clk_cec);
if (ret) {

View file

@ -300,21 +300,15 @@ static int ad5820_probe(struct i2c_client *client)
return -ENOMEM;
coil->vana = devm_regulator_get(&client->dev, "VANA");
if (IS_ERR(coil->vana)) {
ret = PTR_ERR(coil->vana);
if (ret != -EPROBE_DEFER)
dev_err(&client->dev, "could not get regulator for vana\n");
return ret;
}
if (IS_ERR(coil->vana))
return dev_err_probe(&client->dev, PTR_ERR(coil->vana),
"could not get regulator for vana\n");
coil->enable_gpio = devm_gpiod_get_optional(&client->dev, "enable",
GPIOD_OUT_LOW);
if (IS_ERR(coil->enable_gpio)) {
ret = PTR_ERR(coil->enable_gpio);
if (ret != -EPROBE_DEFER)
dev_err(&client->dev, "could not get enable gpio\n");
return ret;
}
if (IS_ERR(coil->enable_gpio))
return dev_err_probe(&client->dev, PTR_ERR(coil->enable_gpio),
"could not get enable gpio\n");
mutex_init(&coil->power_lock);

View file

@ -2060,9 +2060,8 @@ static int imx274_probe(struct i2c_client *client)
imx274->reset_gpio = devm_gpiod_get_optional(dev, "reset",
GPIOD_OUT_HIGH);
if (IS_ERR(imx274->reset_gpio)) {
if (PTR_ERR(imx274->reset_gpio) != -EPROBE_DEFER)
dev_err(dev, "Reset GPIO not setup in DT");
ret = PTR_ERR(imx274->reset_gpio);
ret = dev_err_probe(dev, PTR_ERR(imx274->reset_gpio),
"Reset GPIO not setup in DT\n");
goto err_me;
}

View file

@ -1891,12 +1891,9 @@ static int tc358743_probe_of(struct tc358743_state *state)
int ret;
refclk = devm_clk_get(dev, "refclk");
if (IS_ERR(refclk)) {
if (PTR_ERR(refclk) != -EPROBE_DEFER)
dev_err(dev, "failed to get refclk: %ld\n",
PTR_ERR(refclk));
return PTR_ERR(refclk);
}
if (IS_ERR(refclk))
return dev_err_probe(dev, PTR_ERR(refclk),
"failed to get refclk\n");
ep = of_graph_get_next_endpoint(dev->of_node, NULL);
if (!ep) {

View file

@ -52,9 +52,8 @@ int mtk_mdp_comp_init(struct device *dev, struct device_node *node,
for (i = 0; i < ARRAY_SIZE(comp->clk); i++) {
comp->clk[i] = of_clk_get(node, i);
if (IS_ERR(comp->clk[i])) {
if (PTR_ERR(comp->clk[i]) != -EPROBE_DEFER)
dev_err(dev, "Failed to get clock\n");
ret = PTR_ERR(comp->clk[i]);
ret = dev_err_probe(dev, PTR_ERR(comp->clk[i]),
"Failed to get clock\n");
goto put_dev;
}

View file

@ -1471,9 +1471,7 @@ static int fimc_md_probe(struct platform_device *pdev)
pinctrl = devm_pinctrl_get(dev);
if (IS_ERR(pinctrl)) {
ret = PTR_ERR(pinctrl);
if (ret != -EPROBE_DEFER)
dev_err(dev, "Failed to get pinctrl: %d\n", ret);
ret = dev_err_probe(dev, PTR_ERR(pinctrl), "Failed to get pinctrl\n");
goto err_clk;
}

View file

@ -1946,12 +1946,9 @@ static int dcmi_probe(struct platform_device *pdev)
return -ENOMEM;
dcmi->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL);
if (IS_ERR(dcmi->rstc)) {
if (PTR_ERR(dcmi->rstc) != -EPROBE_DEFER)
dev_err(&pdev->dev, "Could not get reset control\n");
return PTR_ERR(dcmi->rstc);
}
if (IS_ERR(dcmi->rstc))
return dev_err_probe(&pdev->dev, PTR_ERR(dcmi->rstc),
"Could not get reset control\n");
/* Get bus characteristics from devicetree */
np = of_graph_get_next_endpoint(np, NULL);
@ -2001,20 +1998,14 @@ static int dcmi_probe(struct platform_device *pdev)
return PTR_ERR(dcmi->regs);
mclk = devm_clk_get(&pdev->dev, "mclk");
if (IS_ERR(mclk)) {
if (PTR_ERR(mclk) != -EPROBE_DEFER)
dev_err(&pdev->dev, "Unable to get mclk\n");
return PTR_ERR(mclk);
}
if (IS_ERR(mclk))
return dev_err_probe(&pdev->dev, PTR_ERR(mclk),
"Unable to get mclk\n");
chan = dma_request_chan(&pdev->dev, "tx");
if (IS_ERR(chan)) {
ret = PTR_ERR(chan);
if (ret != -EPROBE_DEFER)
dev_err(&pdev->dev,
"Failed to request DMA channel: %d\n", ret);
return ret;
}
if (IS_ERR(chan))
return dev_err_probe(&pdev->dev, PTR_ERR(chan),
"Failed to request DMA channel\n");
dcmi->dma_max_burst = UINT_MAX;
ret = dma_get_slave_caps(chan, &caps);

View file

@ -1884,8 +1884,7 @@ static int isp_initialize_modules(struct isp_device *isp)
ret = omap3isp_ccp2_init(isp);
if (ret < 0) {
if (ret != -EPROBE_DEFER)
dev_err(isp->dev, "CCP2 initialization failed\n");
dev_err_probe(isp->dev, ret, "CCP2 initialization failed\n");
goto error_ccp2;
}

View file

@ -976,11 +976,9 @@ static int xcsi2rxss_probe(struct platform_device *pdev)
/* Reset GPIO */
xcsi2rxss->rst_gpio = devm_gpiod_get_optional(dev, "video-reset",
GPIOD_OUT_HIGH);
if (IS_ERR(xcsi2rxss->rst_gpio)) {
if (PTR_ERR(xcsi2rxss->rst_gpio) != -EPROBE_DEFER)
dev_err(dev, "Video Reset GPIO not setup in DT");
return PTR_ERR(xcsi2rxss->rst_gpio);
}
if (IS_ERR(xcsi2rxss->rst_gpio))
return dev_err_probe(dev, PTR_ERR(xcsi2rxss->rst_gpio),
"Video Reset GPIO not setup in DT\n");
ret = xcsi2rxss_parse_of(xcsi2rxss);
if (ret < 0)

View file

@ -74,13 +74,9 @@ static int gpio_ir_recv_probe(struct platform_device *pdev)
return -ENOMEM;
gpio_dev->gpiod = devm_gpiod_get(dev, NULL, GPIOD_IN);
if (IS_ERR(gpio_dev->gpiod)) {
rc = PTR_ERR(gpio_dev->gpiod);
/* Just try again if this happens */
if (rc != -EPROBE_DEFER)
dev_err(dev, "error getting gpio (%d)\n", rc);
return rc;
}
if (IS_ERR(gpio_dev->gpiod))
return dev_err_probe(dev, PTR_ERR(gpio_dev->gpiod),
"error getting gpio\n");
gpio_dev->irq = gpiod_to_irq(gpio_dev->gpiod);
if (gpio_dev->irq < 0)
return gpio_dev->irq;

View file

@ -174,12 +174,9 @@ static int gpio_ir_tx_probe(struct platform_device *pdev)
return -ENOMEM;
gpio_ir->gpio = devm_gpiod_get(&pdev->dev, NULL, GPIOD_OUT_LOW);
if (IS_ERR(gpio_ir->gpio)) {
if (PTR_ERR(gpio_ir->gpio) != -EPROBE_DEFER)
dev_err(&pdev->dev, "Failed to get gpio (%ld)\n",
PTR_ERR(gpio_ir->gpio));
return PTR_ERR(gpio_ir->gpio);
}
if (IS_ERR(gpio_ir->gpio))
return dev_err_probe(&pdev->dev, PTR_ERR(gpio_ir->gpio),
"Failed to get gpio\n");
rcdev->priv = gpio_ir;
rcdev->driver_name = DRIVER_NAME;

View file

@ -231,13 +231,8 @@ static int ir_rx51_probe(struct platform_device *dev)
struct rc_dev *rcdev;
pwm = pwm_get(&dev->dev, NULL);
if (IS_ERR(pwm)) {
int err = PTR_ERR(pwm);
if (err != -EPROBE_DEFER)
dev_err(&dev->dev, "pwm_get failed: %d\n", err);
return err;
}
if (IS_ERR(pwm))
return dev_err_probe(&dev->dev, PTR_ERR(pwm), "pwm_get failed\n");
/* Use default, in case userspace does not set the carrier */
ir_rx51.freq = DIV_ROUND_CLOSEST_ULL(pwm_get_period(pwm), NSEC_PER_SEC);

View file

@ -1266,12 +1266,9 @@ static int uvc_gpio_parse(struct uvc_device *dev)
return PTR_ERR_OR_ZERO(gpio_privacy);
irq = gpiod_to_irq(gpio_privacy);
if (irq < 0) {
if (irq != EPROBE_DEFER)
dev_err(&dev->udev->dev,
"No IRQ for privacy GPIO (%d)\n", irq);
return irq;
}
if (irq < 0)
return dev_err_probe(&dev->udev->dev, irq,
"No IRQ for privacy GPIO\n");
unit = uvc_alloc_entity(UVC_EXT_GPIO_UNIT, UVC_EXT_GPIO_UNIT_ID, 0, 1);
if (!unit)