From patchwork Wed Jun 5 10:03:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Laszczak X-Patchwork-Id: 10976579 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D24436C5 for ; Wed, 5 Jun 2019 10:14:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C459C288D0 for ; Wed, 5 Jun 2019 10:14:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C228628901; Wed, 5 Jun 2019 10:14:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3BB2728911 for ; Wed, 5 Jun 2019 10:14:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727287AbfFEKOj (ORCPT ); Wed, 5 Jun 2019 06:14:39 -0400 Received: from mx0a-0014ca01.pphosted.com ([208.84.65.235]:56034 "EHLO mx0a-0014ca01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726988AbfFEKOj (ORCPT ); Wed, 5 Jun 2019 06:14:39 -0400 Received: from pps.filterd (m0042385.ppops.net [127.0.0.1]) by mx0a-0014ca01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x559uvC4008600; Wed, 5 Jun 2019 03:04:22 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cadence.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=proofpoint; bh=xJScHqcKlnr0GSmyo3i5fJZdQQL1TyqjQZkkHl6Y1KA=; b=e9Lk9o+DAJCpx9DIZGgQNfBtlhJYOihp/E+eY7bVXupwLPF3LPkE7hNecX3BAootJR2K 7OU+QCBa9bBO/UJdZw15n9eV2arSSCEzZ57Bgk4h2n/0vn/V8rSaXK0WXbCsyFP97JfU s167TRFQlQJiBidipyUas7DUrSmSTBFQ9GpsGE4O30+0GDEjtd78PtDm2Exc0nbQhkyc m4eauYnnNzfsRlkZt2x8ZQHwuQFgy3Doaz7vIV4DwNVzVAxogc5qYwvQ18nGJJ4JCveQ RFggNxNVc/3ttKgFVSKHKUQ4rqwMTAMVso6rzonyY1QHvIkm50mLJA6pZg086MMXnsPv jw== Authentication-Results: cadence.com; spf=pass smtp.mailfrom=pawell@cadence.com Received: from nam03-by2-obe.outbound.protection.outlook.com (mail-by2nam03lp2053.outbound.protection.outlook.com [104.47.42.53]) by mx0a-0014ca01.pphosted.com with ESMTP id 2sunwry5m9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2019 03:04:22 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cadence.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xJScHqcKlnr0GSmyo3i5fJZdQQL1TyqjQZkkHl6Y1KA=; b=gGcuJNeMnyth1Ia44EboD+RyiLRlf6cSv9MuDC8l/6+koubIufDoGUGExWVunYYNlo+5o3lPR9XuGZ++gP95acqpKTcJcZWJcUjQoc1wdwEWeJUcpinOIuGHPkSJZo7vBk/2ffsu0O2bzcPtMpkK39Trt9NKVFuwqCSo10eIgNU= Received: from DM5PR07CA0084.namprd07.prod.outlook.com (2603:10b6:4:ad::49) by BN8PR07MB6820.namprd07.prod.outlook.com (2603:10b6:408:b9::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1943.22; Wed, 5 Jun 2019 10:04:19 +0000 Received: from CO1NAM05FT051.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e50::209) by DM5PR07CA0084.outlook.office365.com (2603:10b6:4:ad::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1943.20 via Frontend Transport; Wed, 5 Jun 2019 10:04:19 +0000 Received-SPF: SoftFail (protection.outlook.com: domain of transitioning cadence.com discourages use of 158.140.1.28 as permitted sender) Received: from sjmaillnx1.cadence.com (158.140.1.28) by CO1NAM05FT051.mail.protection.outlook.com (10.152.96.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1965.10 via Frontend Transport; Wed, 5 Jun 2019 10:04:18 +0000 Received: from maileu3.global.cadence.com (maileu3.cadence.com [10.160.88.99]) by sjmaillnx1.cadence.com (8.14.4/8.14.4) with ESMTP id x55A4Dqt028887 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Wed, 5 Jun 2019 03:04:17 -0700 X-CrossPremisesHeadersFilteredBySendConnector: maileu3.global.cadence.com Received: from maileu3.global.cadence.com (10.160.88.99) by maileu3.global.cadence.com (10.160.88.99) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 5 Jun 2019 12:04:13 +0200 Received: from lvlogina.cadence.com (10.165.176.102) by maileu3.global.cadence.com (10.160.88.99) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Wed, 5 Jun 2019 12:04:13 +0200 Received: from lvlogina.cadence.com (localhost.localdomain [127.0.0.1]) by lvlogina.cadence.com (8.14.4/8.14.4) with ESMTP id x55A4DkO017319; Wed, 5 Jun 2019 11:04:13 +0100 Received: (from pawell@localhost) by lvlogina.cadence.com (8.14.4/8.14.4/Submit) id x55A4D0W017314; Wed, 5 Jun 2019 11:04:13 +0100 From: Pawel Laszczak To: CC: , , , , , , , , , , , , , , , Pawel Laszczak Subject: [PATCH v7 4/6] usb:common Simplify usb_decode_get_set_descriptor function. Date: Wed, 5 Jun 2019 11:03:48 +0100 Message-ID: <1559729030-16390-5-git-send-email-pawell@cadence.com> X-Mailer: git-send-email 1.7.11.2 In-Reply-To: <1559729030-16390-1-git-send-email-pawell@cadence.com> References: <1559729030-16390-1-git-send-email-pawell@cadence.com> MIME-Version: 1.0 X-OrganizationHeadersPreserved: maileu3.global.cadence.com X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:158.140.1.28;IPV:CAL;SCL:-1;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(346002)(39860400002)(396003)(136003)(376002)(2980300002)(36092001)(199004)(189003)(48376002)(2906002)(356004)(87636003)(478600001)(26826003)(8676002)(50466002)(426003)(2351001)(76176011)(50226002)(26005)(16586007)(7416002)(336012)(246002)(6666004)(70206006)(86362001)(70586007)(36756003)(5660300002)(42186006)(51416003)(54906003)(8936002)(4720700003)(76130400001)(6916009)(107886003)(316002)(47776003)(7636002)(11346002)(4326008)(2616005)(476003)(486006)(305945005)(126002)(186003)(446003);DIR:OUT;SFP:1101;SCL:1;SRVR:BN8PR07MB6820;H:sjmaillnx1.cadence.com;FPR:;SPF:SoftFail;LANG:en;PTR:corp.cadence.com;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f16fa206-c88d-4f73-613e-08d6e99d2cd6 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600148)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328);SRVR:BN8PR07MB6820; X-MS-TrafficTypeDiagnostic: BN8PR07MB6820: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:46; X-Forefront-PRVS: 00594E8DBA X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: XIydMR8t8zUzAn+85o3ql7QtUzI7RVfzTgWFOEo5KkbhLBJ6ystKHLIOfBCndDwe9S4+F+GN679dwzxLg+uPIV2q+TLEJO60ZAOu6dgQ944+3r9NkVSS1Es3zeiWYFe53pOBucWvOnD5bRIW+t9G/h4bm1ktqCIxFLkqVG6pxlvKXZJ4+MuKbfx3oqOac5irwihfCXpcx1pwMjLlYqd1xruLeOTMii1tDLuQmCHTcQPDkfrXBULXvs3XjHy1cEuiwIphn6/qWhNO98FV11ZEmQXc3OcLgXWj14Kfx+eHKsxvO9X2E0zuNQ85eE3T2N2hoKZDDPzr79DzBO8QD+EdXsj2dj3dC78I3dtD9VtEI17WZKxvHFF7LePWHGJ5cJ6npGEJIpGGX3Nm1nmLARbOMmpqDn+4gN9u8FvEvbMeiNw= X-OriginatorOrg: cadence.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2019 10:04:18.7115 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f16fa206-c88d-4f73-613e-08d6e99d2cd6 X-MS-Exchange-CrossTenant-Id: d36035c5-6ce6-4662-a3dc-e762e61ae4c9 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d36035c5-6ce6-4662-a3dc-e762e61ae4c9;Ip=[158.140.1.28];Helo=[sjmaillnx1.cadence.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR07MB6820 X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 include:spf.smktg.jp include:_spf.salesforce.com include:mktomail.com include:spf-0014ca01.pphosted.com include:spf.protection.outlook.com include:auth.msgapp.com include:spf.mandrillapp.com ~all X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-06-05_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_check_notspam policy=outbound_check score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=849 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906050063 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Patch moves switch responsible for decoding descriptor type outside snprintf. It improves code readability a little. Signed-off-by: Pawel Laszczak --- drivers/usb/common/debug.c | 113 +++++++++++++++++++------------------ 1 file changed, 58 insertions(+), 55 deletions(-) diff --git a/drivers/usb/common/debug.c b/drivers/usb/common/debug.c index f948eb7d51b8..a858b3838764 100644 --- a/drivers/usb/common/debug.c +++ b/drivers/usb/common/debug.c @@ -108,62 +108,65 @@ static void usb_decode_get_set_descriptor(__u8 bRequestType, __u8 bRequest, __u16 wValue, __u16 wIndex, __u16 wLength, char *str, size_t size) { + char *s; + + switch (wValue >> 8) { + case USB_DT_DEVICE: + s = "Device"; + break; + case USB_DT_CONFIG: + s = "Configuration"; + break; + case USB_DT_STRING: + s = "String"; + break; + case USB_DT_INTERFACE: + s = "Interface"; + break; + case USB_DT_ENDPOINT: + s = "Endpoint"; + break; + case USB_DT_DEVICE_QUALIFIER: + s = "Device Qualifier"; + break; + case USB_DT_OTHER_SPEED_CONFIG: + s = "Other Speed Config"; + break; + case USB_DT_INTERFACE_POWER: + s = "Interface Power"; + break; + case USB_DT_OTG: + s = "OTG"; + break; + case USB_DT_DEBUG: + s = "Debug"; + break; + case USB_DT_INTERFACE_ASSOCIATION: + s = "Interface Association"; + break; + case USB_DT_BOS: + s = "BOS"; + break; + case USB_DT_DEVICE_CAPABILITY: + s = "Device Capability"; + break; + case USB_DT_PIPE_USAGE: + s = "Pipe Usage"; + break; + case USB_DT_SS_ENDPOINT_COMP: + s = "SS Endpoint Companion"; + break; + case USB_DT_SSP_ISOC_ENDPOINT_COMP: + s = "SSP Isochronous Endpoint Companion"; + break; + default: + s = "UNKNOWN"; + break; + } + snprintf(str, size, "%s %s Descriptor(Index = %d, Length = %d)", - bRequest == USB_REQ_GET_DESCRIPTOR ? "Get" : "Set", - ({ char *s; - switch (wValue >> 8) { - case USB_DT_DEVICE: - s = "Device"; - break; - case USB_DT_CONFIG: - s = "Configuration"; - break; - case USB_DT_STRING: - s = "String"; - break; - case USB_DT_INTERFACE: - s = "Interface"; - break; - case USB_DT_ENDPOINT: - s = "Endpoint"; - break; - case USB_DT_DEVICE_QUALIFIER: - s = "Device Qualifier"; - break; - case USB_DT_OTHER_SPEED_CONFIG: - s = "Other Speed Config"; - break; - case USB_DT_INTERFACE_POWER: - s = "Interface Power"; - break; - case USB_DT_OTG: - s = "OTG"; - break; - case USB_DT_DEBUG: - s = "Debug"; - break; - case USB_DT_INTERFACE_ASSOCIATION: - s = "Interface Association"; - break; - case USB_DT_BOS: - s = "BOS"; - break; - case USB_DT_DEVICE_CAPABILITY: - s = "Device Capability"; - break; - case USB_DT_PIPE_USAGE: - s = "Pipe Usage"; - break; - case USB_DT_SS_ENDPOINT_COMP: - s = "SS Endpoint Companion"; - break; - case USB_DT_SSP_ISOC_ENDPOINT_COMP: - s = "SSP Isochronous Endpoint Companion"; - break; - default: - s = "UNKNOWN"; - break; - } s; }), wValue & 0xff, wLength); + bRequest == USB_REQ_GET_DESCRIPTOR ? "Get" : "Set", + s, wValue & 0xff, wLength); } static void usb_decode_get_configuration(__u16 wLength, char *str, size_t size)