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

2018-05-16 Thread Eric W. Biederman
Christoph Hellwig  writes:

> On Sat, May 05, 2018 at 07:37:33AM -0500, Eric W. Biederman wrote:
>> Christoph Hellwig  writes:
>> 
>> > 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.
>> 
>> This is wrong.
>> 
>> Move task_active_pid_ns(current) from open to seq_start actually means
>> that the results if you pass this proc file between callers the results
>> will change.  So this breaks file descriptor passing.
>> 
>> Open is a bad place to access current.  In the middle of read/write is
>> broken.
>> 
>> 
>> In this particular instance looking up the pid namespace with
>> task_active_pid_ns was a personal brain fart.  What the code should be
>> doing (with an appropriate helper) is:
>> 
>> struct pid_namespace *pid_ns = inode->i_sb->s_fs_info;
>> 
>> Because each mount of proc is bound to a pid namespace.  Looking up the
>> pid namespace from the super_block is a much better way to go.
>
> What do you have in mind for the helper?  For now I've thrown it in
> opencoded into my working tree, but I'd be glad to add a helper.
>
> struct pid_namespace *proc_pid_namespace(struct inode *inode)
> {
>   // maybe warn on for s_magic not on procfs??
>   return inode->i_sb->s_fs_info;
> }

That should work.  Ideally out of line for the proc_fs.h version.
Basically it should be a cousin of PDE_DATA.

Eric

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


Re: [PATCH 4/4] staging: lustre: obdclass: change object lookup to no wait mode

2018-05-16 Thread James Simmons

> > > Anyway, I understand that Intel has been ignoring kernel.org instead of
> > > sending forwarding their patches properly so you're doing a difficult
> > > and thankless job...  Thanks for that.  I'm sure it's frustrating to
> > > look at these patches for you as well.
> > 
> > Thank you for the complement. Also thank you for taking time to review
> > these patches. Your feedback is most welcomed and benefitical to the
> > health of the lustre client.
> > 
> > Sadly its not just Intel but other vendors that don't directly contribute
> > to the linux lustre client. I have spoke to the vendors about contributing 
> > and they all say the same thing. No working with drivers in the staging 
> > tree. Sadly all the parties involved are very interested in the success 
> > of the lustre client. No one has ever told me directly why they don't get
> > involved but I suspect it has to deal with 2 reasons. One is that staging
> > drivers are not normally enabled by distributions so their clients 
> > normally will never deal with the staging lustre client. Secondly vendors
> > just lack the man power to contribute in a meanful way.
> 
> If staging is hurting you, why is it in staging at all?  Why not just
> drop it, go off and spend a few months to clean up all the issues in
> your own tree (with none of those pesky requirements of easy-to-review
> patches) and then submit a "clean" filesystem for inclusion in the
> "real" part of the kernel tree?
> 
> It doesn't sound like anyone is actually using this code in the tree
> as-is, so why even keep it here?

I never said being in staging is hurting the progression of Lustre. In 
fact it is the exact opposite otherwise I wouldn't be active in this work.
What I was pointing out to Dan was that many vendors are reluctant to 
partcipate in broader open source development of this type.

The whole point of this is to evolve Lustre into a proper open source 
project not dependent on vendors for survival. Several years ago Lustre 
changed hands several times and the HPC community was worried about its
survival. Various institutions band togther to raise the resources to 
keep it alive. Over time Lustre has been migrating to a more open source 
community effort. An awesome example is the work the University of Indiana 
did for the sptlrpc layer. Now we see efforts expanding into the realm of 
the linux lustre client. Actually HPC sites that are community members are 
testing and running the linux client. In spite of the lack of vendor 
involvement the linux lustre client is making excellent progress. How 
often do you see style patches anymore? The headers are properly split
between userspace UAPI headers and kernel space. One of the major barriers
to leave staging was the the lack of a strong presence to continue moving
the lustre client forward. That is no longer the case. The finish line is
in view.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 08/11] staging: mt7621-gpio: avoid devm_kzalloc() hidden inside declarations

2018-05-16 Thread Sergio Paracuellos
On Wed, May 16, 2018 at 12:40:57PM +0300, Dan Carpenter wrote:
> On Wed, May 16, 2018 at 10:56:05AM +0200, Sergio Paracuellos wrote:
> > On Wed, May 16, 2018 at 11:04:52AM +0300, Dan Carpenter wrote:
> > > On Wed, May 16, 2018 at 07:30:01AM +0200, Sergio Paracuellos wrote:
> > > > diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
> > > > b/drivers/staging/mt7621-gpio/gpio-mt7621.c
> > > > index c701259..2d16d62 100644
> > > > --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
> > > > +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
> > > > @@ -156,17 +156,18 @@ mediatek_gpio_bank_probe(struct platform_device 
> > > > *pdev, struct device_node *bank)
> > > >  {
> > > > struct mtk_data *gpio_data = dev_get_drvdata(>dev);
> > > > const __be32 *id = of_get_property(bank, "reg", NULL);
> > > > -   struct mtk_gc *rg = devm_kzalloc(>dev,
> > > > -   sizeof(struct mtk_gc), GFP_KERNEL);
> > > > +   struct mtk_gc *rg;
> > > > int ret;
> > > >  
> > > > -   if (!rg || !id || be32_to_cpu(*id) > MTK_MAX_BANK)
> > > > +   if (!id || be32_to_cpu(*id) > MTK_MAX_BANK)
> > > 
> > > You didn't introduce this, but it should be >= MTK_MAX_BANK.  (Off by
> > > one).
> > 
> > Totally true, thanks for pointing this out, Dan. 
> > I'll fix this and send v3 of the whole series.
> 
> I think you can just send the off by one fix by itself unless there are
> complaints about this patch series.  The bug was there before, so it's
> not a new thing.

