From patchwork Fri Mar 20 21:25:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arun Ramamurthy X-Patchwork-Id: 6061131 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C25B19F6E8 for ; Fri, 20 Mar 2015 21:28:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 04A0B203F4 for ; Fri, 20 Mar 2015 21:28:28 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 09A7620395 for ; Fri, 20 Mar 2015 21:28:27 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YZ4Qu-0003FA-B4; Fri, 20 Mar 2015 21:26:20 +0000 Received: from mail-gw2-out.broadcom.com ([216.31.210.63]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YZ4QE-00030g-9b for linux-arm-kernel@lists.infradead.org; Fri, 20 Mar 2015 21:25:39 +0000 X-IronPort-AV: E=Sophos;i="5.11,439,1422950400"; d="scan'208";a="60016373" Received: from irvexchcas08.broadcom.com (HELO IRVEXCHCAS08.corp.ad.broadcom.com) ([10.9.208.57]) by mail-gw2-out.broadcom.com with ESMTP; 20 Mar 2015 14:27:29 -0700 Received: from IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) by IRVEXCHCAS08.corp.ad.broadcom.com (10.9.208.57) with Microsoft SMTP Server (TLS) id 14.3.174.1; Fri, 20 Mar 2015 14:25:17 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) with Microsoft SMTP Server id 14.3.174.1; Fri, 20 Mar 2015 14:25:17 -0700 Received: from lbrmn-lnxub64.broadcom.com (unknown [10.136.8.214]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id EC5D140FE6; Fri, 20 Mar 2015 14:23:58 -0700 (PDT) From: Arun Ramamurthy To: Kishon Vijay Abraham I , Rob Herring , Pawel Moll , Mark Rutland , "Ian Campbell" , Kumar Gala , Arnd Bergmann , Subject: [PATCH v1 1/3] phy: phy-core: allow specifying supply at port level Date: Fri, 20 Mar 2015 14:25:25 -0700 Message-ID: <1426886727-537-2-git-send-email-arun.ramamurthy@broadcom.com> X-Mailer: git-send-email 2.3.2 In-Reply-To: <1426886727-537-1-git-send-email-arun.ramamurthy@broadcom.com> References: <1426886727-537-1-git-send-email-arun.ramamurthy@broadcom.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150320_142538_394898_B32FBBD2 X-CRM114-Status: UNSURE ( 9.60 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.3 (--) Cc: Dmitry Torokhov , Scott Branden , Ray Jui , linux-kernel@vger.kernel.org, Jonathan Richardson , Anatol Pomazau , linux-arm-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, Arun Ramamurthy , Dmitry Torokhov X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Multi-port phy's may have per-port power supplies. Let's change phy core to first attempt to look up the supply at the port level, and then, if not found, check parent device. Reviewed-by: Ray Jui Reviewed-by: Scott Branden Signed-off-by: Dmitry Torokhov Signed-off-by: Arun Ramamurthy --- drivers/phy/phy-core.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index a12d353..b43bb6b 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -650,16 +650,6 @@ struct phy *phy_create(struct device *dev, struct device_node *node, goto free_phy; } - /* phy-supply */ - phy->pwr = regulator_get_optional(dev, "phy"); - if (IS_ERR(phy->pwr)) { - if (PTR_ERR(phy->pwr) == -EPROBE_DEFER) { - ret = -EPROBE_DEFER; - goto free_ida; - } - phy->pwr = NULL; - } - device_initialize(&phy->dev); mutex_init(&phy->mutex); @@ -673,6 +663,26 @@ struct phy *phy_create(struct device *dev, struct device_node *node, if (ret) goto put_dev; + /* + * Locate phy-supply. We first try individual port and then, + * if supply is not found, try parent device. + */ + phy->pwr = regulator_get_optional(&phy->dev, "phy"); + if (IS_ERR(phy->pwr)) { + ret = PTR_ERR(phy->pwr); + if (ret == -EPROBE_DEFER) + goto free_ida; + + phy->pwr = regulator_get_optional(phy->dev.parent, "phy"); + if (IS_ERR(phy->pwr)) { + ret = PTR_ERR(phy->pwr); + if (ret == -EPROBE_DEFER) + goto free_ida; + + phy->pwr = NULL; + } + } + ret = device_add(&phy->dev); if (ret) goto put_dev;