From mboxrd@z Thu Jan 1 00:00:00 1970 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=-10.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 9CAB9C49ED7 for ; Fri, 13 Sep 2019 08:48:10 +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 65FF4208C2 for ; Fri, 13 Sep 2019 08:48:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="NOgDCMmO"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="3KuqL4b3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 65FF4208C2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=analog.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=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.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Ch1I3rXKSo9MdOGPkEXz2eO8dToEFcIo0guj2U4/VVg=; b=NOgDCMmOkzQ1Bd cpntPkemdNnGrlENqlIPVXzcWd6P5oxYg406sCUQwaFTKqdXfM8MBCHUnnDQcFTdcfXT3rs8eAPmY hRUkhza79H+j1HmIp7Rww1HEt1VN5K2Mcp3ngTNeS5JgnMKJ642r08LNYl3EuRgqcMsbvSNdOqVsB 1+GGN/zSqiRfRvxT5S8DtWhZTc/iZQji9CGvT+ugOb8p6lmjHXAwJuBHf6pfjQE4Eq6qRyuVGbC7z dAbwH9UvH/EnGNSZR5N08U7hro8yiAzxlbwqhYVKffwOXN5CgBM/wAZMBBSPA37C4dfMOZex/+NHs D/4vmZLCF+4jupkwcVTQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1i8hFK-0003tW-TO; Fri, 13 Sep 2019 08:48:02 +0000 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1i8hDi-0002Px-J9 for linux-arm-kernel@lists.infradead.org; Fri, 13 Sep 2019 08:46:24 +0000 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 x8D8gaUA015969; Fri, 13 Sep 2019 04:46:20 -0400 Received: from nam04-co1-obe.outbound.protection.outlook.com (mail-co1nam04lp2059.outbound.protection.outlook.com [104.47.45.59]) by mx0a-00128a01.pphosted.com with ESMTP id 2uytdksa67-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 13 Sep 2019 04:46:19 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mh/R5u66BOW4fOT4zHO2FmbX9DZOdZP6ITD0O1i2rE+fdXVKJK+V5SwPl+BUvtEpmC5DdemMT2XRPYoAzk+h45bY2qgScgKxRzzeBrQVpqwNmLBK3A7Q+wt8w0HRHew6VW7h4IxHCnQTUKnhw+BL9sw6ot3KI8MR+FLu+oJg8zHGeq5kcSY+mqPXz3xeuXyK91V6hve/1UOkr+eG97Z/D0L5HJKvdRRMseoOJMjAJf15iMt3Q2JaFvzS4XedO8jvhdUhgAbwIC6K2/joXiqB+Fn63qQg4i61CgGvyKtFNJFyNg5Em8TZMchg+Itx3Mqt2X5sZHdT2nN4q/pgZanFqw== 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=8DSsgUaiyPcfIXlk2vetnOMbPD9B8m8+una/987DFjo=; b=OcaoCo4RPgYCP0sn2BDBMFBC1+SjsSYz5u6Bje3PRviFrNuJNl+LjDuy003jEeIk3WzwlElfVfjswkGZYip7bbW5Ez7SacmQuR4VAR+MiMDnjbKovBwEfq79XuJAWROc17WKys5RG6IqAjGGTWE5B8m7TJgHwM1chjt17Av1Oi992Dbqv7tN2WLKDmJ2VZzttRwUqLVZohEU4yzjyYJd/Go2EE173XUmby+h4p4KKxYe+SNOB/HVlZSXaaH4aj219snSjjesc2P8NF28VzRBmocvQQKBXLNduDSVBqf7w8MN8NgeRQOMObmFnigcT23kh6p1SgR9BQaYoBWxAeCsjw== 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=8DSsgUaiyPcfIXlk2vetnOMbPD9B8m8+una/987DFjo=; b=3KuqL4b3L3isNwlAC8nXgAma5s4Z3sUoHP09rMB6GpVZAm63RLHKqkvsSeZsKRh6Pj2xvIYryi3lxKWeTDoUOcTkwGZJowJ5JPrOGvRfXscFM9zs+NgveVOH2Gil6FjMc+GyBYy7gpmjATRN2c6A0BOiEVk/oLjkvs1y6BGfLEw= Received: from CY1PR03CA0005.namprd03.prod.outlook.com (2603:10b6:600::15) by SN6SPR01MB0060.namprd03.prod.outlook.com (2603:10b6:805:107::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.14; Fri, 13 Sep 2019 08:46:18 +0000 Received: from SN1NAM02FT050.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e44::204) by CY1PR03CA0005.outlook.office365.com (2603:10b6:600::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.14 via Frontend Transport; Fri, 13 Sep 2019 08:46:18 +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 SN1NAM02FT050.mail.protection.outlook.com (10.152.72.128) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2241.14 via Frontend Transport; Fri, 13 Sep 2019 08:46:17 +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 x8D8kCeq030628 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Fri, 13 Sep 2019 01:46:12 -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; Fri, 13 Sep 2019 04:46:17 -0400 From: Alexandru Ardelean To: , , , , , Subject: [RFC PATCH 03/15] spi: make `cs_change_delay` the first user of the `spi_delay` logic Date: Fri, 13 Sep 2019 14:45:38 +0300 Message-ID: <20190913114550.956-4-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190913114550.956-1-alexandru.ardelean@analog.com> References: <20190913114550.956-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)(396003)(136003)(39860400002)(346002)(376002)(199004)(189003)(70206006)(70586007)(54906003)(316002)(110136005)(336012)(2616005)(486006)(476003)(126002)(356004)(6666004)(106002)(7416002)(2906002)(26005)(186003)(2870700001)(5660300002)(48376002)(50226002)(426003)(44832011)(11346002)(446003)(7636002)(51416003)(8936002)(4326008)(50466002)(76176011)(2201001)(7696005)(8676002)(86362001)(36756003)(107886003)(305945005)(478600001)(246002)(1076003)(47776003)(81973001)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:SN6SPR01MB0060; 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: 11085ce2-6d45-40c4-7d8f-08d73826d805 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600166)(711020)(4605104)(4709080)(1401327)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328); SRVR:SN6SPR01MB0060; X-MS-TrafficTypeDiagnostic: SN6SPR01MB0060: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-Forefront-PRVS: 0159AC2B97 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: j2m2rWa7j8CxH4VtpCixydB4gjddpAPlkd41KEc70a3ZoXEMweSSMPkm03yj4X1v1lQwSJu1O9iGCxKPSUHDSDmaLN5v8plfyK7iip4oFIICAMSwFTy9b4rzTmAnduG1rOjMgjqm39hZXVgLjdk4wVBGY05LSx+zsoJZu+ZovdtbjvpSHXj7O59ewszgGobq6wNhGO8HXeZju9x7wmRR4/aTMLyUXNNEovV3wjW4uw25UgPXqU6BdrNZ7Q5+0VP171wJXW7grq9xq1tAvB76tvyHr/wU2vRHP4RYudP3kNPyx5C5iTt53KhLgQFbS6SWuMfyAmk0NIq7aW1SZdXRncc9HEqK5HIMt10PK/hRCYppX+eOLEQU4QhBYyK9C/U0GWvpTkBTGRBjvisw2OAmMS7tZKJEobaHhCftXfdRhNE= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2019 08:46:17.9130 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 11085ce2-6d45-40c4-7d8f-08d73826d805 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: SN6SPR01MB0060 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.70,1.0.8 definitions=2019-09-13_05:2019-09-11,2019-09-13 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 mlxlogscore=999 spamscore=0 suspectscore=0 malwarescore=0 clxscore=1015 impostorscore=0 mlxscore=0 phishscore=0 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1909130083 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190913_014623_045031_65EDD0BD X-CRM114-Status: GOOD ( 16.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: f.fainelli@gmail.com, baolin.wang@linaro.org, zhang.lyra@gmail.com, linus.walleij@linaro.org, broonie@kernel.org, orsonzhai@gmail.com, Alexandru Ardelean , jic23@kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.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. Signed-off-by: Alexandru Ardelean --- drivers/spi/spi.c | 28 +++++++--------------------- include/linux/spi/spi.h | 4 +--- 2 files changed, 8 insertions(+), 24 deletions(-) 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; -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel