Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1471584ybh; Thu, 23 Jul 2020 09:39:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx94Ib+ewzBS9MvN3HyAfDsw6EFRYB/RRKiOOTSx5hHsGz3UByLy+TyLHsL3J23nXOnl88N X-Received: by 2002:a17:906:6897:: with SMTP id n23mr3157281ejr.297.1595522376827; Thu, 23 Jul 2020 09:39:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595522376; cv=none; d=google.com; s=arc-20160816; b=ziDILBjxCU6Ft8mfhdV9IcgokP3VQ7JBqA7IhXFqMJmoI9ixD0r2FkSIcBH4uRZNVM yOp6/VPxMyoZRAIQnAsr5dwrlNZb4vXljNaWGC8Y4nfpjfAFpF4xo8a1xZPOy8Oys5z3 SHeSo7W2iNa5RtJFJ9GMJINxM+C0a248z7LJDBCoURj8WKvvOjXlhqbxniF5/DKW+Chx ZyW8ZN4UChpFO0s9m2eG+aLQYM8SyxpSar+klOTmKIriFnbQ+68PTDx094gyaRXyf7rb 2jtjynpQN4YGbnk1/5cSZCyxR4vjML9Fa3wAYGT/P9tKyTVNLR0INAJB8ofW/iNehYCD hR4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:reply-to:ironport-sdr :ironport-sdr; bh=2M1aQmI0/cHSTEGpbNKFuwDSV4CK/J/VI9bdI36LucQ=; b=XhOoj65+QcVqa9RkDLa/2aL7cAIymnigsL7JoJpGqYwyUiciNPurYPdYX6UClm0IKj z61i3kr5nZ2NjifpnmhNcjPZG2rNWjy0iHL869g7tKYx/bNVQgC8I8XAy6PICrs1MHQU E3cAyy49++25gi+Kt8kw4J0yfRasWI0eV/0l8a++636O4Ru/Yc2aW75+QCv6+bAPUjvF jDDqrFbZU39Vcc+Q1xfTejb5GVD9r/hlxBUEYE/UXrDm46Wh5HzClOwjBB8hxwJhpD2h 6wmeW3QdpIXdWfDxvKhl9qxEHr4y16A/neN6eipwJkwf1nuMTddAbuEo6d8GCic/kjwv b3rA== ARC-Authentication-Results: i=1; mx.google.com; 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l10si639639edk.142.2020.07.23.09.39.14; Thu, 23 Jul 2020 09:39:36 -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; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729875AbgGWQjD (ORCPT + 99 others); Thu, 23 Jul 2020 12:39:03 -0400 Received: from mga17.intel.com ([192.55.52.151]:18382 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726649AbgGWQjD (ORCPT ); Thu, 23 Jul 2020 12:39:03 -0400 IronPort-SDR: T/vaNr0i++vssk5z+hMTwyfvFFf6X02oTk+dqzulhfg/2c+RLDkNstCsyZzJ2yGfxkUAbI6Gq0 3up1Mty23PeA== X-IronPort-AV: E=McAfee;i="6000,8403,9691"; a="130645846" X-IronPort-AV: E=Sophos;i="5.75,387,1589266800"; d="scan'208";a="130645846" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jul 2020 09:38:55 -0700 IronPort-SDR: 82caIWkwnXhub7UaQfxmQvI2LX7Kjo7m5xbS4S+sgwiAoKWx41Hwrl1ri9b9mKCALuF3DvaZtD LjvxekVeLMtA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,387,1589266800"; d="scan'208";a="432797009" Received: from tthayer-hp-z620.an.intel.com (HELO [10.122.105.146]) ([10.122.105.146]) by orsmga004.jf.intel.com with ESMTP; 23 Jul 2020 09:38:54 -0700 Reply-To: thor.thayer@linux.intel.com Subject: Re: [PATCH v4 05/10] net: eth: altera: Move common functions to altera_utils To: "Ooi, Joyce" , "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Dalon Westergreen , Tan Ley Foon , See Chin Liang , Dinh Nguyen , Dalon Westergreen References: <20200708072401.169150-1-joyce.ooi@intel.com> <20200708072401.169150-6-joyce.ooi@intel.com> From: Thor Thayer Message-ID: <790a146f-5bb3-6e11-d80f-b63aaf9a5531@linux.intel.com> Date: Thu, 23 Jul 2020 11:39:06 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200708072401.169150-6-joyce.ooi@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/8/20 2:23 AM, Ooi, Joyce wrote: > From: Dalon Westergreen > > Move request_and_map and other shared functions to altera_utils. This > is the first step to moving common code out of tse specific code so > that it can be shared with future altera ethernet ip. > > Signed-off-by: Dalon Westergreen > Signed-off-by: Joyce Ooi > --- > v2: no change > v3: no change > v4: no change > --- > drivers/net/ethernet/altera/altera_tse.h | 45 --------------------- > drivers/net/ethernet/altera/altera_tse_ethtool.c | 1 + > drivers/net/ethernet/altera/altera_tse_main.c | 32 +-------------- > drivers/net/ethernet/altera/altera_utils.c | 29 ++++++++++++++ > drivers/net/ethernet/altera/altera_utils.h | 51 ++++++++++++++++++++++++ > 5 files changed, 82 insertions(+), 76 deletions(-) > > diff --git a/drivers/net/ethernet/altera/altera_tse.h b/drivers/net/ethernet/altera/altera_tse.h > index 26c5541fda27..fa24ab3c7d6a 100644 > --- a/drivers/net/ethernet/altera/altera_tse.h > +++ b/drivers/net/ethernet/altera/altera_tse.h > @@ -489,49 +489,4 @@ struct altera_tse_private { > */ > void altera_tse_set_ethtool_ops(struct net_device *); > > -static inline > -u32 csrrd32(void __iomem *mac, size_t offs) > -{ > - void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs); > - return readl(paddr); > -} > - > -static inline > -u16 csrrd16(void __iomem *mac, size_t offs) > -{ > - void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs); > - return readw(paddr); > -} > - > -static inline > -u8 csrrd8(void __iomem *mac, size_t offs) > -{ > - void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs); > - return readb(paddr); > -} > - > -static inline > -void csrwr32(u32 val, void __iomem *mac, size_t offs) > -{ > - void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs); > - > - writel(val, paddr); > -} > - > -static inline > -void csrwr16(u16 val, void __iomem *mac, size_t offs) > -{ > - void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs); > - > - writew(val, paddr); > -} > - > -static inline > -void csrwr8(u8 val, void __iomem *mac, size_t offs) > -{ > - void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs); > - > - writeb(val, paddr); > -} > - > #endif /* __ALTERA_TSE_H__ */ > diff --git a/drivers/net/ethernet/altera/altera_tse_ethtool.c b/drivers/net/ethernet/altera/altera_tse_ethtool.c > index 4299f1301149..420d77f00eab 100644 > --- a/drivers/net/ethernet/altera/altera_tse_ethtool.c > +++ b/drivers/net/ethernet/altera/altera_tse_ethtool.c > @@ -22,6 +22,7 @@ > #include > > #include "altera_tse.h" > +#include "altera_utils.h" > > #define TSE_STATS_LEN 31 > #define TSE_NUM_REGS 128 > diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c > index 0a724e4d2c8c..c9100ce24b0a 100644 > --- a/drivers/net/ethernet/altera/altera_tse_main.c > +++ b/drivers/net/ethernet/altera/altera_tse_main.c > @@ -23,7 +23,6 @@ > #include > #include > #include > -#include > #include > #include > #include > @@ -33,7 +32,7 @@ > #include > #include > #include > -#include > +#include > #include > #include > > @@ -1320,35 +1319,6 @@ static struct net_device_ops altera_tse_netdev_ops = { > .ndo_validate_addr = eth_validate_addr, > }; > > -static int request_and_map(struct platform_device *pdev, const char *name, > - struct resource **res, void __iomem **ptr) > -{ > - struct resource *region; > - struct device *device = &pdev->dev; > - > - *res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name); > - if (*res == NULL) { > - dev_err(device, "resource %s not defined\n", name); > - return -ENODEV; > - } > - > - region = devm_request_mem_region(device, (*res)->start, > - resource_size(*res), dev_name(device)); > - if (region == NULL) { > - dev_err(device, "unable to request %s\n", name); > - return -EBUSY; > - } > - > - *ptr = devm_ioremap(device, region->start, > - resource_size(region)); > - if (*ptr == NULL) { > - dev_err(device, "ioremap of %s failed!", name); > - return -ENOMEM; > - } > - > - return 0; > -} > - > /* Probe Altera TSE MAC device > */ > static int altera_tse_probe(struct platform_device *pdev) > diff --git a/drivers/net/ethernet/altera/altera_utils.c b/drivers/net/ethernet/altera/altera_utils.c > index e6a7fc9d8fb1..c9bc7d0ea02a 100644 > --- a/drivers/net/ethernet/altera/altera_utils.c > +++ b/drivers/net/ethernet/altera/altera_utils.c > @@ -31,3 +31,32 @@ int tse_bit_is_clear(void __iomem *ioaddr, size_t offs, u32 bit_mask) > u32 value = csrrd32(ioaddr, offs); > return (value & bit_mask) ? 0 : 1; > } > + > +int request_and_map(struct platform_device *pdev, const char *name, > + struct resource **res, void __iomem **ptr) > +{ > + struct resource *region; > + struct device *device = &pdev->dev; > + > + *res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name); > + if (!*res) { > + dev_err(device, "resource %s not defined\n", name); > + return -ENODEV; > + } > + > + region = devm_request_mem_region(device, (*res)->start, > + resource_size(*res), dev_name(device)); > + if (!region) { > + dev_err(device, "unable to request %s\n", name); > + return -EBUSY; > + } > + > + *ptr = devm_ioremap(device, region->start, > + resource_size(region)); > + if (!*ptr) { > + dev_err(device, "ioremap of %s failed!", name); > + return -ENOMEM; > + } > + > + return 0; > +} > diff --git a/drivers/net/ethernet/altera/altera_utils.h b/drivers/net/ethernet/altera/altera_utils.h > index b7d772f2dcbb..fbe985099a44 100644 > --- a/drivers/net/ethernet/altera/altera_utils.h > +++ b/drivers/net/ethernet/altera/altera_utils.h > @@ -3,7 +3,9 @@ > * Copyright (C) 2014 Altera Corporation. All rights reserved > */ > > +#include > #include > +#include > > #ifndef __ALTERA_UTILS_H__ > #define __ALTERA_UTILS_H__ > @@ -12,5 +14,54 @@ void tse_set_bit(void __iomem *ioaddr, size_t offs, u32 bit_mask); > void tse_clear_bit(void __iomem *ioaddr, size_t offs, u32 bit_mask); > int tse_bit_is_set(void __iomem *ioaddr, size_t offs, u32 bit_mask); > int tse_bit_is_clear(void __iomem *ioaddr, size_t offs, u32 bit_mask); > +int request_and_map(struct platform_device *pdev, const char *name, > + struct resource **res, void __iomem **ptr); > > +static inline > +u32 csrrd32(void __iomem *mac, size_t offs) > +{ > + void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs); > + > + return readl(paddr); > +} > + > +static inline > +u16 csrrd16(void __iomem *mac, size_t offs) > +{ > + void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs); > + > + return readw(paddr); > +} > + > +static inline > +u8 csrrd8(void __iomem *mac, size_t offs) > +{ > + void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs); > + > + return readb(paddr); > +} > + > +static inline > +void csrwr32(u32 val, void __iomem *mac, size_t offs) > +{ > + void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs); > + > + writel(val, paddr); > +} > + > +static inline > +void csrwr16(u16 val, void __iomem *mac, size_t offs) > +{ > + void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs); > + > + writew(val, paddr); > +} > + > +static inline > +void csrwr8(u8 val, void __iomem *mac, size_t offs) > +{ > + void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs); > + > + writeb(val, paddr); > +} > #endif /* __ALTERA_UTILS_H__*/ > Reviewed-by: Thor Thayer