From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965222AbcCNNDq (ORCPT ); Mon, 14 Mar 2016 09:03:46 -0400 Received: from hqemgate16.nvidia.com ([216.228.121.65]:13715 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965035AbcCNNDn (ORCPT ); Mon, 14 Mar 2016 09:03:43 -0400 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Mon, 14 Mar 2016 06:02:16 -0700 From: Laxman Dewangan To: CC: , , Laxman Dewangan , Lee Jones Subject: [PATCH V2] regulator: pwm: Prints error number along with detail Date: Mon, 14 Mar 2016 18:20:13 +0530 Message-ID: <1457959813-1982-1-git-send-email-ldewangan@nvidia.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Prints the error number along with error message when any error occurs. This help on getting the reason of failure quickly from log without any code instrument. Signed-off-by: Laxman Dewangan Cc: Lee Jones --- This was part of the series: regulator: pwm: Add supports for multiple instance and voltage linear step But first 2 patches are already applied of this series, creating patch on top of applied patches and resetting the patch count. - Taken care of the comment for error print like it should be "foo: %d\n" style. - Added error number on all possible places. drivers/regulator/pwm-regulator.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/regulator/pwm-regulator.c b/drivers/regulator/pwm-regulator.c index 4689d62..f99a697 100644 --- a/drivers/regulator/pwm-regulator.c +++ b/drivers/regulator/pwm-regulator.c @@ -70,7 +70,7 @@ static int pwm_regulator_set_voltage_sel(struct regulator_dev *rdev, ret = pwm_config(drvdata->pwm, dutycycle, pwm_reg_period); if (ret) { - dev_err(&rdev->dev, "Failed to configure PWM\n"); + dev_err(&rdev->dev, "Failed to configure PWM: %d\n", ret); return ret; } @@ -146,13 +146,13 @@ static int pwm_regulator_set_voltage(struct regulator_dev *rdev, ret = pwm_config(drvdata->pwm, (period / 100) * duty_cycle, period); if (ret) { - dev_err(&rdev->dev, "Failed to configure PWM\n"); + dev_err(&rdev->dev, "Failed to configure PWM: %d\n", ret); return ret; } ret = pwm_enable(drvdata->pwm); if (ret) { - dev_err(&rdev->dev, "Failed to enable PWM\n"); + dev_err(&rdev->dev, "Failed to enable PWM: %d\n", ret); return ret; } drvdata->volt_uV = min_uV; @@ -200,8 +200,7 @@ static int pwm_regulator_init_table(struct platform_device *pdev, if ((length < sizeof(*duty_cycle_table)) || (length % sizeof(*duty_cycle_table))) { - dev_err(&pdev->dev, - "voltage-table length(%d) is invalid\n", + dev_err(&pdev->dev, "voltage-table length(%d) is invalid\n", length); return -EINVAL; } @@ -214,7 +213,7 @@ static int pwm_regulator_init_table(struct platform_device *pdev, (u32 *)duty_cycle_table, length / sizeof(u32)); if (ret) { - dev_err(&pdev->dev, "Failed to read voltage-table\n"); + dev_err(&pdev->dev, "Failed to read voltage-table: %d\n", ret); return ret; } @@ -277,16 +276,18 @@ static int pwm_regulator_probe(struct platform_device *pdev) drvdata->pwm = devm_pwm_get(&pdev->dev, NULL); if (IS_ERR(drvdata->pwm)) { - dev_err(&pdev->dev, "Failed to get PWM\n"); - return PTR_ERR(drvdata->pwm); + ret = PTR_ERR(drvdata->pwm); + dev_err(&pdev->dev, "Failed to get PWM: %d\n", ret); + return ret; } regulator = devm_regulator_register(&pdev->dev, &drvdata->desc, &config); if (IS_ERR(regulator)) { - dev_err(&pdev->dev, "Failed to register regulator %s\n", - drvdata->desc.name); - return PTR_ERR(regulator); + ret = PTR_ERR(regulator); + dev_err(&pdev->dev, "Failed to register regulator %s: %d\n", + drvdata->desc.name, ret); + return ret; } return 0; -- 2.1.4