From patchwork Mon Oct 16 16:10:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 153523 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp3568218vqb; Mon, 16 Oct 2023 09:11:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IExCEukB+mu+DZLNw3mMFwHIExJOEEcKWWT5+6rDuRLReCwCEUFVXvyCc538DL6YBzm579+ X-Received: by 2002:a05:6a20:4407:b0:133:6e3d:68cd with SMTP id ce7-20020a056a20440700b001336e3d68cdmr47010891pzb.3.1697472661753; Mon, 16 Oct 2023 09:11:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697472661; cv=none; d=google.com; s=arc-20160816; b=T5gINGszV9Gb0iqQm24kl+kkqEY4M/BTrnj1c7E5ODMIHtl13D+WigW5vnI6i16cKC Aiv0senyBVf3XEIzXpVVqQj+q6DILQ7ui065Zi2AoBKPgUSqkgV27dnAqkTowE3SAWae p4Y7tTQjv3XaYTpnwLV69FvHWXn5cZxIfBk46nUan64IknxvZHWcP0JC9Ks4qnjQ5H24 jUyifLkGQqgc5+2klDC3sd8V/F5vM/pL9IwgKo5HQmbXLPfaeTs/DztJxmrQqzeKjCE+ UFKHWBdaxiYcDvbWRhiPF7G7MEWqCYk1y/So9v0qc8nh2z4UhC+f2eI2O4wGKN3R/nRe GHLA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fgaesPHR/7WchPNA9VUk7GRgmHi6eB1eaB+rHpWbNAg=; fh=tUAC4oQq3UuKajr6ZMoB53sspoioCuMU4y0NrDbDhac=; b=XwSS8wdwWejHbkyMwG9PYyTFc13gIuSrrurdoVVUKzVTbgQuWg9qF4OVQYWLAC9+Kl cgyF6lQ2zGNU6h/koYaES1rYMzhmsREsz5Wmr8sWVSAwdcgg5jyStKLguyD+8I/6s71u teQk8Xe33Jo1JkdJjwjGKRPNoHKz8F+T+822YJwmewVTeGpXEDCZH4W7QcONazuKCAOP zoZzTFw/wi68t0JA4R0nw00CyDDmVLflDGHd0vEg4DmMnsnPvf9YWIkpcCsTEPzzR0g+ gO1CLkIT6gLSQ2EOCfwYbdOQb8eLVH+7DieuwQesHSACF1DFPNkD6crfN+xMVPoEciRR JjZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=W6o2Y3Wa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id a17-20020a170902ee9100b001b8ba81d04dsi10675791pld.395.2023.10.16.09.11.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 09:11:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=W6o2Y3Wa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id B96B080B1207; Mon, 16 Oct 2023 09:10:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233799AbjJPQKo (ORCPT + 18 others); Mon, 16 Oct 2023 12:10:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233746AbjJPQKd (ORCPT ); Mon, 16 Oct 2023 12:10:33 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 360C0F2; Mon, 16 Oct 2023 09:10:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697472631; x=1729008631; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cvuQMHb9LmDrcSq69UbNf/WifWB3BY+q2NCKjOo91RU=; b=W6o2Y3WaRlIsFT6xoLxifGUMMYeyxfKpJa4G3qLa9mSLWzmIJKhliTLR DXjkkv2kCRGL3GVo27lNzxQ/DUdpzYV6T5kvqWMTcWX5/a+DKz68rbihZ CEMyUn0+AmWTe3kxlARJ17mnsQRyWVhayftDVYkkmKoYG7vobw9iFWRNZ Jli2hy/O/PVdADyPjR4kQf4axnm8Pet4CkwyCzrcLvllqTtqs1UqJRSUm HUgHGYvl1I7aZnhKxgI7qRwOcVd8yrCDX7YwMYoqCpMZ4nDjpb419aZZL DVfazt2N05Gw8OhlFpIBbWtrz/cUexMVsDCHBCKzmWV19s83hOH29WdVy Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="7132785" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="7132785" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 09:10:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="785123038" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="785123038" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 16 Oct 2023 09:10:10 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 0A927385; Mon, 16 Oct 2023 19:10:08 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Pavel Machek , Lee Jones Subject: [PATCH v1 2/6] leds: gpio: Utilise PTR_ERR_OR_ZERO() Date: Mon, 16 Oct 2023 19:10:01 +0300 Message-Id: <20231016161005.1471768-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20231016161005.1471768-1-andriy.shevchenko@linux.intel.com> References: <20231016161005.1471768-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Mon, 16 Oct 2023 09:10:59 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779929093756335137 X-GMAIL-MSGID: 1779929093756335137 Avoid a boilerplate code by using PTR_ERR_OR_ZERO() in create_gpio_led(). Signed-off-by: Andy Shevchenko --- drivers/leds/leds-gpio.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c index debadb48ceda..4071cb9eefec 100644 --- a/drivers/leds/leds-gpio.c +++ b/drivers/leds/leds-gpio.c @@ -125,16 +125,13 @@ static int create_gpio_led(const struct gpio_led *template, return ret; pinctrl = devm_pinctrl_get_select_default(led_dat->cdev.dev); - if (IS_ERR(pinctrl)) { - ret = PTR_ERR(pinctrl); - if (ret != -ENODEV) { - dev_warn(led_dat->cdev.dev, - "Failed to select %pfw pinctrl: %d\n", - fwnode, ret); - } else { - /* pinctrl-%d not present, not an error */ - ret = 0; - } + ret = PTR_ERR_OR_ZERO(pinctrl); + /* pinctrl-%d not present, not an error */ + if (ret == -ENODEV) + ret = 0; + if (ret) { + dev_warn(led_dat->cdev.dev, "Failed to select %pfw pinctrl: %d\n", + fwnode, ret); } return ret;