Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp896373ybt; Tue, 7 Jul 2020 03:00:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwa2WdCX4/XTpL0Imybqxhp/TPqpDxW8kVEUd6NEzDezaAjEU5+8MMWP8CIs2qOxZJhalsV X-Received: by 2002:a17:906:2c02:: with SMTP id e2mr30629524ejh.64.1594116017984; Tue, 07 Jul 2020 03:00:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594116017; cv=none; d=google.com; s=arc-20160816; b=oRaraoRVNq0SN2WnVm3TbcFywEkEyejlXdb57LpLOwgHBmQDynL3v5q3FBWEu+uxWq 19mGDfVssO8WVUabbyx26bV2oqOuD/SQHD6HrFRKiiG4W+5kQOCgP90OKgGKxNS5IsWr jS20nrcDf0vg4rthOTXpqiqf/SZVVUQaskwQTP7JWr39HZLox0zUKTtg7n0hSUV7WBFj cgYUQh5xN5v5WXzTS5+2HxqVIGTqUVomGw57Pg8IlGl9Thn7A5umBe+RjjlksOsQRu+h NSkPB87IzYACASxQIgEHkVFagaY9JnRaadH78CryIYGZ9cbekRr+LRKSHz3eoKolcolB +Ggw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=C4eDJfDQ2O8UUzPVYO4ixzIP7yiUb1/eu6C6M7C54kk=; b=J+jgSCQQgnmmMf7q9bXEHcoGCUx3BVZxPxZ2/tJtsXGg1CwDo16HjTmlh/kvBssa29 KQlS4POxJwZiWCgXrbjrd3y1PzXdlsT4nH/Qs4P2Mv2Dhb/vy2CkIGZp8qgC582S5BbS Zo5vulQTysg4ZhcwSXdA6b8BRcTzq89l5Tf9JrSVrK8wyzruPplMrq+pyEQjT3uKHvoz gm8lArznR6oxqn/cwjenDgwY9w+zHgtNAoFcwmFi8neSSSNEaR19KZOvOM2C5LB92M2x +V9gXCq7vDk1CJfZo/447hs7Spm2ZAeiY+FhbvTNjUwYjMHE2KHzLBi/jAaxJUms1ohS e0eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="bBGHU/Ix"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ci26si13703921ejc.715.2020.07.07.02.59.54; Tue, 07 Jul 2020 03:00:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="bBGHU/Ix"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727107AbgGGJ7S (ORCPT + 99 others); Tue, 7 Jul 2020 05:59:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726879AbgGGJ7R (ORCPT ); Tue, 7 Jul 2020 05:59:17 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EDBCC061755; Tue, 7 Jul 2020 02:59:17 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id 1so520691pfn.9; Tue, 07 Jul 2020 02:59:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=C4eDJfDQ2O8UUzPVYO4ixzIP7yiUb1/eu6C6M7C54kk=; b=bBGHU/IxEdGnMMvzMvAddWFz0lF7tIyqAGNHt5+Zsy+CDq3FtUCvjY2GB/wuiKe+Tk dOctHzgrbqDRLtdMZXmCN2ve9pPa59dN2M845uxfAZeWXz2UiiM8IZxHdOikNIMp+Y+I wQUEpwED4tJ19sGhTDgN9ctCLtQ7K813PakEztg7udz6UI7JR2YhYPvtqm6LWdi54r/R iQppiTyuuwC5LxjhVpNhznGxQEWqJ0hHaM1n5UuALxCF3PBnbC6CTnLF+zex05kvyNg8 lXoaO0mHps+0QnnH3uKsZNJwsNQmHKJ+Tmvr8aeVYjrJdCQUdU09SeqKbRAPrlzQUarL 4fLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=C4eDJfDQ2O8UUzPVYO4ixzIP7yiUb1/eu6C6M7C54kk=; b=I611HvUpaQw/ySacglDqHZlSJBFNcUxUYfBdCbDEIJ89YLA+1+6kKcziYTI52Wk1y2 1deGv4br9PI8p7H275s3yEE6VepGG6bbLgUhpnOE6S4dCjFCp7gTXWD+vLMwWYS7Ow+A nihpV39kdfMyEonf1/Ia7Rx8rAqvWhWWFXSEZFrUtQjxhY8dLbg/JCjp0NQ1rI3N57w7 9q2RXVSyu5iaRkoaQYPN1vu92UCn8v0UwVofc6WIuhqu46yeLuWGi7QlDTZP5/vPF78Y +1/UpgzWlvdPo3CbKr5lSrvuTdG0UGpZxLMNOc4jYA4JgciwQSkj1Bb8AZ5Yl8Q6/hkJ OAHw== X-Gm-Message-State: AOAM530/IIDua6QqzP50quCla5nOKwpZEzM6s7c7tSa5JdIFI+7E9qrM 0a5+u8cXKtzNiJVzoJhsrfQ= X-Received: by 2002:a65:67d9:: with SMTP id b25mr44913068pgs.311.1594115956404; Tue, 07 Jul 2020 02:59:16 -0700 (PDT) Received: from localhost.localdomain ([103.51.74.198]) by smtp.gmail.com with ESMTPSA id r7sm435805pgu.51.2020.07.07.02.59.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 02:59:15 -0700 (PDT) From: Anand Moon To: linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Kishon Vijay Abraham I , Vinod Koul , Kukjin Kim , Krzysztof Kozlowski , Marek Szyprowski Subject: [PATCH v3] phy: samsung: Use readl_poll_timeout function Date: Tue, 7 Jul 2020 09:59:08 +0000 Message-Id: <20200707095908.372-1-linux.amoon@gmail.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of a busy waiting loop while loop using udelay use readl_poll_timeout function to check the condition is met or timeout occurs in crport_handshake function. Fixes: d8c80bb3b55b ("phy: exynos5-usbdrd: Calibrate LOS levels for exynos5420/5800") Signed-off-by: Anand Moon --- Changes v3: --Fix the commit message. --Drop the variable, used the value directly. Changes v2: --used the default timeout values. --Added missing Fixed tags. --- drivers/phy/samsung/phy-exynos5-usbdrd.c | 35 +++++++----------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/drivers/phy/samsung/phy-exynos5-usbdrd.c b/drivers/phy/samsung/phy-exynos5-usbdrd.c index e510732afb8b..fa75fa88da33 100644 --- a/drivers/phy/samsung/phy-exynos5-usbdrd.c +++ b/drivers/phy/samsung/phy-exynos5-usbdrd.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -556,40 +557,24 @@ static int exynos5_usbdrd_phy_power_off(struct phy *phy) static int crport_handshake(struct exynos5_usbdrd_phy *phy_drd, u32 val, u32 cmd) { - u32 usec = 100; unsigned int result; + int err; writel(val | cmd, phy_drd->reg_phy + EXYNOS5_DRD_PHYREG0); - do { - result = readl(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1); - if (result & PHYREG1_CR_ACK) - break; - - udelay(1); - } while (usec-- > 0); - - if (!usec) { - dev_err(phy_drd->dev, - "CRPORT handshake timeout1 (0x%08x)\n", val); + err = readl_poll_timeout(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1, + result, (result & PHYREG1_CR_ACK), 1, 100); + if (err) { + dev_err(phy_drd->dev, "CRPORT handshake timeout1 (0x%08x)\n", val); return -ETIME; } - usec = 100; - writel(val, phy_drd->reg_phy + EXYNOS5_DRD_PHYREG0); - do { - result = readl(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1); - if (!(result & PHYREG1_CR_ACK)) - break; - - udelay(1); - } while (usec-- > 0); - - if (!usec) { - dev_err(phy_drd->dev, - "CRPORT handshake timeout2 (0x%08x)\n", val); + err = readl_poll_timeout(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1, + result, !(result & PHYREG1_CR_ACK), 1, 100); + if (err) { + dev_err(phy_drd->dev, "CRPORT handshake timeout2 (0x%08x)\n", val); return -ETIME; } -- 2.27.0