Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2579373rdg; Mon, 16 Oct 2023 08:31:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEA/8EGj7rbvKsDrQ9uu51rnOyD1YErWhQ7zkJT4Sq8acYO/0x7O1OyqQK2PV3PiqY1ThqC X-Received: by 2002:a05:6a20:a121:b0:134:a4e2:4ac8 with SMTP id q33-20020a056a20a12100b00134a4e24ac8mr34089750pzk.39.1697470280459; Mon, 16 Oct 2023 08:31:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697470280; cv=none; d=google.com; s=arc-20160816; b=tIXIcjzaX/sEyOawlza3KOKVwdJaARYh8HrVvH8q88nnxhEhjL+LaMa8u5jENdxQt1 fI9HwKrCUaiqmjtSDQ9MugDnsIvJlmm58cfJbW5fqnPfm7aEs357OXtl/hg2LpwYSZXX hMbGLbcfAQkTrbMTPk6dUDk02xdgfwIxB7pJ8y/AuQidKCOT/MqjTDNzc9tfgBWFY5UG bBnBRWYVnqAxNJ9h0QGMAroRqkkGc13ads2MKt/GglJFztWWBsK3lfvzaD5tcOK1HbTM 3B2FjQDfzHCGvK9T6Mj88r6flzl9ddJ3jYBHSwA3R46eJh4/0q38Gcm1N+VmO1cny1vV MFqg== 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=MblyG7AGWJgtk2SwVX1nf24vKreS1s9X0eDbBdaTscY=; fh=ieNU6J2CCMFcjsonbfumoLV8NJC7190bebRui38VHqc=; b=NM/qxkMsxuhHt9QFwlg4I9C3JsKvKLXgrMYQOdIGokqhLrW2mE9y1JCOdQiKOcR/Bb nbWAzsh938+6psppqyxrAl2bTc7dwJ8uVg+Lf88sp1tl6PhgaZZ2c9jFlEzlPJkin8vT XcV2IWlbBejyu9XgRP+sXzmbN5aAvHraJvMkA0HeIwhAzL6Qnwupp8JKqif4fQIHXbrH ZKWd/xnuQvd6itXVeC7/giBUPLTMEdtDVd8IOZcVoYjAbyyk/MU548aWxiZEQS5xAzY5 i350xokPYxzcPRqw/hAfypty67X1P/XVvHMOu6jcAuim2hjMCU128a1sy+ZV9Enie/bA HDRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=New87foo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id m9-20020a17090ab78900b00273dfe0741csi5953577pjr.90.2023.10.16.08.31.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 08:31:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=New87foo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 1AC76805B2BD; Mon, 16 Oct 2023 08:31:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232582AbjJPPbA (ORCPT + 99 others); Mon, 16 Oct 2023 11:31:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231896AbjJPPa6 (ORCPT ); Mon, 16 Oct 2023 11:30:58 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76D24B4; Mon, 16 Oct 2023 08:30:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697470256; x=1729006256; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=RQU8/Zny7LUH+xDdoP1sBFUskYkB9NhPlwDT24YZKrQ=; b=New87fooCZGCPjDieI26pgbQ/3fMznUEs42SeLBDcvEMLov/Wwlrlshr DlszLacHjiaeOFDzHdsgqNiAM7SWumW4Fzvj0UyS3AyDbmb73BfQdVIM1 oN2dv3Gx8PpkCRVB3Ym8JPIFEaaoykVej38B+c0iz1lvHx873gIadL7JI i4tKIXfVaUklhXLwMAqjZkfXDb1i0a164KSyTLZmAZhXrgPAP2NeCYRJc 7OHByQpxC0Cy+BJwefY/717v2ns5MYDjXOllSTZwK27jCI2YRw7Ja5R0b cs4Gl1Nppr1Pvbeog3eYdcU6HJ4Vp82aXfdeC/OCmh24oH+g2JNTqZNhT Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="7121603" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="7121603" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 08:30:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="1002987990" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="1002987990" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 16 Oct 2023 08:30:54 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id CF423385; Mon, 16 Oct 2023 18:30:52 +0300 (EEST) From: Andy Shevchenko To: Hans de Goede , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Pavel Machek , Lee Jones , Andy Shevchenko , Denis Osterland-Heim Subject: [PATCH v2 1/1] leds: core: Refactor led_update_brightness() to use standard pattern Date: Mon, 16 Oct 2023 18:30:51 +0300 Message-Id: <20231016153051.1409074-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 16 Oct 2023 08:31:17 -0700 (PDT) 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. Acked-by: Denis Osterland-Heim Signed-off-by: Andy Shevchenko --- v2: added tag (Denis), Cc'ed to the updated list of LED maintainers 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 2230239283d0..89c9806cc97f 100644 --- a/drivers/leds/led-core.c +++ b/drivers/leds/led-core.c @@ -364,17 +364,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.40.0.1.gaa8946217a0b