Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1982586pxx; Sat, 31 Oct 2020 04:47:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSM0ibat5TbPTPzBawb+j6GcSCHk+04cMncH/YjhFXyQESayFg5JZQh0pkYYfUlriHtYeK X-Received: by 2002:a17:906:512:: with SMTP id j18mr7014631eja.370.1604144845547; Sat, 31 Oct 2020 04:47:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604144845; cv=none; d=google.com; s=arc-20160816; b=D7rbAw9OFuB3UMlZxwRCHa4cCJCWay/lw2h0Olu5IohEfwSbvCohk+Qh7VI1NfTcoe l6BBOV+2D7tXKpyoP0DrmMFdZARfOFN8nigNwcTcjyKmwepjcNnfxZ/JA9rZWtmuJrls 0pWNQ9NiGU3OCvgw2OgtmEZp9dNNrBcbEFwBFk9AIMxd6N7trmiv0of9rXuMhwwGE8E+ 8vC3CjvHojqD5ZMweyDtvS/DXUfktSpvEbF9g5CvttgFEn+fVwFSYYUVtCn9fSBrttFK TAz0eC4vyPDyR0Lt//IBi32BnJl2VMfi09lc7aCieKaOoEjQfvTJaKX/S39t7hmebbqO a9xA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9WqWzlx5R3ZTYLlEZX/ZHGyu8xy95BXJukgaDRIJw4Y=; b=pFssSCkrxtBtbadB1rFghQ6XyU2aKoiJRoKYhE++K0tLVM/VZ/7yA10BvCeHYSJc8v bkf83e41LObvMbA80rWK4cPVAStZueYSlLJrTicXxtN0DkXxKMT7jGKFcc3CRYYIx+Fd B6jYm1Oam0U5BkliMhTA9TbR1pHJg5j5jDMMYECmU7vwlXhbaLpNcM9zS7rGVpzIORVF aYv2GuOwA15e2PRYFL90F0QZhc9QmuhorzCMGsIBEHIS2ViAxkkOjZKO9pjtyMEyDm+7 KI2wjiGxEzpUos1Ld1dbkl9wmuCZHdxIwaAqMxo2NjYzdTcm1NT+UlEWAjxt/gYZtN0d 795Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="geRR4zI/"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t16si7128494edi.258.2020.10.31.04.47.03; Sat, 31 Oct 2020 04:47:25 -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="geRR4zI/"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727932AbgJaLmz (ORCPT + 99 others); Sat, 31 Oct 2020 07:42:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:42634 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727927AbgJaLmx (ORCPT ); Sat, 31 Oct 2020 07:42:53 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 72FD920731; Sat, 31 Oct 2020 11:42:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604144572; bh=lp61+OWJbjIgZGSPK/gfon+MQDZYdOwpgU2lyciFs/o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=geRR4zI/eFws25hEsSym1om9wfmFiS5sbGQn9rux0ua8aRNkXyhP6WBPfE+PyZXi3 Lm1dgAbuXfChaEyA7mpbXOEoYAy208A7YCdka6DO1FSlrmLQrgsZxX9dVJkF1SwQQE Mlv4hBWVz1CFEVst+tAf2/JVSqxY8ZJuB5ASi8EM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tomasz Maciej Nowak , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Lorenzo Pieralisi , Rob Herring Subject: [PATCH 5.8 70/70] phy: marvell: comphy: Convert internal SMCC firmware return codes to errno Date: Sat, 31 Oct 2020 12:36:42 +0100 Message-Id: <20201031113502.835084619@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201031113459.481803250@linuxfoundation.org> References: <20201031113459.481803250@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pali Rohár commit ea17a0f153af2cd890e4ce517130dcccaa428c13 upstream. 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: Greg Kroah-Hartman --- 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(-) --- 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(unsign 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(s } 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"); --- 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 lon 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 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");