From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jC2L7-00049R-B5 for barebox@lists.infradead.org; Wed, 11 Mar 2020 14:28:08 +0000 From: Sascha Hauer Date: Wed, 11 Mar 2020 15:27:49 +0100 Message-Id: <20200311142757.25263-9-s.hauer@pengutronix.de> In-Reply-To: <20200311142757.25263-1-s.hauer@pengutronix.de> References: <20200311142757.25263-1-s.hauer@pengutronix.de> MIME-Version: 1.0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH 08/16] usb: Add a slice to usb host controllers To: Barebox List Cc: Edmund Henniges , =?UTF-8?q?Daniel=20Gl=C3=B6ckner?= Signed-off-by: Sascha Hauer --- drivers/usb/core/usb.c | 6 ++++++ include/usb/usb.h | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 1c3dcb79a8..da7afb5a32 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -83,11 +83,16 @@ static inline int usb_host_acquire(struct usb_host *host) if (host->sem) return -EAGAIN; host->sem++; + + slice_acquire(&host->slice); + return 0; } static inline void usb_host_release(struct usb_host *host) { + slice_release(&host->slice); + if (host->sem > 0) host->sem--; } @@ -97,6 +102,7 @@ int usb_register_host(struct usb_host *host) list_add_tail(&host->list, &host_list); host->busnum = host_busnum++; host->sem = 0; + slice_init(&host->slice, host->hw_dev); return 0; } diff --git a/include/usb/usb.h b/include/usb/usb.h index 95dedfd5b7..d730578fd7 100644 --- a/include/usb/usb.h +++ b/include/usb/usb.h @@ -23,6 +23,7 @@ #define _USB_H_ #include +#include #include #include #include @@ -154,11 +155,17 @@ struct usb_host { struct usb_device *root_dev; int sem; struct usb_phy *usbphy; + struct slice slice; }; int usb_register_host(struct usb_host *); void usb_unregister_host(struct usb_host *host); +static inline struct slice *usb_device_slice(struct usb_device *udev) +{ + return &udev->host->slice; +} + int usb_host_detect(struct usb_host *host); int usb_set_protocol(struct usb_device *dev, int ifnum, int protocol); -- 2.25.1 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox