Re: [PATCH 0/2] staging: wilc1000: TODO list updates

2018-04-25 Thread Claudiu Beznea
Reviewed-by: Claudiu Beznea 

On 24.04.2018 19:07, Ajay Singh wrote:
> Updated the TODO list by removing items, which are already addressed.
> Also remove the code to handle IOCTL(SIOCSIWPRIV) as Wext support is
> not present in the driver.
> 
> Ajay Singh (2):
>   staging: wilc1000: remove registering of ndo_do_ioctl callback
>   staging: wilc1000: updated TODO list
> 
>  drivers/staging/wilc1000/TODO |  8 -
>  drivers/staging/wilc1000/linux_wlan.c | 63 
> ---
>  2 files changed, 71 deletions(-)
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: mt7621-mmc: Fix calculation typo in msdc_init_gpd_bd

2018-04-25 Thread NeilBrown
On Wed, Apr 25 2018, Christian Lütke-Stetzkamp wrote:

> When refactoring the function msdc_init_gpd_bd, an error in the
> calculation of the bd.next address was introduced. The offset has to
> be added to the base address, not multiplied.
>
> Fixes: 8f2395586cf0 ("staging: mt7621-mmc: Refactor msdc_init_gpd_bd")
> Reported-by: NeilBrown 

Now ...
Reported-and-tested-by: NeilBrown 

Thanks,
NeilBrown


> Signed-off-by: Christian Lütke-Stetzkamp 
> ---
>  drivers/staging/mt7621-mmc/sd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
> index ae70f9d0b346..a003f8324088 100644
> --- a/drivers/staging/mt7621-mmc/sd.c
> +++ b/drivers/staging/mt7621-mmc/sd.c
> @@ -2505,7 +2505,7 @@ static void msdc_init_gpd_bd(struct msdc_host *host, 
> struct msdc_dma *dma)
>  
>   memset(bd, 0, sizeof(struct bd) * MAX_BD_NUM);
>   for (i = 0; i < (MAX_BD_NUM - 1); i++)
> - bd[i].next = (void *)(dma->bd_addr * sizeof(*bd) * (i + 1));
> + bd[i].next = (void *)(dma->bd_addr + sizeof(*bd) * (i + 1));
>  }
>  
>  static int msdc_drv_probe(struct platform_device *pdev)
> -- 
> 2.16.1


signature.asc
Description: PGP signature
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/8] dmaengine: shdmac: Change platform check to CONFIG_ARCH_RENESAS

2018-04-25 Thread Vinod Koul
On Fri, Apr 20, 2018 at 03:28:28PM +0200, Geert Uytterhoeven wrote:
> Since commit 9b5ba0df4ea4f940 ("ARM: shmobile: Introduce ARCH_RENESAS")
> is CONFIG_ARCH_RENESAS a more appropriate platform check than the legacy
> CONFIG_ARCH_SHMOBILE, hence use the former.
> 
> Renesas SuperH SH-Mobile SoCs are still covered by the CONFIG_CPU_SH4
> check, just like before support for Renesas ARM SoCs was added.
> 
> Instead of blindly changing all the #ifdefs, switch the main code block
> in sh_dmae_probe() to IS_ENABLED(), as this allows to remove all the
> remaining #ifdefs.
> 
> This will allow to drop ARCH_SHMOBILE on ARM in the near future.

Applied, thanks

-- 
~Vinod
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: fsl-dpaa2/eth: Add support for hardware timestamping

2018-04-25 Thread Yangbo Lu
From: Ioana Radulescu 

Hardware timestamping is supported both on Rx and Tx paths.
On Rx, timestamping is enabled for all frames. On Tx, we
only instruct the hardware to timestamp the frames marked
accordingly by the stack.

Signed-off-by: Ioana Radulescu 
Signed-off-by: Yangbo Lu 
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c |  109 +++-
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h |   48 ++-
 2 files changed, 151 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 553678d..d9febba 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -38,8 +38,11 @@
 #include 
 #include 
 #include 
-
+#include 
 #include 
+
+#include 
+
 #include "dpaa2-eth.h"
 
 /* CREATE_TRACE_POINTS only needs to be defined once. Other dpa files
@@ -275,6 +278,16 @@ static void dpaa2_eth_rx(struct dpaa2_eth_priv *priv,
 
prefetch(skb->data);
 
+   /* Get the timestamp value */
+   if (priv->ts_rx_en) {
+   struct skb_shared_hwtstamps *shhwtstamps = skb_hwtstamps(skb);
+   u64 *ns = dpaa2_get_ts(vaddr, false);
+
+   *ns = DPAA2_PTP_NOMINAL_FREQ_PERIOD_NS * le64_to_cpup(ns);
+   memset(shhwtstamps, 0, sizeof(*shhwtstamps));
+   shhwtstamps->hwtstamp = ns_to_ktime(*ns);
+   }
+
/* Check if we need to validate the L4 csum */
if (likely(dpaa2_fd_get_frc(fd) & DPAA2_FD_FRC_FASV)) {
status = le32_to_cpu(fas->status);
@@ -334,6 +347,28 @@ static int consume_frames(struct dpaa2_eth_channel *ch)
return cleaned;
 }
 
+/* Configure the egress frame annotation for timestamp update */
+static void enable_tx_tstamp(struct dpaa2_fd *fd, void *buf_start)
+{
+   struct dpaa2_faead *faead;
+   u32 ctrl, frc;
+
+   /* Mark the egress frame annotation area as valid */
+   frc = dpaa2_fd_get_frc(fd);
+   dpaa2_fd_set_frc(fd, frc | DPAA2_FD_FRC_FAEADV);
+
+   /* Set hardware annotation size */
+   ctrl = dpaa2_fd_get_ctrl(fd);
+   dpaa2_fd_set_ctrl(fd, ctrl | DPAA2_FD_CTRL_ASAL);
+
+   /* enable UPD (update prepanded data) bit in FAEAD field of
+* hardware frame annotation area
+*/
+   ctrl = DPAA2_FAEAD_A2V | DPAA2_FAEAD_UPDV | DPAA2_FAEAD_UPD;
+   faead = dpaa2_get_faead(buf_start, true);
+   faead->ctrl = cpu_to_le32(ctrl);
+}
+
 /* Create a frame descriptor based on a fragmented skb */
 static int build_sg_fd(struct dpaa2_eth_priv *priv,
   struct sk_buff *skb,
@@ -420,6 +455,9 @@ static int build_sg_fd(struct dpaa2_eth_priv *priv,
dpaa2_fd_set_len(fd, skb->len);
dpaa2_fd_set_ctrl(fd, DPAA2_FD_CTRL_PTA | DPAA2_FD_CTRL_PTV1);
 
+   if (priv->ts_tx_en && skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)
+   enable_tx_tstamp(fd, sgt_buf);
+
return 0;
 
 dma_map_single_failed:
@@ -470,6 +508,9 @@ static int build_single_fd(struct dpaa2_eth_priv *priv,
dpaa2_fd_set_format(fd, dpaa2_fd_single);
dpaa2_fd_set_ctrl(fd, DPAA2_FD_CTRL_PTA | DPAA2_FD_CTRL_PTV1);
 
+   if (priv->ts_tx_en && skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)
+   enable_tx_tstamp(fd, buffer_start);
+
return 0;
 }
 
@@ -520,6 +561,19 @@ static void free_tx_fd(const struct dpaa2_eth_priv *priv,
return;
}
 
+   /* Get the timestamp value */
+   if (priv->ts_tx_en && skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) {
+   struct skb_shared_hwtstamps shhwtstamps;
+   u64 *ns;
+
+   memset(&shhwtstamps, 0, sizeof(shhwtstamps));
+
+   ns = dpaa2_get_ts(skbh, true);
+   *ns = DPAA2_PTP_NOMINAL_FREQ_PERIOD_NS * le64_to_cpup(ns);
+   shhwtstamps.hwtstamp = ns_to_ktime(*ns);
+   skb_tstamp_tx(skb, &shhwtstamps);
+   }
+
/* Free SGT buffer allocated on tx */
if (fd_format != dpaa2_fd_single)
skb_free_frag(skbh);
@@ -552,6 +606,10 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, 
struct net_device *net_dev)
goto err_alloc_headroom;
}
percpu_extras->tx_reallocs++;
+
+   if (skb->sk)
+   skb_set_owner_w(ns, skb->sk);
+
dev_kfree_skb(skb);
skb = ns;
}
@@ -1365,6 +1423,45 @@ static int dpaa2_eth_set_features(struct net_device 
*net_dev,
return 0;
 }
 
+static int dpaa2_eth_ts_ioctl(struct net_device *dev, struct ifreq *rq, int 
cmd)
+{
+   struct dpaa2_eth_priv *priv = netdev_priv(dev);
+   struct hwtstamp_config config;
+
+   if (copy_from_user(&config, rq->ifr_data, sizeof(config)))
+   return -EFAULT;
+
+   switch (config.tx_type) {
+   case HWTSTAMP_TX_OFF:
+   priv->ts_tx_en = false;
+   break;
+  

Re: [PATCH] staging: fsl-dpaa2/eth: Add support for hardware timestamping

2018-04-25 Thread Dan Carpenter
On Wed, Apr 25, 2018 at 05:17:49PM +0800, Yangbo Lu wrote:
> @@ -275,6 +278,16 @@ static void dpaa2_eth_rx(struct dpaa2_eth_priv *priv,
>  
>   prefetch(skb->data);
>  
> + /* Get the timestamp value */
> + if (priv->ts_rx_en) {
> + struct skb_shared_hwtstamps *shhwtstamps = skb_hwtstamps(skb);
> + u64 *ns = dpaa2_get_ts(vaddr, false);
> +
> + *ns = DPAA2_PTP_NOMINAL_FREQ_PERIOD_NS * le64_to_cpup(ns);

This will cause Sparse endianess warnings.

I don't totally understand why we're writing to *ns.  Do we access *ns
again or not?  Either way, this doesn't seem right.  In other words, why
don't we do this:

__le64 *period = dpaa2_get_ts(vaddr, false);
u64 ns;

ns = DPAA2_PTP_NOMINAL_FREQ_PERIOD_NS * le64_to_cpup(period);
memset(shhwtstamps, 0, sizeof(*shhwtstamps));
shhwtstamps->hwtstamp = ns_to_ktime(ns);

Then if we need to save a munged *ns then we can do this at the end:

/* we need this because blah blah blah */
*period = (__le64)ns;


> + memset(shhwtstamps, 0, sizeof(*shhwtstamps));
> + shhwtstamps->hwtstamp = ns_to_ktime(*ns);
> + }
> +
>   /* Check if we need to validate the L4 csum */
>   if (likely(dpaa2_fd_get_frc(fd) & DPAA2_FD_FRC_FASV)) {
>   status = le32_to_cpu(fas->status);

[ snip ]

> @@ -520,6 +561,19 @@ static void free_tx_fd(const struct dpaa2_eth_priv *priv,
>   return;
>   }
>  
> + /* Get the timestamp value */
> + if (priv->ts_tx_en && skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) {
> + struct skb_shared_hwtstamps shhwtstamps;
> + u64 *ns;
> +
> + memset(&shhwtstamps, 0, sizeof(shhwtstamps));
> +
> + ns = dpaa2_get_ts(skbh, true);
> + *ns = DPAA2_PTP_NOMINAL_FREQ_PERIOD_NS * le64_to_cpup(ns);
> + shhwtstamps.hwtstamp = ns_to_ktime(*ns);
> + skb_tstamp_tx(skb, &shhwtstamps);

Sparse issues here also.

> + }
> +
>   /* Free SGT buffer allocated on tx */
>   if (fd_format != dpaa2_fd_single)
>   skb_free_frag(skbh);
> @@ -552,6 +606,10 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, 
> struct net_device *net_dev)
>   goto err_alloc_headroom;
>   }
>   percpu_extras->tx_reallocs++;
> +
> + if (skb->sk)
> + skb_set_owner_w(ns, skb->sk);

Is this really related?  (I have not looked at this code).

> +
>   dev_kfree_skb(skb);
>   skb = ns;
>   }

[ snip ]

> @@ -319,6 +351,9 @@ struct dpaa2_eth_priv {
>   u16 bpid;
>   struct iommu_domain *iommu_domain;
>  
> + bool ts_tx_en; /* Tx timestamping enabled */
> + bool ts_rx_en; /* Rx timestamping enabled */

These variable names are not great.  I wouldn't have understood "ts_"
without the comment.  "tx_" is good.  "en" is confusing until you read
the comment.  But really it should just be left out because "enable" is
assumed, generally.  Last week I asked someone to rewrite a patch that
had a _disable variable because negative variables lead to double
negatives which screw with my tiny head.

if (blah_disable != 0) {

OH MY BLASTED WORD MY BRIAN ESPLODED!!!1!

So let's just name these "tx_timestamps" or something.


> +
>   u16 tx_qdid;
>   u16 rx_buf_align;
>   struct fsl_mc_io *mc_io;

regards,
dan carpenter
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4.14 087/183] x86/hyperv: Stop suppressing X86_FEATURE_PCID

2018-04-25 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Vitaly Kuznetsov 


[ Upstream commit 617ab45c9a8900e64a78b43696c02598b8cad68b ]

When hypercall-based TLB flush was enabled for Hyper-V guests PCID feature
was deliberately suppressed as a precaution: back then PCID was never
exposed to Hyper-V guests and it wasn't clear what will happen if some day
it becomes available. The day came and PCID/INVPCID features are already
exposed on certain Hyper-V hosts.

>From TLFS (as of 5.0b) it is unclear how TLB flush hypercalls combine with
PCID. In particular the usage of PCID is per-cpu based: the same mm gets
different CR3 values on different CPUs. If the hypercall does exact
matching this will fail. However, this is not the case. David Zhang
explains:

 "In practice, the AddressSpace argument is ignored on any VM that supports
  PCIDs.

  Architecturally, the AddressSpace argument must match the CR3 with PCID
  bits stripped out (i.e., the low 12 bits of AddressSpace should be 0 in
  long mode). The flush hypercalls flush all PCIDs for the specified
  AddressSpace."

With this, PCID can be enabled.

Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: Thomas Gleixner 
Cc: David Zhang 
Cc: Stephen Hemminger 
Cc: Haiyang Zhang 
Cc: "Michael Kelley (EOSG)" 
Cc: Andy Lutomirski 
Cc: de...@linuxdriverproject.org
Cc: "K. Y. Srinivasan" 
Cc: Aditya Bhandari 
Link: https://lkml.kernel.org/r/20180124103629.29980-1-vkuzn...@redhat.com
Signed-off-by: Sasha Levin 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/x86/hyperv/mmu.c |   12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

--- a/arch/x86/hyperv/mmu.c
+++ b/arch/x86/hyperv/mmu.c
@@ -137,7 +137,12 @@ static void hyperv_flush_tlb_others(cons
}
 
if (info->mm) {
+   /*
+* AddressSpace argument must match the CR3 with PCID bits
+* stripped out.
+*/
flush->address_space = virt_to_phys(info->mm->pgd);
+   flush->address_space &= CR3_ADDR_MASK;
flush->flags = 0;
} else {
flush->address_space = 0;
@@ -219,7 +224,12 @@ static void hyperv_flush_tlb_others_ex(c
}
 
if (info->mm) {
+   /*
+* AddressSpace argument must match the CR3 with PCID bits
+* stripped out.
+*/
flush->address_space = virt_to_phys(info->mm->pgd);
+   flush->address_space &= CR3_ADDR_MASK;
flush->flags = 0;
} else {
flush->address_space = 0;
@@ -278,8 +288,6 @@ void hyperv_setup_mmu_ops(void)
if (!(ms_hyperv.hints & HV_X64_REMOTE_TLB_FLUSH_RECOMMENDED))
return;
 
-   setup_clear_cpu_cap(X86_FEATURE_PCID);
-
if (!(ms_hyperv.hints & HV_X64_EX_PROCESSOR_MASKS_RECOMMENDED)) {
pr_info("Using hypercall for remote TLB flush\n");
pv_mmu_ops.flush_tlb_others = hyperv_flush_tlb_others;


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4.14 102/183] x86/hyperv: Check for required priviliges in hyperv_init()

2018-04-25 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Vitaly Kuznetsov 


[ Upstream commit 89a8f6d4904c8cf3ff8fee9fdaff392a6bbb8bf6 ]

In hyperv_init() its presumed that it always has access to VP index and
hypercall MSRs while according to the specification it should be checked if
it's allowed to access the corresponding MSRs before accessing them.

Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: Thomas Gleixner 
Reviewed-by: Thomas Gleixner 
Cc: Stephen Hemminger 
Cc: k...@vger.kernel.org
Cc: Radim Krčmář 
Cc: Haiyang Zhang 
Cc: "Michael Kelley (EOSG)" 
Cc: Roman Kagan 
Cc: Andy Lutomirski 
Cc: de...@linuxdriverproject.org
Cc: Paolo Bonzini 
Cc: "K. Y. Srinivasan" 
Cc: Cathy Avery 
Cc: Mohammed Gamal 
Link: https://lkml.kernel.org/r/20180124132337.30138-2-vkuzn...@redhat.com
Signed-off-by: Sasha Levin 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/x86/hyperv/hv_init.c |9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -110,12 +110,19 @@ static int hv_cpu_init(unsigned int cpu)
  */
 void hyperv_init(void)
 {
-   u64 guest_id;
+   u64 guest_id, required_msrs;
union hv_x64_msr_hypercall_contents hypercall_msr;
 
if (x86_hyper_type != X86_HYPER_MS_HYPERV)
return;
 
+   /* Absolutely required MSRs */
+   required_msrs = HV_X64_MSR_HYPERCALL_AVAILABLE |
+   HV_X64_MSR_VP_INDEX_AVAILABLE;
+
+   if ((ms_hyperv.features & required_msrs) != required_msrs)
+   return;
+
/* Allocate percpu VP index */
hv_vp_index = kmalloc_array(num_possible_cpus(), sizeof(*hv_vp_index),
GFP_KERNEL);


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


your photos need this

2018-04-25 Thread Lance

We're a good team, who can process 500+ images each day.

If you need any image editing service, please let us know.
Such as ecommerce photos editing, jewelry photos retouching, beauty and
skin image retouching,
and wedding photo editing, image cut out and clipping path, masking.

Our advantages:
Quality is good
Turnaround time fast
7/24/365 available

Best regards,
Lance Nelson

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/2] staging: gdm724x: add SPDX identifiers to all files.

2018-04-25 Thread Greg Kroah-Hartman
It's good to have SPDX identifiers in all files to make it easier to
audit the kernel tree for correct licenses.

Fix up the all of the staging gdm724x files to have a proper SPDX
identifier, based on the license text in the file itself.  The SPDX
identifier is a legally binding shorthand, which can be used instead of
the full boiler plate text.

Cc: Thomas Gleixner 
Cc: Kate Stewart 
Cc: Philippe Ombredanne 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/staging/gdm724x/gdm_endian.c | 1 +
 drivers/staging/gdm724x/gdm_endian.h | 1 +
 drivers/staging/gdm724x/gdm_lte.c| 1 +
 drivers/staging/gdm724x/gdm_lte.h| 1 +
 drivers/staging/gdm724x/gdm_mux.c| 1 +
 drivers/staging/gdm724x/gdm_mux.h| 1 +
 drivers/staging/gdm724x/gdm_tty.c| 1 +
 drivers/staging/gdm724x/gdm_tty.h| 1 +
 drivers/staging/gdm724x/gdm_usb.c| 1 +
 drivers/staging/gdm724x/gdm_usb.h| 1 +
 drivers/staging/gdm724x/hci.h| 1 +
 drivers/staging/gdm724x/hci_packet.h | 1 +
 drivers/staging/gdm724x/netlink_k.c  | 1 +
 drivers/staging/gdm724x/netlink_k.h  | 1 +
 14 files changed, 14 insertions(+)

diff --git a/drivers/staging/gdm724x/gdm_endian.c 
b/drivers/staging/gdm724x/gdm_endian.c
index 4200391b1a97..c79cfbd8daa6 100644
--- a/drivers/staging/gdm724x/gdm_endian.c
+++ b/drivers/staging/gdm724x/gdm_endian.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
  *
diff --git a/drivers/staging/gdm724x/gdm_endian.h 
b/drivers/staging/gdm724x/gdm_endian.h
index e58d29f868ba..e38e9924d956 100644
--- a/drivers/staging/gdm724x/gdm_endian.h
+++ b/drivers/staging/gdm724x/gdm_endian.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
  *
diff --git a/drivers/staging/gdm724x/gdm_lte.c 
b/drivers/staging/gdm724x/gdm_lte.c
index 4f3c518304f2..9539c68403da 100644
--- a/drivers/staging/gdm724x/gdm_lte.c
+++ b/drivers/staging/gdm724x/gdm_lte.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
  *
diff --git a/drivers/staging/gdm724x/gdm_lte.h 
b/drivers/staging/gdm724x/gdm_lte.h
index bad0855e4721..d15c7f491ca9 100644
--- a/drivers/staging/gdm724x/gdm_lte.h
+++ b/drivers/staging/gdm724x/gdm_lte.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
  *
diff --git a/drivers/staging/gdm724x/gdm_mux.c 
b/drivers/staging/gdm724x/gdm_mux.c
index 63921bad519e..8b860e2f5192 100644
--- a/drivers/staging/gdm724x/gdm_mux.c
+++ b/drivers/staging/gdm724x/gdm_mux.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
  *
diff --git a/drivers/staging/gdm724x/gdm_mux.h 
b/drivers/staging/gdm724x/gdm_mux.h
index 0871b8feec55..38764aa0cbb8 100644
--- a/drivers/staging/gdm724x/gdm_mux.h
+++ b/drivers/staging/gdm724x/gdm_mux.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
  *
diff --git a/drivers/staging/gdm724x/gdm_tty.c 
b/drivers/staging/gdm724x/gdm_tty.c
index 3cdebb81ba63..2336462823c6 100644
--- a/drivers/staging/gdm724x/gdm_tty.c
+++ b/drivers/staging/gdm724x/gdm_tty.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
  *
diff --git a/drivers/staging/gdm724x/gdm_tty.h 
b/drivers/staging/gdm724x/gdm_tty.h
index 195c5902989f..84c800f9c41a 100644
--- a/drivers/staging/gdm724x/gdm_tty.h
+++ b/drivers/staging/gdm724x/gdm_tty.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
  *
diff --git a/drivers/staging/gdm724x/gdm_usb.c 
b/drivers/staging/gdm724x/gdm_usb.c
index c95bad4a8615..6fd2682f89dd 100644
--- a/drivers/staging/gdm724x/gdm_usb.c
+++ b/drivers/staging/gdm724x/gdm_usb.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
  *
diff --git a/drivers/staging/gdm724x/gdm_usb.h 
b/drivers/staging/gdm724x/gdm_usb.h
index 701038685e23..a5521092925c 100644
--- a/drivers/staging/gdm724x/gdm_usb.h
+++ b/drivers/staging/gdm724x/gdm_usb.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
  *
diff --git a/drivers/staging/gdm724x/hci.h b/drivers/staging/gdm724x/hci.h
index 9a591b0db516..bcc682fbc1be 100644
--- a/drivers/staging/gdm724x/hci.h
+++ b/drivers/staging/gdm724x/hci.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
  *
diff --git a/drivers/staging/gdm724x/hci_packet.h 
b/drivers/staging/gdm724x/hci_packet.h
index 22ce8b9477b6..4ef621d98d28 100644
--- a/drivers/staging/gdm724x/hci_packet.h
+++ b/drivers/staging/gdm724x/hci

[PATCH 2/2] staging: gdm724x: remove redundant license information

2018-04-25 Thread Greg Kroah-Hartman
Now that the SPDX tag is in all gdm724x files, that identifies the
license in a specific and legally-defined manner.  So the extra GPL text
wording can be removed as it is no longer needed at all.

This is done on a quest to remove the 700+ different ways that files in
the kernel describe the GPL license text.  And there's unneeded stuff
like the address (sometimes incorrect) for the FSF which is never
needed.

Signed-off-by: Greg Kroah-Hartman 
---
 drivers/staging/gdm724x/gdm_endian.c | 13 +
 drivers/staging/gdm724x/gdm_endian.h | 13 +
 drivers/staging/gdm724x/gdm_lte.c| 13 +
 drivers/staging/gdm724x/gdm_lte.h| 13 +
 drivers/staging/gdm724x/gdm_mux.c| 13 +
 drivers/staging/gdm724x/gdm_mux.h| 13 +
 drivers/staging/gdm724x/gdm_tty.c| 13 +
 drivers/staging/gdm724x/gdm_tty.h| 13 +
 drivers/staging/gdm724x/gdm_usb.c| 13 +
 drivers/staging/gdm724x/gdm_usb.h| 13 +
 drivers/staging/gdm724x/hci.h| 13 +
 drivers/staging/gdm724x/hci_packet.h | 13 +
 drivers/staging/gdm724x/netlink_k.c  | 13 +
 drivers/staging/gdm724x/netlink_k.h  | 13 +
 14 files changed, 14 insertions(+), 168 deletions(-)

diff --git a/drivers/staging/gdm724x/gdm_endian.c 
b/drivers/staging/gdm724x/gdm_endian.c
index c79cfbd8daa6..ae39e59daf70 100644
--- a/drivers/staging/gdm724x/gdm_endian.c
+++ b/drivers/staging/gdm724x/gdm_endian.c
@@ -1,16 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+/* Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. */
 
 #include 
 #include "gdm_endian.h"
diff --git a/drivers/staging/gdm724x/gdm_endian.h 
b/drivers/staging/gdm724x/gdm_endian.h
index e38e9924d956..f373dc3a19bf 100644
--- a/drivers/staging/gdm724x/gdm_endian.h
+++ b/drivers/staging/gdm724x/gdm_endian.h
@@ -1,16 +1,5 @@
 /* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+/* Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. */
 
 #ifndef __GDM_ENDIAN_H__
 #define __GDM_ENDIAN_H__
diff --git a/drivers/staging/gdm724x/gdm_lte.c 
b/drivers/staging/gdm724x/gdm_lte.c
index 9539c68403da..f071ef013288 100644
--- a/drivers/staging/gdm724x/gdm_lte.c
+++ b/drivers/staging/gdm724x/gdm_lte.c
@@ -1,16 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+/* Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
diff --git a/drivers/staging/gdm724x/gdm_lte.h 
b/drivers/staging/gdm724x/gdm_lte.h
index d15c7f491ca9..f2143a6e0e99 100644
--- a/drivers/staging/gdm724x/gdm_lte.h
+++ b/drivers/staging/gdm724x/gdm_lte.h
@@ -1,16 +1,5 @@
 /* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+/* Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. */
 
 #ifndef _GDM_LTE_H_
 #define _

Re: [PATCH 06/18] staging: ks7010: use GPL-2.0+ SPDX license identifier

2018-04-25 Thread Greg KH
On Tue, Apr 24, 2018 at 03:49:55PM +0200, Sergio Paracuellos wrote:
> The summary text for the GPL is not needed since the SPDX identifier
> is a legally binding shorthand that can be used instead.
> 
> Signed-off-by: Sergio Paracuellos 
> ---
>  drivers/staging/ks7010/ks7010_sdio.c   | 5 +
>  drivers/staging/ks7010/ks7010_sdio.h   | 5 +
>  drivers/staging/ks7010/ks_hostif.c | 5 +
>  drivers/staging/ks7010/ks_hostif.h | 5 +
>  drivers/staging/ks7010/ks_wlan.h   | 5 +
>  drivers/staging/ks7010/ks_wlan_ioctl.h | 5 +
>  drivers/staging/ks7010/ks_wlan_net.c   | 5 +
>  drivers/staging/ks7010/michael_mic.c   | 5 +
>  drivers/staging/ks7010/michael_mic.h   | 5 +
>  9 files changed, 9 insertions(+), 36 deletions(-)
> 
> diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
> b/drivers/staging/ks7010/ks7010_sdio.c
> index b29f48c..b6cabab 100644
> --- a/drivers/staging/ks7010/ks7010_sdio.c
> +++ b/drivers/staging/ks7010/ks7010_sdio.c
> @@ -1,13 +1,10 @@
> +/* SPDX-License-Identifier: GPL-2.0 */

Subject does not match what you put here :(

Please be exact, it matters.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: ks7010: fix ks_wlan_start_xmit()'s return type

2018-04-25 Thread Greg Kroah-Hartman
On Tue, Apr 24, 2018 at 03:18:21PM +0200, Luc Van Oostenryck wrote:
> The method ndo_start_xmit() is defined as returning an 'netdev_tx_t',
> which is a typedef for an enum type, but the implementation in this
> driver returns an 'int'.
> 
> Fix this by returning 'netdev_tx_t' in this driver too.
> 
> Signed-off-by: Luc Van Oostenryck 
> ---
>  drivers/staging/ks7010/ks_wlan_net.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Patch does not apply to my tree, please rebase and resend.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 03/16] staging: ks7010: refactor ks_wlan_set_scan_type function

2018-04-25 Thread Sergio Paracuellos
This commit changes logic to handle invalid values first
and just assign valid ones afterwards.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_wlan_net.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 68aece7..b10c54c 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -1937,14 +1937,11 @@ static int ks_wlan_set_scan_type(struct net_device *dev,
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
/* for SLEEP MODE */
-   if (*uwrq == ACTIVE_SCAN) { /* 0 */
-   priv->reg.scan_type = ACTIVE_SCAN;
-   } else if (*uwrq == PASSIVE_SCAN) { /* 1 */
-   priv->reg.scan_type = PASSIVE_SCAN;
-   } else {
+
+   if (*uwrq != ACTIVE_SCAN && *uwrq != PASSIVE_SCAN)
return -EINVAL;
-   }
 
+   priv->reg.scan_type = *uwrq;
return 0;
 }
 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 01/16] staging: ks7010: add SPDX identifiers to all files

2018-04-25 Thread Sergio Paracuellos
It's good to have SPDX identifiers in all files to make it easier to
audit the kernel tree for correct licenses.

Fix up the all of the staging ks7010 files to have a proper SPDX
identifier, based on the license text in the file itself.  The SPDX
identifier is a legally binding shorthand, which can be used instead of
the full boiler plate text.

Extra GPL text wording can be removed as it is no longer needed at all.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks7010_sdio.c   | 5 +
 drivers/staging/ks7010/ks7010_sdio.h   | 5 +
 drivers/staging/ks7010/ks_hostif.c | 5 +
 drivers/staging/ks7010/ks_hostif.h | 5 +
 drivers/staging/ks7010/ks_wlan.h   | 5 +
 drivers/staging/ks7010/ks_wlan_ioctl.h | 5 +
 drivers/staging/ks7010/ks_wlan_net.c   | 5 +
 drivers/staging/ks7010/michael_mic.c   | 5 +
 drivers/staging/ks7010/michael_mic.h   | 5 +
 9 files changed, 9 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index b29f48c..b6cabab 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -1,13 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  *   Driver for KeyStream, KS7010 based SDIO cards.
  *
  *   Copyright (C) 2006-2008 KeyStream Corp.
  *   Copyright (C) 2009 Renesas Technology Corp.
  *   Copyright (C) 2016 Sang Engineering, Wolfram Sang
- *
- *   This program is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2 as
- *   published by the Free Software Foundation.
  */
 
 #include 
diff --git a/drivers/staging/ks7010/ks7010_sdio.h 
b/drivers/staging/ks7010/ks7010_sdio.h
index 95ac86b..831b2f1 100644
--- a/drivers/staging/ks7010/ks7010_sdio.h
+++ b/drivers/staging/ks7010/ks7010_sdio.h
@@ -1,12 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  *   Driver for KeyStream, KS7010 based SDIO cards.
  *
  *   Copyright (C) 2006-2008 KeyStream Corp.
  *   Copyright (C) 2009 Renesas Technology Corp.
- *
- *   This program is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2 as
- *   published by the Free Software Foundation.
  */
 #ifndef _KS7010_SDIO_H
 #define _KS7010_SDIO_H
diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 9a05374..61d9742 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1,12 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  *   Driver for KeyStream wireless LAN cards.
  *
  *   Copyright (C) 2005-2008 KeyStream Corp.
  *   Copyright (C) 2009 Renesas Technology Corp.
- *
- *   This program is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2 as
- *   published by the Free Software Foundation.
  */
 
 #include 
diff --git a/drivers/staging/ks7010/ks_hostif.h 
b/drivers/staging/ks7010/ks_hostif.h
index 05ff5ca..172d38f 100644
--- a/drivers/staging/ks7010/ks_hostif.h
+++ b/drivers/staging/ks7010/ks_hostif.h
@@ -1,12 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  *   Driver for KeyStream wireless LAN
  *
  *   Copyright (c) 2005-2008 KeyStream Corp.
  *   Copyright (C) 2009 Renesas Technology Corp.
- *
- *   This program is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2 as
- *   published by the Free Software Foundation.
  */
 
 #ifndef _KS_HOSTIF_H_
diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h
index 2894b0c..5070af8 100644
--- a/drivers/staging/ks7010/ks_wlan.h
+++ b/drivers/staging/ks7010/ks_wlan.h
@@ -1,12 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  *   Driver for KeyStream IEEE802.11 b/g wireless LAN cards.
  *
  *   Copyright (C) 2006-2008 KeyStream Corp.
  *   Copyright (C) 2009 Renesas Technology Corp.
- *
- *   This program is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2 as
- *   published by the Free Software Foundation.
  */
 
 #ifndef _KS_WLAN_H
diff --git a/drivers/staging/ks7010/ks_wlan_ioctl.h 
b/drivers/staging/ks7010/ks_wlan_ioctl.h
index e45a332..97c7d95 100644
--- a/drivers/staging/ks7010/ks_wlan_ioctl.h
+++ b/drivers/staging/ks7010/ks_wlan_ioctl.h
@@ -1,12 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  *   Driver for KeyStream 11b/g wireless LAN
  *
  *   Copyright (c) 2005-2008 KeyStream Corp.
  *   Copyright (C) 2009 Renesas Technology Corp.
- *
- *   This program is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2 as
- *   published by the Free Software Foundation.
  */
 
 #ifndef _KS_WLAN_IOCTL_H
diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index aaa57c2..71fc8c2 100644
---

[PATCH 00/16] staging: ks7010: next cleanups

2018-04-25 Thread Sergio Paracuellos
This patch series includes some new cleanups in code.

It also includes a remaining patch (PATCH 1/16) about 
SPDX identifiers in files which wasn't be applied.

Sergio Paracuellos (16):
  staging: ks7010: add SPDX identifiers to all files
  staging: ks7010: refactor ks_wlan_set_beacon_lost function
  staging: ks7010: refactor ks_wlan_set_scan_type function
  staging: ks7010: refactor ks_wlan_set_power_mgmt function
  staging: ks7010: refactor ks_wlan_set_preamble function
  staging: ks7010: refactor ks_wlan_set_cts_mode function
  staging: ks7010: refactor ks_wlan_set_pmksa function
  staging: ks7010: use ether_addr_copy in ks_wlan_set_encode_ext
  staging: ks7010: align values in frequency_list array
  staging: ks7010: refactor ks_wlan_set_wap function
  staging: ks7010: use ether_addr_copy in ks_wlan_get_wap
  staging: ks7010: avoid an 'else' in ks_wlan_set_power
  staging: ks7010: avoid if-else condition in ks_wlan_get_power
  staging: ks7010: use ether_addr_copy in ks_wlan_get_aplist
  staging: ks7010: avoid blank line between declarations in
ks_wlan_get_aplist
  staging: ks7010: refactor ks_wlan_translate_scan function

 drivers/staging/ks7010/ks7010_sdio.c   |   5 +-
 drivers/staging/ks7010/ks7010_sdio.h   |   5 +-
 drivers/staging/ks7010/ks_hostif.c |   5 +-
 drivers/staging/ks7010/ks_hostif.h |   5 +-
 drivers/staging/ks7010/ks_wlan.h   |   5 +-
 drivers/staging/ks7010/ks_wlan_ioctl.h |   5 +-
 drivers/staging/ks7010/ks_wlan_net.c   | 302 ++---
 drivers/staging/ks7010/michael_mic.c   |   5 +-
 drivers/staging/ks7010/michael_mic.h   |   5 +-
 9 files changed, 134 insertions(+), 208 deletions(-)

-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 04/16] staging: ks7010: refactor ks_wlan_set_power_mgmt function

2018-04-25 Thread Sergio Paracuellos
This commit change logic to simplify conditional paths in
ks_wlan_set_power_mgmt function. It handles invalid's first
and just finally assign a valid value.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_wlan_net.c | 23 ---
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index b10c54c..ba587c6 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -1892,23 +1892,16 @@ static int ks_wlan_set_power_mgmt(struct net_device 
*dev,
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
 
-   /* for SLEEP MODE */
-   if (*uwrq == POWER_MGMT_ACTIVE) {   /* 0 */
-   priv->reg.power_mgmt = POWER_MGMT_ACTIVE;
-   } else if (*uwrq == POWER_MGMT_SAVE1) { /* 1 */
-   if (priv->reg.operation_mode == MODE_INFRASTRUCTURE)
-   priv->reg.power_mgmt = POWER_MGMT_SAVE1;
-   else
-   return -EINVAL;
-   } else if (*uwrq == POWER_MGMT_SAVE2) { /* 2 */
-   if (priv->reg.operation_mode == MODE_INFRASTRUCTURE)
-   priv->reg.power_mgmt = POWER_MGMT_SAVE2;
-   else
-   return -EINVAL;
-   } else {
+   if (*uwrq != POWER_MGMT_ACTIVE &&
+   *uwrq != POWER_MGMT_SAVE1 &&
+   *uwrq != POWER_MGMT_SAVE2)
+   return -EINVAL;
+
+   if ((*uwrq == POWER_MGMT_SAVE1 || *uwrq == POWER_MGMT_SAVE2) &&
+   (priv->reg.operation_mode != MODE_INFRASTRUCTURE))
return -EINVAL;
-   }
 
+   priv->reg.power_mgmt = *uwrq;
hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST);
 
return 0;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 05/16] staging: ks7010: refactor ks_wlan_set_preamble function

2018-04-25 Thread Sergio Paracuellos
Change if logic to handle invalid values first and just
assign at the end the valid one if it is the case.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_wlan_net.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index ba587c6..89d9fda 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -1857,14 +1857,10 @@ static int ks_wlan_set_preamble(struct net_device *dev,
return -EPERM;
 
/* for SLEEP MODE */
-   if (*uwrq == LONG_PREAMBLE) {   /* 0 */
-   priv->reg.preamble = LONG_PREAMBLE;
-   } else if (*uwrq == SHORT_PREAMBLE) {   /* 1 */
-   priv->reg.preamble = SHORT_PREAMBLE;
-   } else {
+   if (*uwrq != LONG_PREAMBLE && *uwrq != SHORT_PREAMBLE)
return -EINVAL;
-   }
 
+   priv->reg.preamble = *uwrq;
priv->need_commit |= SME_MODE_SET;
return -EINPROGRESS;/* Call commit handler */
 }
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 06/16] staging: ks7010: refactor ks_wlan_set_cts_mode function

