From patchwork Wed May 2 19:55:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 10376385 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CC0B56053D for ; Wed, 2 May 2018 19:56:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC9AB28E73 for ; Wed, 2 May 2018 19:56:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B170928FB9; Wed, 2 May 2018 19:56:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5FE9D28FB6 for ; Wed, 2 May 2018 19:56:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751133AbeEBTz4 (ORCPT ); Wed, 2 May 2018 15:55:56 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:41397 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750993AbeEBTzz (ORCPT ); Wed, 2 May 2018 15:55:55 -0400 Received: by mail-lf0-f65.google.com with SMTP id o123-v6so22614748lfe.8 for ; Wed, 02 May 2018 12:55:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20150623.gappssmtp.com; s=20150623; h=subject:from:to:cc:references:organization:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=5/VlcX46lvl8vy7grYetsO5hoYtmn5nqnISOFUuQyJ8=; b=ySPO/I6HkR+2Aje1lsRmXnYFW7DpyXPYArkp/hPpdo03B147+N3sZUpAathy3tLhIq V4VcPEB7fdX8zpz2xjTUtA6W54M2MnYsrEyk6UBzoWvQvJIDFqZOV8zUiPOU/uXGR1bB v2s+Uncz5N87F+LQTdIjmtEDIloBnGCaSG4klnf4dzv9cfKbgB3aQFDZbRVgxwPf/5kS XftkYUesFW5kQpLffyOYExMKvV5uyIsf1Jlur+5kzS6G2ZzJCi4tmvKQfFUtyIJllBND MID4Gu5X3B/n8Fv+g9LGY8Lj0Im0URLAy07WMgSTLMOiCCpFnKmUMPP6Wdorr8kbp8DT J2WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=5/VlcX46lvl8vy7grYetsO5hoYtmn5nqnISOFUuQyJ8=; b=mlIjNzzPSGfS5UnK1ge8Kjq9GRp8eUL3e0ZQkF52H8FvptK+KZHgTzZrMLfIbW4Z+w GFoIfnOR/b9zHF88IwhIqtIsyUUjZxu9+TPJfEtIZyNFLNPSZ5jqqnu/1DozcNCjaIIX 5iTB9Kygfiy1UplKQaHzIDwl4MkyMy6iNwYtXFnPvY30CiyIbH98CIa8xQpeQ4dzfqLX 3tGTFWv/5/Wx1s/EIUZYkKSkA3WmtSaydxqU3mihNb0/8971Q1/dU6EWzBn85iLQ3bYR eQK8tkNkAFlTbW/QA/ANrsCH4x5LC+R7Mw4v7yrj9Ji86p6hY7oR+XcTNEX5j0HTSzYh 8PHQ== X-Gm-Message-State: ALQs6tCFzyvKVgRqKdGZOazxXQWLnWNXlWAiDpBz2Llc6VYjoM3hDWIT X7/uUSgmTlWh41IqAgG6YWblh0Lt8y8= X-Google-Smtp-Source: AB8JxZrKOr5wUce6pHMqGH3Xtv9E8Dr81LHzRjAQbmdq4r5GDYQn2rYbYyCyE2lILQsClZq7DcnxwQ== X-Received: by 2002:a19:f505:: with SMTP id j5-v6mr12299935lfb.12.1525290954466; Wed, 02 May 2018 12:55:54 -0700 (PDT) Received: from wasted.cogentembedded.com ([31.173.87.190]) by smtp.gmail.com with ESMTPSA id w2-v6sm2493175ljw.70.2018.05.02.12.55.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 May 2018 12:55:53 -0700 (PDT) Subject: [PATCH 2/2] sh_eth: WARN_ON() access to unimplemented TSU register From: Sergei Shtylyov To: netdev@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, linux-sh@vger.kernel.org References: <4a17ab65-4d9c-897e-c340-7d86e0296f2f@cogentembedded.com> Organization: Cogent Embedded Message-ID: Date: Wed, 2 May 2018 22:55:52 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <4a17ab65-4d9c-897e-c340-7d86e0296f2f@cogentembedded.com> Content-Language: en-MW Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit 3365711df024 ("sh_eth: WARN on access to a register not implemented in a particular chip") added WARN_ON() to sh_eth_{read|write}() but not to sh_eth_tsu_{read|write}(). Now that we've routed almost all TSU register accesses (except TSU_ADR{H|L} -- which are special) thru the latter pair of accessors, it makes sense to check for the unimplemented TSU registers as well... Signed-off-by: Sergei Shtylyov --- drivers/net/ethernet/renesas/sh_eth.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) Index: net-next/drivers/net/ethernet/renesas/sh_eth.c =================================================================== --- net-next.orig/drivers/net/ethernet/renesas/sh_eth.c +++ net-next/drivers/net/ethernet/renesas/sh_eth.c @@ -442,12 +442,22 @@ static void sh_eth_modify(struct net_dev static void sh_eth_tsu_write(struct sh_eth_private *mdp, u32 data, int enum_index) { - iowrite32(data, mdp->tsu_addr + mdp->reg_offset[enum_index]); + u16 offset = mdp->reg_offset[enum_index]; + + if (WARN_ON(offset == SH_ETH_OFFSET_INVALID)) + return; + + iowrite32(data, mdp->tsu_addr + offset); } static u32 sh_eth_tsu_read(struct sh_eth_private *mdp, int enum_index) { - return ioread32(mdp->tsu_addr + mdp->reg_offset[enum_index]); + u16 offset = mdp->reg_offset[enum_index]; + + if (WARN_ON(offset == SH_ETH_OFFSET_INVALID)) + return ~0U; + + return ioread32(mdp->tsu_addr + offset); } static void sh_eth_select_mii(struct net_device *ndev)