Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4673619yba; Wed, 10 Apr 2019 02:27:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqyHCzGQjCljAE5JtvESFE45mGkmcQJnk9/ZDRSOtF8qyfaiPfX1P0PmjFnjQZvwLUr2L+qB X-Received: by 2002:a62:1815:: with SMTP id 21mr42956669pfy.107.1554888451960; Wed, 10 Apr 2019 02:27:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554888451; cv=none; d=google.com; s=arc-20160816; b=rnV+kquUh9heSyqbbm45NtbyWvEPRXXddziwFJ3ZzHJNj+Tj53ZNJmgRHUgT3bOeR6 55jYJgVc8EIk60eno8cFBhfuweyVDRF+HsPMWfYAyV6lfAx3wDhyZArF9L+wB5uuXu34 kisp/oVpsnOABob7NsPtNDI+MrMcrpX60oQ9JI3optGzJEkPdaYPXmGZkPBjceJUOJTj F63sb93dycLaZE+xfGyBWGXLdlWaZkPCaUZQOt0ArjKg7K5VGQ7pS2Ukr1sVLWiWA5gE tml5r/niOP3BsZ5z9evzyIoUEvFVwxdOlpgc7eNU//sedrxJ6r+UgOzlivfsEsyFlT11 yGCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=9sYRTpxdlVHnn5/oHJPtFelTxxi3AU7r4B61wajNYMM=; b=HgkCgzoKUvjs3qPmV8jylykUi1qjb1KOeBcj1+I4M6MeYzJRkWnqeXiCSAP63rUNf5 c7KaBtAjUAZvqr0uSRESI87lSrl6vGNeS/RVJEdkIuXPDQwyG7dvWACHyGUdmpjKuLlX CkoyS0ePKuItKfZKGGRP+ZphLNcEVDDy75o254nzT4YFEdCHsKf8MRxEKyV4drtQ5Z53 35ELToP0JBZUhWVDNFoZqm8k3kyYnojOYOXUohHV8lnhbM72/RiMgwCCoKcUxuYoZoMZ jBXm/zKA3u7oNaMotRzAVKKq4beYtfTIoBhGCNjJg54XrD3lqQWEO9iHTAWJ72mwSmau wjBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cadence.com header.s=proofpoint header.b=OwQkab7f; dkim=pass header.i=@cadence.com header.s=selector1 header.b=mxLtGpCV; 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=pass (p=NONE sp=NONE dis=NONE) header.from=cadence.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v40si4113948plg.409.2019.04.10.02.27.15; Wed, 10 Apr 2019 02:27:31 -0700 (PDT) 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; dkim=pass header.i=@cadence.com header.s=proofpoint header.b=OwQkab7f; dkim=pass header.i=@cadence.com header.s=selector1 header.b=mxLtGpCV; 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=pass (p=NONE sp=NONE dis=NONE) header.from=cadence.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729317AbfDJIBE (ORCPT + 99 others); Wed, 10 Apr 2019 04:01:04 -0400 Received: from mx0b-0014ca01.pphosted.com ([208.86.201.193]:54038 "EHLO mx0a-0014ca01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729277AbfDJIBD (ORCPT ); Wed, 10 Apr 2019 04:01:03 -0400 Received: from pps.filterd (m0042333.ppops.net [127.0.0.1]) by mx0b-0014ca01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x3A7xp9F017643; Wed, 10 Apr 2019 01:00:48 -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=9sYRTpxdlVHnn5/oHJPtFelTxxi3AU7r4B61wajNYMM=; b=OwQkab7fXXpUCfbvr6AQddbvlMnh6vy7kZG6BQuyermAaL7p9YdbqltUAHxPxyrN+i6N QVqKTfX/jv93ZYaLFsww0UO08odLRG6VhNYwnZmrWyLYlCo4yh3B/wQHGpggAHA1a85M KhDGhzU+zTXOrikBaj0NXZzrC+7ZaIe068m1++TRySDkKCp096fl8vRF08PAitmPFRZz bJ+03FhlYJk6tfUCtmRvOgFM7dx5R/Pnx1HUyBrPpKPb0vbRa2m7ifIL21gHjvn9hXIH qc6rqPMSBye2WbVdm9kM7k67enY8a0R8V4TBp4g/iuSFJlwWxew5oXkLsPC9BV572SUz Tg== Authentication-Results: cadence.com; spf=pass smtp.mailfrom=pawell@cadence.com Received: from nam03-by2-obe.outbound.protection.outlook.com (mail-by2nam03lp2054.outbound.protection.outlook.com [104.47.42.54]) by mx0b-0014ca01.pphosted.com with ESMTP id 2rsa27rm7t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 10 Apr 2019 01:00:48 -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=9sYRTpxdlVHnn5/oHJPtFelTxxi3AU7r4B61wajNYMM=; b=mxLtGpCVBYm0eRqUB4VqlINaAM1WjnN+onkO8tJ2IhPz8faEi7/R7UiAi7+BEWVXoOy6fef7VMPJYn83nH9HxzeWNcJkzahkvnCiRw8+WifKPOaZ8cfJLGTerFOFsVr6ukowziXzfw69aTsUhGMd5wZy6ctghDWDv9ILFoEYrYs= Received: from BYAPR07CA0100.namprd07.prod.outlook.com (2603:10b6:a03:12b::41) by BL2PR07MB2292.namprd07.prod.outlook.com (2a01:111:e400:c752::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1771.19; Wed, 10 Apr 2019 08:00:36 +0000 Received: from DM3NAM05FT046.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e51::200) by BYAPR07CA0100.outlook.office365.com (2603:10b6:a03:12b::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1792.15 via Frontend Transport; Wed, 10 Apr 2019 08:00:36 +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 DM3NAM05FT046.mail.protection.outlook.com (10.152.98.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1792.7 via Frontend Transport; Wed, 10 Apr 2019 08:00:35 +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 x3A80TDQ028108 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Wed, 10 Apr 2019 01:00:33 -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, 10 Apr 2019 10:00:30 +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, 10 Apr 2019 10:00:29 +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 x3A80TSa021761; Wed, 10 Apr 2019 09:00:29 +0100 Received: (from pawell@localhost) by lvlogina.cadence.com (8.14.4/8.14.4/Submit) id x3A80Tla021739; Wed, 10 Apr 2019 09:00:29 +0100 From: Pawel Laszczak To: CC: , , , , , , , , , , , , , , , , Pawel Laszczak Subject: [PATCH v6 4/6] usb:common Simplify usb_decode_get_set_descriptor function. Date: Wed, 10 Apr 2019 08:48:22 +0100 Message-ID: <1554882504-9010-5-git-send-email-pawell@cadence.com> X-Mailer: git-send-email 1.7.11.2 In-Reply-To: <1554882504-9010-1-git-send-email-pawell@cadence.com> References: <1554882504-9010-1-git-send-email-pawell@cadence.com> MIME-Version: 1.0 Content-Type: text/plain 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)(136003)(346002)(39860400002)(376002)(396003)(2980300002)(199004)(189003)(36092001)(2616005)(478600001)(336012)(7416002)(126002)(87636003)(105596002)(6916009)(36756003)(4720700003)(11346002)(486006)(106466001)(76176011)(476003)(7636002)(305945005)(50466002)(2351001)(48376002)(246002)(356004)(8676002)(50226002)(6666004)(8936002)(26826003)(426003)(5660300002)(47776003)(26005)(42186006)(2906002)(107886003)(186003)(51416003)(86362001)(4326008)(446003)(76130400001)(316002)(54906003)(16586007);DIR:OUT;SFP:1101;SCL:1;SRVR:BL2PR07MB2292;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: 5f0aaff6-8232-4107-09da-08d6bd8a9d31 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600139)(711020)(4605104)(2017052603328);SRVR:BL2PR07MB2292; X-MS-TrafficTypeDiagnostic: BL2PR07MB2292: X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 00032065B2 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: TiLzL300Q6/hXCAEwVLlhhkWOMDWVTCruY0WW9MsHsCq8rSisgT4xAfOqb+hrLSSfMK4tK9KPcF6dp6HBtHkJxD4fEZG2fgW+EH6GF5GQs4u7pLyUdaP9n/fJ1pbBIyipux+PAT01jGbSURzN32vLVpLGTfZ8nnT+c26Dj0IA5xXUH2X5lOByuR6+mo3R/kRsyjQlU0D40+z/wvpBqwJla2UWmq6UBXgGk3UY1wuXtSRapQMgfy/AQ0SdBzZS0dLCmzChazwubdO7W828+EzrB1wC2SOGIBah9zeQHdLUXAGkYPY324ZDFFQgU/cASdkvHqRf+udYKllezZhuGaXJuB9ZZEXLeh7N7tGkWt0gAVvIcUd9j0olu5+zAZL80ILZOtONf2quxD2cLeghOPixLjvFTs9R06TutPI9UIr4Dw= X-OriginatorOrg: cadence.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Apr 2019 08:00:35.0869 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5f0aaff6-8232-4107-09da-08d6bd8a9d31 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: BL2PR07MB2292 X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 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-04-10_05:,, 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=876 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1904100059 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 ad6c96aa45b0..8e2c81a40cf8 100644 --- a/drivers/usb/common/debug.c +++ b/drivers/usb/common/debug.c @@ -105,62 +105,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) -- 2.17.1