Received: by 10.213.65.68 with SMTP id h4csp841120imn; Tue, 27 Mar 2018 09:46:08 -0700 (PDT) X-Google-Smtp-Source: AIpwx49ANZnxljCjZ86u91EffH9C/otT/kjscjAnJNGs4LDaffpavWWO2+GnZe003xacAQgR0UcJ X-Received: by 10.98.77.197 with SMTP id a188mr41550pfb.219.1522169167900; Tue, 27 Mar 2018 09:46:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522169167; cv=none; d=google.com; s=arc-20160816; b=CaeFnJ5WH6hBOfW1hX/BAjb20QxfVO6FADrNfcSe1pJq2DYcdc76Ktqcy0bO/z7VAs rovVHYpJUVg42JWHTMRai8cb2Xn+yhcearpkN4gAGYhpfNRnhAMOtw3rIYxa3Xwn8+wr aavbhJ3iwFLW7UI5i6kkVUqMyRq4uT5G9AgCBX7Me7K36K4HcOxrf22zXikZ8Pr2wolb hP7XUvuS1DoVJeWxJVYINIUB9oS/ymM/I3veC4m/ITW11QPQcJ1W2z2lvnNGC+6rR6ue m1BbmzFztEAMHb7ohPV1qu9r7cq3hts8FEyF13xImHe4uFrbgTdRMWuI4Spp70Uma0ry yrvw== 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=5YL5NPZG5jK8ejElntm4yZW2Ypimnax/dfJuu4Nj0ro=; b=1D6JUMI8i7ENGv+0NAtRCuYSetAL5AdDPTCHDc3tSe9QEo4yLDzk35nFxB8LzdnfEY HH4CxAkhowWOJE/h0CGKq+QbuEcGHpKCZqaf5pdNBL1HiKCLPdXDi0yPtrQs/1JuVgUu 0IBgyH/5+Y8rf9PLl0i55KoiIMJuRnA/EdIL5D8EFMFKeoqOU3sdXGoq5jCx7tR7KcIW oiD301fBn5/v0xJ8WCMCA1NoAMI5znmgzm6gLBoShbq+bmr9fiZ58ILLYMB+715TdTsE 2gp0FgJ5sHSW4X7tHEAfd/mkVNg9Z70x8jE2o/4+0QLqRVM/bggp+vDy4bOLTYusZO4j /mzQ== 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 a59-v6si1647376pla.497.2018.03.27.09.45.53; Tue, 27 Mar 2018 09:46:07 -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 S1755582AbeC0Qnd (ORCPT + 99 others); Tue, 27 Mar 2018 12:43:33 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:49544 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751219AbeC0Qn3 (ORCPT ); Tue, 27 Mar 2018 12:43:29 -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 AD85E1098; Tue, 27 Mar 2018 16:43:28 +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.15 078/105] can: ifi: Check core revision upon probe Date: Tue, 27 Mar 2018 18:27:58 +0200 Message-Id: <20180327162802.708932607@linuxfoundation.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180327162757.813009222@linuxfoundation.org> References: <20180327162757.813009222@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.15-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;