media: i2c: imx219: Use dev_err_probe on probe
PATCH 1/1 media: i2c: imx219: Use dev_err_probe on probe
Drop dev_err() and use the dev_err_probe() helper on probe path.
No functional changes intended.
--- drivers/media/i2c/imx219.c | 64 +++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 32 deletions(-)
drivers/media/i2c/imx219.c +32 -32
@@ -551,8 +551,9 @@ static int imx219_init_controls(struct imx219 *imx219)if (ctrl_hdlr->error) { ret = ctrl_hdlr->error; -dev_err (&client->dev,"%s control init failed (%d)\n" , - __func__, ret); +dev_err_probe (&client->dev, ret, +"%s control init failed\n" , + __func__); goto error; }
@@ -1025,15 +1026,15 @@ static int imx219_identify_module(struct imx219 *imx219) ret =cci_read (imx219->regmap,IMX219_REG_CHIP_ID , &val,NULL );if (ret) { -dev_err (&client->dev,"failed to read chip id %x\n" , -IMX219_CHIP_ID ); -return ret; +return dev_err_probe (&client->dev, ret, +"failed to read chip id %x\n" , +IMX219_CHIP_ID ); }if (val !=IMX219_CHIP_ID ) { -dev_err (&client->dev,"chip id mismatch: %x!=%llx\n" , -IMX219_CHIP_ID , val); -return -EIO ; +return dev_err_probe (&client->dev, -EIO , +"chip id mismatch: %x!=%llx\n" , +IMX219_CHIP_ID , val); }return 0 ;
@@ -1048,35 +1049,36 @@ static int imx219_check_hwcfg(struct device *dev, struct imx219 *imx219)int ret = -EINVAL ; endpoint =fwnode_graph_get_next_endpoint (dev_fwnode (dev),NULL ); -if (!endpoint) { -dev_err (dev,"endpoint node not found\n" ); -return -EINVAL ; - } +if (!endpoint) +return dev_err_probe (dev, -EINVAL ,"endpoint node not found\n" );if (v4l2_fwnode_endpoint_alloc_parse (endpoint, &ep_cfg)) { -dev_err (dev,"could not parse endpoint\n" ); +dev_err_probe (dev, -EINVAL ,"could not parse endpoint\n" ); goto error_out; }/* Check the number of MIPI CSI2 data lanes */ if (ep_cfg.bus.mipi_csi2.num_data_lanes !=2 && ep_cfg.bus.mipi_csi2.num_data_lanes !=4 ) { -dev_err (dev,"only 2 or 4 data lanes are currently supported\n" ); +dev_err_probe (dev, -EINVAL , +"only 2 or 4 data lanes are currently supported\n" ); goto error_out; } imx219->lanes = ep_cfg.bus.mipi_csi2.num_data_lanes;/* Check the link frequency set in device tree */ if (!ep_cfg.nr_of_link_frequencies) { -dev_err (dev,"link-frequency property not found in DT\n" ); +dev_err_probe (dev, -EINVAL , +"link-frequency property not found in DT\n" ); goto error_out; }if (ep_cfg.nr_of_link_frequencies !=1 || (ep_cfg.link_frequencies[0 ] != ((imx219->lanes ==2 ) ?IMX219_DEFAULT_LINK_FREQ :IMX219_DEFAULT_LINK_FREQ_4LANE ))) { -dev_err (dev,"Link frequency not supported: %lld\n" , - ep_cfg.link_frequencies[0 ]); +dev_err_probe (dev, -EINVAL , +"Link frequency not supported: %lld\n" , + ep_cfg.link_frequencies[0 ]); goto error_out; }
@@ -1108,30 +1110,27 @@ static int imx219_probe(struct i2c_client *client) imx219->regmap =devm_cci_regmap_init_i2c (client,16 );if (IS_ERR (imx219->regmap)) { - ret =PTR_ERR (imx219->regmap); -dev_err (dev,"failed to initialize CCI: %d\n" , ret); -return ret; +return dev_err_probe (dev,PTR_ERR (imx219->regmap), +"failed to initialize CCI\n" ); }/* Get system clock (xclk) */ imx219->xclk =devm_clk_get (dev,NULL );if (IS_ERR (imx219->xclk)) { -dev_err (dev,"failed to get xclk\n" ); -return PTR_ERR (imx219->xclk); +return dev_err_probe (dev,PTR_ERR (imx219->xclk), +"failed to get xclk\n" ); } imx219->xclk_freq =clk_get_rate (imx219->xclk);if (imx219->xclk_freq !=IMX219_XCLK_FREQ ) { -dev_err (dev,"xclk frequency not supported: %d Hz\n" , - imx219->xclk_freq); -return -EINVAL ; +return dev_err_probe (dev, -EINVAL , +"xclk frequency not supported: %d Hz\n" , + imx219->xclk_freq); } ret =imx219_get_regulators (imx219); -if (ret) { -dev_err (dev,"failed to get regulators\n" ); -return ret; - } +if (ret) +return dev_err_probe (dev, ret,"failed to get regulators\n" );/* Request optional enable pin */ imx219->reset_gpio = devm_gpiod_get_optional(dev, "reset",
@@ -1183,20 +1182,21 @@ static int imx219_probe(struct i2c_client *client) ret =media_entity_pads_init (&imx219->sd.entity,1 , &imx219->pad);if (ret) { -dev_err (dev,"failed to init entity pads: %d\n" , ret); +dev_err_probe (dev, ret,"failed to init entity pads\n" ); goto error_handler_free; } imx219->sd.state_lock = imx219->ctrl_handler.lock; ret =v4l2_subdev_init_finalize (&imx219->sd);if (ret <0 ) { -dev_err (dev,"subdev init error: %d\n" , ret); +dev_err_probe (dev, ret,"subdev init error\n" ); goto error_media_entity; } ret =v4l2_async_register_subdev_sensor (&imx219->sd);if (ret <0 ) { -dev_err (dev,"failed to register sensor sub-device: %d\n" , ret); +dev_err_probe (dev, ret, +"failed to register sensor sub-device\n" ); goto error_subdev_cleanup; }
Signature · 1 line
2.43.0
Hi Umang,
Thanks for the patch.
Quoted 26 lines · Umang Jain
Drop
dev_err()and use thedev_err_probe()helper on probe path.No functional changes intended.
Signed-off-by Umang Jain <[email protected]>--- drivers/media/i2c/imx219.c | 64 +++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 32 deletions(-)drivers/media/i2c/imx219.c +3
-2@@ -551,8 +551,9 @@ static int imx219_init_controls(struct imx219 *imx219)if (ctrl_hdlr->error) { ret = ctrl_hdlr->error; -dev_err (&client->dev,"%s control init failed (%d)\n" , - __func__, ret); +dev_err_probe (&client->dev, ret, +"%s control init failed\n" , + __func__); goto error; }
drivers/media/i2c/imx219.c static int imx219_identify_module(struct imx219 *imx219) · line 1032
Quoted 10 lines
drivers/media/i2c/imx219.c +3
-3@@ -1025,15 +1026,15 @@ static int imx219_identify_module(struct imx219 *imx219) ret =cci_read (imx219->regmap,IMX219_REG_CHIP_ID , &val,NULL );if (ret) { -dev_err (&client->dev,"failed to read chip id %x\n" , -IMX219_CHIP_ID ); -return ret; +return dev_err_probe (&client->dev, ret, +"failed to read chip id %x\n" , +IMX219_CHIP_ID ); }
I think you can remove also here the curve brakets we don't need that anymore.
drivers/media/i2c/imx219.c static int imx219_identify_module(struct imx219 *imx219) · line 1038
Quoted 9 lines
drivers/media/i2c/imx219.c +3
-3if (val !=IMX219_CHIP_ID ) { -dev_err (&client->dev,"chip id mismatch: %x!=%llx\n" , -IMX219_CHIP_ID , val); -return -EIO ; +return dev_err_probe (&client->dev, -EIO , +"chip id mismatch: %x!=%llx\n" , +IMX219_CHIP_ID , val); }
ditto
Quoted 49 lines
drivers/media/i2c/imx219.c +10
-9return 0 ;@@ -1048,35 +1049,36 @@ static int imx219_check_hwcfg(struct device *dev, struct imx219 *imx219)int ret = -EINVAL ; endpoint =fwnode_graph_get_next_endpoint (dev_fwnode (dev),NULL ); -if (!endpoint) { -dev_err (dev,"endpoint node not found\n" ); -return -EINVAL ; - } +if (!endpoint) +return dev_err_probe (dev, -EINVAL ,"endpoint node not found\n" );if (v4l2_fwnode_endpoint_alloc_parse (endpoint, &ep_cfg)) { -dev_err (dev,"could not parse endpoint\n" ); +dev_err_probe (dev, -EINVAL ,"could not parse endpoint\n" ); goto error_out; }/* Check the number of MIPI CSI2 data lanes */ if (ep_cfg.bus.mipi_csi2.num_data_lanes !=2 && ep_cfg.bus.mipi_csi2.num_data_lanes !=4 ) { -dev_err (dev,"only 2 or 4 data lanes are currently supported\n" ); +dev_err_probe (dev, -EINVAL , +"only 2 or 4 data lanes are currently supported\n" ); goto error_out; } imx219->lanes = ep_cfg.bus.mipi_csi2.num_data_lanes;/* Check the link frequency set in device tree */ if (!ep_cfg.nr_of_link_frequencies) { -dev_err (dev,"link-frequency property not found in DT\n" ); +dev_err_probe (dev, -EINVAL , +"link-frequency property not found in DT\n" ); goto error_out; }if (ep_cfg.nr_of_link_frequencies !=1 || (ep_cfg.link_frequencies[0 ] != ((imx219->lanes ==2 ) ?IMX219_DEFAULT_LINK_FREQ :IMX219_DEFAULT_LINK_FREQ_4LANE ))) { -dev_err (dev,"Link frequency not supported: %lld\n" , - ep_cfg.link_frequencies[0 ]); +dev_err_probe (dev, -EINVAL , +"Link frequency not supported: %lld\n" , + ep_cfg.link_frequencies[0 ]); goto error_out; }
drivers/media/i2c/imx219.c static int imx219_probe(struct i2c_client *client) · line 1115
Quoted 9 lines
drivers/media/i2c/imx219.c +2
-3@@ -1108,30 +1110,27 @@ static int imx219_probe(struct i2c_client *client) imx219->regmap =devm_cci_regmap_init_i2c (client,16 );if (IS_ERR (imx219->regmap)) { - ret =PTR_ERR (imx219->regmap); -dev_err (dev,"failed to initialize CCI: %d\n" , ret); -return ret; +return dev_err_probe (dev,PTR_ERR (imx219->regmap), +"failed to initialize CCI\n" ); }
ditto
drivers/media/i2c/imx219.c static int imx219_probe(struct i2c_client *client) · line 1122
Quoted 9 lines
drivers/media/i2c/imx219.c +2
-2/* Get system clock (xclk) */ imx219->xclk =devm_clk_get (dev,NULL );if (IS_ERR (imx219->xclk)) { -dev_err (dev,"failed to get xclk\n" ); -return PTR_ERR (imx219->xclk); +return dev_err_probe (dev,PTR_ERR (imx219->xclk), +"failed to get xclk\n" ); }
ditto
drivers/media/i2c/imx219.c static int imx219_probe(struct i2c_client *client) · line 1129
Quoted 10 lines
drivers/media/i2c/imx219.c +3
-3imx219->xclk_freq =clk_get_rate (imx219->xclk);if (imx219->xclk_freq !=IMX219_XCLK_FREQ ) { -dev_err (dev,"xclk frequency not supported: %d Hz\n" , - imx219->xclk_freq); -return -EINVAL ; +return dev_err_probe (dev, -EINVAL , +"xclk frequency not supported: %d Hz\n" , + imx219->xclk_freq); }
ditto
Quoted 38 lines
drivers/media/i2c/imx219.c +6
-7ret =imx219_get_regulators (imx219); -if (ret) { -dev_err (dev,"failed to get regulators\n" ); -return ret; - } +if (ret) +return dev_err_probe (dev, ret,"failed to get regulators\n" );/* Request optional enable pin */ imx219->reset_gpio = devm_gpiod_get_optional(dev, "reset",@@ -1183,20 +1182,21 @@ static int imx219_probe(struct i2c_client *client) ret =media_entity_pads_init (&imx219->sd.entity,1 , &imx219->pad);if (ret) { -dev_err (dev,"failed to init entity pads: %d\n" , ret); +dev_err_probe (dev, ret,"failed to init entity pads\n" ); goto error_handler_free; } imx219->sd.state_lock = imx219->ctrl_handler.lock; ret =v4l2_subdev_init_finalize (&imx219->sd);if (ret <0 ) { -dev_err (dev,"subdev init error: %d\n" , ret); +dev_err_probe (dev, ret,"subdev init error\n" ); goto error_media_entity; } ret =v4l2_async_register_subdev_sensor (&imx219->sd);if (ret <0 ) { -dev_err (dev,"failed to register sensor sub-device: %d\n" , ret); +dev_err_probe (dev, ret, +"failed to register sensor sub-device\n" ); goto error_subdev_cleanup; }Signature · 1 line
2.43.0
Thanks & Regards,
Tommaso
Quoted 2 lines
Hi Tommaso,
Quoted 31 lines · Tommaso Merciai
Hi Umang,
Thanks for the patch.Quoted 27 lines · Umang Jain
Drop
dev_err()and use thedev_err_probe()helper on probe path.No functional changes intended.
Signed-off-by Umang Jain <[email protected]>--- drivers/media/i2c/imx219.c | 64 +++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 32 deletions(-)drivers/media/i2c/imx219.c +3
-2@@ -551,8 +551,9 @@ static int imx219_init_controls(struct imx219 *imx219)if (ctrl_hdlr->error) { ret = ctrl_hdlr->error; -dev_err (&client->dev,"%s control init failed (%d)\n" , - __func__, ret); +dev_err_probe (&client->dev, ret, +"%s control init failed\n" , + __func__); goto error; }@@ -1025,15 +1026,15 @@ static int imx219_identify_module(struct imx219 *imx219)
Quoted 11 lines
drivers/media/i2c/imx219.c static int imx219_identify_module(struct imx219 *imx219) · line 1032
Quoted 9 lines
drivers/media/i2c/imx219.c +3
-3ret =cci_read (imx219->regmap,IMX219_REG_CHIP_ID , &val,NULL );if (ret) { -dev_err (&client->dev,"failed to read chip id %x\n" , -IMX219_CHIP_ID ); -return ret; +return dev_err_probe (&client->dev, ret, +"failed to read chip id %x\n" , +IMX219_CHIP_ID ); }I think you can remove also here the curve brakets we don't need that anymore.
I think multi-line single statement like this one, is better with { ... } and is actually preferred?
I actually got a review-comment about this long ago(don't remember when) in a non-related, kernel patch series.
I'll leaving this upto maintainers probably
Quoted 137 lines
drivers/media/i2c/imx219.c static int imx219_identify_module(struct imx219 *imx219) · line 1038
Quoted 10 lines
drivers/media/i2c/imx219.c +3
-3if (val !=IMX219_CHIP_ID ) { -dev_err (&client->dev,"chip id mismatch: %x!=%llx\n" , -IMX219_CHIP_ID , val); -return -EIO ; +return dev_err_probe (&client->dev, -EIO , +"chip id mismatch: %x!=%llx\n" , +IMX219_CHIP_ID , val); }ditto
Quoted 49 lines
drivers/media/i2c/imx219.c +10
-9return 0 ;@@ -1048,35 +1049,36 @@ static int imx219_check_hwcfg(struct device *dev, struct imx219 *imx219)int ret = -EINVAL ; endpoint =fwnode_graph_get_next_endpoint (dev_fwnode (dev),NULL ); -if (!endpoint) { -dev_err (dev,"endpoint node not found\n" ); -return -EINVAL ; - } +if (!endpoint) +return dev_err_probe (dev, -EINVAL ,"endpoint node not found\n" );if (v4l2_fwnode_endpoint_alloc_parse (endpoint, &ep_cfg)) { -dev_err (dev,"could not parse endpoint\n" ); +dev_err_probe (dev, -EINVAL ,"could not parse endpoint\n" ); goto error_out; }/* Check the number of MIPI CSI2 data lanes */ if (ep_cfg.bus.mipi_csi2.num_data_lanes !=2 && ep_cfg.bus.mipi_csi2.num_data_lanes !=4 ) { -dev_err (dev,"only 2 or 4 data lanes are currently supported\n" ); +dev_err_probe (dev, -EINVAL , +"only 2 or 4 data lanes are currently supported\n" ); goto error_out; } imx219->lanes = ep_cfg.bus.mipi_csi2.num_data_lanes;/* Check the link frequency set in device tree */ if (!ep_cfg.nr_of_link_frequencies) { -dev_err (dev,"link-frequency property not found in DT\n" ); +dev_err_probe (dev, -EINVAL , +"link-frequency property not found in DT\n" ); goto error_out; }if (ep_cfg.nr_of_link_frequencies !=1 || (ep_cfg.link_frequencies[0 ] != ((imx219->lanes ==2 ) ?IMX219_DEFAULT_LINK_FREQ :IMX219_DEFAULT_LINK_FREQ_4LANE ))) { -dev_err (dev,"Link frequency not supported: %lld\n" , - ep_cfg.link_frequencies[0 ]); +dev_err_probe (dev, -EINVAL , +"Link frequency not supported: %lld\n" , + ep_cfg.link_frequencies[0 ]); goto error_out; }drivers/media/i2c/imx219.c static int imx219_probe(struct i2c_client *client) · line 1115
Quoted 9 lines
drivers/media/i2c/imx219.c +2
-3@@ -1108,30 +1110,27 @@ static int imx219_probe(struct i2c_client *client) imx219->regmap =devm_cci_regmap_init_i2c (client,16 );if (IS_ERR (imx219->regmap)) { - ret =PTR_ERR (imx219->regmap); -dev_err (dev,"failed to initialize CCI: %d\n" , ret); -return ret; +return dev_err_probe (dev,PTR_ERR (imx219->regmap), +"failed to initialize CCI\n" ); }ditto
drivers/media/i2c/imx219.c static int imx219_probe(struct i2c_client *client) · line 1122
Quoted 9 lines
drivers/media/i2c/imx219.c +2
-2/* Get system clock (xclk) */ imx219->xclk =devm_clk_get (dev,NULL );if (IS_ERR (imx219->xclk)) { -dev_err (dev,"failed to get xclk\n" ); -return PTR_ERR (imx219->xclk); +return dev_err_probe (dev,PTR_ERR (imx219->xclk), +"failed to get xclk\n" ); }ditto
drivers/media/i2c/imx219.c static int imx219_probe(struct i2c_client *client) · line 1129
Quoted 10 lines
drivers/media/i2c/imx219.c +3
-3imx219->xclk_freq =clk_get_rate (imx219->xclk);if (imx219->xclk_freq !=IMX219_XCLK_FREQ ) { -dev_err (dev,"xclk frequency not supported: %d Hz\n" , - imx219->xclk_freq); -return -EINVAL ; +return dev_err_probe (dev, -EINVAL , +"xclk frequency not supported: %d Hz\n" , + imx219->xclk_freq); }ditto
Quoted 38 lines
drivers/media/i2c/imx219.c +6
-7ret =imx219_get_regulators (imx219); -if (ret) { -dev_err (dev,"failed to get regulators\n" ); -return ret; - } +if (ret) +return dev_err_probe (dev, ret,"failed to get regulators\n" );/* Request optional enable pin */ imx219->reset_gpio = devm_gpiod_get_optional(dev, "reset",@@ -1183,20 +1182,21 @@ static int imx219_probe(struct i2c_client *client) ret =media_entity_pads_init (&imx219->sd.entity,1 , &imx219->pad);if (ret) { -dev_err (dev,"failed to init entity pads: %d\n" , ret); +dev_err_probe (dev, ret,"failed to init entity pads\n" ); goto error_handler_free; } imx219->sd.state_lock = imx219->ctrl_handler.lock; ret =v4l2_subdev_init_finalize (&imx219->sd);if (ret <0 ) { -dev_err (dev,"subdev init error: %d\n" , ret); +dev_err_probe (dev, ret,"subdev init error\n" ); goto error_media_entity; } ret =v4l2_async_register_subdev_sensor (&imx219->sd);if (ret <0 ) { -dev_err (dev,"failed to register sensor sub-device: %d\n" , ret); +dev_err_probe (dev, ret, +"failed to register sensor sub-device\n" ); goto error_subdev_cleanup; }Signature · 1 line
2.43.0Thanks & Regards,
TommasoQuoted 1 line
Hi Umang,
Quoted 43 lines · Umang Jain
Hi Tommaso,
Quoted 31 lines · Tommaso Merciai
Hi Umang,
Thanks for the patch.Quoted 27 lines · Umang Jain
Drop
dev_err()and use thedev_err_probe()helper on probe path.No functional changes intended.
Signed-off-by Umang Jain <[email protected]>--- drivers/media/i2c/imx219.c | 64 +++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 32 deletions(-)drivers/media/i2c/imx219.c +3
-3@@ -551,8 +551,9 @@ static int imx219_init_controls(struct imx219 *imx219)if (ctrl_hdlr->error) { ret = ctrl_hdlr->error; -dev_err (&client->dev,"%s control init failed (%d)\n" , - __func__, ret); +dev_err_probe (&client->dev, ret, +"%s control init failed\n" , + __func__); goto error; }@@ -1025,15 +1026,15 @@ static int imx219_identify_module(struct imx219 *imx219) ret =cci_read (imx219->regmap,IMX219_REG_CHIP_ID , &val,NULL );if (ret) { - dev_err(&client->dev, "failed to read chip id %x\n",Quoted 8 lines
drivers/media/i2c/imx219.c static int imx219_identify_module(struct imx219 *imx219) · line 1032
Quoted 6 lines
drivers/media/i2c/imx219.c +3
-2- IMX219_CHIP_ID); -return ret; +return dev_err_probe (&client->dev, ret, +"failed to read chip id %x\n" , +IMX219_CHIP_ID ); }I think you can remove also here the curve brakets we don't need that anymore.
Quoted 2 lines
I think multi-line single statement like this one, is better with { ... } and is actually preferred?
Yep, some driver is using your pattern some other not. I'm curious about the truth :) (for my education :))
Quoted 5 lines
I actually got a review-comment about this long ago(don't remember when) in a non-related, kernel patch series.
I'll leaving this upto maintainers probably
Oks, thanks for sharing!
Regards,
Tommaso
Quoted 121 lines
Quoted 120 lines
drivers/media/i2c/imx219.c static int imx219_identify_module(struct imx219 *imx219) · line 1038
Quoted 9 lines
drivers/media/i2c/imx219.c +3
-3if (val !=IMX219_CHIP_ID ) { -dev_err (&client->dev,"chip id mismatch: %x!=%llx\n" , -IMX219_CHIP_ID , val); -return -EIO ; +return dev_err_probe (&client->dev, -EIO , +"chip id mismatch: %x!=%llx\n" , +IMX219_CHIP_ID , val); }ditto
Quoted 42 lines
drivers/media/i2c/imx219.c +10
-9return 0 ;@@ -1048,35 +1049,36 @@ static int imx219_check_hwcfg(struct device *dev, struct imx219 *imx219)int ret = -EINVAL ; endpoint =fwnode_graph_get_next_endpoint (dev_fwnode (dev),NULL ); -if (!endpoint) { -dev_err (dev,"endpoint node not found\n" ); -return -EINVAL ; - } +if (!endpoint) +return dev_err_probe (dev, -EINVAL ,"endpoint node not found\n" );if (v4l2_fwnode_endpoint_alloc_parse (endpoint, &ep_cfg)) { -dev_err (dev,"could not parse endpoint\n" ); +dev_err_probe (dev, -EINVAL ,"could not parse endpoint\n" ); goto error_out; }/* Check the number of MIPI CSI2 data lanes */ if (ep_cfg.bus.mipi_csi2.num_data_lanes !=2 && ep_cfg.bus.mipi_csi2.num_data_lanes !=4 ) { -dev_err (dev,"only 2 or 4 data lanes are currently supported\n" ); +dev_err_probe (dev, -EINVAL , +"only 2 or 4 data lanes are currently supported\n" ); goto error_out; } imx219->lanes = ep_cfg.bus.mipi_csi2.num_data_lanes;/* Check the link frequency set in device tree */ if (!ep_cfg.nr_of_link_frequencies) { -dev_err (dev,"link-frequency property not found in DT\n" ); +dev_err_probe (dev, -EINVAL , +"link-frequency property not found in DT\n" ); goto error_out; }if (ep_cfg.nr_of_link_frequencies !=1 || (ep_cfg.link_frequencies[0 ] != ((imx219->lanes ==2 ) ?IMX219_DEFAULT_LINK_FREQ :IMX219_DEFAULT_LINK_FREQ_4LANE ))) { -dev_err (dev,"Link frequency not supported: %lld\n" , - ep_cfg.link_frequencies[0 ]); +dev_err_probe (dev, -EINVAL , +"Link frequency not supported: %lld\n" , + ep_cfg.link_frequencies[0 ]); goto error_out; }drivers/media/i2c/imx219.c static int imx219_probe(struct i2c_client *client) · line 1114
Quoted 8 lines
drivers/media/i2c/imx219.c +2
-3@@ -1108,30 +1110,27 @@ static int imx219_probe(struct i2c_client *client) imx219->regmap =devm_cci_regmap_init_i2c (client,16 );if (IS_ERR (imx219->regmap)) { - ret =PTR_ERR (imx219->regmap); -dev_err (dev,"failed to initialize CCI: %d\n" , ret); -return ret; +return dev_err_probe (dev,PTR_ERR (imx219->regmap), +"failed to initialize CCI\n" ); }ditto
drivers/media/i2c/imx219.c static int imx219_probe(struct i2c_client *client) · line 1122
Quoted 8 lines
drivers/media/i2c/imx219.c +2
-2/* Get system clock (xclk) */ imx219->xclk =devm_clk_get (dev,NULL );if (IS_ERR (imx219->xclk)) { -dev_err (dev,"failed to get xclk\n" ); -return PTR_ERR (imx219->xclk); +return dev_err_probe (dev,PTR_ERR (imx219->xclk), +"failed to get xclk\n" ); }ditto
drivers/media/i2c/imx219.c static int imx219_probe(struct i2c_client *client) · line 1129
Quoted 9 lines
drivers/media/i2c/imx219.c +3
-3imx219->xclk_freq =clk_get_rate (imx219->xclk);if (imx219->xclk_freq !=IMX219_XCLK_FREQ ) { -dev_err (dev,"xclk frequency not supported: %d Hz\n" , - imx219->xclk_freq); -return -EINVAL ; +return dev_err_probe (dev, -EINVAL , +"xclk frequency not supported: %d Hz\n" , + imx219->xclk_freq); }ditto
Quoted 32 lines
drivers/media/i2c/imx219.c +6
-7ret =imx219_get_regulators (imx219); -if (ret) { -dev_err (dev,"failed to get regulators\n" ); -return ret; - } +if (ret) +return dev_err_probe (dev, ret,"failed to get regulators\n" );/* Request optional enable pin */ imx219->reset_gpio = devm_gpiod_get_optional(dev, "reset",@@ -1183,20 +1182,21 @@ static int imx219_probe(struct i2c_client *client) ret =media_entity_pads_init (&imx219->sd.entity,1 , &imx219->pad);if (ret) { -dev_err (dev,"failed to init entity pads: %d\n" , ret); +dev_err_probe (dev, ret,"failed to init entity pads\n" ); goto error_handler_free; } imx219->sd.state_lock = imx219->ctrl_handler.lock; ret =v4l2_subdev_init_finalize (&imx219->sd);if (ret <0 ) { -dev_err (dev,"subdev init error: %d\n" , ret); +dev_err_probe (dev, ret,"subdev init error\n" ); goto error_media_entity; } ret =v4l2_async_register_subdev_sensor (&imx219->sd);if (ret <0 ) { -dev_err (dev,"failed to register sensor sub-device: %d\n" , ret); +dev_err_probe (dev, ret, +"failed to register sensor sub-device\n" ); goto error_subdev_cleanup; }Signature · 1 line
2.43.0Thanks & Regards,
TommasoQuoted 1 line
Sakari Ailus
maintainerQuoted 13 lines · Tommaso Merciai
Quoted 13 lines
Quoted 12 lines
drivers/media/i2c/imx219.c static int imx219_identify_module(struct imx219 *imx219) · line 1031
Quoted 10 lines
drivers/media/i2c/imx219.c +3
-3@@ -1025,15 +1026,15 @@ static int imx219_identify_module(struct imx219 *imx219) ret =cci_read (imx219->regmap,IMX219_REG_CHIP_ID , &val,NULL );if (ret) { -dev_err (&client->dev,"failed to read chip id %x\n" , -IMX219_CHIP_ID ); -return ret; +return dev_err_probe (&client->dev, ret, +"failed to read chip id %x\n" , +IMX219_CHIP_ID ); }I think you can remove also here the curve brakets we don't need that anymore.
Quoted 5 lines
Quoted 2 lines
I think multi-line single statement like this one, is better with { ... } and is actually preferred?
Yep, some driver is using your pattern some other not. I'm curious about the truth :) (for my education :))
I'd prefer it without braces.
See the end of section 3 in Documentation/process/coding-style.rst .
Signature · 1 line
Sakari Ailus
Hi Umang,
Quoted 17 lines · Umang Jain
Quoted 16 lines · Tommaso Merciai
Quoted 15 lines · Umang Jain
Drop
dev_err()and use thedev_err_probe()helper on probe path.No functional changes intended.
Signed-off-by Umang Jain <[email protected]>--- drivers/media/i2c/imx219.c | 64 +++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 32 deletions(-)drivers/media/i2c/imx219.c +0
-0@@ -551,8 +551,9 @@ static int imx219_init_controls(struct imx219 *imx219)
Quoted 7 lines
Quoted 7 lines
drivers/media/i2c/imx219.c static int imx219_init_controls(struct imx219 *imx219) · line 556
Quoted 7 lines
drivers/media/i2c/imx219.c +3
-2if (ctrl_hdlr->error) { ret = ctrl_hdlr->error; -dev_err (&client->dev,"%s control init failed (%d)\n" , - __func__, ret); +dev_err_probe (&client->dev, ret, +"%s control init failed\n" , + __func__);
ctrl_hdlr->error can never be -EPROBE_DEFER, is dev_err_probe() really useful here ?
Quoted 18 lines
Quoted 5 lines
Quoted 5 lines
drivers/media/i2c/imx219.c +0
-0goto error; }@@ -1025,15 +1026,15 @@ static int imx219_identify_module(struct imx219 *imx219)Quoted 12 lines
drivers/media/i2c/imx219.c static int imx219_identify_module(struct imx219 *imx219) · line 1032
Quoted 9 lines
drivers/media/i2c/imx219.c +3
-3ret =cci_read (imx219->regmap,IMX219_REG_CHIP_ID , &val,NULL );if (ret) { -dev_err (&client->dev,"failed to read chip id %x\n" , -IMX219_CHIP_ID ); -return ret; +return dev_err_probe (&client->dev, ret, +"failed to read chip id %x\n" , +IMX219_CHIP_ID ); }I think you can remove also here the curve brakets we don't need that anymore.
Quoted 7 lines
I think multi-line single statement like this one, is better with { ... } and is actually preferred?
I actually got a review-comment about this long ago(don't remember when) in a non-related, kernel patch series.
I'll leaving this upto maintainers probably
I think the preferred coding style in the media subsystem is to leave the curly brackets out for all single statements, even if the statement spans multiple lines.
Quoted 17 lines
Quoted 17 lines
drivers/media/i2c/imx219.c static int imx219_identify_module(struct imx219 *imx219) · line 1038
Quoted 9 lines
drivers/media/i2c/imx219.c +3
-3if (val !=IMX219_CHIP_ID ) { -dev_err (&client->dev,"chip id mismatch: %x!=%llx\n" , -IMX219_CHIP_ID , val); -return -EIO ; +return dev_err_probe (&client->dev, -EIO , +"chip id mismatch: %x!=%llx\n" , +IMX219_CHIP_ID , val); }ditto
Quoted 5 lines
drivers/media/i2c/imx219.c +0
-0return 0 ;@@ -1048,35 +1049,36 @@ static int imx219_check_hwcfg(struct device *dev, struct imx219 *imx219)int ret = -EINVAL ;
Quoted 7 lines
Quoted 7 lines
drivers/media/i2c/imx219.c static int imx219_check_hwcfg(struct device *dev, struct imx219 *imx219) · line 1053
Quoted 7 lines
drivers/media/i2c/imx219.c +2
-4endpoint =fwnode_graph_get_next_endpoint (dev_fwnode (dev),NULL ); -if (!endpoint) { -dev_err (dev,"endpoint node not found\n" ); -return -EINVAL ; - } +if (!endpoint) +return dev_err_probe (dev, -EINVAL ,"endpoint node not found\n" );
Same here, what's the advantage of using dev_err_probe() when you hardcode the error value to something different than -EPROBE_DEFER ? Same below.
Quoted 4 lines
Quoted 4 lines
drivers/media/i2c/imx219.c static int imx219_check_hwcfg(struct device *dev, struct imx219 *imx219) · line 1056
Quoted 4 lines
drivers/media/i2c/imx219.c +1
-1if (v4l2_fwnode_endpoint_alloc_parse (endpoint, &ep_cfg)) { -dev_err (dev,"could not parse endpoint\n" ); +dev_err_probe (dev, -EINVAL ,"could not parse endpoint\n" );
This I like even less. -EINVAL is meaningless here, it's not even guaranteed to be the error code that the function will return.
Quoted 46 lines
Quoted 46 lines
Quoted 33 lines
drivers/media/i2c/imx219.c +7
-4goto error_out; }/* Check the number of MIPI CSI2 data lanes */ if (ep_cfg.bus.mipi_csi2.num_data_lanes !=2 && ep_cfg.bus.mipi_csi2.num_data_lanes !=4 ) { -dev_err (dev,"only 2 or 4 data lanes are currently supported\n" ); +dev_err_probe (dev, -EINVAL , +"only 2 or 4 data lanes are currently supported\n" ); goto error_out; } imx219->lanes = ep_cfg.bus.mipi_csi2.num_data_lanes;/* Check the link frequency set in device tree */ if (!ep_cfg.nr_of_link_frequencies) { -dev_err (dev,"link-frequency property not found in DT\n" ); +dev_err_probe (dev, -EINVAL , +"link-frequency property not found in DT\n" ); goto error_out; }if (ep_cfg.nr_of_link_frequencies !=1 || (ep_cfg.link_frequencies[0 ] != ((imx219->lanes ==2 ) ?IMX219_DEFAULT_LINK_FREQ :IMX219_DEFAULT_LINK_FREQ_4LANE ))) { -dev_err (dev,"Link frequency not supported: %lld\n" , - ep_cfg.link_frequencies[0 ]); +dev_err_probe (dev, -EINVAL , +"Link frequency not supported: %lld\n" , + ep_cfg.link_frequencies[0 ]); goto error_out; }drivers/media/i2c/imx219.c static int imx219_probe(struct i2c_client *client) · line 1115
Quoted 9 lines
drivers/media/i2c/imx219.c +2
-3@@ -1108,30 +1110,27 @@ static int imx219_probe(struct i2c_client *client) imx219->regmap =devm_cci_regmap_init_i2c (client,16 );if (IS_ERR (imx219->regmap)) { - ret =PTR_ERR (imx219->regmap); -dev_err (dev,"failed to initialize CCI: %d\n" , ret); -return ret; +return dev_err_probe (dev,PTR_ERR (imx219->regmap), +"failed to initialize CCI\n" ); }ditto
Quoted 1 line
Quoted 7 lines
Quoted 7 lines
drivers/media/i2c/imx219.c static int imx219_probe(struct i2c_client *client) · line 1121
Quoted 7 lines
/* Get system clock (xclk) */ imx219->xclk = devm_clk_get(dev, NULL); if (IS_ERR(imx219->xclk)) {drivers/media/i2c/imx219.c +2
-2-dev_err (dev,"failed to get xclk\n" ); -return PTR_ERR (imx219->xclk); +return dev_err_probe (dev,PTR_ERR (imx219->xclk), +"failed to get xclk\n" );
This change makes sense, the clock provider may not have probed yet (even if it's quite unlikely).
Quoted 18 lines
Quoted 18 lines
Quoted 1 line
}ditto
drivers/media/i2c/imx219.c static int imx219_probe(struct i2c_client *client) · line 1129
Quoted 10 lines
imx219->xclk_freq = clk_get_rate(imx219->xclk); if (imx219->xclk_freq != IMX219_XCLK_FREQ) {drivers/media/i2c/imx219.c +3
-3-dev_err (dev,"xclk frequency not supported: %d Hz\n" , - imx219->xclk_freq); -return -EINVAL ; +return dev_err_probe (dev, -EINVAL , +"xclk frequency not supported: %d Hz\n" , + imx219->xclk_freq); }ditto
Quoted 1 line
Quoted 7 lines
Quoted 7 lines
drivers/media/i2c/imx219.c static int imx219_probe(struct i2c_client *client) · line 1133
Quoted 7 lines
ret = imx219_get_regulators(imx219);drivers/media/i2c/imx219.c +2
-4-if (ret) { -dev_err (dev,"failed to get regulators\n" ); -return ret; - } +if (ret) +return dev_err_probe (dev, ret,"failed to get regulators\n" );
Same here.
Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
/* Request optional enable pin */
imx219->reset_gpio= devm_gpiod_get_optional(dev, "reset",drivers/media/i2c/imx219.c +4
-3@@ -1183,20 +1182,21 @@ static int imx219_probe(struct i2c_client *client) ret =media_entity_pads_init (&imx219->sd.entity,1 , &imx219->pad);if (ret) { -dev_err (dev,"failed to init entity pads: %d\n" , ret); +dev_err_probe (dev, ret,"failed to init entity pads\n" ); goto error_handler_free; } imx219->sd.state_lock = imx219->ctrl_handler.lock; ret =v4l2_subdev_init_finalize (&imx219->sd);if (ret <0 ) { -dev_err (dev,"subdev init error: %d\n" , ret); +dev_err_probe (dev, ret,"subdev init error\n" ); goto error_media_entity; } ret =v4l2_async_register_subdev_sensor (&imx219->sd);if (ret <0 ) { -dev_err (dev,"failed to register sensor sub-device: %d\n" , ret); +dev_err_probe (dev, ret, +"failed to register sensor sub-device\n" ); goto error_subdev_cleanup; }
Signature · 3 lines
Regards, Laurent Pinchart
HI Laurent,
Quoted 20 lines · Laurent Pinchart
Hi Umang,
Quoted 17 lines · Umang Jain
Quoted 16 lines · Tommaso Merciai
Quoted 15 lines · Umang Jain
Drop
dev_err()and use thedev_err_probe()helper on probe path.No functional changes intended.
Signed-off-by Umang Jain <[email protected]>--- drivers/media/i2c/imx219.c | 64 +++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 32 deletions(-)drivers/media/i2c/imx219.c +0
-0@@ -551,8 +551,9 @@ static int imx219_init_controls(struct imx219 *imx219)
Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
drivers/media/i2c/imx219.c static int imx219_init_controls(struct imx219 *imx219) · line 556
Quoted 7 lines
drivers/media/i2c/imx219.c +3
-2if (ctrl_hdlr->error) { ret = ctrl_hdlr->error; -dev_err (&client->dev,"%s control init failed (%d)\n" , - __func__, ret); +dev_err_probe (&client->dev, ret, +"%s control init failed\n" , + __func__);
ctrl_hdlr->errorcan never be -EPROBE_DEFER, isdev_err_probe()really useful here ?
is dev_err_probe() really /only/ about -EPROBE_DEFER ? or all probe() errors?
The documentation is explicitly stating for dev_Err_probe()
``` * Note that it is deemed acceptable to use this function for error * prints during probe even if the @err is known to never be -EPROBE_DEFER. * The benefit compared to a normal dev_err() is the standardized format * of the error code and the fact that the error code is returned. * ```
Quoted 20 lines
Quoted 20 lines
Quoted 6 lines
Quoted 6 lines
drivers/media/i2c/imx219.c +0
-0goto error; }@@ -1025,15 +1026,15 @@ static int imx219_identify_module(struct imx219 *imx219)Quoted 11 lines
drivers/media/i2c/imx219.c static int imx219_identify_module(struct imx219 *imx219) · line 1032
Quoted 9 lines
drivers/media/i2c/imx219.c +3
-3ret =cci_read (imx219->regmap,IMX219_REG_CHIP_ID , &val,NULL );if (ret) { -dev_err (&client->dev,"failed to read chip id %x\n" , -IMX219_CHIP_ID ); -return ret; +return dev_err_probe (&client->dev, ret, +"failed to read chip id %x\n" , +IMX219_CHIP_ID ); }I think you can remove also here the curve brakets we don't need that anymore.
I think multi-line single statement like this one, is better with { ... } and is actually preferred?
Quoted 7 lines
Quoted 4 lines
I actually got a review-comment about this long ago(don't remember when) in a non-related, kernel patch series.
I'll leaving this upto maintainers probably
I think the preferred coding style in the media subsystem is to leave the curly brackets out for all single statements, even if the statement spans multiple lines.
ack
Quoted 143 lines
Quoted 17 lines
Quoted 17 lines
drivers/media/i2c/imx219.c static int imx219_identify_module(struct imx219 *imx219) · line 1038
Quoted 10 lines
drivers/media/i2c/imx219.c +3
-3if (val !=IMX219_CHIP_ID ) { -dev_err (&client->dev,"chip id mismatch: %x!=%llx\n" , -IMX219_CHIP_ID , val); -return -EIO ; +return dev_err_probe (&client->dev, -EIO , +"chip id mismatch: %x!=%llx\n" , +IMX219_CHIP_ID , val); }ditto
Quoted 5 lines
drivers/media/i2c/imx219.c +0
-0return 0 ;@@ -1048,35 +1049,36 @@ static int imx219_check_hwcfg(struct device *dev, struct imx219 *imx219)int ret = -EINVAL ;Quoted 7 lines
Quoted 7 lines
drivers/media/i2c/imx219.c static int imx219_check_hwcfg(struct device *dev, struct imx219 *imx219) · line 1053
Quoted 7 lines
drivers/media/i2c/imx219.c +2
-4endpoint =fwnode_graph_get_next_endpoint (dev_fwnode (dev),NULL ); -if (!endpoint) { -dev_err (dev,"endpoint node not found\n" ); -return -EINVAL ; - } +if (!endpoint) +return dev_err_probe (dev, -EINVAL ,"endpoint node not found\n" );Same here, what's the advantage of using
dev_err_probe()when you hardcode the error value to something different than -EPROBE_DEFER ? Same below.Quoted 4 lines
Quoted 4 lines
drivers/media/i2c/imx219.c static int imx219_check_hwcfg(struct device *dev, struct imx219 *imx219) · line 1056
Quoted 4 lines
drivers/media/i2c/imx219.c +1
-1if (v4l2_fwnode_endpoint_alloc_parse (endpoint, &ep_cfg)) { -dev_err (dev,"could not parse endpoint\n" ); +dev_err_probe (dev, -EINVAL ,"could not parse endpoint\n" );This I like even less.
-EINVALis meaningless here, it's not even guaranteed to be the error code that the function will return.Quoted 45 lines
Quoted 45 lines
Quoted 33 lines
drivers/media/i2c/imx219.c +7
-4goto error_out; }/* Check the number of MIPI CSI2 data lanes */ if (ep_cfg.bus.mipi_csi2.num_data_lanes !=2 && ep_cfg.bus.mipi_csi2.num_data_lanes !=4 ) { -dev_err (dev,"only 2 or 4 data lanes are currently supported\n" ); +dev_err_probe (dev, -EINVAL , +"only 2 or 4 data lanes are currently supported\n" ); goto error_out; } imx219->lanes = ep_cfg.bus.mipi_csi2.num_data_lanes;/* Check the link frequency set in device tree */ if (!ep_cfg.nr_of_link_frequencies) { -dev_err (dev,"link-frequency property not found in DT\n" ); +dev_err_probe (dev, -EINVAL , +"link-frequency property not found in DT\n" ); goto error_out; }if (ep_cfg.nr_of_link_frequencies !=1 || (ep_cfg.link_frequencies[0 ] != ((imx219->lanes ==2 ) ?IMX219_DEFAULT_LINK_FREQ :IMX219_DEFAULT_LINK_FREQ_4LANE ))) { -dev_err (dev,"Link frequency not supported: %lld\n" , - ep_cfg.link_frequencies[0 ]); +dev_err_probe (dev, -EINVAL , +"Link frequency not supported: %lld\n" , + ep_cfg.link_frequencies[0 ]); goto error_out; }drivers/media/i2c/imx219.c static int imx219_probe(struct i2c_client *client) · line 1115
Quoted 9 lines
drivers/media/i2c/imx219.c +2
-3@@ -1108,30 +1110,27 @@ static int imx219_probe(struct i2c_client *client) imx219->regmap =devm_cci_regmap_init_i2c (client,16 );if (IS_ERR (imx219->regmap)) { - ret =PTR_ERR (imx219->regmap); -dev_err (dev,"failed to initialize CCI: %d\n" , ret); -return ret; +return dev_err_probe (dev,PTR_ERR (imx219->regmap), +"failed to initialize CCI\n" ); }ditto
Quoted 1 line
Quoted 7 lines
Quoted 7 lines
drivers/media/i2c/imx219.c static int imx219_probe(struct i2c_client *client) · line 1121
Quoted 7 lines
/* Get system clock (xclk) */ imx219->xclk = devm_clk_get(dev, NULL); if (IS_ERR(imx219->xclk)) {drivers/media/i2c/imx219.c +2
-2-dev_err (dev,"failed to get xclk\n" ); -return PTR_ERR (imx219->xclk); +return dev_err_probe (dev,PTR_ERR (imx219->xclk), +"failed to get xclk\n" );This change makes sense, the clock provider may not have probed yet (even if it's quite unlikely).
Quoted 16 lines
Quoted 16 lines
Quoted 1 line
}ditto
drivers/media/i2c/imx219.c static int imx219_probe(struct i2c_client *client) · line 1129
Quoted 10 lines
imx219->xclk_freq = clk_get_rate(imx219->xclk); if (imx219->xclk_freq != IMX219_XCLK_FREQ) {drivers/media/i2c/imx219.c +3
-3-dev_err (dev,"xclk frequency not supported: %d Hz\n" , - imx219->xclk_freq); -return -EINVAL ; +return dev_err_probe (dev, -EINVAL , +"xclk frequency not supported: %d Hz\n" , + imx219->xclk_freq); }ditto
Quoted 1 line
Quoted 7 lines
Quoted 7 lines
drivers/media/i2c/imx219.c static int imx219_probe(struct i2c_client *client) · line 1133
Quoted 7 lines
ret = imx219_get_regulators(imx219);drivers/media/i2c/imx219.c +2
-4-if (ret) { -dev_err (dev,"failed to get regulators\n" ); -return ret; - } +if (ret) +return dev_err_probe (dev, ret,"failed to get regulators\n" );Same here.
Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
/* Request optional enable pin */ imx219->reset_gpio = devm_gpiod_get_optional(dev, "reset",drivers/media/i2c/imx219.c +4
-3@@ -1183,20 +1182,21 @@ static int imx219_probe(struct i2c_client *client) ret =media_entity_pads_init (&imx219->sd.entity,1 , &imx219->pad);if (ret) { -dev_err (dev,"failed to init entity pads: %d\n" , ret); +dev_err_probe (dev, ret,"failed to init entity pads\n" ); goto error_handler_free; } imx219->sd.state_lock = imx219->ctrl_handler.lock; ret =v4l2_subdev_init_finalize (&imx219->sd);if (ret <0 ) { -dev_err (dev,"subdev init error: %d\n" , ret); +dev_err_probe (dev, ret,"subdev init error\n" ); goto error_media_entity; } ret =v4l2_async_register_subdev_sensor (&imx219->sd);if (ret <0 ) { -dev_err (dev,"failed to register sensor sub-device: %d\n" , ret); +dev_err_probe (dev, ret, +"failed to register sensor sub-device\n" ); goto error_subdev_cleanup; }
Hi Umang,
Quoted 35 lines · Umang Jain
Quoted 18 lines · Laurent Pinchart
Quoted 17 lines · Umang Jain
Quoted 16 lines · Tommaso Merciai
Quoted 15 lines · Umang Jain
Drop
dev_err()and use thedev_err_probe()helper on probe path.No functional changes intended.
Signed-off-by Umang Jain <[email protected]>--- drivers/media/i2c/imx219.c | 64 +++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 32 deletions(-)drivers/media/i2c/imx219.c +0
-0@@ -551,8 +551,9 @@ static int imx219_init_controls(struct imx219 *imx219)Quoted 10 lines
Quoted 7 lines
Quoted 7 lines
drivers/media/i2c/imx219.c static int imx219_init_controls(struct imx219 *imx219) · line 556
Quoted 7 lines
drivers/media/i2c/imx219.c +3
-2if (ctrl_hdlr->error) { ret = ctrl_hdlr->error; -dev_err (&client->dev,"%s control init failed (%d)\n" , - __func__, ret); +dev_err_probe (&client->dev, ret, +"%s control init failed\n" , + __func__);
ctrl_hdlr->errorcan never be -EPROBE_DEFER, isdev_err_probe()really useful here ?is
dev_err_probe()really /only/ about -EPROBE_DEFER ? or allprobe()errors?The documentation is explicitly stating for
dev_Err_probe()
Quoted 8 lines
``` * Note that it is deemed acceptable to use this function for error * prints during probe even if the @err is known to never be -EPROBE_DEFER. * The benefit compared to a normal dev_err() is the standardized format * of the error code and the fact that the error code is returned. * ```
As in so many cases, it's partly a matter of taste :-) When it comes to changes such as
- dev_err(dev, "xclk frequency not supported: %d Hz\n",
- imx219->xclk_freq);
- return -EINVAL;
+ return dev_err_probe(dev, -EINVAL,
+ "xclk frequency not supported: %d Hz\n",
+ imx219->xclk_freq);
I find the resulting less readable. The indentation is higher, you have to look at the parameters to dev_err_probe() to see what is returned (compared to reading "return -EINVAL"), and adding the error code to the printed message also makes the kernel log less as the error code really doesn't need to be printed in this case.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/media/i2c/imx219.c +0
-0goto error; }
[snip]
Signature · 3 lines
Regards, Laurent Pinchart
Hi Laurent,
Quoted 54 lines · Laurent Pinchart
Hi Umang,
Quoted 33 lines · Umang Jain
Quoted 18 lines · Laurent Pinchart
Quoted 17 lines · Umang Jain
Quoted 16 lines · Tommaso Merciai
Quoted 15 lines · Umang Jain
Drop
dev_err()and use thedev_err_probe()helper on probe path.No functional changes intended.
Signed-off-by Umang Jain <[email protected]>--- drivers/media/i2c/imx219.c | 64 +++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 32 deletions(-)drivers/media/i2c/imx219.c +0
-0@@ -551,8 +551,9 @@ static int imx219_init_controls(struct imx219 *imx219)Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
drivers/media/i2c/imx219.c static int imx219_init_controls(struct imx219 *imx219) · line 556
Quoted 7 lines
drivers/media/i2c/imx219.c +3
-2if (ctrl_hdlr->error) { ret = ctrl_hdlr->error; -dev_err (&client->dev,"%s control init failed (%d)\n" , - __func__, ret); +dev_err_probe (&client->dev, ret, +"%s control init failed\n" , + __func__);
ctrl_hdlr->errorcan never be -EPROBE_DEFER, isdev_err_probe()really useful here ?is
dev_err_probe()really /only/ about -EPROBE_DEFER ? or allprobe()errors?The documentation is explicitly stating for
dev_Err_probe()Quoted 8 lines
``` * Note that it is deemed acceptable to use this function for error * prints during probe even if the @err is known to never be -EPROBE_DEFER. * The benefit compared to a normal dev_err() is the standardized format * of the error code and the fact that the error code is returned. * ```As in so many cases, it's partly a matter of taste :-) When it comes to changes such as
drivers/media/i2c/imx219.c +3
-3-dev_err (dev,"xclk frequency not supported: %d Hz\n" , - imx219->xclk_freq); -return -EINVAL ; +return dev_err_probe (dev, -EINVAL , +"xclk frequency not supported: %d Hz\n" , + imx219->xclk_freq);
Quoted 5 lines
I find the resulting less readable. The indentation is higher, you have to look at the parameters to
dev_err_probe()to see what is returned (compared to reading "return-EINVAL"), and adding the error code to the printed message also makes the kernel log less as the error code really doesn't need to be printed in this case.
Indeed, a matter of taste ...
On IMX283 driver, I got the feedback that all probe errors should go via dev_err_probe()
"Make all messages in ->probe() stage to use the same pattern." [1]
For IMX219, (since it's the most appropriate reference driver from framework PoV), I saw that it is not logging through dev_err_probe(), and in such cases hence tried to align with [1]
[1] https://lore.kernel.org/all/CAHp75Vcvvadd6EeTWk2ZDrmtCQzWBV8rOoxNCotzYRRPwecaEA@mail.gmail.com/
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/media/i2c/imx219.c +0
-0goto error; }[snip]
Sakari, there's a question for you below.
Quoted 61 lines · Umang Jain
Quoted 52 lines · Laurent Pinchart
Quoted 33 lines · Umang Jain
Quoted 18 lines · Laurent Pinchart
Quoted 17 lines · Umang Jain
Quoted 16 lines · Tommaso Merciai
Quoted 15 lines · Umang Jain
Drop
dev_err()and use thedev_err_probe()helper on probe path.No functional changes intended.
Signed-off-by Umang Jain <[email protected]>--- drivers/media/i2c/imx219.c | 64 +++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 32 deletions(-)drivers/media/i2c/imx219.c +0
-0@@ -551,8 +551,9 @@ static int imx219_init_controls(struct imx219 *imx219)Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
drivers/media/i2c/imx219.c static int imx219_init_controls(struct imx219 *imx219) · line 556
Quoted 7 lines
drivers/media/i2c/imx219.c +3
-2if (ctrl_hdlr->error) { ret = ctrl_hdlr->error; -dev_err (&client->dev,"%s control init failed (%d)\n" , - __func__, ret); +dev_err_probe (&client->dev, ret, +"%s control init failed\n" , + __func__);
ctrl_hdlr->errorcan never be -EPROBE_DEFER, isdev_err_probe()really useful here ?is
dev_err_probe()really /only/ about -EPROBE_DEFER ? or allprobe()errors?The documentation is explicitly stating for
dev_Err_probe()Quoted 8 lines
``` * Note that it is deemed acceptable to use this function for error * prints during probe even if the @err is known to never be -EPROBE_DEFER. * The benefit compared to a normal dev_err() is the standardized format * of the error code and the fact that the error code is returned. * ```As in so many cases, it's partly a matter of taste :-) When it comes to changes such as
(quoted diff) +3
-3- dev_err(dev, "xclk frequency not supported: %d Hz\n", - imx219->xclk_freq); - return -EINVAL; + return dev_err_probe(dev, -EINVAL, + "xclk frequency not supported: %d Hz\n", + imx219->xclk_freq);Quoted 5 lines
I find the resulting less readable. The indentation is higher, you have to look at the parameters to
dev_err_probe()to see what is returned (compared to reading "return-EINVAL"), and adding the error code to the printed message also makes the kernel log less as the error code really doesn't need to be printed in this case.Indeed, a matter of taste ...
Quoted 8 lines
On IMX283 driver, I got the feedback that all probe errors should go via
dev_err_probe()"Make all messages in ->probe() stage to use the same pattern." [1]
For IMX219, (since it's the most appropriate reference driver from framework PoV), I saw that it is not logging through
dev_err_probe(), and in such cases hence tried to align with [1]
I'd say we should have common guidelines for all sensor drivers. As Sakari is the maintainer here, he can be the judge too :-)
Quoted 6 lines
[1] https://lore.kernel.org/all/CAHp75Vcvvadd6EeTWk2ZDrmtCQzWBV8rOoxNCotzYRRPwecaEA@mail.gmail.com/
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/media/i2c/imx219.c +0
-0goto error; }[snip]
Signature · 3 lines
Regards, Laurent Pinchart
hello
Quoted 66 lines · Laurent Pinchart
Sakari, there's a question for you below.
Quoted 63 lines · Umang Jain
Quoted 52 lines · Laurent Pinchart
Quoted 33 lines · Umang Jain
Quoted 18 lines · Laurent Pinchart
Quoted 17 lines · Umang Jain
Quoted 16 lines · Tommaso Merciai
Quoted 15 lines · Umang Jain
Drop
dev_err()and use thedev_err_probe()helper on probe path.No functional changes intended.
Signed-off-by Umang Jain <[email protected]>--- drivers/media/i2c/imx219.c | 64 +++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 32 deletions(-)drivers/media/i2c/imx219.c +0
-0@@ -551,8 +551,9 @@ static int imx219_init_controls(struct imx219 *imx219)Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
drivers/media/i2c/imx219.c static int imx219_init_controls(struct imx219 *imx219) · line 556
Quoted 7 lines
drivers/media/i2c/imx219.c +3
-2if (ctrl_hdlr->error) { ret = ctrl_hdlr->error; -dev_err (&client->dev,"%s control init failed (%d)\n" , - __func__, ret); +dev_err_probe (&client->dev, ret, +"%s control init failed\n" , + __func__);
ctrl_hdlr->errorcan never be -EPROBE_DEFER, isdev_err_probe()really useful here ?is
dev_err_probe()really /only/ about -EPROBE_DEFER ? or allprobe()errors?The documentation is explicitly stating for
dev_Err_probe()Quoted 8 lines
``` * Note that it is deemed acceptable to use this function for error * prints during probe even if the @err is known to never be -EPROBE_DEFER. * The benefit compared to a normal dev_err() is the standardized format * of the error code and the fact that the error code is returned. * ```As in so many cases, it's partly a matter of taste :-) When it comes to changes such as
(quoted diff) +3
-3- dev_err(dev, "xclk frequency not supported: %d Hz\n", - imx219->xclk_freq); - return -EINVAL; + return dev_err_probe(dev, -EINVAL, + "xclk frequency not supported: %d Hz\n", + imx219->xclk_freq);Quoted 5 lines
I find the resulting less readable. The indentation is higher, you have to look at the parameters to
dev_err_probe()to see what is returned (compared to reading "return-EINVAL"), and adding the error code to the printed message also makes the kernel log less as the error code really doesn't need to be printed in this case.Indeed, a matter of taste ...
On IMX283 driver, I got the feedback that all probe errors should go via
dev_err_probe()
Quoted 7 lines
Quoted 5 lines
"Make all messages in ->probe() stage to use the same pattern." [1]
For IMX219, (since it's the most appropriate reference driver from framework PoV), I saw that it is not logging through
dev_err_probe(), and in such cases hence tried to align with [1]I'd say we should have common guidelines for all sensor drivers. As Sakari is the maintainer here, he can be the judge too :-)
There is also a v2 in case someone has missed it:
https://patchwork.kernel.org/project/linux-media/patch/[email protected]/
Quoted 6 lines
Quoted 6 lines
[1] https://lore.kernel.org/all/CAHp75Vcvvadd6EeTWk2ZDrmtCQzWBV8rOoxNCotzYRRPwecaEA@mail.gmail.com/
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/media/i2c/imx219.c +0
-0goto error; }[snip]
Sakari Ailus
maintainerHi Laurent,
Quoted 67 lines · Laurent Pinchart
Sakari, there's a question for you below.
Quoted 64 lines · Umang Jain
Quoted 52 lines · Laurent Pinchart
Quoted 33 lines · Umang Jain
Quoted 18 lines · Laurent Pinchart
Quoted 17 lines · Umang Jain
Quoted 16 lines · Tommaso Merciai
Quoted 15 lines · Umang Jain
Drop
dev_err()and use thedev_err_probe()helper on probe path.No functional changes intended.
Signed-off-by Umang Jain <[email protected]>--- drivers/media/i2c/imx219.c | 64 +++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 32 deletions(-)drivers/media/i2c/imx219.c +0
-0@@ -551,8 +551,9 @@ static int imx219_init_controls(struct imx219 *imx219)Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
drivers/media/i2c/imx219.c static int imx219_init_controls(struct imx219 *imx219) · line 556
Quoted 7 lines
drivers/media/i2c/imx219.c +3
-2if (ctrl_hdlr->error) { ret = ctrl_hdlr->error; -dev_err (&client->dev,"%s control init failed (%d)\n" , - __func__, ret); +dev_err_probe (&client->dev, ret, +"%s control init failed\n" , + __func__);
ctrl_hdlr->errorcan never be -EPROBE_DEFER, isdev_err_probe()really useful here ?is
dev_err_probe()really /only/ about -EPROBE_DEFER ? or allprobe()errors?The documentation is explicitly stating for
dev_Err_probe()Quoted 8 lines
``` * Note that it is deemed acceptable to use this function for error * prints during probe even if the @err is known to never be -EPROBE_DEFER. * The benefit compared to a normal dev_err() is the standardized format * of the error code and the fact that the error code is returned. * ```As in so many cases, it's partly a matter of taste :-) When it comes to changes such as
(quoted diff) +3
-3- dev_err(dev, "xclk frequency not supported: %d Hz\n", - imx219->xclk_freq); - return -EINVAL; + return dev_err_probe(dev, -EINVAL, + "xclk frequency not supported: %d Hz\n", + imx219->xclk_freq);Quoted 5 lines
I find the resulting less readable. The indentation is higher, you have to look at the parameters to
dev_err_probe()to see what is returned (compared to reading "return-EINVAL"), and adding the error code to the printed message also makes the kernel log less as the error code really doesn't need to be printed in this case.Indeed, a matter of taste ...
On IMX283 driver, I got the feedback that all probe errors should go via
dev_err_probe()
Quoted 8 lines
Quoted 5 lines
"Make all messages in ->probe() stage to use the same pattern." [1]
For IMX219, (since it's the most appropriate reference driver from framework PoV), I saw that it is not logging through
dev_err_probe(), and in such cases hence tried to align with [1]I'd say we should have common guidelines for all sensor drivers. As Sakari is the maintainer here, he can be the judge too :-)
I don't really have much of an opinion. If there's a chance you might have -EPROBE_DEFER, then you should use it, I guess, but it may well be reasonable also otherwise.
Signature · 3 lines
Regards, Sakari Ailus