Thanks for clarification, Dan. I had sent already v3 before reading this :(.

Anyway, I'll take this into account from now.

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


Re: [PATCH 34/40] atm: simplify procfs code

2018-05-16 Thread Eric W. Biederman
Christoph Hellwig  writes:

> On Sat, May 05, 2018 at 07:51:18AM -0500, Eric W. Biederman wrote:
>> Christoph Hellwig  writes:
>> 
>> > 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.
>> 
>> Can you please explain why you are removing the error handling when
>> you are unwinding the registration loop?
>
> Because there is no point in handling these errors.  The code work
> perfectly fine without procfs, or without given proc files and the
> removal works just fine if they don't exist either.  This is a very
> common patter in various parts of the kernel already.
>
> I'll document it better in the changelog.

Thank you.  That is the kind of thing that could be a signal of
inattentiveness and problems, especially when it is not documented.

Eric

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


[PATCH V3 5/5] X86: Hyper-V: Consolidate the allocation of the hypercall input page

2018-05-16 Thread kys
From: "K. Y. Srinivasan" 

Consolidate the allocation of the hypercall input page.

Signed-off-by: K. Y. Srinivasan 
Reviewed-by: Michael Kelley 
---
 arch/x86/hyperv/hv_init.c   |  2 --
 arch/x86/hyperv/mmu.c   | 30 ++
 arch/x86/include/asm/mshyperv.h |  1 -
 3 files changed, 6 insertions(+), 27 deletions(-)

diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index 6bc90d68ac8b..4c431e1c1eff 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -324,8 +324,6 @@ void __init hyperv_init(void)
hypercall_msr.guest_physical_address = vmalloc_to_pfn(hv_hypercall_pg);
wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
 
-   hyper_alloc_mmu();
-
hv_apic_init();
 
/*
diff --git a/arch/x86/hyperv/mmu.c b/arch/x86/hyperv/mmu.c
index c9cd28f0bae4..5f053d7d1bd9 100644
--- a/arch/x86/hyperv/mmu.c
+++ b/arch/x86/hyperv/mmu.c
@@ -32,9 +32,6 @@ struct hv_flush_pcpu_ex {
 /* Each gva in gva_list encodes up to 4096 pages to flush */
 #define HV_TLB_FLUSH_UNIT (4096 * PAGE_SIZE)
 
-static struct hv_flush_pcpu __percpu **pcpu_flush;
-
-static struct hv_flush_pcpu_ex __percpu **pcpu_flush_ex;
 
 /*
  * Fills in gva_list starting from offset. Returns the number of items added.
@@ -77,7 +74,7 @@ static void hyperv_flush_tlb_others(const struct cpumask 
*cpus,
 
trace_hyperv_mmu_flush_tlb_others(cpus, info);
 
-   if (!pcpu_flush || !hv_hypercall_pg)
+   if (!hv_hypercall_pg)
goto do_native;
 
if (cpumask_empty(cpus))
@@ -85,10 +82,8 @@ static void hyperv_flush_tlb_others(const struct cpumask 
*cpus,
 
local_irq_save(flags);
 
-   flush_pcpu = this_cpu_ptr(pcpu_flush);
-
-   if (unlikely(!*flush_pcpu))
-   *flush_pcpu = page_address(alloc_page(GFP_ATOMIC));
+   flush_pcpu = (struct hv_flush_pcpu **)
+this_cpu_ptr(hyperv_pcpu_input_arg);
 
flush = *flush_pcpu;
 
@@ -164,7 +159,7 @@ static void hyperv_flush_tlb_others_ex(const struct cpumask 
*cpus,
 
trace_hyperv_mmu_flush_tlb_others(cpus, info);
 
-   if (!pcpu_flush_ex || !hv_hypercall_pg)
+   if (!hv_hypercall_pg)
goto do_native;
 
if (cpumask_empty(cpus))
@@ -172,10 +167,8 @@ static void hyperv_flush_tlb_others_ex(const struct 
cpumask *cpus,
 
local_irq_save(flags);
 
-   flush_pcpu = this_cpu_ptr(pcpu_flush_ex);
-
-   if (unlikely(!*flush_pcpu))
-   *flush_pcpu = page_address(alloc_page(GFP_ATOMIC));
+   flush_pcpu = (struct hv_flush_pcpu_ex **)
+this_cpu_ptr(hyperv_pcpu_input_arg);
 
flush = *flush_pcpu;
 
@@ -257,14 +250,3 @@ void hyperv_setup_mmu_ops(void)
pv_mmu_ops.flush_tlb_others = hyperv_flush_tlb_others_ex;
}
 }
-
-void hyper_alloc_mmu(void)
-{
-   if (!(ms_hyperv.hints & HV_X64_REMOTE_TLB_FLUSH_RECOMMENDED))
-   return;
-
-   if (!(ms_hyperv.hints & HV_X64_EX_PROCESSOR_MASKS_RECOMMENDED))
-   pcpu_flush = alloc_percpu(struct hv_flush_pcpu *);
-   else
-   pcpu_flush_ex = alloc_percpu(struct hv_flush_pcpu_ex *);
-}
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 0ee82519957b..9aaa493f5756 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -294,7 +294,6 @@ static inline int cpumask_to_vpset(struct hv_vpset *vpset,
 
 void __init hyperv_init(void);
 void hyperv_setup_mmu_ops(void);
-void hyper_alloc_mmu(void);
 void hyperv_report_panic(struct pt_regs *regs, long err);
 bool hv_is_hyperv_initialized(void);
 void hyperv_cleanup(void);
-- 
2.17.0

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


[PATCH V3 1/5] X86: Hyper-V: Enlighten APIC access

2018-05-16 Thread kys
From: "K. Y. Srinivasan" 

Hyper-V supports MSR based APIC access; implement
the enlightenment.

Signed-off-by: K. Y. Srinivasan 
Reviewed-by: Michael Kelley 
---
 arch/x86/hyperv/Makefile|   2 +-
 arch/x86/hyperv/hv_apic.c   | 104 
 arch/x86/hyperv/hv_init.c   |   5 +-
 arch/x86/include/asm/mshyperv.h |   4 +-
 4 files changed, 112 insertions(+), 3 deletions(-)
 create mode 100644 arch/x86/hyperv/hv_apic.c

diff --git a/arch/x86/hyperv/Makefile b/arch/x86/hyperv/Makefile
index 367a8203cfcf..00ce4df01a09 100644
--- a/arch/x86/hyperv/Makefile
+++ b/arch/x86/hyperv/Makefile
@@ -1 +1 @@
-obj-y  := hv_init.o mmu.o
+obj-y  := hv_init.o mmu.o hv_apic.o
diff --git a/arch/x86/hyperv/hv_apic.c b/arch/x86/hyperv/hv_apic.c
new file mode 100644
index ..ca20e31d311c
--- /dev/null
+++ b/arch/x86/hyperv/hv_apic.c
@@ -0,0 +1,104 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/*
+ * Hyper-V specific APIC code.
+ *
+ * Copyright (C) 2018, Microsoft, Inc.
+ *
+ * Author : K. Y. Srinivasan 
+ *
+ * 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.
+ *
+ * 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, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#ifdef CONFIG_X86_64
+#if IS_ENABLED(CONFIG_HYPERV)
+
+static u64 hv_apic_icr_read(void)
+{
+   u64 reg_val;
+
+   rdmsrl(HV_X64_MSR_ICR, reg_val);
+   return reg_val;
+}
+
+static void hv_apic_icr_write(u32 low, u32 id)
+{
+   u64 reg_val;
+
+   reg_val = SET_APIC_DEST_FIELD(id);
+   reg_val = reg_val << 32;
+   reg_val |= low;
+
+   wrmsrl(HV_X64_MSR_ICR, reg_val);
+}
+
+static u32 hv_apic_read(u32 reg)
+{
+   u32 reg_val, hi;
+
+   switch (reg) {
+   case APIC_EOI:
+   rdmsr(HV_X64_MSR_EOI, reg_val, hi);
+   return reg_val;
+   case APIC_TASKPRI:
+   rdmsr(HV_X64_MSR_TPR, reg_val, hi);
+   return reg_val;
+
+   default:
+   return native_apic_mem_read(reg);
+   }
+}
+
+static void hv_apic_write(u32 reg, u32 val)
+{
+   switch (reg) {
+   case APIC_EOI:
+   wrmsr(HV_X64_MSR_EOI, val, 0);
+   break;
+   case APIC_TASKPRI:
+   wrmsr(HV_X64_MSR_TPR, val, 0);
+   break;
+   default:
+   native_apic_mem_write(reg, val);
+   }
+}
+
+static void hv_apic_eoi_write(u32 reg, u32 val)
+{
+   wrmsr(HV_X64_MSR_EOI, val, 0);
+}
+
+void __init hv_apic_init(void)
+{
+   if (ms_hyperv.hints & HV_X64_APIC_ACCESS_RECOMMENDED) {
+   pr_info("Hyper-V: Using MSR based APIC access\n");
+   apic_set_eoi_write(hv_apic_eoi_write);
+   apic->read  = hv_apic_read;
+   apic->write = hv_apic_write;
+   apic->icr_write = hv_apic_icr_write;
+   apic->icr_read  = hv_apic_icr_read;
+   }
+}
+
+#endif /* CONFIG_HYPERV */
+#endif /* CONFIG_X86_64 */
diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index cfecc2272f2d..71e50fc2b7ef 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -242,8 +242,9 @@ static int hv_cpu_die(unsigned int cpu)
  *
  * 1. Setup the hypercall page.
  * 2. Register Hyper-V specific clocksource.
+ * 3. Setup Hyper-V specific APIC entry points.
  */
-void hyperv_init(void)
+void __init hyperv_init(void)
 {
u64 guest_id, required_msrs;
union hv_x64_msr_hypercall_contents hypercall_msr;
@@ -298,6 +299,8 @@ void hyperv_init(void)
 
hyper_alloc_mmu();
 
+   hv_apic_init();
+
/*
 * Register Hyper-V specific clocksource.
 */
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index b90e79610cf7..162977b82e2e 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -258,7 +258,7 @@ static inline int hv_cpu_number_to_vp_number(int cpu_number)
return hv_vp_index[cpu_number];
 }
 
-void hyperv_init(void);
+void __init hyperv_init(void);
 void hyperv_setup_mmu_ops(void);
 void hyper_alloc_mmu(void);
 void hyperv_report_panic(struct pt_regs *regs, long err);
@@ -269,6 +269,7 @@ void hyperv_reenlightenment_intr(struct pt_regs *regs);
 void set_hv_tscchange_cb(void (*cb)(void));
 void clear_hv_tscchange_cb(void);
 void hyperv_stop_tsc_emulation(void);
+void hv_apic_init(void);
 #else /* CONFIG_HYPERV */
 static inline void hyperv_init(void) {}
 static inline bool 

[PATCH V3 3/5] X86: Hyper-V: Enhanced IPI enlightenment

2018-05-16 Thread kys
From: "K. Y. Srinivasan" 

Support enhanced IPI enlightenments (to target more than 64 CPUs).

Signed-off-by: K. Y. Srinivasan 
Reviewed-by: Michael Kelley 
---
 arch/x86/hyperv/hv_apic.c  | 42 +-
 arch/x86/hyperv/mmu.c  |  2 +-
 arch/x86/include/asm/hyperv-tlfs.h | 15 ++-
 arch/x86/include/asm/mshyperv.h| 33 +++
 4 files changed, 89 insertions(+), 3 deletions(-)

diff --git a/arch/x86/hyperv/hv_apic.c b/arch/x86/hyperv/hv_apic.c
index 3e0de61f1a7c..192b6ad6a361 100644
--- a/arch/x86/hyperv/hv_apic.c
+++ b/arch/x86/hyperv/hv_apic.c
@@ -93,6 +93,40 @@ static void hv_apic_eoi_write(u32 reg, u32 val)
 /*
  * IPI implementation on Hyper-V.
  */
+static bool __send_ipi_mask_ex(const struct cpumask *mask, int vector)
+{
+   struct ipi_arg_ex **arg;
+   struct ipi_arg_ex *ipi_arg;
+   unsigned long flags;
+   int nr_bank = 0;
+   int ret = 1;
+
+   local_irq_save(flags);
+   arg = (struct ipi_arg_ex **)this_cpu_ptr(hyperv_pcpu_input_arg);
+
+   ipi_arg = *arg;
+   if (unlikely(!ipi_arg))
+   goto ipi_mask_ex_done;
+
+   ipi_arg->vector = vector;
+   ipi_arg->reserved = 0;
+   ipi_arg->vp_set.valid_bank_mask = 0;
+
+   if (!cpumask_equal(mask, cpu_present_mask)) {
+   ipi_arg->vp_set.format = HV_GENERIC_SET_SPARSE_4K;
+   nr_bank = cpumask_to_vpset(&(ipi_arg->vp_set), mask);
+   }
+   if (!nr_bank)
+   ipi_arg->vp_set.format = HV_GENERIC_SET_ALL;
+
+   ret = hv_do_rep_hypercall(HVCALL_SEND_IPI_EX, 0, nr_bank,
+ ipi_arg, NULL);
+
+ipi_mask_ex_done:
+   local_irq_restore(flags);
+   return ((ret == 0) ? true : false);
+}
+
 static bool __send_ipi_mask(const struct cpumask *mask, int vector)
 {
int cur_cpu, vcpu;
@@ -110,6 +144,9 @@ static bool __send_ipi_mask(const struct cpumask *mask, int 
vector)
if ((vector < HV_IPI_LOW_VECTOR) || (vector > HV_IPI_HIGH_VECTOR))
return false;
 
+   if ((ms_hyperv.hints & HV_X64_EX_PROCESSOR_MASKS_RECOMMENDED))
+   return __send_ipi_mask_ex(mask, vector);
+
local_irq_save(flags);
arg = (struct ipi_arg_non_ex **)this_cpu_ptr(hyperv_pcpu_input_arg);
 
@@ -193,7 +230,10 @@ static void hv_send_ipi_self(int vector)
 void __init hv_apic_init(void)
 {
if (ms_hyperv.hints & HV_X64_CLUSTER_IPI_RECOMMENDED) {
-   pr_info("Hyper-V: Using IPI hypercalls\n");
+   if ((ms_hyperv.hints & HV_X64_EX_PROCESSOR_MASKS_RECOMMENDED))
+   pr_info("Hyper-V: Using ext hypercalls for IPI\n");
+   else
+   pr_info("Hyper-V: Using IPI hypercalls\n");
/*
 * Set the IPI entry points.
 */
diff --git a/arch/x86/hyperv/mmu.c b/arch/x86/hyperv/mmu.c
index 56c9ebac946f..adee39a7a3f2 100644
--- a/arch/x86/hyperv/mmu.c
+++ b/arch/x86/hyperv/mmu.c
@@ -239,7 +239,7 @@ static void hyperv_flush_tlb_others_ex(const struct cpumask 
*cpus,
flush->hv_vp_set.valid_bank_mask = 0;
 
if (!cpumask_equal(cpus, cpu_present_mask)) {
-   flush->hv_vp_set.format = HV_GENERIC_SET_SPARCE_4K;
+   flush->hv_vp_set.format = HV_GENERIC_SET_SPARSE_4K;
nr_bank = cpumask_to_vp_set(flush, cpus);
}
 
diff --git a/arch/x86/include/asm/hyperv-tlfs.h 
b/arch/x86/include/asm/hyperv-tlfs.h
index 332e786d4deb..3bfa92c2793c 100644
--- a/arch/x86/include/asm/hyperv-tlfs.h
+++ b/arch/x86/include/asm/hyperv-tlfs.h
@@ -344,6 +344,7 @@ struct hv_tsc_emulation_status {
 #define HVCALL_SEND_IPI0x000b
 #define HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX  0x0013
 #define HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST_EX   0x0014
+#define HVCALL_SEND_IPI_EX 0x0015
 #define HVCALL_POST_MESSAGE0x005c
 #define HVCALL_SIGNAL_EVENT0x005d
 
@@ -369,7 +370,7 @@ struct hv_tsc_emulation_status {
 #define HV_FLUSH_USE_EXTENDED_RANGE_FORMAT BIT(3)
 
 enum HV_GENERIC_SET_FORMAT {
-   HV_GENERIC_SET_SPARCE_4K,
+   HV_GENERIC_SET_SPARSE_4K,
HV_GENERIC_SET_ALL,
 };
 
@@ -721,4 +722,16 @@ struct ipi_arg_non_ex {
u64 cpu_mask;
 };
 
+struct hv_vpset {
+   u64 format;
+   u64 valid_bank_mask;
+   u64 bank_contents[];
+};
+
+struct ipi_arg_ex {
+   u32 vector;
+   u32 reserved;
+   struct hv_vpset vp_set;
+};
+
 #endif
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 1eff91599c2b..0ee82519957b 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -259,6 +259,39 @@ static inline int hv_cpu_number_to_vp_number(int 
cpu_number)
return hv_vp_index[cpu_number];
 }
 
+static inline int cpumask_to_vpset(struct hv_vpset *vpset,
+ 

[PATCH V3 2/5] X86: Hyper-V: Enable IPI enlightenments

2018-05-16 Thread kys
From: "K. Y. Srinivasan" 

Hyper-V supports hypercalls to implement IPI; use them.

Signed-off-by: K. Y. Srinivasan 
Reviewed-by: Michael Kelley 
---
 arch/x86/hyperv/hv_apic.c  | 117 +
 arch/x86/hyperv/hv_init.c  |  27 +++
 arch/x86/include/asm/hyperv-tlfs.h |  15 
 arch/x86/include/asm/mshyperv.h|   1 +
 4 files changed, 160 insertions(+)

diff --git a/arch/x86/hyperv/hv_apic.c b/arch/x86/hyperv/hv_apic.c
index ca20e31d311c..3e0de61f1a7c 100644
--- a/arch/x86/hyperv/hv_apic.c
+++ b/arch/x86/hyperv/hv_apic.c
@@ -33,6 +33,8 @@
 #ifdef CONFIG_X86_64
 #if IS_ENABLED(CONFIG_HYPERV)
 
+static struct apic orig_apic;
+
 static u64 hv_apic_icr_read(void)
 {
u64 reg_val;
@@ -88,8 +90,123 @@ static void hv_apic_eoi_write(u32 reg, u32 val)
wrmsr(HV_X64_MSR_EOI, val, 0);
 }
 
+/*
+ * IPI implementation on Hyper-V.
+ */
+static bool __send_ipi_mask(const struct cpumask *mask, int vector)
+{
+   int cur_cpu, vcpu;
+   struct ipi_arg_non_ex **arg;
+   struct ipi_arg_non_ex *ipi_arg;
+   int ret = 1;
+   unsigned long flags;
+
+   if (cpumask_empty(mask))
+   return true;
+
+   if (!hv_hypercall_pg)
+   return false;
+
+   if ((vector < HV_IPI_LOW_VECTOR) || (vector > HV_IPI_HIGH_VECTOR))
+   return false;
+
+   local_irq_save(flags);
+   arg = (struct ipi_arg_non_ex **)this_cpu_ptr(hyperv_pcpu_input_arg);
+
+   ipi_arg = *arg;
+   if (unlikely(!ipi_arg))
+   goto ipi_mask_done;
+
+   ipi_arg->vector = vector;
+   ipi_arg->reserved = 0;
+   ipi_arg->cpu_mask = 0;
+
+   for_each_cpu(cur_cpu, mask) {
+   vcpu = hv_cpu_number_to_vp_number(cur_cpu);
+   /*
+* This particular version of the IPI hypercall can
+* only target upto 64 CPUs.
+*/
+   if (vcpu >= 64)
+   goto ipi_mask_done;
+
+   __set_bit(vcpu, (unsigned long *)_arg->cpu_mask);
+   }
+
+   ret = hv_do_hypercall(HVCALL_SEND_IPI, ipi_arg, NULL);
+
+ipi_mask_done:
+   local_irq_restore(flags);
+   return ((ret == 0) ? true : false);
+}
+
+static bool __send_ipi_one(int cpu, int vector)
+{
+   struct cpumask mask = CPU_MASK_NONE;
+
+   cpumask_set_cpu(cpu, );
+   return __send_ipi_mask(, vector);
+}
+
+static void hv_send_ipi(int cpu, int vector)
+{
+   if (!__send_ipi_one(cpu, vector))
+   orig_apic.send_IPI(cpu, vector);
+}
+
+static void hv_send_ipi_mask(const struct cpumask *mask, int vector)
+{
+   if (!__send_ipi_mask(mask, vector))
+   orig_apic.send_IPI_mask(mask, vector);
+}
+
+static void hv_send_ipi_mask_allbutself(const struct cpumask *mask, int vector)
+{
+   unsigned int this_cpu = smp_processor_id();
+   struct cpumask new_mask;
+   const struct cpumask *local_mask;
+
+   cpumask_copy(_mask, mask);
+   cpumask_clear_cpu(this_cpu, _mask);
+   local_mask = _mask;
+   if (!__send_ipi_mask(local_mask, vector))
+   orig_apic.send_IPI_mask_allbutself(mask, vector);
+}
+
+static void hv_send_ipi_allbutself(int vector)
+{
+   hv_send_ipi_mask_allbutself(cpu_online_mask, vector);
+}
+
+static void hv_send_ipi_all(int vector)
+{
+   if (!__send_ipi_mask(cpu_online_mask, vector))
+   orig_apic.send_IPI_all(vector);
+}
+
+static void hv_send_ipi_self(int vector)
+{
+   if (!__send_ipi_one(smp_processor_id(), vector))
+   orig_apic.send_IPI_self(vector);
+}
+
 void __init hv_apic_init(void)
 {
+   if (ms_hyperv.hints & HV_X64_CLUSTER_IPI_RECOMMENDED) {
+   pr_info("Hyper-V: Using IPI hypercalls\n");
+   /*
+* Set the IPI entry points.
+*/
+   orig_apic = *apic;
+
+   apic->send_IPI = hv_send_ipi;
+   apic->send_IPI_mask = hv_send_ipi_mask;
+   apic->send_IPI_mask_allbutself = hv_send_ipi_mask_allbutself;
+   apic->send_IPI_allbutself = hv_send_ipi_allbutself;
+   apic->send_IPI_all = hv_send_ipi_all;
+   apic->send_IPI_self = hv_send_ipi_self;
+   }
+
if (ms_hyperv.hints & HV_X64_APIC_ACCESS_RECOMMENDED) {
pr_info("Hyper-V: Using MSR based APIC access\n");
apic_set_eoi_write(hv_apic_eoi_write);
diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index 71e50fc2b7ef..6bc90d68ac8b 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -91,12 +91,19 @@ EXPORT_SYMBOL_GPL(hv_vp_index);
 struct hv_vp_assist_page **hv_vp_assist_page;
 EXPORT_SYMBOL_GPL(hv_vp_assist_page);
 
+void  __percpu **hyperv_pcpu_input_arg;
+EXPORT_SYMBOL_GPL(hyperv_pcpu_input_arg);
+
 u32 hv_max_vp_index;
 
 static int hv_cpu_init(unsigned int cpu)
 {
u64 msr_vp_index;
struct 

[PATCH V3 4/5] X86: Hyper-V: Consolidate code for converting cpumask to vpset

2018-05-16 Thread kys
From: "K. Y. Srinivasan" 

Consolidate code for converting cpumask to vpset.

Signed-off-by: K. Y. Srinivasan 
Reviewed-by: Michael Kelley 
---
 arch/x86/hyperv/mmu.c | 43 ++-
 1 file changed, 2 insertions(+), 41 deletions(-)

diff --git a/arch/x86/hyperv/mmu.c b/arch/x86/hyperv/mmu.c
index adee39a7a3f2..c9cd28f0bae4 100644
--- a/arch/x86/hyperv/mmu.c
+++ b/arch/x86/hyperv/mmu.c
@@ -25,11 +25,7 @@ struct hv_flush_pcpu {
 struct hv_flush_pcpu_ex {
u64 address_space;
u64 flags;
-   struct {
-   u64 format;
-   u64 valid_bank_mask;
-   u64 bank_contents[];
-   } hv_vp_set;
+   struct hv_vpset hv_vp_set;
u64 gva_list[];
 };
 
@@ -70,41 +66,6 @@ static inline int fill_gva_list(u64 gva_list[], int offset,
return gva_n - offset;
 }
 
-/* Return the number of banks in the resulting vp_set */
-static inline int cpumask_to_vp_set(struct hv_flush_pcpu_ex *flush,
-   const struct cpumask *cpus)
-{
-   int cpu, vcpu, vcpu_bank, vcpu_offset, nr_bank = 1;
-
-   /* valid_bank_mask can represent up to 64 banks */
-   if (hv_max_vp_index / 64 >= 64)
-   return 0;
-
-   /*
-* Clear all banks up to the maximum possible bank as hv_flush_pcpu_ex
-* structs are not cleared between calls, we risk flushing unneeded
-* vCPUs otherwise.
-*/
-   for (vcpu_bank = 0; vcpu_bank <= hv_max_vp_index / 64; vcpu_bank++)
-   flush->hv_vp_set.bank_contents[vcpu_bank] = 0;
-
-   /*
-* Some banks may end up being empty but this is acceptable.
-*/
-   for_each_cpu(cpu, cpus) {
-   vcpu = hv_cpu_number_to_vp_number(cpu);
-   vcpu_bank = vcpu / 64;
-   vcpu_offset = vcpu % 64;
-   __set_bit(vcpu_offset, (unsigned long *)
- >hv_vp_set.bank_contents[vcpu_bank]);
-   if (vcpu_bank >= nr_bank)
-   nr_bank = vcpu_bank + 1;
-   }
-   flush->hv_vp_set.valid_bank_mask = GENMASK_ULL(nr_bank - 1, 0);
-
-   return nr_bank;
-}
-
 static void hyperv_flush_tlb_others(const struct cpumask *cpus,
const struct flush_tlb_info *info)
 {
@@ -240,7 +201,7 @@ static void hyperv_flush_tlb_others_ex(const struct cpumask 
*cpus,
 
if (!cpumask_equal(cpus, cpu_present_mask)) {
flush->hv_vp_set.format = HV_GENERIC_SET_SPARSE_4K;
-   nr_bank = cpumask_to_vp_set(flush, cpus);
+   nr_bank = cpumask_to_vpset(&(flush->hv_vp_set), cpus);
}
 
if (!nr_bank) {
-- 
2.17.0

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


[PATCH V3 0/5] X86: Hyper-V: APIC enlightenments

2018-05-16 Thread kys
From: "K. Y. Srinivasan" 

Implement APIC related enlightenments.

V2: Addressed comments from Thomas Gleixner 
and Michael Kelley (EOSG) .

V3: Address build issues reported by kbuild test robot 

K. Y. Srinivasan (5):
  X86: Hyper-V: Enlighten APIC access
  X86: Hyper-V: Enable IPI enlightenments
  X86: Hyper-V: Enhanced IPI enlightenment
  X86: Hyper-V: Consolidate code for converting cpumask to vpset
  X86: Hyper-V: Consolidate the allocation of the hypercall input page

 arch/x86/hyperv/Makefile   |   2 +-
 arch/x86/hyperv/hv_apic.c  | 261 +
 arch/x86/hyperv/hv_init.c  |  32 +++-
 arch/x86/hyperv/mmu.c  |  75 +
 arch/x86/include/asm/hyperv-tlfs.h |  30 +++-
 arch/x86/include/asm/mshyperv.h|  39 -
 6 files changed, 367 insertions(+), 72 deletions(-)
 create mode 100644 arch/x86/hyperv/hv_apic.c

-- 
2.17.0

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


RE: [PATCH V2 0/5] X86: Hyper-V: APIC enlightenments

2018-05-16 Thread Thomas Gleixner
On Wed, 16 May 2018, KY Srinivasan wrote:

> 
> 
> > -Original Message-
> > From: k...@linuxonhyperv.com 
> > Sent: Thursday, May 3, 2018 11:07 PM
> > To: x...@kernel.org; gre...@linuxfoundation.org; linux-
> > ker...@vger.kernel.org; de...@linuxdriverproject.org; o...@aepfle.de;
> > a...@canonical.com; jasow...@redhat.com; t...@linutronix.de;
> > h...@zytor.com; Stephen Hemminger ; Michael
> > Kelley (EOSG) ; vkuzn...@redhat.com
> > Cc: KY Srinivasan 
> > Subject: [PATCH V2 0/5] X86: Hyper-V: APIC enlightenments
> > 
> > From: "K. Y. Srinivasan" 
> > 
> > Implement APIC related enlightenments.
> > 
> > V2: Addressed comments from Thomas Gleixner 
> > and Michael Kelley (EOSG) .
> 
> Thomas,
> 
> I think I have addressed all your comments;
> let me know if you have any additional comments on this patch set.

Looks good now. There is just the build robot fallout which needs to be
addressed AFAICT.

Thanks,

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


[PATCH 11/11] Staging: goldfish: Kconfig: fixed code style issue

2018-05-16 Thread ankit patel
Style fix: config GOLDFISH_AUDIO containing "--help--" to "help"

Signed-off-by:  ankit patel 
---
 drivers/staging/goldfish/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/goldfish/Kconfig b/drivers/staging/goldfish/Kconfig
index 4e094602437c..0302720cd5f5 100644
--- a/drivers/staging/goldfish/Kconfig
+++ b/drivers/staging/goldfish/Kconfig
@@ -1,7 +1,7 @@
 config GOLDFISH_AUDIO
tristate "Goldfish AVD Audio Device"
depends on GOLDFISH
-   ---help---
+   help
  Emulated audio channel for the Goldfish Android Virtual Device
 
 config MTD_GOLDFISH_NAND
-- 
2.17.0

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


Re: [PATCH 4/4] staging: lustre: obdclass: change object lookup to no wait mode

2018-05-16 Thread Joe Perches
On Wed, 2018-05-16 at 09:12 +, Dilger, Andreas wrote:
> On May 16, 2018, at 02:00, Dan Carpenter  wrote:
> > 
> > On Tue, May 15, 2018 at 04:02:55PM +0100, James Simmons wrote:
> > > 
> > > > >   /*
> > > > >* Allocate new object. This may result in rather complicated
> > > > >* operations, including fld queries, inode loading, etc.
> > > > >*/
> > > > >   o = lu_object_alloc(env, dev, f, conf);
> > > > > - if (IS_ERR(o))
> > > > > + if (unlikely(IS_ERR(o)))
> > > > >   return o;
> > > > > 
> > > > 
> > > > This is an unrelated and totally pointless.  likely/unlikely annotations
> > > > hurt readability, and they should only be added if it's something which
> > > > is going to show up in benchmarking.  lu_object_alloc() is already too
> > > > slow for the unlikely() to make a difference and anyway IS_ERR() has an
> > > > unlikely built in so it's duplicative...
> > > 
> > > Sounds like a good checkpatch case to test for :-)
> > 
> > The likely/unlikely annotations have their place in fast paths so a
> > checkpatch warning would get annoying...
> 
> I think James was suggesting a check for unlikely(IS_ERR()),

Probably so.

$ git grep -P 'likely\s*\(\s*\!?\s*IS_ERR' | wc -l
42

Are there other known likely/unlikely duplications?

>  or possibly
> a check for unlikely() on something that is already unlikely() after CPP
> expansion.

checkpatch isn't the tool for that type of test
as it is a collection of trivial regex tests and
it is not a c90 preprocessor.

Anyway, here's a possible checkpatch patch.
---
 scripts/checkpatch.pl | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index baddac9379f0..20c0973f1c39 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -6299,6 +6299,12 @@ sub process {
  "#define of '$1' is wrong - use Kconfig variables 
or standard guards instead\n" . $herecurr);
}
 
+# likely/unlikely tests with IS_ERR (already unlikely)"
+   if ($line =~ 
/\b((?:un)?likely)\s*\(\s*\!?\s*(IS_ERR[A-Z_]*)\s*\(/) {
+   WARN("DUPLICATE_LIKELY",
+"Unnecessary use of $1 with $2 as it already has 
an unlikely\n" . $herecurr);
+   }
+
 # likely/unlikely comparisons similar to "(likely(foo) > 0)"
if ($^V && $^V ge 5.10.0 &&
$line =~ 
/\b((?:un)?likely)\s*\(\s*$FuncArg\s*\)\s*$Compare/) {


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


[PATCH v2] staging: lustre: Change return type to vm_fault_t

2018-05-16 Thread Souptick Joarder
Use new return type vm_fault_t for fault handler. For
now, this is just documenting that the function returns
a VM_FAULT value rather than an errno. Once all instances
are converted, vm_fault_t will become a distinct type.

Commit 1c8f422059ae ("mm: change return type to vm_fault_t")

Signed-off-by: Souptick Joarder 
---
v2: updated the change log

 drivers/staging/lustre/lustre/llite/llite_mmap.c | 35 
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c 
b/drivers/staging/lustre/lustre/llite/llite_mmap.c
index c0533bd..5b8fd10 100644
--- a/drivers/staging/lustre/lustre/llite/llite_mmap.c
+++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c
@@ -231,7 +231,7 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, 
struct page *vmpage,
return result;
 }
 
-static inline int to_fault_error(int result)
+static inline vm_fault_t to_fault_error(int result)
 {
switch (result) {
case 0:
@@ -261,7 +261,7 @@ static inline int to_fault_error(int result)
  * \retval VM_FAULT_ERROR on general error
  * \retval NOPAGE_OOM not have memory for allocate new page
  */
-static int ll_fault0(struct vm_area_struct *vma, struct vm_fault *vmf)
+static vm_fault_t ll_fault0(struct vm_area_struct *vma, struct vm_fault *vmf)
 {
struct lu_env  *env;
struct cl_io*io;
@@ -269,16 +269,16 @@ static int ll_fault0(struct vm_area_struct *vma, struct 
vm_fault *vmf)
struct page  *vmpage;
unsigned long   ra_flags;
int   result = 0;
-   int   fault_ret = 0;
+   vm_fault_t  fault_ret = 0;
u16 refcheck;
 
env = cl_env_get();
if (IS_ERR(env))
-   return PTR_ERR(env);
+   return VM_FAULT_ERROR;
 
io = ll_fault_io_init(env, vma, vmf->pgoff, _flags);
if (IS_ERR(io)) {
-   result = to_fault_error(PTR_ERR(io));
+   fault_ret = to_fault_error(PTR_ERR(io));
goto out;
}
 
@@ -319,15 +319,15 @@ static int ll_fault0(struct vm_area_struct *vma, struct 
vm_fault *vmf)
if (result != 0 && !(fault_ret & VM_FAULT_RETRY))
fault_ret |= to_fault_error(result);
 
-   CDEBUG(D_MMAP, "%s fault %d/%d\n", current->comm, fault_ret, result);
+   CDEBUG(D_MMAP, "%s fault %x/%d\n", current->comm, fault_ret, result);
return fault_ret;
 }
 
-static int ll_fault(struct vm_fault *vmf)
+static vm_fault_t ll_fault(struct vm_fault *vmf)
 {
int count = 0;
bool printed = false;
-   int result;
+   vm_fault_t result;
sigset_t set;
 
/* Only SIGKILL and SIGTERM are allowed for fault/nopage/mkwrite
@@ -364,18 +364,19 @@ static int ll_fault(struct vm_fault *vmf)
return result;
 }
 
-static int ll_page_mkwrite(struct vm_fault *vmf)
+static vm_fault_t ll_page_mkwrite(struct vm_fault *vmf)
 {
struct vm_area_struct *vma = vmf->vma;
int count = 0;
bool printed = false;
bool retry;
-   int result;
+   int err;
+   vm_fault_t ret;
 
file_update_time(vma->vm_file);
do {
retry = false;
-   result = ll_page_mkwrite0(vma, vmf->page, );
+   err = ll_page_mkwrite0(vma, vmf->page, );
 
if (!printed && ++count > 16) {
const struct dentry *de = vma->vm_file->f_path.dentry;
@@ -387,25 +388,25 @@ static int ll_page_mkwrite(struct vm_fault *vmf)
}
} while (retry);
 
-   switch (result) {
+   switch (err) {
case 0:
LASSERT(PageLocked(vmf->page));
-   result = VM_FAULT_LOCKED;
+   ret = VM_FAULT_LOCKED;
break;
case -ENODATA:
case -EAGAIN:
case -EFAULT:
-   result = VM_FAULT_NOPAGE;
+   ret = VM_FAULT_NOPAGE;
break;
case -ENOMEM:
-   result = VM_FAULT_OOM;
+   ret = VM_FAULT_OOM;
break;
default:
-   result = VM_FAULT_SIGBUS;
+   ret = VM_FAULT_SIGBUS;
break;
}
 
-   return result;
+   return ret;
 }
 
 /**
-- 
1.9.1

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


Re: [PATCH] Delete the goldfish_nand driver.

2018-05-16 Thread Greg KH
On Wed, May 16, 2018 at 10:31:26AM -0700, Roman Kiryanov wrote:
> Hi, thank you for looking.
> 
> I see goldfish_audio.c in drivers/staging/goldfish. There
> is arch/mips/configs/generic/board-ranchu.config referencing this driver
> (CONFIG_GOLDFISH_AUDIO=y). I believe we need to keep goldfish to keep this
> config.

Does anyone actually use that config?  Is it a "real" device?

> I can move the goldfish folder to a more appropriate place and add more
> goldfish drivers there. Will drivers/goldfish work for you?

It has a long effort to be cleaned up properly before it can get out of
drivers/staging/, it's not a matter of just moving it to a new
directory.  It is in staging for a good reason :)

Again, are these even needed now that the cuttlefish build target is
present?  Who is even using these drivers?  Why has no one worked on
cleaning up the upstream code in the past few years?

thanks,

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


RE: [PATCH V2 0/5] X86: Hyper-V: APIC enlightenments

2018-05-16 Thread KY Srinivasan


> -Original Message-
> From: k...@linuxonhyperv.com 
> Sent: Thursday, May 3, 2018 11:07 PM
> To: x...@kernel.org; gre...@linuxfoundation.org; linux-
> ker...@vger.kernel.org; de...@linuxdriverproject.org; o...@aepfle.de;
> a...@canonical.com; jasow...@redhat.com; t...@linutronix.de;
> h...@zytor.com; Stephen Hemminger ; Michael
> Kelley (EOSG) ; vkuzn...@redhat.com
> Cc: KY Srinivasan 
> Subject: [PATCH V2 0/5] X86: Hyper-V: APIC enlightenments
> 
> From: "K. Y. Srinivasan" 
> 
> Implement APIC related enlightenments.
> 
> V2: Addressed comments from Thomas Gleixner 
> and Michael Kelley (EOSG) .

Thomas,

I think I have addressed all your comments;
let me know if you have any additional comments on this patch set.

Regards,

K. Y
> 
> K. Y. Srinivasan (5):
>   X86: Hyper-V: Enlighten APIC access
>   X86: Hyper-V: Enable IPI enlightenments
>   X86: Hyper-V: Enhanced IPI enlightenment
>   X86: Hyper-V: Consolidate code for converting cpumask to vpset
>   X86: Hyper-V: Consolidate the allocation of the hypercall input page
> 
>  arch/x86/hyperv/Makefile   |   2 +-
>  arch/x86/hyperv/hv_apic.c  | 259
> +
>  arch/x86/hyperv/hv_init.c  |  32 -
>  arch/x86/hyperv/mmu.c  |  75 ++-
>  arch/x86/include/asm/hyperv-tlfs.h |  30 -
>  arch/x86/include/asm/mshyperv.h|  39 +-
>  6 files changed, 365 insertions(+), 72 deletions(-)
>  create mode 100644 arch/x86/hyperv/hv_apic.c
> 
> --
> 2.15.1

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


Re: [PATCH 4/4] staging: lustre: obdclass: change object lookup to no wait mode

2018-05-16 Thread Greg Kroah-Hartman
On Tue, May 15, 2018 at 04:02:55PM +0100, James Simmons wrote:
> > >   /*
> > >* Allocate new object. This may result in rather complicated
> > >* operations, including fld queries, inode loading, etc.
> > >*/
> > >   o = lu_object_alloc(env, dev, f, conf);
> > > - if (IS_ERR(o))
> > > + if (unlikely(IS_ERR(o)))
> > >   return o;
> > >  
> > 
> > This is an unrelated and totally pointless.  likely/unlikely annotations
> > hurt readability, and they should only be added if it's something which
> > is going to show up in benchmarking.  lu_object_alloc() is already too
> > slow for the unlikely() to make a difference and anyway IS_ERR() has an
> > unlikely built in so it's duplicative...
> 
> Sounds like a good checkpatch case to test for :-) Some people like to try
> and milk ever cycle they can. Personally for me I never use those 
> annotations. With modern processors I'm skeptical if their benefits.
> I do cleanup up the patches to some extent to make it compliant with 
> kernel standards but leave the core code in place for people to comment 
> on.
> 
> > Anyway, I understand that Intel has been ignoring kernel.org instead of
> > sending forwarding their patches properly so you're doing a difficult
> > and thankless job...  Thanks for that.  I'm sure it's frustrating to
> > look at these patches for you as well.
> 
> Thank you for the complement. Also thank you for taking time to review
> these patches. Your feedback is most welcomed and benefitical to the
> health of the lustre client.
> 
> Sadly its not just Intel but other vendors that don't directly contribute
> to the linux lustre client. I have spoke to the vendors about contributing 
> and they all say the same thing. No working with drivers in the staging 
> tree. Sadly all the parties involved are very interested in the success 
> of the lustre client. No one has ever told me directly why they don't get
> involved but I suspect it has to deal with 2 reasons. One is that staging
> drivers are not normally enabled by distributions so their clients 
> normally will never deal with the staging lustre client. Secondly vendors
> just lack the man power to contribute in a meanful way.

If staging is hurting you, why is it in staging at all?  Why not just
drop it, go off and spend a few months to clean up all the issues in
your own tree (with none of those pesky requirements of easy-to-review
patches) and then submit a "clean" filesystem for inclusion in the
"real" part of the kernel tree?

It doesn't sound like anyone is actually using this code in the tree
as-is, so why even keep it here?

thanks,

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


Re: simplify procfs code for seq_file instances V3

2018-05-16 Thread Al Viro
On Wed, May 16, 2018 at 11:43:04AM +0200, Christoph Hellwig wrote:
> 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.3

Pulled, but the last bit is a bleeding atrocity in need of followup
cleanup.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [Jfs-discussion] [PATCH 25/42] jfs: simplify procfs code

2018-05-16 Thread Dave Kleikamp
On 05/16/2018 04:43 AM, Christoph Hellwig wrote:
> 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 

Acked-by:  Dave Kleikamp 

> ---
>  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",_lmstats_proc_fops, },
> - { "txstats",_txstats_proc_fops, },
> - { "xtstat", _xtstat_proc_fops, },
> - { "mpstat", _mpstat_proc_fops, },
> -#endif
> -#ifdef CONFIG_JFS_DEBUG
> - { "TxAnchor",   _txanchor_proc_fops, },
> - { "loglevel",   _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, _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);
>  
>  #define  INCREMENT(x)((x)++)
>  #define  DECREMENT(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   = 

[PATCH] staging: ks7010: avoid casting inside cpu_to_* assignments

2018-05-16 Thread Sergio Paracuellos
cpu_to_*() functions already have a cast to u* built in,
so the cast is never required. Review and remove all of
them along the code.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks7010_sdio.c |  4 +--
 drivers/staging/ks7010/ks_hostif.c   | 59 ++--
 2 files changed, 31 insertions(+), 32 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index e904740..74551eb 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -1061,8 +1061,8 @@ static int send_stop_request(struct sdio_func *func)
return -ENOMEM;
 
size = sizeof(*pp) - sizeof(pp->header.size);
-   pp->header.size = cpu_to_le16((u16)size);
-   pp->header.event = cpu_to_le16((u16)HIF_STOP_REQ);
+   pp->header.size = cpu_to_le16(size);
+   pp->header.event = cpu_to_le16(HIF_STOP_REQ);
 
sdio_claim_host(func);
write_to_device(card->priv, (u8 *)pp, hif_align_size(sizeof(*pp)));
diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 66ab45a..0ecffab 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -989,7 +989,7 @@ static void *hostif_generic_request(size_t size, int event)
if (!p)
return NULL;
 
-   p->size = cpu_to_le16((u16)(size - sizeof(p->size)));
+   p->size = cpu_to_le16(size - sizeof(p->size));
p->event = cpu_to_le16(event);
 
return p;
@@ -1109,7 +1109,7 @@ int hostif_data_request(struct ks_wlan_private *priv, 
struct sk_buff *skb)
priv->wpa.key[1].key_len == 0 &&
priv->wpa.key[2].key_len == 0 &&
priv->wpa.key[3].key_len == 0) {
-   pp->auth_type = cpu_to_le16((u16)TYPE_AUTH);
+   pp->auth_type = cpu_to_le16(TYPE_AUTH);
} else {
if (priv->wpa.pairwise_suite == IW_AUTH_CIPHER_TKIP) {
michael_mic_function(_mic,
@@ -1121,26 +1121,25 @@ int hostif_data_request(struct ks_wlan_private *priv, 
struct sk_buff *skb)
skb_len += 8;
p += 8;
pp->auth_type =
-   cpu_to_le16((u16)TYPE_DATA);
+   cpu_to_le16(TYPE_DATA);
 
} else if (priv->wpa.pairwise_suite ==
   IW_AUTH_CIPHER_CCMP) {
pp->auth_type =
-   cpu_to_le16((u16)TYPE_DATA);
+   cpu_to_le16(TYPE_DATA);
}
}
} else {
if (eth_proto == ETH_P_PAE)
-   pp->auth_type = cpu_to_le16((u16)TYPE_AUTH);
+   pp->auth_type = cpu_to_le16(TYPE_AUTH);
else
-   pp->auth_type = cpu_to_le16((u16)TYPE_DATA);
+   pp->auth_type = cpu_to_le16(TYPE_DATA);
}
 
/* header value set */
pp->header.size =
-   cpu_to_le16((u16)
-   (sizeof(*pp) - sizeof(pp->header.size) + skb_len));
-   pp->header.event = cpu_to_le16((u16)HIF_DATA_REQ);
+   cpu_to_le16((sizeof(*pp) - sizeof(pp->header.size) + skb_len));
+   pp->header.event = cpu_to_le16(HIF_DATA_REQ);
 
/* tx request */
result = ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + skb_len),
@@ -1211,7 +1210,7 @@ static void hostif_mib_set_request(struct ks_wlan_private 
*priv,
return;
 
pp->mib_attribute = cpu_to_le32(attr);
-   pp->mib_value.size = cpu_to_le16((u16)size);
+   pp->mib_value.size = cpu_to_le16(size);
pp->mib_value.type = cpu_to_le16(type);
memcpy(>mib_value.body, data, size);
 
@@ -1221,7 +1220,7 @@ static void hostif_mib_set_request(struct ks_wlan_private 
*priv,
 static inline void hostif_mib_set_request_int(struct ks_wlan_private *priv,
  enum mib_attribute attr, int val)
 {
-   __le32 v = cpu_to_le32((u32)val);
+   __le32 v = cpu_to_le32(val);
size_t size = sizeof(v);
 
hostif_mib_set_request(priv, attr, MIB_VALUE_TYPE_INT, , size);
@@ -1231,7 +1230,7 @@ static inline void hostif_mib_set_request_bool(struct 
ks_wlan_private *priv,
   enum mib_attribute attr,
   bool val)
 {
-   __le32 v = cpu_to_le32((u32)val);
+   __le32 v = cpu_to_le32(val);
size_t size = sizeof(v);
 
hostif_mib_set_request(priv, attr, MIB_VALUE_TYPE_BOOL, , size);
@@ -1253,7 +1252,7 @@ void hostif_start_request(struct ks_wlan_private *priv, 
unsigned char mode)
if (!pp)
return;
 
-

Re: [PATCH 41/42] tty: replace ->proc_fops with ->proc_show

2018-05-16 Thread Greg Kroah-Hartman
On Wed, May 16, 2018 at 11:43:45AM +0200, Christoph Hellwig wrote:
> 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 

Reviewed-by: Greg Kroah-Hartman 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


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

2018-05-16 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 = _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 = _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 = _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 

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

2018-05-16 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, _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, _cache_proc_fops },
-   { "capacity", S_IFREG|S_IRUGO, _capacity_proc_fops  },
-   { "geometry", S_IFREG|S_IRUGO, _geometry_proc_fops  },
-   { "smart_values", S_IFREG|S_IRUSR, _sv_proc_fops},
-   { "smart_thresholds", S_IFREG|S_IRUSR, _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..7f697ddb5fe5 100644
--- 

[PATCH 42/42] proc: update SIZEOF_PDE_INLINE_NAME for the new pde fields

2018-05-16 Thread Christoph Hellwig
This makes Alexey happy and Al groan.  Based on a patch from
Alexey Dobriyan.

Signed-off-by: Christoph Hellwig 
---
 fs/proc/internal.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/proc/internal.h b/fs/proc/internal.h
index 84c68508a256..a318ae5b36b4 100644
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -62,9 +62,9 @@ struct proc_dir_entry {
umode_t mode;
u8 namelen;
 #ifdef CONFIG_64BIT
-#define SIZEOF_PDE_INLINE_NAME (192-139)
+#define SIZEOF_PDE_INLINE_NAME (192-155)
 #else
-#define SIZEOF_PDE_INLINE_NAME (128-87)
+#define SIZEOF_PDE_INLINE_NAME (128-95)
 #endif
char inline_name[SIZEOF_PDE_INLINE_NAME];
 } __randomize_layout;
-- 
2.17.0

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


[PATCH 38/42] isdn: replace ->proc_fops with ->proc_show

2018-05-16 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(>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 = _proc_fops;
+   iif->ctr.proc_show = gigaset_proc_show,
INIT_LIST_HEAD(>appls);
skb_queue_head_init(>sendqueue);
atomic_set(>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 35/42] bluetooth: switch to proc_create_seq_data

2018-05-16 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(>lock);
return seq_hlist_start_head(>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, >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(>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, _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, _fops, sk_list))
+   if (!proc_create_seq_data(name, 0, net->proc_net, _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/42] ide: remove ide_driver_proc_write

2018-05-16 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 
Acked-by: "Eric W. Biederman" 
---
 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 = >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


[PATCH 37/42] atm: switch to proc_create_seq_private

2018-05-16 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(>sk, state->family, >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(>sk, family, >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(_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, _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, _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, _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, _dev_seq_ops);
-   proc_create("pvc", 0444, atm_proc_root, _seq_fops);
-   proc_create("svc", 0444, atm_proc_root, _seq_fops);
-   proc_create("vc", 0444, atm_proc_root, _seq_fops);
+   proc_create_seq_private("pvc", 0444, atm_proc_root, _seq_ops,
+   sizeof(struct vcc_state), (void *)(uintptr_t)PF_ATMPVC);
+   proc_create_seq_private("svc", 0444, atm_proc_root, _seq_ops,
+   sizeof(struct vcc_state), (void *)(uintptr_t)PF_ATMSVC);
+   proc_create_seq_private("vc", 0444, atm_proc_root, _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 33/42] netfilter/xt_hashlimit: switch to proc_create_{seq, single}_data

2018-05-16 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 = _file_ops_v1;
+   ops = _seq_ops_v1;
break;
case 2:
-   fops = _file_ops_v2;
+   ops = _seq_ops_v2;
break;
default:
-   fops = _file_ops;
+   ops = _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(>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(>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(>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(>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_show_v1(struct seq_file *s, 

[PATCH 30/42] bonding: switch to proc_create_seq_data

2018-05-16 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, _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,
-   _info_fops, bond);
+   bond->proc_entry = proc_create_seq_data(bond_dev->name, 0444,
+   bn->proc_dir, _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 36/42] atm: simplify procfs code

2018-05-16 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.

Also don't bother handling proc_create* failures - the driver works
perfectly fine without the proc files, and the cleanup will handle
missing files gracefully.

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, _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 = _seq_fops },
-   { .name = "pvc",.proc_fops = _seq_fops },
-   { .name = "svc",.proc_fops = _seq_fops },
-   { .name = "vc", .proc_fops = _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(_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, _dev_seq_ops);
+   proc_create("pvc", 0444, atm_proc_root, _seq_fops);
+   proc_create("svc", 0444, atm_proc_root, _seq_fops);
+   proc_create("vc", 0444, atm_proc_root, _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 32/42] neigh: switch to proc_create_seq_data

2018-05-16 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,
- _stat_seq_fops, tbl))
+   if (!proc_create_seq_data(tbl->id, 0, init_net.proc_net_stat,
+ _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, _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 29/42] rtc/proc: switch to proc_create_single_data

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

Signed-off-by: Christoph Hellwig 
Acked-by: Alexandre Belloni 
---
 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, _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 25/42] jfs: simplify procfs code

2018-05-16 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",_lmstats_proc_fops, },
-   { "txstats",_txstats_proc_fops, },
-   { "xtstat", _xtstat_proc_fops, },
-   { "mpstat", _mpstat_proc_fops, },
-#endif
-#ifdef CONFIG_JFS_DEBUG
-   { "TxAnchor",   _txanchor_proc_fops, },
-   { "loglevel",   _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, _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
+++ 

[PATCH 26/42] staging/rtl8192u: simplify procfs code

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

Also don't bother handling proc_create* failures - the driver works
perfectly fine without the proc files, and the cleanup will handle
missing files gracefully.

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",   _get_stats_rx },
-   { "stats-tx",   _get_stats_tx },
-   { "stats-ap",   _get_stats_ap },
-   { "registers",  _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,
- _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 23/42] afs: simplify procfs code

2018-05-16 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, _proc_cells_fops) ||
!proc_create("rootcell", 0644, net->proc_afs, 
_proc_rootcell_fops) ||
-   !proc_create("servers", 0644, net->proc_afs, 
_proc_servers_fops) ||
-   !proc_create("stats", 0644, net->proc_afs, _proc_stats_fops) ||
+   !proc_create_seq("servers", 0644, net->proc_afs, 
_proc_servers_ops) ||
+   !proc_create_single("stats", 0644, net->proc_afs, 
afs_proc_stats_show) ||
!proc_create("sysname", 0644, net->proc_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, _proc_cells_ops);
-   if (ret < 0)
-   return ret;
-
-   m = file->private_data;
-   m->private = PDE_DATA(inode);
-   return 0;
+   return seq_open(file, _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,
- _proc_cell_vlservers_fops, cell) ||
-   !proc_create_data("volumes", 0, dir,
- _proc_cell_volumes_fops, cell))
+   if (!proc_create_seq_data("vlservers", 0, dir,
+   _proc_cell_vlservers_ops, cell))
+   goto error_tree;
+   if (!proc_create_seq_data("volumes", 0, dir, _proc_cell_volumes_ops,
+   cell))
goto error_tree;
 
_leave(" = 0");
@@ -458,29 +425,6 @@ void afs_proc_cell_remove(struct afs_net *net, struct 
afs_cell *cell)

[PATCH 20/42] sgi-gru: simplify procfs code

2018-05-16 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, _seq_ops);
-}
-
-static int gru_open(struct inode *inode, struct file *file)
-{
-   return seq_open(file, _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, _fops},
-   {"mcs_statistics", 0644, _statistics_fops},
-   {"debug_options", 0644, _fops},
-   {"cch_status", 0444, _fops},
-   {"gru_status", 0444, _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, _fops))
+   goto err;
+   if (!proc_create("mcs_statistics", 0644, proc_gru, 
_statistics_fops))
+   goto err;
+   if (!proc_create("debug_options", 0644, proc_gru, _fops))
+   goto err;
+   if (!proc_create_seq("cch_status", 0444, proc_gru, _seq_ops))
+   goto err;
+   if (!proc_create_seq("gru_status", 0444, proc_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 27/42] resource: switch to proc_create_seq_data

2018-05-16 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(_lock);
for (p = p->child; p && l < *pos; p = r_next(m, p, ))
@@ -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, _op);
-   if (!res) {
-   struct seq_file *m = file->private_data;
-   m->private = _resource;
-   }
-   return res;
-}
-
-static int iomem_open(struct inode *inode, struct file *file)
-{
-   int res = seq_open(file, _op);
-   if (!res) {
-   struct seq_file *m = file->private_data;
-   m->private = _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, _ioports_operations);
-   proc_create("iomem", 0, NULL, _iomem_operations);
+   proc_create_seq_data("ioports", 0, NULL, _op,
+   _resource);
+   proc_create_seq_data("iomem", 0, NULL, _op, _resource);
return 0;
 }
 __initcall(ioresources_init);
-- 
2.17.0

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


[PATCH 31/42] hostap: switch to proc_create_{seq,single}_data

2018-05-16 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(>mac_restrictions.lock);
return seq_list_start_head(>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, >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(>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, _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(>sta_table_lock);
return seq_list_start_head(>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, >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(>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, _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,
-   .read   = seq_read,

[PATCH 17/42] proc: introduce proc_create_net{,_data}

2018-05-16 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 7df07337d69c..ce61231e96ea 100644
--- a/drivers/net/ppp/pppoe.c
+++ b/drivers/net/ppp/pppoe.c
@@ -1096,21 +1096,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, _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 = {
@@ -1146,7 +1131,8 @@ static __net_init int pppoe_init_net(struct net *net)
 
rwlock_init(>hash_lock);
 
-   pde = proc_create("pppoe", 0444, net->proc_net, _seq_fops);
+   pde = proc_create_net("pppoe", 0444, net->proc_net,
+   _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(struct 

[PATCH 22/42] sg: simplify procfs code

2018-05-16 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.

Also don't bother handling proc_create* failures - the driver works
perfectly fine without the proc files, and the cleanup will handle
missing files gracefully.

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(_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", _fops},
-   {"debug", _fops},
-   {"def_reserved_size", _fops},
-   {"device_hdr", _fops},
-   {"devices", _fops},
-   {"device_strs", _fops},
-   {"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 = 

[PATCH 24/42] ext4: simplify procfs code

2018-05-16 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, _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), _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(>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);
+   

[PATCH 28/42] drbd: switch to proc_create_single

2018-05-16 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, 
_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 21/42] megaraid: simplify procfs code

2018-05-16 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.

Also don't bother handling proc_create* failures - the driver works
perfectly fine without the proc files, and the cleanup will handle
missing files gracefully.

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(>dev->dev, "proc_mkdir failed\n");
return;
}
 
-   for (f = mega_proc_files; f->name; f++) {
-   de = proc_create_data(f->name, S_IRUSR, dir, _proc_fops,
- f->show);
-   if (!de) {
-   dev_warn(>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, 

[PATCH 34/42] netfilter/x_tables: switch to proc_create_seq_private

2018-05-16 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, _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, _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, _match_ops,
-   (void *)(unsigned long)af);
+   proc = proc_create_seq_private(buf, 0440, net->proc_net,
+   _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, _target_ops,
-   (void *)(unsigned long)af);
+   proc = proc_create_seq_private(buf, 0440, net->proc_net,
+_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 15/42] netfilter/x_tables: simplify Ñ•eq_file code

2018-05-16 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([af].mutex);
return seq_list_start(>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, >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([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, _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, _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([NFPROTO_UNSPEC].mutex);
-   mutex_lock([trav->nfproto].mutex);
+   mutex_lock([nfproto].mutex);
trav->head = trav->curr = is_target ?
-   [trav->nfproto].target : [trav->nfproto].match;
+   [nfproto].target : [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([NFPROTO_UNSPEC].mutex);
break;
case MTTG_TRAV_NFP_SPEC:
-   mutex_unlock([trav->nfproto].mutex);
+   mutex_unlock([nfproto].mutex);
break;
}
 }
@@ -1680,8 +1667,6 @@ static int xt_match_open(struct inode *inode, struct file 
*file)
trav = __seq_open_private(file, _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, _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

[PATCH 18/42] proc: introduce proc_create_net_single

2018-05-16 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 c99fd183f034..7d94fa005b0d 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, , data);
+   if (!p)
+   return NULL;
+   p->proc_fops = _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 9dcde9644253..e518352137e7 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 

[PATCH 04/42] proc: simplify proc_register calling conventions

2018-05-16 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(>low_ino);
-   if (ret)
-   return ret;
+   if (proc_alloc_inum(>low_ino))
+   goto out_free_entry;
 
write_lock(_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(_subdir_lock);
-   proc_free_inum(dp->low_ino);
-   return -EEXIST;
+   goto out_free_inum;
}
write_unlock(_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 = _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 = _dir_operations;
ent->proc_iops = _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 = _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


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

2018-05-16 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 b61a770884fa..51559a8c6e57 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -2582,12 +2582,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 = 
>udp_table->hash[state->bucket];
+   struct udp_hslot *hslot = 
>udp_table->hash[state->bucket];
 
if (hlist_empty(>head))
continue;
@@ -2596,7 +2597,7 @@ static struct sock *udp_get_first(struct seq_file *seq, 
int start)
sk_for_each(sk, >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(>lock);
@@ -2608,16 +2609,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(>udp_table->hash[state->bucket].lock);
+   if (state->bucket <= afinfo->udp_table->mask)
+   
spin_unlock_bh(>udp_table->hash[state->bucket].lock);
return udp_get_first(seq, state->bucket + 1);
}
return sk;
@@ -2633,15 +2635,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;
 
@@ -2653,56 +2656,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(struct seq_file *seq, void *v)
+void 

[PATCH 08/42] proc: introduce proc_create_single{,_data}

2018-05-16 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  | 51 ++--
 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 

[PATCH 05/42] proc: add a proc_create_reg helper

2018-05-16 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 = _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(, name, mode, 1);
-   if (!pde)
-   goto out;
-   pde->proc_fops = proc_fops;
-   pde->data = data;
-   pde->proc_iops = _file_inode_operations;
-   return proc_register(parent, pde);
-out:
-   return NULL;
+   p = proc_create_reg(name, mode, , 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 13/42] ipv6/flowlabel: simplify pid namespace lookup

2018-05-16 Thread Christoph Hellwig
The code should be using the pid namespace from the procfs mount
instead of trying to look it up during open.

Suggested-by: Eric W. Biederman 
Signed-off-by: Christoph Hellwig 
---
 net/ipv6/ip6_flowlabel.c | 29 ++---
 1 file changed, 6 insertions(+), 23 deletions(-)

diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c
index c05c4e82a7ca..2fbd9bed764a 100644
--- a/net/ipv6/ip6_flowlabel.c
+++ b/net/ipv6/ip6_flowlabel.c
@@ -754,6 +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);
+
+   state->pid_ns = proc_pid_ns(file_inode(seq->file));
+
rcu_read_lock_bh();
return *pos ? ip6fl_get_idx(seq, *pos - 1) : SEQ_START_TOKEN;
 }
@@ -810,36 +814,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, _seq_ops,
+   return seq_open_net(inode, file, _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 19/42] acpi/battery: simplify procfs code

2018-05-16 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

[PATCH 16/42] net: move seq_file_single_net to

2018-05-16 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 _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 _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 12/42] ipv{4, 6}/raw: simplify Ñ•eq_file code

2018-05-16 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, >h->ht[state->bucket])
+   sk_for_each(sk, >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(>h->ht[state->bucket]);
+   sk = sk_head(>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(>h->lock);
+   read_lock(>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(>h->lock);
+   read_unlock(>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, _v4_hashinfo, _seq_ops);
+   return seq_open_net(inode, file, _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, _seq_fops))
+   if (!proc_create_data("raw", 0444, net->proc_net, _seq_fops,
+   _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, _v6_hashinfo, _seq_ops);
+   return seq_open_net(inode, file, _seq_ops,
+   sizeof(struct raw_iter_state));
 }
 

[PATCH 14/42] net/kcm: simplify proc registration

2018-05-16 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, >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, _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   = _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,
-_stats_seq_fops)) {
-   err = -ENOMEM;
+_stats_seq_fops))
goto out_kcm_stats;
-   }
 
-   err = kcm_proc_register(net, _seq_muxinfo);
-   if (err)
+   if (!proc_create("kcm", 0444, net->proc_net, _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, _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 11/42] ipv{4,6}/ping: simplify proc file creation

2018-05-16 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 56a010622f70..4d21c24dba78 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -1150,58 +1150,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, >seq_ops,
+   return seq_open_net(inode, file, _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   = _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, _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, _v4_seq_afinfo);
-}
 
 static void __net_exit ping_v4_proc_exit_net(struct net *net)
 {
-   ping_proc_unregister(net, _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   = _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,
+};
+
+static int 

[PATCH 10/42] ipv{4,6}/tcp: simplify procfs registration

2018-05-16 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(>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, 
_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 

[PATCH 07/42] proc: introduce proc_create_seq_private

2018-05-16 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, _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, _locks_operations);
+   proc_create_seq_private("locks", 0, NULL, _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 = _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..bcfe830ffd59 100644
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -46,6 +46,7 @@ struct proc_dir_entry {
const struct file_operations *proc_fops;
const struct seq_operations *seq_ops;
void *data;
+   unsigned int state_size;
unsigned int low_ino;
nlink_t nlink;
kuid_t uid;
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 f368a896a8cb..314713a48817 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) \
-   proc_create_seq_data(name, mode, 

[PATCH 06/42] proc: introduce proc_create_seq{,_data}

2018-05-16 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, _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, _fops);
+   proc_create_seq(ioc_list->name, 0, dir, _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, _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, _proc_fops);
+   perfmon_dir = proc_create_seq("perfmon", S_IRUGO, NULL, _seq_ops);
if (perfmon_dir == NULL) {
printk(KERN_ERR "perfmon: cannot create /proc entry, perfmon 
disabled\n");
pmu_conf = 

[PATCH 02/42] proc: introduce a proc_pid_ns helper

2018-05-16 Thread Christoph Hellwig
Factor out retrieving the per-sb pid namespaces from the sb private data
into an easier to understand helper.

Suggested-by: Eric W. Biederman 
Signed-off-by: Christoph Hellwig 
---
 fs/proc/array.c |  7 +--
 fs/proc/base.c  | 18 --
 fs/proc/self.c  |  4 ++--
 fs/proc/thread_self.c   |  4 ++--
 include/linux/proc_fs.h |  6 ++
 5 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/fs/proc/array.c b/fs/proc/array.c
index ae2c807fd719..911f66924d81 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -677,12 +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;
-   pid_t pid;
-
-   pid = pid_nr_ns(v, inode->i_sb->s_fs_info);
-   seq_printf(seq, "%d ", pid);
-
+   seq_printf(seq, "%d ", pid_nr_ns(v, proc_pid_ns(seq->private)));
return 0;
 }
 
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 1b2ede6abcdf..29237cad19fd 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -698,7 +698,7 @@ static bool has_pid_permissions(struct pid_namespace *pid,
 
 static int proc_pid_permission(struct inode *inode, int mask)
 {
-   struct pid_namespace *pid = inode->i_sb->s_fs_info;
+   struct pid_namespace *pid = proc_pid_ns(inode);
struct task_struct *task;
bool has_perms;
 
@@ -733,13 +733,11 @@ static const struct inode_operations 
proc_def_inode_operations = {
 static int proc_single_show(struct seq_file *m, void *v)
 {
struct inode *inode = m->private;
-   struct pid_namespace *ns;
-   struct pid *pid;
+   struct pid_namespace *ns = proc_pid_ns(inode);
+   struct pid *pid = proc_pid(inode);
struct task_struct *task;
int ret;
 
-   ns = inode->i_sb->s_fs_info;
-   pid = proc_pid(inode);
task = get_pid_task(pid, PIDTYPE_PID);
if (!task)
return -ESRCH;
@@ -1410,7 +1408,7 @@ static const struct file_operations 
proc_fail_nth_operations = {
 static int sched_show(struct seq_file *m, void *v)
 {
struct inode *inode = m->private;
-   struct pid_namespace *ns = inode->i_sb->s_fs_info;
+   struct pid_namespace *ns = proc_pid_ns(inode);
struct task_struct *p;
 
p = get_proc_task(inode);
@@ -1782,8 +1780,8 @@ int pid_getattr(const struct path *path, struct kstat 
*stat,
u32 request_mask, unsigned int query_flags)
 {
struct inode *inode = d_inode(path->dentry);
+   struct pid_namespace *pid = proc_pid_ns(inode);
struct task_struct *task;
-   struct pid_namespace *pid = path->dentry->d_sb->s_fs_info;
 
generic_fillattr(inode, stat);
 
@@ -2337,7 +2335,7 @@ static int proc_timers_open(struct inode *inode, struct 
file *file)
return -ENOMEM;
 
tp->pid = proc_pid(inode);
-   tp->ns = inode->i_sb->s_fs_info;
+   tp->ns = proc_pid_ns(inode);
return 0;
 }
 
@@ -3239,7 +3237,7 @@ static struct tgid_iter next_tgid(struct pid_namespace 
*ns, struct tgid_iter ite
 int proc_pid_readdir(struct file *file, struct dir_context *ctx)
 {
struct tgid_iter iter;
-   struct pid_namespace *ns = file_inode(file)->i_sb->s_fs_info;
+   struct pid_namespace *ns = proc_pid_ns(file_inode(file));
loff_t pos = ctx->pos;
 
if (pos >= PID_MAX_LIMIT + TGID_OFFSET)
@@ -3588,7 +3586,7 @@ static int proc_task_readdir(struct file *file, struct 
dir_context *ctx)
/* f_version caches the tgid value that the last readdir call couldn't
 * return. lseek aka telldir automagically resets f_version to 0.
 */
-   ns = inode->i_sb->s_fs_info;
+   ns = proc_pid_ns(inode);
tid = (int)file->f_version;
file->f_version = 0;
for (task = first_tid(proc_pid(inode), tid, ctx->pos - 2, ns);
diff --git a/fs/proc/self.c b/fs/proc/self.c
index 4d7d061696b3..127265e5c55f 100644
--- a/fs/proc/self.c
+++ b/fs/proc/self.c
@@ -12,7 +12,7 @@ static const char *proc_self_get_link(struct dentry *dentry,
  struct inode *inode,
  struct delayed_call *done)
 {
-   struct pid_namespace *ns = inode->i_sb->s_fs_info;
+   struct pid_namespace *ns = proc_pid_ns(inode);
pid_t tgid = task_tgid_nr_ns(current, ns);
char *name;
 
@@ -36,7 +36,7 @@ static unsigned self_inum __ro_after_init;
 int proc_setup_self(struct super_block *s)
 {
struct inode *root_inode = d_inode(s->s_root);
-   struct pid_namespace *ns = s->s_fs_info;
+   struct pid_namespace *ns = proc_pid_ns(root_inode);
struct dentry *self;

inode_lock(root_inode);
diff --git a/fs/proc/thread_self.c b/fs/proc/thread_self.c
index 9d2efaca499f..b905010ca9eb 100644
--- a/fs/proc/thread_self.c
+++ b/fs/proc/thread_self.c
@@ -12,7 +12,7 @@ static const char 

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

2018-05-16 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/42] proc: don't detour through seq->private to get the inode

2018-05-16 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
---
 fs/proc/array.c | 20 ++--
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/fs/proc/array.c b/fs/proc/array.c
index 911f66924d81..4a8e413bf59b 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -677,20 +677,22 @@ get_children_pid(struct inode *inode, struct pid 
*pid_prev, loff_t pos)
 
 static int children_seq_show(struct seq_file *seq, void *v)
 {
-   seq_printf(seq, "%d ", pid_nr_ns(v, proc_pid_ns(seq->private)));
+   struct inode *inode = file_inode(seq->file);
+
+   seq_printf(seq, "%d ", pid_nr_ns(v, proc_pid_ns(inode)));
return 0;
 }
 
 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;
@@ -711,17 +713,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, _seq_ops);
-   if (ret)
-   return ret;
-
-   m = file->private_data;
-   m->private = inode;
-
-   return ret;
+   return seq_open(file, _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


simplify procfs code for seq_file instances V3

2018-05-16 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.3

Gitweb:


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

Changes since V2:
 - use unsigned int for state_size everywhere
 - move state_size around in proc_dir_entry to use a struct packing hole
 - update SIZEOF_PDE_INLINE_NAME
 - added a new proc_pid_ns helper
 - improved a few changelogs
 - added back a nubus comment
 - minor typo fix
 - collected various ACKs

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


Re: [PATCH v2 08/11] staging: mt7621-gpio: avoid devm_kzalloc() hidden inside declarations

2018-05-16 Thread Dan Carpenter
On Wed, May 16, 2018 at 10:56:05AM +0200, Sergio Paracuellos wrote:
> On Wed, May 16, 2018 at 11:04:52AM +0300, Dan Carpenter wrote:
> > On Wed, May 16, 2018 at 07:30:01AM +0200, Sergio Paracuellos wrote:
> > > diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
> > > b/drivers/staging/mt7621-gpio/gpio-mt7621.c
> > > index c701259..2d16d62 100644
> > > --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
> > > +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
> > > @@ -156,17 +156,18 @@ mediatek_gpio_bank_probe(struct platform_device 
> > > *pdev, struct device_node *bank)
> > >  {
> > >   struct mtk_data *gpio_data = dev_get_drvdata(>dev);
> > >   const __be32 *id = of_get_property(bank, "reg", NULL);
> > > - struct mtk_gc *rg = devm_kzalloc(>dev,
> > > - sizeof(struct mtk_gc), GFP_KERNEL);
> > > + struct mtk_gc *rg;
> > >   int ret;
> > >  
> > > - if (!rg || !id || be32_to_cpu(*id) > MTK_MAX_BANK)
> > > + if (!id || be32_to_cpu(*id) > MTK_MAX_BANK)
> > 
> > You didn't introduce this, but it should be >= MTK_MAX_BANK.  (Off by
> > one).
> 
> Totally true, thanks for pointing this out, Dan. 
> I'll fix this and send v3 of the whole series.

I think you can just send the off by one fix by itself unless there are
complaints about this patch series.  The bug was there before, so it's
not a new thing.

regards,
dan carpenter

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


Re: [PATCH 4/4] staging: lustre: obdclass: change object lookup to no wait mode

2018-05-16 Thread Dilger, Andreas
On May 16, 2018, at 02:00, Dan Carpenter  wrote:
> 
> On Tue, May 15, 2018 at 04:02:55PM +0100, James Simmons wrote:
>> 
/*
 * Allocate new object. This may result in rather complicated
 * operations, including fld queries, inode loading, etc.
 */
o = lu_object_alloc(env, dev, f, conf);
 -  if (IS_ERR(o))
 +  if (unlikely(IS_ERR(o)))
return o;
 
>>> 
>>> This is an unrelated and totally pointless.  likely/unlikely annotations
>>> hurt readability, and they should only be added if it's something which
>>> is going to show up in benchmarking.  lu_object_alloc() is already too
>>> slow for the unlikely() to make a difference and anyway IS_ERR() has an
>>> unlikely built in so it's duplicative...
>> 
>> Sounds like a good checkpatch case to test for :-)
> 
> The likely/unlikely annotations have their place in fast paths so a
> checkpatch warning would get annoying...

I think James was suggesting a check for unlikely(IS_ERR()), or possibly
a check for unlikely() on something that is already unlikely() after CPP
expansion.

Cheers, Andreas
--
Andreas Dilger
Lustre Principal Architect
Intel Corporation







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


[PATCH v3 08/11] staging: mt7621-gpio: avoid devm_kzalloc() hidden inside declarations and refactor function a bit

2018-05-16 Thread Sergio Paracuellos
Driver probe function includes an allocation using devm_kzalloc
which is "hidden" a bit inside the declarations. Extract this
to a better place to increase readability. Also because we are
allocating zeroed memory 'memset' statement is not needed at all.
Condition for checking for a valid gpio id is wrong and it should
be greater or equal instead of only greater so update to be the
good one.

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

diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index c701259..016475f 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -156,17 +156,18 @@ mediatek_gpio_bank_probe(struct platform_device *pdev, 
struct device_node *bank)
 {
struct mtk_data *gpio_data = dev_get_drvdata(>dev);
const __be32 *id = of_get_property(bank, "reg", NULL);
-   struct mtk_gc *rg = devm_kzalloc(>dev,
-   sizeof(struct mtk_gc), GFP_KERNEL);
+   struct mtk_gc *rg;
int ret;
 
-   if (!rg || !id || be32_to_cpu(*id) > MTK_MAX_BANK)
+   if (!id || be32_to_cpu(*id) >= MTK_MAX_BANK)
+   return -EINVAL;
+
+   rg = devm_kzalloc(>dev, sizeof(struct mtk_gc), GFP_KERNEL);
+   if (!rg)
return -ENOMEM;
 
gpio_data->gc_map[be32_to_cpu(*id)] = rg;
 
-   memset(rg, 0, sizeof(struct mtk_gc));
-
spin_lock_init(>lock);
 
rg->chip.parent = >dev;
-- 
2.7.4

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


[PATCH v3 11/11] staging: mt7621-gpio: update TODO list

2018-05-16 Thread Sergio Paracuellos
Some of the remaining stuff included in TODO list
have been complete. So update this file accordly.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-gpio/TODO | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/mt7621-gpio/TODO b/drivers/staging/mt7621-gpio/TODO
index 9077b16..9089833 100644
--- a/drivers/staging/mt7621-gpio/TODO
+++ b/drivers/staging/mt7621-gpio/TODO
@@ -1,7 +1,4 @@
 
-- general code review and clean up 
-- avoid global variables and use drvdata allocated instead
-- ensure device-tree requirements are documented
 - make sure interrupts work
 
 Cc:  NeilBrown 
-- 
2.7.4

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


[PATCH v3 02/11] staging: mt7621-gpio: update TODO file

2018-05-16 Thread Sergio Paracuellos
This commit updates TODO file with missing things to
get this driver ready to be mainlined.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-gpio/TODO | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/mt7621-gpio/TODO b/drivers/staging/mt7621-gpio/TODO
index 7143905..9077b16 100644
--- a/drivers/staging/mt7621-gpio/TODO
+++ b/drivers/staging/mt7621-gpio/TODO
@@ -1,5 +1,7 @@
 
-- general code review and clean up
+- general code review and clean up 
+- avoid global variables and use drvdata allocated instead
 - ensure device-tree requirements are documented
+- make sure interrupts work
 
 Cc:  NeilBrown 
-- 
2.7.4

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


[PATCH v3 06/11] staging: mt7621-dts: add interrupt device tree nodes for the gpio controller

2018-05-16 Thread Sergio Paracuellos
The GPIO controller of mt7621 can receive interrupts on any
of the GPIOs, either edge or level. It then interrupts the CPU using
GIC INT12. Update device tree accordly.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-dts/mt7621.dtsi | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/staging/mt7621-dts/mt7621.dtsi 
b/drivers/staging/mt7621-dts/mt7621.dtsi
index 115eb04..240d396 100644
--- a/drivers/staging/mt7621-dts/mt7621.dtsi
+++ b/drivers/staging/mt7621-dts/mt7621.dtsi
@@ -67,6 +67,9 @@
compatible = "mediatek,mt7621-gpio";
reg = <0x600 0x100>;
 
+   interrupt-parent = <>;
+   interrupts = ;
+
gpio0: bank@0 {
reg = <0>;
compatible = "mediatek,mt7621-gpio-bank";
-- 
2.7.4

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


[PATCH v3 04/11] staging: mt7621-gpio: replace 'mtk' to use correct one 'mediatek'

2018-05-16 Thread Sergio Paracuellos
Gpio driver is using mtk and there is already 'mediatek' binding
defined for this maker. Update driver to use it instead the custom
one 'mtk'.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index a577381..7d17949 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -323,7 +323,7 @@ mediatek_gpio_probe(struct platform_device *pdev)
}
 
for_each_child_of_node(np, bank)
-   if (of_device_is_compatible(bank, "mtk,mt7621-gpio-bank"))
+   if (of_device_is_compatible(bank, "mediatek,mt7621-gpio-bank"))
mediatek_gpio_bank_probe(pdev, bank);
 
if (mediatek_gpio_irq_domain)
@@ -334,7 +334,7 @@ mediatek_gpio_probe(struct platform_device *pdev)
 }
 
 static const struct of_device_id mediatek_gpio_match[] = {
-   { .compatible = "mtk,mt7621-gpio" },
+   { .compatible = "mediatek,mt7621-gpio" },
{},
 };
 MODULE_DEVICE_TABLE(of, mediatek_gpio_match);
-- 
2.7.4

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


[PATCH v3 10/11] staging: mt7621-gpio: use MTK_BANK_WIDTH instead of magic number

2018-05-16 Thread Sergio Paracuellos
There are some places where magic number '32' is being used to get
the gpio bank. There already exist a definition MTK_BANK_WIDTH
with this value, so just use it instead.

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

diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index 9fcdaf4..0b403f9 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -229,7 +229,7 @@ mediatek_gpio_irq_unmask(struct irq_data *d)
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct mtk_data *gpio_data = gpiochip_get_data(gc);
int pin = d->hwirq;
-   int bank = pin / 32;
+   int bank = pin / MTK_BANK_WIDTH;
struct mtk_gc *rg = gpio_data->gc_map[bank];
unsigned long flags;
u32 rise, fall;
@@ -252,7 +252,7 @@ mediatek_gpio_irq_mask(struct irq_data *d)
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct mtk_data *gpio_data = gpiochip_get_data(gc);
int pin = d->hwirq;
-   int bank = pin / 32;
+   int bank = pin / MTK_BANK_WIDTH;
struct mtk_gc *rg = gpio_data->gc_map[bank];
unsigned long flags;
u32 rise, fall;
@@ -275,7 +275,7 @@ mediatek_gpio_irq_type(struct irq_data *d, unsigned int 
type)
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct mtk_data *gpio_data = gpiochip_get_data(gc);
int pin = d->hwirq;
-   int bank = pin / 32;
+   int bank = pin / MTK_BANK_WIDTH;
struct mtk_gc *rg = gpio_data->gc_map[bank];
u32 mask = BIT(d->hwirq);
 
-- 
2.7.4

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


[PATCH v3 01/11] staging: mt7621-gpio: dt-bindings: add documentation for mt7621-gpio

2018-05-16 Thread Sergio Paracuellos
This commit add missing dt bindings documentation for mt7621-gpio
driver. There is some missing stuff here about interrupts with is
not also being used in the mt7621.dtsi file. So just include in
staging a incomplete version before moving this to kernel's dt-bindings
place.

Signed-off-by: Sergio Paracuellos 
---
 .../staging/mt7621-gpio/mediatek,mt7621-gpio.txt   | 51 ++
 1 file changed, 51 insertions(+)
 create mode 100644 drivers/staging/mt7621-gpio/mediatek,mt7621-gpio.txt

diff --git a/drivers/staging/mt7621-gpio/mediatek,mt7621-gpio.txt 
b/drivers/staging/mt7621-gpio/mediatek,mt7621-gpio.txt
new file mode 100644
index 000..54de9f7
--- /dev/null
+++ b/drivers/staging/mt7621-gpio/mediatek,mt7621-gpio.txt
@@ -0,0 +1,51 @@
+Mediatek SoC GPIO controller bindings
+
+The IP core used inside these SoCs has 3 banks of 32 GPIOs each.
+The registers of all the banks are interwoven inside one single IO range.
+We load one GPIO controller instance per bank. To make this possible
+we support 2 types of nodes. The parent node defines the memory I/O range and
+has 3 children each describing a single bank.
+
+Required properties for the top level node:
+- compatible:
+  - "mediatek,mt7621-gpio" for Mediatek controllers
+- reg : Physical base address and length of the controller's registers
+
+Required properties for the GPIO bank node:
+- compatible:
+  - "mediatek,mt7621-gpio-bank" for Mediatek banks
+- #gpio-cells : Should be two.
+  - first cell is the pin number
+  - second cell is used to specify optional parameters (unused)
+- gpio-controller : Marks the device node as a GPIO controller
+- reg : The id of the bank that the node describes.
+
+Example:
+   gpio@600 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   compatible = "mediatek,mt7621-gpio";
+   reg = <0x600 0x100>;
+
+   gpio0: bank@0 {
+   reg = <0>;
+   compatible = "mediatek,mt7621-gpio-bank";
+   gpio-controller;
+   #gpio-cells = <2>;
+   };
+
+   gpio1: bank@1 {
+   reg = <1>;
+   compatible = "mediatek,mt7621-gpio-bank";
+   gpio-controller;
+   #gpio-cells = <2>;
+   };
+
+   gpio2: bank@2 {
+   reg = <2>;
+   compatible = "mediatek,mt7621-gpio-bank";
+   gpio-controller;
+   #gpio-cells = <2>;
+   };
+   };
-- 
2.7.4

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


[PATCH v3 09/11] staging: mt7621-gpio: use ternary operator in return in mediatek_gpio_get_direction

2018-05-16 Thread Sergio Paracuellos
This commits replaces if statement and two returns in favour
of a only one return using a ternary operator.

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

diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index 016475f..9fcdaf4 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -135,10 +135,7 @@ mediatek_gpio_get_direction(struct gpio_chip *chip, 
unsigned int offset)
t = mtk_gpio_r32(rg, GPIO_REG_CTRL);
spin_unlock_irqrestore(>lock, flags);
 
-   if (t & BIT(offset))
-   return 0;
-
-   return 1;
+   return (t & BIT(offset)) ? 0 : 1;
 }
 
 static int
-- 
2.7.4

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


[PATCH v3 05/11] staging: mt7621-gpio: avoid use of globals and use platform_data instead

2018-05-16 Thread Sergio Paracuellos
Gpio driver have a some globals which can be avoided just
using platform_data in a proper form. This commit adds a new
struct mtk_data which includes all of those globals setting them
using platform_set_drvdata and devm_gpiochip_add_data functions.
With this properly set we are able to retrieve driver data along
the code using kernel api's so globals are not needed anymore.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 85 +--
 1 file changed, 59 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index 7d17949..c701259 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -31,17 +31,20 @@ enum mediatek_gpio_reg {
GPIO_REG_EDGE,
 };
 
-static void __iomem *mediatek_gpio_membase;
-static int mediatek_gpio_irq;
-static struct irq_domain *mediatek_gpio_irq_domain;
-
-static struct mtk_gc {
+struct mtk_gc {
struct gpio_chip chip;
spinlock_t lock;
int bank;
u32 rising;
u32 falling;
-} *gc_map[MTK_MAX_BANK];
+};
+
+struct mtk_data {
+   void __iomem *gpio_membase;
+   int gpio_irq;
+   struct irq_domain *gpio_irq_domain;
+   struct mtk_gc *gc_map[MTK_MAX_BANK];
+};
 
 static inline struct mtk_gc
 *to_mediatek_gpio(struct gpio_chip *chip)
@@ -56,15 +59,19 @@ static inline struct mtk_gc
 static inline void
 mtk_gpio_w32(struct mtk_gc *rg, u8 reg, u32 val)
 {
-   iowrite32(val, mediatek_gpio_membase + (reg * 0x10) + (rg->bank * 0x4));
+   struct mtk_data *gpio_data = gpiochip_get_data(>chip);
+   u32 offset = (reg * 0x10) + (rg->bank * 0x4);
+
+   iowrite32(val, gpio_data->gpio_membase + offset);
 }
 
 static inline u32
 mtk_gpio_r32(struct mtk_gc *rg, u8 reg)
 {
+   struct mtk_data *gpio_data = gpiochip_get_data(>chip);
u32 offset = (reg * 0x10) + (rg->bank * 0x4);
 
-   return ioread32(mediatek_gpio_membase + offset);
+   return ioread32(gpio_data->gpio_membase + offset);
 }
 
 static void
@@ -137,23 +144,26 @@ mediatek_gpio_get_direction(struct gpio_chip *chip, 
unsigned int offset)
 static int
 mediatek_gpio_to_irq(struct gpio_chip *chip, unsigned int pin)
 {
+   struct mtk_data *gpio_data = gpiochip_get_data(chip);
struct mtk_gc *rg = to_mediatek_gpio(chip);
 
-   return irq_create_mapping(mediatek_gpio_irq_domain,
+   return irq_create_mapping(gpio_data->gpio_irq_domain,
  pin + (rg->bank * MTK_BANK_WIDTH));
 }
 
 static int
 mediatek_gpio_bank_probe(struct platform_device *pdev, struct device_node 
*bank)
 {
+   struct mtk_data *gpio_data = dev_get_drvdata(>dev);
const __be32 *id = of_get_property(bank, "reg", NULL);
struct mtk_gc *rg = devm_kzalloc(>dev,
sizeof(struct mtk_gc), GFP_KERNEL);
+   int ret;
 
if (!rg || !id || be32_to_cpu(*id) > MTK_MAX_BANK)
return -ENOMEM;
 
-   gc_map[be32_to_cpu(*id)] = rg;
+   gpio_data->gc_map[be32_to_cpu(*id)] = rg;
 
memset(rg, 0, sizeof(struct mtk_gc));
 
@@ -169,10 +179,17 @@ mediatek_gpio_bank_probe(struct platform_device *pdev, 
struct device_node *bank)
rg->chip.get_direction = mediatek_gpio_get_direction;
rg->chip.get = mediatek_gpio_get;
rg->chip.set = mediatek_gpio_set;
-   if (mediatek_gpio_irq_domain)
+   if (gpio_data->gpio_irq_domain)
rg->chip.to_irq = mediatek_gpio_to_irq;
rg->bank = be32_to_cpu(*id);
 
+   ret = devm_gpiochip_add_data(>dev, >chip, gpio_data);
+   if (ret < 0) {
+   dev_err(>dev, "Could not register gpio %d, ret=%d\n",
+   rg->chip.ngpio, ret);
+   return ret;
+   }
+
/* set polarity to low for all gpios */
mtk_gpio_w32(rg, GPIO_REG_POL, 0);
 
@@ -184,10 +201,12 @@ mediatek_gpio_bank_probe(struct platform_device *pdev, 
struct device_node *bank)
 static void
 mediatek_gpio_irq_handler(struct irq_desc *desc)
 {
+   struct gpio_chip *gc = irq_desc_get_handler_data(desc);
+   struct mtk_data *gpio_data = gpiochip_get_data(gc);
int i;
 
for (i = 0; i < MTK_MAX_BANK; i++) {
-   struct mtk_gc *rg = gc_map[i];
+   struct mtk_gc *rg = gpio_data->gc_map[i];
unsigned long pending;
int bit;
 
@@ -197,7 +216,7 @@ mediatek_gpio_irq_handler(struct irq_desc *desc)
pending = mtk_gpio_r32(rg, GPIO_REG_STAT);
 
for_each_set_bit(bit, , MTK_BANK_WIDTH) {
-   u32 map = irq_find_mapping(mediatek_gpio_irq_domain,
+   u32 map = irq_find_mapping(gpio_data->gpio_irq_domain,
   (MTK_BANK_WIDTH * i) + bit);
 
generic_handle_irq(map);
@@ -209,9 +228,11 @@ 

[PATCH v3 03/11] staging: mt7621-dts: update gpios related entries to use 'mediatek'

2018-05-16 Thread Sergio Paracuellos
Gpio driver for mt7621 is using 'mtk' as binding but in the kernel
is already defined one for this maker which is 'mediatek'. Update
device tree to use the correct one.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-dts/mt7621.dtsi | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/mt7621-dts/mt7621.dtsi 
b/drivers/staging/mt7621-dts/mt7621.dtsi
index 9d941b5..115eb04 100644
--- a/drivers/staging/mt7621-dts/mt7621.dtsi
+++ b/drivers/staging/mt7621-dts/mt7621.dtsi
@@ -64,26 +64,26 @@
#address-cells = <1>;
#size-cells = <0>;
 
-   compatible = "mtk,mt7621-gpio";
+   compatible = "mediatek,mt7621-gpio";
reg = <0x600 0x100>;
 
gpio0: bank@0 {
reg = <0>;
-   compatible = "mtk,mt7621-gpio-bank";
+   compatible = "mediatek,mt7621-gpio-bank";
gpio-controller;
#gpio-cells = <2>;
};
 
gpio1: bank@1 {
reg = <1>;
-   compatible = "mtk,mt7621-gpio-bank";
+   compatible = "mediatek,mt7621-gpio-bank";
gpio-controller;
#gpio-cells = <2>;
};
 
gpio2: bank@2 {
reg = <2>;
-   compatible = "mtk,mt7621-gpio-bank";
+   compatible = "mediatek,mt7621-gpio-bank";
gpio-controller;
#gpio-cells = <2>;
};
-- 
2.7.4

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


[PATCH v3 07/11] staging: mt7621-gpio: dt-bindings: add interrupt nodes to bindings doc

2018-05-16 Thread Sergio Paracuellos
Interrupt related stuff for gpio controller in mt7621 was missing
in device tree documentation. Add it to complete documentation for
this driver.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-gpio/mediatek,mt7621-gpio.txt | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/mt7621-gpio/mediatek,mt7621-gpio.txt 
b/drivers/staging/mt7621-gpio/mediatek,mt7621-gpio.txt
index 54de9f7..af64092 100644
--- a/drivers/staging/mt7621-gpio/mediatek,mt7621-gpio.txt
+++ b/drivers/staging/mt7621-gpio/mediatek,mt7621-gpio.txt
@@ -4,12 +4,16 @@ The IP core used inside these SoCs has 3 banks of 32 GPIOs 
each.
 The registers of all the banks are interwoven inside one single IO range.
 We load one GPIO controller instance per bank. To make this possible
 we support 2 types of nodes. The parent node defines the memory I/O range and
-has 3 children each describing a single bank.
+has 3 children each describing a single bank. Also the GPIO controller can 
receive
+interrupts on any of the GPIOs, either edge or level. It then interrupts the 
CPU
+using GIC INT12.
 
 Required properties for the top level node:
 - compatible:
   - "mediatek,mt7621-gpio" for Mediatek controllers
 - reg : Physical base address and length of the controller's registers
+- interrupt-parent : phandle of the parent interrupt controller.
+- interrupts = Interrupt specifier for the controllers interrupt
 
 Required properties for the GPIO bank node:
 - compatible:
@@ -28,6 +32,9 @@ Example:
compatible = "mediatek,mt7621-gpio";
reg = <0x600 0x100>;
 
+   interrupt-parent = <>;
+   interrupts = ;
+
gpio0: bank@0 {
reg = <0>;
compatible = "mediatek,mt7621-gpio-bank";
-- 
2.7.4

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


[PATCH v3 00/11] staging: mt7621-gpio: use mediatek as binding instead of custom mtk

2018-05-16 Thread Sergio Paracuellos
The following series updated mt7621-gpio driver to use 'mediatek'
which is already defined in kernel bindings documentation instead
of add a new custom one 'mtk' for this company. mt7621-gpio device-tree
documentation has been added also to the staging driver directory.

v3:
 - Fix condition for check for a valid gpio id in driver probe function
   included in the PATCH 8 ("staging: mt7621-gpio: avoid devm_kzalloc() 
   hidden inside declarations and refactor function a bit") of the series.
 - Rest of patches are not modified at all.

v2:
 - Join some patch ("staging: mt7621-gpio: avoid use of globals
   and use platform_data instead") with the needed fixes to make
   it work pointed out by NeilBrown
 - Add gpio interrupts to documentation and device tree in order to
   can try them
 - Other minor code cleanups have been added also.

After this changes only testing interrupts should be remaining to
get this out of staging.

Hope this helps.

Best regards,
 Sergio

Sergio Paracuellos (11):
  staging: mt7621-gpio: dt-bindings: add documentation for mt7621-gpio
  staging: mt7621-gpio: update TODO file
  staging: mt7621-dts: update gpios related entries to use 'mediatek'
  staging: mt7621-gpio: replace 'mtk' to use correct one 'mediatek'
  staging: mt7621-gpio: avoid use of globals and use platform_data
instead
  staging: mt7621-dts: add interrupt device tree nodes for the gpio
controller
  staging: mt7621-gpio: dt-bindings: add interrupt nodes to bindings doc
  staging: mt7621-gpio: avoid devm_kzalloc() hidden inside declarations
and refactor function a bit
  staging: mt7621-gpio: use ternary operator in return in
mediatek_gpio_get_direction
  staging: mt7621-gpio: use MTK_BANK_WIDTH instead of magic number
  staging: mt7621-gpio: update TODO list

 drivers/staging/mt7621-dts/mt7621.dtsi |  11 +-
 drivers/staging/mt7621-gpio/TODO   |   3 +-
 drivers/staging/mt7621-gpio/gpio-mt7621.c  | 111 +
 .../staging/mt7621-gpio/mediatek,mt7621-gpio.txt   |  58 +++
 4 files changed, 137 insertions(+), 46 deletions(-)
 create mode 100644 drivers/staging/mt7621-gpio/mediatek,mt7621-gpio.txt

-- 
2.7.4

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


Re: [PATCH v2 08/11] staging: mt7621-gpio: avoid devm_kzalloc() hidden inside declarations

2018-05-16 Thread Sergio Paracuellos
On Wed, May 16, 2018 at 11:04:52AM +0300, Dan Carpenter wrote:
> On Wed, May 16, 2018 at 07:30:01AM +0200, Sergio Paracuellos wrote:
> > diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
> > b/drivers/staging/mt7621-gpio/gpio-mt7621.c
> > index c701259..2d16d62 100644
> > --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
> > +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
> > @@ -156,17 +156,18 @@ mediatek_gpio_bank_probe(struct platform_device 
> > *pdev, struct device_node *bank)
> >  {
> > struct mtk_data *gpio_data = dev_get_drvdata(>dev);
> > const __be32 *id = of_get_property(bank, "reg", NULL);
> > -   struct mtk_gc *rg = devm_kzalloc(>dev,
> > -   sizeof(struct mtk_gc), GFP_KERNEL);
> > +   struct mtk_gc *rg;
> > int ret;
> >  
> > -   if (!rg || !id || be32_to_cpu(*id) > MTK_MAX_BANK)
> > +   if (!id || be32_to_cpu(*id) > MTK_MAX_BANK)
> 
> You didn't introduce this, but it should be >= MTK_MAX_BANK.  (Off by
> one).

Totally true, thanks for pointing this out, Dan. 
I'll fix this and send v3 of the whole series.

> 
> regards,
> dan carpenter
> 

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


Re: [PATCH] Delete the goldfish_nand driver.

2018-05-16 Thread Greg KH
On Tue, May 15, 2018 at 01:58:45PM -0700, r...@google.com wrote:
> From: Roman Kiryanov 
> 
> This driver was inherited from qemu1 and not used anymore.
> 
> Signed-off-by: Roman Kiryanov 
> ---
>  drivers/staging/goldfish/Kconfig |   7 -
>  drivers/staging/goldfish/Makefile|   1 -
>  drivers/staging/goldfish/goldfish_nand.c | 441 ---
>  drivers/staging/goldfish/goldfish_nand_reg.h |  76 
>  4 files changed, 525 deletions(-)
>  delete mode 100644 drivers/staging/goldfish/goldfish_nand.c
>  delete mode 100644 drivers/staging/goldfish/goldfish_nand_reg.h

Now that we have the drivers/staging/android/vsoc.c driver, are any of
the goldfish drivers needed anymore?  I can run a virtual android system
on my laptop using the vsoc driver only, no goldfish needed at all.

If not, and goldfish is still needed, what's the plans on getting this
code out of staging?  It's been living there for a while with no forward
progress or updates in a long time.

thanks,

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


Re: [PATCH v2 08/11] staging: mt7621-gpio: avoid devm_kzalloc() hidden inside declarations

2018-05-16 Thread Dan Carpenter
On Wed, May 16, 2018 at 07:30:01AM +0200, Sergio Paracuellos wrote:
> diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
> b/drivers/staging/mt7621-gpio/gpio-mt7621.c
> index c701259..2d16d62 100644
> --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
> +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
> @@ -156,17 +156,18 @@ mediatek_gpio_bank_probe(struct platform_device *pdev, 
> struct device_node *bank)
>  {
>   struct mtk_data *gpio_data = dev_get_drvdata(>dev);
>   const __be32 *id = of_get_property(bank, "reg", NULL);
> - struct mtk_gc *rg = devm_kzalloc(>dev,
> - sizeof(struct mtk_gc), GFP_KERNEL);
> + struct mtk_gc *rg;
>   int ret;
>  
> - if (!rg || !id || be32_to_cpu(*id) > MTK_MAX_BANK)
> + if (!id || be32_to_cpu(*id) > MTK_MAX_BANK)

You didn't introduce this, but it should be >= MTK_MAX_BANK.  (Off by
one).

regards,
dan carpenter

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


Re: [PATCH 4/4] staging: lustre: obdclass: change object lookup to no wait mode

2018-05-16 Thread Dan Carpenter
On Tue, May 15, 2018 at 04:02:55PM +0100, James Simmons wrote:
> 
> > >   /*
> > >* Allocate new object. This may result in rather complicated
> > >* operations, including fld queries, inode loading, etc.
> > >*/
> > >   o = lu_object_alloc(env, dev, f, conf);
> > > - if (IS_ERR(o))
> > > + if (unlikely(IS_ERR(o)))
> > >   return o;
> > >  
> > 
> > This is an unrelated and totally pointless.  likely/unlikely annotations
> > hurt readability, and they should only be added if it's something which
> > is going to show up in benchmarking.  lu_object_alloc() is already too
> > slow for the unlikely() to make a difference and anyway IS_ERR() has an
> > unlikely built in so it's duplicative...
> 
> Sounds like a good checkpatch case to test for :-)

The likely/unlikely annotations have their place in fast paths so a
checkpatch warning would get annoying...

regards,
dan carpenter

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


Re: [PATCH] staging: wlan-ng: fix coding style issues in p80211netdev.h

2018-05-16 Thread Tim Collier
Sorry. This is a duplicate of the previous path for p80211netdev.h,
sent in error. Please ignore.

On Wed, May 16, 2018 at 08:48:54AM +0100, Tim Collier wrote:
> Fix two issues with parameters not aligned to opening parenthesis, as
> reported by checkpatch. File is now clean for checkpatch.
> 
> Signed-off-by: Tim Collier 
> ---
>  drivers/staging/wlan-ng/p80211netdev.h | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/wlan-ng/p80211netdev.h 
> b/drivers/staging/wlan-ng/p80211netdev.h
> index fbac47311f26..d48466d943b4 100644
> --- a/drivers/staging/wlan-ng/p80211netdev.h
> +++ b/drivers/staging/wlan-ng/p80211netdev.h
> @@ -180,11 +180,11 @@ struct wlandevice {
>   int (*close)(struct wlandevice *wlandev);
>   void (*reset)(struct wlandevice *wlandev);
>   int (*txframe)(struct wlandevice *wlandev, struct sk_buff *skb,
> - union p80211_hdr *p80211_hdr,
> - struct p80211_metawep *p80211_wep);
> +union p80211_hdr *p80211_hdr,
> +struct p80211_metawep *p80211_wep);
>   int (*mlmerequest)(struct wlandevice *wlandev, struct p80211msg *msg);
>   int (*set_multicast_list)(struct wlandevice *wlandev,
> -struct net_device *dev);
> +   struct net_device *dev);
>   void (*tx_timeout)(struct wlandevice *wlandev);
>  
>   /* 802.11 State */
> -- 
> 2.11.0
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: wlan-ng: fix coding style issues in p80211netdev.c

2018-05-16 Thread Tim Collier
Fix 2 "Alignment should match open parenthesis" messages issued by
checkpatch.

Signed-off-by: Tim Collier 
---
 drivers/staging/wlan-ng/p80211netdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/wlan-ng/p80211netdev.c 
b/drivers/staging/wlan-ng/p80211netdev.c
index 710ce839493d..8258cb5a335d 100644
--- a/drivers/staging/wlan-ng/p80211netdev.c
+++ b/drivers/staging/wlan-ng/p80211netdev.c
@@ -96,7 +96,7 @@ static int p80211knetdev_init(struct net_device *netdev);
 static int p80211knetdev_open(struct net_device *netdev);
 static int p80211knetdev_stop(struct net_device *netdev);
 static netdev_tx_t p80211knetdev_hard_start_xmit(struct sk_buff *skb,
-struct net_device *netdev);
+struct net_device *netdev);
 static void p80211knetdev_set_multicast_list(struct net_device *dev);
 static int p80211knetdev_do_ioctl(struct net_device *dev, struct ifreq *ifr,
  int cmd);
@@ -322,7 +322,7 @@ static void p80211netdev_rx_bh(unsigned long arg)
  *
  */
 static netdev_tx_t p80211knetdev_hard_start_xmit(struct sk_buff *skb,
-struct net_device *netdev)
+struct net_device *netdev)
 {
int result = 0;
int txresult = -1;
-- 
2.11.0

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


[PATCH] staging: wlan-ng: fix coding style issues in p80211netdev.h

2018-05-16 Thread Tim Collier
Fix two issues with parameters not aligned to opening parenthesis, as
reported by checkpatch. File is now clean for checkpatch.

Signed-off-by: Tim Collier 
---
 drivers/staging/wlan-ng/p80211netdev.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/wlan-ng/p80211netdev.h 
b/drivers/staging/wlan-ng/p80211netdev.h
index fbac47311f26..d48466d943b4 100644
--- a/drivers/staging/wlan-ng/p80211netdev.h
+++ b/drivers/staging/wlan-ng/p80211netdev.h
@@ -180,11 +180,11 @@ struct wlandevice {
int (*close)(struct wlandevice *wlandev);
void (*reset)(struct wlandevice *wlandev);
int (*txframe)(struct wlandevice *wlandev, struct sk_buff *skb,
-   union p80211_hdr *p80211_hdr,
-   struct p80211_metawep *p80211_wep);
+  union p80211_hdr *p80211_hdr,
+  struct p80211_metawep *p80211_wep);
int (*mlmerequest)(struct wlandevice *wlandev, struct p80211msg *msg);
int (*set_multicast_list)(struct wlandevice *wlandev,
-  struct net_device *dev);
+ struct net_device *dev);
void (*tx_timeout)(struct wlandevice *wlandev);
 
/* 802.11 State */
-- 
2.11.0

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


Re: [PATCH] staging: mt7621-gpio: avoid use of globals and use a drvdata allocated structure

2018-05-16 Thread Sergio Paracuellos
On Wed, May 16, 2018 at 09:59:09AM +1000, NeilBrown wrote:
> On Tue, May 15 2018, Sergio Paracuellos wrote:
> 
> > Gpio driver have a some globals which can be avoided just
> > using platform_data in a proper form. This commit adds a new
> > struct mtk_data which includes all of those globals setting them
> > using platform_set_drvdata and devm_gpiochip_add_data functions.
> > With this properly set we are able to retrieve driver data along
> > the code using kernel api's so globals are not needed anymore.
> >
> > Signed-off-by: Sergio Paracuellos 
> > ---
> >
> > I have not tested this because I don't hardware to do it but I
> > have compile it just to be sure it compiles. This patch needs 
> 
> I've tested it.  Doesn't work :-(  Close though.
> mtk_gpio_w32() needs the gpio_data, so it cannot be called before
> devm_gpiochip_add_data() is called.
> This:
> 
> diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
> b/drivers/staging/mt7621-gpio/gpio-mt7621.c
> index be27cbdcbfa8..48141d979059 100644
> --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
> +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
> @@ -185,9 +185,6 @@ mediatek_gpio_bank_probe(struct platform_device *pdev, 
> struct device_node *bank)
>   rg->chip.to_irq = mediatek_gpio_to_irq;
>   rg->bank = be32_to_cpu(*id);
>  
> - /* set polarity to low for all gpios */
> - mtk_gpio_w32(rg, GPIO_REG_POL, 0);
> -
>   ret = devm_gpiochip_add_data(>dev, >chip, gpio_data);
>   if (ret < 0) {
>   dev_err(>dev, "Could not register gpio %d, ret=%d\n",
> @@ -195,6 +192,9 @@ mediatek_gpio_bank_probe(struct platform_device *pdev, 
> struct device_node *bank)
>   return ret;
>   }
>  
> + /* set polarity to low for all gpios */
> + mtk_gpio_w32(rg, GPIO_REG_POL, 0);
> +
>   dev_info(>dev, "registering %d gpios\n", rg->chip.ngpio);
>  
>   return gpiochip_add(>chip);
> 
> 
> makes it work.  It probably won't work once I try interrupts as
> mediatek_gpio_to_irq() also needs gpio_data, and that is currently
> called early.
> 
> Also:
> 
> >  
> >  static inline u32
> >  mtk_gpio_r32(struct mtk_gc *rg, u8 reg)
> >  {
> > +   struct mtk_data *gpio_data = gpiochip_get_data(>chip);
> > u32 offset = (reg * 0x10) + (rg->bank * 0x4);
> >  
> > -   return ioread32(mediatek_gpio_membase + offset);
> > +   return ioread32(gpio_data->gpio_membase + offset);
> >  }
> >  
> 
> This hunk doesn't apply.
> The existing code is:
> 
> static inline u32
> mtk_gpio_r32(struct mtk_gc *rg, u8 reg)
> {
>return ioread32(mediatek_gpio_membase + (reg * 0x10) + (rg->bank * 
> 0x4));
> }
> 
> Thanks!
> 
> NeilBrown

I have just sent v2 with things you pointed out here probably fixed and other 
remaining
cleanups pointed in this thread.

Hope this helps,

Best regards,
Sergio Paracuellos


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