Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp546872ybv; Thu, 13 Feb 2020 05:26:38 -0800 (PST) X-Google-Smtp-Source: APXvYqwft6etwDv6TRvmFIMh1YmW0Usw8/dlfTqc2wcjyLJSzRjnf7vmm+u2jvyfa0480a5ae3Hx X-Received: by 2002:a05:6830:1184:: with SMTP id u4mr12651885otq.221.1581600398182; Thu, 13 Feb 2020 05:26:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581600398; cv=none; d=google.com; s=arc-20160816; b=QJhz/WnNiuNMxawfmtLFU+bhgoVGdRGOF2yGX3NbBJHboYkupAQ7dkfCPNzPVzPJQg elm+RJY3+6UqsSPNdrRafyXcqaeVRFebHwg/SADDTNhwcXhmi5FvSWgD0yRYrLHOYwxr TkCJ4U/xylwVDYG0zHENbQyL7Om86/U1OCUEok4x8Yw6pN7+BJbJE4k4q+FcvQNdQCly +5CuRxBbQ+E+qLXagvtWuqIAnGPiLz6ug0eyt1AZDkqFdVztlo40xD6Bb0sfqQIaiw8s 8ZRAnGKI8oxlRIxJ4lxXDm2ZTgkunXESMDV0BTYJhvsxOGgDUECIgL1YW6Cal1u5tHIN 9iLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=lUYNvvVOxY9bSU7LhtVGkRfKhZcoelP2hA9q2AecYLQ=; b=YyVMxvHW60lfltT5PsRTcwHEPwQCGyOKI03bhEvMpn+JuHVDQKCA3UY4S1jX79LOdl AwQ9sTqgdNQTZQlc2wlcbqDYODHdX+FTRlSTNLpkEBWo0vCxkR13VXQ2auPXl2npDRzd hLbEs/wB5FDHkx99lc/EVfeFwVOuOdZAAwGL9Lg7qa6aI65hmjJwVgs8XJj7oM3KX/PR G8YA5SyVrat2hxyYtOP8h8nO1nf4SuSAmjHQrzSyGXqMogWC91zHE9xQjR9j7wlbhUjA z1+Zuc4fvMXmlUSjAAJJcCYI8l7w2NLGYs+EV+WA38BBDHJk921j69uePTsqwi3cp/fG o9KQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id y19si1092666oto.102.2020.02.13.05.26.24; Thu, 13 Feb 2020 05:26:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1730057AbgBMNYl (ORCPT + 99 others); Thu, 13 Feb 2020 08:24:41 -0500 Received: from mga06.intel.com ([134.134.136.31]:44559 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730000AbgBMNYj (ORCPT ); Thu, 13 Feb 2020 08:24:39 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Feb 2020 05:24:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,436,1574150400"; d="scan'208";a="347728498" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 13 Feb 2020 05:24:37 -0800 From: Heikki Krogerus To: Greg Kroah-Hartman Cc: Benson Leung , Prashant Malani , Mika Westerberg , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH 4/9] usb: roles: Leave the private driver data pointer to the drivers Date: Thu, 13 Feb 2020 16:24:23 +0300 Message-Id: <20200213132428.53374-5-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200213132428.53374-1-heikki.krogerus@linux.intel.com> References: <20200213132428.53374-1-heikki.krogerus@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding usb_role_switch_get/set_drvdata() functions that the switch drivers can use for setting and getting private data pointer that is associated with the switch. Signed-off-by: Heikki Krogerus --- drivers/usb/roles/class.c | 22 ++++++++++++++++++++++ include/linux/usb/role.h | 16 ++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c index 63a00ff26655..f3132d231599 100644 --- a/drivers/usb/roles/class.c +++ b/drivers/usb/roles/class.c @@ -329,6 +329,7 @@ usb_role_switch_register(struct device *parent, sw->dev.fwnode = desc->fwnode; sw->dev.class = role_class; sw->dev.type = &usb_role_dev_type; + sw->dev.driver_data = desc->driver_data; dev_set_name(&sw->dev, "%s-role-switch", dev_name(parent)); ret = device_register(&sw->dev); @@ -356,6 +357,27 @@ void usb_role_switch_unregister(struct usb_role_switch *sw) } EXPORT_SYMBOL_GPL(usb_role_switch_unregister); +/** + * usb_role_switch_set_drvdata - Assign private data pointer to a switch + * @sw: USB Role Switch + * @data: Private data pointer + */ +void usb_role_switch_set_drvdata(struct usb_role_switch *sw, void *data) +{ + dev_set_drvdata(&sw->dev, data); +} +EXPORT_SYMBOL_GPL(usb_role_switch_set_drvdata); + +/** + * usb_role_switch_get_drvdata - Get the private data pointer of a switch + * @sw: USB Role Switch + */ +void *usb_role_switch_get_drvdata(struct usb_role_switch *sw) +{ + return dev_get_drvdata(&sw->dev); +} +EXPORT_SYMBOL_GPL(usb_role_switch_get_drvdata); + static int __init usb_roles_init(void) { role_class = class_create(THIS_MODULE, "usb_role"); diff --git a/include/linux/usb/role.h b/include/linux/usb/role.h index efac3af83d6b..02dae936cebd 100644 --- a/include/linux/usb/role.h +++ b/include/linux/usb/role.h @@ -25,6 +25,7 @@ typedef enum usb_role (*usb_role_switch_get_t)(struct device *dev); * @set: Callback for setting the role * @get: Callback for getting the role (optional) * @allow_userspace_control: If true userspace may change the role through sysfs + * @driver_data: Private data pointer * * @usb2_port and @usb3_port will point to the USB host port and @udc to the USB * device controller behind the USB connector with the role switch. If @@ -40,6 +41,7 @@ struct usb_role_switch_desc { usb_role_switch_set_t set; usb_role_switch_get_t get; bool allow_userspace_control; + void *driver_data; }; @@ -57,6 +59,9 @@ struct usb_role_switch * usb_role_switch_register(struct device *parent, const struct usb_role_switch_desc *desc); void usb_role_switch_unregister(struct usb_role_switch *sw); + +void usb_role_switch_set_drvdata(struct usb_role_switch *sw, void *data); +void *usb_role_switch_get_drvdata(struct usb_role_switch *sw); #else static inline int usb_role_switch_set_role(struct usb_role_switch *sw, enum usb_role role) @@ -90,6 +95,17 @@ usb_role_switch_register(struct device *parent, } static inline void usb_role_switch_unregister(struct usb_role_switch *sw) { } + +static inline void +usb_role_switch_set_drvdata(struct usb_role_switch *sw, void *data) +{ +} + +static inline void *usb_role_switch_get_drvdata(struct usb_role_switch *sw) +{ + return NULL; +} + #endif #endif /* __LINUX_USB_ROLE_H */ -- 2.25.0