Skip to contentSkip to conversation

net: qcom/emac: fix a sizeof() typo

PATCH Applied Dan Carpenter 4 participants 10 messages Feb 13, 2017 – Feb 14, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: qcom/emac: fix a sizeof() typo

We had intended to say "sizeof(u32)" but the "u" is missing. Fortunately, sizeof(32) is also 4, so the original code still works.

Fixes c4e7beea2192 ("net: qcom/emac: add ethtool support for reading hardware registers")
drivers/net/ethernet/qualcomm/emac/emac-ethtool.c +1 -1
index 0d9945fb79be..bbe24639aa5a 100644
@@ -227,7 +227,7 @@ static void emac_get_regs(struct net_device *netdev,
 
 static int emac_get_regs_len(struct net_device *netdev)
 {
-	return EMAC_MAX_REG_SIZE * sizeof(32);
+	return EMAC_MAX_REG_SIZE * sizeof(u32);
 }
 
 static const struct ethtool_ops emac_ethtool_ops = {
#1 lore raw

Am 13.02.2017 12:00, schrieb Dan Carpenter:

Quoted 11 lines

We had intended to say "sizeof(u32)" but the "u" is missing. Fortunately, sizeof(32) is also 4, so the original code still works.

Fixes c4e7beea2192 ("net: qcom/emac: add ethtool support for reading hardware registers")
drivers/net/ethernet/qualcomm/emac/emac-ethtool.c +0 -0
index 0d9945fb79be..bbe24639aa5a 100644

drivers/net/ethernet/qualcomm/emac/emac-ethtool.c static void emac_get_regs(struct net_device *netdev, · line 232

Quoted 7 lines
drivers/net/ethernet/qualcomm/emac/emac-ethtool.c +1 -1
@@ -227,7 +227,7 @@ static void emac_get_regs(struct net_device *netdev,
 
 static int emac_get_regs_len(struct net_device *netdev)
 {
-	return EMAC_MAX_REG_SIZE * sizeof(32);
+	return EMAC_MAX_REG_SIZE * sizeof(u32);
 }
 

We have a function where the argument is ignored and the rest is const ?

emac_ethtool_get_regs_len seems the only user. So it would be fairly easy to move that into that function.

@maintainer:
Is there a deeper logic behind this ?

re,
wh

Quoted 6 lines
drivers/net/ethernet/qualcomm/emac/emac-ethtool.c +0 -1
 static const struct ethtool_ops emac_ethtool_ops = {
--

To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 7 lines · walter harms

We have a function where the argument is ignored and the rest is const ?

emac_ethtool_get_regs_len seems the only user. So it would be fairly easy to move that into that function.

@maintainer:
Is there a deeper logic behind this ?

I don't understand the question.

The patch is valid (I have no idea how I made that mistake).

Signature · 3 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the
Code Aurora Forum, hosted by The Linux Foundation.
#3 lore raw

Am 13.02.2017 14:03, schrieb Timur Tabi:

Quoted 11 lines
Quoted 8 lines · walter harms

We have a function where the argument is ignored and the rest is const ?

emac_ethtool_get_regs_len seems the only user. So it would be fairly easy to
move that into that function.

@maintainer:
Is there a deeper logic behind this ?

I don't understand the question.

The question is: why is a simple calculation const*const separated into a function ?

re,
wh

#5 lore raw
In reply to walter harms
Quoted 25 lines · walter harms

Am 13.02.2017 12:00, schrieb Dan Carpenter:

Quoted 11 lines

We had intended to say "sizeof(u32)" but the "u" is missing. Fortunately, sizeof(32) is also 4, so the original code still works.

Fixes c4e7beea2192 ("net: qcom/emac: add ethtool support for reading hardware registers")
drivers/net/ethernet/qualcomm/emac/emac-ethtool.c +0 -0
index 0d9945fb79be..bbe24639aa5a 100644

drivers/net/ethernet/qualcomm/emac/emac-ethtool.c static void emac_get_regs(struct net_device *netdev, · line 232

Quoted 7 lines
drivers/net/ethernet/qualcomm/emac/emac-ethtool.c +1 -1
@@ -227,7 +227,7 @@ static void emac_get_regs(struct net_device *netdev,
 
 static int emac_get_regs_len(struct net_device *netdev)
 {
-	return EMAC_MAX_REG_SIZE * sizeof(32);
+	return EMAC_MAX_REG_SIZE * sizeof(u32);
 }
 

We have a function where the argument is ignored and the rest is const ?

Quoted 2 lines

emac_ethtool_get_regs_len seems the only user. So it would be fairly easy to move that into that function.

It's not the only user. We have to pass netdev because it's used as a function pointer.

regards,
dan carpenter

#4 lore raw
In reply to walter harms
Quoted 2 lines · walter harms

The question is: why is a simple calculation const*const separated into a function ?

This is a callback function. That's just how it's defined.

It's rare, but there are drivers that use the parameter, like this one:

http://git.kernel.org/cgit/linux/kernel/git/davem/net-next.git/tree/drivers/net/ethernet/qlogic/qlge/qlge_ethtool.c#n591

Signature · 3 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the
Code Aurora Forum, hosted by The Linux Foundation.
Acked-by on v1 1/1
#6 lore raw
In reply to Dan Carpenter
Quoted 5 lines · Dan Carpenter

We had intended to say "sizeof(u32)" but the "u" is missing. Fortunately, sizeof(32) is also 4, so the original code still works.

Fixes c4e7beea2192 ("net: qcom/emac: add ethtool support for reading hardware registers")
Signature · 3 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the
Code Aurora Forum, hosted by The Linux Foundation.
#7 lore raw
In reply to Dan Carpenter

Am 13.02.2017 16:43, schrieb Timur Tabi:

Quoted 11 lines
Quoted 2 lines · walter harms

The question is: why is a simple calculation const*const separated into a function ?

This is a callback function. That's just how it's defined.

It's rare, but there are drivers that use the parameter, like this one:

http://git.kernel.org/cgit/linux/kernel/git/davem/net-next.git/tree/drivers/net/ethernet/qlogic/qlge/qlge_ethtool.c#n591

this is the problem:
I used: http://lxr.free-electrons.com/source/drivers/net/ibm_emac/ibm_emac_core.c?v=2.6.24#L1778

here is the patched function emac_get_regs_len used the calculate the length in emac_ethtool_get_regs_len what is used as callback.

in
http://git.kernel.org/cgit/linux/kernel/git/davem/net-next.git/tree/drivers/net/ethernet/qualcomm/emac/emac-ethtool.c
is it now used directly.

sorry for the noise,

re,
wh

#8 lore raw
In reply to Dan Carpenter

Ah yes, thet are two completely different network drivers, both called EMAC. IBM's EMAC controller is not related at all to Qualcomm's EMAC driver. It's just an unfortunate coincidence that both devices are called EMAC, and that's why both drivers are also called EMAC.

Quoted 30 lines · walter harms

Am 13.02.2017 16:43, schrieb Timur Tabi:

Quoted 11 lines
Quoted 2 lines · walter harms

The question is: why is a simple calculation const*const separated into a function ?

This is a callback function. That's just how it's defined.

It's rare, but there are drivers that use the parameter, like this one:

http://git.kernel.org/cgit/linux/kernel/git/davem/net-next.git/tree/drivers/net/ethernet/qlogic/qlge/qlge_ethtool.c#n591

this is the problem:
I used: http://lxr.free-electrons.com/source/drivers/net/ibm_emac/ibm_emac_core.c?v=2.6.24#L1778

here is the patched function emac_get_regs_len used the calculate the length in emac_ethtool_get_regs_len what is used as callback.

in
http://git.kernel.org/cgit/linux/kernel/git/davem/net-next.git/tree/drivers/net/ethernet/qualcomm/emac/emac-ethtool.c
is it now used directly.

sorry for the noise,

re,
wh

Signature · 3 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the
Code Aurora Forum, hosted by The Linux Foundation.