Re: [net-next 12/12] igc: Clean up code

2018-11-08 Thread Joe Perches
On Wed, 2018-11-07 at 14:48 -0800, Jeff Kirsher wrote:
> From: Sasha Neftin 
> 
> Address few community comments.
> Remove unused code, will be added per demand.
> Remove blank lines and unneeded includes.
> 
> Signed-off-by: Sasha Neftin 
> Tested-by: Aaron Brown 
> Signed-off-by: Jeff Kirsher 
> ---
>  drivers/net/ethernet/intel/igc/igc.h  |  9 -
>  drivers/net/ethernet/intel/igc/igc_main.c | 15 ---
>  2 files changed, 24 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/igc/igc.h 
> b/drivers/net/ethernet/intel/igc/igc.h
[]
>  #define IGC_ERR(args...) pr_err("igc: " args)

This is used just once and should probably be removed.

maybe:

---
 drivers/net/ethernet/intel/igc/igc_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/igc/igc_main.c 
b/drivers/net/ethernet/intel/igc/igc_main.c
index 9d85707e8a81..b58542b20623 100644
--- a/drivers/net/ethernet/intel/igc/igc_main.c
+++ b/drivers/net/ethernet/intel/igc/igc_main.c
@@ -3551,7 +3551,7 @@ static int igc_probe(struct pci_dev *pdev,
err = dma_set_coherent_mask(>dev,
DMA_BIT_MASK(32));
if (err) {
-   IGC_ERR("Wrong DMA configuration, aborting\n");
+   dev_err(>dev, "igc: Wrong DMA 
configuration, aborting\n");
goto err_dma;
}
}




Re: [Patch V4 net 01/11] net: hns3: add error handler for hns3_nic_init_vector_data()

2018-10-29 Thread Joe Perches
On Tue, 2018-10-30 at 09:21 +0800, tanhuazhong wrote:
> 
> On 2018/10/30 1:44, Joe Perches wrote:
> > On Mon, 2018-10-29 at 21:54 +0800, Huazhong Tan wrote:
> > > When hns3_nic_init_vector_data() fails to map ring to vector,
> > > it should cancel the netif_napi_add() that has been successfully
> > > done and then exits.
> > []
> > > diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c 
> > > b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
> > []
> > > @@ -2821,7 +2821,7 @@ static int hns3_nic_init_vector_data(struct 
> > > hns3_nic_priv *priv)
> > >   struct hnae3_handle *h = priv->ae_handle;
> > >   struct hns3_enet_tqp_vector *tqp_vector;
> > >   int ret = 0;
> > > - u16 i;
> > > + int i, j;
> > >   
> > >   hns3_nic_set_cpumask(priv);
> > >   
> > > @@ -2868,13 +2868,19 @@ static int hns3_nic_init_vector_data(struct 
> > > hns3_nic_priv *priv)
> > >   hns3_free_vector_ring_chain(tqp_vector, 
> > > _ring_chain);
> > >   
> > >   if (ret)
> > > - return ret;
> > > + goto map_ring_fail;
> > >   
> > >   netif_napi_add(priv->netdev, _vector->napi,
> > >  hns3_nic_common_poll, NAPI_POLL_WEIGHT);
> > >   }
> > >   
> > >   return 0;
> > > +
> > > +map_ring_fail:
> > > + for (j = i - 1; j >= 0; j--)
> > > + netif_napi_del(>tqp_vector[j].napi);
> > 
> > style trivia:
> > 
> > Error clearing is most commonly done without another variable
> > by decrementing i in the loop.
> > 
> 
> Hi, Joe.
> Is the below one more suitable?

Yes.

> +
> +map_ring_fail:
> + while(i--)
> + netif_napi_del(>tqp_vector[i].napi);
> +
> + return ret;
> 
> Or do you have any other better suggestion?

No I do not.

"while (i--)" is a much more common style.

cheers, Joe




Re: [Patch V4 net 01/11] net: hns3: add error handler for hns3_nic_init_vector_data()

2018-10-29 Thread Joe Perches
On Mon, 2018-10-29 at 21:54 +0800, Huazhong Tan wrote:
> When hns3_nic_init_vector_data() fails to map ring to vector,
> it should cancel the netif_napi_add() that has been successfully
> done and then exits.
[]
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c 
> b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
[]
> @@ -2821,7 +2821,7 @@ static int hns3_nic_init_vector_data(struct 
> hns3_nic_priv *priv)
>   struct hnae3_handle *h = priv->ae_handle;
>   struct hns3_enet_tqp_vector *tqp_vector;
>   int ret = 0;
> - u16 i;
> + int i, j;
>  
>   hns3_nic_set_cpumask(priv);
>  
> @@ -2868,13 +2868,19 @@ static int hns3_nic_init_vector_data(struct 
> hns3_nic_priv *priv)
>   hns3_free_vector_ring_chain(tqp_vector, _ring_chain);
>  
>   if (ret)
> - return ret;
> + goto map_ring_fail;
>  
>   netif_napi_add(priv->netdev, _vector->napi,
>  hns3_nic_common_poll, NAPI_POLL_WEIGHT);
>   }
>  
>   return 0;
> +
> +map_ring_fail:
> + for (j = i - 1; j >= 0; j--)
> + netif_napi_del(>tqp_vector[j].napi);

style trivia:

Error clearing is most commonly done without another variable
by decrementing i in the loop.




Re: [PATCH v2] rtlwifi: remove set but not used variable 'radiob_array_table' and 'radiob_arraylen'

2018-10-23 Thread Joe Perches
On Tue, 2018-10-23 at 16:28 +0800, zhong jiang wrote:
> radiob_array_table' and 'radiob_arraylen' are not used after setting its 
> value.
> It is safe to remove the unused variable. Meanwhile, radio B radio should be
> removed as well. because it will no longer be referenced.

The patch subject is a bit off and too generic here.

This is specific to rtl8723ae and not rtlwifi so it is
probably better for the subject to be something like:

[PATCH] rtl8723ae: Remove set but not used variables and #defines

> Signed-off-by: zhong jiang 
> ---
>  drivers/net/wireless/realtek/rtlwifi/rtl8723ae/phy.c   | 5 +
>  drivers/net/wireless/realtek/rtlwifi/rtl8723ae/table.c | 4 
>  drivers/net/wireless/realtek/rtlwifi/rtl8723ae/table.h | 2 --



Re: [PATCH v7 15/15] MAINTAINERS: Add entry for Marvell OcteonTX2 Admin Function driver

2018-10-06 Thread Joe Perches
On Sat, 2018-10-06 at 11:36 +0530, sunil.kovv...@gmail.com wrote:
> Added maintainers entry for Marvell OcteonTX2 SOC's RVU
> admin function driver.
[]
> diff --git a/MAINTAINERS b/MAINTAINERS
[]
> @@ -8844,6 +8844,15 @@ S: Supported
>  F:   drivers/mmc/host/sdhci-xenon*
>  F:   Documentation/devicetree/bindings/mmc/marvell,xenon-sdhci.txt
>  
> +MARVELL OCTEONTX2 RVU ADMIN FUNCTION DRIVER
> +M:   Sunil Goutham 
> +M:   Linu Cherian 
> +M:   Geetha sowjanya  +M:   Jerin Jacob 
> +L:   netdev@vger.kernel.org
> +S:   Maintained

Aren't you all being paid?

So shouldn't this be

S:  Supported

?

> +F:   drivers/net/ethernet/marvell/octeontx2/af

Please add a terminating / to show that this
is a directory and not a file.

F:  drivers/net/ethernet/marvell/octeontx2/af/




Re: any reason for "!!netif_carrier_ok" and "!!netif_dormant" in net-sysfs.c?

2018-08-27 Thread Joe Perches
On Mon, 2018-08-27 at 12:16 -0400, rpj...@crashcourse.ca wrote:
> Quoting David Miller :
> 
> > From: "Robert P. J. Day" 
> > Date: Mon, 27 Aug 2018 04:55:29 -0400 (EDT)
> > 
> > >   another pedantic oddity -- is there a reason for these two double
> > > negations in net/core/net-sysfs.c?
> > 
> > It turns an arbitrary integer into a boolean, this is a common
> > construct across the kernel tree so I'm surprised you've never seen
> > it before.
> > 
> > Although, I don't know how much more hand holding we're willing to
> > tolerate continuing to give to you at this point.
> > 
> > Thanks.
> 
>I mentioned in my earlier email that I know what that construct is
> *typically* used for; I also pointed out that, AFAICT, it was totally
> unnecessary in the context of the two routines I mentioned, which
> would appear to ever return only one of two boolean values, 0 or 1.

Both are bool functions, so it's guaranteed and the
!! uses are redundant.

include/linux/netdevice.h:static inline bool netif_carrier_ok(const struct 
net_device *dev)
include/linux/netdevice.h:static inline bool netif_dormant(const struct 
net_device *dev)

And there are 4 uses with !!

$ git grep -P  '\!\s*\!\s*netif_(?:dormant|carrier_ok)\s*\('
drivers/net/team/team.c:__team_port_change_port_added(port, 
!!netif_carrier_ok(port_dev));
drivers/net/usb/r8152.c:bool sw_linking = 
!!netif_carrier_ok(tp->netdev);
net/core/net-sysfs.c:   return sprintf(buf, fmt_dec, 
!!netif_carrier_ok(netdev));
net/core/net-sysfs.c:   return sprintf(buf, fmt_dec, 
!!netif_dormant(netdev));

out of the ~400 or so treewide.

Only redeeming use of the !! is the fmt_dec expects
an int and this forces the type to int, though the
compiler would do that automatically anyway.

I'd suggest removing the fmt_ uses for clarity.
---
 net/core/net-sysfs.c | 49 ++---
 1 file changed, 22 insertions(+), 27 deletions(-)

diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index bd67c4d0fcfd..ecaa684f4b92 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -31,11 +31,6 @@
 #include "net-sysfs.h"
 
 #ifdef CONFIG_SYSFS
