Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3437806pxf; Mon, 29 Mar 2021 02:07:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSEXkw8pC0kKkjbRH6AvR6VzG1b78wVJE6ehqMUW0NNsJaYxPmP4DYnQqx1F2vhlttbEP9 X-Received: by 2002:a17:907:d8b:: with SMTP id go11mr15759393ejc.167.1617008857911; Mon, 29 Mar 2021 02:07:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617008857; cv=none; d=google.com; s=arc-20160816; b=m4HSBIaIDKQ15zIJaHASNUP1+/OVkAMBNRmJnaIseDaQ0pVESEhDmwvQyLAVXGousD o3mzxRqKTFwtfwilTaDp7f6bOtF3P5dDkMoEt9ztmREEbRKu/1gnLqG1HZjTtNgYza93 x0QOv4iQIeXZyUMFhuAJxsm24U/xDJBVyObzB5vUZVMEngOgbnzB11SNRmkB9AJrHl6h jXXPma2WDbhzYpOs9WDpaJ5piFZqjAQhIoemjv3WqGIstxEMBrbKV9FqFBSePOdBNnFM Qklg8Y8mfgvkcjxrrRxsqNOVxi9Y6G2H/jdxKPEiMv93Rs815BW8/pC5/w3M8hLb5eOC F38g== 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 :ironport-sdr:ironport-sdr; bh=bd1o2KqX/snny0TOclYVa9I1h3iuZi9qjfZW0L4u6D4=; b=JyM0FKCGxjzNr4afc7hgOuasuYB5okxdHls5sW2KfDe0hSQycfmJDMg3SRfmbQzHh1 ufWt2oAOesAnbi5OUkRjkYTVezekUjBAJkFo0MRxhjrpxVMJ0mOVHQ/WFzC94+CUARq3 2nHdapANADTGM5dSo9oFkOO+Tu7r3dfVsAzkc1Bk2V9SBRktT2gIiIlEitntmn2/kqIL VHOv7kh5DTQTGcXLFuKUwb4jsrpoBq9fbXQoki7K+m4f4UmqVjN6ZwTgSt1xu4qY80dH /FRLWQNn55TsiQtqVhbVDfjk2pbMwOYk6OgtIxCvGzq+l7jCIK1GraR/DfN0yJ3+nbBQ Aolw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b9si12222285edq.492.2021.03.29.02.07.15; Mon, 29 Mar 2021 02:07:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233574AbhC2JEy (ORCPT + 99 others); Mon, 29 Mar 2021 05:04:54 -0400 Received: from mga06.intel.com ([134.134.136.31]:14119 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234803AbhC2IoV (ORCPT ); Mon, 29 Mar 2021 04:44:21 -0400 IronPort-SDR: 6Db6hxGbK4MJKtUwiwocjaE1AnRCMTJXodM+KoGB/U3Fz/pSMVPqvcIzO6g9uZa446HNUeKuBI zqlRGOBejyYA== X-IronPort-AV: E=McAfee;i="6000,8403,9937"; a="252854817" X-IronPort-AV: E=Sophos;i="5.81,287,1610438400"; d="scan'208";a="252854817" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Mar 2021 01:44:17 -0700 IronPort-SDR: mrMYbK2u8Nsc2n1kpcpoJjlML/rc8G64ZWebg5eBJF7sxiaZSmxSc5AwhUnGp00+q/C9IWzzHV +9l/OBCiGosQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,287,1610438400"; d="scan'208";a="515918683" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 29 Mar 2021 01:44:15 -0700 From: Heikki Krogerus To: Greg Kroah-Hartman Cc: Alan Stern , Benson Leung , Prashant Malani , Guenter Roeck , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/6] usb: typec: Organize the private headers properly Date: Mon, 29 Mar 2021 11:44:21 +0300 Message-Id: <20210329084426.78138-2-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210329084426.78138-1-heikki.krogerus@linux.intel.com> References: <20210329084426.78138-1-heikki.krogerus@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding a header file for each subsystem - the connector class, alt mode bus and the class for the muxes. Signed-off-by: Heikki Krogerus --- drivers/usb/typec/bus.c | 2 ++ drivers/usb/typec/bus.h | 19 +--------- drivers/usb/typec/class.c | 69 +++-------------------------------- drivers/usb/typec/class.h | 76 +++++++++++++++++++++++++++++++++++++++ drivers/usb/typec/mux.c | 4 +-- drivers/usb/typec/mux.h | 21 +++++++++++ 6 files changed, 107 insertions(+), 84 deletions(-) create mode 100644 drivers/usb/typec/class.h create mode 100644 drivers/usb/typec/mux.h diff --git a/drivers/usb/typec/bus.c b/drivers/usb/typec/bus.c index e8ddb81cb6df4..7f3c9a8e2bf08 100644 --- a/drivers/usb/typec/bus.c +++ b/drivers/usb/typec/bus.c @@ -9,6 +9,8 @@ #include #include "bus.h" +#include "class.h" +#include "mux.h" static inline int typec_altmode_set_mux(struct altmode *alt, unsigned long conf, void *data) diff --git a/drivers/usb/typec/bus.h b/drivers/usb/typec/bus.h index 8ba8112d2740d..56dec268d4dd9 100644 --- a/drivers/usb/typec/bus.h +++ b/drivers/usb/typec/bus.h @@ -4,9 +4,9 @@ #define __USB_TYPEC_ALTMODE_H__ #include -#include struct bus_type; +struct typec_mux; struct altmode { unsigned int id; @@ -28,24 +28,7 @@ struct altmode { extern struct bus_type typec_bus; extern const struct device_type typec_altmode_dev_type; -extern const struct device_type typec_port_dev_type; #define is_typec_altmode(_dev_) (_dev_->type == &typec_altmode_dev_type) -#define is_typec_port(_dev_) (_dev_->type == &typec_port_dev_type) - -extern struct class typec_mux_class; - -struct typec_switch { - struct device dev; - typec_switch_set_fn_t set; -}; - -struct typec_mux { - struct device dev; - typec_mux_set_fn_t set; -}; - -#define to_typec_switch(_dev_) container_of(_dev_, struct typec_switch, dev) -#define to_typec_mux(_dev_) container_of(_dev_, struct typec_mux, dev) #endif /* __USB_TYPEC_ALTMODE_H__ */ diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index 45f0bf65e9aba..5fa279a96b6ef 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -6,74 +6,15 @@ * Author: Heikki Krogerus */ -#include #include #include #include #include #include +#include #include "bus.h" - -struct typec_plug { - struct device dev; - enum typec_plug_index index; - struct ida mode_ids; - int num_altmodes; -}; - -struct typec_cable { - struct device dev; - enum typec_plug_type type; - struct usb_pd_identity *identity; - unsigned int active:1; - u16 pd_revision; /* 0300H = "3.0" */ -}; - -struct typec_partner { - struct device dev; - unsigned int usb_pd:1; - struct usb_pd_identity *identity; - enum typec_accessory accessory; - struct ida mode_ids; - int num_altmodes; - u16 pd_revision; /* 0300H = "3.0" */ - enum usb_pd_svdm_ver svdm_version; -}; - -struct typec_port { - unsigned int id; - struct device dev; - struct ida mode_ids; - - int prefer_role; - enum typec_data_role data_role; - enum typec_role pwr_role; - enum typec_role vconn_role; - enum typec_pwr_opmode pwr_opmode; - enum typec_port_type port_type; - struct mutex port_type_lock; - - enum typec_orientation orientation; - struct typec_switch *sw; - struct typec_mux *mux; - - const struct typec_capability *cap; - const struct typec_operations *ops; -}; - -#define to_typec_port(_dev_) container_of(_dev_, struct typec_port, dev) -#define to_typec_plug(_dev_) container_of(_dev_, struct typec_plug, dev) -#define to_typec_cable(_dev_) container_of(_dev_, struct typec_cable, dev) -#define to_typec_partner(_dev_) container_of(_dev_, struct typec_partner, dev) - -static const struct device_type typec_partner_dev_type; -static const struct device_type typec_cable_dev_type; -static const struct device_type typec_plug_dev_type; - -#define is_typec_partner(_dev_) (_dev_->type == &typec_partner_dev_type) -#define is_typec_cable(_dev_) (_dev_->type == &typec_cable_dev_type) -#define is_typec_plug(_dev_) (_dev_->type == &typec_plug_dev_type) +#include "class.h" static DEFINE_IDA(typec_index_ida); static struct class *typec_class; @@ -726,7 +667,7 @@ static void typec_partner_release(struct device *dev) kfree(partner); } -static const struct device_type typec_partner_dev_type = { +const struct device_type typec_partner_dev_type = { .name = "typec_partner", .groups = typec_partner_groups, .release = typec_partner_release, @@ -941,7 +882,7 @@ static const struct attribute_group *typec_plug_groups[] = { NULL }; -static const struct device_type typec_plug_dev_type = { +const struct device_type typec_plug_dev_type = { .name = "typec_plug", .groups = typec_plug_groups, .release = typec_plug_release, @@ -1089,7 +1030,7 @@ static void typec_cable_release(struct device *dev) kfree(cable); } -static const struct device_type typec_cable_dev_type = { +const struct device_type typec_cable_dev_type = { .name = "typec_cable", .groups = typec_cable_groups, .release = typec_cable_release, diff --git a/drivers/usb/typec/class.h b/drivers/usb/typec/class.h new file mode 100644 index 0000000000000..d414be58d122e --- /dev/null +++ b/drivers/usb/typec/class.h @@ -0,0 +1,76 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __USB_TYPEC_CLASS__ +#define __USB_TYPEC_CLASS__ + +#include +#include + +struct typec_mux; +struct typec_switch; + +struct typec_plug { + struct device dev; + enum typec_plug_index index; + struct ida mode_ids; + int num_altmodes; +}; + +struct typec_cable { + struct device dev; + enum typec_plug_type type; + struct usb_pd_identity *identity; + unsigned int active:1; + u16 pd_revision; /* 0300H = "3.0" */ +}; + +struct typec_partner { + struct device dev; + unsigned int usb_pd:1; + struct usb_pd_identity *identity; + enum typec_accessory accessory; + struct ida mode_ids; + int num_altmodes; + u16 pd_revision; /* 0300H = "3.0" */ + enum usb_pd_svdm_ver svdm_version; +}; + +struct typec_port { + unsigned int id; + struct device dev; + struct ida mode_ids; + + int prefer_role; + enum typec_data_role data_role; + enum typec_role pwr_role; + enum typec_role vconn_role; + enum typec_pwr_opmode pwr_opmode; + enum typec_port_type port_type; + struct mutex port_type_lock; + + enum typec_orientation orientation; + struct typec_switch *sw; + struct typec_mux *mux; + + const struct typec_capability *cap; + const struct typec_operations *ops; +}; + +#define to_typec_port(_dev_) container_of(_dev_, struct typec_port, dev) +#define to_typec_plug(_dev_) container_of(_dev_, struct typec_plug, dev) +#define to_typec_cable(_dev_) container_of(_dev_, struct typec_cable, dev) +#define to_typec_partner(_dev_) container_of(_dev_, struct typec_partner, dev) + +extern const struct device_type typec_partner_dev_type; +extern const struct device_type typec_cable_dev_type; +extern const struct device_type typec_plug_dev_type; +extern const struct device_type typec_port_dev_type; + +#define is_typec_partner(dev) ((dev)->type == &typec_partner_dev_type) +#define is_typec_cable(dev) ((dev)->type == &typec_cable_dev_type) +#define is_typec_plug(dev) ((dev)->type == &typec_plug_dev_type) +#define is_typec_port(dev) ((dev)->type == &typec_port_dev_type) + +extern struct class typec_mux_class; + +#endif /* __USB_TYPEC_CLASS__ */ diff --git a/drivers/usb/typec/mux.c b/drivers/usb/typec/mux.c index cf720e944aaaa..9da22ae3006c9 100644 --- a/drivers/usb/typec/mux.c +++ b/drivers/usb/typec/mux.c @@ -13,9 +13,9 @@ #include #include #include -#include -#include "bus.h" +#include "class.h" +#include "mux.h" static bool dev_name_ends_with(struct device *dev, const char *suffix) { diff --git a/drivers/usb/typec/mux.h b/drivers/usb/typec/mux.h new file mode 100644 index 0000000000000..4fd9426ee44f6 --- /dev/null +++ b/drivers/usb/typec/mux.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __USB_TYPEC_MUX__ +#define __USB_TYPEC_MUX__ + +#include + +struct typec_switch { + struct device dev; + typec_switch_set_fn_t set; +}; + +struct typec_mux { + struct device dev; + typec_mux_set_fn_t set; +}; + +#define to_typec_switch(_dev_) container_of(_dev_, struct typec_switch, dev) +#define to_typec_mux(_dev_) container_of(_dev_, struct typec_mux, dev) + +#endif /* __USB_TYPEC_MUX__ */ -- 2.30.2