Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp298505pxx; Wed, 28 Oct 2020 05:19:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNxLgahrAyvCSM6LOL+lxg8P4K3m7uplZiZge0X1XPd6V0xzLiev5/IhwqvTCRgEW5UkRD X-Received: by 2002:a17:906:7481:: with SMTP id e1mr2436152ejl.13.1603887566720; Wed, 28 Oct 2020 05:19:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603887566; cv=none; d=google.com; s=arc-20160816; b=DN+R1CUxm+ks1pFv9xjaecb5cMYsYvh67TGYt8SWyAcGxm6VJNFi2e0PfhDT304aR2 KR760zHY3lVr8qbkdEUC6+DK8m+ImKJEtMVxut04kZOuyNXtwlvz2HxCFbVvF0g8SW/Z q2lkwq1uMe4tlETxdU83G/PynLMl398UO/wGCE+jxUh3XQINCN/nbSt6Ft/SuWB05oqQ INi7WdzGcE8hN91RoB87CBhoTZJSZwFRPWs/mOadisTcr2ciM1fGbyFR43aLwZUjrogn lceGOD/6/QbKBfsgf7vCN0bOTrw3wesvBQT+BnGf1npBWyzYl4uXuXGbtWHaweT1ROsU 7//g== 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=q4iwkBXemZCLsvMl6tp/8M+OTQARqiPgMM64hFAyxXw=; b=OghMvwy7pxdKTrVoB2D3oPyPsPfl8/vgqlLb++/DeV6k/OfiM9kwJ4FIEQBXr5oz65 8rRc7oAjUUy6lchn8HmKMPFAI7fO16gxHb0cC3pf8s4S2dzym8osqLZ25Uy2lRlxM/RF xUPtu2k3hnxfn9YcbZ5g60EqplVyWcbjfGALsO0jA3ZO0fV21K/oY0mphmMkKYZ/4HFw bk1/o3DaadDr+05z94qcyjIn5LHdmD4HN4ailbldTuDiho9XxjjYvQy3X0aNW8ywjRCX 3EqUMCJYIZ4QOxpIX55WRxc5DOBUYMQkGSn6GJYvEKdcfztD0o8+wuX9XYJif6eY/0QT lgIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=h9AvZJvO; 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 q18si2524555edb.466.2020.10.28.05.19.04; Wed, 28 Oct 2020 05:19:26 -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=h9AvZJvO; 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 S1796505AbgJ0PTG (ORCPT + 99 others); Tue, 27 Oct 2020 11:19:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:51758 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1794981AbgJ0POn (ORCPT ); Tue, 27 Oct 2020 11:14:43 -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 4151521D41; Tue, 27 Oct 2020 15:14:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811681; bh=BDNwQRwoRfZPxJGVVrsS9A5kA4VPUPUBVwYYvkvLSsk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h9AvZJvOZxlR6GrM5gdhVCQhbRj6COyFo7JjEBrCRqm1YsgBpaKQA7QMJA0HIvl6t flsFDkvIayJCRSAs3k9HWMGsRdxQI3thFx11k0Jvgf5tP5uVZ6vwyk9FkKoRjetXC7 BZX6VpQwlsE93Cn6oZGHbfvnx9iYZSzAz87iP/W0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joakim Zhang , Marc Kleine-Budde , Sasha Levin Subject: [PATCH 5.8 578/633] can: flexcan: flexcan_chip_stop(): add error handling and propagate error value Date: Tue, 27 Oct 2020 14:55:21 +0100 Message-Id: <20201027135549.926563710@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@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: Joakim Zhang [ Upstream commit 9ad02c7f4f279504bdd38ab706fdc97d5f2b2a9c ] This patch implements error handling and propagates the error value of flexcan_chip_stop(). This function will be called from flexcan_suspend() in an upcoming patch in some SoCs which support LPSR mode. Add a new function flexcan_chip_stop_disable_on_error() that tries to disable the chip even in case of errors. Signed-off-by: Joakim Zhang [mkl: introduce flexcan_chip_stop_disable_on_error() and use it in flexcan_close()] Signed-off-by: Marc Kleine-Budde Link: https://lore.kernel.org/r/20200922144429.2613631-11-mkl@pengutronix.de Signed-off-by: Sasha Levin --- drivers/net/can/flexcan.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c index 94d10ec954a05..2ac7a667bde35 100644 --- a/drivers/net/can/flexcan.c +++ b/drivers/net/can/flexcan.c @@ -1260,18 +1260,23 @@ static int flexcan_chip_start(struct net_device *dev) return err; } -/* flexcan_chip_stop +/* __flexcan_chip_stop * - * this functions is entered with clocks enabled + * this function is entered with clocks enabled */ -static void flexcan_chip_stop(struct net_device *dev) +static int __flexcan_chip_stop(struct net_device *dev, bool disable_on_error) { struct flexcan_priv *priv = netdev_priv(dev); struct flexcan_regs __iomem *regs = priv->regs; + int err; /* freeze + disable module */ - flexcan_chip_freeze(priv); - flexcan_chip_disable(priv); + err = flexcan_chip_freeze(priv); + if (err && !disable_on_error) + return err; + err = flexcan_chip_disable(priv); + if (err && !disable_on_error) + goto out_chip_unfreeze; /* Disable all interrupts */ priv->write(0, ®s->imask2); @@ -1281,6 +1286,23 @@ static void flexcan_chip_stop(struct net_device *dev) flexcan_transceiver_disable(priv); priv->can.state = CAN_STATE_STOPPED; + + return 0; + + out_chip_unfreeze: + flexcan_chip_unfreeze(priv); + + return err; +} + +static inline int flexcan_chip_stop_disable_on_error(struct net_device *dev) +{ + return __flexcan_chip_stop(dev, true); +} + +static inline int flexcan_chip_stop(struct net_device *dev) +{ + return __flexcan_chip_stop(dev, false); } static int flexcan_open(struct net_device *dev) @@ -1362,7 +1384,7 @@ static int flexcan_close(struct net_device *dev) netif_stop_queue(dev); can_rx_offload_disable(&priv->offload); - flexcan_chip_stop(dev); + flexcan_chip_stop_disable_on_error(dev); can_rx_offload_del(&priv->offload); free_irq(dev->irq, dev); -- 2.25.1