-static const char fmt_hex[] = "%#x\n";
-static const char fmt_dec[] = "%d\n";
-static const char fmt_ulong[] = "%lu\n";
-static const char fmt_u64[] = "%llu\n";
-
 static inline int dev_isalive(const struct net_device *dev)
 {
return dev->reg_state <= NETREG_REGISTERED;
@@ -107,26 +102,26 @@ static ssize_t netdev_store(struct device *dev, struct 
device_attribute *attr,
return ret;
 }
 
-NETDEVICE_SHOW_RO(dev_id, fmt_hex);
-NETDEVICE_SHOW_RO(dev_port, fmt_dec);
-NETDEVICE_SHOW_RO(addr_assign_type, fmt_dec);
-NETDEVICE_SHOW_RO(addr_len, fmt_dec);
-NETDEVICE_SHOW_RO(ifindex, fmt_dec);
-NETDEVICE_SHOW_RO(type, fmt_dec);
-NETDEVICE_SHOW_RO(link_mode, fmt_dec);
+NETDEVICE_SHOW_RO(dev_id, "%#x\n");
+NETDEVICE_SHOW_RO(dev_port, "%d\n");
+NETDEVICE_SHOW_RO(addr_assign_type, "%d\n");
+NETDEVICE_SHOW_RO(addr_len, "%d\n");
+NETDEVICE_SHOW_RO(ifindex, "%d\n");
+NETDEVICE_SHOW_RO(type, "%d\n");
+NETDEVICE_SHOW_RO(link_mode, "%d\n");
 
 static ssize_t iflink_show(struct device *dev, struct device_attribute *attr,
   char *buf)
 {
struct net_device *ndev = to_net_dev(dev);
 
-   return sprintf(buf, fmt_dec, dev_get_iflink(ndev));
+   return sprintf(buf, "%d\n", dev_get_iflink(ndev));
 }
 static DEVICE_ATTR_RO(iflink);
 
 static ssize_t format_name_assign_type(const struct net_device *dev, char *buf)
 {
-   return sprintf(buf, fmt_dec, dev->name_assign_type);
+   return sprintf(buf, "%d\n", dev->name_assign_type);
 }
 
 static ssize_t name_assign_type_show(struct device *dev,
@@ -188,7 +183,7 @@ static ssize_t carrier_show(struct device *dev,
struct net_device *netdev = to_net_dev(dev);
 
if (netif_running(netdev))
-   return sprintf(buf, fmt_dec, !!netif_carrier_ok(netdev));
+   return sprintf(buf, "%d\n", !!netif_carrier_ok(netdev));
 
return -EINVAL;
 }
@@ -207,7 +202,7 @@ static ssize_t speed_show(struct device *dev,
struct ethtool_link_ksettings cmd;
 
if (!__ethtool_get_link_ksettings(netdev, ))
-   ret = sprintf(buf, fmt_dec, cmd.base.speed);
+   ret = sprintf(buf, "%d\n", cmd.base.speed);
}
rtnl_unlock();
return ret;
@@ -254,7 +249,7 @@ static ssize_t dormant_show(struct device *dev,
struct net_device *netdev = to_net_dev(dev);
 
if (netif_running(netdev))
-   return sprintf(buf, fmt_dec, !!netif_dormant(netdev));
+   return sprintf(buf, "%d\n", !!netif_dormant(netdev));
 
return -EINVAL;
 }
@@ -295,7 +290,7 @@ static ssize_t carrier_changes_show(struct device *dev,
 {
struct net_device *netdev = to_net_dev(dev);
 
-   return sprintf(buf, fmt_dec,
+   return sprintf(buf, "%d\n",
   

Re: [net 01/11] ixgb: use dma_zalloc_coherent instead of allocator/memset

2018-08-25 Thread Joe Perches
On Fri, 2018-08-24 at 11:47 -0700, Jeff Kirsher wrote:
> From: YueHaibing 
> 
> Use dma_zalloc_coherent instead of dma_alloc_coherent
> followed by memset 0.

Unrelated trivia:  above this, perhaps the

size = sizeof(struct ixgb_buffer) * txdr->count;
txdr->buffer_info = vzalloc(size);
if (!txdr->buffer_info)
return -ENOMEM;

should be changed to kvzalloc to avoid using vzalloc where
possible, with the appropriate vfree/kvfree conversions.

Perhaps across all intel drivers:

$ git grep -n "\bv.alloc(" drivers/net/ethernet/intel
drivers/net/ethernet/intel/e1000/e1000_main.c:1499: txdr->buffer_info = 
vzalloc(size);
drivers/net/ethernet/intel/e1000/e1000_main.c:1689: rxdr->buffer_info = 
vzalloc(size);
drivers/net/ethernet/intel/e1000e/ethtool.c:705:temp_tx = 
vmalloc(size);
drivers/net/ethernet/intel/e1000e/ethtool.c:712:temp_rx = 
vmalloc(size);
drivers/net/ethernet/intel/e1000e/netdev.c:2328:tx_ring->buffer_info = 
vzalloc(size);
drivers/net/ethernet/intel/e1000e/netdev.c:2363:rx_ring->buffer_info = 
vzalloc(size);
drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c:561:   temp_ring = 
vmalloc(array_size(i, sizeof(struct fm10k_ring)));
drivers/net/ethernet/intel/fm10k/fm10k_netdev.c:22: tx_ring->tx_buffer = 
vzalloc(size);
drivers/net/ethernet/intel/fm10k/fm10k_netdev.c:90: rx_ring->rx_buffer = 
vzalloc(size);
drivers/net/ethernet/intel/igb/igb_ethtool.c:905:   temp_ring = 
vmalloc(array_size(sizeof(struct igb_ring),
drivers/net/ethernet/intel/igb/igb_ethtool.c:908:   temp_ring = 
vmalloc(array_size(sizeof(struct igb_ring),
drivers/net/ethernet/intel/igb/igb_main.c:4075: tx_ring->tx_buffer_info = 
vmalloc(size);
drivers/net/ethernet/intel/igb/igb_main.c:4224: rx_ring->rx_buffer_info = 
vmalloc(size);
drivers/net/ethernet/intel/igbvf/ethtool.c:226: temp_ring = 
vmalloc(sizeof(struct igbvf_ring));
drivers/net/ethernet/intel/igbvf/netdev.c:421:  tx_ring->buffer_info = 
vzalloc(size);
drivers/net/ethernet/intel/igbvf/netdev.c:459:  rx_ring->buffer_info = 
vzalloc(size);
drivers/net/ethernet/intel/ixgb/ixgb_main.c:682:txdr->buffer_info = 
vzalloc(size);
drivers/net/ethernet/intel/ixgb/ixgb_main.c:765:rxdr->buffer_info = 
vzalloc(size);
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c:1074:  temp_ring = 
vmalloc(array_size(i, sizeof(struct ixgbe_ring)));
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c:6352: 
tx_ring->tx_buffer_info = vmalloc(size);
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c:6446: 
rx_ring->rx_buffer_info = vmalloc(size);
drivers/net/ethernet/intel/ixgbevf/ethtool.c:285:   tx_ring = 
vmalloc(array_size(sizeof(*tx_ring),
drivers/net/ethernet/intel/ixgbevf/ethtool.c:331:   rx_ring = 
vmalloc(array_size(sizeof(*rx_ring),
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c:3373: tx_ring->tx_buffer_info 
= vmalloc(size);
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c:3451: rx_ring->rx_buffer_info 
= vmalloc(size);



[PATCH] checkpatch: warn on unnecessary int declarations

2018-08-05 Thread Joe Perches
On Sun, 2018-08-05 at 08:52 -0700, Linus Torvalds wrote:
> "long unsigned int" isn't _technically_ wrong. But we normally
> call that type "unsigned long".

So add a checkpatch test for it.

Signed-off-by: Joe Perches 
---
 scripts/checkpatch.pl | 20 
 1 file changed, 20 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index ce72cc4784e6..bc6dda34394e 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3829,6 +3829,26 @@ sub process {
 "type '$tmp' should be specified in [[un]signed] 
[short|int|long|long long] order\n" . $herecurr);
}
 
+# check for unnecessary  int declarations of short/long/long long
+   while ($sline =~ 
m{\b($TypeMisordered(\s*\*)*|$C90_int_types)\b}g) {
+   my $type = trim($1);
+   next if ($type !~ /\bint\b/);
+   next if ($type !~ /\b(?:short|long\s+long|long)\b/);
+   my $new_type = $type;
+   $new_type =~ s/\b\s*int\s*\b/ /;
+   $new_type =~ s/\b\s*(?:un)?signed\b\s*/ /;
+   $new_type =~ s/^const\s+//;
+   $new_type = "unsigned $new_type" if ($type =~ 
/\bunsigned\b/);
+   $new_type = "const $new_type" if ($type =~ /^const\b/);
+   $new_type =~ s/\s+/ /g;
+   $new_type = trim($new_type);
+   if (WARN("UNNECESSARY_INT",
+"Prefer '$new_type' over '$type' as the int is 
unnecessary\n" . $herecurr) &&
+   $fix) {
+   $fixed[$fixlinenr] =~ 
s/\b\Q$type\E\b/$new_type/;
+   }
+   }
+
 # check for static const char * arrays.
if ($line =~ 
/\bstatic\s+const\s+char\s*\*\s*(\w+)\s*\[\s*\]\s*=\s*/) {
WARN("STATIC_CONST_CHAR_ARRAY",



Re: [PATCH 1/4] treewide: convert ISO_8859-1 text comments to utf-8

2018-07-25 Thread Joe Perches
On Wed, 2018-07-25 at 15:12 +0200, Arnd Bergmann wrote:
> tools/perf/tests/.gitignore:
> LLVM byte-codes, uncompressed
> On Wed, Jul 25, 2018 at 2:55 AM, Andrew Morton
>  wrote:
> > On Tue, 24 Jul 2018 17:13:20 -0700 Joe Perches  wrote:
> > 
> > > On Tue, 2018-07-24 at 14:00 -0700, Andrew Morton wrote:
> > > > On Tue, 24 Jul 2018 13:13:25 +0200 Arnd Bergmann  wrote:
> > > > > Almost all files in the kernel are either plain text or UTF-8
> > > > > encoded. A couple however are ISO_8859-1, usually just a few
> > > > > characters in a C comments, for historic reasons.
> > > > > This converts them all to UTF-8 for consistency.
> > > 
> > > []
> > > > Will we be getting a checkpatch rule to keep things this way?
> > > 
> > > How would that be done?
> > 
> > I'm using this, seems to work.
> > 
> > if ! file $p | grep -q -P ", ASCII text|, UTF-8 Unicode text"
> > then
> > echo $p: weird charset
> > fi
> 
> There are a couple of files that my version of 'find' incorrectly identified 
> as
> something completely different, like:
> 
> Documentation/devicetree/bindings/pinctrl/pinctrl-sx150x.txt:
> SemOne archive data
> Documentation/devicetree/bindings/rtc/epson,rtc7301.txt:
> Microsoft Document Imaging Format
> Documentation/filesystems/nfs/pnfs-block-server.txt:
> PPMN archive data
> arch/arm/boot/dts/bcm283x-rpi-usb-host.dtsi:
> Sendmail frozen configuration  - version = "host";
> Documentation/networking/segmentation-offloads.txt:
> StuffIt Deluxe Segment (data) : gmentation Offloads in the
> Linux Networking Stack
> arch/sparc/include/asm/visasm.h:  SAS 7+
> arch/xtensa/kernel/setup.c: ,
> init=0x454c, stat=0x090a, dev=0x2009, bas=0x2020
> drivers/cpufreq/powernow-k8.c:
> TI-XX Graphing Calculator (FLASH)
> tools/testing/selftests/net/forwarding/tc_shblocks.sh:
> Minix filesystem, V2 (big endian)
> tools/perf/tests/.gitignore:
> LLVM byte-codes, uncompressed
> 
> All of the above seem to be valid ASCII or UTF-8 files, so the check
> above will lead
> to false-positives, but it may be good enough as they are the
> exception, and may be
> bugs in 'file'.
> 
> Not sure if we need to worry about 'file' not being installed.

checkpatch works on patches so I think the test isn't
really relevant.  It has to use the appropriate email
header that sets the charset.

perhaps:
---
 scripts/checkpatch.pl | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 34e4683de7a3..57355fbd2d28 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2765,9 +2765,13 @@ sub process {
 # Check if there is UTF-8 in a commit log when a mail header has explicitly
 # declined it, i.e defined some charset where it is missing.
if ($in_header_lines &&
-   $rawline =~ /^Content-Type:.+charset="(.+)".*$/ &&
-   $1 !~ /utf-8/i) {
-   $non_utf8_charset = 1;
+   $rawline =~ /^Content-Type:.+charset="?([^\s;"]+)/) {
+   my $charset = $1;
+   $non_utf8_charset = 1 if ($charset !~ /^utf-8$/i);
+   if ($charset !~ /^(?:us-ascii|utf-8|iso-8859-1)$/) {
+   WARN("PATCH_CHARSET",
+"Unpreferred email header charset 
'$charset'\n" . $herecurr);
+   }
}
 
if ($in_commit_log && $non_utf8_charset && $realfile =~ /^$/ &&





Re: [PATCH v2 net] nfp: cast sizeof() to int when comparing with error code

2018-06-25 Thread Joe Perches
On Tue, 2018-06-26 at 09:16 +0800, Chengguang Xu wrote:
> sizeof() will return unsigned value so in the error check
> negative error code will be always larger than sizeof().
[]
> diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nffw.c 
> b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nffw.c
[]
> @@ -232,7 +232,7 @@ struct nfp_nffw_info *nfp_nffw_info_open(struct nfp_cpp 
> *cpp)
>   err = nfp_cpp_read(cpp, nfp_resource_cpp_id(state->res),
>  nfp_resource_address(state->res),
>  fwinf, sizeof(*fwinf));
> - if (err < sizeof(*fwinf))
> + if (err < (int)sizeof(*fwinf))
>   goto err_release;
>  
>   if (!nffw_res_flg_init_get(fwinf))

The way this is done in several places in the kernel is
to test first for < 0 and then test for < sizeof

if (err < 0 || err < sizeof(etc...)

see net/ceph/ceph_common.c etc...



Re: [PATCH 3/4] net/ncsi: Use netdev_dbg for debug messages

2018-06-18 Thread Joe Perches
On Mon, 2018-06-18 at 16:49 +0930, Joel Stanley wrote:
> This moves all of the netdev_printk(KERN_DEBUG, ...) messages over to
> netdev_dbg. There is no change in behaviour.

Not quite, but I think the patch is fine anyway.

netdev_printk(KERN_DEBUG ... is always emitted as
long as the console level includes debug output.

netdev_dbg is not included in object code unless
DEBUG is defined or CONFIG_DYNAMIC_DEBUG is set.
And then, it is not emitted into the log unless
DEBUG is set or this specific netdev_dbg is enabled
via the dynamic debug control file.

> Signed-off-by: Joel Stanley 
> ---
>  net/ncsi/ncsi-aen.c|  6 +++---
>  net/ncsi/ncsi-manage.c | 33 +++--
>  2 files changed, 18 insertions(+), 21 deletions(-)
> 
> diff --git a/net/ncsi/ncsi-aen.c b/net/ncsi/ncsi-aen.c
> index f899ed61bb57..25e483e8278b 100644
> --- a/net/ncsi/ncsi-aen.c
> +++ b/net/ncsi/ncsi-aen.c
> @@ -148,9 +148,9 @@ static int ncsi_aen_handler_hncdsc(struct ncsi_dev_priv 
> *ndp,
>   hncdsc = (struct ncsi_aen_hncdsc_pkt *)h;
>   ncm->data[3] = ntohl(hncdsc->status);
>   spin_unlock_irqrestore(>lock, flags);
> - netdev_printk(KERN_DEBUG, ndp->ndev.dev,
> -   "NCSI: host driver %srunning on channel %u\n",
> -   ncm->data[3] & 0x1 ? "" : "not ", nc->id);
> + netdev_dbg(ndp->ndev.dev,
> +"NCSI: host driver %srunning on channel %u\n",
> +ncm->data[3] & 0x1 ? "" : "not ", nc->id);
>  
>   return 0;
>  }
> diff --git a/net/ncsi/ncsi-manage.c b/net/ncsi/ncsi-manage.c
> index 716493a61ba6..091284760d21 100644
> --- a/net/ncsi/ncsi-manage.c
> +++ b/net/ncsi/ncsi-manage.c
> @@ -788,8 +788,8 @@ static void ncsi_configure_channel(struct ncsi_dev_priv 
> *ndp)
>   }
>   break;
>   case ncsi_dev_state_config_done:
> - netdev_printk(KERN_DEBUG, ndp->ndev.dev,
> -   "NCSI: channel %u config done\n", nc->id);
> + netdev_dbg(ndp->ndev.dev, "NCSI: channel %u config done\n",
> +nc->id);
>   spin_lock_irqsave(>lock, flags);
>   if (nc->reconfigure_needed) {
>   /* This channel's configuration has been updated
> @@ -804,8 +804,7 @@ static void ncsi_configure_channel(struct ncsi_dev_priv 
> *ndp)
>   list_add_tail_rcu(>link, >channel_queue);
>   spin_unlock_irqrestore(>lock, flags);
>  
> - netdev_printk(KERN_DEBUG, dev,
> -   "Dirty NCSI channel state reset\n");
> + netdev_dbg(dev, "Dirty NCSI channel state reset\n");
>   ncsi_process_next_channel(ndp);
>   break;
>   }
> @@ -908,9 +907,9 @@ static int ncsi_choose_active_channel(struct 
> ncsi_dev_priv *ndp)
>   }
>  
>   ncm = >modes[NCSI_MODE_LINK];
> - netdev_printk(KERN_DEBUG, ndp->ndev.dev,
> -   "NCSI: Channel %u added to queue (link %s)\n",
> -   found->id, ncm->data[2] & 0x1 ? "up" : "down");
> + netdev_dbg(ndp->ndev.dev,
> +"NCSI: Channel %u added to queue (link %s)\n",
> +found->id, ncm->data[2] & 0x1 ? "up" : "down");
>  
>  out:
>   spin_lock_irqsave(>lock, flags);
> @@ -1316,9 +1315,9 @@ static int ncsi_kick_channels(struct ncsi_dev_priv *ndp)
>   if ((ndp->ndev.state & 0xff00) ==
>   ncsi_dev_state_config ||
>   !list_empty(>link)) {
> - netdev_printk(KERN_DEBUG, nd->dev,
> -   "NCSI: channel %p marked 
> dirty\n",
> -   nc);
> + netdev_dbg(nd->dev,
> +"NCSI: channel %p marked 
> dirty\n",
> +nc);
>   nc->reconfigure_needed = true;
>   }
>   spin_unlock_irqrestore(>lock, flags);
> @@ -1336,8 +1335,7 @@ static int ncsi_kick_channels(struct ncsi_dev_priv *ndp)
>   list_add_tail_rcu(>link, >channel_queue);
>   spin_unlock_irqrestore(>lock, flags);
>  
> - netdev_printk(KERN_DEBUG, nd->dev,
> -   "NCSI: kicked channel %p\n", nc);
> + netdev_dbg(nd->dev, "NCSI: kicked channel %p\n", nc);
>   n++;
>   }
>   }
> @@ -1368,8 +1366,8 @@ int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 
> proto, u16 vid)
>   list_for_each_entry_rcu(vlan, >vlan_vids, list) {
>   n_vids++;
>   if (vlan->vid == vid) {
> - netdev_printk(KERN_DEBUG, dev,
> -   

Re: [PATCH 1/4] net/ncsi: Silence debug messages

2018-06-18 Thread Joe Perches
On Mon, 2018-06-18 at 16:49 +0930, Joel Stanley wrote:
> In normal operation we see this series of messages as the host drives
> the network device:
> 
>  ftgmac100 1e66.ethernet eth0: NCSI: LSC AEN - channel 0 state down
>  ftgmac100 1e66.ethernet eth0: NCSI: suspending channel 0
[...]
> This makes all of these messages netdev_dbg. They are still useful to
> debug eg. misbehaving network device firmware, but we do not need them
> filling up the kernel logs in normal operation.

trivia:

> diff --git a/drivers/net/ethernet/faraday/ftgmac100.c 
> b/drivers/net/ethernet/faraday/ftgmac100.c
[]
> @@ -1735,7 +1735,7 @@ static void ftgmac100_ncsi_handler(struct ncsi_dev *nd)
>   if (unlikely(nd->state != ncsi_dev_state_functional))
>   return;
>  
> - netdev_info(nd->dev, "NCSI interface %s\n",
> + netdev_dbg(nd->dev, "NCSI interface %s\n",
>   nd->link_up ? "up" : "down");

It's nicer to realign the multiple line statements
to the open parenthesis

> diff --git a/net/ncsi/ncsi-aen.c b/net/ncsi/ncsi-aen.c
[]
> @@ -73,8 +73,8 @@ static int ncsi_aen_handler_lsc(struct ncsi_dev_priv *ndp,
>   ncm->data[2] = data;
>   ncm->data[4] = ntohl(lsc->oem_status);
>  
> - netdev_info(ndp->ndev.dev, "NCSI: LSC AEN - channel %u state %s\n",
> - nc->id, data & 0x1 ? "up" : "down");
> + netdev_dbg(ndp->ndev.dev, "NCSI: LSC AEN - channel %u state %s\n",
> +nc->id, data & 0x1 ? "up" : "down");

as was done for the rest of these...




[PATCH] drivers/net: Fix various unnecessary characters after logging newlines

2018-05-28 Thread Joe Perches
Remove and coalesce formats when there is an unnecessary
character after a logging newline.  These extra characters
cause logging defects.

Miscellanea:

o Coalesce formats

Signed-off-by: Joe Perches 
---
 drivers/net/ethernet/cavium/liquidio/lio_main.c | 2 +-
 drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c | 6 ++
 drivers/net/ethernet/qlogic/qed/qed_dev.c   | 2 +-
 drivers/net/ethernet/qlogic/qlge/qlge_main.c| 4 ++--
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 2 +-
 drivers/net/wireless/intel/ipw2x00/ipw2200.c| 3 +--
 drivers/net/wireless/intersil/prism54/islpci_eth.c  | 6 +++---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c  | 4 ++--
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c  | 4 ++--
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c   | 4 ++--
 drivers/net/wireless/realtek/rtlwifi/rtl8821ae/dm.c | 2 +-
 11 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index e500528ad751..8a815bb57177 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -1766,7 +1766,7 @@ static int load_firmware(struct octeon_device *oct)
 
ret = request_firmware(, fw_name, >pci_dev->dev);
if (ret) {
-   dev_err(>pci_dev->dev, "Request firmware failed. Could not 
find file %s.\n.",
+   dev_err(>pci_dev->dev, "Request firmware failed. Could not 
find file %s.\n",
fw_name);
release_firmware(fw);
return ret;
diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c 
b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c
index 6cec2a6a3dcc..7503aa222392 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c
@@ -146,8 +146,7 @@ netxen_get_minidump_template(struct netxen_adapter *adapter)
if ((cmd.rsp.cmd == NX_RCODE_SUCCESS) && (size == cmd.rsp.arg2)) {
memcpy(adapter->mdump.md_template, addr, size);
} else {
-   dev_err(>pdev->dev, "Failed to get minidump template, "
-   "err_code : %d, requested_size : %d, actual_size : %d\n 
",
+   dev_err(>pdev->dev, "Failed to get minidump template, 
err_code : %d, requested_size : %d, actual_size : %d\n",
cmd.rsp.cmd, size, cmd.rsp.arg2);
}
pci_free_consistent(adapter->pdev, size, addr, md_template_addr);
@@ -180,8 +179,7 @@ netxen_setup_minidump(struct netxen_adapter *adapter)
if ((err == NX_RCODE_CMD_INVALID) ||
(err == NX_RCODE_CMD_NOT_IMPL)) {
dev_info(>pdev->dev,
-   "Flashed firmware version does not support 
minidump, "
-   "minimum version required is [ %u.%u.%u ].\n ",
+   "Flashed firmware version does not support 
minidump, minimum version required is [ %u.%u.%u ]\n",
NX_MD_SUPPORT_MAJOR, NX_MD_SUPPORT_MINOR,
NX_MD_SUPPORT_SUBVERSION);
}
diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c 
b/drivers/net/ethernet/qlogic/qed/qed_dev.c
index 560528962658..fde20fd9942c 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_dev.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c
@@ -1098,7 +1098,7 @@ int qed_final_cleanup(struct qed_hwfn *p_hwfn,
}
 
DP_VERBOSE(p_hwfn, QED_MSG_IOV,
-  "Sending final cleanup for PFVF[%d] [Command %08x\n]",
+  "Sending final cleanup for PFVF[%d] [Command %08x]\n",
   id, command);
 
qed_wr(p_hwfn, p_ptt, XSDM_REG_OPERATION_GEN, command);
diff --git a/drivers/net/ethernet/qlogic/qlge/qlge_main.c 
b/drivers/net/ethernet/qlogic/qlge/qlge_main.c
index 8293c2028002..70de062b72a1 100644
--- a/drivers/net/ethernet/qlogic/qlge/qlge_main.c
+++ b/drivers/net/ethernet/qlogic/qlge/qlge_main.c
@@ -2211,7 +2211,7 @@ static int ql_clean_outbound_rx_ring(struct rx_ring 
*rx_ring)
while (prod != rx_ring->cnsmr_idx) {
 
netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev,
-"cq_id = %d, prod = %d, cnsmr = %d.\n.",
+"cq_id = %d, prod = %d, cnsmr = %d\n",
 rx_ring->cq_id, prod, rx_ring->cnsmr_idx);
 
net_rsp = (struct ob_mac_iocb_rsp *)rx_ring->curr_entry;
@@ -2258,7 +2258,7 @@ static int ql_clean_inbound_rx_ring(struct rx_ring 
*rx_ring, int budget

Re: [PATCH 2/8] batman-adv: Disable CONFIG_BATMAN_ADV_DEBUGFS by default

2018-05-25 Thread Joe Perches
On Fri, 2018-05-25 at 14:13 +0300, Sergei Shtylyov wrote:
> On 5/25/2018 1:50 PM, Sven Eckelmann wrote:
> 
> > [...]
> > > > --- a/net/batman-adv/Kconfig
> > > > +++ b/net/batman-adv/Kconfig
> > > > @@ -94,13 +94,13 @@ config BATMAN_ADV_DEBUGFS
> > > > bool "batman-adv debugfs entries"
> > > > depends on BATMAN_ADV
> > > > depends on DEBUG_FS
> > > > -   default y
> > > > +   default n
> > > 
> > >  N is the default default. :-) You don't need this line.
> > 
> > Hm, looks like this would have to be changed in a lot of places (~782
> > according to `git grep 'default n$'|wc -l` in my slightly outdated linux-
> > next). Do you want to fix it everywhere?
> 
> No, but we can at least not add the new ones...
> 
> > Might be good to get this integrated
> > in checkpatch.pl when this will become a new policy.
> 
> Adding Joe Perches. Joe, can you add a check for "default n"?

OK.

This also improves the Kconfig boolean->bool test above
as it's broken for multiple section Kconfig files with
help texts.
---
 scripts/checkpatch.pl | 19 ---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index baddac9379f0..1f980be4950b 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2888,9 +2888,22 @@ sub process {
 
 # discourage the use of boolean for type definition attributes of Kconfig 
options
if ($realfile =~ /Kconfig/ &&
-   $line =~ /^\+\s*\bboolean\b/) {
-   WARN("CONFIG_TYPE_BOOLEAN",
-"Use of boolean is deprecated, please use bool 
instead.\n" . $herecurr);
+   $rawline =~ /^\+\s*\bboolean\b/) {
+   if (WARN("CONFIG_TYPE_BOOLEAN",
+"Use of boolean is deprecated, please use bool 
instead.\n" . $herecurr) &&
+   $fix) {
+   $fixed[$fixlinenr] =~ s/\bboolean\b/bool/;
+   }
+   }
+
+# discourage the use of 'default n' in Kconfig files as that's the default
+   if ($realfile =~ /Kconfig/ &&
+   $rawline =~ /^\+\s*default\s+n\s*$/) {
+   if (WARN("CONFIG_DEFAULT_N",
+"Unnecessary Use of 'default n'\n" . 
$herecurr) &&
+   $fix) {
+   fix_delete_line($fixlinenr, $rawline);
+   }
}
 
if (($realfile =~ /Makefile.*/ || $realfile =~ /Kbuild.*/) &&



Re: [PATCH] rtlwifi: remove duplicate code

2018-05-24 Thread Joe Perches
On Thu, 2018-05-24 at 13:54 -0500, Gustavo A. R. Silva wrote:
> Remove and refactor some code in order to avoid having identical code
> for different branches.

True and nice tool and patch submittal thanks.

> Notice that the logic has been there since 2014.

But perhaps the original logic is a defective copy/paste
and it should be corrected instead.

Can anyone from realtek verify this?

> Addresses-Coverity-ID: 1426199 ("Identical code for different branches")
> Signed-off-by: Gustavo A. R. Silva 
> ---
>  .../realtek/rtlwifi/btcoexist/halbtc8723b2ant.c| 23 
> --
>  1 file changed, 4 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c 
> b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
> index 279fe01..df3facc 100644
> --- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
> +++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
> @@ -2876,25 +2876,10 @@ static void btc8723b2ant_action_hid(struct 
> btc_coexist *btcoexist)
>   btc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 13);
>  
>   /* sw mechanism */
> - if (BTC_WIFI_BW_HT40 == wifi_bw) {
> - if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
> - (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
> - btc8723b2ant_sw_mechanism(btcoexist, true, true,
> -   false, false);
> - } else {
> - btc8723b2ant_sw_mechanism(btcoexist, true, true,
> -   false, false);
> - }
> - } else {
> - if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
> - (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
> - btc8723b2ant_sw_mechanism(btcoexist, false, true,
> -   false, false);
> - } else {
> - btc8723b2ant_sw_mechanism(btcoexist, false, true,
> -   false, false);
> - }
> - }
> + if (wifi_bw == BTC_WIFI_BW_HT40)
> + btc8723b2ant_sw_mechanism(btcoexist, true, true, false, false);
> + else
> + btc8723b2ant_sw_mechanism(btcoexist, false, true, false, false);
>  }
>  
>  /* A2DP only / PAN(EDR) only/ A2DP+PAN(HS) */


Re: [PATCH 8/8] batman-adv: enable B.A.T.M.A.N. V compilation by default

2018-05-24 Thread Joe Perches
On Thu, 2018-05-24 at 14:03 +0200, Simon Wunderlich wrote:
> From: Marek Lindner 
> 
> Signed-off-by: Marek Lindner 
> Acked-by: Antonio Quartulli 
> Signed-off-by: Sven Eckelmann 
> Signed-off-by: Simon Wunderlich 
> ---
>  net/batman-adv/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/batman-adv/Kconfig b/net/batman-adv/Kconfig
> index bee034a95208..de8034d80623 100644
> --- a/net/batman-adv/Kconfig
> +++ b/net/batman-adv/Kconfig
> @@ -35,7 +35,7 @@ config BATMAN_ADV
>  config BATMAN_ADV_BATMAN_V
>   bool "B.A.T.M.A.N. V protocol (experimental)"
>   depends on BATMAN_ADV && !(CFG80211=m && BATMAN_ADV=y)
> - default n
> + default y

Why should anything experimental be enabled by default?

>   help
> This option enables the B.A.T.M.A.N. V protocol, the successor
> of the currently used B.A.T.M.A.N. IV protocol. The main


Re: [PATCH bpf-next] bpf: btf: Avoid variable length array

2018-05-23 Thread Joe Perches
On Wed, 2018-05-23 at 10:46 -0700, Martin KaFai Lau wrote:
> Sparse warning:
> kernel/bpf/btf.c:1985:34: warning: Variable length array is used.

Perhaps use ARRAY_SIZE directly instead of indirectly via a #define

> diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
[]
> @@ -1970,6 +1970,8 @@ static const size_t btf_sec_info_offset[] = {
>   offsetof(struct btf_header, str_off),
>  };
>  
> +#define NR_SECS ARRAY_SIZE(btf_sec_info_offset)
> +
>  static int btf_sec_info_cmp(const void *a, const void *b)
>  {
>   const struct btf_sec_info *x = a;
> @@ -1981,8 +1983,7 @@ static int btf_sec_info_cmp(const void *a, const void 
> *b)
>  static int btf_check_sec_info(struct btf_verifier_env *env,
> u32 btf_data_size)
>  {
> - const unsigned int nr_secs = ARRAY_SIZE(btf_sec_info_offset);
> - struct btf_sec_info secs[nr_secs];
> + struct btf_sec_info secs[NR_SECS];

struct btf_sec_info secs[ARRAY_SIZE(btf_sec_info_offset)];

>   u32 total, expected_total, i;
>   const struct btf_header *hdr;
>   const struct btf *btf;
> @@ -1991,17 +1992,17 @@ static int btf_check_sec_info(struct btf_verifier_env 
> *env,
>   hdr = >hdr;
>  
>   /* Populate the secs from hdr */
> - for (i = 0; i < nr_secs; i++)
> + for (i = 0; i < NR_SECS; i++)

for (i = 0; i < ARRAY_SIZE(btf_sec_info_offset); i++)

>   secs[i] = *(struct btf_sec_info *)((void *)hdr +
>  btf_sec_info_offset[i]);

which makes this loop more intelligible.

> - sort(secs, nr_secs, sizeof(struct btf_sec_info),
> + sort(secs, NR_SECS, sizeof(struct btf_sec_info),
>btf_sec_info_cmp, NULL);

etc...



Re: [PATCH net-next ] net: mscc: Add SPDX identifier

2018-05-18 Thread Joe Perches
On Fri, 2018-05-18 at 09:52 +0200, Alexandre Belloni wrote:
> On 17/05/2018 18:13:25-0700, Joe Perches wrote:
> > On Thu, 2018-05-17 at 21:39 +0200, Alexandre Belloni wrote:
> > > On 17/05/2018 12:28:59-0700, Joe Perches wrote:
> > > > On Thu, 2018-05-17 at 21:23 +0200, Alexandre Belloni wrote:
> > > > > ocelot_qsys.h is missing the SPDX identfier, fix that.
> > > > > 
> > > > > Signed-off-by: Alexandre Belloni <alexandre.bell...@bootlin.com>
> > > > 
> > > > Only the copyright holders should ideally be modifying
> > > > these and also removing other license content.
> > > > 
> > > > For instance, what's the real intent here?
> > > > 
> > > 
> > > Well, if you have a look, I submitted that file this cycle and it is the
> > > only one that doesn't have the proper SPDX identifier. This is a mistake
> > > I'm fixing.
> > 
> > Just because you submitted it does not mean you
> > are the copyright holder.
> > 
> > > > > diff --git a/drivers/net/ethernet/mscc/ocelot_qsys.h 
> > > > > b/drivers/net/ethernet/mscc/ocelot_qsys.h
> > > > 
> > > > []
> > > > > @@ -1,7 +1,7 @@
> > > > > +/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
> > > > 
> > > > GPL 2.0+ or 2.0?
> > > > 
> > > 
> > > 2.0
> > 
> > How do you know that?
> > 
> 
> The fact is that it should have been submitted with the SPDX identifier
> to be consistent with the rest of the driver. If you can't trust me on
> that, then, you can't probably trust anyone submitting anything new
> driver to the kernel.

Silly.

> I still don't understand why you are making an issue out of this.

Correctness in licensing text is important.

> Because my email address doesn't match the copyright holder's name
> doesn't mean I'm not allowed to fix my own mistake.

Mostly, it's a question of what the original
license is.  As far as I can tell, microsemi
publishes their code only under an MIT license.

The MIT license does allow sublicensing, so
it does seem you can choose what additional
license restrictions you can assert as long
as the original MIT license is also followed.

cheers, Joe




Re: [PATCH net-next ] net: mscc: Add SPDX identifier

2018-05-17 Thread Joe Perches
On Thu, 2018-05-17 at 21:39 +0200, Alexandre Belloni wrote:
> On 17/05/2018 12:28:59-0700, Joe Perches wrote:
> > On Thu, 2018-05-17 at 21:23 +0200, Alexandre Belloni wrote:
> > > ocelot_qsys.h is missing the SPDX identfier, fix that.
> > > 
> > > Signed-off-by: Alexandre Belloni <alexandre.bell...@bootlin.com>
> > 
> > Only the copyright holders should ideally be modifying
> > these and also removing other license content.
> > 
> > For instance, what's the real intent here?
> > 
> 
> Well, if you have a look, I submitted that file this cycle and it is the
> only one that doesn't have the proper SPDX identifier. This is a mistake
> I'm fixing.

Just because you submitted it does not mean you
are the copyright holder.

> > > diff --git a/drivers/net/ethernet/mscc/ocelot_qsys.h 
> > > b/drivers/net/ethernet/mscc/ocelot_qsys.h
> > 
> > []
> > > @@ -1,7 +1,7 @@
> > > +/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
> > 
> > GPL 2.0+ or 2.0?
> > 
> 
> 2.0

How do you know that?



Re: [PATCH net-next ] net: mscc: Add SPDX identifier

2018-05-17 Thread Joe Perches
On Thu, 2018-05-17 at 21:23 +0200, Alexandre Belloni wrote:
> ocelot_qsys.h is missing the SPDX identfier, fix that.
> 
> Signed-off-by: Alexandre Belloni 

Only the copyright holders should ideally be modifying
these and also removing other license content.

For instance, what's the real intent here?

> diff --git a/drivers/net/ethernet/mscc/ocelot_qsys.h 
> b/drivers/net/ethernet/mscc/ocelot_qsys.h
[]
> @@ -1,7 +1,7 @@
> +/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */

GPL 2.0+ or 2.0?

>  /*
>   * Microsemi Ocelot Switch driver
>   *
> - * License: Dual MIT/GPL
>   * Copyright (c) 2017 Microsemi Corporation
>   */
>  


Re: [resend PATCH] rxrpc: Neaten logging macros and add KERN_DEBUG logging level

2018-05-11 Thread Joe Perches
On Tue, 2018-03-27 at 11:52 -0700, Joe Perches wrote:
> When enabled, the current debug logging does not have a KERN_.
> Add KERN_DEBUG to the logging macros.
> 
> Miscellanea:
> 
> o Remove #define redundancy and neaten the macros a bit

ping?

> Signed-off-by: Joe Perches <j...@perches.com>
> ---
> 
> Resend of patch: https://lkml.org/lkml/2017/11/30/573
> 
> No change in patch.
> 
> David Howells is now a listed maintainer for net/rxrpc/ so he should receive
> this patch via get_maintainer
> 
>  net/rxrpc/ar-internal.h | 75 
> ++---
>  1 file changed, 28 insertions(+), 47 deletions(-)
> 
> diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
> index 416688381eb7..d4b53b2339b3 100644
> --- a/net/rxrpc/ar-internal.h
> +++ b/net/rxrpc/ar-internal.h
> @@ -1147,66 +1147,47 @@ static inline bool after_eq(u32 seq1, u32 seq2)
>   */
>  extern unsigned int rxrpc_debug;
>  
> -#define dbgprintk(FMT,...) \
> - printk("[%-6.6s] "FMT"\n", current->comm ,##__VA_ARGS__)
> +#if defined(__KDEBUG) || defined(CONFIG_AF_RXRPC_DEBUG)
> +#define dbgprintk(fmt, ...)  \
> + printk(KERN_DEBUG "[%-6.6s] " fmt "\n", current->comm, ##__VA_ARGS__)
> +#else
> +#define dbgprintk(fmt, ...)  \
> + no_printk(KERN_DEBUG "[%-6.6s] " fmt "\n", current->comm, ##__VA_ARGS__)
> +#endif
>  
> -#define kenter(FMT,...)  dbgprintk("==> %s("FMT")",__func__ 
> ,##__VA_ARGS__)
> -#define kleave(FMT,...)  dbgprintk("<== %s()"FMT"",__func__ 
> ,##__VA_ARGS__)
> -#define kdebug(FMT,...)  dbgprintk(""FMT ,##__VA_ARGS__)
> -#define kproto(FMT,...)  dbgprintk("### "FMT ,##__VA_ARGS__)
> -#define knet(FMT,...)dbgprintk("@@@ "FMT ,##__VA_ARGS__)
> +#define kenter(fmt, ...) dbgprintk("==> %s(" fmt ")", __func__, 
> ##__VA_ARGS__)
> +#define kleave(fmt, ...) dbgprintk("<== %s()" fmt "", __func__, 
> ##__VA_ARGS__)
> +#define kdebug(fmt, ...) dbgprintk("" fmt, ##__VA_ARGS__)
> +#define kproto(fmt, ...) dbgprintk("### " fmt, ##__VA_ARGS__)
> +#define knet(fmt, ...)   dbgprintk("@@@ " fmt, ##__VA_ARGS__)
>  
> +#if defined(__KDEBUG) || !defined(CONFIG_AF_RXRPC_DEBUG)
> +#define _enter(fmt, ...) kenter(fmt, ##__VA_ARGS__)
> +#define _leave(fmt, ...) kleave(fmt, ##__VA_ARGS__)
> +#define _debug(fmt, ...) kdebug(fmt, ##__VA_ARGS__)
> +#define _proto(fmt, ...) kproto(fmt, ##__VA_ARGS__)
> +#define _net(fmt, ...)   knet(fmt, ##__VA_ARGS__)
>  
> -#if defined(__KDEBUG)
> -#define _enter(FMT,...)  kenter(FMT,##__VA_ARGS__)
> -#define _leave(FMT,...)  kleave(FMT,##__VA_ARGS__)
> -#define _debug(FMT,...)  kdebug(FMT,##__VA_ARGS__)
> -#define _proto(FMT,...)  kproto(FMT,##__VA_ARGS__)
> -#define _net(FMT,...)knet(FMT,##__VA_ARGS__)
> +#else
>  
> -#elif defined(CONFIG_AF_RXRPC_DEBUG)
>  #define RXRPC_DEBUG_KENTER   0x01
>  #define RXRPC_DEBUG_KLEAVE   0x02
>  #define RXRPC_DEBUG_KDEBUG   0x04
>  #define RXRPC_DEBUG_KPROTO   0x08
>  #define RXRPC_DEBUG_KNET 0x10
>  
> -#define _enter(FMT,...)  \
> -do { \
> - if (unlikely(rxrpc_debug & RXRPC_DEBUG_KENTER)) \
> - kenter(FMT,##__VA_ARGS__);  \
> -} while (0)
> -
> -#define _leave(FMT,...)  \
> -do { \
> - if (unlikely(rxrpc_debug & RXRPC_DEBUG_KLEAVE)) \
> - kleave(FMT,##__VA_ARGS__);  \
> -} while (0)
> -
> -#define _debug(FMT,...)  \
> -do { \
> - if (unlikely(rxrpc_debug & RXRPC_DEBUG_KDEBUG)) \
> - kdebug(FMT,##__VA_ARGS__);  \
> -} while (0)
> -
> -#define _proto(FMT,...)  \
> -do { \
> - if (unlikely(rxrpc_debug & RXRPC_DEBUG_KPROTO)) \
> - kproto(FMT,##__VA_ARGS__);  \
> +#define RXRPC_DEBUG(TYPE, type, fmt, ...)\
> +do { \
> + if (unlikely(rxrpc_debug & RXRPC_DEBUG_##TYPE)) \
> + type(fmt, ##__VA_ARGS__);   \
>  } while (0)
>

[PATCH 00/18] Convert default pr_fmt from empty to KBUILD_MODNAME

2018-05-10 Thread Joe Perches
pr_ logging uses allow a prefix to be specified with a
specific #define pr_fmt

The default of pr_fmt in printk.h is #define pr_fmt(fmt) fmt
so no prefixing of logging output is generically done.

There are several output logging uses like dump_stack() that are
unprefixed and should remain unprefixed.

This patch series attempts to convert the default #define of pr_fmt to
KBUILD_MODNAME ": " fmt and as well update the various bits of the kernel
that should _not_ be prefixed by adding #define pr_fmt(fmt) fmt to those
compilation units that do not want output message prefixing.

There are about 1200 uses of #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
that could be removed if the default is changed.

A script that does this removal (and removes any blank lines that follow)
for the linux-kernel tree is included below:

$ git grep -P --name-only "define\s+pr_fmt\b" | \
  grep -v include/linux/printk.h | \
  xargs perl -i -e 'local $/; while (<>) {s/(\n)*[ \t]*#[ \t]*define[ 
\t]+pr_fmt[ \t]*\([ \t]*(\w+)[ \t]*\)[ \t]*KBUILD_MODNAME[ \t]*\": \"[ \t]*\2[ 
\t]*\n\s*/\1\n/; s/^\n//; print;}'

This script should be run after this patch series is applied.

The above script output diff is currently:

1198 files changed, 70 insertions(+), 2241 deletions(-)

Joe Perches (18):
  kernel: Use pr_fmt
  lib: Use pr_fmt
  printk: Convert pr_fmt from blank define to KBUILD_MODNAME
  x86: Remove pr_fmt duplicate logging prefixes
  x86/mtrr: Rename main.c to mtrr.c and remove duplicate prefixes
  net: Remove pr_fmt duplicate logging prefixes
  blk-mq: Remove pr_fmt duplicate logging prefixes
  random: Remove pr_fmt duplicate logging prefixes
  ptp: Remove pr_fmt duplicate logging prefixes
  efifb: Remove pr_fmt duplicate logging prefixes
  proc: Remove pr_fmt duplicate logging prefixes
  uprobes: Remove pr_fmt duplicate logging prefixes
  printk: Remove pr_fmt duplicate logging prefixes
  lib/mpi: Remove pr_fmt duplicate logging prefixes
  security: Remove pr_fmt duplicate logging prefixes
  aoe: Remove pr_fmt duplicate logging prefixes
  security: encrypted-keys: Remove pr_fmt duplicate logging prefixes
  rcu: Use pr_fmt to prefix "rcu: " to logging output

 arch/x86/events/amd/ibs.c  |  2 +-
 arch/x86/kernel/cpu/mtrr/Makefile  |  2 +-
 arch/x86/kernel/cpu/mtrr/{main.c => mtrr.c}| 33 ++---
 arch/x86/kernel/e820.c | 32 ++--
 arch/x86/kernel/hpet.c |  5 +-
 arch/x86/kernel/uprobes.c  |  4 +-
 arch/x86/mm/numa.c | 22 -
 block/blk-mq.c |  9 ++--
 drivers/block/aoe/aoeblk.c | 29 ++-
 drivers/block/aoe/aoechr.c | 11 ++---
 drivers/block/aoe/aoecmd.c | 34 ++---
 drivers/block/aoe/aoedev.c | 19 +++-
 drivers/block/aoe/aoemain.c|  6 +--
 drivers/block/aoe/aoenet.c | 19 +++-
 drivers/char/hw_random/via-rng.c   | 10 ++--
 drivers/char/random.c  | 16 +++---
 drivers/ptp/ptp_clock.c|  4 +-
 drivers/video/fbdev/efifb.c| 48 +-
 fs/proc/root.c |  6 +--
 include/linux/printk.h |  2 +-
 kernel/acct.c  |  2 +
 kernel/async.c | 14 +++---
 kernel/audit_tree.c|  2 +-
 kernel/backtracetest.c |  8 +--
 kernel/crash_core.c| 29 ++-
 kernel/events/uprobes.c|  3 +-
 kernel/exit.c  |  2 +
 kernel/hung_task.c | 13 +++--
 kernel/kprobes.c   | 20 +---
 kernel/module.c| 59 +++
 kernel/panic.c |  3 ++
 kernel/params.c| 13 +++--
 kernel/pid.c   |  2 +
 kernel/printk/printk.c |  2 +-
 kernel/profile.c   |  2 +
 kernel/range.c |  2 +-
 kernel/rcu/rcu_segcblist.c |  2 +
 kernel/rcu/rcuperf.c   | 10 ++--
 kernel/rcu/rcutorture.c| 46 +-
 kernel/rcu/srcutiny.c  |  2 +
 kernel/rcu/srcutree.c  |  5 +-
 kernel/rcu/tiny.c  |  3 ++
 kernel/rcu/tree.c  |  8 +--
 kernel/rcu/tree_plugin.h   | 67 +++---
 kernel/rcu/update.c| 19 +---
 kernel/relay.c |  5 +-
 ker

[PATCH 02/18] lib: Use pr_fmt

2018-05-10 Thread Joe Perches
Sometime in the future, it would be useful to convert pr_fmt from a
default simple define to use a default prefix with KBUILD_MODNAME.

There are files in lib/ that use pr_, some with an embedded
prefix, that also do not have a specific pr_fmt define.

Add pr_fmt for those files.

There are some differences in output as some logging output now is
prefixed with the appropriate KBUILD_MODNAME.

Miscellanea:

o Simplify debugging macros to only require a single function definition
  by moving #define DEBUG into the definition and removing the empty
  function definition
o Function alignment neatening
o Use %s, __func__ instead of embedding function names as strings
o Add missing newline terminations

Signed-off-by: Joe Perches <j...@perches.com>
---
 lib/cpu_rmap.c   | 15 +---
 lib/crc32test.c  |  2 ++
 lib/earlycpio.c  |  5 ++--
 lib/find_bit_benchmark.c |  2 ++
 lib/kobject.c| 36 ++--
 lib/kobject_uevent.c | 27 ++---
 lib/nmi_backtrace.c  |  3 +++
 lib/percpu_ida.c |  4 +++-
 lib/percpu_test.c|  2 ++
 lib/random32.c   | 10 
 lib/stmp_device.c|  2 ++
 lib/string.c |  2 ++
 lib/swiotlb.c|  4 +++-
 lib/test_debug_virtual.c |  2 ++
 lib/test_rhashtable.c| 44 ++
 lib/test_sort.c  |  2 ++
 lib/ubsan.c  | 61 
 17 files changed, 122 insertions(+), 101 deletions(-)

diff --git a/lib/cpu_rmap.c b/lib/cpu_rmap.c
index f610b2a10b3e..2d7204928c60 100644
--- a/lib/cpu_rmap.c
+++ b/lib/cpu_rmap.c
@@ -7,6 +7,8 @@
  * by the Free Software Foundation, incorporated herein by reference.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include 
 #include 
 #include 
@@ -110,26 +112,21 @@ static bool cpu_rmap_copy_neigh(struct cpu_rmap *rmap, 
unsigned int cpu,
return false;
 }
 
-#ifdef DEBUG
 static void debug_print_rmap(const struct cpu_rmap *rmap, const char *prefix)
 {
+#ifdef DEBUG
unsigned index;
unsigned int cpu;
 
-   pr_info("cpu_rmap %p, %s:\n", rmap, prefix);
+   pr_info("%p, %s:\n", rmap, prefix);
 
for_each_possible_cpu(cpu) {
index = rmap->near[cpu].index;
pr_info("cpu %d -> obj %u (distance %u)\n",
cpu, index, rmap->near[cpu].dist);
}
-}
-#else
-static inline void
-debug_print_rmap(const struct cpu_rmap *rmap, const char *prefix)
-{
-}
 #endif
+}
 
 /**
  * cpu_rmap_add - add object to a rmap
@@ -258,7 +255,7 @@ irq_cpu_rmap_notify(struct irq_affinity_notify *notify, 
const cpumask_t *mask)
 
rc = cpu_rmap_update(glue->rmap, glue->index, mask);
if (rc)
-   pr_warning("irq_cpu_rmap_notify: update failed: %d\n", rc);
+   pr_warn("%s: update failed: %d\n", __func__, rc);
 }
 
 /**
diff --git a/lib/crc32test.c b/lib/crc32test.c
index 97d6a57cefcc..63bb08ccb6f3 100644
--- a/lib/crc32test.c
+++ b/lib/crc32test.c
@@ -24,6 +24,8 @@
  * Version 2.  See the file COPYING for more details.
  */
 
+#define pr_fmt(fmt) fmt
+
 #include 
 #include 
 #include 
diff --git a/lib/earlycpio.c b/lib/earlycpio.c
index db283ba4d2c1..e98816b13719 100644
--- a/lib/earlycpio.c
+++ b/lib/earlycpio.c
@@ -130,9 +130,8 @@ struct cpio_data find_cpio_data(const char *path, void 
*data,
*nextoff = (long)nptr - (long)data;
 
if (ch[C_NAMESIZE] - mypathsize >= MAX_CPIO_FILE_NAME) {
-   pr_warn(
-   "File %s exceeding MAX_CPIO_FILE_NAME [%d]\n",
-   p, MAX_CPIO_FILE_NAME);
+   pr_warn("File %s exceeding MAX_CPIO_FILE_NAME 
[%d]\n",
+   p, MAX_CPIO_FILE_NAME);
}
strlcpy(cd.name, p + mypathsize, MAX_CPIO_FILE_NAME);
 
diff --git a/lib/find_bit_benchmark.c b/lib/find_bit_benchmark.c
index 5367ffa5c18f..d59d92c9e73e 100644
--- a/lib/find_bit_benchmark.c
+++ b/lib/find_bit_benchmark.c
@@ -24,6 +24,8 @@
  * - sparse bitmap with few set bits at random positions.
  */
 
+#define pr_fmt(fmt) fmt
+
 #include 
 #include 
 #include 
diff --git a/lib/kobject.c b/lib/kobject.c
index 18989b5b3b56..2bb9a50da4b0 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -10,6 +10,8 @@
  * about using the kobject interface.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include 
 #include 
 #include 
@@ -129,8 +131,8 @@ static void fill_kobj_path(struct kobject *kobj, char 
*path, int length)
*(path + --length) = '/';
}
 
-   pr_debug("kobject: '%s' (%p): %s: path = '%s'\n", kobject_name(kobj),
-kobj, __func__, path);
+   pr_debug("'%

[PATCH 06/18] net: Remove pr_fmt duplicate logging prefixes

2018-05-10 Thread Joe Perches
Using KBUILD_MODNAME as the default pr_fmt prefix caused some
duplication on logging prefixes in net/.

Remove the duplicate prefixes.

Signed-off-by: Joe Perches <j...@perches.com>
---
 net/ipv4/ipconfig.c| 59 --
 net/ipv4/ipmr.c|  2 +-
 net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c |  9 ++--
 net/ipv6/ip6mr.c   |  2 +-
 net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c |  6 +--
 net/ipv6/netfilter/nf_defrag_ipv6_hooks.c  |  4 +-
 net/netfilter/nf_conntrack_helper.c| 11 ++---
 net/netfilter/nf_conntrack_standalone.c|  2 +-
 net/socket.c   |  2 +-
 9 files changed, 43 insertions(+), 54 deletions(-)

diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index d839d74853fc..fcf7a4f1b09a 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -224,7 +224,7 @@ static int __init ic_open_devs(void)
if (!(dev->flags & IFF_LOOPBACK) && !netdev_uses_dsa(dev))
continue;
if (dev_change_flags(dev, dev->flags | IFF_UP) < 0)
-   pr_err("IP-Config: Failed to open %s\n", dev->name);
+   pr_err("Failed to open %s\n", dev->name);
}
 
for_each_netdev(_net, dev) {
@@ -242,8 +242,7 @@ static int __init ic_open_devs(void)
continue;
oflags = dev->flags;
if (dev_change_flags(dev, oflags | IFF_UP) < 0) {
-   pr_err("IP-Config: Failed to open %s\n",
-  dev->name);
+   pr_err("Failed to open %s\n", dev->name);
continue;
}
if (!(d = kmalloc(sizeof(struct ic_device), 
GFP_KERNEL))) {
@@ -260,7 +259,7 @@ static int __init ic_open_devs(void)
else
d->xid = 0;
ic_proto_have_if |= able;
-   pr_debug("IP-Config: %s UP (able=%d, xid=%08x)\n",
+   pr_debug("%s UP (able=%d, xid=%08x)\n",
 dev->name, able, d->xid);
}
}
@@ -287,7 +286,7 @@ static int __init ic_open_devs(void)
 
elapsed = jiffies_to_msecs(jiffies - start);
wait = (CONF_CARRIER_TIMEOUT - elapsed + 500)/1000;
-   pr_info("Waiting up to %d more seconds for network.\n", wait);
+   pr_info("Waiting up to %d more seconds for network\n", wait);
next_msg = jiffies + msecs_to_jiffies(CONF_CARRIER_TIMEOUT/12);
}
 have_carrier:
@@ -297,10 +296,9 @@ static int __init ic_open_devs(void)
 
if (!ic_first_dev) {
if (user_dev_name[0])
-   pr_err("IP-Config: Device `%s' not found\n",
-  user_dev_name);
+   pr_err("Device `%s' not found\n", user_dev_name);
else
-   pr_err("IP-Config: No network devices available\n");
+   pr_err("No network devices available\n");
return -ENODEV;
}
return 0;
@@ -317,7 +315,7 @@ static void __init ic_close_devs(void)
next = d->next;
dev = d->dev;
if (d != ic_dev && !netdev_uses_dsa(dev)) {
-   pr_debug("IP-Config: Downing %s\n", dev->name);
+   pr_debug("Downing %s\n", dev->name);
dev_change_flags(dev, d->flags);
}
kfree(d);
@@ -351,20 +349,17 @@ static int __init ic_setup_if(void)
strcpy(ir.ifr_ifrn.ifrn_name, ic_dev->dev->name);
set_sockaddr(sin, ic_myaddr, 0);
if ((err = devinet_ioctl(_net, SIOCSIFADDR, )) < 0) {
-   pr_err("IP-Config: Unable to set interface address (%d)\n",
-  err);
+   pr_err("Unable to set interface address (%d)\n", err);
return -1;
}
set_sockaddr(sin, ic_netmask, 0);
if ((err = devinet_ioctl(_net, SIOCSIFNETMASK, )) < 0) {
-   pr_err("IP-Config: Unable to set interface netmask (%d)\n",
-  err);
+   pr_err("Unable to set interface netmask (%d)\n", err);
return -1;
}
set_sockaddr(sin, ic_myaddr | ~ic_netmask, 0);
if ((err = devinet_ioctl(_net, SIOCSIFBRDADDR, )) < 0) {
-   pr_err("IP-Config: Unable to set interface broadcast address 
(%d)\n",
-  err);
+

[PATCH 09/18] ptp: Remove pr_fmt duplicate logging prefixes

2018-05-10 Thread Joe Perches
Converting pr_fmt from a simple define to use KBUILD_MODNAME added
some duplicate logging prefixes to existing uses.

Remove them.

Signed-off-by: Joe Perches <j...@perches.com>
---
 drivers/ptp/ptp_clock.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
index 7eacc1c4b3b1..35d9e1aa6564 100644
--- a/drivers/ptp/ptp_clock.c
+++ b/drivers/ptp/ptp_clock.c
@@ -396,13 +396,13 @@ static int __init ptp_init(void)
 
ptp_class = class_create(THIS_MODULE, "ptp");
if (IS_ERR(ptp_class)) {
-   pr_err("ptp: failed to allocate class\n");
+   pr_err("failed to allocate class\n");
return PTR_ERR(ptp_class);
}
 
err = alloc_chrdev_region(_devt, 0, MINORMASK + 1, "ptp");
if (err < 0) {
-   pr_err("ptp: failed to allocate device region\n");
+   pr_err("failed to allocate device region\n");
goto no_region;
}
 
-- 
2.15.0



[PATCH] net: ipv4: remove define INET_CSK_DEBUG and unnecessary EXPORT_SYMBOL

2018-05-10 Thread Joe Perches
INET_CSK_DEBUG is always set and only is used for 2 pr_debug calls.

EXPORT_SYMBOL(inet_csk_timer_bug_msg) is only used by these 2
pr_debug calls and is also unnecessary as the exported string can
be used directly by these calls.

Signed-off-by: Joe Perches <j...@perches.com>
---
 include/net/inet_connection_sock.h | 22 --
 net/ipv4/inet_connection_sock.c|  5 -
 2 files changed, 4 insertions(+), 23 deletions(-)

diff --git a/include/net/inet_connection_sock.h 
b/include/net/inet_connection_sock.h
index 2ab6667275df..0a6c9e0f2b5a 100644
--- a/include/net/inet_connection_sock.h
+++ b/include/net/inet_connection_sock.h
@@ -23,8 +23,6 @@
 #include 
 #include 
 
-#define INET_CSK_DEBUG 1
-
 /* Cancel timers, when they are not required. */
 #undef INET_CSK_CLEAR_TIMERS
 
@@ -196,10 +194,6 @@ static inline void inet_csk_delack_init(struct sock *sk)
 void inet_csk_delete_keepalive_timer(struct sock *sk);
 void inet_csk_reset_keepalive_timer(struct sock *sk, unsigned long timeout);
 
-#ifdef INET_CSK_DEBUG
-extern const char inet_csk_timer_bug_msg[];
-#endif
-
 static inline void inet_csk_clear_xmit_timer(struct sock *sk, const int what)
 {
struct inet_connection_sock *icsk = inet_csk(sk);
@@ -214,12 +208,9 @@ static inline void inet_csk_clear_xmit_timer(struct sock 
*sk, const int what)
 #ifdef INET_CSK_CLEAR_TIMERS
sk_stop_timer(sk, >icsk_delack_timer);
 #endif
+   } else {
+   pr_debug("inet_csk BUG: unknown timer value\n");
}
-#ifdef INET_CSK_DEBUG
-   else {
-   pr_debug("%s", inet_csk_timer_bug_msg);
-   }
-#endif
 }
 
 /*
@@ -232,10 +223,8 @@ static inline void inet_csk_reset_xmit_timer(struct sock 
*sk, const int what,
struct inet_connection_sock *icsk = inet_csk(sk);
 
if (when > max_when) {
-#ifdef INET_CSK_DEBUG
pr_debug("reset_xmit_timer: sk=%p %d when=0x%lx, caller=%p\n",
 sk, what, when, current_text_addr());
-#endif
when = max_when;
}
 
@@ -249,12 +238,9 @@ static inline void inet_csk_reset_xmit_timer(struct sock 
*sk, const int what,
icsk->icsk_ack.pending |= ICSK_ACK_TIMER;
icsk->icsk_ack.timeout = jiffies + when;
sk_reset_timer(sk, >icsk_delack_timer, 
icsk->icsk_ack.timeout);
+   } else {
+   pr_debug("inet_csk BUG: unknown timer value\n");
}
-#ifdef INET_CSK_DEBUG
-   else {
-   pr_debug("%s", inet_csk_timer_bug_msg);
-   }
-#endif
 }
 
 static inline unsigned long
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index 881ac6d046f2..33a88e045efd 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -27,11 +27,6 @@
 #include 
 #include 
 
-#ifdef INET_CSK_DEBUG
-const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n";
-EXPORT_SYMBOL(inet_csk_timer_bug_msg);
-#endif
-
 #if IS_ENABLED(CONFIG_IPV6)
 /* match_wildcard == true:  IPV6_ADDR_ANY equals to any IPv6 addresses if IPv6
  *  only, and any IPv4 addresses if not IPv6 only
-- 
2.15.0



Re: [net-next][PATCH] inet: Use switch case instead of multiple condition checks

2018-05-09 Thread Joe Perches
On Thu, 2018-05-10 at 13:37 +0800, Li RongQing wrote:
> inet_csk_reset_xmit_timer uses multiple equality condition checks,
> so it is better to use switch case instead of them
[]
> diff --git a/include/net/inet_connection_sock.h 
> b/include/net/inet_connection_sock.h
[]
> @@ -239,22 +239,31 @@ static inline void inet_csk_reset_xmit_timer(struct 
> sock *sk, const int what,
>   when = max_when;
>   }
>  
> - if (what == ICSK_TIME_RETRANS || what == ICSK_TIME_PROBE0 ||
> - what == ICSK_TIME_EARLY_RETRANS || what == ICSK_TIME_LOSS_PROBE ||
> - what == ICSK_TIME_REO_TIMEOUT) {
> + switch (what) {
> + case ICSK_TIME_RETRANS:
> + /* fall through */
> + case ICSK_TIME_PROBE0:
> + /* fall through */
> + case ICSK_TIME_EARLY_RETRANS:
> + /* fall through */
> + case ICSK_TIME_LOSS_PROBE:
> + /* fall through */
> + case ICSK_TIME_REO_TIMEOUT:

Please remove the /* fall through */ lines
and use consecutive case labels like:

case ICSK_TIME_RETRANS:
case ICSK_TIME_PROBE0:
case ICSK_TIME_EARLY_RETRANS:
case ICSK_TIME_LOSS_PROBE:
case ICSK_TIME_REO_TIMEOUT:



Re: [net-next 2/6] fm10k: reduce duplicate fm10k_stat macro code

2018-05-08 Thread Joe Perches
On Mon, 2018-05-07 at 07:45 -0700, Jeff Kirsher wrote:
> Share some of the code for setting up fm10k_stat macros by implementing
> an FM10K_STAT_FIELDS macro which we can use when setting up the type
> specific macros.
[]
> diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c 
> b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
[]
> @@ -11,12 +11,16 @@ struct fm10k_stats {
>   int stat_offset;
>  };o 
>  
> -#define FM10K_NETDEV_STAT(_net_stat) { \
> - .stat_string = #_net_stat, \
> - .sizeof_stat = FIELD_SIZEOF(struct net_device_stats, _net_stat), \
> - .stat_offset = offsetof(struct net_device_stats, _net_stat) \
> +#define FM10K_STAT_FIELDS(_type, _name, _stat) { \
> + .stat_string = _name, \
> + .sizeof_stat = FIELD_SIZEOF(_type, _stat), \
> + .stat_offset = offsetof(_type, _stat) \
>  }
>  
> +/* netdevice statistics */
> +#define FM10K_NETDEV_STAT(_net_stat) \
> + FM10K_STAT_FIELDS(struct net_device_stats, #_net_stat, _net_stat)

trivia:

It's somewhat unusual to use # in a macro argument.
Perhaps this would be slightly easier to understand using __stringify

#define FM10K_NETDEV_STAT(_net_stat) \
FM10K_STAT_FIELDS(struct net_device_stats, __stringify(_net_stat), 
_net_stat)



Re: [PATCH 00/12] Ethernet: Add and use ether__addr globals

2018-04-05 Thread Joe Perches
On Thu, 2018-04-05 at 15:27 +0200, Felix Fietkau wrote:
> On 2018-03-31 09:05, Joe Perches wrote:
> > There are many local static and non-static arrays that are used for
> > Ethernet broadcast address output or comparison.
> > 
> > Centralize the array into a single separate file and remove the local
> > arrays.
> 
> I suspect that for many targets and configurations, the local arrays
> might actually be smaller than exporting a global.

I tried x86-64 allnoconfig and defconfig.
Those both did not increase vmlinux size.

The defconfig actually got smaller, but that might have been
some object alignment oddity.

>  You have to factor in
> not just the .text size, but the fact that referencing an exported
> symbol needs a .reloc entry as well, which also eats up some space (at
> least when the code is being built as module).

Thanks, the modules I built got smaller.

> In my opinion, your series probably causes more bloat in common
> configurations instead of reducing it.
> 
> You're also touching several places that could easily use
> eth_broadcast_addr and eth_zero_addr. I think making those changes would
> be more productive than what you did in this series.

Doubtful. AFAIK: possible unaligned addresses.



Re: [PATCH 04/12] bridge: netfilter: Use the new global ether__addr arrays

2018-03-31 Thread Joe Perches
On Sat, 2018-03-31 at 20:28 +0200, Pablo Neira Ayuso wrote:
> Hi Joe,

Hi Pablo.

> On Sat, Mar 31, 2018 at 12:05:19AM -0700, Joe Perches wrote:
> > Remove the local consts and use the new globals.
> 
> This one is already upstream:
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git/commit/?id=9124a20d8794663a396b5d6f91f66903848a042b
> 
> I can see you're using is_broadcast_ether_addr(e->destmsk) in this new
> version, we would need an incremental version.

No worries.  I did it against next-20180329
and that other commit wasn't there.



[PATCH V2] treewide/net: Rename eth_stp_addr to ether_stp_addr

2018-03-31 Thread Joe Perches
eth_stp_addr is not in the same form as the other global ether__addr
addresses like ether_broadcast_addr.

Convert it treewide.

Miscellanea:

o Add comment to the ether_stp_addr define to show it's for spanning-tree

Signed-off-by: Joe Perches <j...@perches.com>
---

V2: Remove gg from initial comment (bad editing)

 drivers/net/dsa/lan9303-core.c | 4 ++--
 include/linux/etherdevice.h| 3 ++-
 net/bridge/br_device.c | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
index fefa454f3e56..a6f015ef251a 100644
--- a/drivers/net/dsa/lan9303-core.c
+++ b/drivers/net/dsa/lan9303-core.c
@@ -789,7 +789,7 @@ static int lan9303_separate_ports(struct lan9303 *chip)
 {
int ret;
 
-   lan9303_alr_del_port(chip, eth_stp_addr, 0);
+   lan9303_alr_del_port(chip, ether_stp_addr, 0);
ret = lan9303_write_switch_reg(chip, LAN9303_SWE_PORT_MIRROR,
LAN9303_SWE_PORT_MIRROR_SNIFFER_PORT0 |
LAN9303_SWE_PORT_MIRROR_MIRRORED_PORT1 |
@@ -814,7 +814,7 @@ static void lan9303_bridge_ports(struct lan9303 *chip)
 
lan9303_write_switch_reg(chip, LAN9303_SWE_PORT_STATE,
 chip->swe_port_state);
-   lan9303_alr_add_port(chip, eth_stp_addr, 0, true);
+   lan9303_alr_add_port(chip, ether_stp_addr, 0, true);
 }
 
 static void lan9303_handle_reset(struct lan9303 *chip)
diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
index 85d2486b2959..142da8043b24 100644
--- a/include/linux/etherdevice.h
+++ b/include/linux/etherdevice.h
@@ -70,7 +70,8 @@ extern const u8 ether_zero_addr[ETH_ALEN];/* all zeros */
 /* Reserved Ethernet Addresses per IEEE 802.1Q */
 extern const u8 ether_reserved_addr_base[ETH_ALEN];
 
-#define eth_stp_addr ether_reserved_addr_base
+/* Ethernet bridge - spanning tree protocol */
+#define ether_stp_addr ether_reserved_addr_base
 
 /**
  * is_link_local_ether_addr - Determine if given Ethernet address is link-local
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index 278fc999d355..17b1917b6ecd 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -431,7 +431,7 @@ void br_dev_setup(struct net_device *dev)
br->bridge_id.prio[0] = 0x80;
br->bridge_id.prio[1] = 0x00;
 
-   ether_addr_copy(br->group_addr, eth_stp_addr);
+   ether_addr_copy(br->group_addr, ether_stp_addr);
 
br->stp_enabled = BR_NO_STP;
br->group_fwd_mask = BR_GROUPFWD_DEFAULT;
-- 
2.15.0



Re: [PATCH 02/12] treewide/net: Rename eth_stp_addr to ether_stp_addr

2018-03-31 Thread Joe Perches
On Sat, 2018-03-31 at 19:36 +0200, Andrew Lunn wrote:
> On Sat, Mar 31, 2018 at 12:05:17AM -0700, Joe Perches wrote:
> > --- a/net/bridge/br_device.c
> > +++ b/net/bridge/br_device.c
> > @@ -1,4 +1,4 @@
> > -/*
> > +gg/*
> 
> Hi Joe
> 
> This does not look good.

Definitely agree with that.  apologies for not noticing.

It's emacs editing nonsense like a superfluous :wq for vim



Re: [PATCH 06/12] wireless: Convert simple uses of a static const Ethernet broadcast address

2018-03-31 Thread Joe Perches
On Sat, 2018-03-31 at 14:01 +, Pkshih wrote:
> On Sat, 2018-03-31 at 00:05 -0700, Joe Perches wrote:
> > Use the new ether_broadcast_addr global instead to save some object code.
[]
> > diff --git a/drivers/net/wireless/realtek/rtlwifi/core.c
[]
> > @@ -1649,7 +1648,7 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, 
> > enum set_key_cmd cmd,
> > memcpy(rtlpriv->sec.key_buf[key_idx],
> >key->key, key->keylen);
> > rtlpriv->sec.key_len[key_idx] = key->keylen;
> > -   memcpy(mac_addr, bcast_addr, ETH_ALEN);
> > +   memcpy(mac_addr, ether_broadcast_addr, ETH_ALEN);
> 
> Use ether_addr_copy(mac_addr, ether_broadcast_addr) ?

This should use eth_broadcast_addr(mac_addr) instead.

There are similar conversion still possible in the tree.
One day.



[PATCH 01/12] ethernet: Add generic ether__addr addresses

2018-03-31 Thread Joe Perches
Treewide there are ~60 declarations of Ethernet broadcast or zero address
use as a 6 byte array that are later used as either an output for vsprintf
extension %pM or as a source array to copy or compare.

Create const globals for these uses with EXPORT_SYMBOL for modules.

Miscellanea:

o Rename and move static const eth_reservd_addr_base from etherdevice.h
  to this new ether_addrs.c file so it is no longer oddly declared
  as static const in a .h file

Signed-off-by: Joe Perches <j...@perches.com>
---
 include/linux/etherdevice.h | 12 
 net/ethernet/Makefile   |  2 +-
 net/ethernet/ether_addrs.c  | 19 +++
 3 files changed, 28 insertions(+), 5 deletions(-)
 create mode 100644 net/ethernet/ether_addrs.c

diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
index 79563840c295..85d2486b2959 100644
--- a/include/linux/etherdevice.h
+++ b/include/linux/etherdevice.h
@@ -63,10 +63,14 @@ struct sk_buff **eth_gro_receive(struct sk_buff **head,
 struct sk_buff *skb);
 int eth_gro_complete(struct sk_buff *skb, int nhoff);
 
+/* Generic Ethernet addresses */
+extern const u8 ether_broadcast_addr[ETH_ALEN];/* all 0xff */
+extern const u8 ether_zero_addr[ETH_ALEN]; /* all zeros */
+
 /* Reserved Ethernet Addresses per IEEE 802.1Q */
-static const u8 eth_reserved_addr_base[ETH_ALEN] __aligned(2) =
-{ 0x01, 0x80, 0xc2, 0x00, 0x00, 0x00 };
-#define eth_stp_addr eth_reserved_addr_base
+extern const u8 ether_reserved_addr_base[ETH_ALEN];
+
+#define eth_stp_addr ether_reserved_addr_base
 
 /**
  * is_link_local_ether_addr - Determine if given Ethernet address is link-local
@@ -80,7 +84,7 @@ static const u8 eth_reserved_addr_base[ETH_ALEN] __aligned(2) 
=
 static inline bool is_link_local_ether_addr(const u8 *addr)
 {
__be16 *a = (__be16 *)addr;
-   static const __be16 *b = (const __be16 *)eth_reserved_addr_base;
+   static const __be16 *b = (const __be16 *)ether_reserved_addr_base;
static const __be16 m = cpu_to_be16(0xfff0);
 
 #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
diff --git a/net/ethernet/Makefile b/net/ethernet/Makefile
index 323177505404..fbbcfec2ba10 100644
--- a/net/ethernet/Makefile
+++ b/net/ethernet/Makefile
@@ -2,4 +2,4 @@
 # Makefile for the Linux Ethernet layer.
 #
 
-obj-y  += eth.o
+obj-y  += eth.o ether_addrs.o
diff --git a/net/ethernet/ether_addrs.c b/net/ethernet/ether_addrs.c
new file mode 100644
index ..e0b7a57628e8
--- /dev/null
+++ b/net/ethernet/ether_addrs.c
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Various const global Ethernet addresses */
+
+#include 
+
+const u8 ether_broadcast_addr[ETH_ALEN] __aligned(2) = {
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+};
+EXPORT_SYMBOL(ether_broadcast_addr);
+
+const u8 ether_zero_addr[ETH_ALEN] __aligned(2) = {
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+EXPORT_SYMBOL(ether_zero_addr);
+
+const u8 ether_reserved_addr_base[ETH_ALEN] __aligned(2) = {
+   0x01, 0x80, 0xc2, 0x00, 0x00, 0x00
+};
+EXPORT_SYMBOL(ether_reserved_addr_base);
-- 
2.15.0



[PATCH 02/12] treewide/net: Rename eth_stp_addr to ether_stp_addr

2018-03-31 Thread Joe Perches
eth_stp_addr is not in the same form as the other global ether__addr
addresses like ether_broadcast_addr.

Convert it treewide.

Miscellanea:

o Add comment to the ether_stp_addr define to show it's for spanning-tree

Signed-off-by: Joe Perches <j...@perches.com>
---
 drivers/net/dsa/lan9303-core.c | 4 ++--
 include/linux/etherdevice.h| 3 ++-
 net/bridge/br_device.c | 4 ++--
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
index fefa454f3e56..a6f015ef251a 100644
--- a/drivers/net/dsa/lan9303-core.c
+++ b/drivers/net/dsa/lan9303-core.c
@@ -789,7 +789,7 @@ static int lan9303_separate_ports(struct lan9303 *chip)
 {
int ret;
 
-   lan9303_alr_del_port(chip, eth_stp_addr, 0);
+   lan9303_alr_del_port(chip, ether_stp_addr, 0);
ret = lan9303_write_switch_reg(chip, LAN9303_SWE_PORT_MIRROR,
LAN9303_SWE_PORT_MIRROR_SNIFFER_PORT0 |
LAN9303_SWE_PORT_MIRROR_MIRRORED_PORT1 |
@@ -814,7 +814,7 @@ static void lan9303_bridge_ports(struct lan9303 *chip)
 
lan9303_write_switch_reg(chip, LAN9303_SWE_PORT_STATE,
 chip->swe_port_state);
-   lan9303_alr_add_port(chip, eth_stp_addr, 0, true);
+   lan9303_alr_add_port(chip, ether_stp_addr, 0, true);
 }
 
 static void lan9303_handle_reset(struct lan9303 *chip)
diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
index 85d2486b2959..142da8043b24 100644
--- a/include/linux/etherdevice.h
+++ b/include/linux/etherdevice.h
@@ -70,7 +70,8 @@ extern const u8 ether_zero_addr[ETH_ALEN];/* all zeros */
 /* Reserved Ethernet Addresses per IEEE 802.1Q */
 extern const u8 ether_reserved_addr_base[ETH_ALEN];
 
-#define eth_stp_addr ether_reserved_addr_base
+/* Ethernet bridge - spanning tree protocol */
+#define ether_stp_addr ether_reserved_addr_base
 
 /**
  * is_link_local_ether_addr - Determine if given Ethernet address is link-local
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index 278fc999d355..3abcf69d1976 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -1,4 +1,4 @@
-/*
+gg/*
  * Device handling code
  * Linux ethernet bridge
  *
@@ -431,7 +431,7 @@ void br_dev_setup(struct net_device *dev)
br->bridge_id.prio[0] = 0x80;
br->bridge_id.prio[1] = 0x00;
 
-   ether_addr_copy(br->group_addr, eth_stp_addr);
+   ether_addr_copy(br->group_addr, ether_stp_addr);
 
br->stp_enabled = BR_NO_STP;
br->group_fwd_mask = BR_GROUPFWD_DEFAULT;
-- 
2.15.0



[PATCH 00/12] Ethernet: Add and use ether__addr globals

2018-03-31 Thread Joe Perches
There are many local static and non-static arrays that are used for
Ethernet broadcast address output or comparison.

Centralize the array into a single separate file and remove the local
arrays.

Joe Perches (12):
  ethernet: Add generic ether__addr addresses
  treewide/net: Rename eth_stp_addr to ether_stp_addr
  net: mac80211: Use global ether_broadcast_addr
  bridge: netfilter: Use the new global ether__addr arrays
  net: atm: Use ether_broadcast_addr
  wireless: Convert simple uses of a static const Ethernet broadcast address
  brcmfmac: Convert ALLFFMAC to ether_broadcast_addr
  iwlegacy: Remove EXPORT_SYMBOL(il_bcast_addr) and use ether_broadcast_addr
  iwlwifi: Remove local iwl_bcast_addr and use ether_broadcast_addr
  mvpp2: Use ether_broadcast_addr instead of a local array
  qlogic: Convert local bcast_addr to global ether_broadcast_addr
  ethernet: Use ether_zero_addr instead of local statics

 drivers/net/dsa/lan9303-core.c|  4 ++--
 drivers/net/ethernet/broadcom/b44.c   |  5 ++---
 drivers/net/ethernet/freescale/gianfar.c  |  3 +--
 drivers/net/ethernet/marvell/mvpp2.c  |  4 +---
 drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c|  5 +
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c|  6 ++
 .../net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c  |  6 ++
 drivers/net/wireless/admtek/adm8211.c |  3 +--
 drivers/net/wireless/ath/carl9170/mac.c   |  4 +---
 drivers/net/wireless/broadcom/b43/main.c  |  3 +--
 .../net/wireless/broadcom/brcm80211/brcmfmac/common.c |  2 --
 .../net/wireless/broadcom/brcm80211/brcmfmac/common.h |  2 --
 .../wireless/broadcom/brcm80211/brcmfmac/flowring.c   |  8 
 drivers/net/wireless/intel/iwlegacy/3945-mac.c|  2 +-
 drivers/net/wireless/intel/iwlegacy/4965-mac.c|  2 +-
 drivers/net/wireless/intel/iwlegacy/common.c  |  3 ---
 drivers/net/wireless/intel/iwlegacy/common.h  |  1 -
 drivers/net/wireless/intel/iwlwifi/dvm/dev.h  |  1 -
 drivers/net/wireless/intel/iwlwifi/dvm/scan.c |  2 +-
 drivers/net/wireless/intel/iwlwifi/dvm/sta.c  |  4 +---
 drivers/net/wireless/marvell/mwifiex/cfg80211.c   |  3 +--
 drivers/net/wireless/realtek/rtlwifi/core.c   |  5 ++---
 drivers/net/wireless/rndis_wlan.c |  6 +-
 drivers/net/wireless/ti/wl1251/main.c |  5 +
 drivers/net/wireless/ti/wlcore/main.c |  5 +
 include/linux/etherdevice.h   | 13 +
 net/atm/lec.c | 12 +---
 net/bridge/br_device.c|  4 ++--
 net/bridge/netfilter/ebt_stp.c|  6 ++
 net/ethernet/Makefile |  2 +-
 net/ethernet/ether_addrs.c| 19 +++
 net/mac80211/iface.c  |  5 +
 net/mac80211/key.c|  6 ++
 net/mac80211/mesh_hwmp.c  | 19 ++-
 net/mac80211/mesh_pathtbl.c   |  8 
 35 files changed, 83 insertions(+), 105 deletions(-)
 create mode 100644 net/ethernet/ether_addrs.c

-- 
2.15.0



[PATCH 03/12] net: mac80211: Use global ether_broadcast_addr

2018-03-31 Thread Joe Perches
Remove statics and use the new global ether_broadcast_addr instead
to save some overall object code size.

Signed-off-by: Joe Perches <j...@perches.com>
---
 net/mac80211/iface.c|  5 +
 net/mac80211/key.c  |  6 ++
 net/mac80211/mesh_hwmp.c| 19 ++-
 net/mac80211/mesh_pathtbl.c |  8 
 4 files changed, 17 insertions(+), 21 deletions(-)

diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index d13ba064951f..f203efc3c532 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -1387,9 +1387,6 @@ static void ieee80211_recalc_smps_work(struct work_struct 
*work)
 static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata,
  enum nl80211_iftype type)
 {
-   static const u8 bssid_wildcard[ETH_ALEN] = {0xff, 0xff, 0xff,
-   0xff, 0xff, 0xff};
-
/* clear type-dependent union */
memset(>u, 0, sizeof(sdata->u));
 
@@ -1442,7 +1439,7 @@ static void ieee80211_setup_sdata(struct 
ieee80211_sub_if_data *sdata,
ieee80211_sta_setup_sdata(sdata);
break;
case NL80211_IFTYPE_OCB:
-   sdata->vif.bss_conf.bssid = bssid_wildcard;
+   sdata->vif.bss_conf.bssid = ether_broadcast_addr;
ieee80211_ocb_setup_sdata(sdata);
break;
case NL80211_IFTYPE_ADHOC:
diff --git a/net/mac80211/key.c b/net/mac80211/key.c
index aee05ec3f7ea..429f0f4bdc0d 100644
--- a/net/mac80211/key.c
+++ b/net/mac80211/key.c
@@ -53,8 +53,6 @@
  * remove the key which waits for an RCU grace period.
  */
 
-static const u8 bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
-
 static void assert_key_lock(struct ieee80211_local *local)
 {
lockdep_assert_held(>key_mtx);
@@ -196,7 +194,7 @@ static int ieee80211_key_enable_hw_accel(struct 
ieee80211_key *key)
sdata_err(sdata,
  "failed to set key (%d, %pM) to hardware (%d)\n",
  key->conf.keyidx,
- sta ? sta->sta.addr : bcast_addr, ret);
+ sta ? sta->sta.addr : ether_broadcast_addr, ret);
 
  out_unsupported:
switch (key->conf.cipher) {
@@ -253,7 +251,7 @@ static void ieee80211_key_disable_hw_accel(struct 
ieee80211_key *key)
sdata_err(sdata,
  "failed to remove key (%d, %pM) from hardware (%d)\n",
  key->conf.keyidx,
- sta ? sta->sta.addr : bcast_addr, ret);
+ sta ? sta->sta.addr : ether_broadcast_addr, ret);
 
key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE;
 }
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c
index 35ad3983ae4b..23027ea80593 100644
--- a/net/mac80211/mesh_hwmp.c
+++ b/net/mac80211/mesh_hwmp.c
@@ -97,8 +97,6 @@ enum mpath_frame_type {
MPATH_RANN
 };
 
-static const u8 broadcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 
0xff};
-
 static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags,
  const u8 *orig_addr, u32 orig_sn,
  u8 target_flags, const u8 *target,
@@ -645,7 +643,7 @@ static void hwmp_preq_frame_process(struct 
ieee80211_sub_if_data *sdata,
preq_id = PREQ_IE_PREQ_ID(preq_elem);
hopcount = PREQ_IE_HOPCOUNT(preq_elem) + 1;
da = (mpath && mpath->is_root) ?
-   mpath->rann_snd_addr : broadcast_addr;
+   mpath->rann_snd_addr : ether_broadcast_addr;
 
if (flags & IEEE80211_PREQ_PROACTIVE_PREP_FLAG) {
target_addr = PREQ_IE_TARGET_ADDR(preq_elem);
@@ -779,7 +777,7 @@ static void hwmp_perr_frame_process(struct 
ieee80211_sub_if_data *sdata,
goto endperr;
mesh_path_error_tx(sdata, ttl, target_addr,
   target_sn, target_rcode,
-  broadcast_addr);
+  ether_broadcast_addr);
} else
spin_unlock_bh(>state_lock);
}
@@ -877,7 +875,8 @@ static void hwmp_rann_frame_process(struct 
ieee80211_sub_if_data *sdata,
 
if (ifmsh->mshcfg.dot11MeshForwarding) {
mesh_path_sel_frame_tx(MPATH_RANN, flags, orig_addr,
-  orig_sn, 0, NULL, 0, broadcast_addr,
+  orig_sn, 0, NULL, 0,
+  ether_broadcast_addr,
   hopcount, ttl, interval,
   new_metric, 0, sdata);
}
@@ -1080,7 +1079,7 @@ void mesh_path_start_discovery(struct 
ieee80211_sub_i

[PATCH 04/12] bridge: netfilter: Use the new global ether__addr arrays

2018-03-31 Thread Joe Perches
Remove the local consts and use the new globals.

Signed-off-by: Joe Perches <j...@perches.com>
---
 net/bridge/netfilter/ebt_stp.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/net/bridge/netfilter/ebt_stp.c b/net/bridge/netfilter/ebt_stp.c
index 3140eb912d7e..2b7479cc0140 100644
--- a/net/bridge/netfilter/ebt_stp.c
+++ b/net/bridge/netfilter/ebt_stp.c
@@ -153,8 +153,6 @@ ebt_stp_mt(const struct sk_buff *skb, struct 
xt_action_param *par)
 static int ebt_stp_mt_check(const struct xt_mtchk_param *par)
 {
const struct ebt_stp_info *info = par->matchinfo;
-   const u8 bridge_ula[6] = {0x01, 0x80, 0xc2, 0x00, 0x00, 0x00};
-   const u8 msk[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
const struct ebt_entry *e = par->entryinfo;
 
if (info->bitmask & ~EBT_STP_MASK || info->invflags & ~EBT_STP_MASK ||
@@ -162,8 +160,8 @@ static int ebt_stp_mt_check(const struct xt_mtchk_param 
*par)
return -EINVAL;
/* Make sure the match only receives stp frames */
if (!par->nft_compat &&
-   (!ether_addr_equal(e->destmac, bridge_ula) ||
-!ether_addr_equal(e->destmsk, msk) ||
+   (!ether_addr_equal(e->destmac, ether_stp_addr) ||
+!ether_addr_equal(e->destmsk, ether_broadcast_addr) ||
 !(e->bitmask & EBT_DESTMAC)))
return -EINVAL;
 
-- 
2.15.0



[PATCH 05/12] net: atm: Use ether_broadcast_addr

2018-03-31 Thread Joe Perches
Use the new global instead of a local static to reduce object code size
a tiny bit.

Signed-off-by: Joe Perches <j...@perches.com>
---
 net/atm/lec.c | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/net/atm/lec.c b/net/atm/lec.c
index 01d5d20a6eb1..ec47b45bd836 100644
--- a/net/atm/lec.c
+++ b/net/atm/lec.c
@@ -116,8 +116,6 @@ static struct lane2_ops lane2_ops = {
.associate_indicator = NULL /* spec 3.1.5 */
 };
 
-static unsigned char bus_mac[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff 
};
-
 /* Device structures */
 static struct net_device *dev_lec[MAX_LEC_ITF];
 
@@ -1726,7 +1724,7 @@ static struct atm_vcc *lec_arp_resolve(struct lec_priv 
*priv,
case 1:
return priv->mcast_vcc;
case 2: /* LANE2 wants arp for multicast addresses */
-   if (ether_addr_equal(mac_to_find, bus_mac))
+   if (ether_addr_equal(mac_to_find, ether_broadcast_addr))
return priv->mcast_vcc;
break;
default:
@@ -1954,7 +1952,7 @@ lec_vcc_added(struct lec_priv *priv, const struct 
atmlec_ioc *ioc_data,
if (ioc_data->receive == 2) {
pr_debug("LEC_ARP: Attaching mcast forward\n");
 #if 0
-   entry = lec_arp_find(priv, bus_mac);
+   entry = lec_arp_find(priv, ether_broadcast_addr);
if (!entry) {
pr_info("LEC_ARP: Multicast entry not found!\n");
goto out;
@@ -1963,7 +1961,7 @@ lec_vcc_added(struct lec_priv *priv, const struct 
atmlec_ioc *ioc_data,
entry->recv_vcc = vcc;
entry->old_recv_push = old_push;
 #endif
-   entry = make_entry(priv, bus_mac);
+   entry = make_entry(priv, ether_broadcast_addr);
if (entry == NULL)
goto out;
del_timer(>timer);
@@ -1988,7 +1986,7 @@ lec_vcc_added(struct lec_priv *priv, const struct 
atmlec_ioc *ioc_data,
 ioc_data->atm_addr[14], ioc_data->atm_addr[15],
 ioc_data->atm_addr[16], ioc_data->atm_addr[17],
 ioc_data->atm_addr[18], ioc_data->atm_addr[19]);
-   entry = make_entry(priv, bus_mac);
+   entry = make_entry(priv, ether_broadcast_addr);
if (entry == NULL)
goto out;
memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN);
@@ -2071,7 +2069,7 @@ lec_vcc_added(struct lec_priv *priv, const struct 
atmlec_ioc *ioc_data,
 * Not found, snatch address from first data packet that arrives
 * from this vcc
 */
-   entry = make_entry(priv, bus_mac);
+   entry = make_entry(priv, ether_broadcast_addr);
if (!entry)
goto out;
entry->vcc = vcc;
-- 
2.15.0



[PATCH 07/12] brcmfmac: Convert ALLFFMAC to ether_broadcast_addr

2018-03-31 Thread Joe Perches
Remove the local ALLFFMAC extern array and use the new global instead.

Miscellanea:

o Convert char *mac to const char *mac as it can't be modified

Signed-off-by: Joe Perches <j...@perches.com>
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c   | 2 --
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h   | 2 --
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/flowring.c | 8 
 3 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
index 105b8774fca9..cd3651069d0c 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
@@ -36,8 +36,6 @@ MODULE_AUTHOR("Broadcom Corporation");
 MODULE_DESCRIPTION("Broadcom 802.11 wireless LAN fullmac driver.");
 MODULE_LICENSE("Dual BSD/GPL");
 
-const u8 ALLFFMAC[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
-
 #define BRCMF_DEFAULT_SCAN_CHANNEL_TIME40
 #define BRCMF_DEFAULT_SCAN_UNASSOC_TIME40
 
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
index ef914619e8e1..a34642cb4d2f 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
@@ -19,8 +19,6 @@
 #include 
 #include "fwil_types.h"
 
-extern const u8 ALLFFMAC[ETH_ALEN];
-
 #define BRCMF_FW_ALTPATH_LEN   256
 
 /* Definitions for the module global and device specific settings are defined
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/flowring.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/flowring.c
index d0b738da2458..f042531dd43c 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/flowring.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/flowring.c
@@ -73,13 +73,13 @@ u32 brcmf_flowring_lookup(struct brcmf_flowring *flow, u8 
da[ETH_ALEN],
bool found;
bool sta;
u8 fifo;
-   u8 *mac;
+   const u8 *mac;
 
fifo = brcmf_flowring_prio2fifo[prio];
sta = (flow->addr_mode[ifidx] == ADDR_INDIRECT);
mac = da;
if ((!sta) && (is_multicast_ether_addr(da))) {
-   mac = (u8 *)ALLFFMAC;
+   mac = ether_broadcast_addr;
fifo = 0;
}
if ((sta) && (flow->tdls_active) &&
@@ -118,13 +118,13 @@ u32 brcmf_flowring_create(struct brcmf_flowring *flow, u8 
da[ETH_ALEN],
bool found;
u8 fifo;
bool sta;
-   u8 *mac;
+   const u8 *mac;
 
fifo = brcmf_flowring_prio2fifo[prio];
sta = (flow->addr_mode[ifidx] == ADDR_INDIRECT);
mac = da;
if ((!sta) && (is_multicast_ether_addr(da))) {
-   mac = (u8 *)ALLFFMAC;
+   mac = ether_broadcast_addr;
fifo = 0;
}
if ((sta) && (flow->tdls_active) &&
-- 
2.15.0



[PATCH 06/12] wireless: Convert simple uses of a static const Ethernet broadcast address

2018-03-31 Thread Joe Perches
Use the new ether_broadcast_addr global instead to save some object code.

Signed-off-by: Joe Perches <j...@perches.com>
---
 drivers/net/wireless/admtek/adm8211.c   | 3 +--
 drivers/net/wireless/ath/carl9170/mac.c | 4 +---
 drivers/net/wireless/broadcom/b43/main.c| 3 +--
 drivers/net/wireless/marvell/mwifiex/cfg80211.c | 3 +--
 drivers/net/wireless/realtek/rtlwifi/core.c | 5 ++---
 drivers/net/wireless/rndis_wlan.c   | 6 +-
 drivers/net/wireless/ti/wl1251/main.c   | 5 +
 drivers/net/wireless/ti/wlcore/main.c   | 5 +
 8 files changed, 9 insertions(+), 25 deletions(-)

diff --git a/drivers/net/wireless/admtek/adm8211.c 
b/drivers/net/wireless/admtek/adm8211.c
index 3b0802fc5bf5..0aa2d114d5b3 100644
--- a/drivers/net/wireless/admtek/adm8211.c
+++ b/drivers/net/wireless/admtek/adm8211.c
@@ -1354,7 +1354,6 @@ static void adm8211_configure_filter(struct ieee80211_hw 
*dev,
 unsigned int *total_flags,
 u64 multicast)
 {
-   static const u8 bcast[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF 
};
struct adm8211_priv *priv = dev->priv;
unsigned int new_flags;
u32 mc_filter[2];
@@ -1385,7 +1384,7 @@ static void adm8211_configure_filter(struct ieee80211_hw 
*dev,
__clear_bit(IEEE80211_HW_RX_INCLUDES_FCS, dev->flags);
 
if (*total_flags & FIF_BCN_PRBRESP_PROMISC)
-   adm8211_set_bssid(dev, bcast);
+   adm8211_set_bssid(dev, ether_broadcast_addr);
else
adm8211_set_bssid(dev, priv->bssid);
 
diff --git a/drivers/net/wireless/ath/carl9170/mac.c 
b/drivers/net/wireless/ath/carl9170/mac.c
index 7d4a72dc98db..b1c608db047c 100644
--- a/drivers/net/wireless/ath/carl9170/mac.c
+++ b/drivers/net/wireless/ath/carl9170/mac.c
@@ -476,10 +476,8 @@ int carl9170_upload_key(struct ar9170 *ar, const u8 id, 
const u8 *mac,
const int keylen)
 {
struct carl9170_set_key_cmd key = { };
-   static const u8 bcast[ETH_ALEN] = {
-   0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
 
-   mac = mac ? : bcast;
+   mac = mac ? : ether_broadcast_addr;
 
key.user = cpu_to_le16(id);
key.keyId = cpu_to_le16(keyidx);
diff --git a/drivers/net/wireless/broadcom/b43/main.c 
b/drivers/net/wireless/broadcom/b43/main.c
index b37e7391f55d..f23d60064691 100644
--- a/drivers/net/wireless/broadcom/b43/main.c
+++ b/drivers/net/wireless/broadcom/b43/main.c
@@ -4185,7 +4185,6 @@ static int b43_op_set_key(struct ieee80211_hw *hw, enum 
set_key_cmd cmd,
u8 algorithm;
u8 index;
int err;
-   static const u8 bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 
0xff };
 
if (modparam_nohwcrypt)
return -ENOSPC; /* User disabled HW-crypto */
@@ -4293,7 +4292,7 @@ static int b43_op_set_key(struct ieee80211_hw *hw, enum 
set_key_cmd cmd,
b43dbg(wl, "%s hardware based encryption for keyidx: %d, "
   "mac: %pM\n",
   cmd == SET_KEY ? "Using" : "Disabling", key->keyidx,
-  sta ? sta->addr : bcast_addr);
+  sta ? sta->addr : ether_broadcast_addr);
b43_dump_keymemory(dev);
}
mutex_unlock(>mutex);
diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c 
b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
index 7f7e9de2db1c..400a4a67d545 100644
--- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
@@ -174,7 +174,6 @@ mwifiex_cfg80211_del_key(struct wiphy *wiphy, struct 
net_device *netdev,
 static int
 mwifiex_form_mgmt_frame(struct sk_buff *skb, const u8 *buf, size_t len)
 {
-   u8 addr[ETH_ALEN] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
u16 pkt_len;
u32 tx_control = 0, pkt_type = PKT_TYPE_MGMT;
 
@@ -191,7 +190,7 @@ mwifiex_form_mgmt_frame(struct sk_buff *skb, const u8 *buf, 
size_t len)
 
/* Add packet data and address4 */
skb_put_data(skb, buf, sizeof(struct ieee80211_hdr_3addr));
-   skb_put_data(skb, addr, ETH_ALEN);
+   skb_put_data(skb, ether_broadcast_addr, ETH_ALEN);
skb_put_data(skb, buf + sizeof(struct ieee80211_hdr_3addr),
 len - sizeof(struct ieee80211_hdr_3addr));
 
diff --git a/drivers/net/wireless/realtek/rtlwifi/core.c 
b/drivers/net/wireless/realtek/rtlwifi/core.c
index cfea57efa7f4..8c534a93dad5 100644
--- a/drivers/net/wireless/realtek/rtlwifi/core.c
+++ b/drivers/net/wireless/realtek/rtlwifi/core.c
@@ -1527,7 +1527,6 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum 
set_key_cmd cmd,
bool wep_only = false;
int err = 0;
u8 mac_addr[ETH_ALEN];
-   u8 bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
 
rtlpriv->btcoexist.btc_info

[PATCH 08/12] iwlegacy: Remove EXPORT_SYMBOL(il_bcast_addr) and use ether_broadcast_addr

2018-03-31 Thread Joe Perches
Remove the local array and use the new global instead to save some small
amount of object code.

Signed-off-by: Joe Perches <j...@perches.com>
---
 drivers/net/wireless/intel/iwlegacy/3945-mac.c | 2 +-
 drivers/net/wireless/intel/iwlegacy/4965-mac.c | 2 +-
 drivers/net/wireless/intel/iwlegacy/common.c   | 3 ---
 drivers/net/wireless/intel/iwlegacy/common.h   | 1 -
 4 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlegacy/3945-mac.c 
b/drivers/net/wireless/intel/iwlegacy/3945-mac.c
index 62a9794f952b..770c7aa13434 100644
--- a/drivers/net/wireless/intel/iwlegacy/3945-mac.c
+++ b/drivers/net/wireless/intel/iwlegacy/3945-mac.c
@@ -2352,7 +2352,7 @@ il3945_alloc_bcast_station(struct il_priv *il)
u8 sta_id;
 
spin_lock_irqsave(>sta_lock, flags);
-   sta_id = il_prep_station(il, il_bcast_addr, false, NULL);
+   sta_id = il_prep_station(il, ether_broadcast_addr, false, NULL);
if (sta_id == IL_INVALID_STATION) {
IL_ERR("Unable to prepare broadcast station\n");
spin_unlock_irqrestore(>sta_lock, flags);
diff --git a/drivers/net/wireless/intel/iwlegacy/4965-mac.c 
b/drivers/net/wireless/intel/iwlegacy/4965-mac.c
index 562e94870a9c..5772cbd9291c 100644
--- a/drivers/net/wireless/intel/iwlegacy/4965-mac.c
+++ b/drivers/net/wireless/intel/iwlegacy/4965-mac.c
@@ -3536,7 +3536,7 @@ il4965_alloc_bcast_station(struct il_priv *il)
u8 sta_id;
 
spin_lock_irqsave(>sta_lock, flags);
-   sta_id = il_prep_station(il, il_bcast_addr, false, NULL);
+   sta_id = il_prep_station(il, ether_broadcast_addr, false, NULL);
if (sta_id == IL_INVALID_STATION) {
IL_ERR("Unable to prepare broadcast station\n");
spin_unlock_irqrestore(>sta_lock, flags);
diff --git a/drivers/net/wireless/intel/iwlegacy/common.c 
b/drivers/net/wireless/intel/iwlegacy/common.c
index 063e19ced7c8..5853b1dedea1 100644
--- a/drivers/net/wireless/intel/iwlegacy/common.c
+++ b/drivers/net/wireless/intel/iwlegacy/common.c
@@ -3378,9 +3378,6 @@ MODULE_PARM_DESC(bt_coex_active, "enable wifi/bluetooth 
co-exist");
 u32 il_debug_level;
 EXPORT_SYMBOL(il_debug_level);
 
-const u8 il_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
-EXPORT_SYMBOL(il_bcast_addr);
-
 #define MAX_BIT_RATE_40_MHZ 150/* Mbps */
 #define MAX_BIT_RATE_20_MHZ 72 /* Mbps */
 static void
diff --git a/drivers/net/wireless/intel/iwlegacy/common.h 
b/drivers/net/wireless/intel/iwlegacy/common.h
index dc6a74a05983..6a6b43c5e4d7 100644
--- a/drivers/net/wireless/intel/iwlegacy/common.h
+++ b/drivers/net/wireless/intel/iwlegacy/common.h
@@ -860,7 +860,6 @@ struct il_hw_params {
  *
  /
 void il4965_update_chain_flags(struct il_priv *il);
-extern const u8 il_bcast_addr[ETH_ALEN];
 int il_queue_space(const struct il_queue *q);
 static inline int
 il_queue_used(const struct il_queue *q, int i)
-- 
2.15.0



[PATCH 10/12] mvpp2: Use ether_broadcast_addr instead of a local array

2018-03-31 Thread Joe Perches
Save a small bit of object code by using the new global instead.

Signed-off-by: Joe Perches <j...@perches.com>
---
 drivers/net/ethernet/marvell/mvpp2.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c 
b/drivers/net/ethernet/marvell/mvpp2.c
index 7fc1bbf51c44..a848b92f5961 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -7345,11 +7345,9 @@ static int mvpp2_open(struct net_device *dev)
 {
struct mvpp2_port *port = netdev_priv(dev);
struct mvpp2 *priv = port->priv;
-   unsigned char mac_bcast[ETH_ALEN] = {
-   0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
int err;
 
-   err = mvpp2_prs_mac_da_accept(port, mac_bcast, true);
+   err = mvpp2_prs_mac_da_accept(port, ether_broadcast_addr, true);
if (err) {
netdev_err(dev, "mvpp2_prs_mac_da_accept BC failed\n");
return err;
-- 
2.15.0



[PATCH 12/12] ethernet: Use ether_zero_addr instead of local statics

2018-03-31 Thread Joe Perches
This saves a small amount of object code.

Miscellanea:

o __b44_cam_write now use const u8 *data instead of unsigned char *
  to avoid compiler warnings as it doesn't modify data

Signed-off-by: Joe Perches <j...@perches.com>
---
 drivers/net/ethernet/broadcom/b44.c  | 5 ++---
 drivers/net/ethernet/freescale/gianfar.c | 3 +--
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/b44.c 
b/drivers/net/ethernet/broadcom/b44.c
index e445ab724827..30879ff7de19 100644
--- a/drivers/net/ethernet/broadcom/b44.c
+++ b/drivers/net/ethernet/broadcom/b44.c
@@ -220,7 +220,7 @@ static inline void __b44_cam_read(struct b44 *bp, unsigned 
char *data, int index
data[1] = (val >> 0) & 0xFF;
 }
 
-static inline void __b44_cam_write(struct b44 *bp, unsigned char *data, int 
index)
+static inline void __b44_cam_write(struct b44 *bp, const u8 *data, int index)
 {
u32 val;
 
@@ -1744,7 +1744,6 @@ static void __b44_set_rx_mode(struct net_device *dev)
val |= RXCONFIG_PROMISC;
bw32(bp, B44_RXCONFIG, val);
} else {
-   unsigned char zero[6] = {0, 0, 0, 0, 0, 0};
int i = 1;
 
__b44_set_mac_addr(bp);
@@ -1756,7 +1755,7 @@ static void __b44_set_rx_mode(struct net_device *dev)
i = __b44_load_mcast(bp, dev);
 
for (; i < 64; i++)
-   __b44_cam_write(bp, zero, i);
+   __b44_cam_write(bp, ether_zero_addr, i);
 
bw32(bp, B44_RXCONFIG, val);
val = br32(bp, B44_CAM_CTRL);
diff --git a/drivers/net/ethernet/freescale/gianfar.c 
b/drivers/net/ethernet/freescale/gianfar.c
index f27f9bae1a4a..24d8c85f8f4e 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -3501,10 +3501,9 @@ static void gfar_set_multi(struct net_device *dev)
 static void gfar_clear_exact_match(struct net_device *dev)
 {
int idx;
-   static const u8 zero_arr[ETH_ALEN] = {0, 0, 0, 0, 0, 0};
 
for (idx = 1; idx < GFAR_EM_NUM + 1; idx++)
-   gfar_set_mac_for_addr(dev, idx, zero_arr);
+   gfar_set_mac_for_addr(dev, idx, ether_zero_addr);
 }
 
 /* Set the appropriate hash bit for the given addr */
-- 
2.15.0



[PATCH 09/12] iwlwifi: Remove local iwl_bcast_addr and use ether_broadcast_addr

2018-03-31 Thread Joe Perches
Use the new global to save a little bit of object code.

Signed-off-by: Joe Perches <j...@perches.com>
---
 drivers/net/wireless/intel/iwlwifi/dvm/dev.h  | 1 -
 drivers/net/wireless/intel/iwlwifi/dvm/scan.c | 2 +-
 drivers/net/wireless/intel/iwlwifi/dvm/sta.c  | 4 +---
 3 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/dev.h 
b/drivers/net/wireless/intel/iwlwifi/dvm/dev.h
index cceb4cd8e501..157cc21c5dfb 100644
--- a/drivers/net/wireless/intel/iwlwifi/dvm/dev.h
+++ b/drivers/net/wireless/intel/iwlwifi/dvm/dev.h
@@ -271,7 +271,6 @@ struct iwl_sensitivity_ranges {
  *
  /
 void iwl_update_chain_flags(struct iwl_priv *priv);
-extern const u8 iwl_bcast_addr[ETH_ALEN];
 
 #define IWL_OPERATION_MODE_AUTO 0
 #define IWL_OPERATION_MODE_HT_ONLY  1
diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/scan.c 
b/drivers/net/wireless/intel/iwlwifi/dvm/scan.c
index 17e6a32384d3..e40d9b9fc4a9 100644
--- a/drivers/net/wireless/intel/iwlwifi/dvm/scan.c
+++ b/drivers/net/wireless/intel/iwlwifi/dvm/scan.c
@@ -871,7 +871,7 @@ static int iwlagn_request_scan(struct iwl_priv *priv, 
struct ieee80211_vif *vif)
/* use bcast addr, will not be transmitted but must be valid */
cmd_len = iwl_fill_probe_req(
(struct ieee80211_mgmt *)scan->data,
-   iwl_bcast_addr, NULL, 0,
+   ether_broadcast_addr, NULL, 0,
NULL, 0,
scan_cmd_size - sizeof(*scan));
break;
diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/sta.c 
b/drivers/net/wireless/intel/iwlwifi/dvm/sta.c
index de6ec9b7ace4..177a366f7ad3 100644
--- a/drivers/net/wireless/intel/iwlwifi/dvm/sta.c
+++ b/drivers/net/wireless/intel/iwlwifi/dvm/sta.c
@@ -32,8 +32,6 @@
 #include "dev.h"
 #include "agn.h"
 
-const u8 iwl_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
-
 static int iwl_sta_ucode_activate(struct iwl_priv *priv, u8 sta_id)
 {
lockdep_assert_held(>sta_lock);
@@ -1287,7 +1285,7 @@ int iwlagn_alloc_bcast_station(struct iwl_priv *priv,
u8 sta_id;
 
spin_lock_bh(>sta_lock);
-   sta_id = iwl_prep_station(priv, ctx, iwl_bcast_addr, false, NULL);
+   sta_id = iwl_prep_station(priv, ctx, ether_broadcast_addr, false, NULL);
if (sta_id == IWL_INVALID_STATION) {
IWL_ERR(priv, "Unable to prepare broadcast station\n");
spin_unlock_bh(>sta_lock);
-- 
2.15.0



[PATCH 11/12] qlogic: Convert local bcast_addr to global ether_broadcast_addr

2018-03-31 Thread Joe Perches
Use the new global instead of local statics to save a bit of object code.

Signed-off-by: Joe Perches <j...@perches.com>
---
 drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c   | 5 +
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c   | 6 ++
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c | 6 ++
 3 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c 
b/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c
index 1cd39c9a0345..bd21aa3d5833 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c
@@ -668,9 +668,6 @@ static void netxen_p3_nic_set_multi(struct net_device 
*netdev)
 {
struct netxen_adapter *adapter = netdev_priv(netdev);
struct netdev_hw_addr *ha;
-   static const u8 bcast_addr[ETH_ALEN] = {
-   0xff, 0xff, 0xff, 0xff, 0xff, 0xff
-   };
u32 mode = VPORT_MISS_MODE_DROP;
LIST_HEAD(del_list);
struct list_head *head;
@@ -682,7 +679,7 @@ static void netxen_p3_nic_set_multi(struct net_device 
*netdev)
list_splice_tail_init(>mac_list, _list);
 
nx_p3_nic_add_mac(adapter, adapter->mac_addr, _list);
-   nx_p3_nic_add_mac(adapter, bcast_addr, _list);
+   nx_p3_nic_add_mac(adapter, ether_broadcast_addr, _list);
 
if (netdev->flags & IFF_PROMISC) {
mode = VPORT_MISS_MODE_ACCEPT_ALL;
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c 
b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c
index 7848cf04b29a..948cb7ae9758 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c
@@ -542,9 +542,6 @@ static void __qlcnic_set_multi(struct net_device *netdev, 
u16 vlan)
struct qlcnic_adapter *adapter = netdev_priv(netdev);
struct qlcnic_hardware_context *ahw = adapter->ahw;
struct netdev_hw_addr *ha;
-   static const u8 bcast_addr[ETH_ALEN] = {
-   0xff, 0xff, 0xff, 0xff, 0xff, 0xff
-   };
u32 mode = VPORT_MISS_MODE_DROP;
 
if (!test_bit(__QLCNIC_FW_ATTACHED, >state))
@@ -552,7 +549,8 @@ static void __qlcnic_set_multi(struct net_device *netdev, 
u16 vlan)
 
qlcnic_nic_add_mac(adapter, adapter->mac_addr, vlan,
   QLCNIC_UNICAST_MAC);
-   qlcnic_nic_add_mac(adapter, bcast_addr, vlan, QLCNIC_BROADCAST_MAC);
+   qlcnic_nic_add_mac(adapter, ether_broadcast_addr, vlan,
+  QLCNIC_BROADCAST_MAC);
 
if (netdev->flags & IFF_PROMISC) {
if (!(adapter->flags & QLCNIC_PROMISC_DISABLED))
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c 
b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
index c58180f40844..17dd0a1353f2 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
@@ -1546,9 +1546,6 @@ void qlcnic_sriov_vf_set_multi(struct net_device *netdev)
 {
struct qlcnic_adapter *adapter = netdev_priv(netdev);
struct qlcnic_hardware_context *ahw = adapter->ahw;
-   static const u8 bcast_addr[ETH_ALEN] = {
-   0xff, 0xff, 0xff, 0xff, 0xff, 0xff
-   };
struct netdev_hw_addr *ha;
u32 mode = VPORT_MISS_MODE_DROP;
 
@@ -1562,7 +1559,8 @@ void qlcnic_sriov_vf_set_multi(struct net_device *netdev)
   (netdev_mc_count(netdev) > ahw->max_mc_count)) {
mode = VPORT_MISS_MODE_ACCEPT_MULTI;
} else {
-   qlcnic_vf_add_mc_list(netdev, bcast_addr, QLCNIC_BROADCAST_MAC);
+   qlcnic_vf_add_mc_list(netdev, ether_broadcast_addr,
+ QLCNIC_BROADCAST_MAC);
if (!netdev_mc_empty(netdev)) {
qlcnic_flush_mcast_mac(adapter);
netdev_for_each_mc_addr(ha, netdev)
-- 
2.15.0



[PATCH] ethernet: hisilicon: hns: hns_dsaf_mac: Use generic eth_broadcast_addr

2018-03-30 Thread Joe Perches
Rather than use an on-stack array to copy a broadcast address, use
the generic eth_broadcast_addr function to save a trivial amount of
object code.

Signed-off-by: Joe Perches <j...@perches.com>
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
index cac86e9ae0dd..9dcc5765f11f 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
@@ -369,7 +369,6 @@ static int hns_mac_port_config_bc_en(struct hns_mac_cb 
*mac_cb,
 {
int ret;
struct dsaf_device *dsaf_dev = mac_cb->dsaf_dev;
-   u8 addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
struct dsaf_drv_mac_single_dest_entry mac_entry;
 
/* directy return ok in debug network mode */
@@ -377,7 +376,7 @@ static int hns_mac_port_config_bc_en(struct hns_mac_cb 
*mac_cb,
return 0;
 
if (!HNS_DSAF_IS_DEBUG(dsaf_dev)) {
-   memcpy(mac_entry.addr, addr, sizeof(mac_entry.addr));
+   eth_broadcast_addr(mac_entry.addr);
mac_entry.in_vlan_id = vlan_id;
mac_entry.in_port_num = mac_cb->mac_id;
mac_entry.port_num = port_num;
@@ -404,7 +403,6 @@ int hns_mac_vm_config_bc_en(struct hns_mac_cb *mac_cb, u32 
vmid, bool enable)
int ret;
struct dsaf_device *dsaf_dev = mac_cb->dsaf_dev;
u8 port_num;
-   u8 addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
struct mac_entry_idx *uc_mac_entry;
struct dsaf_drv_mac_single_dest_entry mac_entry;
 
@@ -414,7 +412,7 @@ int hns_mac_vm_config_bc_en(struct hns_mac_cb *mac_cb, u32 
vmid, bool enable)
uc_mac_entry = _cb->addr_entry_idx[vmid];
 
if (!HNS_DSAF_IS_DEBUG(dsaf_dev))  {
-   memcpy(mac_entry.addr, addr, sizeof(mac_entry.addr));
+   eth_broadcast_addr(mac_entry.addr);
mac_entry.in_vlan_id = uc_mac_entry->vlan_id;
mac_entry.in_port_num = mac_cb->mac_id;
ret = hns_mac_get_inner_port_num(mac_cb, vmid, _num);
-- 
2.15.0



Re: [PATCH] ISDN: eicon: message: remove redundant check

2018-03-30 Thread Joe Perches
On Fri, 2018-03-30 at 10:46 -0500, Gustavo A. R. Silva wrote:
> Check on plci->internal_command is unnecessary.

Probably all of these are unnecessary too:

$ for length in {7..2} ; do \
grep-2.5.4 -rP --include=*.[ch] -n 
"^\t{$length,$length}break;\n\t{$(($length-1)),$(($length-1))}break;" * ; \
  done
drivers/staging/wilc1000/wilc_wlan.c:691:   break;
break;
drivers/media/dvb-frontends/drxd_hard.c:2261:   break;
break;
drivers/media/dvb-frontends/drxd_hard.c:2266:   break;
break;
drivers/media/usb/gspca/sn9c20x.c:1860: break;
break;
drivers/isdn/i4l/isdn_common.c:624: break;
break;
drivers/isdn/i4l/isdn_common.c:642: break;
break;
drivers/isdn/i4l/isdn_common.c:654: break;
break;
drivers/isdn/hardware/eicon/message.c:13890:break;
break;
sound/usb/mixer_quirks.c:1832:  break;
break;



Re: [PATCH] sfp: allow cotsworks modules

2018-03-28 Thread Joe Perches
On Wed, 2018-03-28 at 17:51 +0100, Russell King - ARM Linux wrote:
> On Wed, Mar 28, 2018 at 09:19:01AM -0700, Joe Perches wrote:
> > On Wed, 2018-03-28 at 11:41 +0100, Russell King - ARM Linux wrote:
> > > On Wed, Mar 28, 2018 at 03:33:57AM -0700, Joe Perches wrote:
> > > > On Wed, 2018-03-28 at 11:18 +0100, Russell King wrote:
> > > > > Cotsworks modules fail the checksums - it appears that Cotsworks
> > > > > reprograms the EEPROM at the end of production with the final product
> > > > > information (serial, date code, and exact part number for module
> > > > > options) and fails to update the checksum.
> > > > 
> > > > trivia:
> > > > 
> > > > > diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
> > > > 
> > > > []
> > > > > @@ -574,23 +575,43 @@ static int sfp_sm_mod_probe(struct sfp *sfp)
> > > > 
> > > > []
> > > > > + if (cotsworks) {
> > > > > + dev_warn(sfp->dev,
> > > > > +  "EEPROM base structure checksum 
> > > > > failure (0x%02x != 0x%02x)\n",
> > > > > +  check, id.base.cc_base);
> > > > > + } else {
> > > > > + dev_err(sfp->dev,
> > > > > + "EEPROM base structure checksum 
> > > > > failure: 0x%02x != 0x%02x\n",
> > > > 
> > > > It'd be better to move this above the if and
> > > > use only a single format string instead of
> > > > using 2 slightly different formats.
> > > 
> > > No.  I think you've missed the fact that one is a _warning_ the other is
> > > an _error_ and they are emitted at the appropriate severity.  It's not
> > > just that the format strings are slightly different.
> > 
> > Right.  Still nicer to use the same formats.
> 
> I'll stick a "Warning:" and "Error:" tag before them if you really
> want the rest of the message to be identically formatted - otherwise,
> when seeing reports from people's dmesg, there will be nothing to
> indicate which message was printed.

Not necessary.  It was just a trivial size saving
from the format deduplication.

There is another dmesg info line

dev_info(sfp->dev, "module %.*s %.*s rev %.*s sn %.*s dc %.*s\n",
 (int)sizeof(id.base.vendor_name), id.base.vendor_name,
 (int)sizeof(id.base.vendor_pn), id.base.vendor_pn,
 (int)sizeof(id.base.vendor_rev), id.base.vendor_rev,
 (int)sizeof(id.ext.vendor_sn), id.ext.vendor_sn,
 (int)sizeof(id.ext.datecode), id.ext.datecode);

the next line later which shows that it's a "COTSWORKS   ".



Re: [PATCH] sfp: allow cotsworks modules

2018-03-28 Thread Joe Perches
On Wed, 2018-03-28 at 11:41 +0100, Russell King - ARM Linux wrote:
> On Wed, Mar 28, 2018 at 03:33:57AM -0700, Joe Perches wrote:
> > On Wed, 2018-03-28 at 11:18 +0100, Russell King wrote:
> > > Cotsworks modules fail the checksums - it appears that Cotsworks
> > > reprograms the EEPROM at the end of production with the final product
> > > information (serial, date code, and exact part number for module
> > > options) and fails to update the checksum.
> > 
> > trivia:
> > 
> > > diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
> > 
> > []
> > > @@ -574,23 +575,43 @@ static int sfp_sm_mod_probe(struct sfp *sfp)
> > 
> > []
> > > + if (cotsworks) {
> > > + dev_warn(sfp->dev,
> > > +  "EEPROM base structure checksum failure 
> > > (0x%02x != 0x%02x)\n",
> > > +  check, id.base.cc_base);
> > > + } else {
> > > + dev_err(sfp->dev,
> > > + "EEPROM base structure checksum failure: 0x%02x 
> > > != 0x%02x\n",
> > 
> > It'd be better to move this above the if and
> > use only a single format string instead of
> > using 2 slightly different formats.
> 
> No.  I think you've missed the fact that one is a _warning_ the other is
> an _error_ and they are emitted at the appropriate severity.  It's not
> just that the format strings are slightly different.

Right.  Still nicer to use the same formats.

cheers, Joe



Re: [PATCH] sfp: allow cotsworks modules

2018-03-28 Thread Joe Perches
On Wed, 2018-03-28 at 11:18 +0100, Russell King wrote:
> Cotsworks modules fail the checksums - it appears that Cotsworks
> reprograms the EEPROM at the end of production with the final product
> information (serial, date code, and exact part number for module
> options) and fails to update the checksum.

trivia:

> diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
[]
> @@ -574,23 +575,43 @@ static int sfp_sm_mod_probe(struct sfp *sfp)
[]
> + if (cotsworks) {
> + dev_warn(sfp->dev,
> +  "EEPROM base structure checksum failure 
> (0x%02x != 0x%02x)\n",
> +  check, id.base.cc_base);
> + } else {
> + dev_err(sfp->dev,
> + "EEPROM base structure checksum failure: 0x%02x 
> != 0x%02x\n",

It'd be better to move this above the if and
use only a single format string instead of
using 2 slightly different formats.

> + check, id.base.cc_base);
> + print_hex_dump(KERN_ERR, "sfp EE: ", DUMP_PREFIX_OFFSET,
> +16, 1, , sizeof(id), true);
> + return -EINVAL;
> + }
>   }
>  
>   check = sfp_check(, sizeof(id.ext) - 1);
>   if (check != id.ext.cc_ext) {
> - dev_err(sfp->dev,
> - "EEPROM extended structure checksum failure: 0x%02x\n",
> - check);
> - memset(, 0, sizeof(id.ext));
> + if (cotsworks) {
> + dev_warn(sfp->dev,
> +  "EEPROM extended structure checksum failure 
> (0x%02x != 0x%02x)\n",
> +  check, id.ext.cc_ext);
> + } else {
> + dev_err(sfp->dev,
> + "EEPROM extended structure checksum failure: 
> 0x%02x != 0x%02x\n",
> + check, id.ext.cc_ext);


here too



[resend PATCH] rxrpc: Neaten logging macros and add KERN_DEBUG logging level

2018-03-27 Thread Joe Perches
When enabled, the current debug logging does not have a KERN_.
Add KERN_DEBUG to the logging macros.

Miscellanea:

o Remove #define redundancy and neaten the macros a bit

Signed-off-by: Joe Perches <j...@perches.com>
---

Resend of patch: https://lkml.org/lkml/2017/11/30/573

No change in patch.

David Howells is now a listed maintainer for net/rxrpc/ so he should receive
this patch via get_maintainer

 net/rxrpc/ar-internal.h | 75 ++---
 1 file changed, 28 insertions(+), 47 deletions(-)

diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
index 416688381eb7..d4b53b2339b3 100644
--- a/net/rxrpc/ar-internal.h
+++ b/net/rxrpc/ar-internal.h
@@ -1147,66 +1147,47 @@ static inline bool after_eq(u32 seq1, u32 seq2)
  */
 extern unsigned int rxrpc_debug;
 
-#define dbgprintk(FMT,...) \
-   printk("[%-6.6s] "FMT"\n", current->comm ,##__VA_ARGS__)
+#if defined(__KDEBUG) || defined(CONFIG_AF_RXRPC_DEBUG)
+#define dbgprintk(fmt, ...)\
+   printk(KERN_DEBUG "[%-6.6s] " fmt "\n", current->comm, ##__VA_ARGS__)
+#else
+#define dbgprintk(fmt, ...)\
+   no_printk(KERN_DEBUG "[%-6.6s] " fmt "\n", current->comm, ##__VA_ARGS__)
+#endif
 
-#define kenter(FMT,...)dbgprintk("==> %s("FMT")",__func__ 
,##__VA_ARGS__)
-#define kleave(FMT,...)dbgprintk("<== %s()"FMT"",__func__ 
,##__VA_ARGS__)
-#define kdebug(FMT,...)dbgprintk(""FMT ,##__VA_ARGS__)
-#define kproto(FMT,...)dbgprintk("### "FMT ,##__VA_ARGS__)
-#define knet(FMT,...)  dbgprintk("@@@ "FMT ,##__VA_ARGS__)
+#define kenter(fmt, ...)   dbgprintk("==> %s(" fmt ")", __func__, 
##__VA_ARGS__)
+#define kleave(fmt, ...)   dbgprintk("<== %s()" fmt "", __func__, 
##__VA_ARGS__)
+#define kdebug(fmt, ...)   dbgprintk("" fmt, ##__VA_ARGS__)
+#define kproto(fmt, ...)   dbgprintk("### " fmt, ##__VA_ARGS__)
+#define knet(fmt, ...) dbgprintk("@@@ " fmt, ##__VA_ARGS__)
 
+#if defined(__KDEBUG) || !defined(CONFIG_AF_RXRPC_DEBUG)
+#define _enter(fmt, ...)   kenter(fmt, ##__VA_ARGS__)
+#define _leave(fmt, ...)   kleave(fmt, ##__VA_ARGS__)
+#define _debug(fmt, ...)   kdebug(fmt, ##__VA_ARGS__)
+#define _proto(fmt, ...)   kproto(fmt, ##__VA_ARGS__)
+#define _net(fmt, ...) knet(fmt, ##__VA_ARGS__)
 
-#if defined(__KDEBUG)
-#define _enter(FMT,...)kenter(FMT,##__VA_ARGS__)
-#define _leave(FMT,...)kleave(FMT,##__VA_ARGS__)
-#define _debug(FMT,...)kdebug(FMT,##__VA_ARGS__)
-#define _proto(FMT,...)kproto(FMT,##__VA_ARGS__)
-#define _net(FMT,...)  knet(FMT,##__VA_ARGS__)
+#else
 
-#elif defined(CONFIG_AF_RXRPC_DEBUG)
 #define RXRPC_DEBUG_KENTER 0x01
 #define RXRPC_DEBUG_KLEAVE 0x02
 #define RXRPC_DEBUG_KDEBUG 0x04
 #define RXRPC_DEBUG_KPROTO 0x08
 #define RXRPC_DEBUG_KNET   0x10
 
-#define _enter(FMT,...)\
-do {   \
-   if (unlikely(rxrpc_debug & RXRPC_DEBUG_KENTER)) \
-   kenter(FMT,##__VA_ARGS__);  \
-} while (0)
-
-#define _leave(FMT,...)\
-do {   \
-   if (unlikely(rxrpc_debug & RXRPC_DEBUG_KLEAVE)) \
-   kleave(FMT,##__VA_ARGS__);  \
-} while (0)
-
-#define _debug(FMT,...)\
-do {   \
-   if (unlikely(rxrpc_debug & RXRPC_DEBUG_KDEBUG)) \
-   kdebug(FMT,##__VA_ARGS__);  \
-} while (0)
-
-#define _proto(FMT,...)\
-do {   \
-   if (unlikely(rxrpc_debug & RXRPC_DEBUG_KPROTO)) \
-   kproto(FMT,##__VA_ARGS__);  \
+#define RXRPC_DEBUG(TYPE, type, fmt, ...)  \
+do {   \
+   if (unlikely(rxrpc_debug & RXRPC_DEBUG_##TYPE)) \
+   type(fmt, ##__VA_ARGS__);   \
 } while (0)
 
-#define _net(FMT,...)  \
-do {   \
-   if (unlikely(rxrpc_debug & RXRPC_DEBUG_KNET))   \
-   knet(FMT,##__VA_ARGS__);\
-} while (0)
+#define _enter(fmt, ...)   RXRPC_DEBUG(KENTER, kenter, fmt, ##__VA_ARGS__)
+#define _leave(fmt, ...)   RXRPC_DEBUG(KLEAVE, kleave, fmt, ##__VA_ARGS__)
+#define _debug(fmt, ...)   RXRPC_DEBUG(KDEBUG, kdebug, fmt, ##__VA_ARGS__)
+#define _proto(f

[PATCH] ipv6: addrconf: Use normal debugging style

2018-03-26 Thread Joe Perches
Remove local ADBG macro and use netdev_dbg/pr_debug

Miscellanea:

o Remove unnecessary debug message after allocation failure as there
  already is a dump_stack() on the failure paths
o Leave the allocation failure message on snmp6_alloc_dev as there
  is one code path that does not do a dump_stack()

Signed-off-by: Joe Perches <j...@perches.com>
---

Remerged resend of http://patchwork.ozlabs.org/patch/826028/
back in October 2017

 net/ipv6/addrconf.c | 28 
 1 file changed, 8 insertions(+), 20 deletions(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 6fd4bbdc444f..0d104bd74934 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -94,15 +94,6 @@
 #include 
 #include 
 
-/* Set to 3 to get tracing... */
-#define ACONF_DEBUG 2
-
-#if ACONF_DEBUG >= 3
-#define ADBG(fmt, ...) printk(fmt, ##__VA_ARGS__)
-#else
-#define ADBG(fmt, ...) do { if (0) printk(fmt, ##__VA_ARGS__); } while (0)
-#endif
-
 #defineINFINITY_LIFE_TIME  0x
 
 #define IPV6_MAX_STRLEN \
@@ -409,9 +400,8 @@ static struct inet6_dev *ipv6_add_dev(struct net_device 
*dev)
dev_hold(dev);
 
if (snmp6_alloc_dev(ndev) < 0) {
-   ADBG(KERN_WARNING
-   "%s: cannot allocate memory for statistics; dev=%s.\n",
-   __func__, dev->name);
+   netdev_dbg(dev, "%s: cannot allocate memory for statistics\n",
+  __func__);
neigh_parms_release(_tbl, ndev->nd_parms);
dev_put(dev);
kfree(ndev);
@@ -419,9 +409,8 @@ static struct inet6_dev *ipv6_add_dev(struct net_device 
*dev)
}
 
if (snmp6_register_dev(ndev) < 0) {
-   ADBG(KERN_WARNING
-   "%s: cannot create /proc/net/dev_snmp6/%s\n",
-   __func__, dev->name);
+   netdev_dbg(dev, "%s: cannot create /proc/net/dev_snmp6/%s\n",
+  __func__, dev->name);
goto err_release;
}
 
@@ -984,7 +973,7 @@ static int ipv6_add_addr_hash(struct net_device *dev, 
struct inet6_ifaddr *ifa)
 
/* Ignore adding duplicate addresses on an interface */
if (ipv6_chk_same_addr(dev_net(dev), >addr, dev, hash)) {
-   ADBG("ipv6_add_addr: already assigned\n");
+   netdev_dbg(dev, "ipv6_add_addr: already assigned\n");
err = -EEXIST;
} else {
hlist_add_head_rcu(>addr_lst, _addr_lst[hash]);
@@ -1044,7 +1033,6 @@ ipv6_add_addr(struct inet6_dev *idev, const struct 
in6_addr *addr,
 
ifa = kzalloc(sizeof(*ifa), gfp_flags);
if (!ifa) {
-   ADBG("ipv6_add_addr: malloc failed\n");
err = -ENOBUFS;
goto out;
}
@@ -2618,7 +2606,7 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, 
int len, bool sllao)
pinfo = (struct prefix_info *) opt;
 
if (len < sizeof(struct prefix_info)) {
-   ADBG("addrconf: prefix option too short\n");
+   netdev_dbg(dev, "addrconf: prefix option too short\n");
return;
}
 
@@ -4446,8 +4434,8 @@ static void addrconf_verify_rtnl(void)
if (time_before(next_sched, jiffies + ADDRCONF_TIMER_FUZZ_MAX))
next_sched = jiffies + ADDRCONF_TIMER_FUZZ_MAX;
 
-   ADBG(KERN_DEBUG "now = %lu, schedule = %lu, rounded schedule = %lu => 
%lu\n",
- now, next, next_sec, next_sched);
+   pr_debug("now = %lu, schedule = %lu, rounded schedule = %lu => %lu\n",
+now, next, next_sec, next_sched);
mod_delayed_work(addrconf_wq, _chk_work, next_sched - now);
rcu_read_unlock_bh();
 }
-- 
2.15.0



Re: [PATCH 2/4] wireless: Use octal not symbolic permissions

2018-03-24 Thread Joe Perches
On Sat, 2018-03-24 at 12:09 +0200, Kalle Valo wrote:
> Joe Perches <j...@perches.com> writes:
> > Prefer the direct use of octal for permissions.
[]
> I don't know what tree are you planning to send these to, but I would
> prefer to take this to wireless-drivers-next to minimise any conflicts.

Fine by me.  Done against -next.


[PATCH 1/4] ethernet: Use octal not symbolic permissions

2018-03-23 Thread Joe Perches
Prefer the direct use of octal for permissions.

Done with checkpatch -f --types=SYMBOLIC_PERMS --fix-inplace
and some typing.

Miscellanea:

o Whitespace neatening around these conversions.

Signed-off-by: Joe Perches <j...@perches.com>
---
 drivers/net/ethernet/8390/apne.c   |   2 +-
 drivers/net/ethernet/8390/lib8390.c|   2 +-
 drivers/net/ethernet/8390/ne.c |   2 +-
 drivers/net/ethernet/8390/ne2k-pci.c   |   2 +-
 drivers/net/ethernet/8390/smc-ultra.c  |   2 +-
 drivers/net/ethernet/8390/stnic.c  |   2 +-
 drivers/net/ethernet/8390/wd.c |   2 +-
 drivers/net/ethernet/altera/altera_tse_main.c  |   6 +-
 drivers/net/ethernet/amd/xgbe/xgbe-drv.c   |  10 +-
 drivers/net/ethernet/amd/xgbe/xgbe-main.c  |   2 +-
 drivers/net/ethernet/broadcom/bnx2.c   |   2 +-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c   |  12 +--
 drivers/net/ethernet/broadcom/sb1250-mac.c |  10 +-
 drivers/net/ethernet/broadcom/tg3.c|   6 +-
 drivers/net/ethernet/brocade/bna/bnad.c|   2 +-
 drivers/net/ethernet/brocade/bna/bnad_debugfs.c|  10 +-
 drivers/net/ethernet/cavium/thunder/nicvf_main.c   |   2 +-
 drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c|   6 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 112 ++---
 .../net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c|  10 +-
 drivers/net/ethernet/ec_bhf.c  |   2 +-
 drivers/net/ethernet/emulex/benet/be_main.c|   6 +-
 drivers/net/ethernet/ibm/ehea/ehea_main.c  |   7 +-
 drivers/net/ethernet/ibm/ibmveth.c |   2 +-
 drivers/net/ethernet/intel/igb/igb_hwmon.c |   2 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c |   2 +-
 drivers/net/ethernet/marvell/mvneta.c  |   8 +-
 drivers/net/ethernet/marvell/skge.c|   2 +-
 drivers/net/ethernet/marvell/sky2.c|   2 +-
 drivers/net/ethernet/mellanox/mlx4/main.c  |  16 +--
 drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c   |  10 +-
 drivers/net/ethernet/myricom/myri10ge/myri10ge.c   |  32 +++---
 .../net/ethernet/netronome/nfp/nfp_net_debugfs.c   |   6 +-
 .../net/ethernet/qlogic/netxen/netxen_nic_main.c   |  14 +--
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c  |  30 +++---
 drivers/net/ethernet/qualcomm/qca_debug.c  |   2 +-
 drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c|   4 +-
 drivers/net/ethernet/sfc/mcdi_mon.c|   2 +-
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  |  26 ++---
 drivers/net/ethernet/sun/niu.c |  10 +-
 40 files changed, 194 insertions(+), 195 deletions(-)

diff --git a/drivers/net/ethernet/8390/apne.c b/drivers/net/ethernet/8390/apne.c
index c56ac9ebc08f..fe6c834c422e 100644
--- a/drivers/net/ethernet/8390/apne.c
+++ b/drivers/net/ethernet/8390/apne.c
@@ -117,7 +117,7 @@ static const char version[] =
 static int apne_owned; /* signal if card already owned */
 
 static u32 apne_msg_enable;
-module_param_named(msg_enable, apne_msg_enable, uint, 
(S_IRUSR|S_IRGRP|S_IROTH));
+module_param_named(msg_enable, apne_msg_enable, uint, 0444);
 MODULE_PARM_DESC(msg_enable, "Debug message level (see linux/netdevice.h for 
bitmap)");
 
 struct net_device * __init apne_probe(int unit)
diff --git a/drivers/net/ethernet/8390/lib8390.c 
b/drivers/net/ethernet/8390/lib8390.c
index 5d9bbde9fe68..c9c55c9eab9f 100644
--- a/drivers/net/ethernet/8390/lib8390.c
+++ b/drivers/net/ethernet/8390/lib8390.c
@@ -113,7 +113,7 @@ static void __NS8390_init(struct net_device *dev, int 
startp);
 
 static unsigned version_printed;
 static u32 msg_enable;
-module_param(msg_enable, uint, (S_IRUSR|S_IRGRP|S_IROTH));
+module_param(msg_enable, uint, 0444);
 MODULE_PARM_DESC(msg_enable, "Debug message level (see linux/netdevice.h for 
bitmap)");
 
 /*
diff --git a/drivers/net/ethernet/8390/ne.c b/drivers/net/ethernet/8390/ne.c
index 44a084b41bf0..ac99d089ac72 100644
--- a/drivers/net/ethernet/8390/ne.c
+++ b/drivers/net/ethernet/8390/ne.c
@@ -77,7 +77,7 @@ static u32 ne_msg_enable;
 module_param_hw_array(io, int, ioport, NULL, 0);
 module_param_hw_array(irq, int, irq, NULL, 0);
 module_param_array(bad, int, NULL, 0);
-module_param_named(msg_enable, ne_msg_enable, uint, (S_IRUSR|S_IRGRP|S_IROTH));
+module_param_named(msg_enable, ne_msg_enable, uint, 0444);
 MODULE_PARM_DESC(io, "I/O base address(es),required");
 MODULE_PARM_DESC(irq, "IRQ number(s)");
 MODULE_PARM_DESC(bad, "Accept card(s) with bad signatures");
diff --git a/drivers/net/ethernet/8390/ne2k-pci.c 
b/drivers/net/ethernet/8390/ne2k-pci.c
index 1bdea746926c..42985a82321a 100644
--- a/drivers/net/ethernet/8390/ne2k-pci.c
+++ b/drivers/net/ethernet/8390/ne2k-pci.c
@@ -76,7 +76,7 @@ MODULE_AUTHOR("Donald Becker / Paul Gortmaker");
 MODULE_DESCRIPTION("P

[PATCH 4/4] drivers/net: Use octal not symbolic permissions

2018-03-23 Thread Joe Perches
Prefer the direct use of octal for permissions.

Done with checkpatch -f --types=SYMBOLIC_PERMS --fix-inplace
and some typing.

Miscellanea:

o Whitespace neatening around these conversions.

Signed-off-by: Joe Perches <j...@perches.com>
---
 drivers/net/bonding/bond_procfs.c  |  2 +-
 drivers/net/bonding/bond_sysfs.c   | 73 +-
 drivers/net/bonding/bond_sysfs_slave.c |  4 +-
 drivers/net/caif/caif_serial.c | 32 +++
 drivers/net/caif/caif_spi.c| 16 
 drivers/net/caif/caif_virtio.c | 16 
 drivers/net/can/at91_can.c |  3 +-
 drivers/net/can/cc770/cc770.c  |  4 +-
 drivers/net/can/cc770/cc770_isa.c  | 16 
 drivers/net/can/grcan.c|  4 +-
 drivers/net/can/janz-ican3.c   |  6 +--
 drivers/net/can/sja1000/sja1000_isa.c  | 14 +++
 drivers/net/can/softing/softing_main.c |  4 +-
 drivers/net/can/spi/mcp251x.c  |  2 +-
 drivers/net/can/usb/esd_usb2.c |  6 +--
 drivers/net/can/vcan.c |  2 +-
 drivers/net/hamradio/bpqether.c|  3 +-
 drivers/net/hamradio/yam.c |  2 +-
 drivers/net/hyperv/netvsc_drv.c|  4 +-
 drivers/net/ieee802154/at86rf230.c |  2 +-
 drivers/net/phy/spi_ks8995.c   |  2 +-
 drivers/net/ppp/ppp_generic.c  |  2 +-
 drivers/net/ppp/pppoe.c|  2 +-
 drivers/net/usb/cdc_ncm.c  | 12 +++---
 drivers/net/usb/hso.c  |  8 ++--
 drivers/net/xen-netback/xenbus.c   |  4 +-
 drivers/net/xen-netfront.c |  6 +--
 27 files changed, 124 insertions(+), 127 deletions(-)

diff --git a/drivers/net/bonding/bond_procfs.c 
b/drivers/net/bonding/bond_procfs.c
index f7799321dffb..01059f1a7bca 100644
--- a/drivers/net/bonding/bond_procfs.c
+++ b/drivers/net/bonding/bond_procfs.c
@@ -287,7 +287,7 @@ void bond_create_proc_entry(struct bonding *bond)
 
if (bn->proc_dir) {
bond->proc_entry = proc_create_data(bond_dev->name,
-   S_IRUGO, bn->proc_dir,
+   0444, bn->proc_dir,
_info_fops, bond);
if (bond->proc_entry == NULL)
netdev_warn(bond_dev, "Cannot create /proc/net/%s/%s\n",
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 040b493f60ae..6096440e96ea 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -147,7 +147,7 @@ static ssize_t bonding_store_bonds(struct class *cls,
 static const struct class_attribute class_attr_bonding_masters = {
.attr = {
.name = "bonding_masters",
-   .mode = S_IWUSR | S_IRUGO,
+   .mode = 0644,
},
.show = bonding_show_bonds,
.store = bonding_store_bonds,
@@ -202,7 +202,7 @@ static ssize_t bonding_show_slaves(struct device *d,
 
return res;
 }
-static DEVICE_ATTR(slaves, S_IRUGO | S_IWUSR, bonding_show_slaves,
+static DEVICE_ATTR(slaves, 0644, bonding_show_slaves,
   bonding_sysfs_store_option);
 
 /* Show the bonding mode. */
@@ -216,8 +216,7 @@ static ssize_t bonding_show_mode(struct device *d,
 
return sprintf(buf, "%s %d\n", val->string, BOND_MODE(bond));
 }
-static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR,
-  bonding_show_mode, bonding_sysfs_store_option);
+static DEVICE_ATTR(mode, 0644, bonding_show_mode, bonding_sysfs_store_option);
 
 /* Show the bonding transmit hash method. */
 static ssize_t bonding_show_xmit_hash(struct device *d,
@@ -231,7 +230,7 @@ static ssize_t bonding_show_xmit_hash(struct device *d,
 
return sprintf(buf, "%s %d\n", val->string, bond->params.xmit_policy);
 }
-static DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR,
+static DEVICE_ATTR(xmit_hash_policy, 0644,
   bonding_show_xmit_hash, bonding_sysfs_store_option);
 
 /* Show arp_validate. */
@@ -247,7 +246,7 @@ static ssize_t bonding_show_arp_validate(struct device *d,
 
return sprintf(buf, "%s %d\n", val->string, bond->params.arp_validate);
 }
-static DEVICE_ATTR(arp_validate, S_IRUGO | S_IWUSR, bonding_show_arp_validate,
+static DEVICE_ATTR(arp_validate, 0644, bonding_show_arp_validate,
   bonding_sysfs_store_option);
 
 /* Show arp_all_targets. */
@@ -263,7 +262,7 @@ static ssize_t bonding_show_arp_all_targets(struct device 
*d,
return sprintf(buf, "%s %d\n",
   val->string, bond->params.arp_all_targets);
 }
-static DEVICE_ATTR(arp_all_targets, S_IRUGO | S_IWUSR,
+static DEVICE_ATTR(arp_all_targets, 0644,
   bonding_show_arp_all_targets, bonding_sysfs_store_option);
 
 /* Show fail_over_mac. */
@@ -279,7 +278,7 @@ static ssize_

[PATCH 2/4] wireless: Use octal not symbolic permissions

2018-03-23 Thread Joe Perches
Prefer the direct use of octal for permissions.

Done with checkpatch -f --types=SYMBOLIC_PERMS --fix-inplace
and some typing.

Miscellanea:

o Whitespace neatening around these conversions.

Signed-off-by: Joe Perches <j...@perches.com>
---
 drivers/net/wireless/ath/ath5k/base.c  |   6 +-
 drivers/net/wireless/ath/ath5k/debug.c |  37 +++
 drivers/net/wireless/ath/ath5k/sysfs.c |   8 +-
 drivers/net/wireless/ath/ath6kl/debug.c|  43 
 drivers/net/wireless/ath/ath9k/common-debug.c  |   9 +-
 drivers/net/wireless/ath/ath9k/common-spectral.c   |  10 +-
 drivers/net/wireless/ath/ath9k/debug.c |  40 
 drivers/net/wireless/ath/ath9k/debug_sta.c |   6 +-
 drivers/net/wireless/ath/ath9k/dfs_debug.c |   4 +-
 drivers/net/wireless/ath/ath9k/htc_drv_debug.c |  16 +--
 drivers/net/wireless/ath/ath9k/tx99.c  |   4 +-
 drivers/net/wireless/ath/carl9170/debug.c  |   8 +-
 drivers/net/wireless/ath/carl9170/main.c   |   4 +-
 drivers/net/wireless/ath/wcn36xx/debug.c   |   5 +-
 .../wireless/broadcom/brcm80211/brcmfmac/common.c  |   6 +-
 .../wireless/broadcom/brcm80211/brcmsmac/debug.c   |   2 +-
 .../broadcom/brcm80211/brcmsmac/mac80211_if.c  |   2 +-
 drivers/net/wireless/cisco/airo.c  |   6 +-
 drivers/net/wireless/intel/ipw2x00/ipw2100.c   |  29 +++---
 drivers/net/wireless/intel/ipw2x00/ipw2200.c   |  51 +-
 drivers/net/wireless/intel/ipw2x00/libipw_module.c |   2 +-
 drivers/net/wireless/intel/iwlegacy/3945-mac.c |  35 +++
 drivers/net/wireless/intel/iwlegacy/4965-mac.c |  19 ++--
 drivers/net/wireless/intel/iwlegacy/4965-rs.c  |   8 +-
 drivers/net/wireless/intel/iwlegacy/common.c   |   4 +-
 drivers/net/wireless/intel/iwlegacy/debug.c|  58 ++-
 drivers/net/wireless/intel/iwlwifi/dvm/debugfs.c   |  78 +++
 drivers/net/wireless/intel/iwlwifi/dvm/rs.c|  16 +--
 drivers/net/wireless/intel/iwlwifi/fw/debugfs.c|   2 +-
 drivers/net/wireless/intel/iwlwifi/iwl-drv.c   |  43 
 .../net/wireless/intel/iwlwifi/mvm/debugfs-vif.c   |  40 +++-
 drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c   | 110 ++---
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c   |   6 +-
 drivers/net/wireless/intel/iwlwifi/mvm/rs.c|  12 +--
 drivers/net/wireless/intel/iwlwifi/pcie/trans.c|  12 +--
 drivers/net/wireless/intersil/p54/main.c   |   2 +-
 drivers/net/wireless/mediatek/mt76/debugfs.c   |  10 +-
 .../net/wireless/mediatek/mt76/mt76x2_debugfs.c|   8 +-
 drivers/net/wireless/mediatek/mt7601u/debugfs.c|  16 ++-
 drivers/net/wireless/ralink/rt2x00/rt2500usb.c |   2 +-
 drivers/net/wireless/ralink/rt2x00/rt2800pci.c |   2 +-
 drivers/net/wireless/ralink/rt2x00/rt2800soc.c |   2 +-
 drivers/net/wireless/ralink/rt2x00/rt2800usb.c |   2 +-
 drivers/net/wireless/ralink/rt2x00/rt2x00debug.c   |  64 ++--
 drivers/net/wireless/ralink/rt2x00/rt61pci.c   |   2 +-
 drivers/net/wireless/ralink/rt2x00/rt73usb.c   |   2 +-
 drivers/net/wireless/ray_cs.c  |   8 +-
 drivers/net/wireless/st/cw1200/debug.c |   6 +-
 drivers/net/wireless/st/cw1200/main.c  |   2 +-
 drivers/net/wireless/ti/wl18xx/main.c  |  27 +++--
 drivers/net/wireless/ti/wlcore/main.c  |   8 +-
 drivers/net/wireless/ti/wlcore/sdio.c  |   2 +-
 drivers/net/wireless/ti/wlcore/sysfs.c |   7 +-
 53 files changed, 427 insertions(+), 486 deletions(-)

diff --git a/drivers/net/wireless/ath/ath5k/base.c 
b/drivers/net/wireless/ath/ath5k/base.c
index 527afcf39246..a2351ef45ae0 100644
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -73,16 +73,16 @@
 #include "trace.h"
 
 bool ath5k_modparam_nohwcrypt;
-module_param_named(nohwcrypt, ath5k_modparam_nohwcrypt, bool, S_IRUGO);
+module_param_named(nohwcrypt, ath5k_modparam_nohwcrypt, bool, 0444);
 MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption.");
 
 static bool modparam_fastchanswitch;
-module_param_named(fastchanswitch, modparam_fastchanswitch, bool, S_IRUGO);
+module_param_named(fastchanswitch, modparam_fastchanswitch, bool, 0444);
 MODULE_PARM_DESC(fastchanswitch, "Enable fast channel switching for 
AR2413/AR5413 radios.");
 
 static bool ath5k_modparam_no_hw_rfkill_switch;
 module_param_named(no_hw_rfkill_switch, ath5k_modparam_no_hw_rfkill_switch,
-   bool, S_IRUGO);
+  bool, 0444);
 MODULE_PARM_DESC(no_hw_rfkill_switch, "Ignore the GPIO RFKill switch state");
 
 
diff --git a/drivers/net/wireless/ath/ath5k/debug.c 
b/drivers/net/wireless/ath/ath5k/debug.c
index bd7f6d7b199e..3513bbec4639 100644
--- a/drivers/net/wireless/ath/ath5k/debug.c
+++ b/drivers/net/w

[PATCH 3/4] net: Use octal not symbolic permissions

2018-03-23 Thread Joe Perches
Prefer the direct use of octal for permissions.

Done with checkpatch -f --types=SYMBOLIC_PERMS --fix-inplace
and some typing.

Miscellanea:

o Whitespace neatening around these conversions.

Signed-off-by: Joe Perches <j...@perches.com>
---
 net/8021q/vlanproc.c   |  6 ++---
 net/appletalk/atalk_proc.c |  8 +++---
 net/atm/atm_sysfs.c| 12 -
 net/atm/clip.c |  2 +-
 net/atm/lec.c  |  2 +-
 net/atm/proc.c |  2 +-
 net/ax25/af_ax25.c |  6 ++---
 net/bluetooth/rfcomm/tty.c |  4 +--
 net/bridge/br_sysfs_br.c   |  2 +-
 net/bridge/br_sysfs_if.c   | 36 -
 net/can/af_can.c   |  2 +-
 net/can/gw.c   |  2 +-
 net/ceph/ceph_common.c |  2 +-
 net/core/net-procfs.c  |  6 ++---
 net/core/net-sysfs.c   | 12 -
 net/core/sock.c|  2 +-
 net/decnet/af_decnet.c |  2 +-
 net/decnet/dn_dev.c|  2 +-
 net/decnet/dn_neigh.c  |  2 +-
 net/decnet/dn_route.c  |  2 +-
 net/dns_resolver/dns_key.c |  2 +-
 net/ipv4/arp.c |  2 +-
 net/ipv4/fib_trie.c|  6 ++---
 net/ipv4/igmp.c|  4 +--
 net/ipv4/ipconfig.c|  2 +-
 net/ipv4/netfilter/ipt_CLUSTERIP.c |  2 +-
 net/ipv4/ping.c|  2 +-
 net/ipv4/proc.c|  6 ++---
 net/ipv4/raw.c |  2 +-
 net/ipv4/route.c   |  4 +--
 net/ipv4/tcp_ipv4.c|  2 +-
 net/ipv4/udp.c |  2 +-
 net/ipv6/addrconf.c|  2 +-
 net/ipv6/anycast.c |  2 +-
 net/ipv6/ip6_flowlabel.c   |  2 +-
 net/ipv6/mcast.c   |  4 +--
 net/ipv6/proc.c|  6 ++---
 net/ipv6/raw.c |  2 +-
 net/ipv6/route.c   |  2 +-
 net/kcm/kcmproc.c  |  4 +--
 net/l2tp/l2tp_ppp.c|  2 +-
 net/llc/llc_proc.c |  4 +--
 net/mac80211/rc80211_minstrel.c|  2 +-
 net/mac80211/rc80211_minstrel_debugfs.c|  8 +++---
 net/mac80211/rc80211_minstrel_ht_debugfs.c |  8 +++---
 net/netfilter/nf_conntrack_netbios_ns.c|  2 +-
 net/netfilter/nf_conntrack_snmp.c  |  2 +-
 net/netfilter/nf_conntrack_standalone.c|  2 +-
 net/netfilter/nf_log.c |  2 +-
 net/netfilter/nf_synproxy_core.c   |  2 +-
 net/netfilter/xt_IDLETIMER.c   |  2 +-
 net/netfilter/xt_recent.c  |  4 +--
 net/netrom/af_netrom.c |  6 ++---
 net/rose/af_rose.c |  8 +++---
 net/rxrpc/af_rxrpc.c   |  2 +-
 net/sctp/proc.c| 16 ++--
 net/sunrpc/auth_gss/svcauth_gss.c  |  2 +-
 net/sunrpc/cache.c | 10 +++
 net/sunrpc/debugfs.c   |  6 ++---
 net/sunrpc/rpc_pipe.c  | 42 +++---
 net/wireless/wext-proc.c   |  2 +-
 net/x25/x25_proc.c | 12 -
 net/xfrm/xfrm_proc.c   |  2 +-
 63 files changed, 161 insertions(+), 161 deletions(-)

diff --git a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c
index a662ccc166df..a627a5db2125 100644
--- a/net/8021q/vlanproc.c
+++ b/net/8021q/vlanproc.c
@@ -148,8 +148,8 @@ int __net_init vlan_proc_init(struct net *net)
if (!vn->proc_vlan_dir)
goto err;
 
-   vn->proc_vlan_conf = proc_create(name_conf, S_IFREG|S_IRUSR|S_IWUSR,
-vn->proc_vlan_dir, _fops);
+   vn->proc_vlan_conf = proc_create(name_conf, S_IFREG | 0600,
+vn->proc_vlan_dir, _fops);
if (!vn->proc_vlan_conf)
goto err;
return 0;
@@ -172,7 +172,7 @@ int vlan_proc_add_dev(struct net_device *vlandev)
if (!strcmp(vlandev->name, name_conf))
return -EINVAL;
vlan->dent =
-   proc_create_data(vlandev->name, S_IFREG|S_IRUSR|S_IWUSR,
+   proc_create_data(vlandev->name, S_IFREG | 0600,
 vn->proc_vlan_dir, _fops, vlandev);
if (!vlan->dent)
return -ENOBUFS;
diff --git a/net/appletalk/atalk_proc.c b/net/appletalk/atalk_proc.c
index a3bf9d519193..7214aea14cb3 100644
--- a/net/appletalk/atalk_proc.c
+++ b/net/appletalk/atalk_proc.c
@@ -25

[PATCH 0/4] net: drivers/net: Use octal permissions

2018-03-23 Thread Joe Perches
Using octal and not symbolic permissions is preferred by many as
more readable.

https://lkml.org/lkml/2016/8/2/1945

Rather than getting these piecemeal, just do them all.
Done with checkpatch and some typing.

Joe Perches (4):
  ethernet: Use octal not symbolic permissions
  wireless: Use octal not symbolic permissions
  net: Use octal not symbolic permissions
  drivers/net: Use octal not symbolic permissions

 drivers/net/bonding/bond_procfs.c  |   2 +-
 drivers/net/bonding/bond_sysfs.c   |  73 +++---
 drivers/net/bonding/bond_sysfs_slave.c |   4 +-
 drivers/net/caif/caif_serial.c |  32 +++---
 drivers/net/caif/caif_spi.c|  16 +--
 drivers/net/caif/caif_virtio.c |  16 +--
 drivers/net/can/at91_can.c |   3 +-
 drivers/net/can/cc770/cc770.c  |   4 +-
 drivers/net/can/cc770/cc770_isa.c  |  16 +--
 drivers/net/can/grcan.c|   4 +-
 drivers/net/can/janz-ican3.c   |   6 +-
 drivers/net/can/sja1000/sja1000_isa.c  |  14 +--
 drivers/net/can/softing/softing_main.c |   4 +-
 drivers/net/can/spi/mcp251x.c  |   2 +-
 drivers/net/can/usb/esd_usb2.c |   6 +-
 drivers/net/can/vcan.c |   2 +-
 drivers/net/ethernet/8390/apne.c   |   2 +-
 drivers/net/ethernet/8390/lib8390.c|   2 +-
 drivers/net/ethernet/8390/ne.c |   2 +-
 drivers/net/ethernet/8390/ne2k-pci.c   |   2 +-
 drivers/net/ethernet/8390/smc-ultra.c  |   2 +-
 drivers/net/ethernet/8390/stnic.c  |   2 +-
 drivers/net/ethernet/8390/wd.c |   2 +-
 drivers/net/ethernet/altera/altera_tse_main.c  |   6 +-
 drivers/net/ethernet/amd/xgbe/xgbe-drv.c   |  10 +-
 drivers/net/ethernet/amd/xgbe/xgbe-main.c  |   2 +-
 drivers/net/ethernet/broadcom/bnx2.c   |   2 +-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c   |  12 +--
 drivers/net/ethernet/broadcom/sb1250-mac.c |  10 +-
 drivers/net/ethernet/broadcom/tg3.c|   6 +-
 drivers/net/ethernet/brocade/bna/bnad.c|   2 +-
 drivers/net/ethernet/brocade/bna/bnad_debugfs.c|  10 +-
 drivers/net/ethernet/cavium/thunder/nicvf_main.c   |   2 +-
 drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c|   6 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 112 ++---
 .../net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c|  10 +-
 drivers/net/ethernet/ec_bhf.c  |   2 +-
 drivers/net/ethernet/emulex/benet/be_main.c|   6 +-
 drivers/net/ethernet/ibm/ehea/ehea_main.c  |   7 +-
 drivers/net/ethernet/ibm/ibmveth.c |   2 +-
 drivers/net/ethernet/intel/igb/igb_hwmon.c |   2 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c |   2 +-
 drivers/net/ethernet/marvell/mvneta.c  |   8 +-
 drivers/net/ethernet/marvell/skge.c|   2 +-
 drivers/net/ethernet/marvell/sky2.c|   2 +-
 drivers/net/ethernet/mellanox/mlx4/main.c  |  16 +--
 drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c   |  10 +-
 drivers/net/ethernet/myricom/myri10ge/myri10ge.c   |  32 +++---
 .../net/ethernet/netronome/nfp/nfp_net_debugfs.c   |   6 +-
 .../net/ethernet/qlogic/netxen/netxen_nic_main.c   |  14 +--
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c  |  30 +++---
 drivers/net/ethernet/qualcomm/qca_debug.c  |   2 +-
 drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c|   4 +-
 drivers/net/ethernet/sfc/mcdi_mon.c|   2 +-
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  |  26 ++---
 drivers/net/ethernet/sun/niu.c |  10 +-
 drivers/net/hamradio/bpqether.c|   3 +-
 drivers/net/hamradio/yam.c |   2 +-
 drivers/net/hyperv/netvsc_drv.c|   4 +-
 drivers/net/ieee802154/at86rf230.c |   2 +-
 drivers/net/phy/spi_ks8995.c   |   2 +-
 drivers/net/ppp/ppp_generic.c  |   2 +-
 drivers/net/ppp/pppoe.c|   2 +-
 drivers/net/usb/cdc_ncm.c  |  12 +--
 drivers/net/usb/hso.c  |   8 +-
 drivers/net/wireless/ath/ath5k/base.c  |   6 +-
 drivers/net/wireless/ath/ath5k/debug.c |  37 ++-
 drivers/net/wireless/ath/ath5k/sysfs.c |   8 +-
 drivers/net/wireless/ath/ath6kl/debug.c|  43 
 drivers/net/wireless/ath/ath9k/common-debug.c  |   9 +-
 drivers/net/wireless/ath/ath9k/common-spectral.c   |  10 +-
 drivers/net/wireless/ath/ath9k/debug.c |  40 
 drivers/net/wireless/ath/ath9k/debug_sta.c |   6 +-
 drivers/net/wireless/ath/ath9k/dfs_debug.c |   4

[trivial PATCH V2] treewide: Align function definition open/close braces

2018-03-21 Thread Joe Perches
Some functions definitions have either the initial open brace and/or
the closing brace outside of column 1.

Move those braces to column 1.

This allows various function analyzers like gnu complexity to work
properly for these modified functions.

Signed-off-by: Joe Perches <j...@perches.com>
Acked-by: Andy Shevchenko <andy.shevche...@gmail.com>
Acked-by: Paul Moore <p...@paul-moore.com>
Acked-by: Alex Deucher <alexander.deuc...@amd.com>
Acked-by: Dave Chinner <dchin...@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.w...@oracle.com>
Acked-by: Alexandre Belloni <alexandre.bell...@free-electrons.com>
Acked-by: Martin K. Petersen <martin.peter...@oracle.com>
Acked-by: Takashi Iwai <ti...@suse.de>
Acked-by: Mauro Carvalho Chehab <mche...@s-opensource.com>
---

git diff -w still shows no difference.

This patch was sent but December and not applied.

As the trivial maintainer seems not active, it'd be nice if
Andrew Morton picks this up.

V2: Remove fs/xfs/libxfs/xfs_alloc.c as it's updated and remerge the rest

 arch/x86/include/asm/atomic64_32.h   |  2 +-
 drivers/acpi/custom_method.c |  2 +-
 drivers/acpi/fan.c   |  2 +-
 drivers/gpu/drm/amd/display/dc/core/dc.c |  2 +-
 drivers/media/i2c/msp3400-kthreads.c |  2 +-
 drivers/message/fusion/mptsas.c  |  2 +-
 drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c |  2 +-
 drivers/net/wireless/ath/ath9k/xmit.c|  2 +-
 drivers/platform/x86/eeepc-laptop.c  |  2 +-
 drivers/rtc/rtc-ab-b5ze-s3.c |  2 +-
 drivers/scsi/dpt_i2o.c   |  2 +-
 drivers/scsi/sym53c8xx_2/sym_glue.c  |  2 +-
 fs/locks.c   |  2 +-
 fs/ocfs2/stack_user.c|  2 +-
 fs/xfs/xfs_export.c  |  2 +-
 kernel/audit.c   |  6 +++---
 kernel/trace/trace_printk.c  |  4 ++--
 lib/raid6/sse2.c | 14 +++---
 sound/soc/fsl/fsl_dma.c  |  2 +-
 19 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/arch/x86/include/asm/atomic64_32.h 
b/arch/x86/include/asm/atomic64_32.h
index 46e1ef17d92d..92212bf0484f 100644
--- a/arch/x86/include/asm/atomic64_32.h
+++ b/arch/x86/include/asm/atomic64_32.h
@@ -123,7 +123,7 @@ static inline long long arch_atomic64_read(const atomic64_t 
*v)
long long r;
alternative_atomic64(read, "=" (r), "c" (v) : "memory");
return r;
- }
+}
 
 /**
  * arch_atomic64_add_return - add and return
diff --git a/drivers/acpi/custom_method.c b/drivers/acpi/custom_method.c
index b33fba70ec51..a07fbe999eb6 100644
--- a/drivers/acpi/custom_method.c
+++ b/drivers/acpi/custom_method.c
@@ -97,7 +97,7 @@ static void __exit acpi_custom_method_exit(void)
 {
if (cm_dentry)
debugfs_remove(cm_dentry);
- }
+}
 
 module_init(acpi_custom_method_init);
 module_exit(acpi_custom_method_exit);
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index 6cf4988206f2..3563103590c6 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -219,7 +219,7 @@ fan_set_cur_state(struct thermal_cooling_device *cdev, 
unsigned long state)
return fan_set_state_acpi4(device, state);
else
return fan_set_state(device, state);
- }
+}
 
 static const struct thermal_cooling_device_ops fan_cooling_ops = {
.get_max_state = fan_get_max_state,
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 8394d69b963f..e934326a95d3 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -588,7 +588,7 @@ static void disable_dangling_plane(struct dc *dc, struct 
dc_state *context)
  
**/
 
 struct dc *dc_create(const struct dc_init_data *init_params)
- {
+{
struct dc *dc = kzalloc(sizeof(*dc), GFP_KERNEL);
unsigned int full_pipe_count;
 
diff --git a/drivers/media/i2c/msp3400-kthreads.c 
b/drivers/media/i2c/msp3400-kthreads.c
index 4dd01e9f553b..dc6cb8d475b3 100644
--- a/drivers/media/i2c/msp3400-kthreads.c
+++ b/drivers/media/i2c/msp3400-kthreads.c
@@ -885,7 +885,7 @@ static int msp34xxg_modus(struct i2c_client *client)
 }
 
 static void msp34xxg_set_source(struct i2c_client *client, u16 reg, int in)
- {
+{
struct msp_state *state = to_state(i2c_get_clientdata(client));
int source, matrix;
 
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index 439ee9c5f535..231f3a1e27bf 100644
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -2967,7 +2967,7 @@ mp

[PATCH] bridge: netfilter: ebt_stp: Use generic functions for comparisons

2018-03-21 Thread Joe Perches
Instead of unnecessary const declarations, use the generic functions to
save a little object space.

$ size net/bridge/netfilter/ebt_stp.o*
   textdata bss dec hex filename
   1250 144   01394 572 net/bridge/netfilter/ebt_stp.o.new
   1344 144   01488 5d0 net/bridge/netfilter/ebt_stp.o.old

Signed-off-by: Joe Perches <j...@perches.com>
---
 net/bridge/netfilter/ebt_stp.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/net/bridge/netfilter/ebt_stp.c b/net/bridge/netfilter/ebt_stp.c
index 3140eb912d7e..47ba98db145d 100644
--- a/net/bridge/netfilter/ebt_stp.c
+++ b/net/bridge/netfilter/ebt_stp.c
@@ -153,8 +153,6 @@ ebt_stp_mt(const struct sk_buff *skb, struct 
xt_action_param *par)
 static int ebt_stp_mt_check(const struct xt_mtchk_param *par)
 {
const struct ebt_stp_info *info = par->matchinfo;
-   const u8 bridge_ula[6] = {0x01, 0x80, 0xc2, 0x00, 0x00, 0x00};
-   const u8 msk[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
const struct ebt_entry *e = par->entryinfo;
 
if (info->bitmask & ~EBT_STP_MASK || info->invflags & ~EBT_STP_MASK ||
@@ -162,8 +160,8 @@ static int ebt_stp_mt_check(const struct xt_mtchk_param 
*par)
return -EINVAL;
/* Make sure the match only receives stp frames */
if (!par->nft_compat &&
-   (!ether_addr_equal(e->destmac, bridge_ula) ||
-!ether_addr_equal(e->destmsk, msk) ||
+   (!ether_addr_equal(e->destmac, eth_stp_addr) ||
+!is_broadcast_ether_addr(e->destmsk) ||
 !(e->bitmask & EBT_DESTMAC)))
return -EINVAL;
 
-- 
2.15.0



[PATCH] ath: Remove unnecessary ath_bcast_mac and use eth_broadcast_addr

2018-03-21 Thread Joe Perches
Remove the static array and use the generic routine to set the
Ethernet broadcast address.

Signed-off-by: Joe Perches <j...@perches.com>
---
 drivers/net/wireless/ath/ath.h| 2 --
 drivers/net/wireless/ath/ath5k/attach.c   | 2 +-
 drivers/net/wireless/ath/ath9k/htc_drv_init.c | 2 +-
 drivers/net/wireless/ath/ath9k/init.c | 2 +-
 4 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h
index f3f2784f6ebd..7a364eca46d6 100644
--- a/drivers/net/wireless/ath/ath.h
+++ b/drivers/net/wireless/ath/ath.h
@@ -33,8 +33,6 @@
  */
 #defineATH_KEYMAX  128 /* max key cache size we handle 
*/
 
-static const u8 ath_bcast_mac[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-
 struct ath_ani {
bool caldone;
unsigned int longcal_timer;
diff --git a/drivers/net/wireless/ath/ath5k/attach.c 
b/drivers/net/wireless/ath/ath5k/attach.c
index 233054bd6b52..12d3a6c92ba4 100644
--- a/drivers/net/wireless/ath/ath5k/attach.c
+++ b/drivers/net/wireless/ath/ath5k/attach.c
@@ -327,7 +327,7 @@ int ath5k_hw_init(struct ath5k_hw *ah)
ath5k_hw_set_lladdr(ah, zero_mac);
 
/* Set BSSID to bcast address: ff:ff:ff:ff:ff:ff for now */
-   memcpy(common->curbssid, ath_bcast_mac, ETH_ALEN);
+   eth_broadcast_addr(common->curbssid);
ath5k_hw_set_bssid(ah);
ath5k_hw_set_opmode(ah, ah->opmode);
 
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c 
b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
index e89e5ef2c2a4..bf36bb2821b4 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
@@ -591,7 +591,7 @@ static void ath9k_init_misc(struct ath9k_htc_priv *priv)
 {
struct ath_common *common = ath9k_hw_common(priv->ah);
 
-   memcpy(common->bssidmask, ath_bcast_mac, ETH_ALEN);
+   eth_broadcast_addr(common->bssidmask);
 
common->last_rssi = ATH_RSSI_DUMMY_MARKER;
priv->ah->opmode = NL80211_IFTYPE_STATION;
diff --git a/drivers/net/wireless/ath/ath9k/init.c 
b/drivers/net/wireless/ath/ath9k/init.c
index e479fae5aab9..748becee3ecf 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -427,7 +427,7 @@ static void ath9k_init_misc(struct ath_softc *sc)
timer_setup(>ani.timer, ath_ani_calibrate, 0);
 
common->last_rssi = ATH_RSSI_DUMMY_MARKER;
-   memcpy(common->bssidmask, ath_bcast_mac, ETH_ALEN);
+   eth_broadcast_addr(common->bssidmask);
sc->beacon.slottime = 9;
 
for (i = 0; i < ARRAY_SIZE(sc->beacon.bslot); i++)
-- 
2.15.0



[RFC PATCH] etherdevice.h: net/core: Add ether_addrs.c and global ether__addr

2018-03-21 Thread Joe Perches
There are multiple instances of static const arrays for broadcast
and zero ethernet addresses used for various purposes.

Add const u8 ether__addr[ETH_ALEN] globals to consolidate these uses.

Miscellanea:

o Move and rename the eth_reserved_addr_base declaration to this file
  and declare it extern to avoid possible multiple static definitions
o Add compilation to the Makefile

Signed-off-by: Joe Perches <j...@perches.com>
---

Not sure this is the best place for this.  Better ideas welcomed.

 include/linux/etherdevice.h | 12 
 net/core/Makefile   |  3 ++-
 net/core/ether_addrs.c  | 16 
 3 files changed, 26 insertions(+), 5 deletions(-)
 create mode 100644 net/core/ether_addrs.c

diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
index 79563840c295..85d2486b2959 100644
--- a/include/linux/etherdevice.h
+++ b/include/linux/etherdevice.h
@@ -63,10 +63,14 @@ struct sk_buff **eth_gro_receive(struct sk_buff **head,
 struct sk_buff *skb);
 int eth_gro_complete(struct sk_buff *skb, int nhoff);
 
+/* Generic Ethernet addresses */
+extern const u8 ether_broadcast_addr[ETH_ALEN];/* all 0xff */
+extern const u8 ether_zero_addr[ETH_ALEN]; /* all zeros */
+
 /* Reserved Ethernet Addresses per IEEE 802.1Q */
-static const u8 eth_reserved_addr_base[ETH_ALEN] __aligned(2) =
-{ 0x01, 0x80, 0xc2, 0x00, 0x00, 0x00 };
-#define eth_stp_addr eth_reserved_addr_base
+extern const u8 ether_reserved_addr_base[ETH_ALEN];
+
+#define eth_stp_addr ether_reserved_addr_base
 
 /**
  * is_link_local_ether_addr - Determine if given Ethernet address is link-local
@@ -80,7 +84,7 @@ static const u8 eth_reserved_addr_base[ETH_ALEN] __aligned(2) 
=
 static inline bool is_link_local_ether_addr(const u8 *addr)
 {
__be16 *a = (__be16 *)addr;
-   static const __be16 *b = (const __be16 *)eth_reserved_addr_base;
+   static const __be16 *b = (const __be16 *)ether_reserved_addr_base;
static const __be16 m = cpu_to_be16(0xfff0);
 
 #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
diff --git a/net/core/Makefile b/net/core/Makefile
index 6dbbba8c57ae..7fb941243cc3 100644
--- a/net/core/Makefile
+++ b/net/core/Makefile
@@ -4,7 +4,8 @@
 #
 
 obj-y := sock.o request_sock.o skbuff.o datagram.o stream.o scm.o \
-gen_stats.o gen_estimator.o net_namespace.o secure_seq.o 
flow_dissector.o
+gen_stats.o gen_estimator.o net_namespace.o secure_seq.o \
+flow_dissector.o ether_addrs.o
 
 obj-$(CONFIG_SYSCTL) += sysctl_net_core.o
 
diff --git a/net/core/ether_addrs.c b/net/core/ether_addrs.c
new file mode 100644
index ..18eedabe73fa
--- /dev/null
+++ b/net/core/ether_addrs.c
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Various const global Ethernet addresses */
+
+#include 
+
+const u8 ether_broadcast_addr[ETH_ALEN] __aligned(2) = {
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+};
+
+const u8 ether_zero_addr[ETH_ALEN] __aligned(2) = {
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+const u8 ether_reserved_addr_base[ETH_ALEN] __aligned(2) = {
+   0x01, 0x80, 0xc2, 0x00, 0x00, 0x00
+};
-- 
2.15.0



Re: [net-next] intel: add SPDX identifiers to all the Intel drivers

2018-03-20 Thread Joe Perches
On Tue, 2018-03-20 at 18:09 -0700, Jeff Kirsher wrote:
> On Tue, 2018-03-20 at 16:46 -0700, Philippe Ombredanne wrote:
> > When the kernel maintainers decide to switch to V3.0 of the SPDX list,
> > the doc will be updated and then Joe's script could be applied at once
> > to update the past.
> 
> I am fine with changing my patch back to v2.6 SPDX ids, as long as Joe's
> script in the future won't touch the Intel wired LAN drivers, since we need
> to retain copyright on several files through out our drivers.

Why would exempting intel wired drivers be
necessary or useful?

I think it would be better if the kernel
source files used a consistent tag format.

The script I wrote is basically a sed that
simply updates the SPDX license text.

That is not particular different that Thomas's
original script that added the SPDX tags.

I have no intention of claiming anything like
a copyright on the output of a trivial script.


Re: [net-next] intel: add SPDX identifiers to all the Intel drivers

2018-03-20 Thread Joe Perches
On Tue, 2018-03-20 at 20:48 +, Allan, Bruce W wrote:
> > -Original Message-
> > From: netdev-ow...@vger.kernel.org [mailto:netdev-ow...@vger.kernel.org]
> > On Behalf Of Jeff Kirsher
> > Sent: Tuesday, March 20, 2018 10:52 AM
> > To: Joe Perches <j...@perches.com>; da...@davemloft.net; Philippe
> > Ombredanne <pombreda...@nexb.com>
> > Cc: netdev@vger.kernel.org; nhor...@redhat.com; sassm...@redhat.com;
> > jogre...@redhat.com
> > Subject: Re: [net-next] intel: add SPDX identifiers to all the Intel drivers
> > 
> > On Tue, 2018-03-20 at 10:41 -0700, Joe Perches wrote:
> > > On Tue, 2018-03-20 at 10:13 -0700, Jeff Kirsher wrote:
> > > > Add the SPDX identifiers to all the Intel wired LAN driver files,
> > > > as
> > > > outlined in Documentation/process/license-rules.rst.
> > > 
> > > So far the Documentation does not show using the -only variant.
> > > 
> > > For a discussion, please see:
> > > https://lkml.org/lkml/2018/2/8/311
> 
> But the Linux Foundation, the authority maintaining the valid SPDX
> identifiers, indicates at https://spdx.org/licenses/ that "GPL-2.0" is
> deprecated while "GPL-2.0-only" (and others) is appropriate.
> Was there any mention in the thread or other conversations if/when the
> kernel's documentation (and all existing uses of "GPL-2.0" in the
> kernel) will be updated to "GPL-2.0-only"?

Not as far as I know.

I believe the uses of "-only" and "-or-later" are
superior to the current
styles and should be done
sooner than later.

I trust at some point the documentation will be
updated and something like the script I submitted
to do the conversions will be run across the tree.

At that point, checkpatch will be updated to do
appropriate specific license checking.


> > 
> > :-( I had it originally as GPL-2.0 and then it was pointed out that it
> > was being deprecated, so rather than creating future thrash over the
> > change, figured I would be ahead of the game.
> > 
> > > 
> > > > diff --git a/drivers/net/ethernet/intel/e100.c
> > > > b/drivers/net/ethernet/intel/e100.c
> > > 
> > > []
> > > > @@ -1,3 +1,4 @@
> > > > +// SPDX-License-Identifier: GPL-2.0-only
> > > 
> > > etc...


Re: rfc: treewide replace local ethernet broadcast char arrays with a global ?

2018-03-20 Thread Joe Perches
On Tue, 2018-03-20 at 13:07 -0700, Florian Fainelli wrote:
> On 03/20/2018 01:00 PM, Joe Perches wrote:
> > Treewide there are ~60 declarations of a ethernet broadcast
> > address as a 6 byte array that are later used as either an
> > output for vsprintf extension %pM or as a source array to
> > copy or compare.
> > 
> > Perhaps it'd be useful to declare a global static const u8[]
> > in net somewhere instead to save the text/data space of these
> > duplicate declarations.
> 
> I could have sworn that such a thing existed already within
> include/linux/etherdevice.h but it is only eth_reserved_addr_base and
> friends as well as is_broadcast_ether_addr(). How about you do it?

I hadn't noticed eth_reserved_addr_base before and it does
seem incorrectly specified as static definitions in .h
files for what should be extern are odd.

Real question is, if the global ethernet broadcast address
array is deemed useful, where to put the definition.  The
extern declaration should definitely be in etherdevice.h

Maybe net/ethernet/eth.c ?




rfc: treewide replace local ethernet broadcast char arrays with a global ?

2018-03-20 Thread Joe Perches
Treewide there are ~60 declarations of a ethernet broadcast
address as a 6 byte array that are later used as either an
output for vsprintf extension %pM or as a source array to
copy or compare.

Perhaps it'd be useful to declare a global static const u8[]
in net somewhere instead to save the text/data space of these
duplicate declarations.

$ grep-2.5.4 -n --include=*.[ch] 
"\b(?:static\s+)?(?:const\s+)?(?:char|unsigned\s+char|u8)\s+\w+\s*\[\s*(?:ETH_ALEN|6)\s*\]\s*=\s*\{\s*(?:(?i:0xff|255),\s*){5,5}\s*(?i:0xff|255)\s*\}"
 * | \
  grep -P "\.[ch]:\d+:"



Re: [net-next] intel: add SPDX identifiers to all the Intel drivers

2018-03-20 Thread Joe Perches
On Tue, 2018-03-20 at 10:13 -0700, Jeff Kirsher wrote:
> Add the SPDX identifiers to all the Intel wired LAN driver files, as
> outlined in Documentation/process/license-rules.rst.

So far the Documentation does not show using the -only variant.

For a discussion, please see:
https://lkml.org/lkml/2018/2/8/311

> diff --git a/drivers/net/ethernet/intel/e100.c 
> b/drivers/net/ethernet/intel/e100.c
[]
> @@ -1,3 +1,4 @@
> +// SPDX-License-Identifier: GPL-2.0-only

etc...


[PATCH] netfilter: ipset: Use is_zero_ether_addr instead of static and memcmp

2018-03-20 Thread Joe Perches
To make the test a bit clearer and to reduce object size a little.

Miscellanea:

o remove now unnecessary static const array

$ size ip_set_hash_mac.o*
   textdata bss dec hex filename
  228224619  64   275056b71 ip_set_hash_mac.o.allyesconfig.new
  229324683  64   276796c1f ip_set_hash_mac.o.allyesconfig.old
  104431040   0   114832cdb ip_set_hash_mac.o.defconfig.new
  105071040   0   115472d1b ip_set_hash_mac.o.defconfig.old

Signed-off-by: Joe Perches <j...@perches.com>
---
 net/netfilter/ipset/ip_set_hash_mac.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/net/netfilter/ipset/ip_set_hash_mac.c 
b/net/netfilter/ipset/ip_set_hash_mac.c
index 8f004edad396..f9d5a2a1e3d0 100644
--- a/net/netfilter/ipset/ip_set_hash_mac.c
+++ b/net/netfilter/ipset/ip_set_hash_mac.c
@@ -72,9 +72,6 @@ hash_mac4_data_next(struct hash_mac4_elem *next,
 #define IP_SET_PROTO_UNDEF
 #include "ip_set_hash_gen.h"
 
-/* Zero valued element is not supported */
-static const unsigned char invalid_ether[ETH_ALEN] = { 0 };
-
 static int
 hash_mac4_kadt(struct ip_set *set, const struct sk_buff *skb,
   const struct xt_action_param *par,
@@ -93,7 +90,7 @@ hash_mac4_kadt(struct ip_set *set, const struct sk_buff *skb,
return -EINVAL;
 
ether_addr_copy(e.ether, eth_hdr(skb)->h_source);
-   if (memcmp(e.ether, invalid_ether, ETH_ALEN) == 0)
+   if (is_zero_ether_addr(e.ether))
return -EINVAL;
return adtfn(set, , , >ext, opt->cmdflags);
 }
@@ -118,7 +115,7 @@ hash_mac4_uadt(struct ip_set *set, struct nlattr *tb[],
if (ret)
return ret;
ether_addr_copy(e.ether, nla_data(tb[IPSET_ATTR_ETHER]));
-   if (memcmp(e.ether, invalid_ether, ETH_ALEN) == 0)
+   if (is_zero_ether_addr(e.ether))
return -IPSET_ERR_HASH_ELEM;
 
return adtfn(set, , , , flags);
-- 
2.15.0



Re: rfc: remove print_vma_addr ? (was Re: [PATCH 00/16] remove eight obsolete architectures)

2018-03-15 Thread Joe Perches
On Thu, 2018-03-15 at 10:08 -0700, Matthew Wilcox wrote:
> On Thu, Mar 15, 2018 at 09:56:46AM -0700, Joe Perches wrote:
> > I have a patchset that creates a vsprintf extension for
> > print_vma_addr and removes all the uses similar to the
> > print_symbol() removal.
> > 
> > This now avoids any possible printk interleaving.
> > 
> > Unfortunately, without some #ifdef in vsprintf, which
> > I would like to avoid, it increases the nommu kernel
> > size by ~500 bytes.
> > 
> > Anyone think this is acceptable?
[]
> This doesn't feel like a huge win since it's only called ~once per
> architecture.  I'd be more excited if it made the printing of the whole
> thing standardised; eg we have a print_fault() function in mm/memory.c
> which takes a suitable set of arguments.

Sure but perhaps that's not feasible as the surrounding output
is per-arch specific.

What could be a standardized fault message here?



rfc: remove print_vma_addr ? (was Re: [PATCH 00/16] remove eight obsolete architectures)

2018-03-15 Thread Joe Perches
On Thu, 2018-03-15 at 10:48 +0100, Geert Uytterhoeven wrote:
> Hi David,
> 
> On Thu, Mar 15, 2018 at 10:42 AM, David Howells  wrote:
> > Do we have anything left that still implements NOMMU?
> 
> Sure: arm, c6x, m68k, microblaze, and  sh.

I have a patchset that creates a vsprintf extension for
print_vma_addr and removes all the uses similar to the
print_symbol() removal.

This now avoids any possible printk interleaving.

Unfortunately, without some #ifdef in vsprintf, which
I would like to avoid, it increases the nommu kernel
size by ~500 bytes.

Anyone think this is acceptable?

Here's the overall patch, but I have it as a series
---
 Documentation/core-api/printk-formats.rst |  9 +
 arch/arm64/kernel/traps.c | 13 +++
 arch/mips/mm/fault.c  | 16 -
 arch/parisc/mm/fault.c| 15 
 arch/riscv/kernel/traps.c | 11 +++---
 arch/s390/mm/fault.c  |  7 ++--
 arch/sparc/mm/fault_32.c  |  8 ++---
 arch/sparc/mm/fault_64.c  |  8 ++---
 arch/tile/kernel/signal.c |  9 ++---
 arch/um/kernel/trap.c | 13 +++
 arch/x86/kernel/signal.c  | 10 ++
 arch/x86/kernel/traps.c   | 18 --
 arch/x86/mm/fault.c   | 12 +++
 include/linux/mm.h|  1 -
 lib/vsprintf.c| 58 ++-
 mm/memory.c   | 33 --
 16 files changed, 112 insertions(+), 129 deletions(-)

diff --git a/Documentation/core-api/printk-formats.rst 
b/Documentation/core-api/printk-formats.rst
index 934559b3c130..10a91da1bc83 100644
--- a/Documentation/core-api/printk-formats.rst
+++ b/Documentation/core-api/printk-formats.rst
@@ -157,6 +157,15 @@ DMA address types dma_addr_t
 For printing a dma_addr_t type which can vary based on build options,
 regardless of the width of the CPU data path.
 
+VMA name and address
+
+
+::
+
+   %pav[hexstart+hexsize] or ?[0+0] if unavailable
+
+For any address, print the vma's name and its starting address and size
+
 Passed by reference.
 
 Raw buffer as an escaped string
diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
index 2b478565d774..48edf812ce8b 100644
--- a/arch/arm64/kernel/traps.c
+++ b/arch/arm64/kernel/traps.c
@@ -242,13 +242,14 @@ void arm64_force_sig_info(struct siginfo *info, const 
char *str,
if (!show_unhandled_signals_ratelimited())
goto send_sig;
 
-   pr_info("%s[%d]: unhandled exception: ", tsk->comm, task_pid_nr(tsk));
if (esr)
-   pr_cont("%s, ESR 0x%08x, ", esr_get_class_string(esr), esr);
-
-   pr_cont("%s", str);
-   print_vma_addr(KERN_CONT " in ", regs->pc);
-   pr_cont("\n");
+   pr_info("%s[%d]: unhandled exception: %s, ESR 0x%08x, %s in 
%pav\n",
+   tsk->comm, task_pid_nr(tsk),
+   esr_get_class_string(esr), esr,
+   str, >pc);
+   else
+   pr_info("%s[%d]: unhandled exception: %s in %pav\n",
+   tsk->comm, task_pid_nr(tsk), str, >pc);
__show_regs(regs);
 
 send_sig:
diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
index 4f8f5bf46977..ce7bf077a0f5 100644
--- a/arch/mips/mm/fault.c
+++ b/arch/mips/mm/fault.c
@@ -213,14 +213,14 @@ static void __kprobes __do_page_fault(struct pt_regs 
*regs, unsigned long write,
tsk->comm,
write ? "write access to" : "read access from",
field, address);
-   pr_info("epc = %0*lx in", field,
-   (unsigned long) regs->cp0_epc);
-   print_vma_addr(KERN_CONT " ", regs->cp0_epc);
-   pr_cont("\n");
-   pr_info("ra  = %0*lx in", field,
-   (unsigned long) regs->regs[31]);
-   print_vma_addr(KERN_CONT " ", regs->regs[31]);
-   pr_cont("\n");
+   pr_info("epc = %0*lx in %pav\n",
+   field,
+   (unsigned long)regs->cp0_epc,
+   >cp0_epc);
+   pr_info("ra  = %0*lx in %pav\n",
+   field,
+   (unsigned long)regs->regs[31],
+   >regs[31]);
}
current->thread.trap_nr = (regs->cp0_cause >> 2) & 0x1f;
info.si_signo = SIGSEGV;
diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
index e247edbca68e..877cea702714 100644
--- a/arch/parisc/mm/fault.c
+++ b/arch/parisc/mm/fault.c
@@ -240,17 +240,14 @@ show_signal_msg(struct pt_regs *regs, unsigned long 

Re: [PATCH net 2/2] qed: Fix non TCP packets should be dropped on iWARP ll2 connection

2018-03-14 Thread Joe Perches
On Wed, 2018-03-14 at 14:49 +0200, Michal Kalderon wrote:
> FW workaround. The iWARP LL2 connection did not expect TCP packets
> to arrive on it's connection. The fix drops any non-tcp packets
[]
> diff --git a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c 
> b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
[]
> @@ -1703,6 +1703,13 @@ qed_iwarp_parse_rx_pkt(struct qed_hwfn *p_hwfn,
>   iph = (struct iphdr *)((u8 *)(ethh) + eth_hlen);
>  
>   if (eth_type == ETH_P_IP) {
> + if (iph->protocol != IPPROTO_TCP) {
> + DP_NOTICE(p_hwfn,
> +   "Unexpected ip protocol on ll2 %x\n",
> +   iph->protocol);
> + return -EINVAL;
> + }

Perhaps this should be ratelimited.

> +
>   cm_info->local_ip[0] = ntohl(iph->daddr);
>   cm_info->remote_ip[0] = ntohl(iph->saddr);
>   cm_info->ip_version = TCP_IPV4;
> @@ -1711,6 +1718,14 @@ qed_iwarp_parse_rx_pkt(struct qed_hwfn *p_hwfn,
>   *payload_len = ntohs(iph->tot_len) - ip_hlen;
>   } else if (eth_type == ETH_P_IPV6) {
>   ip6h = (struct ipv6hdr *)iph;
> +
> + if (ip6h->nexthdr != IPPROTO_TCP) {
> + DP_NOTICE(p_hwfn,
> +   "Unexpected ip protocol on ll2 %x\n",
> +   iph->protocol);
> + return -EINVAL;

here too

> + }
> +
>   for (i = 0; i < 4; i++) {
>   cm_info->local_ip[i] =
>   ntohl(ip6h->daddr.in6_u.u6_addr32[i]);


Re: [PATCH net-next v2 2/4] net: qualcomm: rmnet: Update copyright year to 2018

2018-03-13 Thread Joe Perches
On Tue, 2018-03-13 at 18:15 -0600, Subash Abhinov Kasiviswanathan wrote:
> > Did any work actually occur on all these files in 2018?
> > $ git log --name-only --since=01-01-2018
> > drivers/net/ethernet/qualcomm/rmnet/ | \
> >   grep "^drivers" | sort | uniq
> > drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
> > drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h
> > drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c
> > drivers/net/ethernet/qualcomm/rmnet/rmnet_map_command.c
> > drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
> > drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h
> > drivers/net/ethernet/qualcomm/rmnet/rmnet_private.h
> > drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
> 
> Hi
> 
> There were changes to all these files as you pointed out
> except for -
> drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.h
> drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h

Yup.  That's why I sent that list.

Files without modifications should generally not
have updated copyrights.

cheers, Joe


Re: [PATCH net-next v2 2/4] net: qualcomm: rmnet: Update copyright year to 2018

2018-03-13 Thread Joe Perches
On Tue, 2018-03-13 at 16:50 -0600, Subash Abhinov Kasiviswanathan wrote:
> Signed-off-by: Subash Abhinov Kasiviswanathan 
> ---
>  drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c  | 2 +-
>  drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h  | 2 +-
>  drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c| 2 +-
>  drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.h| 2 +-
>  drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h | 2 +-
>  drivers/net/ethernet/qualcomm/rmnet/rmnet_map_command.c | 2 +-
>  drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c| 2 +-
>  drivers/net/ethernet/qualcomm/rmnet/rmnet_private.h | 2 +-
>  drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c | 2 +-
>  drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h | 2 +-

Did any work actually occur on all these files in 2018?
$ git log --name-only --since=01-01-2018 drivers/net/ethernet/qualcomm/rmnet/ | 
\
  grep "^drivers" | sort | uniq
drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h
drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c
drivers/net/ethernet/qualcomm/rmnet/rmnet_map_command.c
drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h
drivers/net/ethernet/qualcomm/rmnet/rmnet_private.h
drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c



Re: [PATCH] netfilter: cttimeout: remove VLA usage

2018-03-13 Thread Joe Perches
On Tue, 2018-03-13 at 15:59 +0100, Pablo Neira Ayuso wrote:
> On Mon, Mar 12, 2018 at 04:58:38PM -0700, Joe Perches wrote:
> > On Mon, 2018-03-12 at 18:14 -0500, Gustavo A. R. Silva wrote:
> > > In preparation to enabling -Wvla, remove VLA and replace it
> > > with dynamic memory allocation.
> > > 
> > > From a security viewpoint, the use of Variable Length Arrays can be
> > > a vector for stack overflow attacks. Also, in general, as the code
> > > evolves it is easy to lose track of how big a VLA can get. Thus, we
> > > can end up having segfaults that are hard to debug.
> > > 
> > > Also, fixed as part of the directive to remove all VLAs from
> > 
> > []
> > > diff --git a/net/netfilter/nfnetlink_cttimeout.c 
> > > b/net/netfilter/nfnetlink_cttimeout.c
> > 
> > []
> > > @@ -51,19 +51,27 @@ ctnl_timeout_parse_policy(void *timeouts,
> > > const struct nf_conntrack_l4proto *l4proto,
> > > struct net *net, const struct nlattr *attr)
> > >  {
> > > + struct nlattr **tb;
> > >   int ret = 0;
> > >  
> > > - if (likely(l4proto->ctnl_timeout.nlattr_to_obj)) {
> > > - struct nlattr *tb[l4proto->ctnl_timeout.nlattr_max+1];
> > > + if (!l4proto->ctnl_timeout.nlattr_to_obj)
> > > + return 0;
> > 
> > Why not
> > if unlikely(!...)
> 
> This is control plane code - not packet path - I think we should just
> let the compiler decide on this one, not really need to provide an
> explicit hint here.

I don't have an issue with that, but it should probably be
mentioned in the changelog as it's unrelated to VLA removal.


Re: [PATCH] netfilter: cttimeout: remove VLA usage

2018-03-12 Thread Joe Perches
On Mon, 2018-03-12 at 18:14 -0500, Gustavo A. R. Silva wrote:
> In preparation to enabling -Wvla, remove VLA and replace it
> with dynamic memory allocation.
> 
> From a security viewpoint, the use of Variable Length Arrays can be
> a vector for stack overflow attacks. Also, in general, as the code
> evolves it is easy to lose track of how big a VLA can get. Thus, we
> can end up having segfaults that are hard to debug.
> 
> Also, fixed as part of the directive to remove all VLAs from
[]
> diff --git a/net/netfilter/nfnetlink_cttimeout.c 
> b/net/netfilter/nfnetlink_cttimeout.c
[]
> @@ -51,19 +51,27 @@ ctnl_timeout_parse_policy(void *timeouts,
> const struct nf_conntrack_l4proto *l4proto,
> struct net *net, const struct nlattr *attr)
>  {
> + struct nlattr **tb;
>   int ret = 0;
>  
> - if (likely(l4proto->ctnl_timeout.nlattr_to_obj)) {
> - struct nlattr *tb[l4proto->ctnl_timeout.nlattr_max+1];
> + if (!l4proto->ctnl_timeout.nlattr_to_obj)
> + return 0;

Why not
if unlikely(!...)

>  
> - ret = nla_parse_nested(tb, l4proto->ctnl_timeout.nlattr_max,
> -attr, l4proto->ctnl_timeout.nla_policy,
> -NULL);
> - if (ret < 0)
> - return ret;
> + tb = kcalloc(l4proto->ctnl_timeout.nlattr_max + 1, sizeof(*tb),
> +  GFP_KERNEL);

kmalloc_array?

>  
> - ret = l4proto->ctnl_timeout.nlattr_to_obj(tb, net, timeouts);
> - }
> + if (!tb)
> + return -ENOMEM;
> +
> + ret = nla_parse_nested(tb, l4proto->ctnl_timeout.nlattr_max, attr,
> +l4proto->ctnl_timeout.nla_policy, NULL);
> + if (ret < 0)
> + goto err;
> +
> + ret = l4proto->ctnl_timeout.nlattr_to_obj(tb, net, timeouts);
> +
> +err:
> + kfree(tb);
>   return ret;
>  }
>  


[PATCH] net: drivers/net: Remove unnecessary skb_copy_expand OOM messages

2018-03-12 Thread Joe Perches
skb_copy_expand without __GFP_NOWARN already does a dump_stack
on OOM so these messages are redundant.

Signed-off-by: Joe Perches <j...@perches.com>
---
 drivers/net/ethernet/qualcomm/qca_spi.c | 1 -
 drivers/net/usb/lg-vl600.c  | 6 +-
 drivers/net/wimax/i2400m/usb-rx.c   | 3 ---
 drivers/net/wireless/ti/wl1251/tx.c | 4 +---
 drivers/usb/gadget/function/f_eem.c | 1 -
 net/mac80211/rx.c   | 5 +
 net/netfilter/nfnetlink_queue.c | 5 +
 7 files changed, 4 insertions(+), 21 deletions(-)

diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c 
b/drivers/net/ethernet/qualcomm/qca_spi.c
index 9c236298fe21..5803cd6db406 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.c
+++ b/drivers/net/ethernet/qualcomm/qca_spi.c
@@ -705,7 +705,6 @@ qcaspi_netdev_xmit(struct sk_buff *skb, struct net_device 
*dev)
tskb = skb_copy_expand(skb, QCAFRM_HEADER_LEN,
   QCAFRM_FOOTER_LEN + pad_len, GFP_ATOMIC);
if (!tskb) {
-   netdev_dbg(qca->net_dev, "could not allocate 
tx_buff\n");
qca->stats.out_of_mem++;
return NETDEV_TX_BUSY;
}
diff --git a/drivers/net/usb/lg-vl600.c b/drivers/net/usb/lg-vl600.c
index dbabd7ca5268..257916f172cd 100644
--- a/drivers/net/usb/lg-vl600.c
+++ b/drivers/net/usb/lg-vl600.c
@@ -157,12 +157,8 @@ static int vl600_rx_fixup(struct usbnet *dev, struct 
sk_buff *skb)
 
s->current_rx_buf = skb_copy_expand(skb, 0,
le32_to_cpup(>len), GFP_ATOMIC);
-   if (!s->current_rx_buf) {
-   netif_err(dev, ifup, dev->net, "Reserving %i bytes "
-   "for packet assembly failed.\n",
-   le32_to_cpup(>len));
+   if (!s->current_rx_buf)
dev->net->stats.rx_errors++;
-   }
 
return 0;
}
diff --git a/drivers/net/wimax/i2400m/usb-rx.c 
b/drivers/net/wimax/i2400m/usb-rx.c
index b78ee676e102..5b64bda7d9e7 100644
--- a/drivers/net/wimax/i2400m/usb-rx.c
+++ b/drivers/net/wimax/i2400m/usb-rx.c
@@ -263,9 +263,6 @@ struct sk_buff *i2400mu_rx(struct i2400mu *i2400mu, struct 
sk_buff *rx_skb)
new_skb = skb_copy_expand(rx_skb, 0, rx_size - rx_skb->len,
  GFP_KERNEL);
if (new_skb == NULL) {
-   if (printk_ratelimit())
-   dev_err(dev, "RX: Can't reallocate skb to %d; "
-   "RX dropped\n", rx_size);
kfree_skb(rx_skb);
rx_skb = NULL;
goto out;   /* drop it...*/
diff --git a/drivers/net/wireless/ti/wl1251/tx.c 
b/drivers/net/wireless/ti/wl1251/tx.c
index de2fa6705574..12ed14ebc307 100644
--- a/drivers/net/wireless/ti/wl1251/tx.c
+++ b/drivers/net/wireless/ti/wl1251/tx.c
@@ -221,10 +221,8 @@ static int wl1251_tx_send_packet(struct wl1251 *wl, struct 
sk_buff *skb,
struct sk_buff *newskb = skb_copy_expand(skb, 0, 3,
 GFP_KERNEL);
 
-   if (unlikely(newskb == NULL)) {
-   wl1251_error("Can't allocate skb!");
+   if (unlikely(newskb == NULL))
return -EINVAL;
-   }
 
tx_hdr = (struct tx_double_buffer_desc *) newskb->data;
 
diff --git a/drivers/usb/gadget/function/f_eem.c 
b/drivers/usb/gadget/function/f_eem.c
index 37557651b600..c13befa31110 100644
--- a/drivers/usb/gadget/function/f_eem.c
+++ b/drivers/usb/gadget/function/f_eem.c
@@ -507,7 +507,6 @@ static int eem_unwrap(struct gether *port,
0,
GFP_ATOMIC);
if (unlikely(!skb3)) {
-   DBG(cdev, "unable to realign EEM packet\n");
dev_kfree_skb_any(skb2);
continue;
}
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index d01743234cf6..9c898a3688c6 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -2549,11 +2549,8 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
 
fwd_skb = skb_copy_expand(skb, local->tx_headroom +
   sdata->encrypt_headroom, 0, GFP_ATOMIC);
-   if (!fwd_skb) {
-   net_info_ratelimited("%s: failed to clone mesh frame\n",
-   sdata->name);
+   if (!fwd_skb)
goto out;
-   }
 
fwd_hdr =  (stru

Re: [PATCH v2] net: netfilter: Replace printk() with appropriate pr_*() macro

2018-03-11 Thread Joe Perches
On Mon, 2018-03-12 at 01:11 +0530, Arushi Singhal wrote:
> Using pr_() is more concise than
> printk(KERN_).
> Replace printks having a log level with the appropriate
> pr_*() macros.
> 
> Signed-off-by: Arushi Singhal 
> ---
> changes in v2
> *in v1 printk() were replaced with netdev_*()

>  net/netfilter/nf_conntrack_acct.c  | 2 +-
>  net/netfilter/nf_conntrack_ecache.c| 2 +-
>  net/netfilter/nf_conntrack_timestamp.c | 2 +-
>  net/netfilter/nf_nat_core.c| 2 +-
>  net/netfilter/nfnetlink_queue.c| 4 ++--
>  5 files changed, 6 insertions(+), 6 deletions(-)

None of these files have a #define for pr_fmt so this
should be OK.

Perhaps coalesce the formats and remove the unnecessary periods too.

> diff --git a/net/netfilter/nf_conntrack_acct.c 
> b/net/netfilter/nf_conntrack_acct.c
[]
> @@ -80,7 +80,7 @@ static int nf_conntrack_acct_init_sysctl(struct net *net)
>   net->ct.acct_sysctl_header = register_net_sysctl(net, "net/netfilter",
>table);
>   if (!net->ct.acct_sysctl_header) {
> - printk(KERN_ERR "nf_conntrack_acct: can't register to 
> sysctl.\n");
> + pr_err("nf_conntrack_acct: can't register to sysctl.\n");
>   goto out_register;
>   }
>   return 0;

etc...

> diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
[]
> @@ -834,8 +834,8 @@ nfqnl_mangle(void *data, int data_len, struct 
> nf_queue_entry *e, int diff)
>   nskb = skb_copy_expand(e->skb, skb_headroom(e->skb),
>  diff, GFP_ATOMIC);
>   if (!nskb) {
> - printk(KERN_WARNING "nf_queue: OOM "
> -   "in mangle, dropping packet\n");
> + pr_warn("nf_queue: OOM "
> + "in mangle, dropping packet\n");
>   return -ENOMEM;
>   }
>   kfree_skb(e->skb);


Re: [PATCH 1/2] net/usb/ax88179_178a: Use common code in ax88179_chk_eee()

2018-03-10 Thread Joe Perches
On Sat, 2018-03-10 at 19:24 +0100, SF Markus Elfring wrote:
> From: Markus Elfring 
> Date: Sat, 10 Mar 2018 18:22:43 +0100
> 
> Adjust a jump target so that a bit of common code can be better reused
> at the end of this function.

Please stop mindlessly sending patching Markus.

How about looking at the code being modified and
thinking about what it does?

Try unindenting the block by reversing the first test
and using the same goto set_inactive.

Look at the last & tests
+   if (!(lp & adv & supported))
and see if it should use && or be more simple to read
by using
if (!condition || !

> ---
>  drivers/net/usb/ax88179_178a.c | 34 +++---
>  1 file changed, 11 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
> index f32261ecd215..e4b0baa98e9a 100644
> --- a/drivers/net/usb/ax88179_178a.c
> +++ b/drivers/net/usb/ax88179_178a.c
> @@ -689,49 +689,37 @@ static int ax88179_chk_eee(struct usbnet *dev)
>   eee_cap = ax88179_phy_read_mmd_indirect(dev,
>   MDIO_PCS_EEE_ABLE,
>   MDIO_MMD_PCS);
> - if (eee_cap < 0) {
> - priv->eee_active = 0;
> - return false;
> - }
> + if (eee_cap < 0)
> + goto set_inactive;
>  
>   cap = mmd_eee_cap_to_ethtool_sup_t(eee_cap);
> - if (!cap) {
> - priv->eee_active = 0;
> - return false;
> - }
> + if (!cap)
> + goto set_inactive;
>  
>   eee_lp = ax88179_phy_read_mmd_indirect(dev,
>  MDIO_AN_EEE_LPABLE,
>  MDIO_MMD_AN);
> - if (eee_lp < 0) {
> - priv->eee_active = 0;
> - return false;
> - }
> + if (eee_lp < 0)
> + goto set_inactive;
>  
>   eee_adv = ax88179_phy_read_mmd_indirect(dev,
>   MDIO_AN_EEE_ADV,
>   MDIO_MMD_AN);
> -
> - if (eee_adv < 0) {
> - priv->eee_active = 0;
> - return false;
> - }
> + if (eee_adv < 0)
> + goto set_inactive;
>  
>   adv = mmd_eee_adv_to_ethtool_adv_t(eee_adv);
>   lp = mmd_eee_adv_to_ethtool_adv_t(eee_lp);
>   supported = (ecmd.speed == SPEED_1000) ?
>SUPPORTED_1000baseT_Full :
>SUPPORTED_100baseT_Full;
> -
> - if (!(lp & adv & supported)) {
> - priv->eee_active = 0;
> - return false;
> - }
> + if (!(lp & adv & supported))
> + goto set_inactive;
>  
>   priv->eee_active = 1;
>   return true;
>   }
> -
> +set_inactive:
>   priv->eee_active = 0;
>   return false;
>  }


Re: [PATCH] drivers: net: wireless: ath: ath9k: dfs: remove VLA usage

2018-03-09 Thread Joe Perches
On Fri, 2018-03-09 at 15:23 +0200, Andreas Christoforou wrote:
> The kernel would like to have all stack VLA usage removed.
> This is the correct patch.
[]
> diff --git a/drivers/net/wireless/ath/ath9k/dfs.c 
> b/drivers/net/wireless/ath/ath9k/dfs.c
[]
> @@ -101,7 +101,7 @@ static bool ath9k_check_chirping(struct ath_softc *sc, u8 
> *data,
>int datalen, bool is_ctl, bool is_ext)
>  {
>   int i;
> - int max_bin[FFT_NUM_SAMPLES];
> + int max_bin[NUM_DIFFS + 1];
>   struct ath_hw *ah = sc->sc_ah;
>   struct ath_common *common = ath9k_hw_common(ah);
>   int prev_delta;

why not just change FFT_NUM_SAMPLES to a #define
or get rid if FFT_NUM_SAMPLES altogether?

$ git grep -w FFT_NUM_SAMPLES
drivers/net/wireless/ath/ath9k/dfs.c:static const int FFT_NUM_SAMPLES   = 
(NUM_DIFFS + 1);
drivers/net/wireless/ath/ath9k/dfs.c:   int max_bin[FFT_NUM_SAMPLES];
drivers/net/wireless/ath/ath9k/dfs.c:   if (num_fft_packets < 
(FFT_NUM_SAMPLES)) {
drivers/net/wireless/ath/ath9k/dfs.c:   for (i = 0; i < 
FFT_NUM_SAMPLES; i++)
drivers/net/wireless/ath/ath9k/dfs.c:   if (num_fft_packets < 
(FFT_NUM_SAMPLES)) {
drivers/net/wireless/ath/ath9k/dfs.c:   for (i = 0; i < 
FFT_NUM_SAMPLES; i++)


Re: [PATCH] i40evf: remove redundant array comparisons to 0 checks

2018-02-18 Thread Joe Perches
On Sun, 2018-02-18 at 16:58 +0200, Andy Shevchenko wrote:
> On Fri, Feb 16, 2018 at 6:53 PM, Colin Ian King
>  wrote:
> > On 16/02/18 16:51, Andy Shevchenko wrote:
> > > On Thu, Feb 15, 2018 at 9:42 PM, Colin King  
> > > wrote:
> > > > +   filter->f.mask.tcp_spec.dst_ip[i] |=
> > > > 
> > > > cpu_to_be32(0x);
> > > 
> > > Can it be one line then?
> > 
> > I re-adjusted the text because checkpatch was complaining.
> > > 
> > > > +   filter->f.mask.tcp_spec.src_ip[i] |=
> > > > 
> > > > cpu_to_be32(0x);
> 
> For the rest OK, but for the above two how much over 80 it went if
> would be one line?
> If it 2-3 characters, consider to make it one line. It would increase
> readability.

Another possibility would be to use temporaries for
filter->f.mask.tcp_spec
and
filter->f.data.tcp_spec
as both are used ~10 times in the function




Re: KASAN: use-after-free Read in rds_tcp_tune

2018-02-14 Thread Joe Perches
On Wed, 2018-02-14 at 18:16 +0100, Dmitry Vyukov wrote:
> On Wed, Feb 14, 2018 at 6:02 PM, Joe Perches <j...@perches.com> wrote:
> > On Wed, 2018-02-14 at 16:55 +0100, Dmitry Vyukov wrote:
> > > On Wed, Feb 14, 2018 at 4:35 PM, Sowmini Varadhan 
> > > <sowmini.varad...@oracle.com> wrote:
> > > > btw, checkpatch.pl complains about the syzbot*@syzkaller.appspotmail.com
> > > > addresses as "Unrecognized email address", we should fix that
> > > > error from checkpatch at some point.
> > > 
> > > Interesting. Looking at checkpatch.pl I think it wants all addresses
> > > to be in <>, i.e.
> > > Reported-by: <syzbot+bbd8e9a06452cc480...@syzkaller.appspotmail.com>
> > > There probably was some reason to enforce this, so I think I will
> > > change the syzbot email template to include <>.
> > > Thanks!
> > 
> > Not really.
> > 
> > It's the somewhat unusual + in the address
> > that perl needs quoted before a substitution.
> > 
> > I believe this fixes it in checkpatch.
> > ---
> >  scripts/checkpatch.pl | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> > @@ -1075,7 +1075,7 @@ sub parse_email {
> > } elsif ($formatted_email =~ /(\S+\@\S+)(.*)$/) {
> > $address = $1;
> > $comment = $2 if defined $2;
> > -   $formatted_email =~ s/$address.*$//;
> > +   $formatted_email =~ s/\Q$address\E.*$//;
> > $name = $formatted_email;
> > $name = trim($name);
> > $name =~ s/^\"|\"$//g;
> 
> 
> I can confirm that running
> $ git show HEAD | scripts/checkpatch.pl -
> on a commit that contains a syzbot Reported-by tag does not produce
> the warning anymore.
> 
> Joe, do you mind mailing this as patch?

'course not.  It's nice you tested it.

I did on the last thousand commits without
apparent change.

$ git log --format=oneline --no-merges -1000 | \
  cut -f1 -d" " | \
  while read commit ; do \
./scripts/checkpatch.pl --git $commit --types=bad_sign_off --terse ; \
  done



Re: KASAN: use-after-free Read in rds_tcp_tune

2018-02-14 Thread Joe Perches
On Wed, 2018-02-14 at 16:55 +0100, Dmitry Vyukov wrote:
> On Wed, Feb 14, 2018 at 4:35 PM, Sowmini Varadhan 
>  wrote:
> > btw, checkpatch.pl complains about the syzbot*@syzkaller.appspotmail.com
> > addresses as "Unrecognized email address", we should fix that
> > error from checkpatch at some point.
> 
> Interesting. Looking at checkpatch.pl I think it wants all addresses
> to be in <>, i.e.
> Reported-by: 
> There probably was some reason to enforce this, so I think I will
> change the syzbot email template to include <>.
> Thanks!

Not really.

It's the somewhat unusual + in the address
that perl needs quoted before a substitution.

I believe this fixes it in checkpatch.
---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 3d4040322ae1..2b8397da39d3 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1075,7 +1075,7 @@ sub parse_email {
} elsif ($formatted_email =~ /(\S+\@\S+)(.*)$/) {
$address = $1;
$comment = $2 if defined $2;
-   $formatted_email =~ s/$address.*$//;
+   $formatted_email =~ s/\Q$address\E.*$//;
$name = $formatted_email;
$name = trim($name);
$name =~ s/^\"|\"$//g;



Re: [PATCH v7 31/37] MAINTAINERS: Add nds32

2018-02-13 Thread Joe Perches
On Tue, 2018-02-13 at 17:09 +0800, Greentime Hu wrote:
> Add a maintainer information for the nds32(Andes) architecture.
[]
> diff --git a/MAINTAINERS b/MAINTAINERS
[]
> @@ -868,6 +868,17 @@ X:   drivers/iio/*/adjd*
>  F:   drivers/staging/iio/*/ad*
>  F:   drivers/staging/iio/trigger/iio-trig-bfin-timer.c
>  
> +ANDES ARCHITECTURE
> +M:   Greentime Hu 
> +M:   Vincent Chen 
> +T:   git https://github.com/andestech/linux.git
> +S:   Supported
> +F:   arch/nds32

This should have a trailing /

F:  arch/nds32/

> +F:   
> Documentation/devicetree/bindings/interrupt-controller/andestech,ativic32.txt
> +F:   Documentation/devicetree/bindings/nds32
> +K:   nds32

Perhaps this should be

K:  \bnds32

as there are some existing uses of nds32 in the current tree.

or maybe case insensitive like

K:  (?i:\bnds32)
or
K:  (?:\bnds32|\bNDS32)

> +N:   nds32
> +
>  ANDROID CONFIG FRAGMENTS
>  M:   Rob Herring 
>  S:   Supported


Re: [PATCH] rtlwifi: rtl8192cu: remove pointless memcpy

2018-02-09 Thread Joe Perches
On Fri, 2018-02-09 at 14:24 +0100, Arnd Bergmann wrote:
> gcc-8 points out that source and destination of the memcpy() are
> always the same pointer, so the effect of memcpy() is undefined
> here (its arguments must not overlap):
> 
> drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c: In function 
> '_rtl_rx_process':
> drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c:430:2: error: 'memcpy' 
> source argument is the same as destination [-Werror=restrict]
> 
> Most likely this is harmless, but it's easy to just remove the
> line and get rid of the warning.
> 
> Signed-off-by: Arnd Bergmann 
> ---
>  drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c 
> b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
> index ac4a82de40c7..9ab56827124e 100644
> --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
> +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
> @@ -427,7 +427,6 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, 
> struct sk_buff *skb)
>(u32)hdr->addr1[0], (u32)hdr->addr1[1],
>(u32)hdr->addr1[2], (u32)hdr->addr1[3],
>(u32)hdr->addr1[4], (u32)hdr->addr1[5]);
> - memcpy(IEEE80211_SKB_RXCB(skb), rx_status, sizeof(*rx_status));
>   ieee80211_rx(hw, skb);
>  }

trivia:

The RT_TRACE above this should probably use %pM too.
Not submitted as it would just cause a conflict.

---

 drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
index ac4a82de40c7..61da667ed8ba 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
@@ -422,11 +422,8 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, 
struct sk_buff *skb)
if (ieee80211_is_data(fc))
RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "Got data frame\n");
RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
-"Fram: fc = 0x%X addr1 = 
0x%02X:0x%02X:0x%02X:0x%02X:0x%02X:0x%02X\n",
-fc,
-(u32)hdr->addr1[0], (u32)hdr->addr1[1],
-(u32)hdr->addr1[2], (u32)hdr->addr1[3],
-(u32)hdr->addr1[4], (u32)hdr->addr1[5]);
+"Fram: fc = 0x%X addr1 = %pM\n",
+fc, hdr->addr1);
memcpy(IEEE80211_SKB_RXCB(skb), rx_status, sizeof(*rx_status));
ieee80211_rx(hw, skb);
 }


Re: [net-next 2/7] fm10k: cleanup unnecessary parenthesis in fm10k_iov.c

2018-01-31 Thread Joe Perches
On Wed, 2018-01-24 at 14:45 -0800, Jeff Kirsher wrote:
> This fixes a few warnings found by checkpatch.pl --strict
[]
> diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_iov.c 
> b/drivers/net/ethernet/intel/fm10k/fm10k_iov.c
[]
> @@ -353,7 +353,7 @@ int fm10k_iov_resume(struct pci_dev *pdev)
>   struct fm10k_vf_info *vf_info = _data->vf_info[i];
>  
>   /* allocate all but the last GLORT to the VFs */
> - if (i == ((~hw->mac.dglort_map) >> FM10K_DGLORTMAP_MASK_SHIFT))
> + if (i == (~hw->mac.dglort_map >> FM10K_DGLORTMAP_MASK_SHIFT))

Strictly, only the if needs parentheses here, but I
think it reads better before this change.

> @@ -511,7 +511,7 @@ int fm10k_iov_configure(struct pci_dev *pdev, int num_vfs)
>   return err;
>  
>   /* allocate VFs if not already allocated */
> - if (num_vfs && (num_vfs != current_vfs)) {
> + if (num_vfs && num_vfs != current_vfs) {




Re: [PATCH v2] smc: return booleans instead of integers

2018-01-22 Thread Joe Perches
On Mon, 2018-01-22 at 12:58 +0100, Ursula Braun wrote:
> 
> On 01/19/2018 09:54 PM, Gustavo A. R. Silva wrote:
> > Return statements in functions returning bool should use
> > true/false instead of 1/0.
> > 
> > This issue was detected with the help of Coccinelle.
> > 
> > Signed-off-by: Gustavo A. R. Silva 
> > ---
> > Changes in v2:
> >  - Fix function using_ipsec as suggested by Ursula Braun.
> >  - Update subject line.
> > 
> >  net/smc/smc.h | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/net/smc/smc.h b/net/smc/smc.h
[]
> > @@ -253,12 +253,12 @@ static inline int smc_uncompress_bufsize(u8 
> > compressed)
> >  static inline bool using_ipsec(struct smc_sock *smc)
> >  {
> > return (smc->clcsock->sk->sk_policy[0] ||
> > -   smc->clcsock->sk->sk_policy[1]) ? 1 : 0;
> > +   smc->clcsock->sk->sk_policy[1]) ? true : false;

Generally, any bool return like

return condition ? true : false;

could be written

return condition;




Re: dangers of bots on the mailing lists was Re: divide error in ___bpf_prog_run

2018-01-17 Thread Joe Perches
On Wed, 2018-01-17 at 17:46 -0800, Eric Biggers wrote:
> On Wed, Jan 17, 2018 at 05:18:17PM -0800, Joe Perches wrote:
> > On Wed, 2018-01-17 at 20:09 -0500, Theodore Ts'o wrote:
> > > get_maintainer.pl, which is often not accurate
> > 
> > Examples please.
> > 
> 
> Well, the primary problem is that place the crash occurs is not necessarily
> responsible for the bug.  But, syzbot actually does have a file blacklist for
> exactly that reason; see
> https://github.com/google/syzkaller/blob/master/pkg/report/linux.go#L56

Which has no association to a problem with get_maintainer.

> And yes, get_maintainer.pl sometimes isn't accurate even if the offending code
> is correctly identified.  That's more of a community problem, e.g. people
> sometimes don't bother to remove themselves from MAINTAINERS when they quit
> maintaining, and sometimes people don't feel responsible enough for a file to
> add themselves to MAINTAINERS, even when in practice they are actually taking
> most of the patches to it through their tree.

Yup, not a get_maintainer problem.

There are more than 1800 sections and more than
1200 individual names in the MAINTAINERS file.

In practice, there are a few dozen maintainers
that are upstream patch paths.



Re: dangers of bots on the mailing lists was Re: divide error in ___bpf_prog_run

2018-01-17 Thread Joe Perches
On Wed, 2018-01-17 at 20:09 -0500, Theodore Ts'o wrote:
> get_maintainer.pl, which is often not accurate

Examples please.



Re: [PATCH net-next v2 08/10] net: aquantia: Fix register definitions to linux style

2018-01-16 Thread Joe Perches
On Mon, 2018-01-15 at 16:41 +0300, Igor Russkikh wrote:
> Original driver code had internal registers and masks declarations
> in low case and without any prefix.
> Here we make all these uppercase and add already used HW_ATL prefix
> to recognize these.
[]
> diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.c 
> b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.c
[]
> @@ -114,13 +115,13 @@ void itr_irq_map_en_rx_set(struct aq_hw_s *aq_hw, u32 
> irq_map_en_rx, u32 rx)
>  /* register address for bitfield imr_rx{r}_en */
>   static u32 itr_imr_rxren_adr[32] = {
>   0x2100U, 0x2100U, 0x2104U, 0x2104U,
> - 0x2108U, 0x2108U, 0x210cU, 0x210cU,
> + 0x2108U, 0x2108U, 0x210CU, 0x210CU,
>   0x2110U, 0x2110U, 0x2114U, 0x2114U,
> - 0x2118U, 0x2118U, 0x211cU, 0x211cU,
> + 0x2118U, 0x2118U, 0x211CU, 0x211CU,
>   0x2120U, 0x2120U, 0x2124U, 0x2124U,
> - 0x2128U, 0x2128U, 0x212cU, 0x212cU,
> + 0x2128U, 0x2128U, 0x212CU, 0x212CU,
>   0x2130U, 0x2130U, 0x2134U, 0x2134U,
> - 0x2138U, 0x2138U, 0x213cU, 0x213cU
> + 0x2138U, 0x2138U, 0x213CU, 0x213CU
>   };

Be nice to change all these to static const
 
>  /* bitmask for bitfield imr_rx{r}_en */
> @@ -154,13 +155,13 @@ void itr_irq_map_en_tx_set(struct aq_hw_s *aq_hw, u32 
> irq_map_en_tx, u32 tx)
>  /* register address for bitfield imr_tx{t}_en */
>   static u32 itr_imr_txten_adr[32] = {

etc...

>   0x2100U, 0x2100U, 0x2104U, 0x2104U,
> - 0x2108U, 0x2108U, 0x210cU, 0x210cU,
> + 0x2108U, 0x2108U, 0x210CU, 0x210CU,
>   0x2110U, 0x2110U, 0x2114U, 0x2114U,
> - 0x2118U, 0x2118U, 0x211cU, 0x211cU,
> + 0x2118U, 0x2118U, 0x211CU, 0x211CU,
>   0x2120U, 0x2120U, 0x2124U, 0x2124U,
> - 0x2128U, 0x2128U, 0x212cU, 0x212cU,
> + 0x2128U, 0x2128U, 0x212CU, 0x212CU,
>   0x2130U, 0x2130U, 0x2134U, 0x2134U,
> - 0x2138U, 0x2138U, 0x213cU, 0x213cU
> + 0x2138U, 0x2138U, 0x213CU, 0x213CU
>   };
>  
>  /* bitmask for bitfield imr_tx{t}_en */
> @@ -194,25 +195,25 @@ void itr_irq_map_rx_set(struct aq_hw_s *aq_hw, u32 
> irq_map_rx, u32 rx)
>  /* register address for bitfield imr_rx{r}[4:0] */
>   static u32 itr_imr_rxr_adr[32] = {
[]
>  /* bitmask for bitfield imr_rx{r}[4:0] */
>   static u32 itr_imr_rxr_msk[32] = {
[]
> @@ -234,25 +235,25 @@ void itr_irq_map_tx_set(struct aq_hw_s *aq_hw, u32 
> irq_map_tx, u32 tx)
>  /* register address for bitfield imr_tx{t}[4:0] */
>   static u32 itr_imr_txt_adr[32] = {
[]
>  /* bitmask for bitfield imr_tx{t}[4:0] */
>   static u32 itr_imr_txt_msk[32] = {



[PATCH] MAINTAINERS: Mark some staging directories as "Obsolete"

2018-01-09 Thread Joe Perches
Several staging directories have TODO files that indicate a
subsystem will be removed in the future.

Using a status entry of "S: Obsolete" helps indicate the
subsystem files should not be modified unnecessarily.

checkpatch also tests this setting and emits a warning that
the matching subsystem files should not be modified.

This might help avoid receiving patches that will be dropped.

Signed-off-by: Joe Perches <j...@perches.com>
---
 MAINTAINERS | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 3d53de49e736..9edf41e051e0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7350,7 +7350,7 @@ F:drivers/tty/ipwireless/
 
 IPX NETWORK LAYER
 L: netdev@vger.kernel.org
-S: Odd fixes
+S: Obsolete
 F: include/uapi/linux/ipx.h
 F: drivers/staging/ipx/
 
@@ -7359,7 +7359,7 @@ M:Samuel Ortiz <sam...@sortiz.org>
 L: irda-us...@lists.sourceforge.net (subscribers-only)
 L: netdev@vger.kernel.org
 W: http://irda.sourceforge.net/
-S: Maintained
+S: Obsolete
 T: git git://git.kernel.org/pub/scm/linux/kernel/git/sameo/irda-2.6.git
 F: Documentation/networking/irda.txt
 F: drivers/staging/irda/
@@ -9439,7 +9439,7 @@ F:drivers/net/ethernet/natsemi/natsemi.c
 
 NCP FILESYSTEM
 M: Petr Vandrovec <p...@vandrovec.name>
-S: Odd Fixes
+S: Obsolete
 F: drivers/staging/ncpfs/
 
 NCR 5380 SCSI DRIVERS


Re: [PATCH net-next v2 1/6] net: Fix netdev_WARN_ONCE macro

2018-01-08 Thread Joe Perches
On Sun, 2018-01-07 at 12:08 +0200, Gal Pressman wrote:
> netdev_WARN_ONCE is broken (whoops..), this fix will remove the
> unnecessary "condition" parameter, add the missing comma and change
> "arg" to "args".
> 
> Fixes: 375ef2b1f0d0 ("net: Introduce netdev_*_once functions")
> Signed-off-by: Gal Pressman 
> Reviewed-by: Saeed Mahameed 
> ---
>  include/linux/netdevice.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 352066e..5ff1ef9 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -4407,8 +4407,8 @@ do {
> \
>   WARN(1, "netdevice: %s%s\n" format, netdev_name(dev),   \
>netdev_reg_state(dev), ##args)
>  
> -#define netdev_WARN_ONCE(dev, condition, format, arg...) \
> - WARN_ONCE(1, "netdevice: %s%s\n" format, netdev_name(dev)   \
> +#define netdev_WARN_ONCE(dev, format, args...)   
> \
> + WARN_ONCE(1, "netdevice: %s%s\n" format, netdev_name(dev),  \

You sure you want the newline before the format?

> netdev_reg_state(dev), ##args)
>  
>  /* netif printk helpers, similar to netdev_printk */


Re: [PATCH] MAINTAINERS: Update my email address.

2018-01-03 Thread Joe Perches
On Tue, 2018-01-02 at 20:14 -0800, Pravin B Shelar wrote:
> Signed-off-by: Pravin Shelar 
> ---
>  MAINTAINERS | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 753799d..1704ed4 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -10152,7 +10152,7 @@ F:drivers/irqchip/irq-ompic.c
>  F:   drivers/irqchip/irq-or1k-*
>  
>  OPENVSWITCH
> -M:   Pravin Shelar 
> +M:   Pravin B Shelar 

If you are going to change the format of your name
by adding a middle initial, you should probably
also add a .mailmap entry.

>  L:   netdev@vger.kernel.org
>  L:   d...@openvswitch.org
>  W:   http://openvswitch.org


Re: [PATCH net-next 2/2] tuntap: XDP transmission

2017-12-31 Thread Joe Perches
On Mon, 2018-01-01 at 11:48 +0800, kbuild test robot wrote:
> Hi Jason,
> 
> I love your patch! Perhaps something to improve:
> 
> [auto build test WARNING on net-next/master]
> 
> url:
> https://github.com/0day-ci/linux/commits/Jason-Wang/XDP-transmission-for-tuntap/20180101-105946
> config: i386-randconfig-x072-201800 (attached as .config)
> compiler: gcc-7 (Debian 7.2.0-12) 7.2.1 20171025
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=i386 
> 
> All warnings (new ones prefixed by >>):
> 
>drivers//net/tun.c: In function 'tun_xdp_to_ptr':
> > > drivers//net/tun.c:251:9: warning: cast to pointer from integer of 
> > > different size [-Wint-to-pointer-cast]
> 
>  return (void *)((unsigned long)ptr | TUN_XDP_FLAG);
> ^
>drivers//net/tun.c: In function 'tun_ptr_to_xdp':
>drivers//net/tun.c:257:9: warning: cast to pointer from integer of 
> different size [-Wint-to-pointer-cast]
>  return (void *)((unsigned long)ptr & ~TUN_XDP_FLAG);
> ^
> 
> vim +251 drivers//net/tun.c
> 
>248
>249void *tun_xdp_to_ptr(void *ptr)
>250{
>  > 251return (void *)((unsigned long)ptr | TUN_XDP_FLAG);

Does TUN_XDP_FLAG really need to be 0x1ULL?
Wouldn't 0x1UL suffice?



Re: [ovs-dev] Pravin Shelar

2017-12-27 Thread Joe Perches
On Wed, 2017-12-27 at 10:25 -0800, Ben Pfaff wrote:
> On Wed, Dec 27, 2017 at 04:22:55PM +0100, Julia Lawall wrote:
> > The email address pshe...@nicira.com listed for Pravin Shelar in
> > MAINTAINERS (OPENVSWITCH section) seems to bounce.
> 
> Pravin has used a newer address recently, so I sent out a suggested
> update (for OVS):
> https://patchwork.ozlabs.org/patch/853232/

As Pravin is still active with acks but not any authored patches in
the
last year, this should still be updated in the linux-kernel's
MAINTAINERS
file too.
---
diff --git a/MAINTAINERS b/MAINTAINERS
index
a6e86e20761e..5869e5f0b930 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@
-10137,7 +10137,7 @@ F: drivers/irqchip/irq-ompic.c
 F: dri
vers/irqchip/irq-or1k-*
 
 OPENVSWITCH
-M: Pravin Shelar 
+M: Pravin Shelar 
 L: netdev@vge
r.kernel.org
 L: d...@openvswitch.org
 W: http://openvswitch.org


Re: [-next PATCH 4/4] treewide: Use DEVICE_ATTR_WO

2017-12-19 Thread Joe Perches
On Tue, 2017-12-19 at 19:44 +0100, Borislav Petkov wrote:
> On Tue, Dec 19, 2017 at 10:15:09AM -0800, Joe Perches wrote:
> > Convert DEVICE_ATTR uses to DEVICE_ATTR_WO where possible.
> > 
> > Done with perl script:
> > 
> > $ git grep -w --name-only DEVICE_ATTR | \
> >   xargs perl -i -e 'local $/; while (<>) { 
> > s/\bDEVICE_ATTR\s*\(\s*(\w+)\s*,\s*\(?(?:\s*S_IWUSR\s*|\s*0200\s*)\)?\s*,\s*NULL\s*,\s*\s_store\s*\)/DEVICE_ATTR_WO(\1)/g;
> >  print;}'
[]
> > diff --git a/arch/x86/kernel/cpu/microcode/core.c 
> > b/arch/x86/kernel/cpu/microcode/core.c
[]
> > @@ -560,7 +560,7 @@ static ssize_t pf_show(struct device *dev,
> > return sprintf(buf, "0x%x\n", uci->cpu_sig.pf);
> >  }
> >  
> > -static DEVICE_ATTR(reload, 0200, NULL, reload_store);
> > +static DEVICE_ATTR_WO(reload);
> >  static DEVICE_ATTR(version, 0400, version_show, NULL);
> >  static DEVICE_ATTR(processor_flags, 0400, pf_show, NULL);
> >  
> 
> # cat /sys/devices/system/cpu/microcode/reload
> cat: /sys/devices/system/cpu/microcode/reload: Permission denied

Not different behavior.  It was and remains write only.

> The reason for the code churn being?

Consistency for easier grep by use-type.




[-next PATCH 0/4] sysfs and DEVICE_ATTR_

2017-12-19 Thread Joe Perches
Joe Perches (4):
  sysfs.h: Use octal permissions
  treewide: Use DEVICE_ATTR_RW
  treewide: Use DEVICE_ATTR_RO
  treewide: Use DEVICE_ATTR_WO

 arch/arm/mach-pxa/sharpsl_pm.c |  4 +-
 arch/s390/kernel/smp.c |  2 +-
 arch/s390/kernel/topology.c|  3 +-
 arch/sh/drivers/push-switch.c  |  2 +-
 arch/tile/kernel/sysfs.c   | 12 ++--
 arch/x86/kernel/cpu/microcode/core.c   |  2 +-
 drivers/acpi/device_sysfs.c|  6 +-
 drivers/char/ipmi/ipmi_msghandler.c| 17 +++---
 drivers/gpu/drm/i915/i915_sysfs.c  | 12 ++--
 drivers/input/touchscreen/elants_i2c.c |  2 +-
 drivers/net/ethernet/ibm/ibmvnic.c |  2 +-
 drivers/net/wimax/i2400m/sysfs.c   |  3 +-
 drivers/nvme/host/core.c   | 10 ++--
 drivers/platform/x86/compal-laptop.c   | 18 ++
 drivers/s390/cio/css.c |  8 +--
 drivers/s390/cio/device.c  | 10 ++--
 drivers/s390/crypto/ap_card.c  |  2 +-
 drivers/scsi/hpsa.c| 10 ++--
 drivers/scsi/lpfc/lpfc_attr.c  | 64 --
 .../staging/media/atomisp/pci/atomisp2/hmm/hmm.c   |  8 +--
 drivers/thermal/thermal_sysfs.c| 17 +++---
 drivers/tty/serial/sh-sci.c|  2 +-
 drivers/usb/host/xhci-dbgcap.c |  2 +-
 drivers/usb/phy/phy-tahvo.c|  2 +-
 drivers/video/fbdev/auo_k190x.c|  4 +-
 drivers/video/fbdev/w100fb.c   |  4 +-
 include/linux/sysfs.h  | 14 ++---
 lib/test_firmware.c| 14 ++---
 lib/test_kmod.c| 14 ++---
 sound/soc/omap/mcbsp.c |  4 +-
 sound/soc/soc-core.c   |  2 +-
 sound/soc/soc-dapm.c   |  2 +-
 32 files changed, 120 insertions(+), 158 deletions(-)

-- 
2.15.0



[-next PATCH 4/4] treewide: Use DEVICE_ATTR_WO

2017-12-19 Thread Joe Perches
Convert DEVICE_ATTR uses to DEVICE_ATTR_WO where possible.

Done with perl script:

$ git grep -w --name-only DEVICE_ATTR | \
  xargs perl -i -e 'local $/; while (<>) { 
s/\bDEVICE_ATTR\s*\(\s*(\w+)\s*,\s*\(?(?:\s*S_IWUSR\s*|\s*0200\s*)\)?\s*,\s*NULL\s*,\s*\s_store\s*\)/DEVICE_ATTR_WO(\1)/g;
 print;}'

Signed-off-by: Joe Perches <j...@perches.com>
---
 arch/s390/kernel/smp.c | 2 +-
 arch/x86/kernel/cpu/microcode/core.c   | 2 +-
 drivers/input/touchscreen/elants_i2c.c | 2 +-
 drivers/net/ethernet/ibm/ibmvnic.c | 2 +-
 drivers/net/wimax/i2400m/sysfs.c   | 3 +--
 drivers/scsi/lpfc/lpfc_attr.c  | 3 +--
 drivers/thermal/thermal_sysfs.c| 2 +-
 7 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index b8c1a85bcf2d..a919b2f0141d 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -1151,7 +1151,7 @@ static ssize_t __ref rescan_store(struct device *dev,
rc = smp_rescan_cpus();
return rc ? rc : count;
 }
-static DEVICE_ATTR(rescan, 0200, NULL, rescan_store);
+static DEVICE_ATTR_WO(rescan);
 #endif /* CONFIG_HOTPLUG_CPU */
 
 static int __init s390_smp_init(void)
diff --git a/arch/x86/kernel/cpu/microcode/core.c 
b/arch/x86/kernel/cpu/microcode/core.c
index c4fa4a85d4cb..09c74b0560dd 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -560,7 +560,7 @@ static ssize_t pf_show(struct device *dev,
return sprintf(buf, "0x%x\n", uci->cpu_sig.pf);
 }
 
-static DEVICE_ATTR(reload, 0200, NULL, reload_store);
+static DEVICE_ATTR_WO(reload);
 static DEVICE_ATTR(version, 0400, version_show, NULL);
 static DEVICE_ATTR(processor_flags, 0400, pf_show, NULL);
 
diff --git a/drivers/input/touchscreen/elants_i2c.c 
b/drivers/input/touchscreen/elants_i2c.c
index a458e5ec9e41..819213e88f32 100644
--- a/drivers/input/touchscreen/elants_i2c.c
+++ b/drivers/input/touchscreen/elants_i2c.c
@@ -1000,7 +1000,7 @@ static ssize_t show_iap_mode(struct device *dev,
"Normal" : "Recovery");
 }
 
-static DEVICE_ATTR(calibrate, S_IWUSR, NULL, calibrate_store);
+static DEVICE_ATTR_WO(calibrate);
 static DEVICE_ATTR(iap_mode, S_IRUGO, show_iap_mode, NULL);
 static DEVICE_ATTR(update_fw, S_IWUSR, NULL, write_update_fw);
 
diff --git a/drivers/net/ethernet/ibm/ibmvnic.c 
b/drivers/net/ethernet/ibm/ibmvnic.c
index 1dc4aef37d3a..42b96e1a1b13 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -4411,7 +4411,7 @@ static ssize_t failover_store(struct device *dev, struct 
device_attribute *attr,
return count;
 }
 
-static DEVICE_ATTR(failover, 0200, NULL, failover_store);
+static DEVICE_ATTR_WO(failover);
 
 static unsigned long ibmvnic_get_desired_dma(struct vio_dev *vdev)
 {
diff --git a/drivers/net/wimax/i2400m/sysfs.c b/drivers/net/wimax/i2400m/sysfs.c
index 1237109f251a..8c67df11105c 100644
--- a/drivers/net/wimax/i2400m/sysfs.c
+++ b/drivers/net/wimax/i2400m/sysfs.c
@@ -65,8 +65,7 @@ ssize_t i2400m_idle_timeout_store(struct device *dev,
 }
 
 static
-DEVICE_ATTR(i2400m_idle_timeout, S_IWUSR,
-   NULL, i2400m_idle_timeout_store);
+DEVICE_ATTR_WO(i2400m_idle_timeout);
 
 static
 struct attribute *i2400m_dev_attrs[] = {
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 517ff203cfde..6ddaf51a23f6 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -2418,8 +2418,7 @@ lpfc_soft_wwn_enable_store(struct device *dev, struct 
device_attribute *attr,
 
return count;
 }
-static DEVICE_ATTR(lpfc_soft_wwn_enable, S_IWUSR, NULL,
-  lpfc_soft_wwn_enable_store);
+static DEVICE_ATTR_WO(lpfc_soft_wwn_enable);
 
 /**
  * lpfc_soft_wwpn_show - Return the cfg soft ww port name of the adapter
diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c
index 2bc964392924..ba81c9080f6e 100644
--- a/drivers/thermal/thermal_sysfs.c
+++ b/drivers/thermal/thermal_sysfs.c
@@ -317,7 +317,7 @@ emul_temp_store(struct device *dev, struct device_attribute 
*attr,
 
return ret ? ret : count;
 }
-static DEVICE_ATTR(emul_temp, S_IWUSR, NULL, emul_temp_store);
+static DEVICE_ATTR_WO(emul_temp);
 #endif
 
 static ssize_t
-- 
2.15.0



Re: [PATCH v2 2/3] vsprintf: print if symbol not found

2017-12-18 Thread Joe Perches
On Tue, 2017-12-19 at 14:28 +1100, Tobin C. Harding wrote:
> Depends on: commit 40eee173a35e ("kallsyms: don't leak address when
> symbol not found")
> 
> Currently vsprintf for specifiers %p[SsB] relies on the behaviour of
> kallsyms (sprint_symbol()) and prints the actual address if a symbol is
> not found. Previous patch changes this behaviour so that sprint_symbol()
> returns an error if symbol not found. With this patch in place we can
> print a sanitized message '' instead of leaking the
> address.
> 
> Print '' for printk specifier %p[sSB] if symbol look
> up fails.
> 
> Signed-off-by: Tobin C. Harding 
> ---
>  lib/vsprintf.c | 11 ---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index 01c3957b2de6..820ed4fe6e6c 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -674,6 +674,8 @@ char *symbol_string(char *buf, char *end, void *ptr,
>   unsigned long value;
>  #ifdef CONFIG_KALLSYMS
>   char sym[KSYM_SYMBOL_LEN];
> + const char *sym_not_found = "";

This will be reinitialized on every use.

> + int ret;
>  #endif
>  
>   if (fmt[1] == 'R')
> @@ -682,11 +684,14 @@ char *symbol_string(char *buf, char *end, void *ptr,
>  
>  #ifdef CONFIG_KALLSYMS
>   if (*fmt == 'B')
> - sprint_backtrace(sym, value);
> + ret = sprint_backtrace(sym, value);
>   else if (*fmt != 'f' && *fmt != 's')
> - sprint_symbol(sym, value);
> + ret = sprint_symbol(sym, value);
>   else
> - sprint_symbol_no_offset(sym, value);
> + ret = sprint_symbol_no_offset(sym, value);
> +
> + if (ret == -1)
> + strcpy(sym, sym_not_found);


This could avoid the unnecessary strcpy if sym_not_found
was not used at all and this was used instead

if (ret == -1)
return string(buf, end, "", spec);

return string(buf, end, sym, spec);

or maybe

return string(buf, end, ret == -1 ? "" : sum, spec);

>  
>   return string(buf, end, sym, spec);
>  #else


Re: [PATCH v2 0/5] Support for generalized use of make C={1,2} via a wrapper program

2017-12-18 Thread Joe Perches
On Mon, 2017-12-18 at 10:46 -0700, Jason Gunthorpe wrote:
> On Sun, Dec 17, 2017 at 10:00:17PM -0800, Joe Perches wrote:
> 
> > > Today when we run checkers we get so many warnings it is too hard to
> > > make any sense of it.
> > 
> > Here is a list of the checkpatch messages for drivers/infiniband
> > sorted by type.
> > 
> > Many of these might be corrected by using
> > 
> > $ ./scripts/checkpatch.pl -f --fix-inplace --types= \
> >   $(git ls-files drivers/infiniband/)
> 
> How many of these do you think it is worth to fix?
> 
> We do get a steady trickle of changes in this topic every cycle.
> 
> Is it better to just do a big number of them all at once?

I think so.

> Do you have
> an idea how disruptive this kind of work is to the whole patch flow
> eg new patches no longer applying to for-next, backports no longer
> applying, merge conflicts?

Some do complain about backport patch purity.

I think that difficulty is overstated, but then
again, I don't do backports very often.

I think the best time for any rather wholesale
change is immediately after an rc-1 so overall
in-flight patch conflict volume is minimized.


  1   2   3   4   5   6   7   8   9   >