From patchwork Mon Mar 23 09:14:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis OSTERLAND-HEIM X-Patchwork-Id: 209135 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.1 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4688C4332B for ; Mon, 23 Mar 2020 09:14:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 70CDC2076A for ; Mon, 23 Mar 2020 09:14:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=diehl.com header.i=@diehl.com header.b="aIuTbsNZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727650AbgCWJOP (ORCPT ); Mon, 23 Mar 2020 05:14:15 -0400 Received: from enterprise02.smtp.diehl.com ([193.201.238.220]:42738 "EHLO enterprise02.smtp.diehl.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726037AbgCWJOO (ORCPT ); Mon, 23 Mar 2020 05:14:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=diehl.com; i=@diehl.com; q=dns/txt; s=default; t=1584954853; x=1616490853; h=from:to:cc:subject:date:message-id: content-transfer-encoding:mime-version; bh=h7MKj78br5bevc3yJERvh6RsXRecxwNZwY4L0iEdVf4=; b=aIuTbsNZLK1a6c223o6GaBHgKLZwWsjZd2mCbwbXnENQBIVTnpj7YUuk mDdnNkX6/nGzxhkuvz2xgcY5zQokwPY51FA0nvf6ECL6JQeY4RPU2nUpM 5OOk/UA5K3hcK51Fh7dOI1w/AOSxBXzmY2AWbQvKhsHgZk1MkHctxrLFc wsQazS1f++4BrI6VI9ia7M/+iQoF49Wu2bXFShQ7yjtPAQPXhzRXR3pi2 ZK9CNN0gdxvrgs71HTg+FkrfkB9O4uewKn7/FnMsZhwhaWuyAftKbq7Qs pPp5UPVklsk7rzhcQmSCnUHsab0cRipBpPjiTK4ohAv/eh7IPjv3sdI+X g==; IronPort-SDR: g5HfhDMrrz1UuX2EFDd4yK5bLf6CtNaXsx6gi8mgZ5IxtnAu69WKRaNgZrPfTnYxgn2CZVQKcq 9VIIfEVa12fQ== From: Denis Osterland-Heim To: "dmurphy@ti.com" , "pavel@ucw.cz" , "jacek.anaszewski@gmail.com" CC: Denis Osterland-Heim , "linux-leds@vger.kernel.org" Subject: [PATCH v4] leds: pwm: check result of led_pwm_set() in led_pwm_add() Thread-Topic: [PATCH v4] leds: pwm: check result of led_pwm_set() in led_pwm_add() Thread-Index: AQHWAPNprlb/rYMY0E2oDLJ9oUB47g== Date: Mon, 23 Mar 2020 09:14:10 +0000 Message-ID: <20200323091243.23140-1-Denis.Osterland@diehl.com> Accept-Language: de-DE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: Evolution 3.28.5-0ubuntu0.18.04.1 x-ms-exchange-messagesentrepresentingtype: 1 MIME-Version: 1.0 X-TrailerSkip: 1 X-GBS-PROC: byQFdw3ukCM+zy1/poiPc1XB7Els37C/Owm81uvOshzceWBsb8FY77IDpYY/3EM1 Sender: linux-leds-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org led_pwm_set() now returns an error when setting the PWM fails. Signed-off-by: Denis Osterland-Heim --- drivers/leds/leds-pwm.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c index 6caf8bea8cd5..07eab2d8b7c7 100644 --- a/drivers/leds/leds-pwm.c +++ b/drivers/leds/leds-pwm.c @@ -91,15 +91,21 @@ static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv, pwm_init_state(led_data->pwm, &led_data->pwmstate); ret = devm_led_classdev_register(dev, &led_data->cdev); - if (ret == 0) { - priv->num_leds++; - led_pwm_set(&led_data->cdev, led_data->cdev.brightness); - } else { + if (ret) { dev_err(dev, "failed to register PWM led for %s: %d\n", led->name, ret); + return ret; } - return ret; + ret = led_pwm_set(&led_data->cdev, led_data->cdev.brightness); + if (ret) { + dev_err(dev, "failed to set led PWM value for %s: %d", + led->name, ret); + return ret; + } + + priv->num_leds++; + return 0; } static int led_pwm_create_fwnode(struct device *dev, struct led_pwm_priv *priv)