linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] Staging: netlogic: platform_net.c: introduced a helper function
@ 2018-01-17  8:40 Naveen Panwar
  2018-02-16 14:33 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Naveen Panwar @ 2018-01-17  8:40 UTC (permalink / raw)
  To: gregkh; +Cc: naveen, naveen.panwar27, devel, linux-kernel

In staging/netlogic/platform.c Refactoring the identical code used
in several places for calculating the physical address of
memory-mapped objects on the device.Put that into an inline helper
function and use it.

Adjust the types of arguments of xlr_resource_init() - 'offset' and 'irq'
are actually unsigned.  The values passed to those fit into 0..2G range,
so the behaviour is unchanged, but it's more consistent that way.

Signed-off-by: Naveen Panwar <naveen.panwar27@gmail.com>
---
 drivers/staging/netlogic/platform_net.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/netlogic/platform_net.c b/drivers/staging/netlogic/platform_net.c
index f45b67a..2196dad 100644
--- a/drivers/staging/netlogic/platform_net.c
+++ b/drivers/staging/netlogic/platform_net.c
@@ -76,11 +76,16 @@ static struct resource xlr_net1_res[8];
 static u32 __iomem *gmac4_addr;
 static u32 __iomem *gpio_addr;
 
-static void xlr_resource_init(struct resource *res, int offset, int irq)
+static inline phys_addr_t physaddr(u32 offset)
+{
+	return CPHYSADDR(nlm_mmio_base(offset));
+}
+
+static void xlr_resource_init(struct resource *res, u32 offset, u32 irq)
 {
 	res->name = "gmac";
 
-	res->start = CPHYSADDR(nlm_mmio_base(offset));
+	res->start = physaddr(offset);
 	res->end = res->start + 0xfff;
 	res->flags = IORESOURCE_MEM;
 
@@ -107,8 +112,7 @@ static struct platform_device *gmac_controller2_init(void *gmac0_addr)
 		.dev.platform_data = &ndata1,
 	};
 
-	gmac4_addr = ioremap(CPHYSADDR
-			(nlm_mmio_base(NETLOGIC_IO_GMAC_4_OFFSET)), 0xfff);
+	gmac4_addr = ioremap(physaddr(NETLOGIC_IO_GMAC_4_OFFSET), 0xfff);
 	ndata1.serdes_addr = gmac4_addr;
 	ndata1.pcs_addr	= gmac4_addr;
 	ndata1.mii_addr	= gmac0_addr;
@@ -134,8 +138,7 @@ static void xls_gmac_init(void)
 {
 	int mac;
 	struct platform_device *xlr_net_dev1;
-	void __iomem *gmac0_addr = ioremap(CPHYSADDR
-			(nlm_mmio_base(NETLOGIC_IO_GMAC_0_OFFSET)), 0xfff);
+	void __iomem *gmac0_addr = ioremap(physaddr(NETLOGIC_IO_GMAC_0_OFFSET), 0xfff);
 
 	static struct xlr_net_data ndata0 = {
 		.rfr_station	= FMN_STNID_GMACRFR_0,
@@ -153,8 +156,7 @@ static void xls_gmac_init(void)
 	ndata0.mii_addr	= gmac0_addr;
 
 	/* Passing GPIO base for serdes init. Only needed on sgmii ports */
-	gpio_addr = ioremap(CPHYSADDR
-			(nlm_mmio_base(NETLOGIC_IO_GPIO_OFFSET)), 0xfff);
+	gpio_addr = ioremap(physaddr(NETLOGIC_IO_GPIO_OFFSET), 0xfff);
 	ndata0.gpio_addr = gpio_addr;
 	ndata0.cpu_mask = nlm_current_node()->coremask;
 
@@ -214,8 +216,7 @@ static void xlr_gmac_init(void)
 		.id		= 0,
 		.dev.platform_data = &ndata0,
 	};
-	ndata0.mii_addr = ioremap(CPHYSADDR
-			(nlm_mmio_base(NETLOGIC_IO_GMAC_0_OFFSET)), 0xfff);
+	ndata0.mii_addr = ioremap(physaddr(NETLOGIC_IO_GMAC_0_OFFSET), 0xfff);
 
 	ndata0.cpu_mask = nlm_current_node()->coremask;
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] Staging: netlogic: platform_net.c: introduced a helper function
  2018-01-17  8:40 [PATCH 2/2] Staging: netlogic: platform_net.c: introduced a helper function Naveen Panwar
