Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp872842pxx; Tue, 27 Oct 2020 02:35:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3PqYoGwdQ8d2l6orUPt+ckyYQhUFqFqRxW0kt/tZqnLMUMJ6Hn61IZ0wwZhcx4PGcQBsZ X-Received: by 2002:a17:906:911:: with SMTP id i17mr1492160ejd.40.1603791352459; Tue, 27 Oct 2020 02:35:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603791352; cv=none; d=google.com; s=arc-20160816; b=M/p8Xv1NqRCU154FC8HrFBihc/+By+VVvFRIPQuk/J5forntszx187AIqBq7tqIg8X TNe3P+uEO8+PrTcipOj9PVe4rWfoqPvtAKvFqM3epF2LvsR8FpAsOUdQ0toKhrPY548U 2G0O/3pn/zqJcUkjU2KY5VafeD1qmm5ByoEsC+OJ04XdkecI9iVMDyH80W840ZA3Z470 avxpB6dhcnPJr3jvrshnataoi+yTEI0cSBZSpVGC2gxGoW/WbRummBx81fHGyEcT5Fvy Vz8sI94fwU+9BC+ygtsneU+EZqRcWGccH0GCBdPV7CQIWGHAz7PmK0z/RASktj4jOtbT tUng== 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=Qnn0OlZhAdI2N0NFOZOfHd55hSoGsU/Y8l2qnq84Nmo=; b=otgfNmGseXVN4Ii/LPl9DQzEMzRqKCehMWLdvDB1HAUU7xfTO8NszfpsBwFaMPijxU nu12/xliFSIPRoPdVmDs9S/CRF0YbliBCpCFpXfHSOrbuLADKnS4tOkyFsFNi2Rj9OgD v0aJDjUFRCC6LgOOMXg5269xXHqwG6FCrQNgZ3479BnhtfonobnExVjLrNEJ6K6qFyqM J+FQZNKgfSPvhMAnKdYV9xD5WuBdSBf6/t4l5Sym9/eweW0+Q/QZeAOlNmVOa+ogjd+P osDg5AOyum6vVBmXQGUoPPhpIsY93+6iugawklM3jr+FY6T3nhtRCGKghlyjLYHVUDIk /Qjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fqawvIMw; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d2si470550edn.245.2020.10.27.02.35.30; Tue, 27 Oct 2020 02:35:52 -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=@kernel.org header.s=default header.b=fqawvIMw; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2409510AbgJZXvo (ORCPT + 99 others); Mon, 26 Oct 2020 19:51:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:52160 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2409398AbgJZXvZ (ORCPT ); Mon, 26 Oct 2020 19:51:25 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D886420874; Mon, 26 Oct 2020 23:51:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603756284; bh=H6ry7Os++r5kVQ9RTuDztQX63AwHHBSJQ66YLrCVN0Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fqawvIMwWvqeQeBhSvaNrkfFJysSKh4AykZj5yEbrUD0VQbnjdrW/o4i7C8eLS5UK VbKFJnlu2CLfr4Y3eJxLSr89j23YzklGvkuq0j9n0as8GOW5YNF9kjh9VrzCRAhX7Y wf4ESEaWr7ZLUp+cIEJUbzYL1Cb2x1aDP1vRxmpU= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: =?UTF-8?q?Pali=20Roh=C3=A1r?= , Tomasz Maciej Nowak , Lorenzo Pieralisi , Rob Herring , Sasha Levin Subject: [PATCH AUTOSEL 5.9 114/147] phy: marvell: comphy: Convert internal SMCC firmware return codes to errno Date: Mon, 26 Oct 2020 19:48:32 -0400 Message-Id: <20201026234905.1022767-114-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026234905.1022767-1-sashal@kernel.org> References: <20201026234905.1022767-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pali Rohár [ Upstream commit ea17a0f153af2cd890e4ce517130dcccaa428c13 ] Driver ->power_on and ->power_off callbacks leaks internal SMCC firmware return codes to phy caller. This patch converts SMCC error codes to standard linux errno codes. Include file linux/arm-smccc.h already provides defines for SMCC error codes, so use them instead of custom driver defines. Note that return value is signed 32bit, but stored in unsigned long type with zero padding. Tested-by: Tomasz Maciej Nowak Link: https://lore.kernel.org/r/20200902144344.16684-2-pali@kernel.org Signed-off-by: Pali Rohár Signed-off-by: Lorenzo Pieralisi Reviewed-by: Rob Herring Signed-off-by: Sasha Levin --- drivers/phy/marvell/phy-mvebu-a3700-comphy.c | 14 +++++++++++--- drivers/phy/marvell/phy-mvebu-cp110-comphy.c | 14 +++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/phy/marvell/phy-mvebu-a3700-comphy.c b/drivers/phy/marvell/phy-mvebu-a3700-comphy.c index 1a138be8bd6a0..810f25a476321 100644 --- a/drivers/phy/marvell/phy-mvebu-a3700-comphy.c +++ b/drivers/phy/marvell/phy-mvebu-a3700-comphy.c @@ -26,7 +26,6 @@ #define COMPHY_SIP_POWER_ON 0x82000001 #define COMPHY_SIP_POWER_OFF 0x82000002 #define COMPHY_SIP_PLL_LOCK 0x82000003 -#define COMPHY_FW_NOT_SUPPORTED (-1) #define COMPHY_FW_MODE_SATA 0x1 #define COMPHY_FW_MODE_SGMII 0x2 @@ -112,10 +111,19 @@ static int mvebu_a3700_comphy_smc(unsigned long function, unsigned long lane, unsigned long mode) { struct arm_smccc_res res; + s32 ret; arm_smccc_smc(function, lane, mode, 0, 0, 0, 0, 0, &res); + ret = res.a0; - return res.a0; + switch (ret) { + case SMCCC_RET_SUCCESS: + return 0; + case SMCCC_RET_NOT_SUPPORTED: + return -EOPNOTSUPP; + default: + return -EINVAL; + } } static int mvebu_a3700_comphy_get_fw_mode(int lane, int port, @@ -220,7 +228,7 @@ static int mvebu_a3700_comphy_power_on(struct phy *phy) } ret = mvebu_a3700_comphy_smc(COMPHY_SIP_POWER_ON, lane->id, fw_param); - if (ret == COMPHY_FW_NOT_SUPPORTED) + if (ret == -EOPNOTSUPP) dev_err(lane->dev, "unsupported SMC call, try updating your firmware\n"); diff --git a/drivers/phy/marvell/phy-mvebu-cp110-comphy.c b/drivers/phy/marvell/phy-mvebu-cp110-comphy.c index e41367f36ee1c..53ad127b100fe 100644 --- a/drivers/phy/marvell/phy-mvebu-cp110-comphy.c +++ b/drivers/phy/marvell/phy-mvebu-cp110-comphy.c @@ -123,7 +123,6 @@ #define COMPHY_SIP_POWER_ON 0x82000001 #define COMPHY_SIP_POWER_OFF 0x82000002 -#define COMPHY_FW_NOT_SUPPORTED (-1) /* * A lane is described by the following bitfields: @@ -273,10 +272,19 @@ static int mvebu_comphy_smc(unsigned long function, unsigned long phys, unsigned long lane, unsigned long mode) { struct arm_smccc_res res; + s32 ret; arm_smccc_smc(function, phys, lane, mode, 0, 0, 0, 0, &res); + ret = res.a0; - return res.a0; + switch (ret) { + case SMCCC_RET_SUCCESS: + return 0; + case SMCCC_RET_NOT_SUPPORTED: + return -EOPNOTSUPP; + default: + return -EINVAL; + } } static int mvebu_comphy_get_mode(bool fw_mode, int lane, int port, @@ -819,7 +827,7 @@ static int mvebu_comphy_power_on(struct phy *phy) if (!ret) return ret; - if (ret == COMPHY_FW_NOT_SUPPORTED) + if (ret == -EOPNOTSUPP) dev_err(priv->dev, "unsupported SMC call, try updating your firmware\n"); -- 2.25.1