Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp601050iol; Thu, 9 Jun 2022 09:51:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwm8DoAV0nCYlEEdkpqj5o27nQLBDhHJiuUJqiaP0MnqfODRctNG+wStHREHO+x3OMnJcWA X-Received: by 2002:a17:906:4482:b0:70a:19e3:d18a with SMTP id y2-20020a170906448200b0070a19e3d18amr35291116ejo.510.1654793513904; Thu, 09 Jun 2022 09:51:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654793513; cv=none; d=google.com; s=arc-20160816; b=sQNnt7TwZcpv8S5Mu6LV5xsY6GmxTFQw7D0G46/oxSUGstGQMTqlusMTFz0rZ3PCkM agnkQWaNYuEc0XLQUDxZRZcYYxJ1xboCyEy6D/56/4PXGM08mjNv4UxZPW8XotNrw2Db vYwKl4SqRrTKxD3S0mG1kDhGrSFOp0Jlm6pBsaIuHrGMsrumZWUoPXsiFTlvzUHjXVpD uQ3ZkNLcmU6Cy0JXI99nPZRPKS9jga+Kx2UGPsqKbazKJMevnyLiOvYRkw8hLvpxKu3G arNcM+TWcgBfF9K9tXlqZLdYhJBV2JiA1w5GT+WEQ2tF1gU3HbV3+aXqqZSVQfzU5lEd kglg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=8/ZGqYW6QZOiASHgqEUWYsuHRI/HUXu4MWiqwZ129YM=; b=l20VtoqbxkyY2qb9A3QsdyUow6S0I1MxWqVuYX6UBicqS5z0MJtpaLlt+xOH8XNIaT HIbn7kMLTmdzgqFRSVI5qIqIMNL98LM+3M4SE6nTGtVgZxnB/YrNbZoNbvzYKmzbKxiT uETwjVlTDsjUz54CSxVSl6DUDllx11kZHOo8Zfo35AzSW9VlYCR4xDNxiM4QUwlYWa3Q vbf9BYxjHujEdMkE/saZQg1g2/wqCygx6RhphNFOg1g8OguoILcHSuc9e/2jJNNqOW1i HwbO19EYq7snrU0x+QE5ppU1kZnm5JVJL0LcqIFoD0ePoyA/Itzde4yf0xX3KtLOc6GE p7Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gLIGGLh8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nc26-20020a1709071c1a00b007117f5643e4si16041926ejc.944.2022.06.09.09.51.27; Thu, 09 Jun 2022 09:51:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gLIGGLh8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244774AbiFIQWi (ORCPT + 99 others); Thu, 9 Jun 2022 12:22:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235171AbiFIQWh (ORCPT ); Thu, 9 Jun 2022 12:22:37 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE64E3AA; Thu, 9 Jun 2022 09:22:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654791756; x=1686327756; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=YWfsZPP8YET9e13ubK9QXgx+cvFXScE1tK7NBcbgUwg=; b=gLIGGLh8oMBZHR0zMpCsqcWqmFVdVOE9SyGfz2ad1Hz2y1+J/L+fVuvn gsAcT1PqPt+q3oKHjgFM+HPUiKGeNae2e9gJ585aOaXTLVhgENB0r7pYY 4FIkeW+rdiNDsh+ij/4uK2B28uLtPxXIoP1QD36+BIa6q+BMUydM37mK7 iq3wy9nthffRSlMeaJrg2KkoYjvnM9TIfMqP3dRVSTulnT5CSs5+WOmOX vRf+6X/qBKxny28Zn4xRLW/g+Ksd/N1Vnmnl1Dw4t7uxa5M7MqmrmIBIj cW/DeZ4+x7r6coYGi9oUmEVZaV7+0D7zxTZ1IVHHMQzGUt5AMPH+Gutbq g==; X-IronPort-AV: E=McAfee;i="6400,9594,10373"; a="277364147" X-IronPort-AV: E=Sophos;i="5.91,287,1647327600"; d="scan'208";a="277364147" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2022 09:22:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,287,1647327600"; d="scan'208";a="585661841" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 09 Jun 2022 09:22:34 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 73BA1F8; Thu, 9 Jun 2022 19:22:38 +0300 (EEST) From: Andy Shevchenko To: Denis Osterland-Heim , Andy Shevchenko , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Pavel Machek Subject: [PATCH v1 1/1] leds: core: Refactor led_update_brightness() to use standard pattern Date: Thu, 9 Jun 2022 19:22:33 +0300 Message-Id: <20220609162233.80498-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The standard conditional pattern is to check for errors first and bail out if any. Refactor led_update_brightness() accordingly. While at it, drop unneeded assignment and return 0 unconditionally on success. Signed-off-by: Andy Shevchenko --- drivers/leds/led-core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c index 4a97cb745788..96a2817712e5 100644 --- a/drivers/leds/led-core.c +++ b/drivers/leds/led-core.c @@ -304,17 +304,17 @@ EXPORT_SYMBOL_GPL(led_set_brightness_sync); int led_update_brightness(struct led_classdev *led_cdev) { - int ret = 0; + int ret; if (led_cdev->brightness_get) { ret = led_cdev->brightness_get(led_cdev); - if (ret >= 0) { - led_cdev->brightness = ret; - return 0; - } + if (ret < 0) + return ret; + + led_cdev->brightness = ret; } - return ret; + return 0; } EXPORT_SYMBOL_GPL(led_update_brightness); -- 2.35.1