@ 2018-02-16 14:33 ` Greg KH
  0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2018-02-16 14:33 UTC (permalink / raw)
  To: Naveen Panwar; +Cc: devel, naveen, linux-kernel

On Wed, Jan 17, 2018 at 02:10:47PM +0530, Naveen Panwar wrote:
> In staging/netlogic/platform.c Refactoring the identical code used
> in several places for calculating the physical address of
> memory-mapped objects on the device.Put that into an inline helper
> function and use it.
> 
> Adjust the types of arguments of xlr_resource_init() - 'offset' and 'irq'
> are actually unsigned.  The values passed to those fit into 0..2G range,
> so the behaviour is unchanged, but it's more consistent that way.
> 
> Signed-off-by: Naveen Panwar <naveen.panwar27@gmail.com>
> ---
>  drivers/staging/netlogic/platform_net.c | 21 +++++++++++----------
>  1 file changed, 11 insertions(+), 10 deletions(-)

This patch does not apply at all :(
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] Staging: netlogic: platform_net.c: introduced a helper function
@ 2018-01-15 18:35 Naveen Panwar
  0 siblings, 0 replies; 3+ messages in thread
From: Naveen Panwar @ 2018-01-15 18:35 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-kernel, Naveen Panwar

In staging/netlogic/platform.c Refactoring the identical code used
in several places for calculating the physical address of
memory-mapped objects on the device.Put that into an inline helper
function and use it.

Adjust the types of arguments of xlr_resource_init() - 'offset' and 'irq'
are actually unsigned.  The values passed to those fit into 0..2G range,
so the behaviour is unchanged, but it's more consistent that way.

Signed-off-by: Naveen Panwar <naveen.panwar27@gmail.com>
---
 drivers/staging/netlogic/platform_net.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/netlogic/platform_net.c b/drivers/staging/netlogic/platform_net.c
index f45b67a..2196dad 100644
--- a/drivers/staging/netlogic/platform_net.c
+++ b/drivers/staging/netlogic/platform_net.c
@@ -76,11 +76,16 @@ static struct resource xlr_net1_res[8];
 static u32 __iomem *gmac4_addr;
 static u32 __iomem *gpio_addr;
 
-static void xlr_resource_init(struct resource *res, int offset, int irq)
+static inline phys_addr_t physaddr(u32 offset)
+{
+	return CPHYSADDR(nlm_mmio_base(offset));
+}
+
+static void xlr_resource_init(struct resource *res, u32 offset, u32 irq)
 {
 	res->name = "gmac";
 
-	res->start = CPHYSADDR(nlm_mmio_base(offset));
+	res->start = physaddr(offset);
 	res->end = res->start + 0xfff;
 	res->flags = IORESOURCE_MEM;
 
@@ -107,8 +112,7 @@ static struct platform_device *gmac_controller2_init(void *gmac0_addr)
 		.dev.platform_data = &ndata1,
 	};
 
-	gmac4_addr = ioremap(CPHYSADDR
-			(nlm_mmio_base(NETLOGIC_IO_GMAC_4_OFFSET)), 0xfff);
+	gmac4_addr = ioremap(physaddr(NETLOGIC_IO_GMAC_4_OFFSET), 0xfff);
 	ndata1.serdes_addr = gmac4_addr;
 	ndata1.pcs_addr	= gmac4_addr;
 	ndata1.mii_addr	= gmac0_addr;
@@ -134,8 +138,7 @@ static void xls_gmac_init(void)
 {
 	int mac;
 	struct platform_device *xlr_net_dev1;
-	void __iomem *gmac0_addr = ioremap(CPHYSADDR
-			(nlm_mmio_base(NETLOGIC_IO_GMAC_0_OFFSET)), 0xfff);
+	void __iomem *gmac0_addr = ioremap(physaddr(NETLOGIC_IO_GMAC_0_OFFSET), 0xfff);
 
 	static struct xlr_net_data ndata0 = {
 		.rfr_station	= FMN_STNID_GMACRFR_0,
@@ -153,8 +156,7 @@ static void xls_gmac_init(void)
 	ndata0.mii_addr	= gmac0_addr;
 
 	/* Passing GPIO base for serdes init. Only needed on sgmii ports */
-	gpio_addr = ioremap(CPHYSADDR
-			(nlm_mmio_base(NETLOGIC_IO_GPIO_OFFSET)), 0xfff);
+	gpio_addr = ioremap(physaddr(NETLOGIC_IO_GPIO_OFFSET), 0xfff);
 	ndata0.gpio_addr = gpio_addr;
 	ndata0.cpu_mask = nlm_current_node()->coremask;
 
@@ -214,8 +216,7 @@ static void xlr_gmac_init(void)
 		.id		= 0,
 		.dev.platform_data = &ndata0,
 	};
-	ndata0.mii_addr = ioremap(CPHYSADDR
-			(nlm_mmio_base(NETLOGIC_IO_GMAC_0_OFFSET)), 0xfff);
+	ndata0.mii_addr = ioremap(physaddr(NETLOGIC_IO_GMAC_0_OFFSET), 0xfff);
 
 	ndata0.cpu_mask = nlm_current_node()->coremask;
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-02-16 14:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-17  8:40 [PATCH 2/2] Staging: netlogic: platform_net.c: introduced a helper function Naveen Panwar
2018-02-16 14:33 ` Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2018-01-15 18:35 Naveen Panwar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).