From patchwork Tue Jun 14 19:34:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 12881520 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7059BC43334 for ; Tue, 14 Jun 2022 19:40:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 72B6C112AA5; Tue, 14 Jun 2022 19:40:02 +0000 (UTC) Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by gabe.freedesktop.org (Postfix) with ESMTPS id EAC37112ABD for ; Tue, 14 Jun 2022 19:40:00 +0000 (UTC) Received: by mail-pf1-x434.google.com with SMTP id e11so9456337pfj.5 for ; Tue, 14 Jun 2022 12:40:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=X4y09CKhEKSaAIT/j96bs/qEeHv9usgEjzmQybc1t0A=; b=CtlXGh7aAuuavGs8UilVy+VnypIwaHyMERCE9mfQ1Fz7il/9JQIR0SPkAP4hwFL5Hs J1PBuztOxKvrn96WWxvUtSLLgzGBgW0O/eBxDI8hApvB3OFqKs6tu6NkWNyEBm01bEJ6 vTvpfF/WlT+TQTbOinp9WKfXfAN2cjuRM4Gvc= 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=X4y09CKhEKSaAIT/j96bs/qEeHv9usgEjzmQybc1t0A=; b=Q3QEl7XmqPsA665vM4bbLdEc7mkUQcT3ecy72/NVKEKDziuYBgcjMFmaiYs/iZ+a/K GjmvTEifKAiQMS9bGFO6OcSKjpXSgaYIeMmXf8V2f+9VRlLAVk2S9ktMWIvXtgzJX21I Epv1VwX5v+p+h6Gfr+EzIXX4bXDqTH0QHPsqweHj2fMmcD8ketBfIyFfyDbDZyudioPu PH2rUOwLYKmPg0NRjQIGe1BCSSeJwRATpt3G60wi6AH2KUTcSW2PfBBwH1EE0RWW8yES 1d+/oXlGcew2MCvXoBHhq52b4beeE1ABlDPBpWHElhzmVrgM0wVrqhjzTirbJPXuxVCi sPvA== X-Gm-Message-State: AOAM5308UxyMLNMUhU/3BP3YiMLTtQYsk/jexknAKaMHda34Vn5/vhXr jAqfyKI6FWeLlDwxHWpcRCOSwb3uf/vXjA== X-Google-Smtp-Source: ABdhPJzdtJZrWEATlgJ1gB9krYfHIvQVtDgAhv2CpgRMXIVNfK1xIMMGtDzKVDhTGWvEy8euHjofEA== X-Received: by 2002:a63:8b4b:0:b0:3fc:ea73:db40 with SMTP id j72-20020a638b4b000000b003fcea73db40mr5698179pge.399.1655235600547; Tue, 14 Jun 2022 12:40:00 -0700 (PDT) Received: from pmalani.c.googlers.com.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id l21-20020a17090a409500b001df3a251cc2sm10014426pjg.4.2022.06.14.12.39.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jun 2022 12:39:59 -0700 (PDT) From: Prashant Malani To: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH v3 2/7] usb: typec: mux: Add CONFIG guards for functions Date: Tue, 14 Jun 2022 19:34:36 +0000 Message-Id: <20220614193558.1163205-3-pmalani@chromium.org> X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog In-Reply-To: <20220614193558.1163205-1-pmalani@chromium.org> References: <20220614193558.1163205-1-pmalani@chromium.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: heikki.krogerus@linux.intel.com, Andrzej Hajda , Neil Armstrong , David Airlie , "open list:DRM DRIVERS" , Laurent Pinchart , Krzysztof Kozlowski , Sam Ravnborg , kernel test robot , Jernej Skrabec , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Thomas Zimmermann , =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_Prado?= , Jonas Karlman , swboyd@chromium.org, Pin-Yen Lin , Rob Herring , Maxime Ripard , Hsin-Yi Wang , Xin Ji , Greg Kroah-Hartman , Robert Foss , Prashant Malani , =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" There are some drivers that can use the Type C mux API, but don't have to. Introduce CONFIG guards for the mux functions so that drivers can include the header file and not run into compilation errors on systems which don't have CONFIG_TYPEC enabled. When CONFIG_TYPEC is not enabled, the Type C mux functions will be stub versions of the original calls. Reported-by: kernel test robot Reviewed-by: NĂ­colas F. R. A. Prado Tested-by: NĂ­colas F. R. A. Prado Signed-off-by: Prashant Malani --- Changes since v2: - Fix up return types for some of the stubs. Remove 1 unnecessary stub in the else condition. - Remove unnecessary IS_MODULE config guard. - Added Reviewed-by and Tested-by tags. Changes since v1: - Added static inline to stub functions. - Updated function signature of stub functions from "struct typec_mux" to "struct typec_mux_dev" in accordance with updates from commit 713fd49b430c ("usb: typec: mux: Introduce indirection") include/linux/usb/typec_mux.h | 44 ++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/include/linux/usb/typec_mux.h b/include/linux/usb/typec_mux.h index ee57781dcf28..9292f0e07846 100644 --- a/include/linux/usb/typec_mux.h +++ b/include/linux/usb/typec_mux.h @@ -58,17 +58,13 @@ struct typec_mux_desc { void *drvdata; }; +#if IS_ENABLED(CONFIG_TYPEC) + struct typec_mux *fwnode_typec_mux_get(struct fwnode_handle *fwnode, const struct typec_altmode_desc *desc); void typec_mux_put(struct typec_mux *mux); int typec_mux_set(struct typec_mux *mux, struct typec_mux_state *state); -static inline struct typec_mux * -typec_mux_get(struct device *dev, const struct typec_altmode_desc *desc) -{ - return fwnode_typec_mux_get(dev_fwnode(dev), desc); -} - struct typec_mux_dev * typec_mux_register(struct device *parent, const struct typec_mux_desc *desc); void typec_mux_unregister(struct typec_mux_dev *mux); @@ -76,4 +72,40 @@ void typec_mux_unregister(struct typec_mux_dev *mux); void typec_mux_set_drvdata(struct typec_mux_dev *mux, void *data); void *typec_mux_get_drvdata(struct typec_mux_dev *mux); +#else + +static inline struct typec_mux *fwnode_typec_mux_get(struct fwnode_handle *fwnode, + const struct typec_altmode_desc *desc) +{ + return NULL; +} + +static inline void typec_mux_put(struct typec_mux *mux) {} + +static inline int typec_mux_set(struct typec_mux *mux, struct typec_mux_state *state) +{ + return 0; +} + +static inline struct typec_mux_dev * +typec_mux_register(struct device *parent, const struct typec_mux_desc *desc) +{ + return ERR_PTR(-EOPNOTSUPP); +} +static inline void typec_mux_unregister(struct typec_mux_dev *mux) {} + +static inline void typec_mux_set_drvdata(struct typec_mux_dev *mux, void *data) {} +static inline void *typec_mux_get_drvdata(struct typec_mux_dev *mux) +{ + return ERR_PTR(-EOPNOTSUPP); +} + +#endif /* CONFIG_TYPEC */ + +static inline struct typec_mux * +typec_mux_get(struct device *dev, const struct typec_altmode_desc *desc) +{ + return fwnode_typec_mux_get(dev_fwnode(dev), desc); +} + #endif /* __USB_TYPEC_MUX */