Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8CE20C433F5 for ; Wed, 22 Dec 2021 17:11:59 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4F602830A9; Wed, 22 Dec 2021 18:11:43 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="E+KTHgEj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 326D78305C; Wed, 22 Dec 2021 18:11:38 +0100 (CET) Received: from mail-qt1-x832.google.com (mail-qt1-x832.google.com [IPv6:2607:f8b0:4864:20::832]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id AB396830F5 for ; Wed, 22 Dec 2021 18:11:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qt1-x832.google.com with SMTP id a1so2496136qtx.11 for ; Wed, 22 Dec 2021 09:11:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=N613nvUuYnvJWC6ffaIXNChwY5a9Yc9dhk5tcJkKLZY=; b=E+KTHgEjveKtn1FpBVdtcm7wbK9xgCmJMGZ/Dk3YpAAKWQJBTIGrOkzipfeyxkI+9W E2GiRJvBRbRZpQQJW/VAdDeIlNxn/QQxo2W+A5dPSHE/qH4AAN9qUKlaO4qN94J1Jipn /ViKmHwpCRqvvoBcntxiYZ0h9iLA9vq0wo4SpT6hrF6LtaxTPS7vhi2ZAb7U9lfvAN7g ccrFrOktan70++q55FOpdNutwMtW4hqT4qru322xu96xO57GE+BVI62AkPNAlRd64x94 Vwd138g9itQPiVWiJseRxRiQOfiktMDhK5FdYhV8/cY4Ux50PL7Db2nYSUzmaEDSGRoZ Eofg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=N613nvUuYnvJWC6ffaIXNChwY5a9Yc9dhk5tcJkKLZY=; b=g0+lLvSF8BmIGiaAmbWWFZxfFRFC7WRJeezVla5C5v2SKzkOo4/Iuy/CPy6h6iHNdR DRM9Ostj3im+cIfj7qX4IVYgcgoSMhjzbNDyWorrY+zgD/SV/6IX3dOquktVsoy6TLGW Xv5ecR5bQ8o6CfuJUK1Hdet5QfeSFJLoOJYrr3Qxy+uNX0U6gQMJw7SrfHICPr/G0NJc ftJUUsNKVsewsgHq8NC/32H6voV3EY59aQJE1PtKBilJ2J6x0rALXgcUoGZR9r5lKJQR hFNLh4QLyta7T0UtElXFcjixw5n7L1wIbs+vuGnzMXPFLy3Rm9O8tgD5jqjigRFT3vcY h7wQ== X-Gm-Message-State: AOAM530BOzsXm7JVDCHJ9rwdIhgy0yhRu6OnMijuA0+S2TP+ZspuR4ah 9Ehwmc9uYW0Dn2xPdowKCc8fGLSJw2o= X-Google-Smtp-Source: ABdhPJy+/hC+8k66wxPW10Mih/QdWB1OC2tba4+ttg/9ue7PcUCYK36yptRGGEXHo5KOsmbknIFecQ== X-Received: by 2002:a05:622a:43:: with SMTP id y3mr2846568qtw.192.1640193089347; Wed, 22 Dec 2021 09:11:29 -0800 (PST) Received: from godwin.fios-router.home (pool-108-18-207-184.washdc.fios.verizon.net. [108.18.207.184]) by smtp.gmail.com with ESMTPSA id j21sm2099609qkk.27.2021.12.22.09.11.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Dec 2021 09:11:29 -0800 (PST) From: Sean Anderson To: u-boot@lists.denx.de Cc: Simon Glass , Lukasz Majewski , Dario Binacchi , Sean Anderson Subject: [PATCH v2 2/5] clk: Inline clk_get_*_optional Date: Wed, 22 Dec 2021 12:11:11 -0500 Message-Id: <20211222171114.3091780-3-seanga2@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211222171114.3091780-1-seanga2@gmail.com> References: <20211222171114.3091780-1-seanga2@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean The optional varients of clk_get_* functions are just simple wrappers. Reduce code size a bit by inlining them. On platforms where it is not used (most of them), it will not be compiled in any more. On platforms where they are used, the inlined branch should not cause any significant growth. Signed-off-by: Sean Anderson --- (no changes since v1) drivers/clk/clk-uclass.c | 22 --------------- include/clk.h | 58 ++++++++++++++++++++++++---------------- 2 files changed, 35 insertions(+), 45 deletions(-) diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c index 0ee9a38b15..5e9749a75b 100644 --- a/drivers/clk/clk-uclass.c +++ b/drivers/clk/clk-uclass.c @@ -432,18 +432,6 @@ int clk_get_by_name_nodev(ofnode node, const char *name, struct clk *clk) return clk_get_by_index_nodev(node, index, clk); } -int clk_get_by_name_nodev_optional(ofnode node, const char *name, - struct clk *clk) -{ - int ret; - - ret = clk_get_by_name_nodev(node, name, clk); - if (ret == -ENODATA) - return 0; - - return ret; -} - int clk_release_all(struct clk *clk, int count) { int i, ret; @@ -824,16 +812,6 @@ struct clk *devm_clk_get(struct udevice *dev, const char *id) return clk; } -struct clk *devm_clk_get_optional(struct udevice *dev, const char *id) -{ - struct clk *clk = devm_clk_get(dev, id); - - if (PTR_ERR(clk) == -ENODATA) - return NULL; - - return clk; -} - void devm_clk_put(struct udevice *dev, struct clk *clk) { int rc; diff --git a/include/clk.h b/include/clk.h index 57c6707a55..82c763d03f 100644 --- a/include/clk.h +++ b/include/clk.h @@ -193,22 +193,6 @@ int clk_get_by_name(struct udevice *dev, const char *name, struct clk *clk); */ int clk_get_by_name_nodev(ofnode node, const char *name, struct clk *clk); -/** - * clk_get_by_name_nodev_optional - Get/request an optinonal clock by name - * without a device. - * @node: The client ofnode. - * @name: The name of the clock to request. - * @name: The name of the clock to request, within the client's list of - * clocks. - * @clock: A pointer to a clock struct to initialize. - * - * Behaves the same as clk_get_by_name_nodev() except where there is - * no clock producer, in this case, skip the error number -ENODATA, and - * the function returns 0. - */ -int clk_get_by_name_nodev_optional(ofnode node, const char *name, - struct clk *clk); - /** * devm_clk_get - lookup and obtain a managed reference to a clock producer. * @dev: device for clock "consumer" @@ -238,7 +222,16 @@ struct clk *devm_clk_get(struct udevice *dev, const char *id); * Behaves the same as devm_clk_get() except where there is no clock producer. * In this case, instead of returning -ENOENT, the function returns NULL. */ -struct clk *devm_clk_get_optional(struct udevice *dev, const char *id); +static inline struct clk *devm_clk_get_optional(struct udevice *dev, + const char *id) +{ + struct clk *clk = devm_clk_get(dev, id); + + if (PTR_ERR(clk) == -ENODATA) + return NULL; + + return clk; +} /** * clk_release_all() - Disable (turn off)/Free an array of previously @@ -291,18 +284,37 @@ clk_get_by_name_nodev(ofnode node, const char *name, struct clk *clk) return -ENOSYS; } -static inline int -clk_get_by_name_nodev_optional(ofnode node, const char *name, struct clk *clk) -{ - return -ENOSYS; -} - static inline int clk_release_all(struct clk *clk, int count) { return -ENOSYS; } #endif +/** + * clk_get_by_name_nodev_optional - Get/request an optinonal clock by name + * without a device. + * @node: The client ofnode. + * @name: The name of the clock to request. + * @name: The name of the clock to request, within the client's list of + * clocks. + * @clock: A pointer to a clock struct to initialize. + * + * Behaves the same as clk_get_by_name_nodev() except where there is + * no clock producer, in this case, skip the error number -ENODATA, and + * the function returns 0. + */ +static inline int clk_get_by_name_nodev_optional(ofnode node, const char *name, + struct clk *clk) +{ + int ret; + + ret = clk_get_by_name_nodev(node, name, clk); + if (ret == -ENODATA) + return 0; + + return ret; +} + /** * enum clk_defaults_stage - What stage clk_set_defaults() is called at * @CLK_DEFAULTS_PRE: Called before probe. Setting of defaults for clocks owned -- 2.33.0