Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp3967338pxb; Tue, 19 Apr 2022 13:46:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhzKNYvb+88Sx8PWJSNANZyCdoaB0lEBhbkHQtHApoO7fovfPeCkB5RoB8LuKybfIwWdf3 X-Received: by 2002:a17:902:ab58:b0:158:f2e1:8c4c with SMTP id ij24-20020a170902ab5800b00158f2e18c4cmr14765197plb.154.1650401211649; Tue, 19 Apr 2022 13:46:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650401211; cv=none; d=google.com; s=arc-20160816; b=xWEyEAlztWQ4txMccLaZPM3HgpUuVgl2KqKRVDgIVNRNMyn6uhUy2hsRYE3F7frCw3 lKrIWRVzdmJHr2+O3+8Z4atOznZA0JCX9jRPz/w/2zHPcJ2io4DO6D0LrMPcYke5OFFu rsl8PCWsj0FksUaqg267ASQFONNv9PDwG3XHnvKJO50JRfXOlug+lid/RQCbVdq03grZ 58E6A4eOEnduLTKHZZ7AQaqf0raKt/fkO9yi41lgjLI76+UE/BQQJBUT21UIsgz38Vmk 91caUQUUuGM79SrQlrEbYilN3ecy9YV9WNyVqungtMX1kJ0QAXyzM0AyQmYe9HFphznr Tzuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZBEMLFx6kZu4Ftbt5C7GuNd16rsxl/WDeqp/06ttweE=; b=qEWemVszxGLPtTLoZqEyvlNxpOjIX4kavqzmFus0ZBrxFiEsDFUCvLh91YWPYim2gK WUA9owY60bz48OzrCRpQvMbUITuGN9OuVk1pKPrO1Zx14UwpwPbnvE366USj2jYTFJGB +zDtYfWa9o4IoOOeusTZNZBmPbWMB4R6tSJapG0SMTZ2IHZKxyHRAuOjojMTRLAD3kxq zxsppQYyRcSC9t6Gb3H+3fM66dpUXi4F4LCu6sk68iMwZ8/85nmZhEZz1WXZOIQCIJgb xDmb7dx++ezMDo94CYHF2mbAaQl47d0cK5lfDHlvI5NRIpMEY5GwG0RkShzxORCveHnq t1Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=bJ3B0eFG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b2-20020a170902a9c200b001569af11990si192224plr.507.2022.04.19.13.46.35; Tue, 19 Apr 2022 13:46:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=bJ3B0eFG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347956AbiDRVPg (ORCPT + 99 others); Mon, 18 Apr 2022 17:15:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347947AbiDRVPd (ORCPT ); Mon, 18 Apr 2022 17:15:33 -0400 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D813E2CCA7 for ; Mon, 18 Apr 2022 14:12:53 -0700 (PDT) Received: by mail-pg1-x52f.google.com with SMTP id j71so7573969pge.11 for ; Mon, 18 Apr 2022 14:12:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZBEMLFx6kZu4Ftbt5C7GuNd16rsxl/WDeqp/06ttweE=; b=bJ3B0eFGTchfQv+WU89bGvDjqoGShoz0Hh2L1M20K3S9SMcuTdpL9CLD0dkuRWWAZd AWUwcLYEdg+XmrZ5lwvCWhcEPSGMnqSDE8s89V2DyhZggHgNrF8g/7KwRkFzsUoc3ALo Vh4fGz6WQukqeBF7jogRDCe96tOG0NPNQ2z+U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZBEMLFx6kZu4Ftbt5C7GuNd16rsxl/WDeqp/06ttweE=; b=fPuqAmjck6eWOHcptLgY4ZljprXPqo12+mDtciF76/zrjRcHjAX3KoEjN/pasihwM9 vocYWku1C3oeaPgY7SufUreaoh3YjhDb4z3qSESVxPYPKNRySYT6M9rk3a5/Hq91ECD6 Msslmbw+0/qacAAAx6VjFh6j5tQv5zt+I7BI1sMY2Eo8KuHOAEJlh80DD9igrAMGwkSO 2RyL6JEHQWWe2k4Dzlrt0nHiUk2aSHRj11pd+TE2AcyyRgNkzHorkwjwHHlBTRVMaZKE h84pQZvLcVDT9OtMGiGcGD0FwqBwG5LFeRqMLozMX2uJP74Xfibj59heTIJw0v0S+Z97 azEQ== X-Gm-Message-State: AOAM532eYUroYRb0XnL8/pP7JS0E/K2vCZiWr7IPkQmuwqZ5w4GawIMe t4xtKWAtV41duJ1epqsL57EXug== X-Received: by 2002:a63:dd54:0:b0:3a8:f358:5b3f with SMTP id g20-20020a63dd54000000b003a8f3585b3fmr8403482pgj.97.1650316373389; Mon, 18 Apr 2022 14:12:53 -0700 (PDT) Received: from localhost ([2620:15c:202:201:c240:3b46:d799:c833]) by smtp.gmail.com with UTF8SMTPSA id d141-20020a621d93000000b00505aa1026f1sm13679742pfd.51.2022.04.18.14.12.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 Apr 2022 14:12:52 -0700 (PDT) From: Brian Norris To: Liam Girdwood , Mark Brown Cc: Matthias Kaehlcke , linux-kernel@vger.kernel.org, Brian Norris Subject: [PATCH 2/2] regulator: core: Replace _regulator_enable_delay() with fsleep() Date: Mon, 18 Apr 2022 14:12:40 -0700 Message-Id: <20220418141158.2.I31ef0014c9597d53722ab513890f839f357fdfb3@changeid> X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog In-Reply-To: <20220418141158.1.If0fc61a894f537b052ca41572aff098cf8e7e673@changeid> References: <20220418141158.1.If0fc61a894f537b052ca41572aff098cf8e7e673@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org fsleep() was designed to handle exactly the same thing as _regulator_enable_delay(): flexible sleep lengths, according to the guidelines at Documentation/timers/timers-howto.rst. Let's use it, instead of duplicating it. One notable difference: fsleep() allows a usleep range of twice the requested amount instead of a fixed +100us. Signed-off-by: Brian Norris --- drivers/regulator/core.c | 45 +++------------------------------------- 1 file changed, 3 insertions(+), 42 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 223c6d71a2b2..d0bac80206d8 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -2510,45 +2510,6 @@ static int regulator_ena_gpio_ctrl(struct regulator_dev *rdev, bool enable) return 0; } -/** - * _regulator_enable_delay - a delay helper function - * @delay: time to delay in microseconds - * - * Delay for the requested amount of time as per the guidelines in: - * - * Documentation/timers/timers-howto.rst - * - * The assumption here is that regulators will never be enabled in - * atomic context and therefore sleeping functions can be used. - */ -static void _regulator_enable_delay(unsigned int delay) -{ - unsigned int ms = delay / 1000; - unsigned int us = delay % 1000; - - if (ms > 0) { - /* - * For small enough values, handle super-millisecond - * delays in the usleep_range() call below. - */ - if (ms < 20) - us += ms * 1000; - else - msleep(ms); - } - - /* - * Give the scheduler some room to coalesce with any other - * wakeup sources. For delays shorter than 10 us, don't even - * bother setting up high-resolution timers and just busy- - * loop. - */ - if (us >= 10) - usleep_range(us, us + 100); - else - udelay(us); -} - /** * _regulator_check_status_enabled * @@ -2603,7 +2564,7 @@ static int _regulator_do_enable(struct regulator_dev *rdev) s64 remaining = ktime_us_delta(end, ktime_get()); if (remaining > 0) - _regulator_enable_delay(remaining); + fsleep(remaining); } if (rdev->ena_pin) { @@ -2637,7 +2598,7 @@ static int _regulator_do_enable(struct regulator_dev *rdev) unsigned int time_remaining = delay; while (time_remaining > 0) { - _regulator_enable_delay(rdev->desc->poll_enabled_time); + fsleep(rdev->desc->poll_enabled_time); if (rdev->desc->ops->get_status) { ret = _regulator_check_status_enabled(rdev); @@ -2656,7 +2617,7 @@ static int _regulator_do_enable(struct regulator_dev *rdev) return -ETIMEDOUT; } } else { - _regulator_enable_delay(delay); + fsleep(delay); } trace_regulator_enable_complete(rdev_get_name(rdev)); -- 2.36.0.rc0.470.gd361397f0d-goog