2018-04-25 Thread Sergio Paracuellos
This commit refactors ks_wlan_set_cts_mode function to
handle invalid values first and then assign the good
one changing a bit logic to use a ternary operator.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_wlan_net.c | 17 ++---
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 89d9fda..676f9fd 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -2027,18 +2027,13 @@ static int ks_wlan_set_cts_mode(struct net_device *dev,
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
/* for SLEEP MODE */
-   if (*uwrq == CTS_MODE_FALSE) {  /* 0 */
-   priv->reg.cts_mode = CTS_MODE_FALSE;
-   } else if (*uwrq == CTS_MODE_TRUE) {/* 1 */
-   if (priv->reg.phy_type == D_11G_ONLY_MODE ||
-   priv->reg.phy_type == D_11BG_COMPATIBLE_MODE) {
-   priv->reg.cts_mode = CTS_MODE_TRUE;
-   } else {
-   priv->reg.cts_mode = CTS_MODE_FALSE;
-   }
-   } else {
+   if (*uwrq != CTS_MODE_FALSE && *uwrq != CTS_MODE_TRUE)
return -EINVAL;
-   }
+
+   priv->reg.cts_mode = (*uwrq == CTS_MODE_FALSE) ? *uwrq :
+ (priv->reg.phy_type == D_11G_ONLY_MODE ||
+  priv->reg.phy_type == D_11BG_COMPATIBLE_MODE) ?
+  *uwrq : !*uwrq;
 
priv->need_commit |= SME_MODE_SET;
return -EINPROGRESS;/* Call commit handler */
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 02/16] staging: ks7010: refactor ks_wlan_set_beacon_lost function

2018-04-25 Thread Sergio Paracuellos
Change if condition to handle invalid value first and
avoid nonsense else's path improving readability.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_wlan_net.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 71fc8c2..68aece7 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -1970,17 +1970,17 @@ static int ks_wlan_set_beacon_lost(struct net_device 
*dev,
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
/* for SLEEP MODE */
-   if (*uwrq >= BEACON_LOST_COUNT_MIN && *uwrq <= BEACON_LOST_COUNT_MAX)
-   priv->reg.beacon_lost_count = *uwrq;
-   else
+   if (*uwrq < BEACON_LOST_COUNT_MIN || *uwrq > BEACON_LOST_COUNT_MAX)
return -EINVAL;
 
+   priv->reg.beacon_lost_count = *uwrq;
+
if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) {
priv->need_commit |= SME_MODE_SET;
return -EINPROGRESS;/* Call commit handler */
-   } else {
-   return 0;
}
+
+   return 0;
 }
 
 static int ks_wlan_get_beacon_lost(struct net_device *dev,
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 13/16] staging: ks7010: avoid if-else condition in ks_wlan_get_power

2018-04-25 Thread Sergio Paracuellos
The if-else code in ks_wlan_get_power function is not needed
at all and can be achieved with a simple boolean assignation.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_wlan_net.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 1387783..df828d6 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -1061,10 +1061,7 @@ static int ks_wlan_get_power(struct net_device *dev,
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
/* for SLEEP MODE */
-   if (priv->reg.power_mgmt > 0)
-   vwrq->power.disabled = 0;
-   else
-   vwrq->power.disabled = 1;
+   vwrq->power.disabled = (priv->reg.power_mgmt <= 0);
 
return 0;
 }
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 09/16] staging: ks7010: align values in frequency_list array

2018-04-25 Thread Sergio Paracuellos
To avoid a long line align values in static array
frequency_list array.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_wlan_net.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index e1f92ce..2fd5b50 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -28,7 +28,8 @@ static int wep_on_off;
 #include /* New driver API */
 
 /* Frequency list (map channels to frequencies) */
-static const long frequency_list[] = { 2412, 2417, 2422, 2427, 2432, 2437, 
2442,
+static const long frequency_list[] = {
+   2412, 2417, 2422, 2427, 2432, 2437, 2442,
2447, 2452, 2457, 2462, 2467, 2472, 2484
 };
 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 11/16] staging: ks7010: use ether_addr_copy in ks_wlan_get_wap

2018-04-25 Thread Sergio Paracuellos
Use ether_addr_copy to copy ethernet addresses instead
of a custom memcpy. This improves readability.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_wlan_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 690e5c0..6625d57 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -343,7 +343,7 @@ static int ks_wlan_get_wap(struct net_device *dev, struct 
iw_request_info *info,
 
/* for SLEEP MODE */
if (is_connect_status(priv->connect_status))
-   memcpy(awrq->ap_addr.sa_data, priv->current_ap.bssid, ETH_ALEN);
+   ether_addr_copy(awrq->ap_addr.sa_data, priv->current_ap.bssid);
else
eth_zero_addr(awrq->ap_addr.sa_data);
 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 14/16] staging: ks7010: use ether_addr_copy in ks_wlan_get_aplist

2018-04-25 Thread Sergio Paracuellos
Use ether_addr_copy to copy ethernet addresses instead of
using custom memcpy for that.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_wlan_net.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index df828d6..b35284c 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -1098,8 +1098,7 @@ static int ks_wlan_get_aplist(struct net_device *dev,
return -EPERM;
/* for SLEEP MODE */
for (i = 0; i < priv->aplist.size; i++) {
-   memcpy(address[i].sa_data, &(priv->aplist.ap[i].bssid[0]),
-  ETH_ALEN);
+   ether_addr_copy(address[i].sa_data, priv->aplist.ap[i].bssid);
address[i].sa_family = ARPHRD_ETHER;
qual[i].level = 256 - priv->aplist.ap[i].rssi;
qual[i].qual = priv->aplist.ap[i].sq;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 16/16] staging: ks7010: refactor ks_wlan_translate_scan function

2018-04-25 Thread Sergio Paracuellos
This commit refactors ks_wlan_translate_scan function with
the following changes:

- reorder local variables
- use ether_addr_copy to copy ethernet addresses
- change style in 'current_ev' variable assignments
- make use of some ternaries avoiding if-else code
- use preferred style for comments
- extract common code into a new ks_wlan_add_leader_event
  function

After this changes readability has been improved.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_wlan_net.c | 150 +++
 1 file changed, 66 insertions(+), 84 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index b1933b3..5c2cc75 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -1143,6 +1143,33 @@ static int ks_wlan_set_scan(struct net_device *dev,
return 0;
 }
 
+static char *ks_wlan_add_leader_event(const char *rsn_leader, char *end_buf,
+ char *current_ev, struct rsn_ie *rsn,
+ struct iw_event *iwe,
+ struct iw_request_info *info)
+{
+   char buffer[RSN_IE_BODY_MAX * 2 + 30];
+   char *pbuf;
+   int i;
+
+   pbuf = &buffer[0];
+   memset(iwe, 0, sizeof(*iwe));
+   iwe->cmd = IWEVCUSTOM;
+   memcpy(buffer, rsn_leader, sizeof(rsn_leader) - 1);
+   iwe->u.data.length += sizeof(rsn_leader) - 1;
+   pbuf += sizeof(rsn_leader) - 1;
+   pbuf += sprintf(pbuf, "%02x", rsn->id);
+   pbuf += sprintf(pbuf, "%02x", rsn->size);
+   iwe->u.data.length += 4;
+
+   for (i = 0; i < rsn->size; i++)
+   pbuf += sprintf(pbuf, "%02x", rsn->body[i]);
+
+   iwe->u.data.length += rsn->size * 2;
+
+   return iwe_stream_add_point(info, current_ev, end_buf, iwe, &buffer[0]);
+}
+
 /*
  * Translate scan data returned from the card to a card independent
  * format that the Wireless Tools will understand - Jean II
@@ -1153,22 +1180,19 @@ static inline char *ks_wlan_translate_scan(struct 
net_device *dev,
   struct local_ap *ap)
 {
/* struct ks_wlan_private *priv = (struct ks_wlan_private *)dev->priv; 
*/
+   static const char rsn_leader[] = "rsn_ie=";
+   static const char wpa_leader[] = "wpa_ie=";
struct iw_event iwe;/* Temporary buffer */
u16 capabilities;
char *current_val;  /* For rates */
int i;
-   static const char rsn_leader[] = "rsn_ie=";
-   static const char wpa_leader[] = "wpa_ie=";
-   char buf0[RSN_IE_BODY_MAX * 2 + 30];
-   char buf1[RSN_IE_BODY_MAX * 2 + 30];
-   char *pbuf;
+
/* First entry *MUST* be the AP MAC address */
iwe.cmd = SIOCGIWAP;
iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
-   memcpy(iwe.u.ap_addr.sa_data, ap->bssid, ETH_ALEN);
-   current_ev =
-   iwe_stream_add_event(info, current_ev, end_buf, &iwe,
-IW_EV_ADDR_LEN);
+   ether_addr_copy(iwe.u.ap_addr.sa_data, ap->bssid);
+   current_ev = iwe_stream_add_event(info, current_ev,
+ end_buf, &iwe, IW_EV_ADDR_LEN);
 
/* Other entries will be displayed in the order we give them */
 
@@ -1178,21 +1202,17 @@ static inline char *ks_wlan_translate_scan(struct 
net_device *dev,
iwe.u.data.length = 32;
iwe.cmd = SIOCGIWESSID;
iwe.u.data.flags = 1;
-   current_ev =
-   iwe_stream_add_point(info, current_ev, end_buf, &iwe,
-ap->ssid.body);
+   current_ev = iwe_stream_add_point(info, current_ev,
+ end_buf, &iwe, ap->ssid.body);
 
/* Add mode */
iwe.cmd = SIOCGIWMODE;
capabilities = ap->capability;
if (capabilities & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)) {
-   if (capabilities & WLAN_CAPABILITY_ESS)
-   iwe.u.mode = IW_MODE_INFRA;
-   else
-   iwe.u.mode = IW_MODE_ADHOC;
-   current_ev =
-   iwe_stream_add_event(info, current_ev, end_buf, &iwe,
-IW_EV_UINT_LEN);
+   iwe.u.mode = (capabilities & WLAN_CAPABILITY_ESS) ?
+ IW_MODE_INFRA : IW_MODE_ADHOC;
+   current_ev = iwe_stream_add_event(info, current_ev,
+ end_buf, &iwe, 
IW_EV_UINT_LEN);
}
 
/* Add frequency */
@@ -1200,32 +1220,29 @@ static inline char *ks_wlan_translate_scan(struct 
net_device *dev,
iwe.u.freq.m = ap->channel;
iwe.u.freq.m = frequency_list[iwe.u.freq.m - 1] * 10;
iwe.u.freq.e = 1;
-   current_ev =
-   iwe_stream_add_event(info, current_ev, end_buf, &iwe,
-IW_EV_FREQ_LEN);
+

[PATCH 08/16] staging: ks7010: use ether_addr_copy in ks_wlan_set_encode_ext

2018-04-25 Thread Sergio Paracuellos
Instead of manually memcpy ethernet addresses use ether_addr_copy
function for this purpose.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_wlan_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 5553743..e1f92ce 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -1591,7 +1591,7 @@ static int ks_wlan_set_encode_ext(struct net_device *dev,
memcpy(&key->rx_seq[0], &enc->rx_seq[0], 
IW_ENCODE_SEQ_MAX_SIZE);
}
 
-   memcpy(&key->addr.sa_data[0], &enc->addr.sa_data[0], ETH_ALEN);
+   ether_addr_copy(&key->addr.sa_data[0], &enc->addr.sa_data[0]);
 
switch (enc->alg) {
case IW_ENCODE_ALG_NONE:
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 12/16] staging: ks7010: avoid an 'else' in ks_wlan_set_power

2018-04-25 Thread Sergio Paracuellos
Change if logic to handle invalid case for operation_mode
at first avoiding an 'else' path.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_wlan_net.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 6625d57..1387783 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -1042,10 +1042,9 @@ static int ks_wlan_set_power(struct net_device *dev,
if (vwrq->power.disabled) {
priv->reg.power_mgmt = POWER_MGMT_ACTIVE;
} else {
-   if (priv->reg.operation_mode == MODE_INFRASTRUCTURE)
-   priv->reg.power_mgmt = POWER_MGMT_SAVE1;
-   else
+   if (priv->reg.operation_mode != MODE_INFRASTRUCTURE)
return -EINVAL;
+   priv->reg.power_mgmt = POWER_MGMT_SAVE1;
}
 
hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST);
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 07/16] staging: ks7010: refactor ks_wlan_set_pmksa function

2018-04-25 Thread Sergio Paracuellos
This commit cleans a bit ks_wlan_set_pmksa function removing
nonsense comments as well as make use of ether_addr_* family
functions written to not do manually things that were being
here. Minor single if brackets has been removed also.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_wlan_net.c | 45 +---
 1 file changed, 21 insertions(+), 24 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 676f9fd..5553743 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -1691,68 +1691,65 @@ static int ks_wlan_set_pmksa(struct net_device *dev,
 
switch (pmksa->cmd) {
case IW_PMKSA_ADD:
-   if (list_empty(&priv->pmklist.head)) {  /* new list */
+   if (list_empty(&priv->pmklist.head)) {
for (i = 0; i < PMK_LIST_MAX; i++) {
pmk = &priv->pmklist.pmk[i];
-   if (memcmp("\x00\x00\x00\x00\x00\x00",
-  pmk->bssid, ETH_ALEN) == 0)
-   break; /* loop */
+   if (is_zero_ether_addr(pmk->bssid))
+   break;
}
-   memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN);
+   ether_addr_copy(pmk->bssid, pmksa->bssid.sa_data);
memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN);
list_add(&pmk->list, &priv->pmklist.head);
priv->pmklist.size++;
-   break;  /* case */
+   break;
}
/* search cache data */
list_for_each(ptr, &priv->pmklist.head) {
pmk = list_entry(ptr, struct pmk, list);
-   if (memcmp(pmksa->bssid.sa_data, pmk->bssid, ETH_ALEN) 
== 0) {
+   if (ether_addr_equal(pmksa->bssid.sa_data, pmk->bssid)) 
{
memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN);
list_move(&pmk->list, &priv->pmklist.head);
-   break; /* list_for_each */
+   break;
}
}
-   if (ptr != &priv->pmklist.head) /* not find address. */
-   break;  /* case */
-
-   if (priv->pmklist.size < PMK_LIST_MAX) {/* new cache 
data */
+   /* not find address. */
+   if (ptr != &priv->pmklist.head)
+   break;
+   /* new cache data */
+   if (priv->pmklist.size < PMK_LIST_MAX) {
for (i = 0; i < PMK_LIST_MAX; i++) {
pmk = &priv->pmklist.pmk[i];
-   if (memcmp("\x00\x00\x00\x00\x00\x00",
-  pmk->bssid, ETH_ALEN) == 0)
-   break; /* loop */
+   if (is_zero_ether_addr(pmk->bssid))
+   break;
}
-   memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN);
+   ether_addr_copy(pmk->bssid, pmksa->bssid.sa_data);
memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN);
list_add(&pmk->list, &priv->pmklist.head);
priv->pmklist.size++;
-   } else {/* overwrite old cache data */
+   } else { /* overwrite old cache data */
pmk = list_entry(priv->pmklist.head.prev, struct pmk,
 list);
-   memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN);
+   ether_addr_copy(pmk->bssid, pmksa->bssid.sa_data);
memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN);
list_move(&pmk->list, &priv->pmklist.head);
}
break;
case IW_PMKSA_REMOVE:
-   if (list_empty(&priv->pmklist.head)) {  /* list empty */
+   if (list_empty(&priv->pmklist.head))
return -EINVAL;
-   }
/* search cache data */
list_for_each(ptr, &priv->pmklist.head) {
pmk = list_entry(ptr, struct pmk, list);
-   if (memcmp(pmksa->bssid.sa_data, pmk->bssid, ETH_ALEN) 
== 0) {
+   if (ether_addr_equal(pmksa->bssid.sa_data, pmk->bssid)) 
{
eth_zero_addr(pmk->bssid);
memset(pmk->pmkid, 0, IW_PMKID_LEN);
list_del_init(&pmk->list);
break;
}

[PATCH 10/16] staging: ks7010: refactor ks_wlan_set_wap function

2018-04-25 Thread Sergio Paracuellos
Make use of ether_addr_copy instead of memcpy for copying
ethernet address data in ks_wlan_set_wap function and avoid
an 'else' just changing if logic to check invalid values first.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_wlan_net.c | 14 ++
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 2fd5b50..690e5c0 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -313,18 +313,16 @@ static int ks_wlan_set_wap(struct net_device *dev, struct 
iw_request_info *info,
return -EPERM;
 
/* for SLEEP MODE */
-   if (priv->reg.operation_mode == MODE_ADHOC ||
-   priv->reg.operation_mode == MODE_INFRASTRUCTURE) {
-   memcpy(priv->reg.bssid, &awrq->ap_addr.sa_data, ETH_ALEN);
-
-   if (is_valid_ether_addr((u8 *)priv->reg.bssid))
-   priv->need_commit |= SME_MODE_SET;
-
-   } else {
+   if (priv->reg.operation_mode != MODE_ADHOC &&
+   priv->reg.operation_mode != MODE_INFRASTRUCTURE) {
eth_zero_addr(priv->reg.bssid);
return -EOPNOTSUPP;
}
 
+   ether_addr_copy(priv->reg.bssid, awrq->ap_addr.sa_data);
+   if (is_valid_ether_addr((u8 *)priv->reg.bssid))
+   priv->need_commit |= SME_MODE_SET;
+
netdev_dbg(dev, "bssid = %pM\n", priv->reg.bssid);
 
/* Write it to the card */
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 15/16] staging: ks7010: avoid blank line between declarations in ks_wlan_get_aplist

2018-04-25 Thread Sergio Paracuellos
This commit removes a blank line which is included between
declarations and it has not sense at all.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_wlan_net.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index b35284c..b1933b3 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -1091,7 +1091,6 @@ static int ks_wlan_get_aplist(struct net_device *dev,
struct ks_wlan_private *priv = netdev_priv(dev);
struct sockaddr *address = (struct sockaddr *)extra;
struct iw_quality qual[LOCAL_APLIST_MAX];
-
int i;
 
if (priv->sleep_mode == SLP_SLEEP)
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 06/18] staging: ks7010: use GPL-2.0+ SPDX license identifier

2018-04-25 Thread Sergio Paracuellos
On Wed, Apr 25, 2018 at 03:49:19PM +0200, Greg KH wrote:
> On Tue, Apr 24, 2018 at 03:49:55PM +0200, Sergio Paracuellos wrote:
> > The summary text for the GPL is not needed since the SPDX identifier
> > is a legally binding shorthand that can be used instead.
> > 
> > Signed-off-by: Sergio Paracuellos 
> > ---
> >  drivers/staging/ks7010/ks7010_sdio.c   | 5 +
> >  drivers/staging/ks7010/ks7010_sdio.h   | 5 +
> >  drivers/staging/ks7010/ks_hostif.c | 5 +
> >  drivers/staging/ks7010/ks_hostif.h | 5 +
> >  drivers/staging/ks7010/ks_wlan.h   | 5 +
> >  drivers/staging/ks7010/ks_wlan_ioctl.h | 5 +
> >  drivers/staging/ks7010/ks_wlan_net.c   | 5 +
> >  drivers/staging/ks7010/michael_mic.c   | 5 +
> >  drivers/staging/ks7010/michael_mic.h   | 5 +
> >  9 files changed, 9 insertions(+), 36 deletions(-)
> > 
> > diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
> > b/drivers/staging/ks7010/ks7010_sdio.c
> > index b29f48c..b6cabab 100644
> > --- a/drivers/staging/ks7010/ks7010_sdio.c
> > +++ b/drivers/staging/ks7010/ks7010_sdio.c
> > @@ -1,13 +1,10 @@
> > +/* SPDX-License-Identifier: GPL-2.0 */
> 
> Subject does not match what you put here :(

I've include this in my next series.
 
> 
> Please be exact, it matters.
> 
> thanks,
> 
> greg k-h

Best regards,
Sergio Paracuellos
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging/wilc1000: fix wilc_mac_xmit()'s return type

2018-04-25 Thread Claudiu Beznea
Could you, please, change the "return 0;"s inside wilc_mac_xmit() with
"return NETDEV_TX_OK" ?

Thank you,
Claudiu

On 24.04.2018 15:18, Luc Van Oostenryck wrote:
> The method ndo_start_xmit() is defined as returning an 'netdev_tx_t',
> which is a typedef for an enum type, but the implementation in this
> driver returns an 'int'.
> 
> Fix this by returning 'netdev_tx_t' in this driver too.
> 
> Signed-off-by: Luc Van Oostenryck 
> ---
>  drivers/staging/wilc1000/linux_wlan.c | 2 +-
>  drivers/staging/wilc1000/wilc_wlan.h  | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/wilc1000/linux_wlan.c 
> b/drivers/staging/wilc1000/linux_wlan.c
> index 38a83bd31..e06aaed5e 100644
> --- a/drivers/staging/wilc1000/linux_wlan.c
> +++ b/drivers/staging/wilc1000/linux_wlan.c
> @@ -941,7 +941,7 @@ static void linux_wlan_tx_complete(void *priv, int status)
>   kfree(pv_data);
>  }
>  
> -int wilc_mac_xmit(struct sk_buff *skb, struct net_device *ndev)
> +netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *ndev)
>  {
>   struct wilc_vif *vif;
>   struct tx_complete_data *tx_data = NULL;
> diff --git a/drivers/staging/wilc1000/wilc_wlan.h 
> b/drivers/staging/wilc1000/wilc_wlan.h
> index fa157a67b..d3b5a6b38 100644
> --- a/drivers/staging/wilc1000/wilc_wlan.h
> +++ b/drivers/staging/wilc1000/wilc_wlan.h
> @@ -298,7 +298,7 @@ void wilc_chip_sleep_manually(struct wilc *wilc);
>  
>  void wilc_enable_tcp_ack_filter(bool value);
>  int wilc_wlan_get_num_conn_ifcs(struct wilc *wilc);
> -int wilc_mac_xmit(struct sk_buff *skb, struct net_device *dev);
> +netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *dev);
>  
>  void WILC_WFI_p2p_rx(struct net_device *dev, u8 *buff, u32 size);
>  void host_wakeup_notify(struct wilc *wilc);
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 01/40] net/can: single_open_net needs to be paired with single_release_net

2018-04-25 Thread Christoph Hellwig
Otherwise we will leak a reference to the network namespace.

Signed-off-by: Christoph Hellwig 
---
 net/can/bcm.c  | 2 +-
 net/can/proc.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/can/bcm.c b/net/can/bcm.c
index ac5e5e34fee3..8073fa14e143 100644
--- a/net/can/bcm.c
+++ b/net/can/bcm.c
@@ -249,7 +249,7 @@ static const struct file_operations bcm_proc_fops = {
.open   = bcm_proc_open,
.read   = seq_read,
.llseek = seq_lseek,
-   .release= single_release,
+   .release= single_release_net,
 };
 #endif /* CONFIG_PROC_FS */
 
diff --git a/net/can/proc.c b/net/can/proc.c
index fdf704e9bb8c..fde2fd55b826 100644
--- a/net/can/proc.c
+++ b/net/can/proc.c
@@ -279,7 +279,7 @@ static const struct file_operations can_stats_proc_fops = {
.open   = can_stats_proc_open,
.read   = seq_read,
.llseek = seq_lseek,
-   .release= single_release,
+   .release= single_release_net,
 };
 
 static int can_reset_stats_proc_show(struct seq_file *m, void *v)
@@ -449,7 +449,7 @@ static const struct file_operations 
can_rcvlist_sff_proc_fops = {
.open   = can_rcvlist_sff_proc_open,
.read   = seq_read,
.llseek = seq_lseek,
-   .release= single_release,
+   .release= single_release_net,
 };
 
 
@@ -492,7 +492,7 @@ static const struct file_operations 
can_rcvlist_eff_proc_fops = {
.open   = can_rcvlist_eff_proc_open,
.read   = seq_read,
.llseek = seq_lseek,
-   .release= single_release,
+   .release= single_release_net,
 };
 
 /*
-- 
2.17.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 03/40] proc: add a proc_create_reg helper

2018-04-25 Thread Christoph Hellwig
Common code for creating a regular file.  Factor out of proc_create_data, to
be reused by other functions soon.

Signed-off-by: Christoph Hellwig 
---
 fs/proc/generic.c  | 44 +---
 fs/proc/internal.h |  2 ++
 2 files changed, 27 insertions(+), 19 deletions(-)

diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index bd8480ff0d35..ab6a321076b8 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -511,33 +511,39 @@ struct proc_dir_entry *proc_create_mount_point(const char 
*name)
 }
 EXPORT_SYMBOL(proc_create_mount_point);
 
-struct proc_dir_entry *proc_create_data(const char *name, umode_t mode,
-   struct proc_dir_entry *parent,
-   const struct file_operations *proc_fops,
-   void *data)
+struct proc_dir_entry *proc_create_reg(const char *name, umode_t mode,
+   struct proc_dir_entry **parent, void *data)
 {
-   struct proc_dir_entry *pde;
+   struct proc_dir_entry *p;
+
if ((mode & S_IFMT) == 0)
mode |= S_IFREG;
-
-   if (!S_ISREG(mode)) {
-   WARN_ON(1); /* use proc_mkdir() */
+   if ((mode & S_IALLUGO) == 0)
+   mode |= S_IRUGO;
+   if (WARN_ON_ONCE(!S_ISREG(mode)))
return NULL;
+
+   p = __proc_create(parent, name, mode, 1);
+   if (p) {
+   p->proc_iops = &proc_file_inode_operations;
+   p->data = data;
}
+   return p;
+}
+
+struct proc_dir_entry *proc_create_data(const char *name, umode_t mode,
+   struct proc_dir_entry *parent,
+   const struct file_operations *proc_fops, void *data)
+{
+   struct proc_dir_entry *p;
 
BUG_ON(proc_fops == NULL);
 
-   if ((mode & S_IALLUGO) == 0)
-   mode |= S_IRUGO;
-   pde = __proc_create(&parent, name, mode, 1);
-   if (!pde)
-   goto out;
-   pde->proc_fops = proc_fops;
-   pde->data = data;
-   pde->proc_iops = &proc_file_inode_operations;
-   return proc_register(parent, pde);
-out:
-   return NULL;
+   p = proc_create_reg(name, mode, &parent, data);
+   if (!p)
+   return NULL;
+   p->proc_fops = proc_fops;
+   return proc_register(parent, p);
 }
 EXPORT_SYMBOL(proc_create_data);
  
diff --git a/fs/proc/internal.h b/fs/proc/internal.h
index 488e67490312..dd1e11400b97 100644
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -162,6 +162,8 @@ extern bool proc_fill_cache(struct file *, struct 
dir_context *, const char *, i
 /*
  * generic.c
  */
+struct proc_dir_entry *proc_create_reg(const char *name, umode_t mode,
+   struct proc_dir_entry **parent, void *data);
 struct proc_dir_entry *proc_register(struct proc_dir_entry *dir,
struct proc_dir_entry *dp);
 extern struct dentry *proc_lookup(struct inode *, struct dentry *, unsigned 
int);
-- 
2.17.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 02/40] proc: simplify proc_register calling conventions

2018-04-25 Thread Christoph Hellwig
Return registered entry on success, return NULL on failure and free the
passed in entry.  Also expose it in internal.h as we'll start using it
in proc_net.c soon.

Signed-off-by: Christoph Hellwig 
---
 fs/proc/generic.c  | 44 ++--
 fs/proc/internal.h |  2 ++
 2 files changed, 20 insertions(+), 26 deletions(-)

diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index 2078e70e1595..bd8480ff0d35 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -346,13 +346,12 @@ static const struct inode_operations 
proc_dir_inode_operations = {
.setattr= proc_notify_change,
 };
 
-static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * 
dp)
+/* returns the registered entry, or frees dp and returns NULL on failure */
+struct proc_dir_entry *proc_register(struct proc_dir_entry *dir,
+   struct proc_dir_entry *dp)
 {
-   int ret;
-
-   ret = proc_alloc_inum(&dp->low_ino);
-   if (ret)
-   return ret;
+   if (proc_alloc_inum(&dp->low_ino))
+   goto out_free_entry;
 
write_lock(&proc_subdir_lock);
dp->parent = dir;
@@ -360,12 +359,16 @@ static int proc_register(struct proc_dir_entry * dir, 
struct proc_dir_entry * dp
WARN(1, "proc_dir_entry '%s/%s' already registered\n",
 dir->name, dp->name);
write_unlock(&proc_subdir_lock);
-   proc_free_inum(dp->low_ino);
-   return -EEXIST;
+   goto out_free_inum;
}
write_unlock(&proc_subdir_lock);
 
-   return 0;
+   return dp;
+out_free_inum:
+   proc_free_inum(dp->low_ino);
+out_free_entry:
+   pde_free(dp);
+   return NULL;
 }
 
 static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent,
@@ -443,10 +446,7 @@ struct proc_dir_entry *proc_symlink(const char *name,
if (ent->data) {
strcpy((char*)ent->data,dest);
ent->proc_iops = &proc_link_inode_operations;
-   if (proc_register(parent, ent) < 0) {
-   pde_free(ent);
-   ent = NULL;
-   }
+   ent = proc_register(parent, ent);
} else {
pde_free(ent);
ent = NULL;
@@ -470,11 +470,9 @@ struct proc_dir_entry *proc_mkdir_data(const char *name, 
umode_t mode,
ent->proc_fops = &proc_dir_operations;
ent->proc_iops = &proc_dir_inode_operations;
parent->nlink++;
-   if (proc_register(parent, ent) < 0) {
-   pde_free(ent);
+   ent = proc_register(parent, ent);
+   if (!ent)
parent->nlink--;
-   ent = NULL;
-   }
}
return ent;
 }
@@ -505,11 +503,9 @@ struct proc_dir_entry *proc_create_mount_point(const char 
*name)
ent->proc_fops = NULL;
ent->proc_iops = NULL;
parent->nlink++;
-   if (proc_register(parent, ent) < 0) {
-   pde_free(ent);
+   ent = proc_register(parent, ent);
+   if (!ent)
parent->nlink--;
-   ent = NULL;
-   }
}
return ent;
 }
@@ -539,11 +535,7 @@ struct proc_dir_entry *proc_create_data(const char *name, 
umode_t mode,
pde->proc_fops = proc_fops;
pde->data = data;
pde->proc_iops = &proc_file_inode_operations;
-   if (proc_register(parent, pde) < 0)
-   goto out_free;
-   return pde;
-out_free:
-   pde_free(pde);
+   return proc_register(parent, pde);
 out:
return NULL;
 }
diff --git a/fs/proc/internal.h b/fs/proc/internal.h
index 0f1692e63cb6..488e67490312 100644
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -162,6 +162,8 @@ extern bool proc_fill_cache(struct file *, struct 
dir_context *, const char *, i
 /*
  * generic.c
  */
+struct proc_dir_entry *proc_register(struct proc_dir_entry *dir,
+   struct proc_dir_entry *dp);
 extern struct dentry *proc_lookup(struct inode *, struct dentry *, unsigned 
int);
 struct dentry *proc_lookup_de(struct inode *, struct dentry *, struct 
proc_dir_entry *);
 extern int proc_readdir(struct file *, struct dir_context *);
-- 
2.17.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


simplify procfs code for seq_file instances V2

2018-04-25 Thread Christoph Hellwig
We currently have hundreds of proc files that implement plain, read-only
seq_file based interfaces.  This series consolidates them using new
procfs helpers that take the seq_operations or simple show callback
directly.

A git tree is available at:

git://git.infradead.org/users/hch/misc.git proc_create.2

Gitweb:


http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/proc_create.2

Changes since V1:
 - open code proc_create_data to avoid setting not fully initialized
   entries live
 - use unsigned int for state_size
 - dropped the s390/cio/blacklist hunk as it has a write method
 - dropped the IPMI patch given that IPMI proc support is scheduled for
   removal.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 05/40] proc: introduce proc_create_seq_private

2018-04-25 Thread Christoph Hellwig
Variant of proc_create_data that directly take a struct seq_operations
argument + a private state size and drastically reduces the boilerplate
code in the callers.

All trivial callers converted over.

Signed-off-by: Christoph Hellwig 
---
 fs/locks.c | 16 ++--
 fs/proc/generic.c  |  9 ++---
 fs/proc/internal.h |  1 +
 include/linux/atalk.h  |  7 ++-
 include/linux/proc_fs.h|  9 ++---
 kernel/time/timer_list.c   | 16 ++--
 mm/vmalloc.c   | 18 +++---
 net/appletalk/aarp.c   | 20 +---
 net/appletalk/atalk_proc.c |  3 ++-
 net/atm/lec.c  | 15 ++-
 net/decnet/af_decnet.c | 17 +++--
 net/decnet/dn_route.c  | 19 +++
 12 files changed, 37 insertions(+), 113 deletions(-)

diff --git a/fs/locks.c b/fs/locks.c
index 62bbe8b31f26..05e211be8684 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -2788,22 +2788,10 @@ static const struct seq_operations locks_seq_operations 
= {
.show   = locks_show,
 };
 
-static int locks_open(struct inode *inode, struct file *filp)
-{
-   return seq_open_private(filp, &locks_seq_operations,
-   sizeof(struct locks_iterator));
-}
-
-static const struct file_operations proc_locks_operations = {
-   .open   = locks_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= seq_release_private,
-};
-
 static int __init proc_locks_init(void)
 {
-   proc_create("locks", 0, NULL, &proc_locks_operations);
+   proc_create_seq_private("locks", 0, NULL, &locks_seq_operations,
+   sizeof(struct locks_iterator), NULL);
return 0;
 }
 fs_initcall(proc_locks_init);
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index af644caaaf85..f87cb0053387 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -560,6 +560,8 @@ static int proc_seq_open(struct inode *inode, struct file 
*file)
 {
struct proc_dir_entry *de = PDE(inode);
 
+   if (de->state_size)
+   return seq_open_private(file, de->seq_ops, de->state_size);
return seq_open(file, de->seq_ops);
 }
 
@@ -570,9 +572,9 @@ static const struct file_operations proc_seq_fops = {
.release= seq_release,
 };
 
