Re: [PATCH 14/15] usb: typec: tcpm/tcpci_maxim: convert to dev_err_probe()

From: Heikki Krogerus
Date: Wed Jul 31 2024 - 08:44:50 EST


On Wed, Jul 10, 2024 at 11:36:21AM +0100, André Draszik wrote:
> dev_err_probe() exists as a useful helper ensuring standardized
> error messages during .probe() and using it also helps to make
> the code more legible.
>
> Use it.
>
> Signed-off-by: André Draszik <andre.draszik@xxxxxxxxxx>

Reviewed-by: Heikki Krogerus <heikki.krogerus@xxxxxxxxxxxxxxx>

> ---
> drivers/usb/typec/tcpm/tcpci_maxim_core.c | 21 +++++++++++----------
> 1 file changed, 11 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/usb/typec/tcpm/tcpci_maxim_core.c b/drivers/usb/typec/tcpm/tcpci_maxim_core.c
> index 5b5441db7047..ee3e86797f17 100644
> --- a/drivers/usb/typec/tcpm/tcpci_maxim_core.c
> +++ b/drivers/usb/typec/tcpm/tcpci_maxim_core.c
> @@ -484,17 +484,17 @@ static int max_tcpci_probe(struct i2c_client *client)
>
> chip->client = client;
> chip->data.regmap = devm_regmap_init_i2c(client, &max_tcpci_regmap_config);
> - if (IS_ERR(chip->data.regmap)) {
> - dev_err(&client->dev, "Regmap init failed\n");
> - return PTR_ERR(chip->data.regmap);
> - }
> + if (IS_ERR(chip->data.regmap))
> + return dev_err_probe(&client->dev, PTR_ERR(chip->data.regmap),
> + "Regmap init failed\n");
>
> chip->dev = &client->dev;
> i2c_set_clientdata(client, chip);
>
> ret = max_tcpci_read8(chip, TCPC_POWER_STATUS, &power_status);
> if (ret < 0)
> - return ret;
> + return dev_err_probe(&client->dev, ret,
> + "Failed to read TCPC_POWER_STATUS\n");
>
> /* Chip level tcpci callbacks */
> chip->data.set_vbus = max_tcpci_set_vbus;
> @@ -511,10 +511,10 @@ static int max_tcpci_probe(struct i2c_client *client)
>
> max_tcpci_init_regs(chip);
> chip->tcpci = tcpci_register_port(chip->dev, &chip->data);
> - if (IS_ERR(chip->tcpci)) {
> - dev_err(&client->dev, "TCPCI port registration failed\n");
> - return PTR_ERR(chip->tcpci);
> - }
> + if (IS_ERR(chip->tcpci))
> + return dev_err_probe(&client->dev, PTR_ERR(chip->tcpci),
> + "TCPCI port registration failed\n");
> +
> chip->port = tcpci_get_tcpm_port(chip->tcpci);
> ret = max_tcpci_init_alert(chip, client);
> if (ret < 0)
> @@ -526,7 +526,8 @@ static int max_tcpci_probe(struct i2c_client *client)
> unreg_port:
> tcpci_unregister_port(chip->tcpci);
>
> - return ret;
> + return dev_err_probe(&client->dev, ret,
> + "Maxim TCPCI driver initialization failed\n");
> }
>
> static void max_tcpci_remove(struct i2c_client *client)
>
> --
> 2.45.2.803.g4e1b14247a-goog

--
heikki