Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4622817yba; Wed, 10 Apr 2019 01:07:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqw85XXCl75hawFiRgrPghGmCtVSKHpr3DRMdXAtxjiK+JgZjYStn4CuljnLcx+o+ExhuzLQ X-Received: by 2002:a62:b61a:: with SMTP id j26mr42199211pff.203.1554883629815; Wed, 10 Apr 2019 01:07:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554883629; cv=none; d=google.com; s=arc-20160816; b=AKw1egzCa9aTETx9Ur4GCuyozQu/ZT2dJTpqT+goo4ZRvyYZ/nwg4zgLJYqCAb0zhn BIUBGPEyl/umUBmuTJCfM1OVd9c8yw7fmWiFuEFkUvQgu4eFexDxirllZ/CmEJp4ZmqZ clyQm/ll1+yghXErBISkn2W7PNHTAEzq3QqnUQHIcJmWg4Z0sBFqYBceOcFd9H0XZ+dO lF65v4xJ7EQztOopmBl4IHljebloTuie0kpffj6zwt5+Rb6aHr1fiEe77T2a5XLuNbi5 x0VEHeBPmVhV0MmST5dQbsuJPIyO4YDkzEknewf3hTBMvy3EGH4uX0ghMyMHty8lk4Ss conA== 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=pQX05cqqIRIAlv/yFLTspatrIQjT2YjfWniHaF+2AbE=; b=LqUzavfOHoZqIxsJoCSB5geQwpWJDXtnefjQ+mPyGpwEZjFYVqeJxteqJ1M/mMvqOj LmnSb+k8JdQ1mryAw2IDKQJtBNfL4n8GaFWW8dTHeP+Ol4IP5W4MWkBMtJEgkkaaeJRq 4WOfbcmG9AXA9/Y7sbVFNlJmNmmStAWaXkiAOLoEhpUCl432QVoRAV5ajcva/dtQIoZN e1DzOuJsnovGWfeTx6wvSO5y3QkZEd80SwOMGd4F+S8cHKK2G/1dGSqMoKTUFv9LFwnh utBz4IHC5PRF/rep/nyjKZkdUTaWd3gHuxolnGJ1Hif+DFadnhu8Nee26DHKbHqmjIY4 XaJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cadence.com header.s=proofpoint header.b=SRwRtD2d; dkim=pass header.i=@cadence.com header.s=selector1 header.b=gG+ZEue4; 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 q61si32821017plb.245.2019.04.10.01.06.53; Wed, 10 Apr 2019 01:07:09 -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=SRwRtD2d; dkim=pass header.i=@cadence.com header.s=selector1 header.b=gG+ZEue4; 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 S1729335AbfDJIBY (ORCPT + 99 others); Wed, 10 Apr 2019 04:01:24 -0400 Received: from mx0a-0014ca01.pphosted.com ([208.84.65.235]:53250 "EHLO mx0a-0014ca01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728942AbfDJIA4 (ORCPT ); Wed, 10 Apr 2019 04:00:56 -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 x3A7uqG6001457; Wed, 10 Apr 2019 01:00:39 -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=pQX05cqqIRIAlv/yFLTspatrIQjT2YjfWniHaF+2AbE=; b=SRwRtD2d5fqTPHWE/GkRnsdkNw6BQCDINeYjuf/g0NO4OUQMPx/+nkfyT+Ciw+D73mK2 nsMgvEOtZfQVfcjw60DxVI46emHhe+PmNt5JxPr78brEsxTeUH6uqTrUnqqEZe1nDKUf uMrL53QUUg0ZpZlbalCd3y40lBn4y3kb4Ivp6Ws43oOKwQrKoIF+N3gKHbazRrazw1Eh cEzOG4CxcE9weUtpVGcpSMoaK6gDN/JPvibjfUdQOUfpYWXvqYb28GYdIAbUdb70qCjJ EYfRPFIbQ/fs/3sO8VYkhHw3dtaC2lxkXKT+u9H9VRYnMf4UAHPMsVB7PIPT9YzlSSmX 5g== Authentication-Results: cadence.com; spf=pass smtp.mailfrom=pawell@cadence.com Received: from nam03-co1-obe.outbound.protection.outlook.com (mail-co1nam03lp2059.outbound.protection.outlook.com [104.47.40.59]) by mx0a-0014ca01.pphosted.com with ESMTP id 2rr9dg0cgn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 10 Apr 2019 01:00:38 -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=pQX05cqqIRIAlv/yFLTspatrIQjT2YjfWniHaF+2AbE=; b=gG+ZEue4pUU36sF98hYSEElk+t3s0dz60+1gRyyLxDVTyVkmmnbFNAN73tv1wauQ//p7H59Coib0F0Oz6w+KZL0fPdq9guOJgFNrNcd9lTNqYEoKfEMLxVH2gaksOP2SuLRODO9nliXwJE5/Ch5zjSK/VYPyRu9kK+MqLYPmxMU= Received: from BYAPR07CA0102.namprd07.prod.outlook.com (2603:10b6:a03:12b::43) by MN2PR07MB5917.namprd07.prod.outlook.com (2603:10b6:208:ae::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1771.13; Wed, 10 Apr 2019 08:00:34 +0000 Received: from BY2NAM05FT027.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e52::205) by BYAPR07CA0102.outlook.office365.com (2603:10b6:a03:12b::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1792.14 via Frontend Transport; Wed, 10 Apr 2019 08:00:33 +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 BY2NAM05FT027.mail.protection.outlook.com (10.152.100.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1792.7 via Frontend Transport; Wed, 10 Apr 2019 08:00:33 +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 x3A80TDP028108 (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:29 +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 x3A80TFc021726; Wed, 10 Apr 2019 09:00:29 +0100 Received: (from pawell@localhost) by lvlogina.cadence.com (8.14.4/8.14.4/Submit) id x3A80TRS021721; Wed, 10 Apr 2019 09:00:29 +0100 From: Pawel Laszczak To: CC: , , , , , , , , , , , , , , , , Pawel Laszczak Subject: [PATCH v6 3/6] usb:common Patch simplify usb_decode_set_clear_feature function. Date: Wed, 10 Apr 2019 08:48:21 +0100 Message-ID: <1554882504-9010-4-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)(39860400002)(376002)(346002)(396003)(2980300002)(199004)(36092001)(189003)(6666004)(5660300002)(2351001)(11346002)(76176011)(126002)(51416003)(446003)(26826003)(47776003)(50226002)(2616005)(105596002)(8936002)(87636003)(486006)(426003)(7416002)(106466001)(336012)(86362001)(476003)(8676002)(356004)(478600001)(36756003)(2906002)(246002)(42186006)(16586007)(54906003)(48376002)(7636002)(107886003)(305945005)(186003)(4326008)(4720700003)(26005)(6916009)(50466002)(316002)(76130400001);DIR:OUT;SFP:1101;SCL:1;SRVR:MN2PR07MB5917;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: 13ef9629-73fd-4e8c-928d-08d6bd8a9be4 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600139)(711020)(4605104)(2017052603328);SRVR:MN2PR07MB5917; X-MS-TrafficTypeDiagnostic: MN2PR07MB5917: X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 00032065B2 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: Pkvf5ljY2bFYP4x+AcBL3reOa2wtGk9HLTe0fjkBBUumc4VFi08ulVQpVzE9Xw7MdJaZ/uLzIiVfKc6wXqcb1+CHB4HdU8k7oXD+IcYLFCv8qJRxMsSi4ktLFpIjkwAkoK8MwsTEsd18k4PopmCfkBjdHGvclAA+c2+Hju4AXxrLEKJYkwnVLn9vOiQKqN9GbgYrzH+qWhCB6N3TJ/mz6WIlzEBdILyRU+1ZBJ0O5df93JP2NWN45l6Q3T6Gg0C1dH7UC963LoDQZjNU/OD8KGfu4PQXJ0sZwDojff9VhUh24UmTOUQXqTIV933CufiVwHaRVuJgwc/rk3sxnh0X2cKGLHeAnR8yE6g63MUe6DkWkonCgmUSqekFRmxFen9/LjJ3tIG1Z04Bpdxb+MZ1Idp45HHkT6UyXUTJfnZksDU= X-OriginatorOrg: cadence.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Apr 2019 08:00:33.7328 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 13ef9629-73fd-4e8c-928d-08d6bd8a9be4 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: MN2PR07MB5917 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=738 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1904100058 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Patch adds usb_decode_test_mode and usb_decode_device_feature functions, which allow to make more readable and simplify the usb_decode_set_clear_feature function. Signed-off-by: Pawel Laszczak --- drivers/usb/common/debug.c | 89 ++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 46 deletions(-) diff --git a/drivers/usb/common/debug.c b/drivers/usb/common/debug.c index 3fdf116da909..ad6c96aa45b0 100644 --- a/drivers/usb/common/debug.c +++ b/drivers/usb/common/debug.c @@ -30,58 +30,55 @@ static void usb_decode_get_status(__u8 bRequestType, __u16 wIndex, } } -static void usb_decode_set_clear_feature(__u8 bRequestType, __u8 bRequest, - __u16 wValue, __u16 wIndex, - char *str, size_t size) +static const char *usb_decode_device_feature(u16 wValue) +{ + switch (wValue) { + case USB_DEVICE_SELF_POWERED: + return "Self Powered"; + case USB_DEVICE_REMOTE_WAKEUP: + return "Remote Wakeup"; + case USB_DEVICE_TEST_MODE: + return "Test Mode"; + case USB_DEVICE_U1_ENABLE: + return "U1 Enable"; + case USB_DEVICE_U2_ENABLE: + return "U2 Enable"; + case USB_DEVICE_LTM_ENABLE: + return "LTM Enable"; + default: + return "UNKNOWN"; + } +} + +static const char *usb_decode_test_mode(u16 wIndex) +{ + switch (wIndex) { + case TEST_J: + return ": TEST_J"; + case TEST_K: + return ": TEST_K"; + case TEST_SE0_NAK: + return ": TEST_SE0_NAK"; + case TEST_PACKET: + return ": TEST_PACKET"; + case TEST_FORCE_EN: + return ": TEST_FORCE_EN"; + default: + return ": UNKNOWN"; + } +} + +static void usb_decode_set_clear_feature(__u8 bRequestType, + __u8 bRequest, __u16 wValue, + __u16 wIndex, char *str, size_t size) { switch (bRequestType & USB_RECIP_MASK) { case USB_RECIP_DEVICE: snprintf(str, size, "%s Device Feature(%s%s)", bRequest == USB_REQ_CLEAR_FEATURE ? "Clear" : "Set", - ({char *s; - switch (wValue) { - case USB_DEVICE_SELF_POWERED: - s = "Self Powered"; - break; - case USB_DEVICE_REMOTE_WAKEUP: - s = "Remote Wakeup"; - break; - case USB_DEVICE_TEST_MODE: - s = "Test Mode"; - break; - case USB_DEVICE_U1_ENABLE: - s = "U1 Enable"; - break; - case USB_DEVICE_U2_ENABLE: - s = "U2 Enable"; - break; - case USB_DEVICE_LTM_ENABLE: - s = "LTM Enable"; - break; - default: - s = "UNKNOWN"; - } s; }), + usb_decode_device_feature(wValue), wValue == USB_DEVICE_TEST_MODE ? - ({ char *s; - switch (wIndex) { - case TEST_J: - s = ": TEST_J"; - break; - case TEST_K: - s = ": TEST_K"; - break; - case TEST_SE0_NAK: - s = ": TEST_SE0_NAK"; - break; - case TEST_PACKET: - s = ": TEST_PACKET"; - break; - case TEST_FORCE_EN: - s = ": TEST_FORCE_EN"; - break; - default: - s = ": UNKNOWN"; - } s; }) : ""); + usb_decode_test_mode(wIndex) : ""); break; case USB_RECIP_INTERFACE: snprintf(str, size, "%s Interface Feature(%s)", -- 2.17.1