From patchwork Mon Sep 16 07:10:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 11146457 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7897A1747 for ; Mon, 16 Sep 2019 07:10:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4D45020890 for ; Mon, 16 Sep 2019 07:10:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="uzv2qbzT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730436AbfIPHKf (ORCPT ); Mon, 16 Sep 2019 03:10:35 -0400 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:30424 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730419AbfIPHKf (ORCPT ); Mon, 16 Sep 2019 03:10:35 -0400 Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x8G77tYl014744; Mon, 16 Sep 2019 03:10:33 -0400 Received: from nam04-bn3-obe.outbound.protection.outlook.com (mail-bn3nam04lp2054.outbound.protection.outlook.com [104.47.46.54]) by mx0a-00128a01.pphosted.com with ESMTP id 2v0t293722-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 16 Sep 2019 03:10:33 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Uu/LnwZKa86YysCcFRf0bQiVeN+6qruHveGqJD5XBctNt99wG0FDOci0/8PGPTNEc3d5+XD+FZqoW+H8Y5vkdVxfxV0qtVmGM0muGKGFzJbeLbSf6x6RxcOIEMgvxUm3YFhGXlL13G2Vq3Au/AhcapQ+p9lVMD7c3qNaDQqlHvGVSpZygm2JF6TApTTzWt+kovdKJJtOjO8jeHKgNf5Sx1/RaHtq32MvWlbl1H703lZ5FLZu5BmjAwr4vm5A50JtYWjABchJQZOb7oc5sNHrYj9uTuFHcZds1evhD86+UolX74o8Ely2pndWcCKF4oRkDFmzQOv6yId9/M7ac+hVDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=N//v9tP42mO82MASuaLghoW7AUmfw1VhX5gXorThYfI=; b=VF8QrpEPq6E+DD/A/Qrox6aSqr4rgQfLlE4d0U6ao3kZ9Yn/Qnk/Yhr5MxelJ9siObbK9xgVp0EML9PsTVmYUhLKQPohabEVESe5lMPd+qe9pE/LMl1xYcrjP6BZ+pnPDYuNDjcT6vhtsVmnwzdFH98Swf5gJ3kidxMEkG2IUsXZpMtIucUUkoFiSwtQBq2GALgsmbGr/sH1EvtwcFgdnAlErN0j40af9qmWph0Ddy1ObFBm1aeqv0hYVMp75D97RE9/1QiafxnbI5w32uGTtJO/DRA1Fpyx3kpey2XOX5quDEUCMjVOXV9CAqVcQZ//oT33/pOLwQTZOCqFxQ2hiA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=N//v9tP42mO82MASuaLghoW7AUmfw1VhX5gXorThYfI=; b=uzv2qbzTwDFAScI0JgpayEjA0k83Nw0E6Mdzd9MlmjRqu96LzQ5pgx1AjvhEwMNH1/ynM62rc+KXpTD1JcRA6CCDb3I88ug3arYQTlMHnyOsBkrc+h129qj0Ao7PjaTFztGEzo+xSEPiK7M7nW0ZraNReIfHB3MEr+e+0zUUlEA= Received: from CY4PR03CA0080.namprd03.prod.outlook.com (2603:10b6:910:4d::21) by DM5PR03MB2810.namprd03.prod.outlook.com (2603:10b6:3:11a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.23; Mon, 16 Sep 2019 07:10:30 +0000 Received: from BL2NAM02FT006.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::208) by CY4PR03CA0080.outlook.office365.com (2603:10b6:910:4d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2220.19 via Frontend Transport; Mon, 16 Sep 2019 07:10:30 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta2.analog.com; Received: from nwd2mta2.analog.com (137.71.25.57) by BL2NAM02FT006.mail.protection.outlook.com (10.152.76.239) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2263.17 via Frontend Transport; Mon, 16 Sep 2019 07:10:29 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id x8G7AOlZ016106 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Mon, 16 Sep 2019 00:10:24 -0700 Received: from saturn.ad.analog.com (10.48.65.123) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Mon, 16 Sep 2019 03:10:29 -0400 From: Alexandru Ardelean To: , , CC: , , Alexandru Ardelean Subject: [PATCH v3 1/3] spi: move `cs_change_delay` backwards compat logic outside switch Date: Mon, 16 Sep 2019 10:10:22 +0300 Message-ID: <20190916071024.21447-2-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190916071024.21447-1-alexandru.ardelean@analog.com> References: <20190916071024.21447-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(39860400002)(136003)(396003)(376002)(346002)(189003)(199004)(47776003)(2906002)(2870700001)(246002)(86362001)(50466002)(8936002)(8676002)(26005)(6666004)(126002)(5660300002)(446003)(76176011)(11346002)(476003)(356004)(186003)(336012)(51416003)(4744005)(107886003)(7696005)(426003)(1076003)(70206006)(70586007)(478600001)(36756003)(2616005)(486006)(305945005)(44832011)(7636002)(110136005)(54906003)(316002)(2201001)(106002)(48376002)(50226002)(4326008)(81973001);DIR:OUT;SFP:1101;SCL:1;SRVR:DM5PR03MB2810;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;MX:1;A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c6f004eb-759f-4372-0096-08d73a74f52e X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(4709080)(1401327)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328);SRVR:DM5PR03MB2810; X-MS-TrafficTypeDiagnostic: DM5PR03MB2810: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-Forefront-PRVS: 0162ACCC24 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: djWVo9yf9y70QUX6g5JUVw4Iaa5drOQdpbWvOEsO5KEEptPrGQsf56UPIyZ4+y2qWQItyfjB8FMNixms2rw9aMiK3xp/Wu3fsevKV1JpPkc1Ha4Ppv/ZsuPFW4oTLeeZEgcMNk59s+CxL2qsPgRzWRTNkk3AkdN+46qnsY9iuHre3FNkqxveQ40GsINrnD2KOtnHp1P13B0mQDrmge+Sorxoa45zELIaaoEzmI8gqN7QHsf5IAjqyNdoL3XYXCgcoemuZjjjFM7uUW5ZRSZLuPBfBuxvJwLCrPcyww05507N+YrIWyAwDqNiKbY0WQf6kDeIMsjDUdzwzIZL8Q5gPVBPFOuM6AOqryx15FRy35oE1QVF6DmgVZRhRXVLjpPVPQndGPYpRGtYyfvjubIoRBj2iJAt4Vk/xQwqBWmfFM4= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2019 07:10:29.9834 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c6f004eb-759f-4372-0096-08d73a74f52e X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2810 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.70,1.0.8 definitions=2019-09-16_04:2019-09-11,2019-09-16 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 priorityscore=1501 clxscore=1015 malwarescore=0 suspectscore=0 phishscore=0 lowpriorityscore=0 mlxscore=0 adultscore=0 bulkscore=0 spamscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1909160077 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The `cs_change_delay` backwards compatibility value could be moved outside of the switch statement. The only reason to do it, is to make the next patches easier to diff. Signed-off-by: Alexandru Ardelean --- drivers/spi/spi.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 75ac046cae52..c90e02e6d62f 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1114,16 +1114,15 @@ static void _spi_transfer_cs_change_delay(struct spi_message *msg, u32 hz; /* return early on "fast" mode - for everything but USECS */ - if (!delay && unit != SPI_DELAY_UNIT_USECS) + if (!delay) { + if (unit == SPI_DELAY_UNIT_USECS) + _spi_transfer_delay_ns(10000); return; + } switch (unit) { case SPI_DELAY_UNIT_USECS: - /* for compatibility use default of 10us */ - if (!delay) - delay = 10000; - else - delay *= 1000; + delay *= 1000; break; case SPI_DELAY_UNIT_NSECS: /* nothing to do here */ break; From patchwork Mon Sep 16 07:10:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 11146449 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 936841745 for ; Mon, 16 Sep 2019 07:10:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 67D1D20890 for ; Mon, 16 Sep 2019 07:10:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="zJIBugjt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730442AbfIPHKj (ORCPT ); Mon, 16 Sep 2019 03:10:39 -0400 Received: from mx0b-00128a01.pphosted.com ([148.163.139.77]:18184 "EHLO mx0b-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730480AbfIPHKi (ORCPT ); Mon, 16 Sep 2019 03:10:38 -0400 Received: from pps.filterd (m0167091.ppops.net [127.0.0.1]) by mx0b-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x8G78bJj003274; Mon, 16 Sep 2019 03:10:33 -0400 Received: from nam03-by2-obe.outbound.protection.outlook.com (mail-by2nam03lp2052.outbound.protection.outlook.com [104.47.42.52]) by mx0b-00128a01.pphosted.com with ESMTP id 2v0sy93f3f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 16 Sep 2019 03:10:33 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MRT4/brWybreJ+QFUUDIuUFybAYTIncx0gDxceAzoeOHsWN/C6KKVc1MEEI/gAiTFQEcJcacLMM5oWClMdcab/U6cbnvShz3lGY+mZcabpIEUzitsnlajuNS7SfDHNIMs1kJsVQ3VjHsH6zpKQWqSF261ry1by2eeBOsP2O4AG+I46buYzIYdgx8Zvs4ZMPidcREL1Mk0Ps9NOyayrEneakwnSMPK96nmFfrTUGOyoYhKgmibEbZGpbT3N8i7gl2lvLVv+BfGF/4/+VU37jayg1VZaOcMlCL0gZGs4RriwGrWWzJhjWe3sHTy9/ygmdSSwGK4FXcZ9gZlXgED02sQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ESeHHXBfFrG988glXvaIvhiPmUc6BnNdkc+lsz3piTo=; b=JJ57e2jUCd1+6F6ernLeR+UTDTaM8NzAZgS89Z+bK6Qigs8FCRe337HfHZgPICDGwMsjtMvniJFVsoC5zNED7BkaMw01pvm5pkxeTms5WkFr783mhewhxVyfXXJ6w9rnF3npCQ6dxET6LE17ARJA864TiAKeulncXdGF8l+f+SqVhdME+ObaTG7t5DFs45DNPzysGv7w2w4ZSC7wPetr14Fvz94TkMtjI0IGbUdog1zxY+7MOAWn32TRkpUpaWqEMMS3q+xkr6zTnLJIOmhgtOM8yxpSQ9VUtqT/Z173Ilw+dzl0hSOcVClkcdP4kygJqsIZTfo26MsOjLQ7jtjDmw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ESeHHXBfFrG988glXvaIvhiPmUc6BnNdkc+lsz3piTo=; b=zJIBugjtoEtSuzovi30f/4gucIUVmzj1RHgtr4cS19Zx0OH+EwCOTAvcwVbv307t73tbB9bLsQQYtWCsrL/t1NgOz2oieWyBLHBmopKKtjlttHpDOSVYmJ88CqXLhvuvxrvxnMvlRCeqACzhwWWSMsp9+cdoUay0YAk/Fo4BW3Q= Received: from MWHPR03CA0001.namprd03.prod.outlook.com (2603:10b6:300:117::11) by MWHPR03MB2575.namprd03.prod.outlook.com (2603:10b6:300:45::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.17; Mon, 16 Sep 2019 07:10:32 +0000 Received: from BL2NAM02FT038.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::200) by MWHPR03CA0001.outlook.office365.com (2603:10b6:300:117::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.15 via Frontend Transport; Mon, 16 Sep 2019 07:10:31 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta2.analog.com; Received: from nwd2mta2.analog.com (137.71.25.57) by BL2NAM02FT038.mail.protection.outlook.com (10.152.77.25) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2263.17 via Frontend Transport; Mon, 16 Sep 2019 07:10:31 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id x8G7AQvZ016120 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Mon, 16 Sep 2019 00:10:26 -0700 Received: from saturn.ad.analog.com (10.48.65.123) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Mon, 16 Sep 2019 03:10:31 -0400 From: Alexandru Ardelean To: , , CC: , , Alexandru Ardelean Subject: [PATCH v3 2/3] spi: introduce spi_delay struct as "value + unit" & spi_delay_exec() Date: Mon, 16 Sep 2019 10:10:23 +0300 Message-ID: <20190916071024.21447-3-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190916071024.21447-1-alexandru.ardelean@analog.com> References: <20190916071024.21447-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(376002)(346002)(136003)(39860400002)(396003)(199004)(189003)(2616005)(107886003)(478600001)(246002)(50466002)(106002)(426003)(186003)(36756003)(2201001)(110136005)(486006)(44832011)(26005)(48376002)(316002)(7636002)(54906003)(305945005)(446003)(47776003)(50226002)(7696005)(356004)(2906002)(70586007)(70206006)(476003)(51416003)(8676002)(5660300002)(2870700001)(126002)(336012)(76176011)(14444005)(6666004)(86362001)(1076003)(4326008)(11346002)(8936002);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR03MB2575;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 007c9fdb-0def-4145-c188-08d73a74f61e X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(4709080)(1401327)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328);SRVR:MWHPR03MB2575; X-MS-TrafficTypeDiagnostic: MWHPR03MB2575: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-Forefront-PRVS: 0162ACCC24 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: cJ3ZfMhwlRk9gX6zUcX2rPod4tvASTFPgxz+UN+WYJw+I8ubwzu5ETVxgE55/iqfGtJlHsWrzYZlAAqASGplGiKr/0mySKAWrxjF6x3aj0GqqeSZ2uWIoyiK+yhB6PPZxLsR2baMfy1kWMXcPbK2y4MNAnf+EztG3I/Es3i6k+kNQ3iDSWIiXhiRKCP7cPgROahC5Oh8Dor1aMmE8alr0DdU0BjCWC9ia1i1ZALbbHqDztMfVV9Ud83QP9l2ZJyZWuur/Or18J2cg2PVJ/F3u2ep4ETD7qHgohzkw09rJpSxRkkkd4OTCIDILYc0NIBfcABMR7csMYElUOePN7ydQf+7z6joUiKXCESLgknsmopN3F4Wrx1XC6eqb+PiHS2DSe00IaU+ON03mvsV2LnFj8VC+TmHDJ8RQUuBk9FkrP8= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2019 07:10:31.5622 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 007c9fdb-0def-4145-c188-08d73a74f61e X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR03MB2575 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.70,1.0.8 definitions=2019-09-16_04:2019-09-11,2019-09-16 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 phishscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 priorityscore=1501 clxscore=1015 malwarescore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1909160077 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org There are plenty of delays that have been introduced in SPI core. Most of them are in micro-seconds, some need to be in nano-seconds, and some in clock-cycles. For some of these delays (related to transfers & CS timing) it may make sense to have a `spi_delay` struct that abstracts these a bit. The important element of these delays [for unification] seems to be the `unit` of the delay. It looks like micro-seconds is good enough for most people, but every-once in a while, some delays seem to require other units of measurement. This change adds the `spi_delay` struct & a `spi_delay_exec()` function that processes a `spi_delay` object/struct to execute the delay. It's a copy of the `cs_change_delay` mechanism, but without the default for 10 uS. The clock-cycle delay unit is a bit special, as it needs to be bound to an `spi_transfer` object to execute. Signed-off-by: Alexandru Ardelean --- drivers/spi/spi.c | 51 +++++++++++++++++++++++++++++++++++++++++ include/linux/spi/spi.h | 18 ++++++++++++--- 2 files changed, 66 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index c90e02e6d62f..1883de8ffa82 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1106,6 +1106,57 @@ static void _spi_transfer_delay_ns(u32 ns) } } +static int _spi_delay_to_ns(struct spi_delay *_delay, struct spi_transfer *xfer) +{ + u32 delay = _delay->value; + u32 unit = _delay->unit; + u32 hz; + + if (!delay) + return 0; + + switch (unit) { + case SPI_DELAY_UNIT_USECS: + delay *= 1000; + break; + case SPI_DELAY_UNIT_NSECS: /* nothing to do here */ + break; + case SPI_DELAY_UNIT_SCK: + /* clock cycles need to be obtained from spi_transfer */ + if (!xfer) + return -EINVAL; + /* if there is no effective speed know, then approximate + * by underestimating with half the requested hz + */ + hz = xfer->effective_speed_hz ?: xfer->speed_hz / 2; + if (!hz) + return -EINVAL; + delay *= DIV_ROUND_UP(1000000000, hz); + break; + default: + return -EINVAL; + } + + return delay; +} + +int spi_delay_exec(struct spi_delay *_delay, struct spi_transfer *xfer) +{ + int delay; + + if (!_delay) + return -EINVAL; + + delay = _spi_delay_to_ns(_delay, xfer); + if (delay < 0) + return delay; + + _spi_transfer_delay_ns(delay); + + return 0; +} +EXPORT_SYMBOL_GPL(spi_delay_exec); + static void _spi_transfer_cs_change_delay(struct spi_message *msg, struct spi_transfer *xfer) { diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index af4f265d0f67..c18cfa7cda35 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -89,6 +89,21 @@ void spi_statistics_add_transfer_stats(struct spi_statistics *stats, #define SPI_STATISTICS_INCREMENT_FIELD(stats, field) \ SPI_STATISTICS_ADD_TO_FIELD(stats, field, 1) +/** + * struct spi_delay - SPI delay information + * @value: Value for the delay + * @unit: Unit for the delay + */ +struct spi_delay { +#define SPI_DELAY_UNIT_USECS 0 +#define SPI_DELAY_UNIT_NSECS 1 +#define SPI_DELAY_UNIT_SCK 2 + u16 value; + u8 unit; +}; + +extern int spi_delay_exec(struct spi_delay *_delay, struct spi_transfer *xfer); + /** * struct spi_device - Controller side proxy for an SPI slave device * @dev: Driver model representation of the device. @@ -834,9 +849,6 @@ struct spi_transfer { u16 delay_usecs; u16 cs_change_delay; u8 cs_change_delay_unit; -#define SPI_DELAY_UNIT_USECS 0 -#define SPI_DELAY_UNIT_NSECS 1 -#define SPI_DELAY_UNIT_SCK 2 u32 speed_hz; u16 word_delay; From patchwork Mon Sep 16 07:10:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 11146453 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 29A711745 for ; Mon, 16 Sep 2019 07:10:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E94A1214AF for ; Mon, 16 Sep 2019 07:10:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="IW5Kgtm+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730464AbfIPHKh (ORCPT ); Mon, 16 Sep 2019 03:10:37 -0400 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:31532 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730442AbfIPHKg (ORCPT ); Mon, 16 Sep 2019 03:10:36 -0400 Received: from pps.filterd (m0167089.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x8G77rTx016418; Mon, 16 Sep 2019 03:10:35 -0400 Received: from nam03-by2-obe.outbound.protection.outlook.com (mail-by2nam03lp2058.outbound.protection.outlook.com [104.47.42.58]) by mx0a-00128a01.pphosted.com with ESMTP id 2v0w47jsqt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 16 Sep 2019 03:10:35 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n/WqhpnIFsZ4NzI9kInAeB5SiaaXeJ/YsCvdWJbsiBdnVYtkaHXeESd5h9z8lrW9garb5O2+Fr9Y4L7zKbV3PzLSgIfGeZmzBuHns+s1sZR6fso9ulbZsVElBXQFYQBK/lfbGsGYo0K4aaybHKCo6EJ7kISMhRQjcSy/K+DUTtapbqhE1mYsPZ/ycOzSJcOqSuchzzRRUs2Xd9iZPbM92YSfi8dye5tUgQkZpbMoiU1YjUYCCd+zqsxj+Z8955fTcDY2oIwO9nCeH0dVw+cRyKkZYPK/1EAU1qmJHfmqrXWicVSQ6cl/bFjHR99+7caDKAKfLJ01rtieOKZDKI265Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xaM1SxqT2GWMH5PNNJdquphJwaB2Lq4IgSpM3l/5FJI=; b=jtfAtDxiFV/9IkoZUxCJLi8HHWB0+QdCw66+5k3yVWWO/0aZC4Nfal9C3j4kBv73zlYDkqHkLQoQbc4Ll9rqrjQHe+k3lK+/nct4IHevgUQOg3U6k0w26PtODTzwujgzYMf0mXcJheLH9O+b53cm/7b38ulkQJ8j3SjTdGFijn0yneckL3jowgm65f3puVSjjCaY5F53rM4ino2+JmYMAjoWmA0mPHe2pp0LNwly6Fro/ZaU/dZqDPMo0kAupxlkFYDVBdh1SLCk7iH3cwoX9cNYLbpILl2OHTn8JNFG9yo7/gpkziX79H3JeIZTAZeQgxGxP8/WGM7h8tsvlO1CcQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.57) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xaM1SxqT2GWMH5PNNJdquphJwaB2Lq4IgSpM3l/5FJI=; b=IW5Kgtm+f9x3axQuikIbm9IraxLKFEZSz6/BNZO4DMKJRNieSxETX/7wI0Pmue4e3LgPADWTXg10UfHxaBAycpflYPZ3yD7IG9eesWiwu0TG6CFZVhMqbzVzskgLE5njkpRfIYo589aRdaNDbwp0gr98JJ9YqAtQHuAQphgHyF8= Received: from MWHPR03CA0029.namprd03.prod.outlook.com (2603:10b6:301:3b::18) by MN2PR03MB4733.namprd03.prod.outlook.com (2603:10b6:208:106::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.15; Mon, 16 Sep 2019 07:10:33 +0000 Received: from BL2NAM02FT028.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::204) by MWHPR03CA0029.outlook.office365.com (2603:10b6:301:3b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.15 via Frontend Transport; Mon, 16 Sep 2019 07:10:33 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta2.analog.com; Received: from nwd2mta2.analog.com (137.71.25.57) by BL2NAM02FT028.mail.protection.outlook.com (10.152.77.165) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2263.17 via Frontend Transport; Mon, 16 Sep 2019 07:10:33 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id x8G7ASeQ016135 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Mon, 16 Sep 2019 00:10:28 -0700 Received: from saturn.ad.analog.com (10.48.65.123) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Mon, 16 Sep 2019 03:10:32 -0400 From: Alexandru Ardelean To: , , CC: , , Alexandru Ardelean Subject: [PATCH v3 3/3] spi: make `cs_change_delay` the first user of the `spi_delay` logic Date: Mon, 16 Sep 2019 10:10:24 +0300 Message-ID: <20190916071024.21447-4-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190916071024.21447-1-alexandru.ardelean@analog.com> References: <20190916071024.21447-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(376002)(346002)(39860400002)(396003)(136003)(189003)(199004)(86362001)(426003)(26005)(246002)(186003)(48376002)(316002)(47776003)(2870700001)(305945005)(5660300002)(54906003)(110136005)(2906002)(106002)(51416003)(7696005)(36756003)(76176011)(50226002)(107886003)(4326008)(486006)(11346002)(126002)(44832011)(476003)(2616005)(7636002)(8936002)(6666004)(356004)(446003)(478600001)(1076003)(70206006)(14444005)(70586007)(50466002)(8676002)(2201001)(336012)(81973001);DIR:OUT;SFP:1101;SCL:1;SRVR:MN2PR03MB4733;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;MX:1;A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0020b6fc-e89e-4413-823d-08d73a74f71b X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(4709080)(1401327)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328);SRVR:MN2PR03MB4733; X-MS-TrafficTypeDiagnostic: MN2PR03MB4733: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-Forefront-PRVS: 0162ACCC24 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: OujM9dNsT/stJcuALV6tHpdaN9Ax0tIQ9ypahZnzuPLnxb5rvlZXC0YEmf7dKeHvT+cj9I/s0Yq8jAatb83r16m7R6HYvfwN0R1CPiUTJTbH6YZ/9JSBo9QY8k1fP30GJStBkjaE7EFFqqQlcfIlx8rAAXdcuOv4ff6diu7d89ClnCy1h8VUZBAOlXQ+3JdnyK3UKCfdo8KKcOfq5V1qFf3coRfm6V2jDseqSsR9Gqx8L6nAlzYFPVnNdkkMzR17uZACR3IrkO/uM2obNd2/o9fHgxFI+U6QcH6S3xnGg3t2jyJpL9W0fnGOebNAONoiAOhfjl7aGKsNltE74GB8nxe9iDU2omoL3YhrkUPqNmbes0uKfls7oBPK6X2R3PVctq0kJs21Sb/VYdvFmqfit3nVADpobsipsQiGWdR9QNw= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2019 07:10:33.2186 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0020b6fc-e89e-4413-823d-08d73a74f71b X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR03MB4733 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.70,1.0.8 definitions=2019-09-16_04:2019-09-11,2019-09-16 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 lowpriorityscore=0 impostorscore=0 mlxscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 priorityscore=1501 suspectscore=0 spamscore=0 phishscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1909160077 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Since the logic for `spi_delay` struct + `spi_delay_exec()` has been copied from the `cs_change_delay` logic, it's natural to make this delay, the first user. The `cs_change_delay` logic requires that the default remain 10 uS, in case it is unspecified/unconfigured. So, there is some special handling needed to do that. The ADIS library is one of the few users of the new `cs_change_delay` parameter for an spi_transfer. The introduction of the `spi_delay` struct, requires that the users of of `cs_change_delay` get an update. This change also updates the ADIS library. Signed-off-by: Alexandru Ardelean --- drivers/iio/imu/adis.c | 24 ++++++++++++------------ drivers/spi/spi.c | 28 +++++++--------------------- include/linux/spi/spi.h | 4 +--- 3 files changed, 20 insertions(+), 36 deletions(-) diff --git a/drivers/iio/imu/adis.c b/drivers/iio/imu/adis.c index 1631c255deab..2cd2cc2316c6 100644 --- a/drivers/iio/imu/adis.c +++ b/drivers/iio/imu/adis.c @@ -39,24 +39,24 @@ int adis_write_reg(struct adis *adis, unsigned int reg, .len = 2, .cs_change = 1, .delay_usecs = adis->data->write_delay, - .cs_change_delay = adis->data->cs_change_delay, - .cs_change_delay_unit = SPI_DELAY_UNIT_USECS, + .cs_change_delay.value = adis->data->cs_change_delay, + .cs_change_delay.unit = SPI_DELAY_UNIT_USECS, }, { .tx_buf = adis->tx + 2, .bits_per_word = 8, .len = 2, .cs_change = 1, .delay_usecs = adis->data->write_delay, - .cs_change_delay = adis->data->cs_change_delay, - .cs_change_delay_unit = SPI_DELAY_UNIT_USECS, + .cs_change_delay.value = adis->data->cs_change_delay, + .cs_change_delay.unit = SPI_DELAY_UNIT_USECS, }, { .tx_buf = adis->tx + 4, .bits_per_word = 8, .len = 2, .cs_change = 1, .delay_usecs = adis->data->write_delay, - .cs_change_delay = adis->data->cs_change_delay, - .cs_change_delay_unit = SPI_DELAY_UNIT_USECS, + .cs_change_delay.value = adis->data->cs_change_delay, + .cs_change_delay.unit = SPI_DELAY_UNIT_USECS, }, { .tx_buf = adis->tx + 6, .bits_per_word = 8, @@ -139,16 +139,16 @@ int adis_read_reg(struct adis *adis, unsigned int reg, .len = 2, .cs_change = 1, .delay_usecs = adis->data->write_delay, - .cs_change_delay = adis->data->cs_change_delay, - .cs_change_delay_unit = SPI_DELAY_UNIT_USECS, + .cs_change_delay.value = adis->data->cs_change_delay, + .cs_change_delay.unit = SPI_DELAY_UNIT_USECS, }, { .tx_buf = adis->tx + 2, .bits_per_word = 8, .len = 2, .cs_change = 1, .delay_usecs = adis->data->read_delay, - .cs_change_delay = adis->data->cs_change_delay, - .cs_change_delay_unit = SPI_DELAY_UNIT_USECS, + .cs_change_delay.value = adis->data->cs_change_delay, + .cs_change_delay.unit = SPI_DELAY_UNIT_USECS, }, { .tx_buf = adis->tx + 4, .rx_buf = adis->rx, @@ -156,8 +156,8 @@ int adis_read_reg(struct adis *adis, unsigned int reg, .len = 2, .cs_change = 1, .delay_usecs = adis->data->read_delay, - .cs_change_delay = adis->data->cs_change_delay, - .cs_change_delay_unit = SPI_DELAY_UNIT_USECS, + .cs_change_delay.value = adis->data->cs_change_delay, + .cs_change_delay.unit = SPI_DELAY_UNIT_USECS, }, { .rx_buf = adis->rx + 2, .bits_per_word = 8, diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 1883de8ffa82..d0bf0ffca042 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1160,9 +1160,9 @@ EXPORT_SYMBOL_GPL(spi_delay_exec); static void _spi_transfer_cs_change_delay(struct spi_message *msg, struct spi_transfer *xfer) { - u32 delay = xfer->cs_change_delay; - u32 unit = xfer->cs_change_delay_unit; - u32 hz; + u32 delay = xfer->cs_change_delay.value; + u32 unit = xfer->cs_change_delay.unit; + int ret; /* return early on "fast" mode - for everything but USECS */ if (!delay) { @@ -1171,27 +1171,13 @@ static void _spi_transfer_cs_change_delay(struct spi_message *msg, return; } - switch (unit) { - case SPI_DELAY_UNIT_USECS: - delay *= 1000; - break; - case SPI_DELAY_UNIT_NSECS: /* nothing to do here */ - break; - case SPI_DELAY_UNIT_SCK: - /* if there is no effective speed know, then approximate - * by underestimating with half the requested hz - */ - hz = xfer->effective_speed_hz ?: xfer->speed_hz / 2; - delay *= DIV_ROUND_UP(1000000000, hz); - break; - default: + ret = spi_delay_exec(&xfer->cs_change_delay, xfer); + if (ret) { dev_err_once(&msg->spi->dev, "Use of unsupported delay unit %i, using default of 10us\n", - xfer->cs_change_delay_unit); - delay = 10000; + unit); + _spi_transfer_delay_ns(10000); } - /* now sleep for the requested amount of time */ - _spi_transfer_delay_ns(delay); } /* diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index c18cfa7cda35..9ded3f44d58e 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -754,7 +754,6 @@ extern void spi_res_release(struct spi_controller *ctlr, * @cs_change: affects chipselect after this transfer completes * @cs_change_delay: delay between cs deassert and assert when * @cs_change is set and @spi_transfer is not the last in @spi_message - * @cs_change_delay_unit: unit of cs_change_delay * @delay_usecs: microseconds to delay after this transfer before * (optionally) changing the chipselect status, then starting * the next transfer or completing this @spi_message. @@ -847,8 +846,7 @@ struct spi_transfer { u8 bits_per_word; u8 word_delay_usecs; u16 delay_usecs; - u16 cs_change_delay; - u8 cs_change_delay_unit; + struct spi_delay cs_change_delay; u32 speed_hz; u16 word_delay;