From patchwork Tue Jun 7 19:00:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 12872474 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 132B7C433EF for ; Tue, 7 Jun 2022 21:42:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381159AbiFGVj7 (ORCPT ); Tue, 7 Jun 2022 17:39:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380874AbiFGVif (ORCPT ); Tue, 7 Jun 2022 17:38:35 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96A66C045E for ; Tue, 7 Jun 2022 12:05:33 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id u2so16323669pfc.2 for ; Tue, 07 Jun 2022 12:05:33 -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=zrwToAbRm/8o4mYKXHsvwuZsdzi56cDWjWGCsMFQCq4=; b=IJmEKjbu0NsIQ2TIKKHgQBPdu95rE+fxg/uNfUr8lhMeiyM3S3ZNsC45sqxk/R9FaT /r8eY4OIvLSDUSY2xX5aGB0rM79qaZ0k5s1ANX+OWkeNYD2rYOnI8ALWyLGqAVuXsJB6 i/HNUOWDOs5Bk+bD/8AV47NIeWcKF4/IUypi8= 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=zrwToAbRm/8o4mYKXHsvwuZsdzi56cDWjWGCsMFQCq4=; b=dhYK0eNgFGjV6aVCgU1KIfyWXjpVW3A6gXvI4h7W+cV7gdFW5/QXU+cZePMpXmxzTl WvH0QN9c0swWtlXL+86Dm0gj15FiLQYR/+yoHZFHlHu0xOYKrLa8eKiHnzrFLfYGV4cQ mB5+H2fj7nb1Ggmmnx4xe0RnwCTGSzdevAPAWD8V8ehCYa51qU4ZHs4oKRvjD460tzoS FW3xLwzbPFz+zAMU3PDFbz3IFn6Q4ctemiDAUMNBtw0EFlCHEcHM+bKKEJ6jwKJd9OLq N2b7PndM+fbi2UyXQnKVjuHICZcln8DhppjBPNfLQNI+AWvBVSFbMQrW6Uh0FPHHVEow 31sA== X-Gm-Message-State: AOAM532mG5k5E+wwXPeg2yI2+cqQ2mnz31aKlyM5YgOMbdbNs4uCeXlj /Hxkm6t1ZY9MLgsKE9DQ7MJibg== X-Google-Smtp-Source: ABdhPJyUhy7+cJfaDKfU+dlJllV7FTT99DCfwfNrat7f5aIWF9lfM1q5wj8dxgFa13yBRD3PkrsPDQ== X-Received: by 2002:a63:8841:0:b0:3fc:704c:24ff with SMTP id l62-20020a638841000000b003fc704c24ffmr26783832pgd.116.1654628732819; Tue, 07 Jun 2022 12:05:32 -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 g29-20020aa79ddd000000b0050dc762819esm13236084pfq.120.2022.06.07.12.05.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 12:05:32 -0700 (PDT) From: Prashant Malani To: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Cc: bleung@chromium.org, swboyd@chromium.org, heikki.krogerus@linux.intel.com, Prashant Malani , Andrzej Hajda , AngeloGioacchino Del Regno , Daniel Vetter , David Airlie , devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), dri-devel@lists.freedesktop.org (open list:DRM DRIVERS), Greg Kroah-Hartman , Hsin-Yi Wang , Jernej Skrabec , Jonas Karlman , =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= , Krzysztof Kozlowski , Laurent Pinchart , Maxime Ripard , Neil Armstrong , =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= , Pin-Yen Lin , Robert Foss , Rob Herring , Sam Ravnborg , Thomas Zimmermann , Tzung-Bi Shih , Xin Ji Subject: [PATCH 2/7] usb: typec: mux: Add CONFIG guards for functions Date: Tue, 7 Jun 2022 19:00:20 +0000 Message-Id: <20220607190131.1647511-3-pmalani@chromium.org> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog In-Reply-To: <20220607190131.1647511-1-pmalani@chromium.org> References: <20220607190131.1647511-1-pmalani@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org 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. Signed-off-by: Prashant Malani --- include/linux/usb/typec_mux.h | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/include/linux/usb/typec_mux.h b/include/linux/usb/typec_mux.h index ee57781dcf28..758d34ced1f8 100644 --- a/include/linux/usb/typec_mux.h +++ b/include/linux/usb/typec_mux.h @@ -58,6 +58,8 @@ struct typec_mux_desc { void *drvdata; }; +#if IS_ENABLED(CONFIG_TYPEC) || IS_MODULE(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); @@ -76,4 +78,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 + +struct typec_mux *fwnode_typec_mux_get(struct fwnode_handle *fwnode, + const struct typec_altmode_desc *desc) +{ + return ERR_PTR(-EOPNOTSUPP); +} + +void typec_mux_put(struct typec_mux *mux) {} + +int typec_mux_set(struct typec_mux *mux, struct typec_mux_state *state) +{ + return -EOPNOTSUPP; +} + +static inline struct typec_mux * +typec_mux_get(struct device *dev, const struct typec_altmode_desc *desc) +{ + return ERR_PTR(-EOPNOTSUPP); +} + +struct typec_mux * +typec_mux_register(struct device *parent, const struct typec_mux_desc *desc) +{ + return ERR_PTR(-EOPNOTSUPP); +} +void typec_mux_unregister(struct typec_mux *mux) {} + +void typec_mux_set_drvdata(struct typec_mux *mux, void *data) {} +void *typec_mux_get_drvdata(struct typec_mux *mux) +{ + return ERR_PTR(-EOPNOTSUPP); +} + +#endif /* CONFIG_TYPEC */ + #endif /* __USB_TYPEC_MUX */