Received: by 10.213.65.68 with SMTP id h4csp879431imn; Tue, 27 Mar 2018 10:27:38 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/sQmRuNu/Fj2fsXo81NjTTzXCR4mVt9l9Dwl40UdXtrZGvLnPwCvPPUmhto6uPmA+my26h X-Received: by 10.98.200.82 with SMTP id z79mr167265pff.45.1522171658795; Tue, 27 Mar 2018 10:27:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522171658; cv=none; d=google.com; s=arc-20160816; b=ySU3rbf+SLAEUeCdBLIvKv4GKQ/M4mwXtzjGs2yTpSI65qgBLQire7E90S95H2pVl7 8EMsJOojzoZKgPUezU5jHOu0TKUq3RsBN2yIg1/kiu1M9isDqxLDtUykWBb6wBjene8R iY7crnm80+3fdRyKbOXIFplyYnE0g3r7X9TasevqXQ19SJo4x6kHVNa3Z4AIwa2jz6U9 APkmUDqjlojmgqVClINGnqcMYxDJrg4obsb3t4dRDKe8dzZLQ0KNO0bp0wBNWGQ3zZ6s RHo/TTxa3Ij0AdwI4k1CcB5TWxmQY783MAt37GsszBThO4MrnxTyjrn79aWNMqq3NvzT g/nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=UJoiIGg2wpmVY3KnLM5QsGpYsP2O6p5bqHvRvoMDamU=; b=rhMCbNgMsX9rFWBVjH6NpF+sfRymrFH22SRQZM6pW02EK6lLA6vKFfSBUUIxlCjW6u SEnfo3uWbein8ZQCOk+VeRb8hhjapo7j0vn3NVhgIF2o1WY7KO0VQ/rjHYpbP7agmIR8 2WU5D5Lb1GtjwsXEG95ogmem7etbl0JadEf3LimNiyDGp7lDjEfniiT3f9IQ1yZ4ohxy YNVsjn8MqyujQRtSgZwl+Ppt23uwR+IOjuHo3YNUW+a9SylS75F4NkMAkdIjNT5GKZql J3aQ58XwTtAypZWepb3toceIDDy7NLDUeRCLvg0F8B8mTsupcemmUPBEi6DpZK0UCu0/ +j0w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 69-v6si1595024pla.390.2018.03.27.10.27.24; Tue, 27 Mar 2018 10:27:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753384AbeC0RZy (ORCPT + 99 others); Tue, 27 Mar 2018 13:25:54 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45992 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754773AbeC0Qg5 (ORCPT ); Tue, 27 Mar 2018 12:36:57 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id DB5F4F73; Tue, 27 Mar 2018 16:36:56 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marek Vasut , Heiko Schocher , Markus Marb , Marc Kleine-Budde Subject: [PATCH 4.14 073/101] can: ifi: Check core revision upon probe Date: Tue, 27 Mar 2018 18:27:45 +0200 Message-Id: <20180327162754.587267139@linuxfoundation.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180327162749.993880276@linuxfoundation.org> References: <20180327162749.993880276@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Marek Vasut commit 591d65d5b15496af8d05e252bc1da611c66c0b79 upstream. Older versions of the core are not compatible with the driver due to various intrusive fixes of the core. Read out the VER register, check the core revision bitfield and verify if the core in use is new enough (rev 2.1 or newer) to work correctly with this driver. Signed-off-by: Marek Vasut Cc: Heiko Schocher Cc: Markus Marb Cc: Marc Kleine-Budde Cc: linux-stable Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman --- drivers/net/can/ifi_canfd/ifi_canfd.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) --- a/drivers/net/can/ifi_canfd/ifi_canfd.c +++ b/drivers/net/can/ifi_canfd/ifi_canfd.c @@ -144,6 +144,8 @@ #define IFI_CANFD_SYSCLOCK 0x50 #define IFI_CANFD_VER 0x54 +#define IFI_CANFD_VER_REV_MASK 0xff +#define IFI_CANFD_VER_REV_MIN_SUPPORTED 0x15 #define IFI_CANFD_IP_ID 0x58 #define IFI_CANFD_IP_ID_VALUE 0xD073CAFD @@ -943,7 +945,7 @@ static int ifi_canfd_plat_probe(struct p struct resource *res; void __iomem *addr; int irq, ret; - u32 id; + u32 id, rev; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); addr = devm_ioremap_resource(dev, res); @@ -957,6 +959,13 @@ static int ifi_canfd_plat_probe(struct p return -EINVAL; } + rev = readl(addr + IFI_CANFD_VER) & IFI_CANFD_VER_REV_MASK; + if (rev < IFI_CANFD_VER_REV_MIN_SUPPORTED) { + dev_err(dev, "This block is too old (rev %i), minimum supported is rev %i\n", + rev, IFI_CANFD_VER_REV_MIN_SUPPORTED); + return -EINVAL; + } + ndev = alloc_candev(sizeof(*priv), 1); if (!ndev) return -ENOMEM;