From patchwork Mon Jul 10 09:46:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13306625 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B65AEB64DA for ; Mon, 10 Jul 2023 09:51:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231722AbjGJJvt (ORCPT ); Mon, 10 Jul 2023 05:51:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233109AbjGJJu6 (ORCPT ); Mon, 10 Jul 2023 05:50:58 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D04F3EE; Mon, 10 Jul 2023 02:46:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688982404; x=1720518404; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=uXugLi1fmKBrAebmGx6Upi+jSUgvd/xrP2azX6cr4N0=; b=maSyQDt7L9uJOQdhION68YRr+o06eyy13nTBVStVQHSDRviFJdBqjWYw Yyrrq9ThsOoUx+DO5DPHSRlkoc5+icNaKqCOqVtLJOLvqCTjyehLXHWxv cv5wWbzuNTAHyhJ0I7BaGZvRUVgjUWcxDFGKTqOvOS2iOssrycLviUfO2 gFDhmr8FmnDb0OlUDGdHN0v3cXq3Hm1Fd+rQNijyym6QkXIcSresIZyR4 wnY+JJZPc/k4CWgUAlsbQqJMEqxYeTtae3jwGYohtiAOGJ/W1WTRCFkAN 2+luX6iX5H8r6xIYPtBh3d3Sx8rATm/BeVWD5zsyTxrhVn1mbR90+CoaP g==; X-IronPort-AV: E=McAfee;i="6600,9927,10766"; a="367796426" X-IronPort-AV: E=Sophos;i="6.01,194,1684825200"; d="scan'208";a="367796426" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jul 2023 02:46:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10766"; a="844813161" X-IronPort-AV: E=Sophos;i="6.01,194,1684825200"; d="scan'208";a="844813161" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga004.jf.intel.com with ESMTP; 10 Jul 2023 02:46:41 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 8193A1FC; Mon, 10 Jul 2023 12:46:46 +0300 (EEST) From: Andy Shevchenko To: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Bin Liu , Greg Kroah-Hartman , Andy Shevchenko , Linus Walleij Subject: [PATCH v2 1/1] usb: musb: Use read_poll_timeout() Date: Mon, 10 Jul 2023 12:46:45 +0300 Message-Id: <20230710094645.42111-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Use read_poll_timeout() instead of open coding it. In the same time, fix the typo in the error message. Reviewed-by: Linus Walleij Signed-off-by: Andy Shevchenko --- v2: added tag (Linus), bumped sleep_us to descrease number of attempts drivers/usb/musb/tusb6010.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c index cbc707fe570f..461587629bf2 100644 --- a/drivers/usb/musb/tusb6010.c +++ b/drivers/usb/musb/tusb6010.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -1029,7 +1030,7 @@ static int tusb_musb_start(struct musb *musb) void __iomem *tbase = musb->ctrl_base; unsigned long flags; u32 reg; - int i; + int ret; /* * Enable or disable power to TUSB6010. When enabling, turn on 3.3 V and @@ -1037,17 +1038,13 @@ static int tusb_musb_start(struct musb *musb) * provide then PGOOD signal to TUSB6010 which will release it from reset. */ gpiod_set_value(glue->enable, 1); - msleep(1); /* Wait for 100ms until TUSB6010 pulls INT pin down */ - i = 100; - while (i && gpiod_get_value(glue->intpin)) { - msleep(1); - i--; - } - if (!i) { - pr_err("tusb: Powerup respones failed\n"); - return -ENODEV; + ret = read_poll_timeout(gpiod_get_value, reg, !reg, 5000, 100000, true, + glue->intpin); + if (ret) { + pr_err("tusb: Powerup response failed\n"); + return ret; } spin_lock_irqsave(&musb->lock, flags);