-struct proc_dir_entry *proc_create_seq_data(const char *name, umode_t mode,
+struct proc_dir_entry *proc_create_seq_private(const char *name, umode_t mode,
struct proc_dir_entry *parent, const struct seq_operations *ops,
-   void *data)
+   unsigned int state_size, void *data)
 {
struct proc_dir_entry *p;
 
@@ -581,9 +583,10 @@ struct proc_dir_entry *proc_create_seq_data(const char 
*name, umode_t mode,
return NULL;
p->proc_fops = &proc_seq_fops;
p->seq_ops = ops;
+   p->state_size = state_size;
return proc_register(parent, p);
 }
-EXPORT_SYMBOL(proc_create_seq_data);
+EXPORT_SYMBOL(proc_create_seq_private);
 
 void proc_set_size(struct proc_dir_entry *de, loff_t size)
 {
diff --git a/fs/proc/internal.h b/fs/proc/internal.h
index 4fb01c5f9c1a..ed29e91ae483 100644
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -45,6 +45,7 @@ struct proc_dir_entry {
const struct inode_operations *proc_iops;
const struct file_operations *proc_fops;
const struct seq_operations *seq_ops;
+   unsigned int state_size;
void *data;
unsigned int low_ino;
nlink_t nlink;
diff --git a/include/linux/atalk.h b/include/linux/atalk.h
index 40373920ea58..23f805562f4e 100644
--- a/include/linux/atalk.h
+++ b/include/linux/atalk.h
@@ -145,7 +145,12 @@ extern rwlock_t atalk_interfaces_lock;
 
 extern struct atalk_route atrtr_default;
 
-extern const struct file_operations atalk_seq_arp_fops;
+struct aarp_iter_state {
+   int bucket;
+   struct aarp_entry **table;
+};
+
+extern const struct seq_operations aarp_seq_ops;
 
 extern int sysctl_aarp_expiry_time;
 extern int sysctl_aarp_tick_time;
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
index 45f5824b99dc..91d7b84c3c64 100644
--- a/include/linux/proc_fs.h
+++ b/include/linux/proc_fs.h
@@ -25,11 +25,13 @@ extern struct proc_dir_entry *proc_mkdir_mode(const char *, 
umode_t,
  struct proc_dir_entry *);
 struct proc_dir_entry *proc_create_mount_point(const char *name);
 
-struct proc_dir_entry *proc_create_seq_data(const char *name, umode_t mode,
+struct proc_dir_entry *proc_create_seq_private(const char *name, umode_t mode,
struct proc_dir_entry *parent, const struct seq_operations *ops,
-   void *data);
+   unsigned int state_size, void *data);
+#define proc_create_seq_data(name, mode, parent, ops, data) \
+   proc_create_seq_private(name, mode, parent, ops, 0, data)
 #define proc_create_seq(name, mode, parent, ops) \
-   

[PATCH 07/40] ipv{4,6}/udp{,lite}: simplify proc registration

2018-04-25 Thread Christoph Hellwig
Remove a couple indirections to make the code look like most other
protocols.

Signed-off-by: Christoph Hellwig 
---
 include/net/udp.h  | 20 --
 net/ipv4/udp.c | 99 +-
 net/ipv4/udplite.c | 21 +++---
 net/ipv6/udp.c | 30 +-
 net/ipv6/udplite.c | 21 +++---
 5 files changed, 78 insertions(+), 113 deletions(-)

diff --git a/include/net/udp.h b/include/net/udp.h
index 0676b272f6ac..093cd323f66a 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -408,31 +408,27 @@ do {  
\
 #define __UDPX_INC_STATS(sk, field) __UDP_INC_STATS(sock_net(sk), field, 0)
 #endif
 
-/* /proc */
-int udp_seq_open(struct inode *inode, struct file *file);
-
+#ifdef CONFIG_PROC_FS
 struct udp_seq_afinfo {
-   char*name;
sa_family_t family;
struct udp_table*udp_table;
-   const struct file_operations*seq_fops;
-   struct seq_operations   seq_ops;
 };
 
 struct udp_iter_state {
struct seq_net_private  p;
-   sa_family_t family;
int bucket;
-   struct udp_table*udp_table;
 };
 
-#ifdef CONFIG_PROC_FS
-int udp_proc_register(struct net *net, struct udp_seq_afinfo *afinfo);
-void udp_proc_unregister(struct net *net, struct udp_seq_afinfo *afinfo);
+void *udp_seq_start(struct seq_file *seq, loff_t *pos);
+void *udp_seq_next(struct seq_file *seq, void *v, loff_t *pos);
+void udp_seq_stop(struct seq_file *seq, void *v);
+
+extern const struct file_operations udp_afinfo_seq_fops;
+extern const struct file_operations udp6_afinfo_seq_fops;
 
 int udp4_proc_init(void);
 void udp4_proc_exit(void);
-#endif
+#endif /* CONFIG_PROC_FS */
 
 int udpv4_offload_init(void);
 
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 24b5c59b1c53..d48790ddb6cf 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -2579,12 +2579,13 @@ EXPORT_SYMBOL(udp_prot);
 static struct sock *udp_get_first(struct seq_file *seq, int start)
 {
struct sock *sk;
+   struct udp_seq_afinfo *afinfo = PDE_DATA(file_inode(seq->file));
struct udp_iter_state *state = seq->private;
struct net *net = seq_file_net(seq);
 
-   for (state->bucket = start; state->bucket <= state->udp_table->mask;
+   for (state->bucket = start; state->bucket <= afinfo->udp_table->mask;
 ++state->bucket) {
-   struct udp_hslot *hslot = 
&state->udp_table->hash[state->bucket];
+   struct udp_hslot *hslot = 
&afinfo->udp_table->hash[state->bucket];
 
if (hlist_empty(&hslot->head))
continue;
@@ -2593,7 +2594,7 @@ static struct sock *udp_get_first(struct seq_file *seq, 
int start)
sk_for_each(sk, &hslot->head) {
if (!net_eq(sock_net(sk), net))
continue;
-   if (sk->sk_family == state->family)
+   if (sk->sk_family == afinfo->family)
goto found;
}
spin_unlock_bh(&hslot->lock);
@@ -2605,16 +2606,17 @@ static struct sock *udp_get_first(struct seq_file *seq, 
int start)
 
 static struct sock *udp_get_next(struct seq_file *seq, struct sock *sk)
 {
+   struct udp_seq_afinfo *afinfo = PDE_DATA(file_inode(seq->file));
struct udp_iter_state *state = seq->private;
struct net *net = seq_file_net(seq);
 
do {
sk = sk_next(sk);
-   } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != 
state->family));
+   } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != 
afinfo->family));
 
if (!sk) {
-   if (state->bucket <= state->udp_table->mask)
-   
spin_unlock_bh(&state->udp_table->hash[state->bucket].lock);
+   if (state->bucket <= afinfo->udp_table->mask)
+   
spin_unlock_bh(&afinfo->udp_table->hash[state->bucket].lock);
return udp_get_first(seq, state->bucket + 1);
}
return sk;
@@ -2630,15 +2632,16 @@ static struct sock *udp_get_idx(struct seq_file *seq, 
loff_t pos)
return pos ? NULL : sk;
 }
 
-static void *udp_seq_start(struct seq_file *seq, loff_t *pos)
+void *udp_seq_start(struct seq_file *seq, loff_t *pos)
 {
struct udp_iter_state *state = seq->private;
state->bucket = MAX_UDP_PORTS;
 
return *pos ? udp_get_idx(seq, *pos-1) : SEQ_START_TOKEN;
 }
+EXPORT_SYMBOL(udp_seq_start);
 
-static void *udp_seq_next(struct seq_file *seq, void *v, loff_t *pos)
+void *udp_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 {
struct sock *sk;
 
@@ -2650,56 +2653,17 @@ static void *udp_seq_next(struct seq_file *seq, void 
*v, loff_t *pos)
++*pos;
return sk;
 }
+EXPORT_SYMBOL(udp_seq_next);
 
-static void udp_seq_stop(s

[PATCH 06/40] proc: introduce proc_create_single{,_data}

2018-04-25 Thread Christoph Hellwig
Variants of proc_create{,_data} that directly take a seq_file show
callback and drastically reduces the boilerplate code in the callers.

All trivial callers converted over.

Signed-off-by: Christoph Hellwig 
---
 arch/arm/kernel/dma.c | 14 +---
 arch/arm/kernel/swp_emulate.c | 15 +---
 arch/arm/mach-rpc/ecard.c | 16 +---
 arch/ia64/kernel/palinfo.c| 16 +---
 arch/ia64/kernel/salinfo.c| 42 --
 arch/ia64/sn/kernel/sn2/prominfo_proc.c   | 32 +---
 arch/ia64/sn/kernel/sn2/sn_proc_fs.c  | 62 ++
 arch/m68k/kernel/setup_mm.c   | 14 +---
 arch/mips/pci/ops-pmcmsp.c| 28 +--
 arch/mips/sibyte/common/bus_watcher.c | 16 +---
 arch/parisc/kernel/pci-dma.c  | 17 +---
 arch/parisc/kernel/pdc_chassis.c  | 14 +---
 arch/powerpc/kernel/eeh.c | 14 +---
 arch/powerpc/kernel/rtas-proc.c   | 32 +---
 arch/powerpc/platforms/cell/spufs/sched.c | 14 +---
 arch/s390/kernel/sysinfo.c| 14 +---
 arch/sh/drivers/dma/dma-api.c | 14 +---
 arch/sparc/kernel/ioport.c| 19 +
 arch/um/drivers/ubd_kern.c| 16 +---
 arch/x86/kernel/apm_32.c  | 15 +---
 drivers/acpi/ac.c | 21 +
 drivers/acpi/button.c | 19 +
 drivers/block/DAC960.c| 49 ++-
 drivers/block/pktcdvd.c   | 14 +---
 drivers/block/ps3vram.c   | 17 +---
 drivers/char/apm-emulation.c  | 15 +---
 drivers/char/ds1620.c | 14 +---
 drivers/char/efirtc.c | 15 +---
 drivers/char/nvram.c  | 15 +---
 drivers/char/rtc.c| 19 +
 drivers/char/toshiba.c| 15 +---
 drivers/connector/connector.c | 15 +---
 drivers/input/misc/hp_sdc_rtc.c   | 14 +---
 drivers/isdn/capi/capi.c  | 30 +--
 drivers/isdn/capi/capidrv.c   | 15 +---
 drivers/isdn/hardware/eicon/diva_didd.c   | 17 +---
 drivers/isdn/hardware/eicon/divasi.c  | 17 +---
 drivers/macintosh/via-pmu.c   | 57 +++--
 drivers/media/pci/saa7164/saa7164-core.c  | 14 +---
 drivers/media/pci/zoran/videocodec.c  | 16 +---
 drivers/message/fusion/mptbase.c  | 57 +++--
 drivers/mtd/mtdcore.c | 14 +---
 drivers/net/wireless/atmel/atmel.c| 15 +---
 .../net/wireless/intersil/hostap/hostap_ap.c  | 16 +---
 drivers/net/wireless/ray_cs.c | 15 +---
 drivers/nubus/proc.c  | 55 ++---
 drivers/parisc/ccio-dma.c | 34 +---
 drivers/parisc/sba_iommu.c| 32 +---
 drivers/platform/x86/toshiba_acpi.c   | 17 +---
 drivers/pnp/pnpbios/proc.c| 78 ++
 drivers/staging/comedi/proc.c | 18 +---
 drivers/usb/gadget/udc/at91_udc.c | 16 +---
 drivers/usb/gadget/udc/fsl_udc_core.c | 18 +---
 drivers/usb/gadget/udc/goku_udc.c | 18 +---
 drivers/usb/gadget/udc/omap_udc.c | 15 +---
 drivers/video/fbdev/via/viafbdev.c| 17 +---
 fs/cifs/cifs_debug.c  | 15 +---
 fs/f2fs/sysfs.c   | 29 ++-
 fs/filesystems.c  | 14 +---
 fs/fscache/internal.h |  2 +-
 fs/fscache/proc.c |  4 +-
 fs/fscache/stats.c| 17 +---
 fs/proc/cmdline.c | 14 +---
 fs/proc/generic.c | 29 +++
 fs/proc/internal.h|  5 +-
 fs/proc/loadavg.c | 14 +---
 fs/proc/meminfo.c | 14 +---
 fs/proc/softirqs.c| 14 +---
 fs/proc/uptime.c  | 14 +---
 fs/proc/version.c | 14 +---
 fs/reiserfs/procfs.c  | 16 +---
 fs/xfs/xfs_stats.c| 31 +--
 include/linux/proc_fs.h   | 10 ++-
 kernel/cgroup/cgroup-internal.h   |  2 +-
 kernel/cgroup/cgroup-v1.c | 14 +---
 kernel/cgroup/cgroup.c|  2 +-
 kernel/dma.c  | 14 +---
 kernel/exec_domain.c  | 14 +---
 kernel/irq/proc.c | 82 +++
 kernel/locking/lockdep_proc.c | 16 +---
 net/8021q/vlanproc.c  | 21 +
 net/ipv4/ipconfig.c   | 14 +---
 net/ipv

[PATCH 04/40] proc: introduce proc_create_seq{,_data}

2018-04-25 Thread Christoph Hellwig
Variants of proc_create{,_data} that directly take a struct seq_operations
argument and drastically reduces the boilerplate code in the callers.

All trivial callers converted over.

Signed-off-by: Christoph Hellwig 
---
 arch/ia64/hp/common/sba_iommu.c  | 15 +-
 arch/ia64/kernel/perfmon.c   | 16 +--
 arch/s390/kernel/sysinfo.c   | 14 +-
 block/genhd.c| 28 +--
 crypto/proc.c| 14 +-
 drivers/char/misc.c  | 15 +-
 drivers/isdn/capi/kcapi_proc.c   | 80 ++--
 drivers/net/hamradio/bpqether.c  | 16 +--
 drivers/net/hamradio/scc.c   | 17 +--
 drivers/net/hamradio/yam.c   | 16 +--
 drivers/pci/proc.c   | 17 +--
 drivers/s390/block/dasd_proc.c   | 17 +--
 drivers/s390/char/tape_proc.c| 19 +---
 drivers/staging/ipx/ipx_proc.c   | 45 ++
 drivers/tty/tty_ldisc.c  | 15 +-
 drivers/video/fbdev/core/fbmem.c | 15 +-
 drivers/zorro/proc.c | 17 +--
 fs/cachefiles/proc.c | 19 +---
 fs/fscache/histogram.c   | 17 +--
 fs/fscache/internal.h|  3 +-
 fs/fscache/proc.c|  4 +-
 fs/proc/consoles.c   | 14 +-
 fs/proc/devices.c| 14 +-
 fs/proc/generic.c| 30 
 fs/proc/internal.h   |  1 +
 fs/proc/interrupts.c | 14 +-
 fs/proc/nommu.c  | 14 +-
 fs/proc/proc_tty.c   | 16 +--
 include/linux/proc_fs.h  |  9 
 include/linux/tty.h  |  3 +-
 include/net/ax25.h   |  5 +-
 include/net/netrom.h |  5 +-
 include/net/rose.h   |  6 +--
 kernel/locking/lockdep_proc.c| 29 +---
 kernel/sched/debug.c | 28 +--
 kernel/sched/stats.c | 15 +-
 mm/vmalloc.c | 11 +++--
 mm/vmstat.c  | 56 ++
 net/appletalk/atalk_proc.c   | 48 +++
 net/atm/br2684.c | 14 +-
 net/ax25/af_ax25.c   | 21 ++---
 net/ax25/ax25_route.c| 15 +-
 net/ax25/ax25_uid.c  | 15 +-
 net/core/net-procfs.c| 16 +--
 net/decnet/dn_dev.c  | 15 +-
 net/llc/llc_proc.c   | 28 +--
 net/netrom/af_netrom.c   | 18 ++-
 net/netrom/nr_route.c| 29 +---
 net/rose/af_rose.c   | 26 +++
 net/rose/rose_route.c| 44 ++
 net/sctp/objcnt.c| 16 +--
 net/x25/x25_proc.c   | 48 +++
 security/keys/proc.c | 34 +-
 53 files changed, 151 insertions(+), 925 deletions(-)

diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c
index aec4a3354abe..cb5cd86a5530 100644
--- a/arch/ia64/hp/common/sba_iommu.c
+++ b/arch/ia64/hp/common/sba_iommu.c
@@ -1942,19 +1942,6 @@ static const struct seq_operations ioc_seq_ops = {
.show  = ioc_show
 };
 
-static int
-ioc_open(struct inode *inode, struct file *file)
-{
-   return seq_open(file, &ioc_seq_ops);
-}
-
-static const struct file_operations ioc_fops = {
-   .open= ioc_open,
-   .read= seq_read,
-   .llseek  = seq_lseek,
-   .release = seq_release
-};
-
 static void __init
 ioc_proc_init(void)
 {
@@ -1964,7 +1951,7 @@ ioc_proc_init(void)
if (!dir)
return;
 
-   proc_create(ioc_list->name, 0, dir, &ioc_fops);
+   proc_create_seq(ioc_list->name, 0, dir, &ioc_seq_ops);
 }
 #endif
 
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index 8fb280e33114..3b38c717008a 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -5708,13 +5708,6 @@ const struct seq_operations pfm_seq_ops = {
.show = pfm_proc_show
 };
 
-static int
-pfm_proc_open(struct inode *inode, struct file *file)
-{
-   return seq_open(file, &pfm_seq_ops);
-}
-
-
 /*
  * we come here as soon as local_cpu_data->pfm_syst_wide is set. this happens
  * during pfm_enable() hence before pfm_start(). We cannot assume monitoring
@@ -6537,13 +6530,6 @@ pfm_probe_pmu(void)
return 0;
 }
 
-static const struct file_operations pfm_proc_fops = {
-   .open   = pfm_proc_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= seq_release,
-};
-
 int __init
 pfm_init(void)
 {
@@ -6615,7 +6601,7 @@ pfm_init(void)
/*
 * create /proc/perfmon (mostly for debugging purposes)
 */
-   perfmon_dir = proc_create("perfmon", S_IRUGO, NULL, &pfm_proc_fops);
+   perfmon_dir = proc_create_seq("perfmon", S_IRUGO, NULL, &pfm_seq_ops);
if (perfmon_dir == NULL) {
printk(KERN_ERR "perfmon: cannot create /proc entry, perfmon 
disabled\n");
pm

[PATCH 10/40] ipv{4, 6}/raw: simplify ѕeq_file code

2018-04-25 Thread Christoph Hellwig
Pass the hashtable to the proc private data instead of copying
it into the per-file private data.

Signed-off-by: Christoph Hellwig 
---
 include/net/raw.h |  4 
 net/ipv4/raw.c| 36 
 net/ipv6/raw.c|  6 --
 3 files changed, 16 insertions(+), 30 deletions(-)

diff --git a/include/net/raw.h b/include/net/raw.h
index 99d26d0c4a19..9c9fa98a91a4 100644
--- a/include/net/raw.h
+++ b/include/net/raw.h
@@ -48,7 +48,6 @@ void raw_proc_exit(void);
 struct raw_iter_state {
struct seq_net_private p;
int bucket;
-   struct raw_hashinfo *h;
 };
 
 static inline struct raw_iter_state *raw_seq_private(struct seq_file *seq)
@@ -58,9 +57,6 @@ static inline struct raw_iter_state *raw_seq_private(struct 
seq_file *seq)
 void *raw_seq_start(struct seq_file *seq, loff_t *pos);
 void *raw_seq_next(struct seq_file *seq, void *v, loff_t *pos);
 void raw_seq_stop(struct seq_file *seq, void *v);
-int raw_seq_open(struct inode *ino, struct file *file,
-struct raw_hashinfo *h, const struct seq_operations *ops);
-
 #endif
 
 int raw_hash_sk(struct sock *sk);
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 1b4d3355624a..ae57962b31e3 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -1003,11 +1003,12 @@ struct proto raw_prot = {
 static struct sock *raw_get_first(struct seq_file *seq)
 {
struct sock *sk;
+   struct raw_hashinfo *h = PDE_DATA(file_inode(seq->file));
struct raw_iter_state *state = raw_seq_private(seq);
 
for (state->bucket = 0; state->bucket < RAW_HTABLE_SIZE;
++state->bucket) {
-   sk_for_each(sk, &state->h->ht[state->bucket])
+   sk_for_each(sk, &h->ht[state->bucket])
if (sock_net(sk) == seq_file_net(seq))
goto found;
}
@@ -1018,6 +1019,7 @@ static struct sock *raw_get_first(struct seq_file *seq)
 
 static struct sock *raw_get_next(struct seq_file *seq, struct sock *sk)
 {
+   struct raw_hashinfo *h = PDE_DATA(file_inode(seq->file));
struct raw_iter_state *state = raw_seq_private(seq);
 
do {
@@ -1027,7 +1029,7 @@ static struct sock *raw_get_next(struct seq_file *seq, 
struct sock *sk)
} while (sk && sock_net(sk) != seq_file_net(seq));
 
if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
-   sk = sk_head(&state->h->ht[state->bucket]);
+   sk = sk_head(&h->ht[state->bucket]);
goto try_again;
}
return sk;
@@ -1045,9 +1047,9 @@ static struct sock *raw_get_idx(struct seq_file *seq, 
loff_t pos)
 
 void *raw_seq_start(struct seq_file *seq, loff_t *pos)
 {
-   struct raw_iter_state *state = raw_seq_private(seq);
+   struct raw_hashinfo *h = PDE_DATA(file_inode(seq->file));
 
-   read_lock(&state->h->lock);
+   read_lock(&h->lock);
return *pos ? raw_get_idx(seq, *pos - 1) : SEQ_START_TOKEN;
 }
 EXPORT_SYMBOL_GPL(raw_seq_start);
@@ -1067,9 +1069,9 @@ EXPORT_SYMBOL_GPL(raw_seq_next);
 
 void raw_seq_stop(struct seq_file *seq, void *v)
 {
-   struct raw_iter_state *state = raw_seq_private(seq);
+   struct raw_hashinfo *h = PDE_DATA(file_inode(seq->file));
 
-   read_unlock(&state->h->lock);
+   read_unlock(&h->lock);
 }
 EXPORT_SYMBOL_GPL(raw_seq_stop);
 
@@ -1110,25 +1112,10 @@ static const struct seq_operations raw_seq_ops = {
.show  = raw_seq_show,
 };
 
-int raw_seq_open(struct inode *ino, struct file *file,
-struct raw_hashinfo *h, const struct seq_operations *ops)
-{
-   int err;
-   struct raw_iter_state *i;
-
-   err = seq_open_net(ino, file, ops, sizeof(struct raw_iter_state));
-   if (err < 0)
-   return err;
-
-   i = raw_seq_private((struct seq_file *)file->private_data);
-   i->h = h;
-   return 0;
-}
-EXPORT_SYMBOL_GPL(raw_seq_open);
-
 static int raw_v4_seq_open(struct inode *inode, struct file *file)
 {
-   return raw_seq_open(inode, file, &raw_v4_hashinfo, &raw_seq_ops);
+   return seq_open_net(inode, file, &raw_seq_ops,
+   sizeof(struct raw_iter_state));
 }
 
 static const struct file_operations raw_seq_fops = {
@@ -1140,7 +1127,8 @@ static const struct file_operations raw_seq_fops = {
 
 static __net_init int raw_init_net(struct net *net)
 {
-   if (!proc_create("raw", 0444, net->proc_net, &raw_seq_fops))
+   if (!proc_create_data("raw", 0444, net->proc_net, &raw_seq_fops,
+   &raw_v4_hashinfo))
return -ENOMEM;
 
return 0;
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index 5eb9b08947ed..dade69bf61e6 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -1306,7 +1306,8 @@ static const struct seq_operations raw6_seq_ops = {
 
 static int raw6_seq_open(struct inode *inode, struct file *file)
 {
-   return raw_seq_open(inode, file, &raw_v6_hashinfo, &raw6_seq_ops);
+   return seq_open_net(inode, file, &raw6_seq_o

[PATCH 08/40] ipv{4,6}/tcp: simplify procfs registration

2018-04-25 Thread Christoph Hellwig
Avoid most of the afinfo indirections and just call the proc helpers
directly.

Signed-off-by: Christoph Hellwig 
---
 include/net/tcp.h   | 11 ++
 net/ipv4/tcp_ipv4.c | 85 +
 net/ipv6/tcp_ipv6.c | 27 +-
 3 files changed, 53 insertions(+), 70 deletions(-)

diff --git a/include/net/tcp.h b/include/net/tcp.h
index 9c9b3768b350..51dc7a26a2fa 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1747,27 +1747,22 @@ enum tcp_seq_states {
TCP_SEQ_STATE_ESTABLISHED,
 };
 
-int tcp_seq_open(struct inode *inode, struct file *file);
+void *tcp_seq_start(struct seq_file *seq, loff_t *pos);
+void *tcp_seq_next(struct seq_file *seq, void *v, loff_t *pos);
+void tcp_seq_stop(struct seq_file *seq, void *v);
 
 struct tcp_seq_afinfo {
-   char*name;
sa_family_t family;
-   const struct file_operations*seq_fops;
-   struct seq_operations   seq_ops;
 };
 
 struct tcp_iter_state {
struct seq_net_private  p;
-   sa_family_t family;
enum tcp_seq_states state;
struct sock *syn_wait_sk;
int bucket, offset, sbucket, num;
loff_t  last_pos;
 };
 
-int tcp_proc_register(struct net *net, struct tcp_seq_afinfo *afinfo);
-void tcp_proc_unregister(struct net *net, struct tcp_seq_afinfo *afinfo);
-
 extern struct request_sock_ops tcp_request_sock_ops;
 extern struct request_sock_ops tcp6_request_sock_ops;
 
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index f70586b50838..645f259d0972 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1961,6 +1961,7 @@ EXPORT_SYMBOL(tcp_v4_destroy_sock);
  */
 static void *listening_get_next(struct seq_file *seq, void *cur)
 {
+   struct tcp_seq_afinfo *afinfo = PDE_DATA(file_inode(seq->file));
struct tcp_iter_state *st = seq->private;
struct net *net = seq_file_net(seq);
struct inet_listen_hashbucket *ilb;
@@ -1983,7 +1984,7 @@ static void *listening_get_next(struct seq_file *seq, 
void *cur)
sk_for_each_from(sk) {
if (!net_eq(sock_net(sk), net))
continue;
-   if (sk->sk_family == st->family)
+   if (sk->sk_family == afinfo->family)
return sk;
}
spin_unlock(&ilb->lock);
@@ -2020,6 +2021,7 @@ static inline bool empty_bucket(const struct 
tcp_iter_state *st)
  */
 static void *established_get_first(struct seq_file *seq)
 {
+   struct tcp_seq_afinfo *afinfo = PDE_DATA(file_inode(seq->file));
struct tcp_iter_state *st = seq->private;
struct net *net = seq_file_net(seq);
void *rc = NULL;
@@ -2036,7 +2038,7 @@ static void *established_get_first(struct seq_file *seq)
 
spin_lock_bh(lock);
sk_nulls_for_each(sk, node, 
&tcp_hashinfo.ehash[st->bucket].chain) {
-   if (sk->sk_family != st->family ||
+   if (sk->sk_family != afinfo->family ||
!net_eq(sock_net(sk), net)) {
continue;
}
@@ -2051,6 +2053,7 @@ static void *established_get_first(struct seq_file *seq)
 
 static void *established_get_next(struct seq_file *seq, void *cur)
 {
+   struct tcp_seq_afinfo *afinfo = PDE_DATA(file_inode(seq->file));
struct sock *sk = cur;
struct hlist_nulls_node *node;
struct tcp_iter_state *st = seq->private;
@@ -2062,7 +2065,8 @@ static void *established_get_next(struct seq_file *seq, 
void *cur)
sk = sk_nulls_next(sk);
 
sk_nulls_for_each_from(sk, node) {
-   if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
+   if (sk->sk_family == afinfo->family &&
+   net_eq(sock_net(sk), net))
return sk;
}
 
@@ -2135,7 +2139,7 @@ static void *tcp_seek_last_pos(struct seq_file *seq)
return rc;
 }
 
-static void *tcp_seq_start(struct seq_file *seq, loff_t *pos)
+void *tcp_seq_start(struct seq_file *seq, loff_t *pos)
 {
struct tcp_iter_state *st = seq->private;
void *rc;
@@ -2156,8 +2160,9 @@ static void *tcp_seq_start(struct seq_file *seq, loff_t 
*pos)
st->last_pos = *pos;
return rc;
 }
+EXPORT_SYMBOL(tcp_seq_start);
 
-static void *tcp_seq_next(struct seq_file *seq, void *v, loff_t *pos)
+void *tcp_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 {
struct tcp_iter_state *st = seq->private;
void *rc = NULL;
@@ -2186,8 +2191,9 @@ static void *tcp_seq_next(struct seq_file *seq, void *v, 
loff_t *pos)
st->last_pos = *pos;
return rc;
 }
+EXPORT_SYMBOL(tcp_seq_next);
 
-static void tcp_seq_stop(struct seq_file *seq, void *v)
+void tcp_seq_stop(struct seq_file *seq, void *v)
 {
struct tcp_iter_state *st = seq->private;
 
@@ -2202,47 +2208,7 @@ 

[PATCH 12/40] net/kcm: simplify proc registration

2018-04-25 Thread Christoph Hellwig
Remove a couple indirections to make the code look like most other
protocols.

Signed-off-by: Christoph Hellwig 
---
 net/kcm/kcmproc.c | 71 ---
 1 file changed, 17 insertions(+), 54 deletions(-)

diff --git a/net/kcm/kcmproc.c b/net/kcm/kcmproc.c
index 1fac92543094..6d0667e62baf 100644
--- a/net/kcm/kcmproc.c
+++ b/net/kcm/kcmproc.c
@@ -15,12 +15,6 @@
 #include 
 
 #ifdef CONFIG_PROC_FS
-struct kcm_seq_muxinfo {
-   char*name;
-   const struct file_operations*seq_fops;
-   const struct seq_operations seq_ops;
-};
-
 static struct kcm_mux *kcm_get_first(struct seq_file *seq)
 {
struct net *net = seq_file_net(seq);
@@ -86,14 +80,6 @@ struct kcm_proc_mux_state {
int idx;
 };
 
-static int kcm_seq_open(struct inode *inode, struct file *file)
-{
-   struct kcm_seq_muxinfo *muxinfo = PDE_DATA(inode);
-
-   return seq_open_net(inode, file, &muxinfo->seq_ops,
-  sizeof(struct kcm_proc_mux_state));
-}
-
 static void kcm_format_mux_header(struct seq_file *seq)
 {
struct net *net = seq_file_net(seq);
@@ -246,6 +232,19 @@ static int kcm_seq_show(struct seq_file *seq, void *v)
return 0;
 }
 
+static const struct seq_operations kcm_seq_ops = {
+   .show   = kcm_seq_show,
+   .start  = kcm_seq_start,
+   .next   = kcm_seq_next,
+   .stop   = kcm_seq_stop,
+};
+
+static int kcm_seq_open(struct inode *inode, struct file *file)
+{
+   return seq_open_net(inode, file, &kcm_seq_ops,
+  sizeof(struct kcm_proc_mux_state));
+}
+
 static const struct file_operations kcm_seq_fops = {
.open   = kcm_seq_open,
.read   = seq_read,
@@ -253,37 +252,6 @@ static const struct file_operations kcm_seq_fops = {
.release= seq_release_net,
 };
 
-static struct kcm_seq_muxinfo kcm_seq_muxinfo = {
-   .name   = "kcm",
-   .seq_fops   = &kcm_seq_fops,
-   .seq_ops= {
-   .show   = kcm_seq_show,
-   .start  = kcm_seq_start,
-   .next   = kcm_seq_next,
-   .stop   = kcm_seq_stop,
-   }
-};
-
-static int kcm_proc_register(struct net *net, struct kcm_seq_muxinfo *muxinfo)
-{
-   struct proc_dir_entry *p;
-   int rc = 0;
-
-   p = proc_create_data(muxinfo->name, 0444, net->proc_net,
-muxinfo->seq_fops, muxinfo);
-   if (!p)
-   rc = -ENOMEM;
-   return rc;
-}
-EXPORT_SYMBOL(kcm_proc_register);
-
-static void kcm_proc_unregister(struct net *net,
-   struct kcm_seq_muxinfo *muxinfo)
-{
-   remove_proc_entry(muxinfo->name, net->proc_net);
-}
-EXPORT_SYMBOL(kcm_proc_unregister);
-
 static int kcm_stats_seq_show(struct seq_file *seq, void *v)
 {
struct kcm_psock_stats psock_stats;
@@ -404,16 +372,11 @@ static const struct file_operations kcm_stats_seq_fops = {
 
 static int kcm_proc_init_net(struct net *net)
 {
-   int err;
-
if (!proc_create("kcm_stats", 0444, net->proc_net,
-&kcm_stats_seq_fops)) {
-   err = -ENOMEM;
+&kcm_stats_seq_fops))
goto out_kcm_stats;
-   }
 
-   err = kcm_proc_register(net, &kcm_seq_muxinfo);
-   if (err)
+   if (!proc_create("kcm", 0444, net->proc_net, &kcm_seq_fops))
goto out_kcm;
 
return 0;
@@ -421,12 +384,12 @@ static int kcm_proc_init_net(struct net *net)
 out_kcm:
remove_proc_entry("kcm_stats", net->proc_net);
 out_kcm_stats:
-   return err;
+   return -ENOMEM;
 }
 
 static void kcm_proc_exit_net(struct net *net)
 {
-   kcm_proc_unregister(net, &kcm_seq_muxinfo);
+   remove_proc_entry("kcm", net->proc_net);
remove_proc_entry("kcm_stats", net->proc_net);
 }
 
-- 
2.17.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 13/40] netfilter/x_tables: simplify ѕeq_file code

2018-04-25 Thread Christoph Hellwig
Just use the address family from the proc private data instead of copying
it into per-file data.

Signed-off-by: Christoph Hellwig 
---
 net/netfilter/x_tables.c | 39 +++
 1 file changed, 11 insertions(+), 28 deletions(-)

diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index 71325fef647d..3704101af27f 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -1489,15 +1489,10 @@ void *xt_unregister_table(struct xt_table *table)
 EXPORT_SYMBOL_GPL(xt_unregister_table);
 
 #ifdef CONFIG_PROC_FS
-struct xt_names_priv {
-   struct seq_net_private p;
-   u_int8_t af;
-};
 static void *xt_table_seq_start(struct seq_file *seq, loff_t *pos)
 {
-   struct xt_names_priv *priv = seq->private;
struct net *net = seq_file_net(seq);
-   u_int8_t af = priv->af;
+   u_int8_t af = (unsigned long)PDE_DATA(file_inode(seq->file));
 
mutex_lock(&xt[af].mutex);
return seq_list_start(&net->xt.tables[af], *pos);
@@ -1505,17 +1500,15 @@ static void *xt_table_seq_start(struct seq_file *seq, 
loff_t *pos)
 
 static void *xt_table_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 {
-   struct xt_names_priv *priv = seq->private;
struct net *net = seq_file_net(seq);
-   u_int8_t af = priv->af;
+   u_int8_t af = (unsigned long)PDE_DATA(file_inode(seq->file));
 
return seq_list_next(v, &net->xt.tables[af], pos);
 }
 
 static void xt_table_seq_stop(struct seq_file *seq, void *v)
 {
-   struct xt_names_priv *priv = seq->private;
-   u_int8_t af = priv->af;
+   u_int8_t af = (unsigned long)PDE_DATA(file_inode(seq->file));
 
mutex_unlock(&xt[af].mutex);
 }
@@ -1538,16 +1531,8 @@ static const struct seq_operations xt_table_seq_ops = {
 
 static int xt_table_open(struct inode *inode, struct file *file)
 {
-   int ret;
-   struct xt_names_priv *priv;
-
-   ret = seq_open_net(inode, file, &xt_table_seq_ops,
-  sizeof(struct xt_names_priv));
-   if (!ret) {
-   priv = ((struct seq_file *)file->private_data)->private;
-   priv->af = (unsigned long)PDE_DATA(inode);
-   }
-   return ret;
+   return seq_open_net(inode, file, &xt_table_seq_ops,
+   sizeof(struct seq_net_private));
 }
 
 static const struct file_operations xt_table_ops = {
@@ -1563,7 +1548,7 @@ static const struct file_operations xt_table_ops = {
  */
 struct nf_mttg_trav {
struct list_head *head, *curr;
-   uint8_t class, nfproto;
+   uint8_t class;
 };
 
 enum {
@@ -1580,6 +1565,7 @@ static void *xt_mttg_seq_next(struct seq_file *seq, void 
*v, loff_t *ppos,
[MTTG_TRAV_NFP_UNSPEC] = MTTG_TRAV_NFP_SPEC,
[MTTG_TRAV_NFP_SPEC]   = MTTG_TRAV_DONE,
};
+   uint8_t nfproto = (unsigned long)PDE_DATA(file_inode(seq->file));
struct nf_mttg_trav *trav = seq->private;
 
switch (trav->class) {
@@ -1594,9 +1580,9 @@ static void *xt_mttg_seq_next(struct seq_file *seq, void 
*v, loff_t *ppos,
if (trav->curr != trav->head)
break;
mutex_unlock(&xt[NFPROTO_UNSPEC].mutex);
-   mutex_lock(&xt[trav->nfproto].mutex);
+   mutex_lock(&xt[nfproto].mutex);
trav->head = trav->curr = is_target ?
-   &xt[trav->nfproto].target : &xt[trav->nfproto].match;
+   &xt[nfproto].target : &xt[nfproto].match;
trav->class = next_class[trav->class];
break;
case MTTG_TRAV_NFP_SPEC:
@@ -1628,6 +1614,7 @@ static void *xt_mttg_seq_start(struct seq_file *seq, 
loff_t *pos,
 
 static void xt_mttg_seq_stop(struct seq_file *seq, void *v)
 {
+   uint8_t nfproto = (unsigned long)PDE_DATA(file_inode(seq->file));
struct nf_mttg_trav *trav = seq->private;
 
switch (trav->class) {
@@ -1635,7 +1622,7 @@ static void xt_mttg_seq_stop(struct seq_file *seq, void 
*v)
mutex_unlock(&xt[NFPROTO_UNSPEC].mutex);
break;
case MTTG_TRAV_NFP_SPEC:
-   mutex_unlock(&xt[trav->nfproto].mutex);
+   mutex_unlock(&xt[nfproto].mutex);
break;
}
 }
@@ -1680,8 +1667,6 @@ static int xt_match_open(struct inode *inode, struct file 
*file)
trav = __seq_open_private(file, &xt_match_seq_ops, sizeof(*trav));
if (!trav)
return -ENOMEM;
-
-   trav->nfproto = (unsigned long)PDE_DATA(inode);
return 0;
 }
 
@@ -1732,8 +1717,6 @@ static int xt_target_open(struct inode *inode, struct 
file *file)
trav = __seq_open_private(file, &xt_target_seq_ops, sizeof(*trav));
if (!trav)
return -ENOMEM;
-
-   trav->nfproto = (unsigned long)PDE_DATA(inode);
return 0;
 }
 
-- 
2.17.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linu

[PATCH 14/40] net: move seq_file_single_net to

2018-04-25 Thread Christoph Hellwig
This helper deals with single_{open,release}_net internals and thus
belongs here.

Signed-off-by: Christoph Hellwig 
---
 include/linux/seq_file_net.h | 13 +
 include/net/ip_vs.h  | 12 
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/include/linux/seq_file_net.h b/include/linux/seq_file_net.h
index 43ccd84127b6..ed20faa99e05 100644
--- a/include/linux/seq_file_net.h
+++ b/include/linux/seq_file_net.h
@@ -28,4 +28,17 @@ static inline struct net *seq_file_net(struct seq_file *seq)
 #endif
 }
 
+/*
+ * This one is needed for single_open_net since net is stored directly in
+ * private not as a struct i.e. seq_file_net can't be used.
+ */
+static inline struct net *seq_file_single_net(struct seq_file *seq)
+{
+#ifdef CONFIG_NET_NS
+   return (struct net *)seq->private;
+#else
+   return &init_net;
+#endif
+}
+
 #endif
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index eb0bec043c96..aea7a124e66b 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -41,18 +41,6 @@ static inline struct netns_ipvs *net_ipvs(struct net* net)
return net->ipvs;
 }
 
-/* This one needed for single_open_net since net is stored directly in
- * private not as a struct i.e. seq_file_net can't be used.
- */
-static inline struct net *seq_file_single_net(struct seq_file *seq)
-{
-#ifdef CONFIG_NET_NS
-   return (struct net *)seq->private;
-#else
-   return &init_net;
-#endif
-}
-
 /* Connections' size value needed by ip_vs_ctl.c */
 extern int ip_vs_conn_tab_size;
 
-- 
2.17.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 17/40] acpi/battery: simplify procfs code

2018-04-25 Thread Christoph Hellwig
Use remove_proc_subtree to remove the whole subtree on cleanup, and
unwind the registration loop into individual calls.  Switch to use
proc_create_seq where applicable.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Rafael J. Wysocki 
---
 drivers/acpi/battery.c | 121 +
 1 file changed, 26 insertions(+), 95 deletions(-)

diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index bdb24d636d9a..76550689ce10 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -81,14 +81,6 @@ MODULE_PARM_DESC(cache_time, "cache time in milliseconds");
 #ifdef CONFIG_ACPI_PROCFS_POWER
 extern struct proc_dir_entry *acpi_lock_battery_dir(void);
 extern void *acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir);
-
-enum acpi_battery_files {
-   info_tag = 0,
-   state_tag,
-   alarm_tag,
-   ACPI_BATTERY_NUMFILES,
-};
-
 #endif
 
 static const struct acpi_device_id battery_device_ids[] = {
@@ -985,9 +977,10 @@ static const char *acpi_battery_units(const struct 
acpi_battery *battery)
"mA" : "mW";
 }
 
-static int acpi_battery_print_info(struct seq_file *seq, int result)
+static int acpi_battery_info_proc_show(struct seq_file *seq, void *offset)
 {
struct acpi_battery *battery = seq->private;
+   int result = acpi_battery_update(battery, false);
 
if (result)
goto end;
@@ -1041,9 +1034,10 @@ static int acpi_battery_print_info(struct seq_file *seq, 
int result)
return result;
 }
 
-static int acpi_battery_print_state(struct seq_file *seq, int result)
+static int acpi_battery_state_proc_show(struct seq_file *seq, void *offset)
 {
struct acpi_battery *battery = seq->private;
+   int result = acpi_battery_update(battery, false);
 
if (result)
goto end;
@@ -1088,9 +1082,10 @@ static int acpi_battery_print_state(struct seq_file 
*seq, int result)
return result;
 }
 
-static int acpi_battery_print_alarm(struct seq_file *seq, int result)
+static int acpi_battery_alarm_proc_show(struct seq_file *seq, void *offset)
 {
struct acpi_battery *battery = seq->private;
+   int result = acpi_battery_update(battery, false);
 
if (result)
goto end;
@@ -1142,82 +1137,22 @@ static ssize_t acpi_battery_write_alarm(struct file 
*file,
return result;
 }
 
-typedef int(*print_func)(struct seq_file *seq, int result);
-
-static print_func acpi_print_funcs[ACPI_BATTERY_NUMFILES] = {
-   acpi_battery_print_info,
-   acpi_battery_print_state,
-   acpi_battery_print_alarm,
-};
-
-static int acpi_battery_read(int fid, struct seq_file *seq)
+static int acpi_battery_alarm_proc_open(struct inode *inode, struct file *file)
 {
-   struct acpi_battery *battery = seq->private;
-   int result = acpi_battery_update(battery, false);
-   return acpi_print_funcs[fid](seq, result);
+   return single_open(file, acpi_battery_alarm_proc_show, PDE_DATA(inode));
 }
 
-#define DECLARE_FILE_FUNCTIONS(_name) \
-static int acpi_battery_read_##_name(struct seq_file *seq, void *offset) \
-{ \
-   return acpi_battery_read(_name##_tag, seq); \
-} \
-static int acpi_battery_##_name##_open_fs(struct inode *inode, struct file 
*file) \
-{ \
-   return single_open(file, acpi_battery_read_##_name, PDE_DATA(inode)); \
-}
-
-DECLARE_FILE_FUNCTIONS(info);
-DECLARE_FILE_FUNCTIONS(state);
-DECLARE_FILE_FUNCTIONS(alarm);
-
-#undef DECLARE_FILE_FUNCTIONS
-
-#define FILE_DESCRIPTION_RO(_name) \
-   { \
-   .name = __stringify(_name), \
-   .mode = S_IRUGO, \
-   .ops = { \
-   .open = acpi_battery_##_name##_open_fs, \
-   .read = seq_read, \
-   .llseek = seq_lseek, \
-   .release = single_release, \
-   .owner = THIS_MODULE, \
-   }, \
-   }
-
-#define FILE_DESCRIPTION_RW(_name) \
-   { \
-   .name = __stringify(_name), \
-   .mode = S_IFREG | S_IRUGO | S_IWUSR, \
-   .ops = { \
-   .open = acpi_battery_##_name##_open_fs, \
-   .read = seq_read, \
-   .llseek = seq_lseek, \
-   .write = acpi_battery_write_##_name, \
-   .release = single_release, \
-   .owner = THIS_MODULE, \
-   }, \
-   }
-
-static const struct battery_file {
-   struct file_operations ops;
-   umode_t mode;
-   const char *name;
-} acpi_battery_file[] = {
-   FILE_DESCRIPTION_RO(info),
-   FILE_DESCRIPTION_RO(state),
-   FILE_DESCRIPTION_RW(alarm),
+static const struct file_operations acpi_battery_alarm_fops = {
+   .owner  = THIS_MODULE,
+   .open   = acpi_battery_alarm_proc_open,
+   .read   = seq_read,
+   .write  = acpi_battery_write_alarm,
+   .llseek = seq_lseek,
+   .release= single_release,
 };
 
-#undef FILE_DESCRIPTION_RO
-#undef FILE_DESCRIPTION_RW
-
 static int

[PATCH 16/40] proc: introduce proc_create_net_single

2018-04-25 Thread Christoph Hellwig
Variant of proc_create_data that directly take a seq_file show
callback and deals with network namespaces in ->open and ->release.
All callers of proc_create + single_open_net converted over, and
single_{open,release}_net are removed entirely.

Signed-off-by: Christoph Hellwig 
---
 fs/proc/proc_net.c |  49 -
 include/linux/proc_fs.h|   4 ++
 include/linux/seq_file_net.h   |   7 +-
 net/can/bcm.c  |  16 +
 net/can/proc.c | 127 ++---
 net/ipv4/fib_trie.c|  16 +
 net/ipv4/proc.c|  48 ++---
 net/ipv6/proc.c|  31 ++--
 net/ipv6/route.c   |  15 +---
 net/kcm/kcmproc.c  |  16 +
 net/netfilter/ipvs/ip_vs_ctl.c |  31 ++--
 net/sctp/proc.c|  17 +
 net/xfrm/xfrm_proc.c   |  16 +
 13 files changed, 86 insertions(+), 307 deletions(-)

diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
index 2b04ca9d7601..baf1994289ce 100644
--- a/fs/proc/proc_net.c
+++ b/fs/proc/proc_net.c
@@ -93,37 +93,50 @@ struct proc_dir_entry *proc_create_net_data(const char 
*name, umode_t mode,
 }
 EXPORT_SYMBOL_GPL(proc_create_net_data);
 
-int single_open_net(struct inode *inode, struct file *file,
-   int (*show)(struct seq_file *, void *))
+static int single_open_net(struct inode *inode, struct file *file)
 {
-   int err;
+   struct proc_dir_entry *de = PDE(inode);
struct net *net;
+   int err;
 
-   err = -ENXIO;
net = get_proc_net(inode);
-   if (net == NULL)
-   goto err_net;
-
-   err = single_open(file, show, net);
-   if (err < 0)
-   goto err_open;
-
-   return 0;
+   if (!net)
+   return -ENXIO;
 
-err_open:
-   put_net(net);
-err_net:
+   err = single_open(file, de->single_show, net);
+   if (err)
+   put_net(net);
return err;
 }
-EXPORT_SYMBOL_GPL(single_open_net);
 
-int single_release_net(struct inode *ino, struct file *f)
+static int single_release_net(struct inode *ino, struct file *f)
 {
struct seq_file *seq = f->private_data;
put_net(seq->private);
return single_release(ino, f);
 }
-EXPORT_SYMBOL_GPL(single_release_net);
+
+static const struct file_operations proc_net_single_fops = {
+   .open   = single_open_net,
+   .read   = seq_read,
+   .llseek = seq_lseek,
+   .release= single_release_net,
+};
+
+struct proc_dir_entry *proc_create_net_single(const char *name, umode_t mode,
+   struct proc_dir_entry *parent,
+   int (*show)(struct seq_file *, void *), void *data)
+{
+   struct proc_dir_entry *p;
+
+   p = proc_create_reg(name, mode, &parent, data);
+   if (!p)
+   return NULL;
+   p->proc_fops = &proc_net_single_fops;
+   p->single_show = show;
+   return proc_register(parent, p);
+}
+EXPORT_SYMBOL_GPL(proc_create_net_single);
 
 static struct net *get_proc_task_net(struct inode *dir)
 {
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
index ae2f849776ec..928c7b2cbff4 100644
--- a/include/linux/proc_fs.h
+++ b/include/linux/proc_fs.h
@@ -58,6 +58,9 @@ struct proc_dir_entry *proc_create_net_data(const char *name, 
umode_t mode,
unsigned int state_size, void *data);
 #define proc_create_net(name, mode, parent, state_size, ops) \
proc_create_net_data(name, mode, parent, state_size, ops, NULL)
+struct proc_dir_entry *proc_create_net_single(const char *name, umode_t mode,
+   struct proc_dir_entry *parent,
+   int (*show)(struct seq_file *, void *), void *data);
 
 #else /* CONFIG_PROC_FS */
 
@@ -97,6 +100,7 @@ static inline int remove_proc_subtree(const char *name, 
struct proc_dir_entry *p
 
 #define proc_create_net_data(name, mode, parent, ops, state_size, data) 
({NULL;})
 #define proc_create_net(name, mode, parent, state_size, ops) ({NULL;})
+#define proc_create_net_single(name, mode, parent, show, data) ({NULL;})
 
 #endif /* CONFIG_PROC_FS */
 
diff --git a/include/linux/seq_file_net.h b/include/linux/seq_file_net.h
index 5ea18a16291a..0fdbe1ddd8d1 100644
--- a/include/linux/seq_file_net.h
+++ b/include/linux/seq_file_net.h
@@ -13,9 +13,6 @@ struct seq_net_private {
 #endif
 };
 
-int single_open_net(struct inode *, struct file *file,
-   int (*show)(struct seq_file *, void *));
-int single_release_net(struct inode *, struct file *);
 static inline struct net *seq_file_net(struct seq_file *seq)
 {
 #ifdef CONFIG_NET_NS
@@ -26,8 +23,8 @@ static inline struct net *seq_file_net(struct seq_file *seq)
 }
 
 /*
- * This one is needed for single_open_net since net is stored directly in
- * private not as a struct i.e. seq_file_net can't be used.
+ * This one is needed for proc_create_net_single since net is stored directly
+ * in private not as a struct i.e. seq_file_net can

[PATCH 11/40] ipv6/flowlabel: simplify pid namespace lookup

2018-04-25 Thread Christoph Hellwig
The shole seq_file sequence already operates under a single RCU lock pair,
so move the pid namespace lookup into it, and stop grabbing a reference
and remove all kinds of boilerplate code.

Signed-off-by: Christoph Hellwig 
---
 net/ipv6/ip6_flowlabel.c | 28 +---
 1 file changed, 5 insertions(+), 23 deletions(-)

diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c
index c05c4e82a7ca..a9f221d45ef9 100644
--- a/net/ipv6/ip6_flowlabel.c
+++ b/net/ipv6/ip6_flowlabel.c
@@ -754,7 +754,10 @@ static struct ip6_flowlabel *ip6fl_get_idx(struct seq_file 
*seq, loff_t pos)
 static void *ip6fl_seq_start(struct seq_file *seq, loff_t *pos)
__acquires(RCU)
 {
+   struct ip6fl_iter_state *state = ip6fl_seq_private(seq);
+
rcu_read_lock_bh();
+   state->pid_ns = task_active_pid_ns(current);
return *pos ? ip6fl_get_idx(seq, *pos - 1) : SEQ_START_TOKEN;
 }
 
@@ -810,36 +813,15 @@ static const struct seq_operations ip6fl_seq_ops = {
 
 static int ip6fl_seq_open(struct inode *inode, struct file *file)
 {
-   struct seq_file *seq;
-   struct ip6fl_iter_state *state;
-   int err;
-
-   err = seq_open_net(inode, file, &ip6fl_seq_ops,
+   return seq_open_net(inode, file, &ip6fl_seq_ops,
   sizeof(struct ip6fl_iter_state));
-
-   if (!err) {
-   seq = file->private_data;
-   state = ip6fl_seq_private(seq);
-   rcu_read_lock();
-   state->pid_ns = get_pid_ns(task_active_pid_ns(current));
-   rcu_read_unlock();
-   }
-   return err;
-}
-
-static int ip6fl_seq_release(struct inode *inode, struct file *file)
-{
-   struct seq_file *seq = file->private_data;
-   struct ip6fl_iter_state *state = ip6fl_seq_private(seq);
-   put_pid_ns(state->pid_ns);
-   return seq_release_net(inode, file);
 }
 
 static const struct file_operations ip6fl_seq_fops = {
.open   =   ip6fl_seq_open,
.read   =   seq_read,
.llseek =   seq_lseek,
-   .release=   ip6fl_seq_release,
+   .release=   seq_release_net,
 };
 
 static int __net_init ip6_flowlabel_proc_init(struct net *net)
-- 
2.17.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 09/40] ipv{4,6}/ping: simplify proc file creation

2018-04-25 Thread Christoph Hellwig
Remove the pointless ping_seq_afinfo indirection and make the code look
like most other protocols.

Signed-off-by: Christoph Hellwig 
---
 include/net/ping.h | 11 --
 net/ipv4/ping.c| 50 +-
 net/ipv6/ping.c| 35 +---
 3 files changed, 37 insertions(+), 59 deletions(-)

diff --git a/include/net/ping.h b/include/net/ping.h
index 4cd90d6b5c25..fd080e043a6e 100644
--- a/include/net/ping.h
+++ b/include/net/ping.h
@@ -83,20 +83,9 @@ int  ping_queue_rcv_skb(struct sock *sk, struct sk_buff 
*skb);
 bool ping_rcv(struct sk_buff *skb);
 
 #ifdef CONFIG_PROC_FS
-struct ping_seq_afinfo {
-   char*name;
-   sa_family_t family;
-   const struct file_operations*seq_fops;
-   const struct seq_operations seq_ops;
-};
-
-extern const struct file_operations ping_seq_fops;
-
 void *ping_seq_start(struct seq_file *seq, loff_t *pos, sa_family_t family);
 void *ping_seq_next(struct seq_file *seq, void *v, loff_t *pos);
 void ping_seq_stop(struct seq_file *seq, void *v);
-int ping_proc_register(struct net *net, struct ping_seq_afinfo *afinfo);
-void ping_proc_unregister(struct net *net, struct ping_seq_afinfo *afinfo);
 
 int __init ping_proc_init(void);
 void ping_proc_exit(void);
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
index 05e47d777009..83170ebf5dfc 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -1147,58 +1147,36 @@ static int ping_v4_seq_show(struct seq_file *seq, void 
*v)
return 0;
 }
 
-static int ping_seq_open(struct inode *inode, struct file *file)
+static const struct seq_operations ping_v4_seq_ops = {
+   .start  = ping_v4_seq_start,
+   .show   = ping_v4_seq_show,
+   .next   = ping_seq_next,
+   .stop   = ping_seq_stop,
+};
+
+static int ping_v4_seq_open(struct inode *inode, struct file *file)
 {
-   struct ping_seq_afinfo *afinfo = PDE_DATA(inode);
-   return seq_open_net(inode, file, &afinfo->seq_ops,
+   return seq_open_net(inode, file, &ping_v4_seq_ops,
   sizeof(struct ping_iter_state));
 }
 
-const struct file_operations ping_seq_fops = {
-   .open   = ping_seq_open,
+const struct file_operations ping_v4_seq_fops = {
+   .open   = ping_v4_seq_open,
.read   = seq_read,
.llseek = seq_lseek,
.release= seq_release_net,
 };
-EXPORT_SYMBOL_GPL(ping_seq_fops);
-
-static struct ping_seq_afinfo ping_v4_seq_afinfo = {
-   .name   = "icmp",
-   .family = AF_INET,
-   .seq_fops   = &ping_seq_fops,
-   .seq_ops= {
-   .start  = ping_v4_seq_start,
-   .show   = ping_v4_seq_show,
-   .next   = ping_seq_next,
-   .stop   = ping_seq_stop,
-   },
-};
 
-int ping_proc_register(struct net *net, struct ping_seq_afinfo *afinfo)
+static int __net_init ping_v4_proc_init_net(struct net *net)
 {
-   struct proc_dir_entry *p;
-   p = proc_create_data(afinfo->name, 0444, net->proc_net,
-afinfo->seq_fops, afinfo);
-   if (!p)
+   if (!proc_create("icmp", 0444, net->proc_net, &ping_v4_seq_fops))
return -ENOMEM;
return 0;
 }
-EXPORT_SYMBOL_GPL(ping_proc_register);
-
-void ping_proc_unregister(struct net *net, struct ping_seq_afinfo *afinfo)
-{
-   remove_proc_entry(afinfo->name, net->proc_net);
-}
-EXPORT_SYMBOL_GPL(ping_proc_unregister);
-
-static int __net_init ping_v4_proc_init_net(struct net *net)
-{
-   return ping_proc_register(net, &ping_v4_seq_afinfo);
-}
 
 static void __net_exit ping_v4_proc_exit_net(struct net *net)
 {
-   ping_proc_unregister(net, &ping_v4_seq_afinfo);
+   remove_proc_entry("icmp", net->proc_net);
 }
 
 static struct pernet_operations ping_v4_net_ops = {
diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c
index 746eeae7f581..45d5c8e0f2bf 100644
--- a/net/ipv6/ping.c
+++ b/net/ipv6/ping.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 /* Compatibility glue so we can support IPv6 when it's compiled as a module */
@@ -215,26 +216,36 @@ static int ping_v6_seq_show(struct seq_file *seq, void *v)
return 0;
 }
 
-static struct ping_seq_afinfo ping_v6_seq_afinfo = {
-   .name   = "icmp6",
-   .family = AF_INET6,
-   .seq_fops   = &ping_seq_fops,
-   .seq_ops= {
-   .start  = ping_v6_seq_start,
-   .show   = ping_v6_seq_show,
-   .next   = ping_seq_next,
-   .stop   = ping_seq_stop,
-   },
+static const struct seq_operations ping_v6_seq_ops = {
+   .start  = ping_v6_seq_start,
+   .show   = ping_v6_seq_show,
+   .next   = ping_seq_next,
+   .stop   = ping_seq_stop,
+};
+
+stati

[PATCH 18/40] sgi-gru: simplify procfs code

2018-04-25 Thread Christoph Hellwig
Use remove_proc_subtree to remove the whole subtree on cleanup, and
unwind the registration loop into individual calls.  Switch to use
proc_create_seq where applicable.

Signed-off-by: Christoph Hellwig 
---
 drivers/misc/sgi-gru/gruprocfs.c | 81 ++--
 1 file changed, 14 insertions(+), 67 deletions(-)

diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
index 4f7635922394..42ea2eccaee9 100644
--- a/drivers/misc/sgi-gru/gruprocfs.c
+++ b/drivers/misc/sgi-gru/gruprocfs.c
@@ -270,16 +270,6 @@ static int options_open(struct inode *inode, struct file 
*file)
return single_open(file, options_show, NULL);
 }
 
-static int cch_open(struct inode *inode, struct file *file)
-{
-   return seq_open(file, &cch_seq_ops);
-}
-
-static int gru_open(struct inode *inode, struct file *file)
-{
-   return seq_open(file, &gru_seq_ops);
-}
-
 /* *INDENT-OFF* */
 static const struct file_operations statistics_fops = {
.open   = statistics_open,
@@ -305,73 +295,30 @@ static const struct file_operations options_fops = {
.release= single_release,
 };
 
-static const struct file_operations cch_fops = {
-   .open   = cch_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= seq_release,
-};
-static const struct file_operations gru_fops = {
-   .open   = gru_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= seq_release,
-};
-
-static struct proc_entry {
-   char *name;
-   umode_t mode;
-   const struct file_operations *fops;
-   struct proc_dir_entry *entry;
-} proc_files[] = {
-   {"statistics", 0644, &statistics_fops},
-   {"mcs_statistics", 0644, &mcs_statistics_fops},
-   {"debug_options", 0644, &options_fops},
-   {"cch_status", 0444, &cch_fops},
-   {"gru_status", 0444, &gru_fops},
-   {NULL}
-};
-/* *INDENT-ON* */
-
 static struct proc_dir_entry *proc_gru __read_mostly;
 
-static int create_proc_file(struct proc_entry *p)
-{
-   p->entry = proc_create(p->name, p->mode, proc_gru, p->fops);
-   if (!p->entry)
-   return -1;
-   return 0;
-}
-
-static void delete_proc_files(void)
-{
-   struct proc_entry *p;
-
-   if (proc_gru) {
-   for (p = proc_files; p->name; p++)
-   if (p->entry)
-   remove_proc_entry(p->name, proc_gru);
-   proc_remove(proc_gru);
-   }
-}
-
 int gru_proc_init(void)
 {
-   struct proc_entry *p;
-
proc_gru = proc_mkdir("sgi_uv/gru", NULL);
-
-   for (p = proc_files; p->name; p++)
-   if (create_proc_file(p))
-   goto err;
+   if (!proc_gru)
+   return -1;
+   if (!proc_create("statistics", 0644, proc_gru, &statistics_fops))
+   goto err;
+   if (!proc_create("mcs_statistics", 0644, proc_gru, 
&mcs_statistics_fops))
+   goto err;
+   if (!proc_create("debug_options", 0644, proc_gru, &options_fops))
+   goto err;
+   if (!proc_create_seq("cch_status", 0444, proc_gru, &cch_seq_ops))
+   goto err;
+   if (!proc_create_seq("gru_status", 0444, proc_gru, &gru_seq_ops))
+   goto err;
return 0;
-
 err:
-   delete_proc_files();
+   remove_proc_subtree("sgi_uv/gru", NULL);
return -1;
 }
 
 void gru_proc_exit(void)
 {
-   delete_proc_files();
+   remove_proc_subtree("sgi_uv/gru", NULL);
 }
-- 
2.17.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 19/40] megaraid: simplify procfs code

2018-04-25 Thread Christoph Hellwig
Use remove_proc_subtree to remove the whole subtree on cleanup, and
unwind the registration loop into individual calls.  Switch to use
proc_create_single.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/megaraid.c | 140 +++-
 drivers/scsi/megaraid.h |  12 
 2 files changed, 36 insertions(+), 116 deletions(-)

diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 7195cff51d4c..91f5e2c68dbc 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -2731,53 +2731,6 @@ proc_show_rdrv_40(struct seq_file *m, void *v)
return proc_show_rdrv(m, m->private, 30, 39);
 }
 
-
-/*
- * seq_file wrappers for procfile show routines.
- */
-static int mega_proc_open(struct inode *inode, struct file *file)
-{
-   adapter_t *adapter = proc_get_parent_data(inode);
-   int (*show)(struct seq_file *, void *) = PDE_DATA(inode);
-
-   return single_open(file, show, adapter);
-}
-
-static const struct file_operations mega_proc_fops = {
-   .open   = mega_proc_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
-
-/*
- * Table of proc files we need to create.
- */
-struct mega_proc_file {
-   const char *name;
-   unsigned short ptr_offset;
-   int (*show) (struct seq_file *m, void *v);
-};
-
-static const struct mega_proc_file mega_proc_files[] = {
-   { "config",   offsetof(adapter_t, proc_read), proc_show_config 
},
-   { "stat", offsetof(adapter_t, proc_stat), proc_show_stat },
-   { "mailbox",  offsetof(adapter_t, proc_mbox), proc_show_mbox },
-#if MEGA_HAVE_ENH_PROC
-   { "rebuild-rate", offsetof(adapter_t, proc_rr), 
proc_show_rebuild_rate },
-   { "battery-status",   offsetof(adapter_t, proc_battery), 
proc_show_battery },
-   { "diskdrives-ch0",   offsetof(adapter_t, proc_pdrvstat[0]), 
proc_show_pdrv_ch0 },
-   { "diskdrives-ch1",   offsetof(adapter_t, proc_pdrvstat[1]), 
proc_show_pdrv_ch1 },
-   { "diskdrives-ch2",   offsetof(adapter_t, proc_pdrvstat[2]), 
proc_show_pdrv_ch2 },
-   { "diskdrives-ch3",   offsetof(adapter_t, proc_pdrvstat[3]), 
proc_show_pdrv_ch3 },
-   { "raiddrives-0-9",   offsetof(adapter_t, proc_rdrvstat[0]), 
proc_show_rdrv_10 },
-   { "raiddrives-10-19", offsetof(adapter_t, proc_rdrvstat[1]), 
proc_show_rdrv_20 },
-   { "raiddrives-20-29", offsetof(adapter_t, proc_rdrvstat[2]), 
proc_show_rdrv_30 },
-   { "raiddrives-30-39", offsetof(adapter_t, proc_rdrvstat[3]), 
proc_show_rdrv_40 },
-#endif
-   { NULL }
-};
-
 /**
  * mega_create_proc_entry()
  * @index - index in soft state array
@@ -2788,31 +2741,45 @@ static const struct mega_proc_file mega_proc_files[] = {
 static void
 mega_create_proc_entry(int index, struct proc_dir_entry *parent)
 {
-   const struct mega_proc_file *f;
-   adapter_t   *adapter = hba_soft_state[index];
-   struct proc_dir_entry   *dir, *de, **ppde;
-   u8  string[16];
+   adapter_t *adapter = hba_soft_state[index];
+   struct proc_dir_entry *dir;
+   u8 string[16];
 
sprintf(string, "hba%d", adapter->host->host_no);
-
-   dir = adapter->controller_proc_dir_entry =
-   proc_mkdir_data(string, 0, parent, adapter);
-   if(!dir) {
+   dir = proc_mkdir_data(string, 0, parent, adapter);
+   if (!dir) {
dev_warn(&adapter->dev->dev, "proc_mkdir failed\n");
return;
}
 
-   for (f = mega_proc_files; f->name; f++) {
-   de = proc_create_data(f->name, S_IRUSR, dir, &mega_proc_fops,
- f->show);
-   if (!de) {
-   dev_warn(&adapter->dev->dev, "proc_create failed\n");
-   return;
-   }
-
-   ppde = (void *)adapter + f->ptr_offset;
-   *ppde = de;
-   }
+   proc_create_single_data("config", S_IRUSR, dir,
+   proc_show_config, adapter);
+   proc_create_single_data("stat", S_IRUSR, dir,
+   proc_show_stat, adapter);
+   proc_create_single_data("mailbox", S_IRUSR, dir,
+   proc_show_mbox, adapter);
+#if MEGA_HAVE_ENH_PROC
+   proc_create_single_data("rebuild-rate", S_IRUSR, dir,
+   proc_show_rebuild_rate, adapter);
+   proc_create_single_data("battery-status", S_IRUSR, dir,
+   proc_show_battery, adapter);
+   proc_create_single_data("diskdrives-ch0", S_IRUSR, dir,
+   proc_show_pdrv_ch0, adapter);
+   proc_create_single_data("diskdrives-ch1", S_IRUSR, dir,
+   proc_show_pdrv_ch1, adapter);
+   proc_create_single_data("diskdrives-ch2", S_IRUSR, dir,
+   proc_show_pdrv_ch2, adapter);
+   proc_create_single_data("diskdrives-ch3", S_IRUSR, dir,
+   proc_s

[PATCH 20/40] sg: simplify procfs code

2018-04-25 Thread Christoph Hellwig
Use remove_proc_subtree to remove the whole subtree on cleanup, and
unwind the registration loop into individual calls.  Switch to use
proc_create_seq where applicable.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/sg.c | 124 +-
 1 file changed, 12 insertions(+), 112 deletions(-)

diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index c198b96368dd..8ff687158704 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -66,7 +66,6 @@ static int sg_version_num = 30536;/* 2 digits for each 
component */
 static char *sg_version_date = "20140603";
 
 static int sg_proc_init(void);
-static void sg_proc_cleanup(void);
 #endif
 
 #define SG_ALLOW_DIO_DEF 0
@@ -1661,7 +1660,7 @@ static void __exit
 exit_sg(void)
 {
 #ifdef CONFIG_SCSI_PROC_FS
-   sg_proc_cleanup();
+   remove_proc_subtree("scsi/sg", NULL);
 #endif /* CONFIG_SCSI_PROC_FS */
scsi_unregister_interface(&sg_interface);
class_destroy(sg_sysfs_class);
@@ -2274,11 +2273,6 @@ sg_get_dev(int dev)
 }
 
 #ifdef CONFIG_SCSI_PROC_FS
-
-static struct proc_dir_entry *sg_proc_sgp = NULL;
-
-static char sg_proc_sg_dirname[] = "scsi/sg";
-
 static int sg_proc_seq_show_int(struct seq_file *s, void *v);
 
 static int sg_proc_single_open_adio(struct inode *inode, struct file *file);
@@ -2306,37 +2300,11 @@ static const struct file_operations dressz_fops = {
 };
 
 static int sg_proc_seq_show_version(struct seq_file *s, void *v);
-static int sg_proc_single_open_version(struct inode *inode, struct file *file);
-static const struct file_operations version_fops = {
-   .owner = THIS_MODULE,
-   .open = sg_proc_single_open_version,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = single_release,
-};
-
 static int sg_proc_seq_show_devhdr(struct seq_file *s, void *v);
-static int sg_proc_single_open_devhdr(struct inode *inode, struct file *file);
-static const struct file_operations devhdr_fops = {
-   .owner = THIS_MODULE,
-   .open = sg_proc_single_open_devhdr,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = single_release,
-};
-
 static int sg_proc_seq_show_dev(struct seq_file *s, void *v);
-static int sg_proc_open_dev(struct inode *inode, struct file *file);
 static void * dev_seq_start(struct seq_file *s, loff_t *pos);
 static void * dev_seq_next(struct seq_file *s, void *v, loff_t *pos);
 static void dev_seq_stop(struct seq_file *s, void *v);
-static const struct file_operations dev_fops = {
-   .owner = THIS_MODULE,
-   .open = sg_proc_open_dev,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = seq_release,
-};
 static const struct seq_operations dev_seq_ops = {
.start = dev_seq_start,
.next  = dev_seq_next,
@@ -2345,14 +2313,6 @@ static const struct seq_operations dev_seq_ops = {
 };
 
 static int sg_proc_seq_show_devstrs(struct seq_file *s, void *v);
-static int sg_proc_open_devstrs(struct inode *inode, struct file *file);
-static const struct file_operations devstrs_fops = {
-   .owner = THIS_MODULE,
-   .open = sg_proc_open_devstrs,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = seq_release,
-};
 static const struct seq_operations devstrs_seq_ops = {
.start = dev_seq_start,
.next  = dev_seq_next,
@@ -2361,14 +2321,6 @@ static const struct seq_operations devstrs_seq_ops = {
 };
 
 static int sg_proc_seq_show_debug(struct seq_file *s, void *v);
-static int sg_proc_open_debug(struct inode *inode, struct file *file);
-static const struct file_operations debug_fops = {
-   .owner = THIS_MODULE,
-   .open = sg_proc_open_debug,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = seq_release,
-};
 static const struct seq_operations debug_seq_ops = {
.start = dev_seq_start,
.next  = dev_seq_next,
@@ -2376,50 +2328,23 @@ static const struct seq_operations debug_seq_ops = {
.show  = sg_proc_seq_show_debug,
 };
 
-
-struct sg_proc_leaf {
-   const char * name;
-   const struct file_operations * fops;
-};
-
-static const struct sg_proc_leaf sg_proc_leaf_arr[] = {
-   {"allow_dio", &adio_fops},
-   {"debug", &debug_fops},
-   {"def_reserved_size", &dressz_fops},
-   {"device_hdr", &devhdr_fops},
-   {"devices", &dev_fops},
-   {"device_strs", &devstrs_fops},
-   {"version", &version_fops}
-};
-
 static int
 sg_proc_init(void)
 {
-   int num_leaves = ARRAY_SIZE(sg_proc_leaf_arr);
-   int k;
+   struct proc_dir_entry *p;
 
-   sg_proc_sgp = proc_mkdir(sg_proc_sg_dirname, NULL);
-   if (!sg_proc_sgp)
+   p = proc_mkdir("scsi/sg", NULL);
+   if (!p)
return 1;
-   for (k = 0; k < num_leaves; ++k) {
-   const struct sg_proc_leaf *leaf = &sg_proc_leaf_arr[k];
-   umode_t mask = leaf->fops->write ? S_IRUGO | S_IWUSR : S_IRUGO;
-   proc_create(leaf->n

[PATCH 23/40] jfs: simplify procfs code

2018-04-25 Thread Christoph Hellwig
Use remove_proc_subtree to remove the whole subtree on cleanup, and
unwind the registration loop into individual calls.  Switch to use
proc_create_seq where applicable.

Signed-off-by: Christoph Hellwig 
---
 fs/jfs/jfs_debug.c| 43 ++-
 fs/jfs/jfs_debug.h| 10 +-
 fs/jfs/jfs_logmgr.c   | 14 +-
 fs/jfs/jfs_metapage.c | 14 +-
 fs/jfs/jfs_txnmgr.c   | 28 ++--
 fs/jfs/jfs_xtree.c| 14 +-
 6 files changed, 24 insertions(+), 99 deletions(-)

diff --git a/fs/jfs/jfs_debug.c b/fs/jfs/jfs_debug.c
index a70907606025..35a5b2a81ae0 100644
--- a/fs/jfs/jfs_debug.c
+++ b/fs/jfs/jfs_debug.c
@@ -29,7 +29,6 @@
 
 #ifdef PROC_FS_JFS /* see jfs_debug.h */
 
-static struct proc_dir_entry *base;
 #ifdef CONFIG_JFS_DEBUG
 static int jfs_loglevel_proc_show(struct seq_file *m, void *v)
 {
@@ -66,43 +65,29 @@ static const struct file_operations jfs_loglevel_proc_fops 
= {
 };
 #endif
 
-static struct {
-   const char  *name;
-   const struct file_operations *proc_fops;
-} Entries[] = {
-#ifdef CONFIG_JFS_STATISTICS
-   { "lmstats",&jfs_lmstats_proc_fops, },
-   { "txstats",&jfs_txstats_proc_fops, },
-   { "xtstat", &jfs_xtstat_proc_fops, },
-   { "mpstat", &jfs_mpstat_proc_fops, },
-#endif
-#ifdef CONFIG_JFS_DEBUG
-   { "TxAnchor",   &jfs_txanchor_proc_fops, },
-   { "loglevel",   &jfs_loglevel_proc_fops }
-#endif
-};
-#define NPROCENT   ARRAY_SIZE(Entries)
-
 void jfs_proc_init(void)
 {
-   int i;
+   struct proc_dir_entry *base;
 
-   if (!(base = proc_mkdir("fs/jfs", NULL)))
+   base = proc_mkdir("fs/jfs", NULL);
+   if (!base)
return;
 
-   for (i = 0; i < NPROCENT; i++)
-   proc_create(Entries[i].name, 0, base, Entries[i].proc_fops);
+#ifdef CONFIG_JFS_STATISTICS
+   proc_create_single("lmstats", 0, base, jfs_lmstats_proc_show);
+   proc_create_single("txstats", 0, base, jfs_txstats_proc_show);
+   proc_create_single("xtstat", 0, base, jfs_xtstat_proc_show);
+   proc_create_single("mpstat", 0, base, jfs_mpstat_proc_show);
+#endif
+#ifdef CONFIG_JFS_DEBUG
+   proc_create_single("TxAnchor", 0, base, jfs_txanchor_proc_show);
+   proc_create("loglevel", 0, base, &jfs_loglevel_proc_fops);
+#endif
 }
 
 void jfs_proc_clean(void)
 {
-   int i;
-
-   if (base) {
-   for (i = 0; i < NPROCENT; i++)
-   remove_proc_entry(Entries[i].name, base);
-   remove_proc_entry("fs/jfs", NULL);
-   }
+   remove_proc_subtree("fs/jfs", NULL);
 }
 
 #endif /* PROC_FS_JFS */
diff --git a/fs/jfs/jfs_debug.h b/fs/jfs/jfs_debug.h
index eafd1300a00b..0d9e35da8462 100644
--- a/fs/jfs/jfs_debug.h
+++ b/fs/jfs/jfs_debug.h
@@ -62,7 +62,7 @@ extern void jfs_proc_clean(void);
 
 extern int jfsloglevel;
 
-extern const struct file_operations jfs_txanchor_proc_fops;
+int jfs_txanchor_proc_show(struct seq_file *m, void *v);
 
 /* information message: e.g., configuration, major event */
 #define jfs_info(fmt, arg...) do { \
@@ -105,10 +105,10 @@ extern const struct file_operations 
jfs_txanchor_proc_fops;
  * --
  */
 #ifdef CONFIG_JFS_STATISTICS
-extern const struct file_operations jfs_lmstats_proc_fops;
-extern const struct file_operations jfs_txstats_proc_fops;
-extern const struct file_operations jfs_mpstat_proc_fops;
-extern const struct file_operations jfs_xtstat_proc_fops;
+int jfs_lmstats_proc_show(struct seq_file *m, void *v);
+int jfs_txstats_proc_show(struct seq_file *m, void *v);
+int jfs_mpstat_proc_show(struct seq_file *m, void *v);
+int jfs_xtstat_proc_show(struct seq_file *m, void *v);
 
 #defineINCREMENT(x)((x)++)
 #defineDECREMENT(x)((x)--)
diff --git a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c
index 0e5d412c0b01..6b68df395892 100644
--- a/fs/jfs/jfs_logmgr.c
+++ b/fs/jfs/jfs_logmgr.c
@@ -2493,7 +2493,7 @@ int lmLogFormat(struct jfs_log *log, s64 logAddress, int 
logSize)
 }
 
 #ifdef CONFIG_JFS_STATISTICS
-static int jfs_lmstats_proc_show(struct seq_file *m, void *v)
+int jfs_lmstats_proc_show(struct seq_file *m, void *v)
 {
seq_printf(m,
   "JFS Logmgr stats\n"
@@ -2510,16 +2510,4 @@ static int jfs_lmstats_proc_show(struct seq_file *m, 
void *v)
   lmStat.partial_page);
return 0;
 }
-
-static int jfs_lmstats_proc_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, jfs_lmstats_proc_show, NULL);
-}
-
-const struct file_operations jfs_lmstats_proc_fops = {
-   .open   = jfs_lmstats_proc_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
 #endif /* CONFIG_JFS_STATISTICS */
diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
index 1a3b0cc22ad3..fa2c6824c7f2 100644
--- a/fs/jfs/jfs_metapage.c
+++ b/fs/j

[PATCH 29/40] hostap: switch to proc_create_{seq,single}_data

2018-04-25 Thread Christoph Hellwig
And use proc private data directly instead of doing a detour
through seq->private.

Signed-off-by: Christoph Hellwig 
---
 .../net/wireless/intersil/hostap/hostap_ap.c  |  70 ++---
 .../net/wireless/intersil/hostap/hostap_hw.c  |  17 +--
 .../wireless/intersil/hostap/hostap_proc.c| 143 +++---
 3 files changed, 39 insertions(+), 191 deletions(-)

diff --git a/drivers/net/wireless/intersil/hostap/hostap_ap.c 
b/drivers/net/wireless/intersil/hostap/hostap_ap.c
index 4f76f81dd3af..d1884b8913e7 100644
--- a/drivers/net/wireless/intersil/hostap/hostap_ap.c
+++ b/drivers/net/wireless/intersil/hostap/hostap_ap.c
@@ -69,7 +69,7 @@ static void prism2_send_mgmt(struct net_device *dev,
 #ifndef PRISM2_NO_PROCFS_DEBUG
 static int ap_debug_proc_show(struct seq_file *m, void *v)
 {
-   struct ap_data *ap = m->private;
+   struct ap_data *ap = PDE_DATA(file_inode(m->file));
 
seq_printf(m, "BridgedUnicastFrames=%u\n", ap->bridged_unicast);
seq_printf(m, "BridgedMulticastFrames=%u\n", ap->bridged_multicast);
@@ -81,18 +81,6 @@ static int ap_debug_proc_show(struct seq_file *m, void *v)
seq_printf(m, "tx_drop_nonassoc=%u\n", ap->tx_drop_nonassoc);
return 0;
 }
-
-static int ap_debug_proc_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, ap_debug_proc_show, PDE_DATA(inode));
-}
-
-static const struct file_operations ap_debug_proc_fops = {
-   .open   = ap_debug_proc_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
 #endif /* PRISM2_NO_PROCFS_DEBUG */
 
 
@@ -333,7 +321,7 @@ void hostap_deauth_all_stas(struct net_device *dev, struct 
ap_data *ap,
 
 static int ap_control_proc_show(struct seq_file *m, void *v)
 {
-   struct ap_data *ap = m->private;
+   struct ap_data *ap = PDE_DATA(file_inode(m->file));
char *policy_txt;
struct mac_entry *entry;
 
@@ -365,20 +353,20 @@ static int ap_control_proc_show(struct seq_file *m, void 
*v)
 
 static void *ap_control_proc_start(struct seq_file *m, loff_t *_pos)
 {
-   struct ap_data *ap = m->private;
+   struct ap_data *ap = PDE_DATA(file_inode(m->file));
spin_lock_bh(&ap->mac_restrictions.lock);
return seq_list_start_head(&ap->mac_restrictions.mac_list, *_pos);
 }
 
 static void *ap_control_proc_next(struct seq_file *m, void *v, loff_t *_pos)
 {
-   struct ap_data *ap = m->private;
+   struct ap_data *ap = PDE_DATA(file_inode(m->file));
return seq_list_next(v, &ap->mac_restrictions.mac_list, _pos);
 }
 
 static void ap_control_proc_stop(struct seq_file *m, void *v)
 {
-   struct ap_data *ap = m->private;
+   struct ap_data *ap = PDE_DATA(file_inode(m->file));
spin_unlock_bh(&ap->mac_restrictions.lock);
 }
 
@@ -389,24 +377,6 @@ static const struct seq_operations ap_control_proc_seqops 
= {
.show   = ap_control_proc_show,
 };
 
-static int ap_control_proc_open(struct inode *inode, struct file *file)
-{
-   int ret = seq_open(file, &ap_control_proc_seqops);
-   if (ret == 0) {
-   struct seq_file *m = file->private_data;
-   m->private = PDE_DATA(inode);
-   }
-   return ret;
-}
-
-static const struct file_operations ap_control_proc_fops = {
-   .open   = ap_control_proc_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= seq_release,
-};
-
-
 int ap_control_add_mac(struct mac_restrictions *mac_restrictions, u8 *mac)
 {
struct mac_entry *entry;
@@ -585,20 +555,20 @@ static int prism2_ap_proc_show(struct seq_file *m, void 
*v)
 
 static void *prism2_ap_proc_start(struct seq_file *m, loff_t *_pos)
 {
-   struct ap_data *ap = m->private;
+   struct ap_data *ap = PDE_DATA(file_inode(m->file));
spin_lock_bh(&ap->sta_table_lock);
return seq_list_start_head(&ap->sta_list, *_pos);
 }
 
 static void *prism2_ap_proc_next(struct seq_file *m, void *v, loff_t *_pos)
 {
-   struct ap_data *ap = m->private;
+   struct ap_data *ap = PDE_DATA(file_inode(m->file));
return seq_list_next(v, &ap->sta_list, _pos);
 }
 
 static void prism2_ap_proc_stop(struct seq_file *m, void *v)
 {
-   struct ap_data *ap = m->private;
+   struct ap_data *ap = PDE_DATA(file_inode(m->file));
spin_unlock_bh(&ap->sta_table_lock);
 }
 
@@ -608,23 +578,6 @@ static const struct seq_operations prism2_ap_proc_seqops = 
{
.stop   = prism2_ap_proc_stop,
.show   = prism2_ap_proc_show,
 };
-
-static int prism2_ap_proc_open(struct inode *inode, struct file *file)
-{
-   int ret = seq_open(file, &prism2_ap_proc_seqops);
-   if (ret == 0) {
-   struct seq_file *m = file->private_data;
-   m->private = PDE_DATA(inode);
-   }
-   return ret;
-}
-
-static const struct file_operations prism2_ap_proc_fops = {
-   .open   = prism2_ap_proc_open,
-   

[PATCH 24/40] staging/rtl8192u: simplify procfs code

2018-04-25 Thread Christoph Hellwig
Unwind the registration loop into individual calls.  Switch to use
proc_create_single where applicable.

Signed-off-by: Christoph Hellwig 
---
 drivers/staging/rtl8192u/r8192U_core.c | 67 ++
 1 file changed, 14 insertions(+), 53 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c 
b/drivers/staging/rtl8192u/r8192U_core.c
index d607c59761cf..7a0dbc0fa18e 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -646,64 +646,25 @@ static void rtl8192_proc_module_init(void)
rtl8192_proc = proc_mkdir(RTL819xU_MODULE_NAME, init_net.proc_net);
 }
 
-/*
- * seq_file wrappers for procfile show routines.
- */
-static int rtl8192_proc_open(struct inode *inode, struct file *file)
-{
-   struct net_device *dev = proc_get_parent_data(inode);
-   int (*show)(struct seq_file *, void *) = PDE_DATA(inode);
-
-   return single_open(file, show, dev);
-}
-
-static const struct file_operations rtl8192_proc_fops = {
-   .open   = rtl8192_proc_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
-
-/*
- * Table of proc files we need to create.
- */
-struct rtl8192_proc_file {
-   char name[12];
-   int (*show)(struct seq_file *, void *);
-};
-
-static const struct rtl8192_proc_file rtl8192_proc_files[] = {
-   { "stats-rx",   &proc_get_stats_rx },
-   { "stats-tx",   &proc_get_stats_tx },
-   { "stats-ap",   &proc_get_stats_ap },
-   { "registers",  &proc_get_registers },
-   { "" }
-};
-
 static void rtl8192_proc_init_one(struct net_device *dev)
 {
-   const struct rtl8192_proc_file *f;
struct proc_dir_entry *dir;
 
-   if (rtl8192_proc) {
-   dir = proc_mkdir_data(dev->name, 0, rtl8192_proc, dev);
-   if (!dir) {
-   RT_TRACE(COMP_ERR,
-"Unable to initialize /proc/net/rtl8192/%s\n",
-dev->name);
-   return;
-   }
+   if (!rtl8192_proc)
+   return;
 
-   for (f = rtl8192_proc_files; f->name[0]; f++) {
-   if (!proc_create_data(f->name, S_IFREG | S_IRUGO, dir,
- &rtl8192_proc_fops, f->show)) {
-   RT_TRACE(COMP_ERR,
-"Unable to initialize 
/proc/net/rtl8192/%s/%s\n",
-dev->name, f->name);
-   return;
-   }
-   }
-   }
+   dir = proc_mkdir_data(dev->name, 0, rtl8192_proc, dev);
+   if (!dir)
+   return;
+
+   proc_create_single("stats-rx", S_IFREG | S_IRUGO, dir,
+   proc_get_stats_rx);
+   proc_create_single("stats-tx", S_IFREG | S_IRUGO, dir,
+   proc_get_stats_tx);
+   proc_create_single("stats-ap", S_IFREG | S_IRUGO, dir,
+   proc_get_stats_ap);
+   proc_create_single("registers", S_IFREG | S_IRUGO, dir,
+   proc_get_registers);
 }
 
 static void rtl8192_proc_remove_one(struct net_device *dev)
-- 
2.17.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 26/40] drbd: switch to proc_create_single

2018-04-25 Thread Christoph Hellwig
And stop messing with try_module_get on THIS_MODULE, which doesn't make
any sense here.

Signed-off-by: Christoph Hellwig 
---
 drivers/block/drbd/drbd_int.h  |  2 +-
 drivers/block/drbd/drbd_main.c |  3 ++-
 drivers/block/drbd/drbd_proc.c | 34 +-
 3 files changed, 4 insertions(+), 35 deletions(-)

diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
index 06ecee1b528e..461ddec04e7c 100644
--- a/drivers/block/drbd/drbd_int.h
+++ b/drivers/block/drbd/drbd_int.h
@@ -1643,7 +1643,7 @@ void drbd_bump_write_ordering(struct drbd_resource 
*resource, struct drbd_backin
 
 /* drbd_proc.c */
 extern struct proc_dir_entry *drbd_proc;
-extern const struct file_operations drbd_proc_fops;
+int drbd_seq_show(struct seq_file *seq, void *v);
 
 /* drbd_actlog.c */
 extern bool drbd_al_begin_io_prepare(struct drbd_device *device, struct 
drbd_interval *i);
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
index 185f1ef00a7c..c2d154faac02 100644
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -3010,7 +3010,8 @@ static int __init drbd_init(void)
goto fail;
 
err = -ENOMEM;
-   drbd_proc = proc_create_data("drbd", S_IFREG | S_IRUGO , NULL, 
&drbd_proc_fops, NULL);
+   drbd_proc = proc_create_single("drbd", S_IFREG | S_IRUGO , NULL,
+   drbd_seq_show);
if (!drbd_proc) {
pr_err("unable to register proc file\n");
goto fail;
diff --git a/drivers/block/drbd/drbd_proc.c b/drivers/block/drbd/drbd_proc.c
index 582caeb0de86..74ef29247bb5 100644
--- a/drivers/block/drbd/drbd_proc.c
+++ b/drivers/block/drbd/drbd_proc.c
@@ -33,18 +33,7 @@
 #include 
 #include "drbd_int.h"
 
-static int drbd_proc_open(struct inode *inode, struct file *file);
-static int drbd_proc_release(struct inode *inode, struct file *file);
-
-
 struct proc_dir_entry *drbd_proc;
-const struct file_operations drbd_proc_fops = {
-   .owner  = THIS_MODULE,
-   .open   = drbd_proc_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= drbd_proc_release,
-};
 
 static void seq_printf_with_thousands_grouping(struct seq_file *seq, long v)
 {
@@ -235,7 +224,7 @@ static void drbd_syncer_progress(struct drbd_device 
*device, struct seq_file *se
}
 }
 
-static int drbd_seq_show(struct seq_file *seq, void *v)
+int drbd_seq_show(struct seq_file *seq, void *v)
 {
int i, prev_i = -1;
const char *sn;
@@ -345,24 +334,3 @@ static int drbd_seq_show(struct seq_file *seq, void *v)
 
return 0;
 }
-
-static int drbd_proc_open(struct inode *inode, struct file *file)
-{
-   int err;
-
-   if (try_module_get(THIS_MODULE)) {
-   err = single_open(file, drbd_seq_show, NULL);
-   if (err)
-   module_put(THIS_MODULE);
-   return err;
-   }
-   return -ENODEV;
-}
-
-static int drbd_proc_release(struct inode *inode, struct file *file)
-{
-   module_put(THIS_MODULE);
-   return single_release(inode, file);
-}
-
-/* PROC FS stuff end */
-- 
2.17.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 25/40] resource: switch to proc_create_seq_data

2018-04-25 Thread Christoph Hellwig
And use the root resource directly from the proc private data.

Signed-off-by: Christoph Hellwig 
---
 kernel/resource.c | 43 +--
 1 file changed, 5 insertions(+), 38 deletions(-)

diff --git a/kernel/resource.c b/kernel/resource.c
index 2af6c03858b9..b589dda910b3 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -87,7 +87,7 @@ enum { MAX_IORES_LEVEL = 5 };
 static void *r_start(struct seq_file *m, loff_t *pos)
__acquires(resource_lock)
 {
-   struct resource *p = m->private;
+   struct resource *p = PDE_DATA(file_inode(m->file));
loff_t l = 0;
read_lock(&resource_lock);
for (p = p->child; p && l < *pos; p = r_next(m, p, &l))
@@ -103,7 +103,7 @@ static void r_stop(struct seq_file *m, void *v)
 
 static int r_show(struct seq_file *m, void *v)
 {
-   struct resource *root = m->private;
+   struct resource *root = PDE_DATA(file_inode(m->file));
struct resource *r = v, *p;
unsigned long long start, end;
int width = root->end < 0x1 ? 4 : 8;
@@ -135,44 +135,11 @@ static const struct seq_operations resource_op = {
.show   = r_show,
 };
 
-static int ioports_open(struct inode *inode, struct file *file)
-{
-   int res = seq_open(file, &resource_op);
-   if (!res) {
-   struct seq_file *m = file->private_data;
-   m->private = &ioport_resource;
-   }
-   return res;
-}
-
-static int iomem_open(struct inode *inode, struct file *file)
-{
-   int res = seq_open(file, &resource_op);
-   if (!res) {
-   struct seq_file *m = file->private_data;
-   m->private = &iomem_resource;
-   }
-   return res;
-}
-
-static const struct file_operations proc_ioports_operations = {
-   .open   = ioports_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= seq_release,
-};
-
-static const struct file_operations proc_iomem_operations = {
-   .open   = iomem_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= seq_release,
-};
-
 static int __init ioresources_init(void)
 {
-   proc_create("ioports", 0, NULL, &proc_ioports_operations);
-   proc_create("iomem", 0, NULL, &proc_iomem_operations);
+   proc_create_seq_data("ioports", 0, NULL, &resource_op,
+   &ioport_resource);
+   proc_create_seq_data("iomem", 0, NULL, &resource_op, &iomem_resource);
return 0;
 }
 __initcall(ioresources_init);
-- 
2.17.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 22/40] ext4: simplify procfs code

2018-04-25 Thread Christoph Hellwig
Use remove_proc_subtree to remove the whole subtree on cleanup, and
unwind the registration loop into individual calls.  Switch to use
proc_create_seq where applicable.

Signed-off-by: Christoph Hellwig 
---
 fs/ext4/ext4.h|  2 +-
 fs/ext4/mballoc.c | 29 
 fs/ext4/sysfs.c   | 49 +--
 3 files changed, 14 insertions(+), 66 deletions(-)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index a42e71203e53..229ea4da6785 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -2390,7 +2390,7 @@ extern int ext4_init_inode_table(struct super_block *sb,
 extern void ext4_end_bitmap_read(struct buffer_head *bh, int uptodate);
 
 /* mballoc.c */
-extern const struct file_operations ext4_seq_mb_groups_fops;
+extern const struct seq_operations ext4_mb_seq_groups_ops;
 extern long ext4_mb_stats;
 extern long ext4_mb_max_to_scan;
 extern int ext4_mb_init(struct super_block *);
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 769a62708b1c..6884e81c1465 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2254,7 +2254,7 @@ ext4_mb_regular_allocator(struct ext4_allocation_context 
*ac)
 
 static void *ext4_mb_seq_groups_start(struct seq_file *seq, loff_t *pos)
 {
-   struct super_block *sb = seq->private;
+   struct super_block *sb = PDE_DATA(file_inode(seq->file));
ext4_group_t group;
 
if (*pos < 0 || *pos >= ext4_get_groups_count(sb))
@@ -2265,7 +2265,7 @@ static void *ext4_mb_seq_groups_start(struct seq_file 
*seq, loff_t *pos)
 
 static void *ext4_mb_seq_groups_next(struct seq_file *seq, void *v, loff_t 
*pos)
 {
-   struct super_block *sb = seq->private;
+   struct super_block *sb = PDE_DATA(file_inode(seq->file));
ext4_group_t group;
 
++*pos;
@@ -2277,7 +2277,7 @@ static void *ext4_mb_seq_groups_next(struct seq_file 
*seq, void *v, loff_t *pos)
 
 static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v)
 {
-   struct super_block *sb = seq->private;
+   struct super_block *sb = PDE_DATA(file_inode(seq->file));
ext4_group_t group = (ext4_group_t) ((unsigned long) v);
int i;
int err, buddy_loaded = 0;
@@ -2330,34 +2330,13 @@ static void ext4_mb_seq_groups_stop(struct seq_file 
*seq, void *v)
 {
 }
 
-static const struct seq_operations ext4_mb_seq_groups_ops = {
+const struct seq_operations ext4_mb_seq_groups_ops = {
.start  = ext4_mb_seq_groups_start,
.next   = ext4_mb_seq_groups_next,
.stop   = ext4_mb_seq_groups_stop,
.show   = ext4_mb_seq_groups_show,
 };
 
-static int ext4_mb_seq_groups_open(struct inode *inode, struct file *file)
-{
-   struct super_block *sb = PDE_DATA(inode);
-   int rc;
-
-   rc = seq_open(file, &ext4_mb_seq_groups_ops);
-   if (rc == 0) {
-   struct seq_file *m = file->private_data;
-   m->private = sb;
-   }
-   return rc;
-
-}
-
-const struct file_operations ext4_seq_mb_groups_fops = {
-   .open   = ext4_mb_seq_groups_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= seq_release,
-};
-
 static struct kmem_cache *get_groupinfo_cache(int blocksize_bits)
 {
int cache_index = blocksize_bits - EXT4_MIN_BLOCK_LOG_SIZE;
diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c
index 9ebd26c957c2..f34da0bb8f17 100644
--- a/fs/ext4/sysfs.c
+++ b/fs/ext4/sysfs.c
@@ -346,39 +346,9 @@ static struct kobject *ext4_root;
 
 static struct kobject *ext4_feat;
 
-#define PROC_FILE_SHOW_DEFN(name) \
-static int name##_open(struct inode *inode, struct file *file) \
-{ \
-   return single_open(file, ext4_seq_##name##_show, PDE_DATA(inode)); \
-} \
-\
-static const struct file_operations ext4_seq_##name##_fops = { \
-   .open   = name##_open, \
-   .read   = seq_read, \
-   .llseek = seq_lseek, \
-   .release= single_release, \
-}
-
-#define PROC_FILE_LIST(name) \
-   { __stringify(name), &ext4_seq_##name##_fops }
-
-PROC_FILE_SHOW_DEFN(es_shrinker_info);
-PROC_FILE_SHOW_DEFN(options);
-
-static const struct ext4_proc_files {
-   const char *name;
-   const struct file_operations *fops;
-} proc_files[] = {
-   PROC_FILE_LIST(options),
-   PROC_FILE_LIST(es_shrinker_info),
-   PROC_FILE_LIST(mb_groups),
-   { NULL, NULL },
-};
-
 int ext4_register_sysfs(struct super_block *sb)
 {
struct ext4_sb_info *sbi = EXT4_SB(sb);
-   const struct ext4_proc_files *p;
int err;
 
init_completion(&sbi->s_kobj_unregister);
@@ -392,11 +362,14 @@ int ext4_register_sysfs(struct super_block *sb)
 
if (ext4_proc_root)
sbi->s_proc = proc_mkdir(sb->s_id, ext4_proc_root);
-
if (sbi->s_proc) {
-   for (p = proc_files; p->name; p++)
-   proc_create_data(p->name, S_IRUGO, sbi->s_proc,
-p->fops, sb);
+   proc_cre

[PATCH 30/40] neigh: switch to proc_create_seq_data

2018-04-25 Thread Christoph Hellwig
And use proc private data directly instead of doing a detour
through seq->private.

Signed-off-by: Christoph Hellwig 
---
 net/core/neighbour.c | 31 ++-
 1 file changed, 6 insertions(+), 25 deletions(-)

diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index ce519861be59..1fb43bff417d 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -59,7 +59,7 @@ static int pneigh_ifdown_and_unlock(struct neigh_table *tbl,
struct net_device *dev);
 
 #ifdef CONFIG_PROC_FS
-static const struct file_operations neigh_stat_seq_fops;
+static const struct seq_operations neigh_stat_seq_ops;
 #endif
 
 /*
@@ -1558,8 +1558,8 @@ void neigh_table_init(int index, struct neigh_table *tbl)
panic("cannot create neighbour cache statistics");
 
 #ifdef CONFIG_PROC_FS
-   if (!proc_create_data(tbl->id, 0, init_net.proc_net_stat,
- &neigh_stat_seq_fops, tbl))
+   if (!proc_create_seq_data(tbl->id, 0, init_net.proc_net_stat,
+ &neigh_stat_seq_ops, tbl))
panic("cannot create neighbour proc dir entry");
 #endif
 
@@ -2786,7 +2786,7 @@ EXPORT_SYMBOL(neigh_seq_stop);
 
 static void *neigh_stat_seq_start(struct seq_file *seq, loff_t *pos)
 {
-   struct neigh_table *tbl = seq->private;
+   struct neigh_table *tbl = PDE_DATA(file_inode(seq->file));
int cpu;
 
if (*pos == 0)
@@ -2803,7 +2803,7 @@ static void *neigh_stat_seq_start(struct seq_file *seq, 
loff_t *pos)
 
 static void *neigh_stat_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 {
-   struct neigh_table *tbl = seq->private;
+   struct neigh_table *tbl = PDE_DATA(file_inode(seq->file));
int cpu;
 
for (cpu = *pos; cpu < nr_cpu_ids; ++cpu) {
@@ -2822,7 +2822,7 @@ static void neigh_stat_seq_stop(struct seq_file *seq, 
void *v)
 
 static int neigh_stat_seq_show(struct seq_file *seq, void *v)
 {
-   struct neigh_table *tbl = seq->private;
+   struct neigh_table *tbl = PDE_DATA(file_inode(seq->file));
struct neigh_statistics *st = v;
 
if (v == SEQ_START_TOKEN) {
@@ -2861,25 +2861,6 @@ static const struct seq_operations neigh_stat_seq_ops = {
.stop   = neigh_stat_seq_stop,
.show   = neigh_stat_seq_show,
 };
-
-static int neigh_stat_seq_open(struct inode *inode, struct file *file)
-{
-   int ret = seq_open(file, &neigh_stat_seq_ops);
-
-   if (!ret) {
-   struct seq_file *sf = file->private_data;
-   sf->private = PDE_DATA(inode);
-   }
-   return ret;
-};
-
-static const struct file_operations neigh_stat_seq_fops = {
-   .open= neigh_stat_seq_open,
-   .read= seq_read,
-   .llseek  = seq_lseek,
-   .release = seq_release,
-};
-
 #endif /* CONFIG_PROC_FS */
 
 static inline size_t neigh_nlmsg_size(void)
-- 
2.17.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 27/40] rtc/proc: switch to proc_create_single_data

2018-04-25 Thread Christoph Hellwig
And stop trying to get a reference on the submodule, procfs code deals
with release after and unloaded module and thus removed proc entry.

Signed-off-by: Christoph Hellwig 
---
 drivers/rtc/rtc-proc.c | 33 ++---
 1 file changed, 2 insertions(+), 31 deletions(-)

diff --git a/drivers/rtc/rtc-proc.c b/drivers/rtc/rtc-proc.c
index 31e7e23cc5be..a9dd9218fae2 100644
--- a/drivers/rtc/rtc-proc.c
+++ b/drivers/rtc/rtc-proc.c
@@ -107,40 +107,11 @@ static int rtc_proc_show(struct seq_file *seq, void 
*offset)
return 0;
 }
 
-static int rtc_proc_open(struct inode *inode, struct file *file)
-{
-   int ret;
-   struct rtc_device *rtc = PDE_DATA(inode);
-
-   if (!try_module_get(rtc->owner))
-   return -ENODEV;
-
-   ret = single_open(file, rtc_proc_show, rtc);
-   if (ret)
-   module_put(rtc->owner);
-   return ret;
-}
-
-static int rtc_proc_release(struct inode *inode, struct file *file)
-{
-   int res = single_release(inode, file);
-   struct rtc_device *rtc = PDE_DATA(inode);
-
-   module_put(rtc->owner);
-   return res;
-}
-
-static const struct file_operations rtc_proc_fops = {
-   .open   = rtc_proc_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= rtc_proc_release,
-};
-
 void rtc_proc_add_device(struct rtc_device *rtc)
 {
if (is_rtc_hctosys(rtc))
-   proc_create_data("driver/rtc", 0, NULL, &rtc_proc_fops, rtc);
+   proc_create_single_data("driver/rtc", 0, NULL, rtc_proc_show,
+   rtc);
 }
 
 void rtc_proc_del_device(struct rtc_device *rtc)
-- 
2.17.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 15/40] proc: introduce proc_create_net{,_data}

2018-04-25 Thread Christoph Hellwig
Variants of proc_create{,_data} that directly take a struct seq_operations
and deal with network namespaces in ->open and ->release.  All callers of
proc_create + seq_open_net converted over, and seq_{open,release}_net are
removed entirely.

Signed-off-by: Christoph Hellwig 
---
 drivers/net/ppp/pppoe.c | 18 +---
 fs/nfs/client.c | 43 ++---
 fs/proc/proc_net.c  | 61 -
 include/linux/proc_fs.h |  9 
 include/linux/seq_file_net.h|  3 --
 include/net/ip6_fib.h   | 10 +++-
 include/net/phonet/pn_dev.h |  4 +-
 include/net/udp.h   |  4 +-
 net/8021q/vlanproc.c| 18 ++--
 net/atm/clip.c  | 17 +--
 net/core/net-procfs.c   | 49 +++-
 net/core/sock.c | 16 +--
 net/decnet/dn_neigh.c   | 18 +---
 net/ipv4/arp.c  | 17 ++-
 net/ipv4/fib_trie.c | 32 ++---
 net/ipv4/igmp.c | 33 ++---
 net/ipv4/ipmr.c | 32 ++---
 net/ipv4/ping.c | 16 +--
 net/ipv4/raw.c  | 17 +--
 net/ipv4/tcp_ipv4.c | 17 +--
 net/ipv4/udp.c  | 21 ++---
 net/ipv4/udplite.c  |  4 +-
 net/ipv6/addrconf.c | 16 +--
 net/ipv6/anycast.c  | 16 +--
 net/ipv6/ip6_fib.c  | 18 +---
 net/ipv6/ip6_flowlabel.c| 17 +--
 net/ipv6/ip6mr.c| 32 ++---
 net/ipv6/mcast.c| 34 ++
 net/ipv6/ping.c | 16 +--
 net/ipv6/raw.c  | 17 +--
 net/ipv6/route.c| 11 +
 net/ipv6/tcp_ipv6.c | 17 +--
 net/ipv6/udp.c  | 21 ++---
 net/ipv6/udplite.c  |  5 +-
 net/kcm/kcmproc.c   | 16 +--
 net/key/af_key.c| 16 +--
 net/l2tp/l2tp_ppp.c | 22 +
 net/netfilter/ipvs/ip_vs_app.c  | 16 +--
 net/netfilter/ipvs/ip_vs_conn.c | 35 ++
 net/netfilter/ipvs/ip_vs_ctl.c  | 16 +--
 net/netfilter/nf_conntrack_expect.c | 17 +--
 net/netfilter/nf_conntrack_standalone.c | 33 ++---
 net/netfilter/nf_log.c  | 19 +---
 net/netfilter/nf_synproxy_core.c| 17 +--
 net/netfilter/nfnetlink_log.c   | 18 +---
 net/netfilter/nfnetlink_queue.c | 18 +---
 net/netfilter/x_tables.c| 18 ++--
 net/netlink/af_netlink.c| 18 +---
 net/packet/af_packet.c  | 17 +--
 net/phonet/pn_dev.c |  6 ++-
 net/phonet/socket.c | 30 +---
 net/rxrpc/ar-internal.h |  4 +-
 net/rxrpc/net_ns.c  |  7 ++-
 net/rxrpc/proc.c| 31 +
 net/sctp/proc.c | 54 +++---
 net/unix/af_unix.c  | 17 +--
 net/wireless/wext-proc.c| 17 +--
 57 files changed, 202 insertions(+), 939 deletions(-)

diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c
index 1483bc7b01e1..714bb605a140 100644
--- a/drivers/net/ppp/pppoe.c
+++ b/drivers/net/ppp/pppoe.c
@@ -1092,21 +1092,6 @@ static const struct seq_operations pppoe_seq_ops = {
.stop   = pppoe_seq_stop,
.show   = pppoe_seq_show,
 };
-
-static int pppoe_seq_open(struct inode *inode, struct file *file)
-{
-   return seq_open_net(inode, file, &pppoe_seq_ops,
-   sizeof(struct seq_net_private));
-}
-
-static const struct file_operations pppoe_seq_fops = {
-   .owner  = THIS_MODULE,
-   .open   = pppoe_seq_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= seq_release_net,
-};
-
 #endif /* CONFIG_PROC_FS */
 
 static const struct proto_ops pppoe_ops = {
@@ -1142,7 +1127,8 @@ static __net_init int pppoe_init_net(struct net *net)
 
rwlock_init(&pn->hash_lock);
 
-   pde = proc_create("pppoe", 0444, net->proc_net, &pppoe_seq_fops);
+   pde = proc_create_net("pppoe", 0444, net->proc_net,
+   &pppoe_seq_ops, sizeof(struct seq_net_private));
 #ifdef CONFIG_PROC_FS
if (!pde)
return -ENOMEM;
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index b9129e2befea..bbc91d7ca1bd 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -1067,7 +1067,6 @@ void nfs_clients_init(struct net *net)
 }
 
 #ifdef CONFIG_PROC_FS
-static int nfs_server_list_open(st

[PATCH 28/40] bonding: switch to proc_create_seq_data

2018-04-25 Thread Christoph Hellwig
And use proc private data directly instead of doing a detour
through seq->private.

Signed-off-by: Christoph Hellwig 
---
 drivers/net/bonding/bond_procfs.c | 36 ++-
 1 file changed, 6 insertions(+), 30 deletions(-)

diff --git a/drivers/net/bonding/bond_procfs.c 
b/drivers/net/bonding/bond_procfs.c
index 01059f1a7bca..9f7d83e827c3 100644
--- a/drivers/net/bonding/bond_procfs.c
+++ b/drivers/net/bonding/bond_procfs.c
@@ -10,7 +10,7 @@
 static void *bond_info_seq_start(struct seq_file *seq, loff_t *pos)
__acquires(RCU)
 {
-   struct bonding *bond = seq->private;
+   struct bonding *bond = PDE_DATA(file_inode(seq->file));
struct list_head *iter;
struct slave *slave;
loff_t off = 0;
@@ -29,7 +29,7 @@ static void *bond_info_seq_start(struct seq_file *seq, loff_t 
*pos)
 
 static void *bond_info_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 {
-   struct bonding *bond = seq->private;
+   struct bonding *bond = PDE_DATA(file_inode(seq->file));
struct list_head *iter;
struct slave *slave;
bool found = false;
@@ -56,7 +56,7 @@ static void bond_info_seq_stop(struct seq_file *seq, void *v)
 
 static void bond_info_show_master(struct seq_file *seq)
 {
-   struct bonding *bond = seq->private;
+   struct bonding *bond = PDE_DATA(file_inode(seq->file));
const struct bond_opt_value *optval;
struct slave *curr, *primary;
int i;
@@ -167,7 +167,7 @@ static void bond_info_show_master(struct seq_file *seq)
 static void bond_info_show_slave(struct seq_file *seq,
 const struct slave *slave)
 {
-   struct bonding *bond = seq->private;
+   struct bonding *bond = PDE_DATA(file_inode(seq->file));
 
seq_printf(seq, "\nSlave Interface: %s\n", slave->dev->name);
seq_printf(seq, "MII Status: %s\n", 
bond_slave_link_status(slave->link));
@@ -257,38 +257,14 @@ static const struct seq_operations bond_info_seq_ops = {
.show  = bond_info_seq_show,
 };
 
-static int bond_info_open(struct inode *inode, struct file *file)
-{
-   struct seq_file *seq;
-   int res;
-
-   res = seq_open(file, &bond_info_seq_ops);
-   if (!res) {
-   /* recover the pointer buried in proc_dir_entry data */
-   seq = file->private_data;
-   seq->private = PDE_DATA(inode);
-   }
-
-   return res;
-}
-
-static const struct file_operations bond_info_fops = {
-   .owner   = THIS_MODULE,
-   .open= bond_info_open,
-   .read= seq_read,
-   .llseek  = seq_lseek,
-   .release = seq_release,
-};
-
 void bond_create_proc_entry(struct bonding *bond)
 {
struct net_device *bond_dev = bond->dev;
struct bond_net *bn = net_generic(dev_net(bond_dev), bond_net_id);
 
if (bn->proc_dir) {
-   bond->proc_entry = proc_create_data(bond_dev->name,
-   0444, bn->proc_dir,
-   &bond_info_fops, bond);
+   bond->proc_entry = proc_create_seq_data(bond_dev->name, 0444,
+   bn->proc_dir, &bond_info_seq_ops, bond);
if (bond->proc_entry == NULL)
netdev_warn(bond_dev, "Cannot create /proc/net/%s/%s\n",
DRV_NAME, bond_dev->name);
-- 
2.17.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 32/40] netfilter/x_tables: switch to proc_create_seq_private

2018-04-25 Thread Christoph Hellwig
And remove proc boilerplate code.

Signed-off-by: Christoph Hellwig 
---
 net/netfilter/x_tables.c | 42 ++--
 1 file changed, 6 insertions(+), 36 deletions(-)

diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index 344dd01a5027..0e314f95a4a3 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -1648,22 +1648,6 @@ static const struct seq_operations xt_match_seq_ops = {
.show   = xt_match_seq_show,
 };
 
-static int xt_match_open(struct inode *inode, struct file *file)
-{
-   struct nf_mttg_trav *trav;
-   trav = __seq_open_private(file, &xt_match_seq_ops, sizeof(*trav));
-   if (!trav)
-   return -ENOMEM;
-   return 0;
-}
-
-static const struct file_operations xt_match_ops = {
-   .open= xt_match_open,
-   .read= seq_read,
-   .llseek  = seq_lseek,
-   .release = seq_release_private,
-};
-
 static void *xt_target_seq_start(struct seq_file *seq, loff_t *pos)
 {
return xt_mttg_seq_start(seq, pos, true);
@@ -1698,22 +1682,6 @@ static const struct seq_operations xt_target_seq_ops = {
.show   = xt_target_seq_show,
 };
 
-static int xt_target_open(struct inode *inode, struct file *file)
-{
-   struct nf_mttg_trav *trav;
-   trav = __seq_open_private(file, &xt_target_seq_ops, sizeof(*trav));
-   if (!trav)
-   return -ENOMEM;
-   return 0;
-}
-
-static const struct file_operations xt_target_ops = {
-   .open= xt_target_open,
-   .read= seq_read,
-   .llseek  = seq_lseek,
-   .release = seq_release_private,
-};
-
 #define FORMAT_TABLES  "_tables_names"
 #defineFORMAT_MATCHES  "_tables_matches"
 #define FORMAT_TARGETS "_tables_targets"
@@ -1787,8 +1755,9 @@ int xt_proto_init(struct net *net, u_int8_t af)
 
strlcpy(buf, xt_prefix[af], sizeof(buf));
strlcat(buf, FORMAT_MATCHES, sizeof(buf));
-   proc = proc_create_data(buf, 0440, net->proc_net, &xt_match_ops,
-   (void *)(unsigned long)af);
+   proc = proc_create_seq_private(buf, 0440, net->proc_net,
+   &xt_match_seq_ops, sizeof(struct nf_mttg_trav),
+   (void *)(unsigned long)af);
if (!proc)
goto out_remove_tables;
if (uid_valid(root_uid) && gid_valid(root_gid))
@@ -1796,8 +1765,9 @@ int xt_proto_init(struct net *net, u_int8_t af)
 
strlcpy(buf, xt_prefix[af], sizeof(buf));
strlcat(buf, FORMAT_TARGETS, sizeof(buf));
-   proc = proc_create_data(buf, 0440, net->proc_net, &xt_target_ops,
-   (void *)(unsigned long)af);
+   proc = proc_create_seq_private(buf, 0440, net->proc_net,
+&xt_target_seq_ops, sizeof(struct nf_mttg_trav),
+(void *)(unsigned long)af);
if (!proc)
goto out_remove_matches;
if (uid_valid(root_uid) && gid_valid(root_gid))
-- 
2.17.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 31/40] netfilter/xt_hashlimit: switch to proc_create_{seq, single}_data

2018-04-25 Thread Christoph Hellwig
And use proc private data directly instead of doing a detour
through seq->private.

Signed-off-by: Christoph Hellwig 
---
 net/netfilter/xt_hashlimit.c | 92 +++-
 1 file changed, 18 insertions(+), 74 deletions(-)

diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c
index 0cd73567e7ff..9b16402f29af 100644
--- a/net/netfilter/xt_hashlimit.c
+++ b/net/netfilter/xt_hashlimit.c
@@ -57,9 +57,9 @@ static inline struct hashlimit_net *hashlimit_pernet(struct 
net *net)
 }
 
 /* need to declare this at the top */
-static const struct file_operations dl_file_ops_v2;
-static const struct file_operations dl_file_ops_v1;
-static const struct file_operations dl_file_ops;
+static const struct seq_operations dl_seq_ops_v2;
+static const struct seq_operations dl_seq_ops_v1;
+static const struct seq_operations dl_seq_ops;
 
 /* hash table crap */
 struct dsthash_dst {
@@ -272,7 +272,7 @@ static int htable_create(struct net *net, struct 
hashlimit_cfg3 *cfg,
 {
struct hashlimit_net *hashlimit_net = hashlimit_pernet(net);
struct xt_hashlimit_htable *hinfo;
-   const struct file_operations *fops;
+   const struct seq_operations *ops;
unsigned int size, i;
int ret;
 
@@ -321,19 +321,19 @@ static int htable_create(struct net *net, struct 
hashlimit_cfg3 *cfg,
 
switch (revision) {
case 1:
-   fops = &dl_file_ops_v1;
+   ops = &dl_seq_ops_v1;
break;
case 2:
-   fops = &dl_file_ops_v2;
+   ops = &dl_seq_ops_v2;
break;
default:
-   fops = &dl_file_ops;
+   ops = &dl_seq_ops;
}
 
-   hinfo->pde = proc_create_data(name, 0,
+   hinfo->pde = proc_create_seq_data(name, 0,
(family == NFPROTO_IPV4) ?
hashlimit_net->ipt_hashlimit : hashlimit_net->ip6t_hashlimit,
-   fops, hinfo);
+   ops, hinfo);
if (hinfo->pde == NULL) {
kfree(hinfo->name);
vfree(hinfo);
@@ -1057,7 +1057,7 @@ static struct xt_match hashlimit_mt_reg[] __read_mostly = 
{
 static void *dl_seq_start(struct seq_file *s, loff_t *pos)
__acquires(htable->lock)
 {
-   struct xt_hashlimit_htable *htable = s->private;
+   struct xt_hashlimit_htable *htable = PDE_DATA(file_inode(s->private));
unsigned int *bucket;
 
spin_lock_bh(&htable->lock);
@@ -1074,7 +1074,7 @@ static void *dl_seq_start(struct seq_file *s, loff_t *pos)
 
 static void *dl_seq_next(struct seq_file *s, void *v, loff_t *pos)
 {
-   struct xt_hashlimit_htable *htable = s->private;
+   struct xt_hashlimit_htable *htable = PDE_DATA(file_inode(s->private));
unsigned int *bucket = v;
 
*pos = ++(*bucket);
@@ -1088,7 +1088,7 @@ static void *dl_seq_next(struct seq_file *s, void *v, 
loff_t *pos)
 static void dl_seq_stop(struct seq_file *s, void *v)
__releases(htable->lock)
 {
-   struct xt_hashlimit_htable *htable = s->private;
+   struct xt_hashlimit_htable *htable = PDE_DATA(file_inode(s->private));
unsigned int *bucket = v;
 
if (!IS_ERR(bucket))
@@ -1130,7 +1130,7 @@ static void dl_seq_print(struct dsthash_ent *ent, 
u_int8_t family,
 static int dl_seq_real_show_v2(struct dsthash_ent *ent, u_int8_t family,
   struct seq_file *s)
 {
-   const struct xt_hashlimit_htable *ht = s->private;
+   struct xt_hashlimit_htable *ht = PDE_DATA(file_inode(s->private));
 
spin_lock(&ent->lock);
/* recalculate to show accurate numbers */
@@ -1145,7 +1145,7 @@ static int dl_seq_real_show_v2(struct dsthash_ent *ent, 
u_int8_t family,
 static int dl_seq_real_show_v1(struct dsthash_ent *ent, u_int8_t family,
   struct seq_file *s)
 {
-   const struct xt_hashlimit_htable *ht = s->private;
+   struct xt_hashlimit_htable *ht = PDE_DATA(file_inode(s->private));
 
spin_lock(&ent->lock);
/* recalculate to show accurate numbers */
@@ -1160,7 +1160,7 @@ static int dl_seq_real_show_v1(struct dsthash_ent *ent, 
u_int8_t family,
 static int dl_seq_real_show(struct dsthash_ent *ent, u_int8_t family,
struct seq_file *s)
 {
-   const struct xt_hashlimit_htable *ht = s->private;
+   struct xt_hashlimit_htable *ht = PDE_DATA(file_inode(s->private));
 
spin_lock(&ent->lock);
/* recalculate to show accurate numbers */
@@ -1174,7 +1174,7 @@ static int dl_seq_real_show(struct dsthash_ent *ent, 
u_int8_t family,
 
 static int dl_seq_show_v2(struct seq_file *s, void *v)
 {
-   struct xt_hashlimit_htable *htable = s->private;
+   struct xt_hashlimit_htable *htable = PDE_DATA(file_inode(s->private));
unsigned int *bucket = (unsigned int *)v;
struct dsthash_ent *ent;
 
@@ -1188,7 +1188,7 @@ static int dl_seq_show_v2(struct seq_file *s, void *v)
 
 static int dl_seq_s

[PATCH 21/40] afs: simplify procfs code

2018-04-25 Thread Christoph Hellwig
Use remove_proc_subtree to remove the whole subtree on cleanup, and
unwind the registration loop into individual calls.  Switch to use
proc_create_seq where applicable.

Signed-off-by: Christoph Hellwig 
---
 fs/afs/proc.c | 134 ++
 1 file changed, 15 insertions(+), 119 deletions(-)

diff --git a/fs/afs/proc.c b/fs/afs/proc.c
index 839a22280606..3aad32762989 100644
--- a/fs/afs/proc.c
+++ b/fs/afs/proc.c
@@ -62,7 +62,6 @@ static const struct file_operations afs_proc_rootcell_fops = {
.llseek = no_llseek,
 };
 
-static int afs_proc_cell_volumes_open(struct inode *inode, struct file *file);
 static void *afs_proc_cell_volumes_start(struct seq_file *p, loff_t *pos);
 static void *afs_proc_cell_volumes_next(struct seq_file *p, void *v,
loff_t *pos);
@@ -76,15 +75,6 @@ static const struct seq_operations afs_proc_cell_volumes_ops 
= {
.show   = afs_proc_cell_volumes_show,
 };
 
-static const struct file_operations afs_proc_cell_volumes_fops = {
-   .open   = afs_proc_cell_volumes_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= seq_release,
-};
-
-static int afs_proc_cell_vlservers_open(struct inode *inode,
-   struct file *file);
 static void *afs_proc_cell_vlservers_start(struct seq_file *p, loff_t *pos);
 static void *afs_proc_cell_vlservers_next(struct seq_file *p, void *v,
  loff_t *pos);
@@ -98,14 +88,6 @@ static const struct seq_operations 
afs_proc_cell_vlservers_ops = {
.show   = afs_proc_cell_vlservers_show,
 };
 
-static const struct file_operations afs_proc_cell_vlservers_fops = {
-   .open   = afs_proc_cell_vlservers_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= seq_release,
-};
-
-static int afs_proc_servers_open(struct inode *inode, struct file *file);
 static void *afs_proc_servers_start(struct seq_file *p, loff_t *pos);
 static void *afs_proc_servers_next(struct seq_file *p, void *v,
loff_t *pos);
@@ -119,13 +101,6 @@ static const struct seq_operations afs_proc_servers_ops = {
.show   = afs_proc_servers_show,
 };
 
-static const struct file_operations afs_proc_servers_fops = {
-   .open   = afs_proc_servers_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= seq_release,
-};
-
 static int afs_proc_sysname_open(struct inode *inode, struct file *file);
 static int afs_proc_sysname_release(struct inode *inode, struct file *file);
 static void *afs_proc_sysname_start(struct seq_file *p, loff_t *pos);
@@ -152,7 +127,7 @@ static const struct file_operations afs_proc_sysname_fops = 
{
.write  = afs_proc_sysname_write,
 };
 
-static const struct file_operations afs_proc_stats_fops;
+static int afs_proc_stats_show(struct seq_file *m, void *v);
 
 /*
  * initialise the /proc/fs/afs/ directory
@@ -167,8 +142,8 @@ int afs_proc_init(struct afs_net *net)
 
if (!proc_create("cells", 0644, net->proc_afs, &afs_proc_cells_fops) ||
!proc_create("rootcell", 0644, net->proc_afs, 
&afs_proc_rootcell_fops) ||
-   !proc_create("servers", 0644, net->proc_afs, 
&afs_proc_servers_fops) ||
-   !proc_create("stats", 0644, net->proc_afs, &afs_proc_stats_fops) ||
+   !proc_create_seq("servers", 0644, net->proc_afs, 
&afs_proc_servers_ops) ||
+   !proc_create_single("stats", 0644, net->proc_afs, 
afs_proc_stats_show) ||
!proc_create("sysname", 0644, net->proc_afs, 
&afs_proc_sysname_fops))
goto error_tree;
 
@@ -196,16 +171,7 @@ void afs_proc_cleanup(struct afs_net *net)
  */
 static int afs_proc_cells_open(struct inode *inode, struct file *file)
 {
-   struct seq_file *m;
-   int ret;
-
-   ret = seq_open(file, &afs_proc_cells_ops);
-   if (ret < 0)
-   return ret;
-
-   m = file->private_data;
-   m->private = PDE_DATA(inode);
-   return 0;
+   return seq_open(file, &afs_proc_cells_ops);
 }
 
 /*
@@ -430,10 +396,11 @@ int afs_proc_cell_setup(struct afs_net *net, struct 
afs_cell *cell)
if (!dir)
goto error_dir;
 
-   if (!proc_create_data("vlservers", 0, dir,
- &afs_proc_cell_vlservers_fops, cell) ||
-   !proc_create_data("volumes", 0, dir,
- &afs_proc_cell_volumes_fops, cell))
+   if (!proc_create_seq_data("vlservers", 0, dir,
+   &afs_proc_cell_vlservers_ops, cell))
+   goto error_tree;
+   if (!proc_create_seq_data("volumes", 0, dir, &afs_proc_cell_volumes_ops,
+   cell))
goto error_tree;
 
_leave(" = 0");
@@ -458,29 +425,6 @@ void afs_proc_cell_remove(struct afs_net *net,

[PATCH 35/40] atm: switch to proc_create_seq_private

2018-04-25 Thread Christoph Hellwig
And remove proc boilerplate code.

Signed-off-by: Christoph Hellwig 
---
 net/atm/proc.c | 72 +-
 1 file changed, 13 insertions(+), 59 deletions(-)

diff --git a/net/atm/proc.c b/net/atm/proc.c
index f272b0f59d82..0b0495a41bbe 100644
--- a/net/atm/proc.c
+++ b/net/atm/proc.c
@@ -68,7 +68,6 @@ static void atm_dev_info(struct seq_file *seq, const struct 
atm_dev *dev)
 struct vcc_state {
int bucket;
struct sock *sk;
-   int family;
 };
 
 static inline int compare_family(struct sock *sk, int family)
@@ -106,23 +105,13 @@ static int __vcc_walk(struct sock **sock, int family, int 
*bucket, loff_t l)
return (l < 0);
 }
 
-static inline void *vcc_walk(struct vcc_state *state, loff_t l)
+static inline void *vcc_walk(struct seq_file *seq, loff_t l)
 {
-   return __vcc_walk(&state->sk, state->family, &state->bucket, l) ?
-  state : NULL;
-}
-
-static int __vcc_seq_open(struct inode *inode, struct file *file,
-   int family, const struct seq_operations *ops)
-{
-   struct vcc_state *state;
-
-   state = __seq_open_private(file, ops, sizeof(*state));
-   if (state == NULL)
-   return -ENOMEM;
+   struct vcc_state *state = seq->private;
+   int family = (uintptr_t)(PDE_DATA(file_inode(seq->file)));
 
-   state->family = family;
-   return 0;
+   return __vcc_walk(&state->sk, family, &state->bucket, l) ?
+  state : NULL;
 }
 
 static void *vcc_seq_start(struct seq_file *seq, loff_t *pos)
@@ -133,7 +122,7 @@ static void *vcc_seq_start(struct seq_file *seq, loff_t 
*pos)
 
read_lock(&vcc_sklist_lock);
state->sk = SEQ_START_TOKEN;
-   return left ? vcc_walk(state, left) : SEQ_START_TOKEN;
+   return left ? vcc_walk(seq, left) : SEQ_START_TOKEN;
 }
 
 static void vcc_seq_stop(struct seq_file *seq, void *v)
@@ -144,9 +133,7 @@ static void vcc_seq_stop(struct seq_file *seq, void *v)
 
 static void *vcc_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 {
-   struct vcc_state *state = seq->private;
-
-   v = vcc_walk(state, 1);
+   v = vcc_walk(seq, 1);
*pos += !!PTR_ERR(v);
return v;
 }
@@ -280,18 +267,6 @@ static const struct seq_operations pvc_seq_ops = {
.show   = pvc_seq_show,
 };
 
-static int pvc_seq_open(struct inode *inode, struct file *file)
-{
-   return __vcc_seq_open(inode, file, PF_ATMPVC, &pvc_seq_ops);
-}
-
-static const struct file_operations pvc_seq_fops = {
-   .open   = pvc_seq_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= seq_release_private,
-};
-
 static int vcc_seq_show(struct seq_file *seq, void *v)
 {
if (v == SEQ_START_TOKEN) {
@@ -314,18 +289,6 @@ static const struct seq_operations vcc_seq_ops = {
.show   = vcc_seq_show,
 };
 
-static int vcc_seq_open(struct inode *inode, struct file *file)
-{
-   return __vcc_seq_open(inode, file, 0, &vcc_seq_ops);
-}
-
-static const struct file_operations vcc_seq_fops = {
-   .open   = vcc_seq_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= seq_release_private,
-};
-
 static int svc_seq_show(struct seq_file *seq, void *v)
 {
static const char atm_svc_banner[] =
@@ -349,18 +312,6 @@ static const struct seq_operations svc_seq_ops = {
.show   = svc_seq_show,
 };
 
-static int svc_seq_open(struct inode *inode, struct file *file)
-{
-   return __vcc_seq_open(inode, file, PF_ATMSVC, &svc_seq_ops);
-}
-
-static const struct file_operations svc_seq_fops = {
-   .open   = svc_seq_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= seq_release_private,
-};
-
 static ssize_t proc_dev_atm_read(struct file *file, char __user *buf,
 size_t count, loff_t *pos)
 {
@@ -434,9 +385,12 @@ int __init atm_proc_init(void)
if (!atm_proc_root)
return -ENOMEM;
proc_create_seq("devices", 0444, atm_proc_root, &atm_dev_seq_ops);
-   proc_create("pvc", 0444, atm_proc_root, &pvc_seq_fops);
-   proc_create("svc", 0444, atm_proc_root, &svc_seq_fops);
-   proc_create("vc", 0444, atm_proc_root, &vcc_seq_fops);
+   proc_create_seq_private("pvc", 0444, atm_proc_root, &pvc_seq_ops,
+   sizeof(struct vcc_state), (void *)(uintptr_t)PF_ATMPVC);
+   proc_create_seq_private("svc", 0444, atm_proc_root, &svc_seq_ops,
+   sizeof(struct vcc_state), (void *)(uintptr_t)PF_ATMSVC);
+   proc_create_seq_private("vc", 0444, atm_proc_root, &vcc_seq_ops,
+   sizeof(struct vcc_state), NULL);
return 0;
 }
 
-- 
2.17.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 34/40] atm: simplify procfs code

2018-04-25 Thread Christoph Hellwig
Use remove_proc_subtree to remove the whole subtree on cleanup, and
unwind the registration loop into individual calls.  Switch to use
proc_create_seq where applicable.

Signed-off-by: Christoph Hellwig 
---
 net/atm/proc.c | 65 ++
 1 file changed, 7 insertions(+), 58 deletions(-)

diff --git a/net/atm/proc.c b/net/atm/proc.c
index 55410c00c7e2..f272b0f59d82 100644
--- a/net/atm/proc.c
+++ b/net/atm/proc.c
@@ -257,18 +257,6 @@ static const struct seq_operations atm_dev_seq_ops = {
.show   = atm_dev_seq_show,
 };
 
-static int atm_dev_seq_open(struct inode *inode, struct file *file)
-{
-   return seq_open(file, &atm_dev_seq_ops);
-}
-
-static const struct file_operations devices_seq_fops = {
-   .open   = atm_dev_seq_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= seq_release,
-};
-
 static int pvc_seq_show(struct seq_file *seq, void *v)
 {
static char atm_pvc_banner[] =
@@ -440,58 +428,19 @@ void atm_proc_dev_deregister(struct atm_dev *dev)
kfree(dev->proc_name);
 }
 
-static struct atm_proc_entry {
-   char *name;
-   const struct file_operations *proc_fops;
-   struct proc_dir_entry *dirent;
-} atm_proc_ents[] = {
-   { .name = "devices",.proc_fops = &devices_seq_fops },
-   { .name = "pvc",.proc_fops = &pvc_seq_fops },
-   { .name = "svc",.proc_fops = &svc_seq_fops },
-   { .name = "vc", .proc_fops = &vcc_seq_fops },
-   { .name = NULL, .proc_fops = NULL }
-};
-
-static void atm_proc_dirs_remove(void)
-{
-   static struct atm_proc_entry *e;
-
-   for (e = atm_proc_ents; e->name; e++) {
-   if (e->dirent)
-   remove_proc_entry(e->name, atm_proc_root);
-   }
-   remove_proc_entry("atm", init_net.proc_net);
-}
-
 int __init atm_proc_init(void)
 {
-   static struct atm_proc_entry *e;
-   int ret;
-
atm_proc_root = proc_net_mkdir(&init_net, "atm", init_net.proc_net);
if (!atm_proc_root)
-   goto err_out;
-   for (e = atm_proc_ents; e->name; e++) {
-   struct proc_dir_entry *dirent;
-
-   dirent = proc_create(e->name, 0444,
-atm_proc_root, e->proc_fops);
-   if (!dirent)
-   goto err_out_remove;
-   e->dirent = dirent;
-   }
-   ret = 0;
-out:
-   return ret;
-
-err_out_remove:
-   atm_proc_dirs_remove();
-err_out:
-   ret = -ENOMEM;
-   goto out;
+   return -ENOMEM;
+   proc_create_seq("devices", 0444, atm_proc_root, &atm_dev_seq_ops);
+   proc_create("pvc", 0444, atm_proc_root, &pvc_seq_fops);
+   proc_create("svc", 0444, atm_proc_root, &svc_seq_fops);
+   proc_create("vc", 0444, atm_proc_root, &vcc_seq_fops);
+   return 0;
 }
 
 void atm_proc_exit(void)
 {
-   atm_proc_dirs_remove();
+   remove_proc_subtree("atm", init_net.proc_net);
 }
-- 
2.17.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 37/40] proc: don't detour through seq->private to get the inode

2018-04-25 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
---
 fs/proc/array.c | 18 --
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/fs/proc/array.c b/fs/proc/array.c
index ae2c807fd719..b34796b562ef 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -677,7 +677,7 @@ get_children_pid(struct inode *inode, struct pid *pid_prev, 
loff_t pos)
 
 static int children_seq_show(struct seq_file *seq, void *v)
 {
-   struct inode *inode = seq->private;
+   struct inode *inode = file_inode(seq->file);
pid_t pid;
 
pid = pid_nr_ns(v, inode->i_sb->s_fs_info);
@@ -688,14 +688,14 @@ static int children_seq_show(struct seq_file *seq, void 
*v)
 
 static void *children_seq_start(struct seq_file *seq, loff_t *pos)
 {
-   return get_children_pid(seq->private, NULL, *pos);
+   return get_children_pid(file_inode(seq->file), NULL, *pos);
 }
 
 static void *children_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 {
struct pid *pid;
 
-   pid = get_children_pid(seq->private, v, *pos + 1);
+   pid = get_children_pid(file_inode(seq->file), v, *pos + 1);
put_pid(v);
 
++*pos;
@@ -716,17 +716,7 @@ static const struct seq_operations children_seq_ops = {
 
 static int children_seq_open(struct inode *inode, struct file *file)
 {
-   struct seq_file *m;
-   int ret;
-
-   ret = seq_open(file, &children_seq_ops);
-   if (ret)
-   return ret;
-
-   m = file->private_data;
-   m->private = inode;
-
-   return ret;
+   return seq_open(file, &children_seq_ops);
 }
 
 const struct file_operations proc_tid_children_operations = {
-- 
2.17.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 40/40] tty: replace ->proc_fops with ->proc_show

2018-04-25 Thread Christoph Hellwig
Just set up the show callback in the tty_operations, and use
proc_create_single_data to create the file without additional
boilerplace code.

Signed-off-by: Christoph Hellwig 
---
 arch/ia64/hp/sim/simserial.c| 15 +--
 arch/xtensa/platforms/iss/console.c | 15 +--
 drivers/char/pcmcia/synclink_cs.c   | 15 +--
 drivers/mmc/core/sdio_uart.c| 15 +--
 drivers/staging/fwserial/fwserial.c | 15 +--
 drivers/tty/amiserial.c | 15 +--
 drivers/tty/cyclades.c  | 15 +--
 drivers/tty/serial/serial_core.c| 15 +--
 drivers/tty/synclink.c  | 15 +--
 drivers/tty/synclink_gt.c   | 15 +--
 drivers/tty/synclinkmp.c| 15 +--
 drivers/usb/serial/usb-serial.c | 15 +--
 fs/proc/proc_tty.c  |  6 +++---
 include/linux/tty_driver.h  |  2 +-
 14 files changed, 16 insertions(+), 172 deletions(-)

diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index a419ccf33cde..663388a73d4e 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -435,19 +435,6 @@ static int rs_proc_show(struct seq_file *m, void *v)
return 0;
 }
 
-static int rs_proc_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, rs_proc_show, NULL);
-}
-
-static const struct file_operations rs_proc_fops = {
-   .owner  = THIS_MODULE,
-   .open   = rs_proc_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
-
 static const struct tty_operations hp_ops = {
.open = rs_open,
.close = rs_close,
@@ -462,7 +449,7 @@ static const struct tty_operations hp_ops = {
.unthrottle = rs_unthrottle,
.send_xchar = rs_send_xchar,
.hangup = rs_hangup,
-   .proc_fops = &rs_proc_fops,
+   .proc_show = rs_proc_show,
 };
 
 static const struct tty_port_operations hp_port_ops = {
diff --git a/arch/xtensa/platforms/iss/console.c 
b/arch/xtensa/platforms/iss/console.c
index 92f567f9a21e..af81a62faba6 100644
--- a/arch/xtensa/platforms/iss/console.c
+++ b/arch/xtensa/platforms/iss/console.c
@@ -153,19 +153,6 @@ static int rs_proc_show(struct seq_file *m, void *v)
return 0;
 }
 
-static int rs_proc_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, rs_proc_show, NULL);
-}
-
-static const struct file_operations rs_proc_fops = {
-   .owner  = THIS_MODULE,
-   .open   = rs_proc_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
-
 static const struct tty_operations serial_ops = {
.open = rs_open,
.close = rs_close,
@@ -176,7 +163,7 @@ static const struct tty_operations serial_ops = {
.chars_in_buffer = rs_chars_in_buffer,
.hangup = rs_hangup,
.wait_until_sent = rs_wait_until_sent,
-   .proc_fops = &rs_proc_fops,
+   .proc_show = rs_proc_show,
 };
 
 int __init rs_init(void)
diff --git a/drivers/char/pcmcia/synclink_cs.c 
b/drivers/char/pcmcia/synclink_cs.c
index aa502e9fb7fa..66b04194aa9f 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -2616,19 +2616,6 @@ static int mgslpc_proc_show(struct seq_file *m, void *v)
return 0;
 }
 
-static int mgslpc_proc_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, mgslpc_proc_show, NULL);
-}
-
-static const struct file_operations mgslpc_proc_fops = {
-   .owner  = THIS_MODULE,
-   .open   = mgslpc_proc_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
-
 static int rx_alloc_buffers(MGSLPC_INFO *info)
 {
/* each buffer has header and data */
@@ -2815,7 +2802,7 @@ static const struct tty_operations mgslpc_ops = {
.tiocmget = tiocmget,
.tiocmset = tiocmset,
.get_icount = mgslpc_get_icount,
-   .proc_fops = &mgslpc_proc_fops,
+   .proc_show = mgslpc_proc_show,
 };
 
 static int __init synclink_cs_init(void)
diff --git a/drivers/mmc/core/sdio_uart.c b/drivers/mmc/core/sdio_uart.c
index d3c91f412b69..25e113001a3c 100644
--- a/drivers/mmc/core/sdio_uart.c
+++ b/drivers/mmc/core/sdio_uart.c
@@ -1008,19 +1008,6 @@ static int sdio_uart_proc_show(struct seq_file *m, void 
*v)
return 0;
 }
 
-static int sdio_uart_proc_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, sdio_uart_proc_show, NULL);
-}
-
-static const struct file_operations sdio_uart_proc_fops = {
-   .owner  = THIS_MODULE,
-   .open   = sdio_uart_proc_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
-
 static const struct t

[PATCH 33/40] bluetooth: switch to proc_create_seq_data

2018-04-25 Thread Christoph Hellwig
And use proc private data directly instead of doing a detour
through seq->private and private state.

Signed-off-by: Christoph Hellwig 
---
 net/bluetooth/af_bluetooth.c | 40 +---
 1 file changed, 5 insertions(+), 35 deletions(-)

diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index 84d92a077834..3264e1873219 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -605,15 +605,10 @@ int bt_sock_wait_ready(struct sock *sk, unsigned long 
flags)
 EXPORT_SYMBOL(bt_sock_wait_ready);
 
 #ifdef CONFIG_PROC_FS
-struct bt_seq_state {
-   struct bt_sock_list *l;
-};
-
 static void *bt_seq_start(struct seq_file *seq, loff_t *pos)
__acquires(seq->private->l->lock)
 {
-   struct bt_seq_state *s = seq->private;
-   struct bt_sock_list *l = s->l;
+   struct bt_sock_list *l = PDE_DATA(file_inode(seq->file));
 
read_lock(&l->lock);
return seq_hlist_start_head(&l->head, *pos);
@@ -621,8 +616,7 @@ static void *bt_seq_start(struct seq_file *seq, loff_t *pos)
 
 static void *bt_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 {
-   struct bt_seq_state *s = seq->private;
-   struct bt_sock_list *l = s->l;
+   struct bt_sock_list *l = PDE_DATA(file_inode(seq->file));
 
return seq_hlist_next(v, &l->head, pos);
 }
@@ -630,16 +624,14 @@ static void *bt_seq_next(struct seq_file *seq, void *v, 
loff_t *pos)
 static void bt_seq_stop(struct seq_file *seq, void *v)
__releases(seq->private->l->lock)
 {
-   struct bt_seq_state *s = seq->private;
-   struct bt_sock_list *l = s->l;
+   struct bt_sock_list *l = PDE_DATA(file_inode(seq->file));
 
read_unlock(&l->lock);
 }
 
 static int bt_seq_show(struct seq_file *seq, void *v)
 {
-   struct bt_seq_state *s = seq->private;
-   struct bt_sock_list *l = s->l;
+   struct bt_sock_list *l = PDE_DATA(file_inode(seq->file));
 
if (v == SEQ_START_TOKEN) {
seq_puts(seq ,"sk   RefCnt Rmem   Wmem   User   
Inode  Parent");
@@ -681,35 +673,13 @@ static const struct seq_operations bt_seq_ops = {
.show  = bt_seq_show,
 };
 
-static int bt_seq_open(struct inode *inode, struct file *file)
-{
-   struct bt_sock_list *sk_list;
-   struct bt_seq_state *s;
-
-   sk_list = PDE_DATA(inode);
-   s = __seq_open_private(file, &bt_seq_ops,
-  sizeof(struct bt_seq_state));
-   if (!s)
-   return -ENOMEM;
-
-   s->l = sk_list;
-   return 0;
-}
-
-static const struct file_operations bt_fops = {
-   .open = bt_seq_open,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = seq_release_private
-};
-
 int bt_procfs_init(struct net *net, const char *name,
   struct bt_sock_list *sk_list,
   int (* seq_show)(struct seq_file *, void *))
 {
sk_list->custom_seq_show = seq_show;
 
-   if (!proc_create_data(name, 0, net->proc_net, &bt_fops, sk_list))
+   if (!proc_create_seq_data(name, 0, net->proc_net, &bt_seq_ops, sk_list))
return -ENOMEM;
return 0;
 }
-- 
2.17.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 39/40] ide: replace ->proc_fops with ->proc_show

2018-04-25 Thread Christoph Hellwig
Just set up the show callback in the tty_operations, and use
proc_create_single_data to create the file without additional
boilerplace code.

Signed-off-by: Christoph Hellwig 
---
 drivers/ide/ide-cd.c  |  15 +---
 drivers/ide/ide-disk_proc.c   |  62 ++--
 drivers/ide/ide-floppy_proc.c |  17 +
 drivers/ide/ide-proc.c| 136 +-
 drivers/ide/ide-tape.c|  17 +
 include/linux/ide.h   |   6 +-
 6 files changed, 31 insertions(+), 222 deletions(-)

diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 5a8e8e3c22cd..b52a7bdace52 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1426,21 +1426,8 @@ static int idecd_capacity_proc_show(struct seq_file *m, 
void *v)
return 0;
 }
 
-static int idecd_capacity_proc_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, idecd_capacity_proc_show, PDE_DATA(inode));
-}
-
-static const struct file_operations idecd_capacity_proc_fops = {
-   .owner  = THIS_MODULE,
-   .open   = idecd_capacity_proc_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
-
 static ide_proc_entry_t idecd_proc[] = {
-   { "capacity", S_IFREG|S_IRUGO, &idecd_capacity_proc_fops },
+   { "capacity", S_IFREG|S_IRUGO, idecd_capacity_proc_show },
{}
 };
 
diff --git a/drivers/ide/ide-disk_proc.c b/drivers/ide/ide-disk_proc.c
index 82a36ced4e96..95d239b2f646 100644
--- a/drivers/ide/ide-disk_proc.c
+++ b/drivers/ide/ide-disk_proc.c
@@ -52,19 +52,6 @@ static int idedisk_cache_proc_show(struct seq_file *m, void 
*v)
return 0;
 }
 
-static int idedisk_cache_proc_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, idedisk_cache_proc_show, PDE_DATA(inode));
-}
-
-static const struct file_operations idedisk_cache_proc_fops = {
-   .owner  = THIS_MODULE,
-   .open   = idedisk_cache_proc_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
-
 static int idedisk_capacity_proc_show(struct seq_file *m, void *v)
 {
ide_drive_t*drive = (ide_drive_t *)m->private;
@@ -73,19 +60,6 @@ static int idedisk_capacity_proc_show(struct seq_file *m, 
void *v)
return 0;
 }
 
-static int idedisk_capacity_proc_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, idedisk_capacity_proc_show, PDE_DATA(inode));
-}
-
-static const struct file_operations idedisk_capacity_proc_fops = {
-   .owner  = THIS_MODULE,
-   .open   = idedisk_capacity_proc_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
-
 static int __idedisk_proc_show(struct seq_file *m, ide_drive_t *drive, u8 
sub_cmd)
 {
u8 *buf;
@@ -114,43 +88,17 @@ static int idedisk_sv_proc_show(struct seq_file *m, void 
*v)
return __idedisk_proc_show(m, m->private, ATA_SMART_READ_VALUES);
 }
 
-static int idedisk_sv_proc_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, idedisk_sv_proc_show, PDE_DATA(inode));
-}
-
-static const struct file_operations idedisk_sv_proc_fops = {
-   .owner  = THIS_MODULE,
-   .open   = idedisk_sv_proc_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
-
 static int idedisk_st_proc_show(struct seq_file *m, void *v)
 {
return __idedisk_proc_show(m, m->private, ATA_SMART_READ_THRESHOLDS);
 }
 
-static int idedisk_st_proc_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, idedisk_st_proc_show, PDE_DATA(inode));
-}
-
-static const struct file_operations idedisk_st_proc_fops = {
-   .owner  = THIS_MODULE,
-   .open   = idedisk_st_proc_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
-
 ide_proc_entry_t ide_disk_proc[] = {
-   { "cache",S_IFREG|S_IRUGO, &idedisk_cache_proc_fops },
-   { "capacity", S_IFREG|S_IRUGO, &idedisk_capacity_proc_fops  },
-   { "geometry", S_IFREG|S_IRUGO, &ide_geometry_proc_fops  },
-   { "smart_values", S_IFREG|S_IRUSR, &idedisk_sv_proc_fops},
-   { "smart_thresholds", S_IFREG|S_IRUSR, &idedisk_st_proc_fops},
+   { "cache",S_IFREG|S_IRUGO, idedisk_cache_proc_show  },
+   { "capacity", S_IFREG|S_IRUGO, idedisk_capacity_proc_show   },
+   { "geometry", S_IFREG|S_IRUGO, ide_geometry_proc_show   },
+   { "smart_values", S_IFREG|S_IRUSR, idedisk_sv_proc_show },
+   { "smart_thresholds", S_IFREG|S_IRUSR, idedisk_st_proc_show },
{}
 };
 
diff --git a/drivers/ide/ide-floppy_proc.c b/drivers/ide/ide-floppy_proc.c
index 471457ebea67..7f697

[PATCH 36/40] isdn: replace ->proc_fops with ->proc_show

2018-04-25 Thread Christoph Hellwig
And switch to proc_create_single_data.

Signed-off-by: Christoph Hellwig 
---
 drivers/isdn/capi/kcapi.c  |  3 ++-
 drivers/isdn/gigaset/capi.c| 16 +---
 drivers/isdn/hardware/avm/avmcard.h|  4 ++--
 drivers/isdn/hardware/avm/b1.c | 17 ++---
 drivers/isdn/hardware/avm/b1dma.c  | 17 ++---
 drivers/isdn/hardware/avm/b1isa.c  |  2 +-
 drivers/isdn/hardware/avm/b1pci.c  |  4 ++--
 drivers/isdn/hardware/avm/b1pcmcia.c   |  2 +-
 drivers/isdn/hardware/avm/c4.c | 15 +--
 drivers/isdn/hardware/avm/t1isa.c  |  2 +-
 drivers/isdn/hardware/avm/t1pci.c  |  2 +-
 drivers/isdn/hardware/eicon/capimain.c | 15 +--
 drivers/isdn/hysdn/hycapi.c| 15 +--
 include/linux/isdn/capilli.h   |  2 +-
 net/bluetooth/cmtp/capi.c  | 14 +-
 15 files changed, 20 insertions(+), 110 deletions(-)

diff --git a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c
index 46c189ad8d94..0ff517d3c98f 100644
--- a/drivers/isdn/capi/kcapi.c
+++ b/drivers/isdn/capi/kcapi.c
@@ -534,7 +534,8 @@ int attach_capi_ctr(struct capi_ctr *ctr)
init_waitqueue_head(&ctr->state_wait_queue);
 
sprintf(ctr->procfn, "capi/controllers/%d", ctr->cnr);
-   ctr->procent = proc_create_data(ctr->procfn, 0, NULL, ctr->proc_fops, 
ctr);
+   ctr->procent = proc_create_single_data(ctr->procfn, 0, NULL,
+   ctr->proc_show, ctr);
 
ncontrollers++;
 
diff --git a/drivers/isdn/gigaset/capi.c b/drivers/isdn/gigaset/capi.c
index ccec7778cad2..dac5cd35e901 100644
--- a/drivers/isdn/gigaset/capi.c
+++ b/drivers/isdn/gigaset/capi.c
@@ -2437,19 +2437,6 @@ static int gigaset_proc_show(struct seq_file *m, void *v)
return 0;
 }
 
-static int gigaset_proc_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, gigaset_proc_show, PDE_DATA(inode));
-}
-
-static const struct file_operations gigaset_proc_fops = {
-   .owner  = THIS_MODULE,
-   .open   = gigaset_proc_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
-
 /**
  * gigaset_isdn_regdev() - register device to LL
  * @cs:device descriptor structure.
@@ -2478,8 +2465,7 @@ int gigaset_isdn_regdev(struct cardstate *cs, const char 
*isdnid)
iif->ctr.register_appl = gigaset_register_appl;
iif->ctr.release_appl  = gigaset_release_appl;
iif->ctr.send_message  = gigaset_send_message;
-   iif->ctr.procinfo  = gigaset_procinfo;
-   iif->ctr.proc_fops = &gigaset_proc_fops;
+   iif->ctr.proc_show = gigaset_proc_show,
INIT_LIST_HEAD(&iif->appls);
skb_queue_head_init(&iif->sendqueue);
atomic_set(&iif->sendqlen, 0);
diff --git a/drivers/isdn/hardware/avm/avmcard.h 
b/drivers/isdn/hardware/avm/avmcard.h
index c95712dbfa9f..cdfa89c71997 100644
--- a/drivers/isdn/hardware/avm/avmcard.h
+++ b/drivers/isdn/hardware/avm/avmcard.h
@@ -556,7 +556,7 @@ u16  b1_send_message(struct capi_ctr *ctrl, struct sk_buff 
*skb);
 void b1_parse_version(avmctrl_info *card);
 irqreturn_t b1_interrupt(int interrupt, void *devptr);
 
-extern const struct file_operations b1ctl_proc_fops;
+int b1_proc_show(struct seq_file *m, void *v);
 
 avmcard_dmainfo *avmcard_dma_alloc(char *name, struct pci_dev *,
   long rsize, long ssize);
@@ -576,6 +576,6 @@ void b1dma_register_appl(struct capi_ctr *ctrl,
 capi_register_params *rp);
 void b1dma_release_appl(struct capi_ctr *ctrl, u16 appl);
 u16  b1dma_send_message(struct capi_ctr *ctrl, struct sk_buff *skb);
-extern const struct file_operations b1dmactl_proc_fops;
+int b1dma_proc_show(struct seq_file *m, void *v);
 
 #endif /* _AVMCARD_H_ */
diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
index b1833d08a5fe..5ee5489d3f15 100644
--- a/drivers/isdn/hardware/avm/b1.c
+++ b/drivers/isdn/hardware/avm/b1.c
@@ -637,7 +637,7 @@ irqreturn_t b1_interrupt(int interrupt, void *devptr)
 }
 
 /* - */
-static int b1ctl_proc_show(struct seq_file *m, void *v)
+int b1_proc_show(struct seq_file *m, void *v)
 {
struct capi_ctr *ctrl = m->private;
avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
@@ -699,20 +699,7 @@ static int b1ctl_proc_show(struct seq_file *m, void *v)
 
return 0;
 }
-
-static int b1ctl_proc_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, b1ctl_proc_show, PDE_DATA(inode));
-}
-
-const struct file_operations b1ctl_proc_fops = {
-   .owner  = THIS_MODULE,
-   .open   = b1ctl_proc_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
-EXPORT_SYMBOL(b1ctl_proc_fops);
+EXPORT_SYMBOL(b1_proc_show);
 
 

[PATCH 38/40] ide: remove ide_driver_proc_write

2018-04-25 Thread Christoph Hellwig
The driver proc file hasn't been writeable for a long time, so this is
just dead code.

Signed-off-by: Christoph Hellwig 
---
 drivers/ide/ide-proc.c | 46 --
 1 file changed, 46 deletions(-)

diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c
index 863db44c7916..b3b8b8822d6a 100644
--- a/drivers/ide/ide-proc.c
+++ b/drivers/ide/ide-proc.c
@@ -528,58 +528,12 @@ static int ide_driver_proc_open(struct inode *inode, 
struct file *file)
return single_open(file, ide_driver_proc_show, PDE_DATA(inode));
 }
 
-static int ide_replace_subdriver(ide_drive_t *drive, const char *driver)
-{
-   struct device *dev = &drive->gendev;
-   int ret = 1;
-   int err;
-
-   device_release_driver(dev);
-   /* FIXME: device can still be in use by previous driver */
-   strlcpy(drive->driver_req, driver, sizeof(drive->driver_req));
-   err = device_attach(dev);
-   if (err < 0)
-   printk(KERN_WARNING "IDE: %s: device_attach error: %d\n",
-   __func__, err);
-   drive->driver_req[0] = 0;
-   if (dev->driver == NULL) {
-   err = device_attach(dev);
-   if (err < 0)
-   printk(KERN_WARNING
-   "IDE: %s: device_attach(2) error: %d\n",
-   __func__, err);
-   }
-   if (dev->driver && !strcmp(dev->driver->name, driver))
-   ret = 0;
-
-   return ret;
-}
-
-static ssize_t ide_driver_proc_write(struct file *file, const char __user 
*buffer,
-size_t count, loff_t *pos)
-{
-   ide_drive_t *drive = PDE_DATA(file_inode(file));
-   char name[32];
-
-   if (!capable(CAP_SYS_ADMIN))
-   return -EACCES;
-   if (count > 31)
-   count = 31;
-   if (copy_from_user(name, buffer, count))
-   return -EFAULT;
-   name[count] = '\0';
-   if (ide_replace_subdriver(drive, name))
-   return -EINVAL;
-   return count;
-}
-
 static const struct file_operations ide_driver_proc_fops = {
.owner  = THIS_MODULE,
.open   = ide_driver_proc_open,
.read   = seq_read,
.llseek = seq_lseek,
.release= single_release,
-   .write  = ide_driver_proc_write,
 };
 
 static int ide_media_proc_show(struct seq_file *m, void *v)
-- 
2.17.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] ion: Consider ion pool pages as indirectly reclaimable

2018-04-25 Thread Laura Abbott

On 04/24/2018 08:43 PM, vji...@codeaurora.org wrote:

From: Vijayanand Jitta 

An issue is observed where mallocs are failing due to overcommit failure.
The failure happens when there is high ION page pool since ION page
pool is not considered reclaimable by the overcommit calculation code.
This change considers ion pool pages as indirectly reclaimable and thus
accounted as available memory in the overcommit calculation.

Signed-off-by: Vijayanand Jitta 
---
  drivers/staging/android/ion/ion_page_pool.c | 5 +
  1 file changed, 5 insertions(+)

diff --git a/drivers/staging/android/ion/ion_page_pool.c 
b/drivers/staging/android/ion/ion_page_pool.c
index db8f614..9bc56eb 100644
--- a/drivers/staging/android/ion/ion_page_pool.c
+++ b/drivers/staging/android/ion/ion_page_pool.c
@@ -32,6 +32,9 @@ static void ion_page_pool_add(struct ion_page_pool *pool, 
struct page *page)
list_add_tail(&page->lru, &pool->low_items);
pool->low_count++;
}
+
+   mod_node_page_state(page_pgdat(page), NR_INDIRECTLY_RECLAIMABLE_BYTES,
+   (1 << (PAGE_SHIFT + pool->order)));
mutex_unlock(&pool->mutex);
  }
  
@@ -50,6 +53,8 @@ static struct page *ion_page_pool_remove(struct ion_page_pool *pool, bool high)

}
  
  	list_del(&page->lru);

+   mod_node_page_state(page_pgdat(page), NR_INDIRECTLY_RECLAIMABLE_BYTES,
+   -(1 << (PAGE_SHIFT + pool->order)));
return page;
  }
  



I'm sure this fixes the problem but I don't think we want to
start throwing page adjustments into Ion. Why isn't this
memory already considered reclaimable by existing calculations?

Thanks,
Laura
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging/wilc1000: fix wilc_mac_xmit()'s return type

2018-04-25 Thread Claudiu Beznea
Hi Luc,

I'm resending this since last time I only send it to staging ml.

Could you, please, change the "return 0;"s inside wilc_mac_xmit() with
"return NETDEV_TX_OK" ?

Thank you,
Claudiu

On 24.04.2018 15:18, Luc Van Oostenryck wrote:
> The method ndo_start_xmit() is defined as returning an 'netdev_tx_t',
> which is a typedef for an enum type, but the implementation in this
> driver returns an 'int'.
> 
> Fix this by returning 'netdev_tx_t' in this driver too.
> 
> Signed-off-by: Luc Van Oostenryck 
> ---
>  drivers/staging/wilc1000/linux_wlan.c | 2 +-
>  drivers/staging/wilc1000/wilc_wlan.h  | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/wilc1000/linux_wlan.c 
> b/drivers/staging/wilc1000/linux_wlan.c
> index 38a83bd31..e06aaed5e 100644
> --- a/drivers/staging/wilc1000/linux_wlan.c
> +++ b/drivers/staging/wilc1000/linux_wlan.c
> @@ -941,7 +941,7 @@ static void linux_wlan_tx_complete(void *priv, int status)
>   kfree(pv_data);
>  }
>  
> -int wilc_mac_xmit(struct sk_buff *skb, struct net_device *ndev)
> +netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *ndev)
>  {
>   struct wilc_vif *vif;
>   struct tx_complete_data *tx_data = NULL;
> diff --git a/drivers/staging/wilc1000/wilc_wlan.h 
> b/drivers/staging/wilc1000/wilc_wlan.h
> index fa157a67b..d3b5a6b38 100644
> --- a/drivers/staging/wilc1000/wilc_wlan.h
> +++ b/drivers/staging/wilc1000/wilc_wlan.h
> @@ -298,7 +298,7 @@ void wilc_chip_sleep_manually(struct wilc *wilc);
>  
>  void wilc_enable_tcp_ack_filter(bool value);
>  int wilc_wlan_get_num_conn_ifcs(struct wilc *wilc);
> -int wilc_mac_xmit(struct sk_buff *skb, struct net_device *dev);
> +netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *dev);
>  
>  void WILC_WFI_p2p_rx(struct net_device *dev, u8 *buff, u32 size);
>  void host_wakeup_notify(struct wilc *wilc);
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: ks7010: fix ks_wlan_start_xmit()'s return type

2018-04-25 Thread Janusz Lisiecki

W dniu 2018-04-24 o 15:18, Luc Van Oostenryck pisze:

The method ndo_start_xmit() is defined as returning an 'netdev_tx_t',
which is a typedef for an enum type, but the implementation in this
driver returns an 'int'.

Fix this by returning 'netdev_tx_t' in this driver too.

Signed-off-by: Luc Van Oostenryck 
---
  drivers/staging/ks7010/ks_wlan_net.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 9078e13b0..57412caac 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -71,7 +71,7 @@ static const struct iw_handler_def ks_wlan_handler_def;
   */
  static int ks_wlan_open(struct net_device *dev);
  static void ks_wlan_tx_timeout(struct net_device *dev);
-static int ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev);
+static netdev_tx_t ks_wlan_start_xmit(struct sk_buff *skb, struct net_device 
*dev);
  static int ks_wlan_close(struct net_device *dev);
  static void ks_wlan_set_multicast_list(struct net_device *dev);
  static struct net_device_stats *ks_wlan_get_stats(struct net_device *dev);
@@ -2772,7 +2772,7 @@ void ks_wlan_tx_timeout(struct net_device *dev)
  }
  
  static

-int ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev)
+netdev_tx_t ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev)
  {
struct ks_wlan_private *priv = netdev_priv(dev);
int ret;
Maybe inside ks_wlan_start_xmit, instead of "return 0;", there should be 
"return NETDEV_TX_OK;" and "return NETDEV_TX_BUSY;" otherwise. It is 
just suggestion.


Br,
Janusz Lisiecki

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: ks7010: fix ks_wlan_start_xmit()'s return type

2018-04-25 Thread Janusz Lisiecki

W dniu 2018-04-24 o 15:18, Luc Van Oostenryck pisze:

The method ndo_start_xmit() is defined as returning an 'netdev_tx_t',
which is a typedef for an enum type, but the implementation in this
driver returns an 'int'.

Fix this by returning 'netdev_tx_t' in this driver too.

Signed-off-by: Luc Van Oostenryck 
---
  drivers/staging/ks7010/ks_wlan_net.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 9078e13b0..57412caac 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -71,7 +71,7 @@ static const struct iw_handler_def ks_wlan_handler_def;
   */
  static int ks_wlan_open(struct net_device *dev);
  static void ks_wlan_tx_timeout(struct net_device *dev);
-static int ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev);
+static netdev_tx_t ks_wlan_start_xmit(struct sk_buff *skb, struct net_device 
*dev);
  static int ks_wlan_close(struct net_device *dev);
  static void ks_wlan_set_multicast_list(struct net_device *dev);
  static struct net_device_stats *ks_wlan_get_stats(struct net_device *dev);
@@ -2772,7 +2772,7 @@ void ks_wlan_tx_timeout(struct net_device *dev)
  }
  
  static

-int ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev)
+netdev_tx_t ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev)
  {
struct ks_wlan_private *priv = netdev_priv(dev);
int ret;
Maybe inside ks_wlan_start_xmit, instead of "return 0;", there should be 
"return NETDEV_TX_OK;" and "return NETDEV_TX_BUSY;" otherwise. It is 
just suggestion.


Br,
Janusz Lisiecki

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 01/21] staging: wilc1000: replace crc7_byte() with inline macro CRC7_BYTE

2018-04-25 Thread Ajay Singh
Replace the function call for crc7_byte() with macro CRC7_BYTE.
crc7_byte() was called in close while(), so replaced it with macro to
avoid extra functional call depth.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_spi.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_spi.c 
b/drivers/staging/wilc1000/wilc_spi.c
index 2cb9f4e..3bb8fec 100644
--- a/drivers/staging/wilc1000/wilc_spi.c
+++ b/drivers/staging/wilc1000/wilc_spi.c
@@ -75,15 +75,12 @@ static const u8 crc7_syndrome_table[256] = {
0x46, 0x4f, 0x54, 0x5d, 0x62, 0x6b, 0x70, 0x79
 };
 
-static u8 crc7_byte(u8 crc, u8 data)
-{
-   return crc7_syndrome_table[(crc << 1) ^ data];
-}
+#define CRC7_BYTE(crc, data) crc7_syndrome_table[(crc << 1) ^ data]
 
 static u8 crc7(u8 crc, const u8 *buffer, u32 len)
 {
while (len--)
-   crc = crc7_byte(crc, *buffer++);
+   crc = CRC7_BYTE(crc, *buffer++);
return crc;
 }
 
-- 
2.7.4


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 05/21] staging: wicl1000: removed the unsed variables in wilc_parse_network_info()

2018-04-25 Thread Ajay Singh
Cleanup patch to remove the unused variables in
wilc_parse_network_info(). The value is assinged to these local
variables but assinged value is not used in that function.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/coreconfigurator.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/staging/wilc1000/coreconfigurator.c 
b/drivers/staging/wilc1000/coreconfigurator.c
index db66b1c..5bc9d78 100644
--- a/drivers/staging/wilc1000/coreconfigurator.c
+++ b/drivers/staging/wilc1000/coreconfigurator.c
@@ -272,10 +272,6 @@ s32 wilc_parse_network_info(u8 *msg_buffer,
 {
struct network_info *network_info = NULL;
u8 msg_type = 0;
-   u8 msg_id = 0;
-   u16 msg_len = 0;
-
-   u16 wid_id = (u16)WID_NIL;
u16 wid_len  = 0;
u8 *wid_val = NULL;
 
@@ -284,9 +280,6 @@ s32 wilc_parse_network_info(u8 *msg_buffer,
if ('N' != msg_type)
return -EFAULT;
 
-   msg_id = msg_buffer[1];
-   msg_len = MAKE_WORD16(msg_buffer[2], msg_buffer[3]);
-   wid_id = MAKE_WORD16(msg_buffer[4], msg_buffer[5]);
wid_len = MAKE_WORD16(msg_buffer[6], msg_buffer[7]);
wid_val = &msg_buffer[8];
 
-- 
2.7.4


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 06/21] staging: wilc1000: remove inner {} in wilc_parse_network_info()

2018-04-25 Thread Ajay Singh
Cleanup patch to remove the unnecessary {/**/} block in
wilc_parse_network_info().

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/coreconfigurator.c | 77 ++---
 1 file changed, 37 insertions(+), 40 deletions(-)

diff --git a/drivers/staging/wilc1000/coreconfigurator.c 
b/drivers/staging/wilc1000/coreconfigurator.c
index 5bc9d78..43b0b21 100644
--- a/drivers/staging/wilc1000/coreconfigurator.c
+++ b/drivers/staging/wilc1000/coreconfigurator.c
@@ -274,6 +274,14 @@ s32 wilc_parse_network_info(u8 *msg_buffer,
u8 msg_type = 0;
u16 wid_len  = 0;
u8 *wid_val = NULL;
+   u8 *msa = NULL;
+   u16 rx_len = 0;
+   u8 *tim_elm = NULL;
+   u8 *ies = NULL;
+   u16 ies_len = 0;
+   u8 index = 0;
+   u32 tsf_lo;
+   u32 tsf_hi;
 
msg_type = msg_buffer[0];
 
@@ -283,60 +291,49 @@ s32 wilc_parse_network_info(u8 *msg_buffer,
wid_len = MAKE_WORD16(msg_buffer[6], msg_buffer[7]);
wid_val = &msg_buffer[8];
 
-   {
-   u8 *msa = NULL;
-   u16 rx_len = 0;
-   u8 *tim_elm = NULL;
-   u8 *ies = NULL;
-   u16 ies_len = 0;
-   u8 index = 0;
-   u32 tsf_lo;
-   u32 tsf_hi;
-
-   network_info = kzalloc(sizeof(*network_info), GFP_KERNEL);
-   if (!network_info)
-   return -ENOMEM;
+   network_info = kzalloc(sizeof(*network_info), GFP_KERNEL);
+   if (!network_info)
+   return -ENOMEM;
 
-   network_info->rssi = wid_val[0];
+   network_info->rssi = wid_val[0];
 
-   msa = &wid_val[1];
+   msa = &wid_val[1];
 
-   rx_len = wid_len - 1;
-   network_info->cap_info = get_cap_info(msa);
-   network_info->tsf_lo = get_beacon_timestamp_lo(msa);
+   rx_len = wid_len - 1;
+   network_info->cap_info = get_cap_info(msa);
+   network_info->tsf_lo = get_beacon_timestamp_lo(msa);
 
-   tsf_lo = get_beacon_timestamp_lo(msa);
-   tsf_hi = get_beacon_timestamp_hi(msa);
+   tsf_lo = get_beacon_timestamp_lo(msa);
+   tsf_hi = get_beacon_timestamp_hi(msa);
 
-   network_info->tsf_hi = tsf_lo | ((u64)tsf_hi << 32);
+   network_info->tsf_hi = tsf_lo | ((u64)tsf_hi << 32);
 
-   get_ssid(msa, network_info->ssid, &network_info->ssid_len);
-   get_BSSID(msa, network_info->bssid);
+   get_ssid(msa, network_info->ssid, &network_info->ssid_len);
+   get_BSSID(msa, network_info->bssid);
 
-   network_info->ch = get_current_channel_802_11n(msa, rx_len
-  + FCS_LEN);
+   network_info->ch = get_current_channel_802_11n(msa, rx_len
+  + FCS_LEN);
 
-   index = MAC_HDR_LEN + TIME_STAMP_LEN;
+   index = MAC_HDR_LEN + TIME_STAMP_LEN;
 
-   network_info->beacon_period = get_beacon_period(msa + index);
+   network_info->beacon_period = get_beacon_period(msa + index);
 
-   index += BEACON_INTERVAL_LEN + CAP_INFO_LEN;
+   index += BEACON_INTERVAL_LEN + CAP_INFO_LEN;
 
-   tim_elm = get_tim_elm(msa, rx_len + FCS_LEN, index);
-   if (tim_elm)
-   network_info->dtim_period = tim_elm[3];
-   ies = &msa[TAG_PARAM_OFFSET];
-   ies_len = rx_len - TAG_PARAM_OFFSET;
+   tim_elm = get_tim_elm(msa, rx_len + FCS_LEN, index);
+   if (tim_elm)
+   network_info->dtim_period = tim_elm[3];
+   ies = &msa[TAG_PARAM_OFFSET];
+   ies_len = rx_len - TAG_PARAM_OFFSET;
 
-   if (ies_len > 0) {
-   network_info->ies = kmemdup(ies, ies_len, GFP_KERNEL);
-   if (!network_info->ies) {
-   kfree(network_info);
-   return -ENOMEM;
-   }
+   if (ies_len > 0) {
+   network_info->ies = kmemdup(ies, ies_len, GFP_KERNEL);
+   if (!network_info->ies) {
+   kfree(network_info);
+   return -ENOMEM;
}
-   network_info->ies_len = ies_len;
}
+   network_info->ies_len = ies_len;
 
*ret_network_info = network_info;
 
-- 
2.7.4


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 11/21] staging: wilc1000: remove unused #define related to MAC status

2018-04-25 Thread Ajay Singh
Remove below #define which are not used in code:

WILC_MAC_STATUS_READY
WILC_MAC_STATUS_CONNECT

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_wlan_if.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h 
b/drivers/staging/wilc1000/wilc_wlan_if.h
index e8a56f4..1982348 100644
--- a/drivers/staging/wilc1000/wilc_wlan_if.h
+++ b/drivers/staging/wilc1000/wilc_wlan_if.h
@@ -49,8 +49,6 @@ struct sdio_cmd53 {
 
 #define WILC_MAC_INDICATE_STATUS   0x1
 #define WILC_MAC_STATUS_INIT   -1
-#define WILC_MAC_STATUS_READY  0
-#define WILC_MAC_STATUS_CONNECT1
 
 #define WILC_MAC_INDICATE_SCAN 0x2
 
-- 
2.7.4


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 07/21] staging: wilc1000: simplified if conditions in spi_data_write()

2018-04-25 Thread Ajay Singh
Cleanup patch to simplify the if conditions logic in spi_data_write().

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_spi.c | 23 +--
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_spi.c 
b/drivers/staging/wilc1000/wilc_spi.c
index ac8df38b..2aaa5fd 100644
--- a/drivers/staging/wilc1000/wilc_spi.c
+++ b/drivers/staging/wilc1000/wilc_spi.c
@@ -614,28 +614,23 @@ static int spi_data_write(struct wilc *wilc, u8 *b, u32 
sz)
 */
ix = 0;
do {
-   if (sz <= DATA_PKT_SZ)
+   if (sz <= DATA_PKT_SZ) {
nbytes = sz;
-   else
+   order = 0x3;
+   } else {
nbytes = DATA_PKT_SZ;
+   if (ix == 0)
+   order = 0x1;
+   else
+   order = 0x02;
+   }
 
/*
 * Write command
 */
cmd = 0xf0;
-   if (ix == 0) {
-   if (sz <= DATA_PKT_SZ)
-
-   order = 0x3;
-   else
-   order = 0x1;
-   } else {
-   if (sz <= DATA_PKT_SZ)
-   order = 0x3;
-   else
-   order = 0x2;
-   }
cmd |= order;
+
if (wilc_spi_tx(wilc, &cmd, 1)) {
dev_err(&spi->dev,
"Failed data block cmd write, bus error...\n");
-- 
2.7.4


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 02/21] staging: wilc1000: align the #define in wilc_spi file

2018-04-25 Thread Ajay Singh
Cleanup patch to align the #define used in wilc_spi.c file by adding the
tabs.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_spi.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_spi.c 
b/drivers/staging/wilc1000/wilc_spi.c
index 3bb8fec..65c 100644
--- a/drivers/staging/wilc1000/wilc_spi.c
+++ b/drivers/staging/wilc1000/wilc_spi.c
@@ -92,29 +92,29 @@ static u8 crc7(u8 crc, const u8 *buffer, u32 len)
 
 #define CMD_DMA_WRITE  0xc1
 #define CMD_DMA_READ   0xc2
-#define CMD_INTERNAL_WRITE 0xc3
-#define CMD_INTERNAL_READ  0xc4
+#define CMD_INTERNAL_WRITE 0xc3
+#define CMD_INTERNAL_READ  0xc4
 #define CMD_TERMINATE  0xc5
-#define CMD_REPEAT 0xc6
-#define CMD_DMA_EXT_WRITE  0xc7
-#define CMD_DMA_EXT_READ   0xc8
+#define CMD_REPEAT 0xc6
+#define CMD_DMA_EXT_WRITE  0xc7
+#define CMD_DMA_EXT_READ   0xc8
 #define CMD_SINGLE_WRITE   0xc9
-#define CMD_SINGLE_READ0xca
-#define CMD_RESET  0xcf
+#define CMD_SINGLE_READ0xca
+#define CMD_RESET  0xcf
 
-#define N_OK   1
-#define N_FAIL 0
-#define N_RESET-1
-#define N_RETRY-2
+#define N_OK   1
+#define N_FAIL 0
+#define N_RESET-1
+#define N_RETRY-2
 
 #define DATA_PKT_SZ_256256
-#define DATA_PKT_SZ_512512
+#define DATA_PKT_SZ_512512
 #define DATA_PKT_SZ_1K 1024
 #define DATA_PKT_SZ_4K (4 * 1024)
 #define DATA_PKT_SZ_8K (8 * 1024)
-#define DATA_PKT_SZDATA_PKT_SZ_8K
+#define DATA_PKT_SZDATA_PKT_SZ_8K
 
-#define USE_SPI_DMA 0
+#define USE_SPI_DMA0
 
 static int wilc_bus_probe(struct spi_device *spi)
 {
-- 
2.7.4


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 04/21] staging: wilc1000: remove 'cmd' variable in wilc_spi functions

2018-04-25 Thread Ajay Singh
Cleanup patch to remove the 'cmd' variable in wilc_spi.c. Instead of
using cmd now passing the command directly.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_spi.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_spi.c 
b/drivers/staging/wilc1000/wilc_spi.c
index c980d3b..ac8df38b 100644
--- a/drivers/staging/wilc1000/wilc_spi.c
+++ b/drivers/staging/wilc1000/wilc_spi.c
@@ -742,7 +742,6 @@ static int wilc_spi_write(struct wilc *wilc, u32 addr, u8 
*buf, u32 size)
 {
struct spi_device *spi = to_spi_device(wilc->dev);
int result;
-   u8 cmd = CMD_DMA_EXT_WRITE;
 
/*
 * has to be greated than 4
@@ -750,7 +749,7 @@ static int wilc_spi_write(struct wilc *wilc, u32 addr, u8 
*buf, u32 size)
if (size <= 4)
return 0;
 
-   result = spi_cmd_complete(wilc, cmd, addr, NULL, size, 0);
+   result = spi_cmd_complete(wilc, CMD_DMA_EXT_WRITE, addr, NULL, size, 0);
if (result != N_OK) {
dev_err(&spi->dev,
"Failed cmd, write block (%08x)...\n", addr);
@@ -795,13 +794,12 @@ static int wilc_spi_read_reg(struct wilc *wilc, u32 addr, 
u32 *data)
 static int wilc_spi_read(struct wilc *wilc, u32 addr, u8 *buf, u32 size)
 {
struct spi_device *spi = to_spi_device(wilc->dev);
-   u8 cmd = CMD_DMA_EXT_READ;
int result;
 
if (size <= 4)
return 0;
 
-   result = spi_cmd_complete(wilc, cmd, addr, buf, size, 0);
+   result = spi_cmd_complete(wilc, CMD_DMA_EXT_READ, addr, buf, size, 0);
if (result != N_OK) {
dev_err(&spi->dev, "Failed cmd, read block (%08x)...\n", addr);
return 0;
-- 
2.7.4


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 09/21] staging: wilc1000: remove unsed typedef wilc_debug_func

2018-04-25 Thread Ajay Singh
Cleanup patch to remove the unused typedef and also removed the
unecessary comment about that typedef.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_wlan.h | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wlan.h 
b/drivers/staging/wilc1000/wilc_wlan.h
index 671e499..a5b9c68 100644
--- a/drivers/staging/wilc1000/wilc_wlan.h
+++ b/drivers/staging/wilc1000/wilc_wlan.h
@@ -202,13 +202,6 @@
 
 /
  *
- *  Debug Type
- *
- /
-typedef void (*wilc_debug_func)(u32, char *, ...);
-
-/
- *
  *  Tx/Rx Queue Structure
  *
  /
-- 
2.7.4


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 03/21] staging: wilc1000: remove unnecessary assingment from 'if' conditions

2018-04-25 Thread Ajay Singh
Cleanup patch to remove the unnecessary use of '==' check used in if
conditions.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_sdio.c | 12 ++--
 drivers/staging/wilc1000/wilc_spi.c  |  6 +++---
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_sdio.c 
b/drivers/staging/wilc1000/wilc_sdio.c
index 087ad42..54121c3 100644
--- a/drivers/staging/wilc1000/wilc_sdio.c
+++ b/drivers/staging/wilc1000/wilc_sdio.c
@@ -885,13 +885,13 @@ static int sdio_clear_int_ext(struct wilc *wilc, u32 val)
reg = 0;
}
/* select VMM table 0 */
-   if ((val & SEL_VMM_TBL0) == SEL_VMM_TBL0)
+   if (val & SEL_VMM_TBL0)
reg |= BIT(5);
/* select VMM table 1 */
-   if ((val & SEL_VMM_TBL1) == SEL_VMM_TBL1)
+   if (val & SEL_VMM_TBL1)
reg |= BIT(6);
/* enable VMM */
-   if ((val & EN_VMM) == EN_VMM)
+   if (val & EN_VMM)
reg |= BIT(7);
if (reg) {
struct sdio_cmd52 cmd;
@@ -961,13 +961,13 @@ static int sdio_clear_int_ext(struct wilc *wilc, u32 val)
 
vmm_ctl = 0;
/* select VMM table 0 */
-   if ((val & SEL_VMM_TBL0) == SEL_VMM_TBL0)
+   if (val & SEL_VMM_TBL0)
vmm_ctl |= BIT(0);
/* select VMM table 1 */
-   if ((val & SEL_VMM_TBL1) == SEL_VMM_TBL1)
+   if (val & SEL_VMM_TBL1)
vmm_ctl |= BIT(1);
/* enable VMM */
-   if ((val & EN_VMM) == EN_VMM)
+   if (val & EN_VMM)
vmm_ctl |= BIT(2);
 
if (vmm_ctl) {
diff --git a/drivers/staging/wilc1000/wilc_spi.c 
b/drivers/staging/wilc1000/wilc_spi.c
index 65c..c980d3b 100644
--- a/drivers/staging/wilc1000/wilc_spi.c
+++ b/drivers/staging/wilc1000/wilc_spi.c
@@ -1023,10 +1023,10 @@ static int wilc_spi_clear_int_ext(struct wilc *wilc, 
u32 val)
 
tbl_ctl = 0;
/* select VMM table 0 */
-   if ((val & SEL_VMM_TBL0) == SEL_VMM_TBL0)
+   if (val & SEL_VMM_TBL0)
tbl_ctl |= BIT(0);
/* select VMM table 1 */
-   if ((val & SEL_VMM_TBL1) == SEL_VMM_TBL1)
+   if (val & SEL_VMM_TBL1)
tbl_ctl |= BIT(1);
 
ret = wilc_spi_write_reg(wilc, WILC_VMM_TBL_CTL, tbl_ctl);
@@ -1035,7 +1035,7 @@ static int wilc_spi_clear_int_ext(struct wilc *wilc, u32 
val)
return ret;
}
 
-   if ((val & EN_VMM) == EN_VMM) {
+   if (val & EN_VMM) {
/*
 * enable vmm transfer.
 */
-- 
2.7.4


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 00/21] staging: wilc1000: remove unused code and reorder functions

2018-04-25 Thread Ajay Singh
This patch series contains fixes to remove the unused code. It also has patches
to reorganize the function and simplify the function logic.

Ajay Singh (21):
  staging: wilc1000: replace crc7_byte() with inline macro CRC7_BYTE
  staging: wilc1000: align the #define in wilc_spi file
  staging: wilc1000: remove unnecessary assingment from 'if' conditions
  staging: wilc1000: remove 'cmd' variable in wilc_spi functions
  staging: wicl1000: removed the unsed variables in
wilc_parse_network_info()
  staging: wilc1000: remove inner {} in wilc_parse_network_info()
  staging: wilc1000: simplified if conditions in spi_data_write()
  staging: wilc1000: remove unused variable scan_while_connected
  staging: wilc1000: remove unsed typedef wilc_debug_func
  staging: wilc1000: remove used #define HIF_SDIO_GPIO_IRQ
  staging: wilc1000: remove unused #define related to MAC status
  staging: wilc1000: rename mac status macros and moved related #define
together
  staging: wilc1000: rename WILC_WFI_stats to avoid uppercase
  staging: wilc1000: rename num_reg_frame macro to have uppercase in
macro name
  staging: wilc1000: rename wlan init and deinit function prefixed with
wil1000
  staging: wilc1000: remove unused elements in 'wilc_priv' struct
  staging: wilc1000: remove unused enum 'stats_flags'
  staging: wilc1000: rename P2P_LISTEN_STATE variable to use lowercase
  staging: wilc1000: remove inner block '{}' in handle_remain_on_chan()
  staging: wilc1000: change function to static in linux_wlan
  staging: wilc1000: reorder functions to avoid forward declaration in
linux_wlan

 drivers/staging/wilc1000/coreconfigurator.c   |  84 +++
 drivers/staging/wilc1000/host_interface.c |  64 
 drivers/staging/wilc1000/linux_wlan.c | 122 ++
 drivers/staging/wilc1000/wilc_sdio.c  |  12 +--
 drivers/staging/wilc1000/wilc_spi.c   |  70 ++---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |   2 +-
 drivers/staging/wilc1000/wilc_wfi_netdevice.h |  23 +---
 drivers/staging/wilc1000/wilc_wlan.h  |   7 --
 drivers/staging/wilc1000/wilc_wlan_if.h   |  11 +-
 9 files changed, 158 insertions(+), 237 deletions(-)

-- 
2.7.4


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 13/21] staging: wilc1000: rename WILC_WFI_stats to avoid uppercase

2018-04-25 Thread Ajay Singh
Cleanup patch to have struct name as per linux coding style.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_wfi_netdevice.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h 
b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
index 07167637..35bc4df 100644
--- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h
+++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
@@ -50,7 +50,7 @@ enum stats_flags {
WILC_WFI_TX_PKT = BIT(1),
 };
 
-struct WILC_WFI_stats {
+struct wilc_wfi_stats {
unsigned long rx_packets;
unsigned long tx_packets;
unsigned long rx_bytes;
@@ -119,7 +119,7 @@ struct wilc_priv {
struct napi_struct napi;
struct host_if_drv *hif_drv;
struct host_if_pmkid_attr pmkid_list;
-   struct WILC_WFI_stats netstats;
+   struct wilc_wfi_stats netstats;
u8 wep_key[4][WLAN_KEY_LEN_WEP104];
u8 wep_key_len[4];
/* The real interface that the monitor is on */
-- 
2.7.4


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 14/21] staging: wilc1000: rename num_reg_frame macro to have uppercase in macro name

2018-04-25 Thread Ajay Singh
Cleanup patch to follow name as per linux coding style.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_wfi_netdevice.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h 
b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
index 35bc4df..4bc1899 100644
--- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h
+++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
@@ -65,7 +65,7 @@ struct wilc_wfi_stats {
  * packets in and out, so there is place for a packet
  */
 
-#define num_reg_frame 2
+#define NUM_REG_FRAME 2
 
 struct wilc_wfi_key {
u8 *key;
@@ -146,7 +146,7 @@ struct wilc_vif {
u8 iftype;
int monitor_flag;
int mac_opened;
-   struct frame_reg frame_reg[num_reg_frame];
+   struct frame_reg frame_reg[NUM_REG_FRAME];
struct net_device_stats netstats;
struct wilc *wilc;
u8 src_addr[ETH_ALEN];
-- 
2.7.4


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 17/21] staging: wilc1000: remove unused enum 'stats_flags'

2018-04-25 Thread Ajay Singh
Cleanup patch to remove the unused enum.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_wfi_netdevice.h | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h 
b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
index e6489fa..5f4dbff 100644
--- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h
+++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
@@ -45,11 +45,6 @@
 #define FLOW_CONTROL_LOWER_THRESHOLD   128
 #define FLOW_CONTROL_UPPER_THRESHOLD   256
 
-enum stats_flags {
-   WILC_WFI_RX_PKT = BIT(0),
-   WILC_WFI_TX_PKT = BIT(1),
-};
-
 struct wilc_wfi_stats {
unsigned long rx_packets;
unsigned long tx_packets;
-- 
2.7.4


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 10/21] staging: wilc1000: remove used #define HIF_SDIO_GPIO_IRQ

2018-04-25 Thread Ajay Singh
Cleanup patch to remove unused #define.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_wlan_if.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h 
b/drivers/staging/wilc1000/wilc_wlan_if.h
index eb8d819..e8a56f4 100644
--- a/drivers/staging/wilc1000/wilc_wlan_if.h
+++ b/drivers/staging/wilc1000/wilc_wlan_if.h
@@ -21,7 +21,6 @@
 
 #define HIF_SDIO   (0)
 #define HIF_SPIBIT(0)
-#define HIF_SDIO_GPIO_IRQ  BIT(2)
 
 /
  *
-- 
2.7.4


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 12/21] staging: wilc1000: rename mac status macros and moved related #define together

2018-04-25 Thread Ajay Singh
Rename the mac status macro to follow the same naming style. Also move
them to keep together.

Renamed like below

>From > To

WILC_MAC_STATUS_INIT -> MAC_STATUS_INIT
MAC_CONNECTED > MAC_STATUS_CONNECTED
MAC_DISCONNECTED -> MAC_STATUS_DISCONNECTED

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 22 +++---
 drivers/staging/wilc1000/linux_wlan.c |  4 ++--
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |  2 +-
 drivers/staging/wilc1000/wilc_wlan_if.h   |  8 
 4 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 1b282b0..758dc44 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -1135,7 +1135,7 @@ static s32 handle_connect(struct wilc_vif *vif,
 
conn_attr->result(CONN_DISCONN_EVENT_CONN_RESP,
   &conn_info,
-  MAC_DISCONNECTED,
+  
MAC_STATUS_DISCONNECTED,
   NULL,
   conn_attr->arg);
hif_drv->hif_state = HOST_IF_IDLE;
@@ -1193,7 +1193,7 @@ static s32 handle_connect_timeout(struct wilc_vif *vif)
 
hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_CONN_RESP,
  &info,
- MAC_DISCONNECTED,
+ MAC_STATUS_DISCONNECTED,
  NULL,
  hif_drv->usr_conn_req.arg);
 
@@ -1321,7 +1321,7 @@ static inline void host_int_parse_assoc_resp_info(struct 
wilc_vif *vif,
 
memset(&conn_info, 0, sizeof(struct connect_info));
 
-   if (mac_status == MAC_CONNECTED) {
+   if (mac_status == MAC_STATUS_CONNECTED) {
u32 rcvd_assoc_resp_info_len;
 
memset(rcv_assoc_resp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
@@ -1357,20 +1357,20 @@ static inline void 
host_int_parse_assoc_resp_info(struct wilc_vif *vif,
}
}
 
-   if (mac_status == MAC_CONNECTED &&
+   if (mac_status == MAC_STATUS_CONNECTED &&
conn_info.status != SUCCESSFUL_STATUSCODE) {
netdev_err(vif->ndev,
-  "Received MAC status is MAC_CONNECTED while the 
received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
+  "Received MAC status is MAC_STATUS_CONNECTED while 
the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
eth_zero_addr(wilc_connected_ssid);
-   } else if (mac_status == MAC_DISCONNECTED){
-   netdev_err(vif->ndev, "Received MAC status is 
MAC_DISCONNECTED\n");
+   } else if (mac_status == MAC_STATUS_DISCONNECTED){
+   netdev_err(vif->ndev, "Received MAC status is 
MAC_STATUS_DISCONNECTED\n");
eth_zero_addr(wilc_connected_ssid);
}
 
if (hif_drv->usr_conn_req.bssid) {
memcpy(conn_info.bssid, hif_drv->usr_conn_req.bssid, 6);
 
-   if (mac_status == MAC_CONNECTED &&
+   if (mac_status == MAC_STATUS_CONNECTED &&
conn_info.status == SUCCESSFUL_STATUSCODE) {
memcpy(hif_drv->assoc_bssid,
   hif_drv->usr_conn_req.bssid, ETH_ALEN);
@@ -1390,7 +1390,7 @@ static inline void host_int_parse_assoc_resp_info(struct 
wilc_vif *vif,
  &conn_info, mac_status, NULL,
  hif_drv->usr_conn_req.arg);
 
-   if (mac_status == MAC_CONNECTED &&
+   if (mac_status == MAC_STATUS_CONNECTED &&
conn_info.status == SUCCESSFUL_STATUSCODE) {
wilc_set_power_mgmt(vif, 0, 0);
 
@@ -1498,10 +1498,10 @@ static s32 handle_rcvd_gnrl_async_info(struct wilc_vif 
*vif,
mac_status_additional_info = rcvd_info->buffer[9];
if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
host_int_parse_assoc_resp_info(vif, mac_status);
-   } else if ((mac_status == MAC_DISCONNECTED) &&
+   } else if ((mac_status == MAC_STATUS_DISCONNECTED) &&
   (hif_drv->hif_state == HOST_IF_CONNECTED)) {
host_int_handle_disconnect(vif);
-   } else if ((mac_status == MAC_DISCONNECTED) &&
+   } else if ((mac_status == MAC_STATUS_DISCONNECTED) &&
   (hif_drv->usr_scan_req.scan_result)) {
del_timer(&hif_drv

[PATCH v2 15/21] staging: wilc1000: rename wlan init and deinit function prefixed with wil1000

2018-04-25 Thread Ajay Singh
Rename wilc1000_wlan_init() & wilc1000_wlan_deinit() function to avoid
unecessary 'wilc1000' prefix in function to be inline with other
function naming convension.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/linux_wlan.c | 10 +-
 drivers/staging/wilc1000/wilc_wfi_netdevice.h |  4 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index f09d6a8..b6a8165 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -604,7 +604,7 @@ static int linux_wlan_init_test_config(struct net_device 
*dev,
return -1;
 }
 
-void wilc1000_wlan_deinit(struct net_device *dev)
+void wilc_wlan_deinitialize(struct net_device *dev)
 {
struct wilc_vif *vif;
struct wilc *wl;
@@ -719,7 +719,7 @@ static void wlan_deinitialize_threads(struct net_device 
*dev)
}
 }
 
-int wilc1000_wlan_init(struct net_device *dev, struct wilc_vif *vif)
+int wilc_wlan_initialize(struct net_device *dev, struct wilc_vif *vif)
 {
int ret = 0;
struct wilc *wl = vif->wilc;
@@ -846,7 +846,7 @@ static int wilc_mac_open(struct net_device *ndev)
if (ret < 0)
return ret;
 
-   ret = wilc1000_wlan_init(ndev, vif);
+   ret = wilc_wlan_initialize(ndev, vif);
if (ret < 0) {
wilc_deinit_host_int(ndev);
return ret;
@@ -869,7 +869,7 @@ static int wilc_mac_open(struct net_device *ndev)
if (!is_valid_ether_addr(ndev->dev_addr)) {
netdev_err(ndev, "Wrong MAC address\n");
wilc_deinit_host_int(ndev);
-   wilc1000_wlan_deinit(ndev);
+   wilc_wlan_deinitialize(ndev);
return -EINVAL;
}
 
@@ -1038,7 +1038,7 @@ static int wilc_mac_close(struct net_device *ndev)
if (wl->open_ifcs == 0) {
netdev_dbg(ndev, "Deinitializing wilc1000\n");
wl->close = 1;
-   wilc1000_wlan_deinit(ndev);
+   wilc_wlan_deinitialize(ndev);
WILC_WFI_deinit_mon_interface();
}
 
diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h 
b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
index 4bc1899..0a91468 100644
--- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h
+++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
@@ -218,14 +218,14 @@ struct WILC_WFI_mon_priv {
struct net_device *real_ndev;
 };
 
-int wilc1000_wlan_init(struct net_device *dev, struct wilc_vif *vif);
+int wilc_wlan_initialize(struct net_device *dev, struct wilc_vif *vif);
 
 void wilc_frmw_to_linux(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset);
 void wilc_mac_indicate(struct wilc *wilc, int flag);
 void wilc_netdev_cleanup(struct wilc *wilc);
 int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
 int gpio, const struct wilc_hif_func *ops);
-void wilc1000_wlan_deinit(struct net_device *dev);
+void wilc_wlan_deinitialize(struct net_device *dev);
 void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size);
 int wilc_wlan_get_firmware(struct net_device *dev);
 int wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid, u8 mode);
-- 
2.7.4


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 08/21] staging: wilc1000: remove unused variable scan_while_connected

2018-04-25 Thread Ajay Singh
Cleanup patch to remove the unused variable.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 17 -
 1 file changed, 17 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 12414f4..1b282b0 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -242,8 +242,6 @@ u8 
wilc_multicast_mac_addr_list[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
 
 static u8 rcv_assoc_resp[MAX_ASSOC_RESP_FRAME_SIZE];
 
-static bool scan_while_connected;
-
 static s8 rssi;
 static u8 set_ip[2][4];
 static u8 get_ip[2][4];
@@ -839,11 +837,6 @@ static s32 handle_scan(struct wilc_vif *vif, struct 
scan_attr *scan_info)
wid_list[index].val = (s8 *)&scan_info->src;
index++;
 
-   if (hif_drv->hif_state == HOST_IF_CONNECTED)
-   scan_while_connected = true;
-   else if (hif_drv->hif_state == HOST_IF_IDLE)
-   scan_while_connected = false;
-
result = wilc_send_config_pkt(vif, SET_CFG, wid_list,
  index,
  wilc_get_vif_idx(vif));
@@ -1182,8 +1175,6 @@ static s32 handle_connect_timeout(struct wilc_vif *vif)
 
hif_drv->hif_state = HOST_IF_IDLE;
 
-   scan_while_connected = false;
-
memset(&info, 0, sizeof(struct connect_info));
 
if (hif_drv->usr_conn_req.conn_result) {
@@ -1410,7 +1401,6 @@ static inline void host_int_parse_assoc_resp_info(struct 
wilc_vif *vif,
  jiffies + msecs_to_jiffies(1));
} else {
hif_drv->hif_state = HOST_IF_IDLE;
-   scan_while_connected = false;
}
 
kfree(conn_info.resp_ies);
@@ -1452,7 +1442,6 @@ static inline void host_int_handle_disconnect(struct 
wilc_vif *vif)
 
host_int_free_user_conn_req(hif_drv);
hif_drv->hif_state = HOST_IF_IDLE;
-   scan_while_connected = false;
 }
 
 static s32 handle_rcvd_gnrl_async_info(struct wilc_vif *vif,
@@ -1830,8 +1819,6 @@ static void handle_disconnect(struct wilc_vif *vif)
netdev_err(vif->ndev, "conn_result = NULL\n");
}
 
-   scan_while_connected = false;
-
hif_drv->hif_state = HOST_IF_IDLE;
 
eth_zero_addr(hif_drv->assoc_bssid);
@@ -3339,8 +3326,6 @@ int wilc_init(struct net_device *dev, struct host_if_drv 
**hif_drv_handler)
vif = netdev_priv(dev);
wilc = vif->wilc;
 
-   scan_while_connected = false;
-
init_completion(&hif_wait_response);
 
hif_drv  = kzalloc(sizeof(*hif_drv), GFP_KERNEL);
@@ -3436,8 +3421,6 @@ int wilc_deinit(struct wilc_vif *vif)
 
hif_drv->hif_state = HOST_IF_IDLE;
 
-   scan_while_connected = false;
-
memset(&msg, 0, sizeof(struct host_if_msg));
 
if (clients_count == 1) {
-- 
2.7.4


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 18/21] staging: wilc1000: rename P2P_LISTEN_STATE variable to use lowercase

2018-04-25 Thread Ajay Singh
Rename P2P_LISTEN_STATE variable to avoid using uppercase for variable
name to follow linux coding style.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 758dc44..6eafb98 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -229,7 +229,7 @@ struct join_bss_param {
 
 static struct host_if_drv *terminated_handle;
 bool wilc_optaining_ip;
-static u8 P2P_LISTEN_STATE;
+static u8 p2p_listen_state;
 static struct workqueue_struct *hif_workqueue;
 static struct completion hif_thread_comp;
 static struct completion hif_driver_comp;
@@ -2245,7 +2245,7 @@ static int handle_remain_on_chan(struct wilc_vif *vif,
 
 error:
{
-   P2P_LISTEN_STATE = 1;
+   p2p_listen_state = 1;
hif_drv->remain_on_ch_timer_vif = vif;
mod_timer(&hif_drv->remain_on_ch_timer,
  jiffies +
@@ -2301,7 +2301,7 @@ static u32 handle_listen_state_expired(struct wilc_vif 
*vif,
s32 result = 0;
struct host_if_drv *hif_drv = vif->hif_drv;
 
-   if (P2P_LISTEN_STATE) {
+   if (p2p_listen_state) {
remain_on_chan_flag = false;
wid.id = (u16)WID_REMAIN_ON_CHAN;
wid.type = WID_STR;
@@ -2326,7 +2326,7 @@ static u32 handle_listen_state_expired(struct wilc_vif 
*vif,
hif_drv->remain_on_ch.expired(hif_drv->remain_on_ch.arg,
  hif_remain_ch->id);
}
-   P2P_LISTEN_STATE = 0;
+   p2p_listen_state = 0;
} else {
netdev_dbg(vif->ndev, "Not in listen state\n");
result = -EFAULT;
-- 
2.7.4


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 19/21] staging: wilc1000: remove inner block '{}' in handle_remain_on_chan()

2018-04-25 Thread Ajay Singh
Cleanup patch to remove unnecessary inner block {\* *\} in
handle_remain_on_chan().

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 19 ---
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 6eafb98..2f3e20d 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -2244,19 +2244,16 @@ static int handle_remain_on_chan(struct wilc_vif *vif,
netdev_err(vif->ndev, "Failed to set remain on channel\n");
 
 error:
-   {
-   p2p_listen_state = 1;
-   hif_drv->remain_on_ch_timer_vif = vif;
-   mod_timer(&hif_drv->remain_on_ch_timer,
- jiffies +
- msecs_to_jiffies(hif_remain_ch->duration));
+   p2p_listen_state = 1;
+   hif_drv->remain_on_ch_timer_vif = vif;
+   mod_timer(&hif_drv->remain_on_ch_timer,
+ jiffies + msecs_to_jiffies(hif_remain_ch->duration));
 
-   if (hif_drv->remain_on_ch.ready)
-   hif_drv->remain_on_ch.ready(hif_drv->remain_on_ch.arg);
+   if (hif_drv->remain_on_ch.ready)
+   hif_drv->remain_on_ch.ready(hif_drv->remain_on_ch.arg);
 
-   if (hif_drv->remain_on_ch_pending)
-   hif_drv->remain_on_ch_pending = 0;
-   }
+   if (hif_drv->remain_on_ch_pending)
+   hif_drv->remain_on_ch_pending = 0;
 
return result;
 }
-- 
2.7.4


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 21/21] staging: wilc1000: reorder functions to avoid forward declaration in linux_wlan

2018-04-25 Thread Ajay Singh
Reorder the functions in linux_wlan.c file to avoid having explicit
declaration of static functions. Forward declaration is avoided
with the help of reordering the function.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/linux_wlan.c | 106 +++---
 1 file changed, 46 insertions(+), 60 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 1643166..35e30c5 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -24,35 +24,8 @@
 #include 
 #include 
 
-static int dev_state_ev_handler(struct notifier_block *this,
-   unsigned long event, void *ptr);
-
-static struct notifier_block g_dev_notifier = {
-   .notifier_call = dev_state_ev_handler
-};
-
-static int wlan_deinit_locks(struct net_device *dev);
-static void wlan_deinitialize_threads(struct net_device *dev);
-
-static void linux_wlan_tx_complete(void *priv, int status);
-static int  mac_init_fn(struct net_device *ndev);
-static struct net_device_stats *mac_stats(struct net_device *dev);
-static int wilc_mac_open(struct net_device *ndev);
-static int wilc_mac_close(struct net_device *ndev);
-static void wilc_set_multicast_list(struct net_device *dev);
-
 bool wilc_enable_ps = true;
 
-static const struct net_device_ops wilc_netdev_ops = {
-   .ndo_init = mac_init_fn,
-   .ndo_open = wilc_mac_open,
-   .ndo_stop = wilc_mac_close,
-   .ndo_start_xmit = wilc_mac_xmit,
-   .ndo_get_stats = mac_stats,
-   .ndo_set_rx_mode  = wilc_set_multicast_list,
-
-};
-
 static int dev_state_ev_handler(struct notifier_block *this,
unsigned long event, void *ptr)
 {
@@ -604,6 +577,39 @@ static int linux_wlan_init_test_config(struct net_device 
*dev,
return -1;
 }
 
+static int wlan_deinit_locks(struct net_device *dev)
+{
+   struct wilc_vif *vif;
+   struct wilc *wilc;
+
+   vif = netdev_priv(dev);
+   wilc = vif->wilc;
+
+   mutex_destroy(&wilc->hif_cs);
+   mutex_destroy(&wilc->rxq_cs);
+   mutex_destroy(&wilc->txq_add_to_head_cs);
+
+   return 0;
+}
+
+static void wlan_deinitialize_threads(struct net_device *dev)
+{
+   struct wilc_vif *vif;
+   struct wilc *wl;
+
+   vif = netdev_priv(dev);
+   wl = vif->wilc;
+
+   wl->close = 1;
+
+   complete(&wl->txq_event);
+
+   if (wl->txq_thread) {
+   kthread_stop(wl->txq_thread);
+   wl->txq_thread = NULL;
+   }
+}
+
 static void wilc_wlan_deinitialize(struct net_device *dev)
 {
struct wilc_vif *vif;
@@ -666,21 +672,6 @@ static int wlan_init_locks(struct net_device *dev)
return 0;
 }
 
-static int wlan_deinit_locks(struct net_device *dev)
-{
-   struct wilc_vif *vif;
-   struct wilc *wilc;
-
-   vif = netdev_priv(dev);
-   wilc = vif->wilc;
-
-   mutex_destroy(&wilc->hif_cs);
-   mutex_destroy(&wilc->rxq_cs);
-   mutex_destroy(&wilc->txq_add_to_head_cs);
-
-   return 0;
-}
-
 static int wlan_initialize_threads(struct net_device *dev)
 {
struct wilc_vif *vif;
@@ -701,24 +692,6 @@ static int wlan_initialize_threads(struct net_device *dev)
return 0;
 }
 
-static void wlan_deinitialize_threads(struct net_device *dev)
-{
-   struct wilc_vif *vif;
-   struct wilc *wl;
-
-   vif = netdev_priv(dev);
-   wl = vif->wilc;
-
-   wl->close = 1;
-
-   complete(&wl->txq_event);
-
-   if (wl->txq_thread) {
-   kthread_stop(wl->txq_thread);
-   wl->txq_thread = NULL;
-   }
-}
-
 static int wilc_wlan_initialize(struct net_device *dev, struct wilc_vif *vif)
 {
int ret = 0;
@@ -1106,6 +1079,10 @@ void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 
size)
wilc_wfi_p2p_rx(wilc->vif[1]->ndev, buff, size);
 }
 
+static struct notifier_block g_dev_notifier = {
+   .notifier_call = dev_state_ev_handler
+};
+
 void wilc_netdev_cleanup(struct wilc *wilc)
 {
int i;
@@ -1135,6 +1112,15 @@ void wilc_netdev_cleanup(struct wilc *wilc)
 }
 EXPORT_SYMBOL_GPL(wilc_netdev_cleanup);
 
+static const struct net_device_ops wilc_netdev_ops = {
+   .ndo_init = mac_init_fn,
+   .ndo_open = wilc_mac_open,
+   .ndo_stop = wilc_mac_close,
+   .ndo_start_xmit = wilc_mac_xmit,
+   .ndo_get_stats = mac_stats,
+   .ndo_set_rx_mode  = wilc_set_multicast_list,
+};
+
 int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
 int gpio, const struct wilc_hif_func *ops)
 {
-- 
2.7.4


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 20/21] staging: wilc1000: change function to static in linux_wlan

2018-04-25 Thread Ajay Singh
Defined function as static which are used only in single file. And also removed
their declaration from header file.
Below function are changed to static
wilc_wlan_initialize()
wilc_wlan_deinitialize()
wilc_wlan_get_firmware()

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/linux_wlan.c | 6 +++---
 drivers/staging/wilc1000/wilc_wfi_netdevice.h | 4 
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index b6a8165..1643166 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -315,7 +315,7 @@ static int linux_wlan_txq_task(void *vp)
return 0;
 }
 
-int wilc_wlan_get_firmware(struct net_device *dev)
+static int wilc_wlan_get_firmware(struct net_device *dev)
 {
struct wilc_vif *vif;
struct wilc *wilc;
@@ -604,7 +604,7 @@ static int linux_wlan_init_test_config(struct net_device 
*dev,
return -1;
 }
 
-void wilc_wlan_deinitialize(struct net_device *dev)
+static void wilc_wlan_deinitialize(struct net_device *dev)
 {
struct wilc_vif *vif;
struct wilc *wl;
@@ -719,7 +719,7 @@ static void wlan_deinitialize_threads(struct net_device 
*dev)
}
 }
 
-int wilc_wlan_initialize(struct net_device *dev, struct wilc_vif *vif)
+static int wilc_wlan_initialize(struct net_device *dev, struct wilc_vif *vif)
 {
int ret = 0;
struct wilc *wl = vif->wilc;
diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h 
b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
index 5f4dbff..ab94d78f 100644
--- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h
+++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
@@ -207,16 +207,12 @@ struct WILC_WFI_mon_priv {
struct net_device *real_ndev;
 };
 
-int wilc_wlan_initialize(struct net_device *dev, struct wilc_vif *vif);
-
 void wilc_frmw_to_linux(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset);
 void wilc_mac_indicate(struct wilc *wilc, int flag);
 void wilc_netdev_cleanup(struct wilc *wilc);
 int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
 int gpio, const struct wilc_hif_func *ops);
-void wilc_wlan_deinitialize(struct net_device *dev);
 void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size);
-int wilc_wlan_get_firmware(struct net_device *dev);
 int wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid, u8 mode);
 
 #endif
-- 
2.7.4


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 16/21] staging: wilc1000: remove unused elements in 'wilc_priv' struct

2018-04-25 Thread Ajay Singh
Cleanup patch to remove unused element from 'wilc_priv' structure.

Below elements are removed in 'wilc_priv' structure:

struct WILC_WFI_packet *ppool;
struct WILC_WFI_packet *rx_queue; /* List of incoming packets */
int rx_int_enabled;
int tx_packetlen;
u8 *tx_packetdata;
struct napi_struct napi;

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_wfi_netdevice.h | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h 
b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
index 0a91468..e6489fa 100644
--- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h
+++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
@@ -108,15 +108,9 @@ struct wilc_priv {
struct net_device_stats stats;
u8 monitor_flag;
int status;
-   struct WILC_WFI_packet *ppool;
-   struct WILC_WFI_packet *rx_queue; /* List of incoming packets */
-   int rx_int_enabled;
-   int tx_packetlen;
-   u8 *tx_packetdata;
struct sk_buff *skb;
spinlock_t lock;
struct net_device *dev;
-   struct napi_struct napi;
struct host_if_drv *hif_drv;
struct host_if_pmkid_attr pmkid_list;
struct wilc_wfi_stats netstats;
-- 
2.7.4


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2] staging: bcm2835-audio: Disconnect and free vchi_instance on module_exit()

2018-04-25 Thread Kirill Marinushkin
On 04/25/18 08:16, Greg Kroah-Hartman wrote:
> On Tue, Apr 24, 2018 at 09:57:29PM +0200, Kirill Marinushkin wrote:
>> In the current implementation, vchi_instance is inited during the first
>> call of bcm2835_audio_open_connection(), and is never freed. It causes a
>> memory leak when the module `snd_bcm2835` is removed.
>>
>> Here is how this commit fixes it:
>>
>> * the VCHI context (including vchi_instance) is created once in the
>>   platform's devres
>> * the VCHI context is allocated and connected once during module_init()
>> * all created bcm2835_chips have a pointer to this VCHI context
>> * bcm2835_audio_open_connection() can access the VCHI context through the
>>   associated bcm2835_chip
>> * the VCHI context is disconnected and freed once during module_exit()
>>
>> After this commit is applied, I don't see other issues with the module's
>> init/exit, so I also remove the associated TODO task.
>>
>> Steps to reproduce the memory leak before this commit:
>>
>> 
>> root@raspberrypi:/home/pi# aplay test0.wav
>> Playing WAVE 'test0.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Ster
>> ^CAborted by signal Interrupt...
>> root@raspberrypi:/home/pi# rmmod snd_bcm2835
>> root@raspberrypi:/home/pi# modprobe snd_bcm2835
>> root@raspberrypi:/home/pi# aplay test0.wav
>> Playing WAVE 'test0.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Ster
>> ^CAborted by signal Interrupt...
>> root@raspberrypi:/home/pi# echo scan > /sys/kernel/debug/kmemleak
>> root@raspberrypi:/home/pi# cat /sys/kernel/debug/kmemleak
>> unreferenced object 0xb6794c00 (size 128):
>>   comm "aplay", pid 406, jiffies 36870 (age 116.650s)
>>   hex dump (first 32 bytes):
>> 08 a5 82 81 01 00 00 00 08 4c 79 b6 08 4c 79 b6  .Ly..Ly.
>> 00 00 00 00 00 00 00 00 ad 4e ad de ff ff ff ff  .N..
>>   backtrace:
>> [<802af5e0>] kmem_cache_alloc_trace+0x294/0x3d0
>> [<806ce620>] vchiq_initialise+0x98/0x1b0
>> [<806d0b34>] vchi_initialise+0x24/0x34
>> [<7f1311ec>] 0x7f1311ec
>> [<7f1303bc>] 0x7f1303bc
>> [<7f130590>] 0x7f130590
>> [<7f111fd8>] snd_pcm_open_substream+0x68/0xc4 [snd_pcm]
>> [<7f112108>] snd_pcm_open+0xd4/0x248 [snd_pcm]
>> [<7f112334>] snd_pcm_playback_open+0x4c/0x6c [snd_pcm]
>> [<7f0e250c>] snd_open+0xa8/0x14c [snd]
>> [<802ce590>] chrdev_open+0xac/0x188
>> [<802c57b4>] do_dentry_open+0x10c/0x314
>> [<802c6ba8>] vfs_open+0x5c/0x88
>> [<802d9a68>] path_openat+0x368/0x944
>> [<802dacd4>] do_filp_open+0x70/0xc4
>> [<802c6f70>] do_sys_open+0x110/0x1d4
>> 
>>
>> Signed-off-by: Kirill Marinushkin 
>> Cc: Eric Anholt 
>> Cc: Stefan Wahren 
>> Cc: Greg Kroah-Hartman 
>> Cc: Florian Fainelli 
>> Cc: Ray Jui 
>> Cc: Scott Branden 
>> Cc: Andy Shevchenko 
>> Cc: Dan Carpenter 
>> Cc: bcm-kernel-feedback-l...@broadcom.com
>> Cc: linux-rpi-ker...@lists.infradead.org
>> Cc: linux-arm-ker...@lists.infradead.org
>> Cc: de...@driverdev.osuosl.org
>> Cc: linux-ker...@vger.kernel.org
>> ---
>>  .../vc04_services/bcm2835-audio/bcm2835-vchiq.c| 64 
>> +-
>>  .../staging/vc04_services/bcm2835-audio/bcm2835.c  | 43 ++-
>>  .../staging/vc04_services/bcm2835-audio/bcm2835.h  | 12 
>>  3 files changed, 91 insertions(+), 28 deletions(-)
> What changed from v1?  Always put that below the --- line as the
> documentation says to do so.
>
> v3?  :)
>
> thanks,
>
> greg k-h
:)

Below is the git diff v1..v2


diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c
b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c
index 009c972d93d6..662e05bd8f05 100644
--- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c
+++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c
@@ -165,7 +165,7 @@ static int snd_bcm2835_create(struct snd_card *card,
 bcm2835_devm_free_vchi_ctx, NULL, NULL);
    if (!chip->vchi_ctx) {
    kfree(chip);
-   return err;
+   return -ENODEV;
    }
 
    err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);


Best Regards,
Kirill
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3 2/5] efi: Add embedded peripheral firmware support

2018-04-25 Thread Luis R. Rodriguez
On Wed, Apr 25, 2018 at 01:00:09AM -0400, Mimi Zohar wrote:
> On Tue, 2018-04-24 at 23:42 +, Luis R. Rodriguez wrote:
> > On Tue, Apr 24, 2018 at 12:07:01PM -0400, Mimi Zohar wrote:
> > > On Tue, 2018-04-24 at 17:09 +0200, Hans de Goede wrote:
> > > > On 23-04-18 23:11, Luis R. Rodriguez wrote:
> > > > > Hans, please see use of READING_FIRMWARE_PREALLOC_BUFFER, we'll need 
> > > > > a new ID
> > > > > and security for this type of request so IMA can reject it if the 
> > > > > policy is
> > > > > configured for it.
> > > > 
> > > > Hmm, interesting, actually it seems like the whole existence
> > > > of READING_FIRMWARE_PREALLOC_BUFFER is a mistake, 
> > 
> > request_firmware_into_buf() was merged without my own review, however,
> > the ID thing did get review from Mimi:
> > 
> > https://patchwork.kernel.org/patch/9074611/
> > 
> > The ID is not for IMA alone, its for any LSM to decide what to do.
> > Note Mimi asked for READING_FIRMWARE_DMA if such buffer was in DMA,
> > otherise READING_FIRMWARE_PREALLOC_BUFFER was suggested.
> > 
> > Mimi why did you want a separate ID for it back before?
> 
> The point of commit a098ecd2fa7d ("firmware: support loading into a
> pre-allocated buffer") is to avoid reading the firmware into kernel
> memory and then copying it "to it's final resting place".  My concern
> is that if the device driver has access to the buffer, it could access
> the buffer prior to the firmware's signature having been verified by
> the kernel.

If request_firmware_into_buf() is used and the firmware was found in
/lib/firmware/ paths then the driver will *not* use the firmware prior
to any LSM doing any firmware signature verification because
kernel_read_file_from_path() and in turn security_kernel_read_file().

The firmware API has a fallback mechanism [0] though, and if that is used then
security_kernel_post_read_file() is used once the firmware is loaded through
the sysfs interface *prior* to handing the firmware data to the driver. As
Hans noted though security_kernel_post_read_file() currently *only* uses
READING_FIRMWARE, so this needs to be fixed. Also note though that LSMs
get a hint of what is going to happen *soon* prior to the fallback
mechanism kicking on as we travere the /lib/firmware/ paths for direct
filesystem loading.

If this is not sufficient to cover LSM appraisals *one* option could be to
have security_kernel_read_file() return a special error of some sort
for READING_FIRMWARE_PREALLOC_BUFFER so that kernel_read_file_from_path()
users could *know* to fatally give up.

Currently the device drivers using request_firmware_into_buf() can end up
getting the buffer with firmware stashed in it without having the kernel do any
firmware signature verification at all through its LSMs. The LSM hooks added to
the firmware loader long ago by Kees via commit 6593d9245bc66 ("firmware_class:
perform new LSM checks") on v3.17 added an LSM for direct filesystem lookups,
but on the fallback mechanism seems to have only added a post LSM hook
security_kernel_fw_from_file().

There is also a custom fallback mechanism [1] which can be used if the path to
the firmware may be out of the /lib/firmware/ paths or perhaps the firmware
requires some very custom fetching of some sort. The only thing this does
though is just *not* issue a uevent when we don't find the firmware and also
sets the timeout to a practically never-ending value. The custom fallback
mechanism is only usable for request_firmware_nowait() though. In retrospect
the custom fallback mechanism is pure crap and these days we've acknowledged
that even in crazy custom firmware fetching cases folks should be able to
accomplish this by relying on uevents and using the firmwared [2] or forking
it, or a different similar proprietary similar solution, which would just
monitor for uevents for firmware and just Do The Right Thing (TM).

Consider some mobile devices which may want to fetch it from some custom
partition which only it can know how to get.

There is a kernel config option which enables the fallback mechanism always,
This is now easily readable as follows:

drivers/base/firmware_loader/fallback_table.c

struct firmware_fallback_config fw_fallback_config = {
.force_sysfs_fallback = 
IS_ENABLED(CONFIG_FW_LOADER_USER_HELPER_FALLBACK),
.loading_timeout = 60,
.old_timeout = 60,
};

Even if this is used we always do direct fs lookups first.

Android became the primary user of CONFIG_FW_LOADER_USER_HELPER_FALLBACK.

It would be good for us to hear from Android folks if their current use of
request_firmware_into_buf() is designed in practice to *never* use the direct
filesystem firmware loading interface, and always rely instead on the
fallback mechanism.

That would answer help your appraisal question in practice today.

[0] 
https://www.kernel.org/doc/html/latest/driver-api/firmware/fallback-mechanisms.html
[1] 
https://www.kernel.org/doc/html/latest/driver-api/firmware/fallback-mechanisms.html#firmware-custom-

  1   2   >