From patchwork Tue May 25 08:53:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= X-Patchwork-Id: 12278207 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED05AC2B9F8 for ; Tue, 25 May 2021 08:54:01 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B065361409 for ; Tue, 25 May 2021 08:54:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B065361409 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=LHkYO3kuQDBgcxagemAXaRkFpsh44CeZZ0crKqHJhkQ=; b=Ydq+WQudHEKixL 9eAtA4dKmYrM8ETY7W3dJVYVkHsRgtAXUtqsUZjeDdH6cdOLimfz1cpqjDaXrcM9KCTlruXnAmoBQ vv+o5loSMF32Zc4f5cDYT9IM4iRitOXE68YhyN7Y+LlhO0wlNC85XpJutcip2PRvRG2lTUiyGni7t rMs0cHCTRRiWWdxpNo9HEZHCehTgaDbRL/SmnpTd/ecmh7LDBWXAd+0u1Ff27D55XIZvBPKN056VT 2WbbawJObzYAbBiIQY0+3bmHO+Z/NNljR1Dwn+6bdaaPjHeOCcYSj+75emfBF0PgCFA9mCavhFp7Q dJwRT0ssPbWGfvusuFPA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1llSoy-004CGO-2T; Tue, 25 May 2021 08:53:52 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1llSoS-004C14-Ix; Tue, 25 May 2021 08:53:24 +0000 X-UUID: ab6d197bb66d4cc2a933f5992b0326c9-20210525 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=Q+d5TmFxgYUOTbXeyIucEBVczen+3LmsqBJCeNp4jJw=; b=W+uP7ZPDQAomOXHtTRTciCn1DDgsG7mjJnhSV7MTsN75DhylrCVH3m6naC2XV3R1aFlzQ+dEvRfdtunLVFoD2ubL8FcozDIBKvMEl1Kh2f8OiRuE8qSJcrkEzA58InU8FCNh7BPZldE7lp7CenPswpklSDZ7LFMkc7TLRBXG4PU=; X-UUID: ab6d197bb66d4cc2a933f5992b0326c9-20210525 Received: from mtkcas67.mediatek.inc [(172.29.193.45)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 539246454; Tue, 25 May 2021 01:53:14 -0700 Received: from MTKMBS31N2.mediatek.inc (172.27.4.87) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 25 May 2021 01:53:12 -0700 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by MTKMBS31N2.mediatek.inc (172.27.4.87) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 25 May 2021 16:53:09 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 25 May 2021 16:53:08 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Heikki Krogerus CC: Matthias Brugger , Chunfeng Yun , Thierry Reding , "Paul Cercueil" , Lee Jones , "Guenter Roeck" , Hans de Goede , , , , Subject: [PATCH 1/2] usb: roles: add helper usb_role_string() Date: Tue, 25 May 2021 16:53:05 +0800 Message-ID: <1621932786-9335-1-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty MIME-Version: 1.0 X-TM-SNTS-SMTP: 9D3C1B779BF25D9D23F9965EFEF3D524173D86C78AC011EFF27669269D1E0E2E2000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210525_015320_694316_91588F93 X-CRM114-Status: GOOD ( 11.53 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Introduces usb_role_string() function, which returns a human-readable name of provided usb role, it's useful to make the log readable. Signed-off-by: Chunfeng Yun Reviewed-by: Heikki Krogerus --- drivers/usb/roles/class.c | 9 +++++++++ include/linux/usb/role.h | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c index 33b637d0d8d9..dfaed7eee94f 100644 --- a/drivers/usb/roles/class.c +++ b/drivers/usb/roles/class.c @@ -214,6 +214,15 @@ static const char * const usb_roles[] = { [USB_ROLE_DEVICE] = "device", }; +const char *usb_role_string(enum usb_role role) +{ + if (role < 0 || role >= ARRAY_SIZE(usb_roles)) + return "unknown"; + + return usb_roles[role]; +} +EXPORT_SYMBOL_GPL(usb_role_string); + static ssize_t role_show(struct device *dev, struct device_attribute *attr, char *buf) { diff --git a/include/linux/usb/role.h b/include/linux/usb/role.h index 0164fed31b06..031f148ab373 100644 --- a/include/linux/usb/role.h +++ b/include/linux/usb/role.h @@ -65,6 +65,7 @@ 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); +const char *usb_role_string(enum usb_role role); #else static inline int usb_role_switch_set_role(struct usb_role_switch *sw, enum usb_role role) @@ -109,6 +110,11 @@ static inline void *usb_role_switch_get_drvdata(struct usb_role_switch *sw) return NULL; } +static inline const char *usb_role_string(enum usb_role role) +{ + return "unknown"; +} + #endif #endif /* __LINUX_USB_ROLE_H */ From patchwork Tue May 25 08:53:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= X-Patchwork-Id: 12278211 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9189C2B9F8 for ; Tue, 25 May 2021 08:56:54 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A18C16100B for ; Tue, 25 May 2021 08:56:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A18C16100B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vfCvlzAWSu5h6hJsvr4Irdb7UID6eym7Rj/lOhNvX8M=; b=ZrIXLYnlV+0ohm Ux72/rE67ksM2cHzUdEl0f525UPgZyRcLLDa13HR1a2daqjot/zPHmTwuCfEmitBjsvdqb1YJY7Or fWuCDFsMaScDCqZi74COkwMBUsmMwK8urz1PK7m599fYNHW4/ucd5J9YbDzaeAx8+OIUvzVMUKJ7F N4tLS3fMU0/QRgdQwxvdabhofvUMQnBwtGvekAnE71/bIXe1PUNuFO/xRs4Lrz8AwRlOxz6KiiQ1o dfk7CbbcpKyMT59iRAj1fE2ucK4CF4QR9Vcge5lMzrxLmmO4GxSPmxWISLoYhuD73wpOXOghR6ki+ HEIYxUDEOjypwUdnoEUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1llSrk-004DZy-NO; Tue, 25 May 2021 08:56:44 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1llSqT-004Cvn-Jt; Tue, 25 May 2021 08:55:27 +0000 X-UUID: 2704153462f94f7583acf311ba51ecc9-20210525 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=xHTcyDobWPIh805bZqSPp7cDAaKUL/6OpGPhJpKrc4w=; b=cW5tOHnxGzzBfnTaC+zpM7++TpMttMUmV7DRN4rYxRdk7DBrr2hmlVvXUAUI+0F4cyrxYLr4hBNo/Y9mCWQK71FHwEB+nMDOSNGV/T3B7qiOgu9nQXMPd30BIVyOxDJGuDkksxAaHQ8L94boKO7eAPJtw7f5Df2dTnR+hQKppdo=; X-UUID: 2704153462f94f7583acf311ba51ecc9-20210525 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1897179374; Tue, 25 May 2021 01:55:20 -0700 Received: from MTKMBS31N2.mediatek.inc (172.27.4.87) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 25 May 2021 01:53:17 -0700 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by MTKMBS31N2.mediatek.inc (172.27.4.87) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 25 May 2021 16:53:10 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 25 May 2021 16:53:09 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Heikki Krogerus CC: Matthias Brugger , Chunfeng Yun , Thierry Reding , "Paul Cercueil" , Lee Jones , "Guenter Roeck" , Hans de Goede , , , , Subject: [PATCH 2/2] usb: common: usb-conn-gpio: use usb_role_string() to print role status Date: Tue, 25 May 2021 16:53:06 +0800 Message-ID: <1621932786-9335-2-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1621932786-9335-1-git-send-email-chunfeng.yun@mediatek.com> References: <1621932786-9335-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: 775A0B1362276C37A09733E3CEDA3FC8205CFB046EBCE31B5DB8EB0AD349CA1F2000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210525_015525_736482_895B8199 X-CRM114-Status: GOOD ( 11.68 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Use usb_role_string() to print role status, make the log readable. Signed-off-by: Chunfeng Yun --- drivers/usb/common/usb-conn-gpio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/common/usb-conn-gpio.c b/drivers/usb/common/usb-conn-gpio.c index 65d89140cd19..7dbe8baed029 100644 --- a/drivers/usb/common/usb-conn-gpio.c +++ b/drivers/usb/common/usb-conn-gpio.c @@ -83,11 +83,11 @@ static void usb_conn_detect_cable(struct work_struct *work) else role = USB_ROLE_NONE; - dev_dbg(info->dev, "role %d/%d, gpios: id %d, vbus %d\n", - info->last_role, role, id, vbus); + dev_dbg(info->dev, "role %s -> %s, gpios: id %d, vbus %d\n", + usb_role_string(info->last_role), usb_role_string(role), id, vbus); if (info->last_role == role) { - dev_warn(info->dev, "repeated role: %d\n", role); + dev_warn(info->dev, "repeated role: %s\n", usb_role_string(role)); return; }