Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1155702iog; Wed, 15 Jun 2022 23:27:21 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t1SddX44TDc60gvANLlu8infE5xfoDZdX5qZn2ipVGPmotFXne59oqnzBjRdoCs2/mGP3O X-Received: by 2002:a63:4746:0:b0:3fd:fd53:5fee with SMTP id w6-20020a634746000000b003fdfd535feemr3076090pgk.338.1655360841523; Wed, 15 Jun 2022 23:27:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655360841; cv=none; d=google.com; s=arc-20160816; b=M71YjvfQFBSu5/4GcAce++kJ7/xZaO78T+64tJ5I5l+Vxd9NcrOecgdFFC/AGiwThW dKob4Y/PiBMShXyhXwFvcuTV3tys/9VKojVKm6bhrpABmvYVpusFdg0Vw9KeFlSWMHZY aTQHDSUe/Ez9lRBLcHknzrWctJwZkIAs+EhmHVDD4yMISFSA8N6Dx/fmkXll2kv6PQXR 4czCeaC4u9iOr81kVmw8B4ousXAxziJeEI6LxlEEPg7+ztoqmqysbFvAhlUgLx4m3mij NcdkJGlBwUw4KRbmT3xmjzFAUFhuZmnSFwLaFcuFBHo7kTQyvqbk/nOIjQdPx2/n/Eu4 eRmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=YmK0zpyTm1M1mo5r/nh6FWXOxqUau0Q2VMCj2FpGTV0=; b=wPuzA7tSVrk6vlkNwnhnKC+66jiK2DPX8EPz9Afkk/7RgBXuyOg1dqR9RJGzT6fsjq u9/jN/06XybI8n9vi+ISau49fou7JFBZzFAsi+bv3t01XCgQLO5k55lGuV6yMCX56aeh EwH742IatoewZqvKk19at2yaASd1Bx+wA0EKFyQ8ieTmHI4DvdDlOJhy4E9V+2XB6Ee6 H8kS2Xvweq2xtQ/+LrvWYJBYgsYUjwVpp6PrjeE6gfqxNfXtc86z6kL/v7T8ZHOTWjqX RRZRxVd0ZYoDuZi9KydAwc/9b4EsZo+gQxrfoM1N1LbZ2y9Y0Mqgx/vJ0AmGi0n7E7GD xOSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SGPkQkX3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ob6-20020a17090b390600b001e335178676si2249988pjb.115.2022.06.15.23.27.08; Wed, 15 Jun 2022 23:27:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SGPkQkX3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359089AbiFPGXJ (ORCPT + 99 others); Thu, 16 Jun 2022 02:23:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237285AbiFPGXH (ORCPT ); Thu, 16 Jun 2022 02:23:07 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2026E0DF; Wed, 15 Jun 2022 23:23:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655360586; x=1686896586; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=C64wXT8o8e3dnYRSkDU43FZmaurq/w0MSIoJ52kgk9M=; b=SGPkQkX3XTI83cig+G/BLE16BN9DkkIDI/e5eKBHXcR3Vmt/Uku34EmC Jd8Pt7FuioYAucBcjjSB6jLuVKxa5T/+O7g93GUz1WYSn5hez9mwEazmi nUZrAMzwlrupG6/EelP2kgEUOj/0MAA/7FKpIygjvUva+DQj9HT5NwPsY QGKJe7PJtC2JrsgET/AJOgypoobyqwmS99qyBvbjW5JC2rHvBosHj2mtn TsEjdvEcUbJPOvRFyWb4Z09lpNWuhjbfCKsiE3R72IkDkCVZMx/4KR1uA xrmHvyxgAEgC7PKwmHLt6+vXHKxJBoTLANM1CxLjVJ55mdT3VYjhkAQeb g==; X-IronPort-AV: E=McAfee;i="6400,9594,10379"; a="267866655" X-IronPort-AV: E=Sophos;i="5.91,304,1647327600"; d="scan'208";a="267866655" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2022 23:23:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,304,1647327600"; d="scan'208";a="727759979" Received: from kuha.fi.intel.com ([10.237.72.185]) by fmsmga001.fm.intel.com with SMTP; 15 Jun 2022 23:22:58 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Thu, 16 Jun 2022 09:22:58 +0300 Date: Thu, 16 Jun 2022 09:22:58 +0300 From: Heikki Krogerus To: Prashant Malani Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, bleung@chromium.org, swboyd@chromium.org, kernel test robot , =?iso-8859-1?Q?N=EDcolas_F_=2E_R_=2E_A_=2E?= Prado , Andrzej Hajda , Daniel Vetter , David Airlie , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , "open list:DRM DRIVERS" , Greg Kroah-Hartman , Hsin-Yi Wang , Jernej Skrabec , Jonas Karlman , =?iso-8859-1?Q?Jos=E9_Exp=F3sito?= , Krzysztof Kozlowski , Laurent Pinchart , Maxime Ripard , Neil Armstrong , Pin-Yen Lin , Robert Foss , Rob Herring , Sam Ravnborg , Thomas Zimmermann , Xin Ji Subject: Re: [PATCH v4 2/7] usb: typec: mux: Add CONFIG guards for functions Message-ID: References: <20220615172129.1314056-1-pmalani@chromium.org> <20220615172129.1314056-3-pmalani@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220615172129.1314056-3-pmalani@chromium.org> X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 15, 2022 at 05:20:18PM +0000, Prashant Malani wrote: > 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 Reviewed-by: Heikki Krogerus > --- > > Changes since v3: > - No changes. > > 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 */ > -- > 2.36.1.476.g0c4daa206d-goog -- heikki