From patchwork Thu Apr 7 10:21:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jules Maselbas X-Patchwork-Id: 561463 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 006D7C433F5 for ; Thu, 7 Apr 2022 10:21:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243724AbiDGKXY (ORCPT ); Thu, 7 Apr 2022 06:23:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240485AbiDGKXW (ORCPT ); Thu, 7 Apr 2022 06:23:22 -0400 Received: from fx305.security-mail.net (smtpout30.security-mail.net [85.31.212.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91DA827FD9 for ; Thu, 7 Apr 2022 03:21:21 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by fx305.security-mail.net (Postfix) with ESMTP id 8164030FDEA for ; Thu, 7 Apr 2022 12:21:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kalray.eu; s=sec-sig-email; t=1649326880; bh=2leB9N9MVO1isCk23h+tI5TUBCZFTqNDEKraPyTS3tI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WiRpawPxoFGAm+vM5jCu3MRtsmlDtvcjqyH52aRHONEi4EIUmvBOYJy3ruGD+AtdV LsQVBS+ElIyEsXAs2lugHscP+vGFwv8PBVqPzfsZ5ExFioqicVuinxj4t35v7HcTn+ uenUPLLFzJxofdag4XAtBMjIlemC22VQekUnI6nc= Received: from fx305 (localhost [127.0.0.1]) by fx305.security-mail.net (Postfix) with ESMTP id 247D730FD36; Thu, 7 Apr 2022 12:21:19 +0200 (CEST) X-Virus-Scanned: E-securemail Secumail-id: <13a18.624ebb1c.cdc68.0> Received: from zimbra2.kalray.eu (unknown [217.181.231.53]) by fx305.security-mail.net (Postfix) with ESMTPS id 8314D30FD53; Thu, 7 Apr 2022 12:21:16 +0200 (CEST) Received: from zimbra2.kalray.eu (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTPS id 9DCF927E044F; Thu, 7 Apr 2022 12:21:16 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTP id 87EE727E044D; Thu, 7 Apr 2022 12:21:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.10.3 zimbra2.kalray.eu 87EE727E044D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kalray.eu; s=32AE1B44-9502-11E5-BA35-3734643DEF29; t=1649326876; bh=9IM9Pd49M0jFhF7iENBzRLSpXjLX1rGW2MgcQSst3IU=; h=From:To:Date:Message-Id; b=IdX8uYYwjaFAjT0p0mKvde9rm56N1wrTLce4TQ7+tgGjKbuT7lmWHuc1FjKk+2tiR zwHrHN1iU5vKialopUMwQoR5K02MOSkH6OkHyQMLq+qaTU0XnoHGg23u7s+LAOXcJg B0L8L4oECeLV78az/wtpUvIeRNI26g2iuRVVQ8nU= Received: from zimbra2.kalray.eu ([127.0.0.1]) by localhost (zimbra2.kalray.eu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Bg-8kJbaERwh; Thu, 7 Apr 2022 12:21:16 +0200 (CEST) Received: from tellis.lin.mbt.kalray.eu (unknown [192.168.36.206]) by zimbra2.kalray.eu (Postfix) with ESMTPSA id 6AB8C27E0443; Thu, 7 Apr 2022 12:21:16 +0200 (CEST) From: Jules Maselbas To: linux-phy@lists.infradead.org Cc: linux-usb@vger.kernel.org, Kishon Vijay Abraham I , Vinod Koul , Ahmad Fatoum , Minas Harutyunyan , Amelie DELAUNAY , Yann Sionneau , Michael Grzeschik , Randy Dunlap , Arnd Bergmann , Jules Maselbas Subject: [PATCH RESEND v3 3/3] phy: core: Warn when phy_power_on is called before phy_init Date: Thu, 7 Apr 2022 12:21:08 +0200 Message-Id: <20220407102108.24211-4-jmaselbas@kalray.eu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220407102108.24211-1-jmaselbas@kalray.eu> References: <20220407102108.24211-1-jmaselbas@kalray.eu> X-Virus-Scanned: by Secumail Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org A warning when the order of phy operation is mixed up by drivers, this is an atempt to make the phy usage more uniform across (usb) drivers. Signed-off-by: Jules Maselbas Cc: Ahmad Fatoum Cc: Amelie DELAUNAY Cc: Minas Harutyunyan Cc: Kishon Vijay Abraham I --- drivers/phy/phy-core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index d11b517e283a..90f589563a60 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -253,6 +253,9 @@ int phy_init(struct phy *phy) ret = 0; /* Override possible ret == -ENOTSUPP */ mutex_lock(&phy->mutex); + if (phy->power_count > phy->init_count) + dev_warn(&phy->dev, "phy_power_on was called before phy_init\n"); + if (phy->init_count == 0 && phy->ops->init) { ret = phy->ops->init(phy); if (ret < 0) {