Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: typec: Organize the private headers properly

Adding a header file for each subsystem - the connector
class, alt mode bus and the class for the muxes.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20210401105847.13026-2-heikki.krogerus@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Heikki Krogerus and committed by
Greg Kroah-Hartman
1e2ed7b2 de800f29

+107 -84
+2
drivers/usb/typec/bus.c
··· 9 9 #include <linux/usb/pd_vdo.h> 10 10 11 11 #include "bus.h" 12 + #include "class.h" 13 + #include "mux.h" 12 14 13 15 static inline int 14 16 typec_altmode_set_mux(struct altmode *alt, unsigned long conf, void *data)
+1 -18
drivers/usb/typec/bus.h
··· 4 4 #define __USB_TYPEC_ALTMODE_H__ 5 5 6 6 #include <linux/usb/typec_altmode.h> 7 - #include <linux/usb/typec_mux.h> 8 7 9 8 struct bus_type; 9 + struct typec_mux; 10 10 11 11 struct altmode { 12 12 unsigned int id; ··· 28 28 29 29 extern struct bus_type typec_bus; 30 30 extern const struct device_type typec_altmode_dev_type; 31 - extern const struct device_type typec_port_dev_type; 32 31 33 32 #define is_typec_altmode(_dev_) (_dev_->type == &typec_altmode_dev_type) 34 - #define is_typec_port(_dev_) (_dev_->type == &typec_port_dev_type) 35 - 36 - extern struct class typec_mux_class; 37 - 38 - struct typec_switch { 39 - struct device dev; 40 - typec_switch_set_fn_t set; 41 - }; 42 - 43 - struct typec_mux { 44 - struct device dev; 45 - typec_mux_set_fn_t set; 46 - }; 47 - 48 - #define to_typec_switch(_dev_) container_of(_dev_, struct typec_switch, dev) 49 - #define to_typec_mux(_dev_) container_of(_dev_, struct typec_mux, dev) 50 33 51 34 #endif /* __USB_TYPEC_ALTMODE_H__ */
+5 -64
drivers/usb/typec/class.c
··· 6 6 * Author: Heikki Krogerus <heikki.krogerus@linux.intel.com> 7 7 */ 8 8 9 - #include <linux/device.h> 10 9 #include <linux/module.h> 11 10 #include <linux/mutex.h> 12 11 #include <linux/property.h> 13 12 #include <linux/slab.h> 14 13 #include <linux/usb/pd_vdo.h> 14 + #include <linux/usb/typec_mux.h> 15 15 16 16 #include "bus.h" 17 - 18 - struct typec_plug { 19 - struct device dev; 20 - enum typec_plug_index index; 21 - struct ida mode_ids; 22 - int num_altmodes; 23 - }; 24 - 25 - struct typec_cable { 26 - struct device dev; 27 - enum typec_plug_type type; 28 - struct usb_pd_identity *identity; 29 - unsigned int active:1; 30 - u16 pd_revision; /* 0300H = "3.0" */ 31 - }; 32 - 33 - struct typec_partner { 34 - struct device dev; 35 - unsigned int usb_pd:1; 36 - struct usb_pd_identity *identity; 37 - enum typec_accessory accessory; 38 - struct ida mode_ids; 39 - int num_altmodes; 40 - u16 pd_revision; /* 0300H = "3.0" */ 41 - enum usb_pd_svdm_ver svdm_version; 42 - }; 43 - 44 - struct typec_port { 45 - unsigned int id; 46 - struct device dev; 47 - struct ida mode_ids; 48 - 49 - int prefer_role; 50 - enum typec_data_role data_role; 51 - enum typec_role pwr_role; 52 - enum typec_role vconn_role; 53 - enum typec_pwr_opmode pwr_opmode; 54 - enum typec_port_type port_type; 55 - struct mutex port_type_lock; 56 - 57 - enum typec_orientation orientation; 58 - struct typec_switch *sw; 59 - struct typec_mux *mux; 60 - 61 - const struct typec_capability *cap; 62 - const struct typec_operations *ops; 63 - }; 64 - 65 - #define to_typec_port(_dev_) container_of(_dev_, struct typec_port, dev) 66 - #define to_typec_plug(_dev_) container_of(_dev_, struct typec_plug, dev) 67 - #define to_typec_cable(_dev_) container_of(_dev_, struct typec_cable, dev) 68 - #define to_typec_partner(_dev_) container_of(_dev_, struct typec_partner, dev) 69 - 70 - static const struct device_type typec_partner_dev_type; 71 - static const struct device_type typec_cable_dev_type; 72 - static const struct device_type typec_plug_dev_type; 73 - 74 - #define is_typec_partner(_dev_) (_dev_->type == &typec_partner_dev_type) 75 - #define is_typec_cable(_dev_) (_dev_->type == &typec_cable_dev_type) 76 - #define is_typec_plug(_dev_) (_dev_->type == &typec_plug_dev_type) 17 + #include "class.h" 77 18 78 19 static DEFINE_IDA(typec_index_ida); 79 20 static struct class *typec_class; ··· 667 726 kfree(partner); 668 727 } 669 728 670 - static const struct device_type typec_partner_dev_type = { 729 + const struct device_type typec_partner_dev_type = { 671 730 .name = "typec_partner", 672 731 .groups = typec_partner_groups, 673 732 .release = typec_partner_release, ··· 882 941 NULL 883 942 }; 884 943 885 - static const struct device_type typec_plug_dev_type = { 944 + const struct device_type typec_plug_dev_type = { 886 945 .name = "typec_plug", 887 946 .groups = typec_plug_groups, 888 947 .release = typec_plug_release, ··· 1030 1089 kfree(cable); 1031 1090 } 1032 1091 1033 - static const struct device_type typec_cable_dev_type = { 1092 + const struct device_type typec_cable_dev_type = { 1034 1093 .name = "typec_cable", 1035 1094 .groups = typec_cable_groups, 1036 1095 .release = typec_cable_release,
+76
drivers/usb/typec/class.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + 3 + #ifndef __USB_TYPEC_CLASS__ 4 + #define __USB_TYPEC_CLASS__ 5 + 6 + #include <linux/device.h> 7 + #include <linux/usb/typec.h> 8 + 9 + struct typec_mux; 10 + struct typec_switch; 11 + 12 + struct typec_plug { 13 + struct device dev; 14 + enum typec_plug_index index; 15 + struct ida mode_ids; 16 + int num_altmodes; 17 + }; 18 + 19 + struct typec_cable { 20 + struct device dev; 21 + enum typec_plug_type type; 22 + struct usb_pd_identity *identity; 23 + unsigned int active:1; 24 + u16 pd_revision; /* 0300H = "3.0" */ 25 + }; 26 + 27 + struct typec_partner { 28 + struct device dev; 29 + unsigned int usb_pd:1; 30 + struct usb_pd_identity *identity; 31 + enum typec_accessory accessory; 32 + struct ida mode_ids; 33 + int num_altmodes; 34 + u16 pd_revision; /* 0300H = "3.0" */ 35 + enum usb_pd_svdm_ver svdm_version; 36 + }; 37 + 38 + struct typec_port { 39 + unsigned int id; 40 + struct device dev; 41 + struct ida mode_ids; 42 + 43 + int prefer_role; 44 + enum typec_data_role data_role; 45 + enum typec_role pwr_role; 46 + enum typec_role vconn_role; 47 + enum typec_pwr_opmode pwr_opmode; 48 + enum typec_port_type port_type; 49 + struct mutex port_type_lock; 50 + 51 + enum typec_orientation orientation; 52 + struct typec_switch *sw; 53 + struct typec_mux *mux; 54 + 55 + const struct typec_capability *cap; 56 + const struct typec_operations *ops; 57 + }; 58 + 59 + #define to_typec_port(_dev_) container_of(_dev_, struct typec_port, dev) 60 + #define to_typec_plug(_dev_) container_of(_dev_, struct typec_plug, dev) 61 + #define to_typec_cable(_dev_) container_of(_dev_, struct typec_cable, dev) 62 + #define to_typec_partner(_dev_) container_of(_dev_, struct typec_partner, dev) 63 + 64 + extern const struct device_type typec_partner_dev_type; 65 + extern const struct device_type typec_cable_dev_type; 66 + extern const struct device_type typec_plug_dev_type; 67 + extern const struct device_type typec_port_dev_type; 68 + 69 + #define is_typec_partner(dev) ((dev)->type == &typec_partner_dev_type) 70 + #define is_typec_cable(dev) ((dev)->type == &typec_cable_dev_type) 71 + #define is_typec_plug(dev) ((dev)->type == &typec_plug_dev_type) 72 + #define is_typec_port(dev) ((dev)->type == &typec_port_dev_type) 73 + 74 + extern struct class typec_mux_class; 75 + 76 + #endif /* __USB_TYPEC_CLASS__ */
+2 -2
drivers/usb/typec/mux.c
··· 13 13 #include <linux/mutex.h> 14 14 #include <linux/property.h> 15 15 #include <linux/slab.h> 16 - #include <linux/usb/typec_mux.h> 17 16 18 - #include "bus.h" 17 + #include "class.h" 18 + #include "mux.h" 19 19 20 20 static bool dev_name_ends_with(struct device *dev, const char *suffix) 21 21 {
+21
drivers/usb/typec/mux.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + 3 + #ifndef __USB_TYPEC_MUX__ 4 + #define __USB_TYPEC_MUX__ 5 + 6 + #include <linux/usb/typec_mux.h> 7 + 8 + struct typec_switch { 9 + struct device dev; 10 + typec_switch_set_fn_t set; 11 + }; 12 + 13 + struct typec_mux { 14 + struct device dev; 15 + typec_mux_set_fn_t set; 16 + }; 17 + 18 + #define to_typec_switch(_dev_) container_of(_dev_, struct typec_switch, dev) 19 + #define to_typec_mux(_dev_) container_of(_dev_, struct typec_mux, dev) 20 + 21 + #endif /* __USB_TYPEC_MUX__ */