Re: [greybus-dev] [PATCH 47/61] staging: greybus: simplify getting .drvdata

2018-04-19 Thread Viresh Kumar
On 19-04-18, 16:06, Wolfram Sang wrote:
> We should get drvdata from struct device directly. Going via
> platform_device is an unneeded step back and forth.
> 
> Signed-off-by: Wolfram Sang 
> ---
> 
> Build tested only. buildbot is happy. Please apply individually.
> 
>  drivers/staging/greybus/arche-platform.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

Acked-by: Viresh Kumar 

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


[Patch v2] Storvsc: Select channel based on available percentage of ring buffer to write

2018-04-19 Thread Long Li
From: Long Li 

This is a best effort for estimating on how busy the ring buffer is for
that channel, based on available buffer to write in percentage. It is still
possible that at the time of actual ring buffer write, the space may not be
available due to other processes may be writing at the time.

Selecting a channel based on how full it is can reduce the possibility that
a ring buffer write will fail, and avoid the situation a channel is over
busy.

Now it's possible that storvsc can use a smaller ring buffer size
(e.g. 40k bytes) to take advantage of cache locality.

Changes.
v2: Pre-allocate struct cpumask on the heap.
Struct cpumask is a big structure (1k bytes) when CONFIG_NR_CPUS=8192 (default
value when CONFIG_MAXSMP=y). Don't use kernel stack for it by pre-allocating
them using kmalloc when channels are first initialized.

Signed-off-by: Long Li 
---
 drivers/scsi/storvsc_drv.c | 90 --
 1 file changed, 72 insertions(+), 18 deletions(-)

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index a2ec0bc9e9fa..2a9fff94dd1a 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -395,6 +395,12 @@ MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer 
size (bytes)");
 
 module_param(storvsc_vcpus_per_sub_channel, int, S_IRUGO);
 MODULE_PARM_DESC(storvsc_vcpus_per_sub_channel, "Ratio of VCPUs to 
subchannels");
+
+static int ring_avail_percent_lowater = 10;
+module_param(ring_avail_percent_lowater, int, S_IRUGO);
+MODULE_PARM_DESC(ring_avail_percent_lowater,
+   "Select a channel if available ring size > this in percent");
+
 /*
  * Timeout in seconds for all devices managed by this driver.
  */
@@ -468,6 +474,13 @@ struct storvsc_device {
 * Mask of CPUs bound to subchannels.
 */
struct cpumask alloced_cpus;
+   /*
+* Pre-allocated struct cpumask for each hardware queue.
+* struct cpumask is used by selecting out-going channels. It is a
+* big structure, default to 1024k bytes when CONFIG_MAXSMP=y.
+* Pre-allocate it to avoid allocation on the kernel stack.
+*/
+   struct cpumask *cpumask_chns;
/* Used for vsc/vsp channel reset process */
struct storvsc_cmd_request init_request;
struct storvsc_cmd_request reset_request;
@@ -872,6 +885,13 @@ static int storvsc_channel_init(struct hv_device *device, 
bool is_fc)
if (stor_device->stor_chns == NULL)
return -ENOMEM;
 
+   stor_device->cpumask_chns = kcalloc(num_possible_cpus(),
+   sizeof(struct cpumask), GFP_KERNEL);
+   if (stor_device->cpumask_chns == NULL) {
+   kfree(stor_device->stor_chns);
+   return -ENOMEM;
+   }
+
stor_device->stor_chns[device->channel->target_cpu] = device->channel;
cpumask_set_cpu(device->channel->target_cpu,
_device->alloced_cpus);
@@ -1232,6 +1252,7 @@ static int storvsc_dev_remove(struct hv_device *device)
vmbus_close(device->channel);
 
kfree(stor_device->stor_chns);
+   kfree(stor_device->cpumask_chns);
kfree(stor_device);
return 0;
 }
@@ -1241,7 +1262,7 @@ static struct vmbus_channel *get_og_chn(struct 
storvsc_device *stor_device,
 {
u16 slot = 0;
u16 hash_qnum;
-   struct cpumask alloced_mask;
+   struct cpumask *alloced_mask = _device->cpumask_chns[q_num];
int num_channels, tgt_cpu;
 
if (stor_device->num_sc == 0)
@@ -1257,10 +1278,10 @@ static struct vmbus_channel *get_og_chn(struct 
storvsc_device *stor_device,
 * III. Mapping is persistent.
 */
 
-   cpumask_and(_mask, _device->alloced_cpus,
+   cpumask_and(alloced_mask, _device->alloced_cpus,
cpumask_of_node(cpu_to_node(q_num)));
 
-   num_channels = cpumask_weight(_mask);
+   num_channels = cpumask_weight(alloced_mask);
if (num_channels == 0)
return stor_device->device->channel;
 
@@ -1268,7 +1289,7 @@ static struct vmbus_channel *get_og_chn(struct 
storvsc_device *stor_device,
while (hash_qnum >= num_channels)
hash_qnum -= num_channels;
 
-   for_each_cpu(tgt_cpu, _mask) {
+   for_each_cpu(tgt_cpu, alloced_mask) {
if (slot == hash_qnum)
break;
slot++;
@@ -1285,9 +1306,9 @@ static int storvsc_do_io(struct hv_device *device,
 {
struct storvsc_device *stor_device;
struct vstor_packet *vstor_packet;
-   struct vmbus_channel *outgoing_channel;
+   struct vmbus_channel *outgoing_channel, *channel;
int ret = 0;
-   struct cpumask alloced_mask;
+   struct cpumask *alloced_mask;
int tgt_cpu;
 
vstor_packet = >vstor_packet;
@@ -1301,22 +1322,53 @@ static int storvsc_do_io(struct hv_device *device,
/*
 * Select an an 

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

2018-04-19 Thread Eric Biggers
On Tue, Apr 03, 2018 at 08:02:02PM -0700, syzbot wrote:
> Hello,
> 
> syzbot hit the following crash on upstream commit
> f2d285669aae656dfeafa0bf25e86bbbc5d22329 (Tue Apr 3 17:45:39 2018 +)
> Merge tag 'pm-4.17-rc1' of
> git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
> syzbot dashboard link:
> https://syzkaller.appspot.com/bug?extid=0cf1f1aa154f56ff2e8d
> 
> So far this crash happened 4 times on upstream.
> C reproducer: https://syzkaller.appspot.com/x/repro.c?id=4827186146050048
> syzkaller reproducer:
> https://syzkaller.appspot.com/x/repro.syz?id=6025869373997056
> Raw console output:
> https://syzkaller.appspot.com/x/log.txt?id=4772918563176448
> Kernel config: https://syzkaller.appspot.com/x/.config?id=686016073509112605
> compiler: gcc (GCC) 7.1.1 20170620
> 
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+0cf1f1aa154f56ff2...@syzkaller.appspotmail.com
> It will help syzbot understand when the bug is fixed. See footer for
> details.
> If you forward the report, please keep this part and the footer.
> 
> binder: 4616:4618 transaction failed 29189/-3, size 0-0 line 2963
> binder: release 4616:4618 transaction 114 in, still active
> binder: send failed reply for transaction 114 to 4616:4618
> binder: 4620:4621 ioctl 400448c8 2200 returned -22
> ==
> BUG: KASAN: use-after-free in __list_del_entry_valid+0x144/0x150
> lib/list_debug.c:54
> Read of size 8 at addr 8801d39a4210 by task kworker/1:2/1891
> 
> CPU: 1 PID: 1891 Comm: kworker/1:2 Not tainted 4.16.0+ #378
> binder: release 4620:4621 transaction 118 out, still active
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
> Google 01/01/2011
> Workqueue: events binder_deferred_func
> Call Trace:
>  __dump_stack lib/dump_stack.c:17 [inline]
>  dump_stack+0x1a7/0x27d lib/dump_stack.c:53
> binder: release 4620:4621 transaction 117 in, still active
>  print_address_description+0x73/0x250 mm/kasan/report.c:256
> binder: undelivered TRANSACTION_COMPLETE
>  kasan_report_error mm/kasan/report.c:354 [inline]
>  kasan_report+0x23c/0x360 mm/kasan/report.c:412
>  __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
> binder: BINDER_SET_CONTEXT_MGR already set
>  __list_del_entry_valid+0x144/0x150 lib/list_debug.c:54
> binder: 4620:4622 ioctl 40046207 0 returned -16
>  __list_del_entry include/linux/list.h:117 [inline]
>  list_del_init include/linux/list.h:159 [inline]
>  binder_dequeue_work_head_ilocked drivers/android/binder.c:893 [inline]
>  binder_dequeue_work_head drivers/android/binder.c:913 [inline]
>  binder_release_work+0x163/0x4b0 drivers/android/binder.c:4191
> binder: 4620:4621 ioctl c0306201 20004000 returned -14
> binder: 4620:4621 ioctl 400448c8 2200 returned -22
>  binder_thread_release+0x4e1/0x730 drivers/android/binder.c:4396
> binder_alloc: binder_alloc_mmap_handler: 4620 2000c000-2000e000 already
> mapped failed -16
>  binder_deferred_release drivers/android/binder.c:4939 [inline]
>  binder_deferred_func+0x4f4/0x1350 drivers/android/binder.c:5022
> binder_alloc: 4620: binder_alloc_buf, no vma
> binder: 4620:4623 transaction failed 29189/-3, size 0-0 line 2963
>  process_one_work+0xc97/0x1c40 kernel/workqueue.c:2113
> binder_alloc: 4620: binder_alloc_buf, no vma
> binder: 4620:4621 transaction failed 29189/-3, size 0-0 line 2963
> binder: release 4620:4622 transaction 118 in, still active
> binder: release 4620:4622 transaction 117 out, still active
>  worker_thread+0x1c3/0x1380 kernel/workqueue.c:2247
> binder: send failed reply for transaction 118, target dead
> binder: send failed reply for transaction 117, target dead
> binder: BINDER_SET_CONTEXT_MGR already set
> binder: 4624:4625 ioctl 40046207 0 returned -16
>  kthread+0x33c/0x400 kernel/kthread.c:238
> binder: 4624:4625 ioctl 400448c8 2200 returned -22
>  ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:411
> 
> binder_alloc: 4620: binder_alloc_buf, no vma
> Allocated by task 4618:
>  save_stack+0x43/0xd0 mm/kasan/kasan.c:447
>  set_track mm/kasan/kasan.c:459 [inline]
>  kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:552
> binder: 4624:4626 transaction failed 29189/-3, size 0-0 line 2963
>  kmem_cache_alloc_trace+0x136/0x740 mm/slab.c:3608
>  kmalloc include/linux/slab.h:512 [inline]
>  kzalloc include/linux/slab.h:701 [inline]
>  binder_transaction+0x13d2/0x8200 drivers/android/binder.c:2900
>  binder_thread_write+0xcf1/0x38b0 drivers/android/binder.c:3513
>  binder_ioctl_write_read.isra.39+0x261/0xcb0 drivers/android/binder.c:4451
>  binder_ioctl+0xb72/0x1417 drivers/android/binder.c:4591
> binder: undelivered TRANSACTION_ERROR: 29189
>  vfs_ioctl fs/ioctl.c:46 [inline]
>  do_vfs_ioctl+0x1b1/0x1520 fs/ioctl.c:686
>  ksys_ioctl+0x94/0xb0 fs/ioctl.c:701
>  SYSC_ioctl fs/ioctl.c:708 [inline]
>  SyS_ioctl+0x24/0x30 fs/ioctl.c:706
>  do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
>  

Re: simplify procfs code for seq_file instances

2018-04-19 Thread Alexey Dobriyan
> git://git.infradead.org/users/hch/misc.git proc_create


I want to ask if it is time to start using poorman function overloading
with _b_c_e(). There are millions of allocation functions for example,
all slightly difference, and people will add more. Seeing /proc interfaces
doubled like this is painful.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 03/39] proc: introduce proc_create_seq_private

2018-04-19 Thread Alexey Dobriyan
On Thu, Apr 19, 2018 at 02:41:04PM +0200, Christoph Hellwig wrote:
> Variant of proc_create_data that directly take a struct seq_operations

> --- a/fs/proc/internal.h
> +++ b/fs/proc/internal.h
> @@ -45,6 +45,7 @@ struct proc_dir_entry {
>   const struct inode_operations *proc_iops;
>   const struct file_operations *proc_fops;
>   const struct seq_operations *seq_ops;
> + size_t state_size;

"unsigned int" please.

Where have you seen 4GB priv states?
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 14/39] proc: introduce proc_create_net_single

2018-04-19 Thread Alexey Dobriyan
On Thu, Apr 19, 2018 at 02:41:15PM +0200, Christoph Hellwig wrote:
> Variant of proc_create_data that directly take a seq_file show

> +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_data(name, mode, parent, _net_single_fops, data);
> + if (p)
> + p->single_show = show;
> + return p;
> +}

Ditto, should be oopsable.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 02/39] proc: introduce proc_create_seq{,_data}

2018-04-19 Thread Alexey Dobriyan
On Thu, Apr 19, 2018 at 02:41:03PM +0200, Christoph Hellwig wrote:
> Variants of proc_create{,_data} that directly take a struct seq_operations
> argument and drastically reduces the boilerplate code in the callers.

> +static int proc_seq_open(struct inode *inode, struct file *file)
> +{
> + struct proc_dir_entry *de = PDE(inode);
> +
> + return seq_open(file, de->seq_ops);
> +}
> +
> +static const struct file_operations proc_seq_fops = {
> + .open   = proc_seq_open,
> + .read   = seq_read,
> + .llseek = seq_lseek,
> + .release= seq_release,
> +};
> +
> +struct proc_dir_entry *proc_create_seq_data(const char *name, umode_t mode,
> + struct proc_dir_entry *parent, const struct seq_operations *ops,
> + void *data)
> +{
> + struct proc_dir_entry *p;
> +
> + p = proc_create_data(name, mode, parent, _seq_fops, data);
> + if (p)
> + p->seq_ops = ops;
> + return p;
> +}

Should be oopsable.
Once proc_create_data() returns, entry is live, ->open can be called.

> --- a/fs/proc/internal.h
> +++ b/fs/proc/internal.h
> @@ -44,6 +44,7 @@ struct proc_dir_entry {
>   struct completion *pde_unload_completion;
>   const struct inode_operations *proc_iops;
>   const struct file_operations *proc_fops;
> + const struct seq_operations *seq_ops;
>   void *data;
>   unsigned int low_ino;
>   nlink_t nlink;

"struct proc_dir_entry is 192/128 bytes now.
If someone knows how to pad array to certain size without union
please tell.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3 15/20] net: Remove depends on HAS_DMA in case of platform dependency

2018-04-19 Thread Kalle Valo
(adding linux-wireless)

Geert Uytterhoeven  writes:

> Remove dependencies on HAS_DMA where a Kconfig symbol depends on another
> symbol that implies HAS_DMA, and, optionally, on "|| COMPILE_TEST".
> In most cases this other symbol is an architecture or platform specific
> symbol, or PCI.
>
> Generic symbols and drivers without platform dependencies keep their
> dependencies on HAS_DMA, to prevent compiling subsystems or drivers that
> cannot work anyway.
>
> This simplifies the dependencies, and allows to improve compile-testing.
>
> Signed-off-by: Geert Uytterhoeven 
> Reviewed-by: Mark Brown 
> Acked-by: Robin Murphy 
> ---
> v3:
>   - Rebase to v4.17-rc1,
>   - Drop obsolete note about FSL_FMAN,
>
> v2:
>   - Add Reviewed-by, Acked-by,
>   - Drop RFC state,
>   - Split per subsystem.
> ---
>  drivers/net/ethernet/amd/Kconfig| 2 +-
>  drivers/net/ethernet/apm/xgene-v2/Kconfig   | 1 -
>  drivers/net/ethernet/apm/xgene/Kconfig  | 1 -
>  drivers/net/ethernet/arc/Kconfig| 6 --
>  drivers/net/ethernet/broadcom/Kconfig   | 2 --
>  drivers/net/ethernet/calxeda/Kconfig| 2 +-
>  drivers/net/ethernet/hisilicon/Kconfig  | 2 +-
>  drivers/net/ethernet/marvell/Kconfig| 8 +++-
>  drivers/net/ethernet/mellanox/mlxsw/Kconfig | 2 +-
>  drivers/net/ethernet/renesas/Kconfig| 2 --
>  drivers/net/wireless/broadcom/brcm80211/Kconfig | 1 -
>  drivers/net/wireless/quantenna/qtnfmac/Kconfig  | 2 +-
>  12 files changed, 12 insertions(+), 19 deletions(-)

For wireless:

Acked-by: Kalle Valo 

Leaving the hunks for linux-wireless list to see:

> diff --git a/drivers/net/wireless/broadcom/brcm80211/Kconfig 
> b/drivers/net/wireless/broadcom/brcm80211/Kconfig
> index 9d99eb42d9176f0f..6acba67bca07abd7 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/Kconfig
> +++ b/drivers/net/wireless/broadcom/brcm80211/Kconfig
> @@ -60,7 +60,6 @@ config BRCMFMAC_PCIE
>   bool "PCIE bus interface support for FullMAC driver"
>   depends on BRCMFMAC
>   depends on PCI
> - depends on HAS_DMA
>   select BRCMFMAC_PROTO_MSGBUF
>   select FW_LOADER
>   ---help---
> diff --git a/drivers/net/wireless/quantenna/qtnfmac/Kconfig 
> b/drivers/net/wireless/quantenna/qtnfmac/Kconfig
> index 025fa6018550895a..8d1492a90bd135c0 100644
> --- a/drivers/net/wireless/quantenna/qtnfmac/Kconfig
> +++ b/drivers/net/wireless/quantenna/qtnfmac/Kconfig
> @@ -7,7 +7,7 @@ config QTNFMAC
>  config QTNFMAC_PEARL_PCIE
>   tristate "Quantenna QSR10g PCIe support"
>   default n
> - depends on HAS_DMA && PCI && CFG80211
> + depends on PCI && CFG80211
>   select QTNFMAC
>   select FW_LOADER
>   select CRC32

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


Re: [PATCH 16/39] ipmi: simplify procfs code

2018-04-19 Thread Corey Minyard

On 04/19/2018 07:41 AM, Christoph Hellwig wrote:

Use remove_proc_subtree to remove the whole subtree on cleanup instead
of a hand rolled list of proc entries, unwind the registration loop into
individual calls.  Switch to use proc_create_single to further simplify
the code.


I'm yanking all the proc code out of the IPMI driver in 3.18.  So this 
is probably

not necessary.

Thanks,

-corey


Signed-off-by: Christoph Hellwig 
---
  drivers/char/ipmi/ipmi_msghandler.c | 150 +---
  drivers/char/ipmi/ipmi_si_intf.c|  47 +
  drivers/char/ipmi/ipmi_ssif.c   |  34 +--
  include/linux/ipmi_smi.h|   8 +-
  4 files changed, 33 insertions(+), 206 deletions(-)

diff --git a/drivers/char/ipmi/ipmi_msghandler.c 
b/drivers/char/ipmi/ipmi_msghandler.c
index 361148938801..c18db313e4c4 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -247,13 +247,6 @@ struct ipmi_my_addrinfo {
unsigned char lun;
  };
  
-#ifdef CONFIG_IPMI_PROC_INTERFACE

-struct ipmi_proc_entry {
-   char   *name;
-   struct ipmi_proc_entry *next;
-};
-#endif
-
  /*
   * Note that the product id, manufacturer id, guid, and device id are
   * immutable in this structure, so dyn_mutex is not required for
@@ -430,10 +423,6 @@ struct ipmi_smi {
void *send_info;
  
  #ifdef CONFIG_IPMI_PROC_INTERFACE

-   /* A list of proc entries for this interface. */
-   struct mutex   proc_entry_lock;
-   struct ipmi_proc_entry *proc_entries;
-
struct proc_dir_entry *proc_dir;
char  proc_dir_name[10];
  #endif
@@ -2358,18 +2347,6 @@ static int smi_ipmb_proc_show(struct seq_file *m, void 
*v)
return 0;
  }
  
-static int smi_ipmb_proc_open(struct inode *inode, struct file *file)

-{
-   return single_open(file, smi_ipmb_proc_show, PDE_DATA(inode));
-}
-
-static const struct file_operations smi_ipmb_proc_ops = {
-   .open   = smi_ipmb_proc_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
-
  static int smi_version_proc_show(struct seq_file *m, void *v)
  {
ipmi_smi_t intf = m->private;
@@ -2387,18 +2364,6 @@ static int smi_version_proc_show(struct seq_file *m, 
void *v)
return 0;
  }
  
-static int smi_version_proc_open(struct inode *inode, struct file *file)

-{
-   return single_open(file, smi_version_proc_show, PDE_DATA(inode));
-}
-
-static const struct file_operations smi_version_proc_ops = {
-   .open   = smi_version_proc_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
-
  static int smi_stats_proc_show(struct seq_file *m, void *v)
  {
ipmi_smi_t intf = m->private;
@@ -2462,95 +2427,45 @@ static int smi_stats_proc_show(struct seq_file *m, void 
*v)
return 0;
  }
  
-static int smi_stats_proc_open(struct inode *inode, struct file *file)

-{
-   return single_open(file, smi_stats_proc_show, PDE_DATA(inode));
-}
-
-static const struct file_operations smi_stats_proc_ops = {
-   .open   = smi_stats_proc_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
-
  int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name,
-   const struct file_operations *proc_ops,
-   void *data)
+   int (*show)(struct seq_file *, void *), void *data)
  {
-   intrv = 0;
-   struct proc_dir_entry  *file;
-   struct ipmi_proc_entry *entry;
-
-   /* Create a list element. */
-   entry = kmalloc(sizeof(*entry), GFP_KERNEL);
-   if (!entry)
+   if (!proc_create_single_data(name, 0, smi->proc_dir, show, data))
return -ENOMEM;
-   entry->name = kstrdup(name, GFP_KERNEL);
-   if (!entry->name) {
-   kfree(entry);
-   return -ENOMEM;
-   }
-
-   file = proc_create_data(name, 0, smi->proc_dir, proc_ops, data);
-   if (!file) {
-   kfree(entry->name);
-   kfree(entry);
-   rv = -ENOMEM;
-   } else {
-   mutex_lock(>proc_entry_lock);
-   /* Stick it on the list. */
-   entry->next = smi->proc_entries;
-   smi->proc_entries = entry;
-   mutex_unlock(>proc_entry_lock);
-   }
-
-   return rv;
+   return 0;
  }
  EXPORT_SYMBOL(ipmi_smi_add_proc_entry);
  
  static int add_proc_entries(ipmi_smi_t smi, int num)

  {
-   int rv = 0;
-
sprintf(smi->proc_dir_name, "%d", num);
smi->proc_dir = proc_mkdir(smi->proc_dir_name, proc_ipmi_root);
if (!smi->proc_dir)
-   rv = -ENOMEM;
-
-   if (rv == 0)
-   rv = ipmi_smi_add_proc_entry(smi, "stats",
-

RE: [PATCH v4 02/13] dt-bindings: usb: add documentation for typec port controller(TCPCI)

2018-04-19 Thread Jun Li
> -Original Message-
> From: Rob Herring [mailto:r...@kernel.org]
> Sent: 2018年4月16日 22:28
> To: Jun Li 
> Cc: gre...@linuxfoundation.org; heikki.kroge...@linux.intel.com;
> li...@roeck-us.net; a.ha...@samsung.com; shufan_...@richtek.com; Peter
> Chen ; devicet...@vger.kernel.org;
> linux-...@vger.kernel.org; dl-linux-imx ;
> de...@driverdev.osuosl.org
> Subject: Re: [PATCH v4 02/13] dt-bindings: usb: add documentation for typec
> port controller(TCPCI)
> 
> On Mon, Apr 16, 2018 at 6:54 AM, Jun Li  wrote:
> > Hi
> >> -Original Message-
> >> From: Rob Herring [mailto:r...@kernel.org]
> >> Sent: 2018年4月10日 4:04
> >> To: Jun Li 
> >> Cc: gre...@linuxfoundation.org; heikki.kroge...@linux.intel.com;
> >> li...@roeck-us.net; a.ha...@samsung.com; shufan_...@richtek.com;
> >> Peter Chen ; devicet...@vger.kernel.org;
> >> linux-...@vger.kernel.org; dl-linux-imx ;
> >> de...@driverdev.osuosl.org
> >> Subject: Re: [PATCH v4 02/13] dt-bindings: usb: add documentation for
> >> typec port controller(TCPCI)
> >>
> >> On Thu, Mar 29, 2018 at 12:06:07AM +0800, Li Jun wrote:
> 
> [...]
> 
> >> > +ptn5110@50 {
> >> > +   compatible = "usb-tcpci,ptn5110";
> >> > +   reg = <0x50>;
> >> > +   interrupt-parent = <>;
> >> > +   interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
> >> > +
> >> > +   usb_con: connector {
> >>
> >> How is the OF graph done in this case? You need some link to the USB
> controller.
> >
> > The platform(i.MX8MQ EVK) for this is still on the way of start
> > upstream, I was Planning to add this part with enabling USB3 function,
> > as of how this will be done, I only have usb3 ss data(no display port or
> Sideband), is something like below OK?
> >
> > typec: ptn5110@50 {
> > compatible = "nxp,ptn5110";
> > ...
> >
> > usb_con: connector {
> > compatible = "usb-c-connector";
> > label = "USB-C";
> > ...
> >
> > ports {
> > #address-cells = <1>;
> > #size-cells = <0>;
> >
> > port@1 {
> > reg = <1>;
> > usb_con_ss: endpoint {
> > remote-endpoint = <_phy_ss>;
> > };
> > };
> > };
> > };
> > };
> >
> > _phy0 {
> > status = "okay";
> >
> > port {
> > usb3_phy_ss: endpoint {
> 
> Normally, the graph connection would be to the USB controller, not the phy as
> the phy is just referred to with a "phys" property.

Understood, I will put this into a USB controller node. Thanks.

Jun
> 
> > remote-endpoint = <_con_ss>;
> > };
> > };
> > }
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 07/15] media: staging/imx: add 10 bit bayer support

2018-04-19 Thread Rui Miguel Silva

Hi Philip,
Thanks for the review.

On Thu 19 Apr 2018 at 13:38, Philipp Zabel wrote:

On Thu, 2018-04-19 at 11:18 +0100, Rui Miguel Silva wrote:
Some sensors can only output 10 bit bayer formats, like the 
OV2680. Add support

for that in imx-media.

Signed-off-by: Rui Miguel Silva 
---
 drivers/staging/media/imx/imx-media-utils.c | 24 
 +

 1 file changed, 24 insertions(+)

diff --git a/drivers/staging/media/imx/imx-media-utils.c 
b/drivers/staging/media/imx/imx-media-utils.c

index fab98fc0d6a0..99527daba29a 100644
--- a/drivers/staging/media/imx/imx-media-utils.c
+++ b/drivers/staging/media/imx/imx-media-utils.c
@@ -118,6 +118,30 @@ static const struct imx_media_pixfmt 
rgb_formats[] = {

.cs = IPUV3_COLORSPACE_RGB,
.bpp= 8,
.bayer  = true,
+   }, {
+   .fourcc = V4L2_PIX_FMT_SBGGR10,
+   .codes  = {MEDIA_BUS_FMT_SBGGR10_1X10},
+   .cs = IPUV3_COLORSPACE_RGB,
+   .bpp= 16,
+   .bayer  = true,
+   }, {
+   .fourcc = V4L2_PIX_FMT_SGBRG10,
+   .codes  = {MEDIA_BUS_FMT_SGBRG10_1X10},
+   .cs = IPUV3_COLORSPACE_RGB,
+   .bpp= 16,
+   .bayer  = true,
+   }, {
+   .fourcc = V4L2_PIX_FMT_SGRBG10,
+   .codes  = {MEDIA_BUS_FMT_SGRBG10_1X10},
+   .cs = IPUV3_COLORSPACE_RGB,
+   .bpp= 16,
+   .bayer  = true,
+   }, {
+   .fourcc = V4L2_PIX_FMT_SRGGB10,
+   .codes  = {MEDIA_BUS_FMT_SRGGB10_1X10},
+   .cs = IPUV3_COLORSPACE_RGB,
+   .bpp= 16,
+   .bayer  = true,


This will break 10-bit bayer formats on i.MX6, which currently 
stores
them in memory expanded to 16-bit, as listed in the entries 
below:


Oh, I see... i.MX7 also store it expanded, I will change my code 
to use

the format array as it is for i.MX6.

Thanks,
---
Cheers,
Rui

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


Re: [PATCH 03/39] proc: introduce proc_create_seq_private

2018-04-19 Thread Dan Carpenter
On Thu, Apr 19, 2018 at 02:41:04PM +0200, Christoph Hellwig wrote:
> diff --git a/drivers/s390/cio/blacklist.c b/drivers/s390/cio/blacklist.c
> index 2a3f874a21d5..ad35cddcf6af 100644
> --- a/drivers/s390/cio/blacklist.c
> +++ b/drivers/s390/cio/blacklist.c
> @@ -391,28 +391,15 @@ static const struct seq_operations 
> cio_ignore_proc_seq_ops = {
>   .show  = cio_ignore_proc_seq_show,
>  };
>  
> -static int
> -cio_ignore_proc_open(struct inode *inode, struct file *file)
> -{
> - return seq_open_private(file, _ignore_proc_seq_ops,
> - sizeof(struct ccwdev_iter));
> -}
> -
> -static const struct file_operations cio_ignore_proc_fops = {
> - .open= cio_ignore_proc_open,
> - .read= seq_read,
> - .llseek  = seq_lseek,
> - .release = seq_release_private,
> - .write   = cio_ignore_write,
   
The cio_ignore_write() function isn't used any more so compilers will
complain.

> -};
> -
>  static int
>  cio_ignore_proc_init (void)
>  {
>   struct proc_dir_entry *entry;
>  
> - entry = proc_create("cio_ignore", S_IFREG | S_IRUGO | S_IWUSR, NULL,
> - _ignore_proc_fops);
> + entry = proc_create_seq_private("cio_ignore",
> + S_IFREG | S_IRUGO | S_IWUSR, NULL,
> + _ignore_proc_seq_ops, sizeof(struct ccwdev_iter),
> + NULL);
>   if (!entry)
>   return -ENOENT;
>   return 0;

regards,
dan carpenter

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


[PATCH 48/61] staging: iio: adc: simplify getting .drvdata

2018-04-19 Thread Wolfram Sang
We should get drvdata from struct device directly. Going via
platform_device is an unneeded step back and forth.

Signed-off-by: Wolfram Sang 
---

Build tested only. buildbot is happy. Please apply individually.

 drivers/staging/iio/adc/ad7606_par.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7606_par.c 
b/drivers/staging/iio/adc/ad7606_par.c
index 3eb6f8f312dd..a34c2a1d5373 100644
--- a/drivers/staging/iio/adc/ad7606_par.c
+++ b/drivers/staging/iio/adc/ad7606_par.c
@@ -18,8 +18,7 @@
 static int ad7606_par16_read_block(struct device *dev,
   int count, void *buf)
 {
-   struct platform_device *pdev = to_platform_device(dev);
-   struct iio_dev *indio_dev = platform_get_drvdata(pdev);
+   struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct ad7606_state *st = iio_priv(indio_dev);
 
insw((unsigned long)st->base_address, buf, count);
@@ -34,8 +33,7 @@ static const struct ad7606_bus_ops ad7606_par16_bops = {
 static int ad7606_par8_read_block(struct device *dev,
  int count, void *buf)
 {
-   struct platform_device *pdev = to_platform_device(dev);
-   struct iio_dev *indio_dev = platform_get_drvdata(pdev);
+   struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct ad7606_state *st = iio_priv(indio_dev);
 
insb((unsigned long)st->base_address, buf, count * 2);
-- 
2.11.0

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


[PATCH 47/61] staging: greybus: simplify getting .drvdata

2018-04-19 Thread Wolfram Sang
We should get drvdata from struct device directly. Going via
platform_device is an unneeded step back and forth.

Signed-off-by: Wolfram Sang 
---

Build tested only. buildbot is happy. Please apply individually.

 drivers/staging/greybus/arche-platform.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/greybus/arche-platform.c 
b/drivers/staging/greybus/arche-platform.c
index 83254a72a7bb..8fe8b6e35432 100644
--- a/drivers/staging/greybus/arche-platform.c
+++ b/drivers/staging/greybus/arche-platform.c
@@ -315,8 +315,7 @@ static ssize_t state_store(struct device *dev,
   struct device_attribute *attr,
   const char *buf, size_t count)
 {
-   struct platform_device *pdev = to_platform_device(dev);
-   struct arche_platform_drvdata *arche_pdata = platform_get_drvdata(pdev);
+   struct arche_platform_drvdata *arche_pdata = dev_get_drvdata(dev);
int ret = 0;
 
mutex_lock(_pdata->platform_state_mutex);
-- 
2.11.0

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


[PATCH 00/61] tree-wide: simplify getting .drvdata

2018-04-19 Thread Wolfram Sang
I got tired of fixing this in Renesas drivers manually, so I took the big
hammer. Remove this cumbersome code pattern which got copy-pasted too much
already:

-   struct platform_device *pdev = to_platform_device(dev);
-   struct ep93xx_keypad *keypad = platform_get_drvdata(pdev);
+   struct ep93xx_keypad *keypad = dev_get_drvdata(dev);

I send this out as one patch per directory per subsystem. I think they should
be applied individually. If you prefer a broken out series per subsystem, I can
provide this as well. Just mail me.

A branch (tested by buildbot; only with all commits squashed into one commit
before) can be found here:

git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git 
coccinelle/get_drvdata

Open for other comments, suggestions, too, of course.

Here is the cocci-script I created (after  iterations by manually checking
samples):

@@
struct device* d;
identifier pdev;
expression *ptr;
@@
(
-   struct platform_device *pdev = to_platform_device(d);
|
-   struct platform_device *pdev;
...
-   pdev = to_platform_device(d);
)
<... when != pdev
-   >dev
+   d
...>

ptr =
-   platform_get_drvdata(pdev)
+   dev_get_drvdata(d)

<... when != pdev
-   >dev
+   d
...>

Kind regards,

   Wolfram


Wolfram Sang (61):
  ARM: plat-samsung: simplify getting .drvdata
  ata: simplify getting .drvdata
  auxdisplay: simplify getting .drvdata
  bus: simplify getting .drvdata
  clk: samsung: simplify getting .drvdata
  crypto: simplify getting .drvdata
  dma: simplify getting .drvdata
  dmaengine: dw: simplify getting .drvdata
  dmaengine: qcom: simplify getting .drvdata
  gpio: simplify getting .drvdata
  gpu: drm: msm: simplify getting .drvdata
  gpu: drm: msm: adreno: simplify getting .drvdata
  gpu: drm: msm: disp: mdp5: simplify getting .drvdata
  gpu: drm: msm: dsi: simplify getting .drvdata
  gpu: drm: omapdrm: displays: simplify getting .drvdata
  gpu: drm: vc4: simplify getting .drvdata
  hid: simplify getting .drvdata
  iio: common: cros_ec_sensors: simplify getting .drvdata
  iio: common: hid-sensors: simplify getting .drvdata
  input: keyboard: simplify getting .drvdata
  input: misc: simplify getting .drvdata
  input: mouse: simplify getting .drvdata
  input: touchscreen: simplify getting .drvdata
  iommu: simplify getting .drvdata
  media: platform: am437x: simplify getting .drvdata
  media: platform: exynos4-is: simplify getting .drvdata
  media: platform: s5p-mfc: simplify getting .drvdata
  mmc: host: simplify getting .drvdata
  mtd: devices: simplify getting .drvdata
  mtd: nand: onenand: simplify getting .drvdata
  net: dsa: simplify getting .drvdata
  net: ethernet: cadence: simplify getting .drvdata
  net: ethernet: davicom: simplify getting .drvdata
  net: ethernet: smsc: simplify getting .drvdata
  net: ethernet: ti: simplify getting .drvdata
  net: ethernet: wiznet: simplify getting .drvdata
  perf: simplify getting .drvdata
  pinctrl: simplify getting .drvdata
  pinctrl: intel: simplify getting .drvdata
  platform: x86: simplify getting .drvdata
  power: supply: simplify getting .drvdata
  ptp: simplify getting .drvdata
  pwm: simplify getting .drvdata
  rtc: simplify getting .drvdata
  slimbus: simplify getting .drvdata
  spi: simplify getting .drvdata
  staging: greybus: simplify getting .drvdata
  staging: iio: adc: simplify getting .drvdata
  staging: nvec: simplify getting .drvdata
  thermal: simplify getting .drvdata
  thermal: int340x_thermal: simplify getting .drvdata
  thermal: st: simplify getting .drvdata
  tty: serial: simplify getting .drvdata
  uio: simplify getting .drvdata
  usb: mtu3: simplify getting .drvdata
  usb: phy: simplify getting .drvdata
  video: fbdev: simplify getting .drvdata
  video: fbdev: omap2: omapfb: displays: simplify getting .drvdata
  watchdog: simplify getting .drvdata
  net: dsa: simplify getting .drvdata
  ASoC: atmel: simplify getting .drvdata

 arch/arm/plat-samsung/adc.c|  3 +-
 drivers/ata/pata_samsung_cf.c  |  8 ++---
 drivers/auxdisplay/arm-charlcd.c   |  6 ++--
 drivers/bus/brcmstb_gisb.c | 12 +++
 drivers/clk/samsung/clk-s3c2410-dclk.c |  6 ++--
 drivers/crypto/exynos-rng.c|  6 ++--
 drivers/crypto/picoxcell_crypto.c  |  6 ++--
 drivers/dma/at_hdmac.c |  9 ++---
 drivers/dma/at_xdmac.c |  9 ++---
 drivers/dma/dw/platform.c  |  6 ++--
 drivers/dma/fsldma.c   |  6 ++--
 drivers/dma/idma64.c   |  6 ++--
 drivers/dma/qcom/hidma.c   |  3 +-
 drivers/dma/qcom/hidma_mgmt_sys.c  |  6 ++--
 drivers/dma/ste_dma40.c| 12 +++
 drivers/dma/txx9dmac.c |  8 ++---
 

[PATCH 49/61] staging: nvec: simplify getting .drvdata

2018-04-19 Thread Wolfram Sang
We should get drvdata from struct device directly. Going via
platform_device is an unneeded step back and forth.

Signed-off-by: Wolfram Sang 
---

Build tested only. buildbot is happy. Please apply individually.

 drivers/staging/nvec/nvec.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
index 52054a528723..2a5e0dcf4162 100644
--- a/drivers/staging/nvec/nvec.c
+++ b/drivers/staging/nvec/nvec.c
@@ -925,8 +925,7 @@ static int tegra_nvec_remove(struct platform_device *pdev)
 static int nvec_suspend(struct device *dev)
 {
int err;
-   struct platform_device *pdev = to_platform_device(dev);
-   struct nvec_chip *nvec = platform_get_drvdata(pdev);
+   struct nvec_chip *nvec = dev_get_drvdata(dev);
struct nvec_msg *msg;
char ap_suspend[] = { NVEC_SLEEP, AP_SUSPEND };
 
@@ -946,8 +945,7 @@ static int nvec_suspend(struct device *dev)
 
 static int nvec_resume(struct device *dev)
 {
-   struct platform_device *pdev = to_platform_device(dev);
-   struct nvec_chip *nvec = platform_get_drvdata(pdev);
+   struct nvec_chip *nvec = dev_get_drvdata(dev);
 
dev_dbg(nvec->dev, "resuming\n");
tegra_init_i2c_slave(nvec);
-- 
2.11.0

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


Re: [cfs_trace_lock_tcd] BUG: KASAN: null-ptr-deref in cfs_trace_lock_tcd+0x25/0xeb

2018-04-19 Thread Andrey Ryabinin


On 04/19/2018 04:35 PM, Andrey Ryabinin wrote:
> 
> 
> On 04/18/2018 09:37 PM, Linus Torvalds wrote:
>> Ugh, that lustre code is disgusting.
>>
>> I thought we were getting rid of it.
>>
>> Anyway, I started looking at why the stack trace is such an incredible
>> mess, with lots of stale entries.
>>
>> The reason (well, _one_ reason) seems to be "ksocknal_startup". It has
>> a 500-byte stack frame for some incomprehensible reason. I assume due
>> to excessive inlining, because the function itself doesn't seem to be
>> that bad.
>>
>> Similarly, LNetNIInit has a 300-byte stack frame. So it gets pretty deep.
>>
>> I'm getting the feeling that KASAN is making things worse because
>> probably it's disabling all the sane stack frame stuff (ie no merging
>> of stack slot entries, perhaps?).
>>
> 
> AFAIR no merging of stack slots policy enabled only if 
> -fsanitize-address-use-after-scope 
> is on (which is CONFIG_KASAN_EXTRA). This feature does cause sometimes 
> significant stack bloat,
> but hasn't been proven to be very useful, so I wouldn't mind disabling it 
> completely.
> 
> So far I know only about a single BUG - 
> https://lkml.kernel.org/r/<151238865557.4852.10258661301122491...@mail.alporthouse.com>
> it has found.

Actually, there is one more - 
https://syzkaller.appspot.com/bug?id=6a929b72a32ca0b1a6985126fa1bc77c03c12304
so two bugs.

> There are also a lot of other 

I didn't finish this sentence:

There are also a lot of other reports about use-after-scope, but seem all of 
them are false positives
caused by STRUCTLEAK plugin.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 05/15] media: staging/imx7: add MIPI CSI-2 receiver subdev for i.MX7

2018-04-19 Thread Rui Miguel Silva

Hi Dan,
On Thu 19 Apr 2018 at 12:45, Dan Carpenter wrote:

+static int mipi_csis_clk_get(struct csi_state *state)
+{
+   struct device *dev = >pdev->dev;
+   int ret = true;


Better to leave ret unitialized.


ack.




+
+   state->mipi_clk = devm_clk_get(dev, "mipi");
+   if (IS_ERR(state->mipi_clk)) {
+   dev_err(dev, "Could not get mipi csi clock\n");
+   return -ENODEV;
+   }
+
+   state->phy_clk = devm_clk_get(dev, "phy");
+   if (IS_ERR(state->phy_clk)) {
+   dev_err(dev, "Could not get mipi phy clock\n");
+   return -ENODEV;
+   }
+
+   /* Set clock rate */
+   if (state->clk_frequency)
+		ret = clk_set_rate(state->mipi_clk, 
state->clk_frequency);

+   else
+   dev_warn(dev, "No clock frequency specified!\n");
+   if (ret < 0) {
+		dev_err(dev, "set rate=%d failed: %d\n", 
state->clk_frequency,

+   ret);
+   return -EINVAL;


Preserve the error code.


agree.




+   }
+
+   return ret;


This could be "return 0;" (let's not return true).  It might be 
nicer

like:

if (!state->clk_frequency) {


looking back again to my code ;), this can never happen, because 
if
clock-frequency is not given by dts I give it a default value. So, 
this

error path will never happen. I will take this in account in v2.


dev_warn(dev, "No clock frequency specified!\n");
return 0;
}

ret = clk_set_rate(state->mipi_clk, state->clk_frequency);
if (ret < 0)
		dev_err(dev, "set rate=%d failed: %d\n", 
state->clk_frequency,

ret);

return ret;



+}
+


[ snip ]

+static irqreturn_t mipi_csis_irq_handler(int irq, void 
*dev_id)

+{
+   struct csi_state *state = dev_id;
+   unsigned long flags;
+   u32 status;
+   int i;
+
+   status = mipi_csis_read(state, MIPI_CSIS_INTSRC);
+
+   spin_lock_irqsave(>slock, flags);
+
+   /* Update the event/error counters */
+   if ((status & MIPI_CSIS_INTSRC_ERRORS) || 1) {

 ^^^
Was this supposed to make it into the published code?


No... ;). Only for my debug purpose... Good catch.

---
Cheers,
Rui

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


Re: [PATCH 02/15] media: staging/imx7: add imx7 CSI subdev driver

2018-04-19 Thread Rui Miguel Silva

Hi,
On Thu 19 Apr 2018 at 12:22, Dan Carpenter wrote:
On Thu, Apr 19, 2018 at 11:17:59AM +0100, Rui Miguel Silva 
wrote:

+static int imx7_csi_link_setup(struct media_entity *entity,
+  const struct media_pad *local,
+			   const struct media_pad *remote, u32 
flags)

+{
+	struct v4l2_subdev *sd = 
media_entity_to_v4l2_subdev(entity);

+   struct imx7_csi *csi = v4l2_get_subdevdata(sd);
+   struct v4l2_subdev *remote_sd;
+   int ret = 0;
+
+	dev_dbg(csi->dev, "link setup %s -> %s\n", 
remote->entity->name,

+   local->entity->name);
+
+   mutex_lock(>lock);
+
+   if (local->flags & MEDIA_PAD_FL_SINK) {
+		if (!is_media_entity_v4l2_subdev(remote->entity)) 
{

+   ret = -EINVAL;
+   goto unlock;
+   }
+
+		remote_sd = 
media_entity_to_v4l2_subdev(remote->entity);

+
+   if (flags & MEDIA_LNK_FL_ENABLED) {
+   if (csi->src_sd) {
+   ret = -EBUSY;
+   goto unlock;
+   }
+   csi->src_sd = remote_sd;
+   } else {
+   csi->src_sd = NULL;
+   }
+
+   goto init;
+   }
+
+   /* source pad */
+   if (flags & MEDIA_LNK_FL_ENABLED) {
+   if (csi->sink) {
+   ret = -EBUSY;
+   goto unlock;
+   }
+   csi->sink = remote->entity;
+   } else {
+   v4l2_ctrl_handler_free(>ctrl_hdlr);
+   v4l2_ctrl_handler_init(>ctrl_hdlr, 0);
+   csi->sink = NULL;
+   }
+
+init:
+   if (csi->sink || csi->src_sd)
+   imx7_csi_init(csi);
+   else
+   imx7_csi_deinit(csi);
+
+unlock:
+   mutex_unlock(>lock);
+
+   return 0;


This should be "return ret;" because the failure paths go 
through here

as well.


Agree.




+}
+
+static int imx7_csi_pad_link_validate(struct v4l2_subdev *sd,
+ struct media_link *link,
+  struct v4l2_subdev_format 
*source_fmt,
+  struct v4l2_subdev_format 
*sink_fmt)

+{
+   struct imx7_csi *csi = v4l2_get_subdevdata(sd);
+   struct v4l2_fwnode_endpoint upstream_ep;
+   int ret;
+
+	ret = v4l2_subdev_link_validate_default(sd, link, 
source_fmt, sink_fmt);

+   if (ret)
+   return ret;
+
+	ret = imx7_csi_get_upstream_endpoint(csi, _ep, 
true);

+   if (ret) {
+		v4l2_err(>sd, "failed to find upstream 
endpoint\n");

+   return ret;
+   }
+
+   mutex_lock(>lock);
+
+   csi->upstream_ep = upstream_ep;
+   csi->is_csi2 = (upstream_ep.bus_type == V4L2_MBUS_CSI2);
+
+   mutex_unlock(>lock);
+
+   return ret;


return 0;


ack.




+}
+


[ snip ]


+
+static int imx7_csi_remove(struct platform_device *pdev)
+{
+   return 0;
+}


There is no need for this empty (struct 
platform_driver)->remove()

function.  See platform_drv_remove() for how it's called.


right.



This looks nice, though.


Thanks,
---
Cheers,
Rui

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


Re: [PATCH 01/15] media: staging/imx: add support to media dev for no IPU systems

2018-04-19 Thread Rui Miguel Silva

Hi Dan,
Thanks for this and the other reviews.

On Thu 19 Apr 2018 at 12:06, Dan Carpenter wrote:
On Thu, Apr 19, 2018 at 11:17:58AM +0100, Rui Miguel Silva 
wrote:
Some i.MX SoC do not have IPU, like the i.MX7, add to the the 
media device
infrastructure support to be used in this type of systems that 
do not have

internal subdevices besides the CSI.

Signed-off-by: Rui Miguel Silva 
---
 drivers/staging/media/imx/imx-media-dev.c| 16 
 +++-

 .../staging/media/imx/imx-media-internal-sd.c|  3 +++
 drivers/staging/media/imx/imx-media.h|  3 +++
 3 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-dev.c 
b/drivers/staging/media/imx/imx-media-dev.c

index f67ec8e27093..a8afe0ec4134 100644
--- a/drivers/staging/media/imx/imx-media-dev.c
+++ b/drivers/staging/media/imx/imx-media-dev.c
@@ -92,6 +92,9 @@ static int imx_media_get_ipu(struct 
imx_media_dev *imxmd,

struct ipu_soc *ipu;
int ipu_id;
 
+	if (imxmd->no_ipu_present)


It's sort of nicer if variables don't have a negative built in 
because
otherwise you get confusing double negatives like "if (!no_ipu) 
{".
It's not hard to invert the varible in this case, because the 
only thing

we need to change is imx_media_probe() to set:

+   imxmd->ipu_present = true;


Yeah, my code was like this till last minute, and I also dislike 
the
double negatives... but since the logic that reset the variable 
would

only be done in a later patch I switched the logic.

But You are right I could just had the initialization here to 
true.

Will take this in account in v2.

---
Cheers,
Rui

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


Re: [cfs_trace_lock_tcd] BUG: KASAN: null-ptr-deref in cfs_trace_lock_tcd+0x25/0xeb

2018-04-19 Thread Andrey Ryabinin


On 04/18/2018 09:37 PM, Linus Torvalds wrote:
> Ugh, that lustre code is disgusting.
> 
> I thought we were getting rid of it.
> 
> Anyway, I started looking at why the stack trace is such an incredible
> mess, with lots of stale entries.
> 
> The reason (well, _one_ reason) seems to be "ksocknal_startup". It has
> a 500-byte stack frame for some incomprehensible reason. I assume due
> to excessive inlining, because the function itself doesn't seem to be
> that bad.
> 
> Similarly, LNetNIInit has a 300-byte stack frame. So it gets pretty deep.
> 
> I'm getting the feeling that KASAN is making things worse because
> probably it's disabling all the sane stack frame stuff (ie no merging
> of stack slot entries, perhaps?).
>

AFAIR no merging of stack slots policy enabled only if 
-fsanitize-address-use-after-scope 
is on (which is CONFIG_KASAN_EXTRA). This feature does cause sometimes 
significant stack bloat,
but hasn't been proven to be very useful, so I wouldn't mind disabling it 
completely.

So far I know only about a single BUG - 
https://lkml.kernel.org/r/<151238865557.4852.10258661301122491...@mail.alporthouse.com>
it has found.
There are also a lot of other 


> Without KASAN (but also without a lot of other things, so I might be
> blaming KASAN incorrectly), the stack usage of ksocknal_startup() is
> just under 100 bytes, so if it is KASAN, it's really a big difference.
>

Yes, it's because of KASAN:
CONFIG_KASAN=n
socklnd.c:2795:1:ksocknal_startup   144 static

CONFIG_KASAN=y
CONFIG_KASAN_OUTLINE=y
CONFIG_KASAN_EXTRA=n
socklnd.c:2795:1:ksocknal_startup   552 static

CONFIG_KASAN=y
CONFIG_KASAN_OUTLINE=y
CONFIG_KASAN_EXTRA=y
socklnd.c:2795:1:ksocknal_startup   624 static

It's expected that KASAN may cause sometimes significant stack usage growth.
This is needed to catch out-of-bounds accesses to stack data.
When compiler can't proof that access to stack variable is valid (e.g. 
reference to
stack variable passed to some external function), it will create redzones 
around such
stack variable.

E.g. ksocknal_enumerate_interfaces() which is called only from 
ksocknal_startup(), thus probably
inlined into ksocknal_startup() does this:


for (i = j = 0; i < n; i++) {
int up;
__u32 ip;
__u32 mask;

if (!strcmp(names[i], "lo")) /* skip the loopback IF */
continue;

rc = lnet_ipif_query(names[i], , , );


With KASAN stack might look something like this:
  [32-byte left redzone of the stack frame] [up (4 bytes)] [28-bytes 
redzone][ip (4 bytes)] [28-bytes redzone][mask (4 bytes)] [28-bytes 
redzone][32-byte right redzone of the stack frame]

GCC always use 32-bytes redzones. AFAIK clang is more smart about this, it has 
adaptive redzone policy - smaller redzones for small variables, and bigger for 
big.

In this particular case, the best way to reduce stack usage is to refactor the 
code.
1) Drop 'int *up' argument from lnet_ipif_query(). When interface is down 
lnet_ipif_query() sets up to zero and doesn't return error.
   But all callers treat up == 0 as error. So instead, lnet_ipif_query() should 
simply return error code, and 'up' won't be needed.
This will simplify the code, and should drop the stack usage with KASAN and 
without KASAN.

2) Instead of using local ip, mask variables, pass pointers 
'>ksnn_interfaces[j].ksni_ipaddr', '>ksnn_interfaces[j].ksni_netmask'.
As in 1) this should alst drop the stack usage both with KASAN and without 
KASAN




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


Re: [PATCH 07/15] media: staging/imx: add 10 bit bayer support

2018-04-19 Thread Philipp Zabel
On Thu, 2018-04-19 at 11:18 +0100, Rui Miguel Silva wrote:
> Some sensors can only output 10 bit bayer formats, like the OV2680. Add 
> support
> for that in imx-media.
> 
> Signed-off-by: Rui Miguel Silva 
> ---
>  drivers/staging/media/imx/imx-media-utils.c | 24 +
>  1 file changed, 24 insertions(+)
> 
> diff --git a/drivers/staging/media/imx/imx-media-utils.c 
> b/drivers/staging/media/imx/imx-media-utils.c
> index fab98fc0d6a0..99527daba29a 100644
> --- a/drivers/staging/media/imx/imx-media-utils.c
> +++ b/drivers/staging/media/imx/imx-media-utils.c
> @@ -118,6 +118,30 @@ static const struct imx_media_pixfmt rgb_formats[] = {
>   .cs = IPUV3_COLORSPACE_RGB,
>   .bpp= 8,
>   .bayer  = true,
> + }, {
> + .fourcc = V4L2_PIX_FMT_SBGGR10,
> + .codes  = {MEDIA_BUS_FMT_SBGGR10_1X10},
> + .cs = IPUV3_COLORSPACE_RGB,
> + .bpp= 16,
> + .bayer  = true,
> + }, {
> + .fourcc = V4L2_PIX_FMT_SGBRG10,
> + .codes  = {MEDIA_BUS_FMT_SGBRG10_1X10},
> + .cs = IPUV3_COLORSPACE_RGB,
> + .bpp= 16,
> + .bayer  = true,
> + }, {
> + .fourcc = V4L2_PIX_FMT_SGRBG10,
> + .codes  = {MEDIA_BUS_FMT_SGRBG10_1X10},
> + .cs = IPUV3_COLORSPACE_RGB,
> + .bpp= 16,
> + .bayer  = true,
> + }, {
> + .fourcc = V4L2_PIX_FMT_SRGGB10,
> + .codes  = {MEDIA_BUS_FMT_SRGGB10_1X10},
> + .cs = IPUV3_COLORSPACE_RGB,
> + .bpp= 16,
> + .bayer  = true,

This will break 10-bit bayer formats on i.MX6, which currently stores
them in memory expanded to 16-bit, as listed in the entries below:

>   }, {
>   .fourcc = V4L2_PIX_FMT_SBGGR16,
>   .codes  = {

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


Re: [PATCH v3 13/20] mmc: Remove depends on HAS_DMA in case of platform dependency

2018-04-19 Thread Ulf Hansson
On 17 April 2018 at 19:49, Geert Uytterhoeven  wrote:
> Remove dependencies on HAS_DMA where a Kconfig symbol depends on another
> symbol that implies HAS_DMA, and, optionally, on "|| COMPILE_TEST".
> In most cases this other symbol is an architecture or platform specific
> symbol, or PCI.
>
> Generic symbols and drivers without platform dependencies keep their
> dependencies on HAS_DMA, to prevent compiling subsystems or drivers that
> cannot work anyway.
>
> This simplifies the dependencies, and allows to improve compile-testing.
>
> Signed-off-by: Geert Uytterhoeven 
> Reviewed-by: Mark Brown 
> Acked-by: Robin Murphy 
> Acked-by: Ulf Hansson 

Thanks, applied for next!

Kind regrds
Uffe

> ---
> v3:
>   - Add Acked-by,
>   - Rebase to v4.17-rc1,
>
> v2:
>   - Add Reviewed-by, Acked-by,
>   - Drop RFC state,
>   - Split per subsystem.
> ---
>  drivers/mmc/host/Kconfig | 10 ++
>  1 file changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
> index 9589f9c9046f14b1..3978d0418958bf6b 100644
> --- a/drivers/mmc/host/Kconfig
> +++ b/drivers/mmc/host/Kconfig
> @@ -358,7 +358,6 @@ config MMC_MESON_MX_SDIO
> tristate "Amlogic Meson6/Meson8/Meson8b SD/MMC Host Controller 
> support"
> depends on ARCH_MESON || COMPILE_TEST
> depends on COMMON_CLK
> -   depends on HAS_DMA
> depends on OF
> help
>   This selects support for the SD/MMC Host Controller on
> @@ -401,7 +400,6 @@ config MMC_OMAP
>
>  config MMC_OMAP_HS
> tristate "TI OMAP High Speed Multimedia Card Interface support"
> -   depends on HAS_DMA
> depends on ARCH_OMAP2PLUS || ARCH_KEYSTONE || COMPILE_TEST
> help
>   This selects the TI OMAP High Speed Multimedia card Interface.
> @@ -511,7 +509,6 @@ config MMC_DAVINCI
>
>  config MMC_GOLDFISH
> tristate "goldfish qemu Multimedia Card Interface support"
> -   depends on HAS_DMA
> depends on GOLDFISH || COMPILE_TEST
> help
>   This selects the Goldfish Multimedia card Interface emulation
> @@ -605,7 +602,7 @@ config MMC_SDHI
>
>  config MMC_SDHI_SYS_DMAC
> tristate "DMA for SDHI SD/SDIO controllers using SYS-DMAC"
> -   depends on MMC_SDHI && HAS_DMA
> +   depends on MMC_SDHI
> default MMC_SDHI if (SUPERH || ARM)
> help
>   This provides DMA support for SDHI SD/SDIO controllers
> @@ -615,7 +612,7 @@ config MMC_SDHI_SYS_DMAC
>  config MMC_SDHI_INTERNAL_DMAC
> tristate "DMA for SDHI SD/SDIO controllers using on-chip bus 
> mastering"
> depends on ARM64 || COMPILE_TEST
> -   depends on MMC_SDHI && HAS_DMA
> +   depends on MMC_SDHI
> default MMC_SDHI if ARM64
> help
>   This provides DMA support for SDHI SD/SDIO controllers
> @@ -669,7 +666,6 @@ config MMC_CAVIUM_THUNDERX
>
>  config MMC_DW
> tristate "Synopsys DesignWare Memory Card Interface"
> -   depends on HAS_DMA
> depends on ARC || ARM || ARM64 || MIPS || COMPILE_TEST
> help
>   This selects support for the Synopsys DesignWare Mobile Storage IP
> @@ -748,7 +744,6 @@ config MMC_DW_ZX
>
>  config MMC_SH_MMCIF
> tristate "SuperH Internal MMCIF support"
> -   depends on HAS_DMA
> depends on SUPERH || ARCH_RENESAS || COMPILE_TEST
> help
>   This selects the MMC Host Interface controller (MMCIF) found in 
> various
> @@ -868,7 +863,6 @@ config MMC_TOSHIBA_PCI
>  config MMC_BCM2835
> tristate "Broadcom BCM2835 SDHOST MMC Controller support"
> depends on ARCH_BCM2835 || COMPILE_TEST
> -   depends on HAS_DMA
> help
>   This selects the BCM2835 SDHOST MMC controller. If you have
>   a BCM2835 platform with SD or MMC devices, say Y or M here.
> --
> 2.7.4
>
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 26/39] rtc/proc: switch to proc_create_single_data

2018-04-19 Thread Alexandre Belloni
On 19/04/2018 14:41:27+0200, Christoph Hellwig wrote:
> And stop trying to get a reference on the submodule, procfs code deals
> with release after and unloaded module and thus removed proc entry.
> 

Are you sure about that? The rtc module is not the one adding the procfs
file so I'm not sure how the procfs code can handle it.

> Signed-off-by: Christoph Hellwig 
> ---
>  drivers/rtc/rtc-proc.c | 33 ++---
>  1 file changed, 2 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-proc.c b/drivers/rtc/rtc-proc.c
> index 31e7e23cc5be..a9dd9218fae2 100644
> --- a/drivers/rtc/rtc-proc.c
> +++ b/drivers/rtc/rtc-proc.c
> @@ -107,40 +107,11 @@ static int rtc_proc_show(struct seq_file *seq, void 
> *offset)
>   return 0;
>  }
>  
> -static int rtc_proc_open(struct inode *inode, struct file *file)
> -{
> - int ret;
> - struct rtc_device *rtc = PDE_DATA(inode);
> -
> - if (!try_module_get(rtc->owner))
> - return -ENODEV;
> -
> - ret = single_open(file, rtc_proc_show, rtc);
> - if (ret)
> - module_put(rtc->owner);
> - return ret;
> -}
> -
> -static int rtc_proc_release(struct inode *inode, struct file *file)
> -{
> - int res = single_release(inode, file);
> - struct rtc_device *rtc = PDE_DATA(inode);
> -
> - module_put(rtc->owner);
> - return res;
> -}
> -
> -static const struct file_operations rtc_proc_fops = {
> - .open   = rtc_proc_open,
> - .read   = seq_read,
> - .llseek = seq_lseek,
> - .release= rtc_proc_release,
> -};
> -
>  void rtc_proc_add_device(struct rtc_device *rtc)
>  {
>   if (is_rtc_hctosys(rtc))
> - proc_create_data("driver/rtc", 0, NULL, _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
> 

-- 
Alexandre Belloni, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 26/39] rtc/proc: switch to proc_create_single_data

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

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

diff --git a/drivers/rtc/rtc-proc.c b/drivers/rtc/rtc-proc.c
index 31e7e23cc5be..a9dd9218fae2 100644
--- a/drivers/rtc/rtc-proc.c
+++ b/drivers/rtc/rtc-proc.c
@@ -107,40 +107,11 @@ static int rtc_proc_show(struct seq_file *seq, void 
*offset)
return 0;
 }
 
-static int rtc_proc_open(struct inode *inode, struct file *file)
-{
-   int ret;
-   struct rtc_device *rtc = PDE_DATA(inode);
-
-   if (!try_module_get(rtc->owner))
-   return -ENODEV;
-
-   ret = single_open(file, rtc_proc_show, rtc);
-   if (ret)
-   module_put(rtc->owner);
-   return ret;
-}
-
-static int rtc_proc_release(struct inode *inode, struct file *file)
-{
-   int res = single_release(inode, file);
-   struct rtc_device *rtc = PDE_DATA(inode);
-
-   module_put(rtc->owner);
-   return res;
-}
-
-static const struct file_operations rtc_proc_fops = {
-   .open   = rtc_proc_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= rtc_proc_release,
-};
-
 void rtc_proc_add_device(struct rtc_device *rtc)
 {
if (is_rtc_hctosys(rtc))
-   proc_create_data("driver/rtc", 0, NULL, _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 30/39] netfilter/xt_hashlimit: switch to proc_create_{seq, single}_data

2018-04-19 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 12/39] net: move seq_file_single_net to

2018-04-19 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 39/39] tty: replace ->proc_fops with ->proc_show

2018-04-19 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 38/39] ide: replace ->proc_fops with ->proc_show

2018-04-19 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 13/39] proc: introduce proc_create_net{,_data}

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

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

diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c
index 1483bc7b01e1..714bb605a140 100644
--- a/drivers/net/ppp/pppoe.c
+++ b/drivers/net/ppp/pppoe.c
@@ -1092,21 +1092,6 @@ static const struct seq_operations pppoe_seq_ops = {
.stop   = pppoe_seq_stop,
.show   = pppoe_seq_show,
 };
-
-static int pppoe_seq_open(struct inode *inode, struct file *file)
-{
-   return seq_open_net(inode, file, _seq_ops,
-   sizeof(struct seq_net_private));
-}
-
-static const struct file_operations pppoe_seq_fops = {
-   .owner  = THIS_MODULE,
-   .open   = pppoe_seq_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= seq_release_net,
-};
-
 #endif /* CONFIG_PROC_FS */
 
 static const struct proto_ops pppoe_ops = {
@@ -1142,7 +1127,8 @@ static __net_init int pppoe_init_net(struct net *net)
 
rwlock_init(>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 19/39] sg: simplify procfs code

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

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

diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index c198b96368dd..8ff687158704 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -66,7 +66,6 @@ static int sg_version_num = 30536;/* 2 digits for each 
component */
 static char *sg_version_date = "20140603";
 
 static int sg_proc_init(void);
-static void sg_proc_cleanup(void);
 #endif
 
 #define SG_ALLOW_DIO_DEF 0
@@ -1661,7 +1660,7 @@ static void __exit
 exit_sg(void)
 {
 #ifdef CONFIG_SCSI_PROC_FS
-   sg_proc_cleanup();
+   remove_proc_subtree("scsi/sg", NULL);
 #endif /* CONFIG_SCSI_PROC_FS */
scsi_unregister_interface(_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 = _proc_leaf_arr[k];
-   umode_t mask = leaf->fops->write ? S_IRUGO | S_IWUSR : S_IRUGO;
-   proc_create(leaf->name, mask, sg_proc_sgp, leaf->fops);

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

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

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


[PATCH 21/39] ext4: simplify procfs code

2018-04-19 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/39] hostap: switch to proc_create_{seq,single}_data

2018-04-19 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 25/39] drbd: switch to proc_create_single

2018-04-19 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 34/39] atm: switch to proc_create_seq_private

2018-04-19 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 17/39] sgi-gru: simplify procfs code

2018-04-19 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 37/39] ide: remove ide_driver_proc_write

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

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

diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c
index 863db44c7916..b3b8b8822d6a 100644
--- a/drivers/ide/ide-proc.c
+++ b/drivers/ide/ide-proc.c
@@ -528,58 +528,12 @@ static int ide_driver_proc_open(struct inode *inode, 
struct file *file)
return single_open(file, ide_driver_proc_show, PDE_DATA(inode));
 }
 
-static int ide_replace_subdriver(ide_drive_t *drive, const char *driver)
-{
-   struct device *dev = >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 01/39] net/can: single_open_net needs to be paired with single_release_net

2018-04-19 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 07/39] ipv{4,6}/ping: simplify proc file creation

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

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

diff --git a/include/net/ping.h b/include/net/ping.h
index 4cd90d6b5c25..fd080e043a6e 100644
--- a/include/net/ping.h
+++ b/include/net/ping.h
@@ -83,20 +83,9 @@ int  ping_queue_rcv_skb(struct sock *sk, struct sk_buff 
*skb);
 bool ping_rcv(struct sk_buff *skb);
 
 #ifdef CONFIG_PROC_FS
-struct ping_seq_afinfo {
-   char*name;
-   sa_family_t family;
-   const struct file_operations*seq_fops;
-   const struct seq_operations seq_ops;
-};
-
-extern const struct file_operations ping_seq_fops;
-
 void *ping_seq_start(struct seq_file *seq, loff_t *pos, sa_family_t family);
 void *ping_seq_next(struct seq_file *seq, void *v, loff_t *pos);
 void ping_seq_stop(struct seq_file *seq, void *v);
-int ping_proc_register(struct net *net, struct ping_seq_afinfo *afinfo);
-void ping_proc_unregister(struct net *net, struct ping_seq_afinfo *afinfo);
 
 int __init ping_proc_init(void);
 void ping_proc_exit(void);
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
index 05e47d777009..83170ebf5dfc 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -1147,58 +1147,36 @@ static int ping_v4_seq_show(struct seq_file *seq, void 
*v)
return 0;
 }
 
-static int ping_seq_open(struct inode *inode, struct file *file)
+static const struct seq_operations ping_v4_seq_ops = {
+   .start  = ping_v4_seq_start,
+   .show   = ping_v4_seq_show,
+   .next   = ping_seq_next,
+   .stop   = ping_seq_stop,
+};
+
+static int ping_v4_seq_open(struct inode *inode, struct file *file)
 {
-   struct ping_seq_afinfo *afinfo = PDE_DATA(inode);
-   return seq_open_net(inode, file, >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 33/39] atm: simplify procfs code

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

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

diff --git a/net/atm/proc.c b/net/atm/proc.c
index 55410c00c7e2..f272b0f59d82 100644
--- a/net/atm/proc.c
+++ b/net/atm/proc.c
@@ -257,18 +257,6 @@ static const struct seq_operations atm_dev_seq_ops = {
.show   = atm_dev_seq_show,
 };
 
-static int atm_dev_seq_open(struct inode *inode, struct file *file)
-{
-   return seq_open(file, _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 04/39] proc: introduce proc_create_single{,_data}

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

All trivial callers converted over.

Signed-off-by: Christoph Hellwig 
---
 arch/arm/kernel/dma.c | 14 +---
 arch/arm/kernel/swp_emulate.c | 15 +---
 arch/arm/mach-rpc/ecard.c | 16 +---
 arch/ia64/kernel/palinfo.c| 16 +---
 arch/ia64/kernel/salinfo.c| 42 --
 arch/ia64/sn/kernel/sn2/prominfo_proc.c   | 32 +---
 arch/ia64/sn/kernel/sn2/sn_proc_fs.c  | 62 ++
 arch/m68k/kernel/setup_mm.c   | 14 +---
 arch/mips/pci/ops-pmcmsp.c| 28 +--
 arch/mips/sibyte/common/bus_watcher.c | 16 +---
 arch/parisc/kernel/pci-dma.c  | 17 +---
 arch/parisc/kernel/pdc_chassis.c  | 14 +---
 arch/powerpc/kernel/eeh.c | 14 +---
 arch/powerpc/kernel/rtas-proc.c   | 32 +---
 arch/powerpc/platforms/cell/spufs/sched.c | 14 +---
 arch/s390/kernel/sysinfo.c| 14 +---
 arch/sh/drivers/dma/dma-api.c | 14 +---
 arch/sparc/kernel/ioport.c| 19 +
 arch/um/drivers/ubd_kern.c| 16 +---
 arch/x86/kernel/apm_32.c  | 15 +---
 drivers/acpi/ac.c | 21 +
 drivers/acpi/button.c | 19 +
 drivers/block/DAC960.c| 49 ++-
 drivers/block/pktcdvd.c   | 14 +---
 drivers/block/ps3vram.c   | 17 +---
 drivers/char/apm-emulation.c  | 15 +---
 drivers/char/ds1620.c | 14 +---
 drivers/char/efirtc.c | 15 +---
 drivers/char/nvram.c  | 15 +---
 drivers/char/rtc.c| 19 +
 drivers/char/toshiba.c| 15 +---
 drivers/connector/connector.c | 15 +---
 drivers/input/misc/hp_sdc_rtc.c   | 14 +---
 drivers/isdn/capi/capi.c  | 30 +--
 drivers/isdn/capi/capidrv.c   | 15 +---
 drivers/isdn/hardware/eicon/diva_didd.c   | 17 +---
 drivers/isdn/hardware/eicon/divasi.c  | 17 +---
 drivers/macintosh/via-pmu.c   | 57 +++--
 drivers/media/pci/saa7164/saa7164-core.c  | 14 +---
 drivers/media/pci/zoran/videocodec.c  | 16 +---
 drivers/message/fusion/mptbase.c  | 57 +++--
 drivers/mtd/mtdcore.c | 14 +---
 drivers/net/wireless/atmel/atmel.c| 15 +---
 .../net/wireless/intersil/hostap/hostap_ap.c  | 16 +---
 drivers/net/wireless/ray_cs.c | 15 +---
 drivers/nubus/proc.c  | 55 ++---
 drivers/parisc/ccio-dma.c | 34 +---
 drivers/parisc/sba_iommu.c| 32 +---
 drivers/platform/x86/toshiba_acpi.c   | 17 +---
 drivers/pnp/pnpbios/proc.c| 78 ++
 drivers/staging/comedi/proc.c | 18 +---
 drivers/usb/gadget/udc/at91_udc.c | 16 +---
 drivers/usb/gadget/udc/fsl_udc_core.c | 18 +---
 drivers/usb/gadget/udc/goku_udc.c | 18 +---
 drivers/usb/gadget/udc/omap_udc.c | 15 +---
 drivers/video/fbdev/via/viafbdev.c| 17 +---
 fs/cifs/cifs_debug.c  | 15 +---
 fs/f2fs/sysfs.c   | 29 ++-
 fs/filesystems.c  | 14 +---
 fs/fscache/internal.h |  2 +-
 fs/fscache/proc.c |  4 +-
 fs/fscache/stats.c| 17 +---
 fs/proc/cmdline.c | 14 +---
 fs/proc/generic.c | 27 ++
 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 02/39] proc: introduce proc_create_seq{,_data}

2018-04-19 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| 28 +++
 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, 149 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 31/39] netfilter/x_tables: switch to proc_create_seq_private

2018-04-19 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 18/39] megaraid: simplify procfs code

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

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

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

[PATCH 24/39] resource: switch to proc_create_seq_data

2018-04-19 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 23/39] staging/rtl8192u: simplify procfs code

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

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

diff --git a/drivers/staging/rtl8192u/r8192U_core.c 
b/drivers/staging/rtl8192u/r8192U_core.c
index d607c59761cf..7a0dbc0fa18e 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -646,64 +646,25 @@ static void rtl8192_proc_module_init(void)
rtl8192_proc = proc_mkdir(RTL819xU_MODULE_NAME, init_net.proc_net);
 }
 
-/*
- * seq_file wrappers for procfile show routines.
- */
-static int rtl8192_proc_open(struct inode *inode, struct file *file)
-{
-   struct net_device *dev = proc_get_parent_data(inode);
-   int (*show)(struct seq_file *, void *) = PDE_DATA(inode);
-
-   return single_open(file, show, dev);
-}
-
-static const struct file_operations rtl8192_proc_fops = {
-   .open   = rtl8192_proc_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
-
-/*
- * Table of proc files we need to create.
- */
-struct rtl8192_proc_file {
-   char name[12];
-   int (*show)(struct seq_file *, void *);
-};
-
-static const struct rtl8192_proc_file rtl8192_proc_files[] = {
-   { "stats-rx",   _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 15/39] acpi/battery: simplify procfs code

2018-04-19 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/acpi/battery.c | 121 +
 1 file changed, 26 insertions(+), 95 deletions(-)

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

[PATCH 29/39] neigh: switch to proc_create_seq_data

2018-04-19 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 7b7a14abba28..cbfb6d71b8be 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -58,7 +58,7 @@ static void neigh_update_notify(struct neighbour *neigh, u32 
nlmsg_pid);
 static int pneigh_ifdown(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
 
 /*
@@ -1550,8 +1550,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
 
@@ -2774,7 +2774,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)
@@ -2791,7 +2791,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) {
@@ -2810,7 +2810,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) {
@@ -2849,25 +2849,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 16/39] ipmi: simplify procfs code

2018-04-19 Thread Christoph Hellwig
Use remove_proc_subtree to remove the whole subtree on cleanup instead
of a hand rolled list of proc entries, unwind the registration loop into
individual calls.  Switch to use proc_create_single to further simplify
the code.

Signed-off-by: Christoph Hellwig 
---
 drivers/char/ipmi/ipmi_msghandler.c | 150 +---
 drivers/char/ipmi/ipmi_si_intf.c|  47 +
 drivers/char/ipmi/ipmi_ssif.c   |  34 +--
 include/linux/ipmi_smi.h|   8 +-
 4 files changed, 33 insertions(+), 206 deletions(-)

diff --git a/drivers/char/ipmi/ipmi_msghandler.c 
b/drivers/char/ipmi/ipmi_msghandler.c
index 361148938801..c18db313e4c4 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -247,13 +247,6 @@ struct ipmi_my_addrinfo {
unsigned char lun;
 };
 
-#ifdef CONFIG_IPMI_PROC_INTERFACE
-struct ipmi_proc_entry {
-   char   *name;
-   struct ipmi_proc_entry *next;
-};
-#endif
-
 /*
  * Note that the product id, manufacturer id, guid, and device id are
  * immutable in this structure, so dyn_mutex is not required for
@@ -430,10 +423,6 @@ struct ipmi_smi {
void *send_info;
 
 #ifdef CONFIG_IPMI_PROC_INTERFACE
-   /* A list of proc entries for this interface. */
-   struct mutex   proc_entry_lock;
-   struct ipmi_proc_entry *proc_entries;
-
struct proc_dir_entry *proc_dir;
char  proc_dir_name[10];
 #endif
@@ -2358,18 +2347,6 @@ static int smi_ipmb_proc_show(struct seq_file *m, void 
*v)
return 0;
 }
 
-static int smi_ipmb_proc_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, smi_ipmb_proc_show, PDE_DATA(inode));
-}
-
-static const struct file_operations smi_ipmb_proc_ops = {
-   .open   = smi_ipmb_proc_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
-
 static int smi_version_proc_show(struct seq_file *m, void *v)
 {
ipmi_smi_t intf = m->private;
@@ -2387,18 +2364,6 @@ static int smi_version_proc_show(struct seq_file *m, 
void *v)
return 0;
 }
 
-static int smi_version_proc_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, smi_version_proc_show, PDE_DATA(inode));
-}
-
-static const struct file_operations smi_version_proc_ops = {
-   .open   = smi_version_proc_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
-
 static int smi_stats_proc_show(struct seq_file *m, void *v)
 {
ipmi_smi_t intf = m->private;
@@ -2462,95 +2427,45 @@ static int smi_stats_proc_show(struct seq_file *m, void 
*v)
return 0;
 }
 
-static int smi_stats_proc_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, smi_stats_proc_show, PDE_DATA(inode));
-}
-
-static const struct file_operations smi_stats_proc_ops = {
-   .open   = smi_stats_proc_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
-
 int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name,
-   const struct file_operations *proc_ops,
-   void *data)
+   int (*show)(struct seq_file *, void *), void *data)
 {
-   intrv = 0;
-   struct proc_dir_entry  *file;
-   struct ipmi_proc_entry *entry;
-
-   /* Create a list element. */
-   entry = kmalloc(sizeof(*entry), GFP_KERNEL);
-   if (!entry)
+   if (!proc_create_single_data(name, 0, smi->proc_dir, show, data))
return -ENOMEM;
-   entry->name = kstrdup(name, GFP_KERNEL);
-   if (!entry->name) {
-   kfree(entry);
-   return -ENOMEM;
-   }
-
-   file = proc_create_data(name, 0, smi->proc_dir, proc_ops, data);
-   if (!file) {
-   kfree(entry->name);
-   kfree(entry);
-   rv = -ENOMEM;
-   } else {
-   mutex_lock(>proc_entry_lock);
-   /* Stick it on the list. */
-   entry->next = smi->proc_entries;
-   smi->proc_entries = entry;
-   mutex_unlock(>proc_entry_lock);
-   }
-
-   return rv;
+   return 0;
 }
 EXPORT_SYMBOL(ipmi_smi_add_proc_entry);
 
 static int add_proc_entries(ipmi_smi_t smi, int num)
 {
-   int rv = 0;
-
sprintf(smi->proc_dir_name, "%d", num);
smi->proc_dir = proc_mkdir(smi->proc_dir_name, proc_ipmi_root);
if (!smi->proc_dir)
-   rv = -ENOMEM;
-
-   if (rv == 0)
-   rv = ipmi_smi_add_proc_entry(smi, "stats",
-_stats_proc_ops,
-smi);
-
-   if (rv == 0)
-   rv = ipmi_smi_add_proc_entry(smi, "ipmb",
- 

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

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

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

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

[PATCH 20/39] afs: simplify procfs code

2018-04-19 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 22/39] jfs: simplify procfs code

2018-04-19 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 11/39] netfilter/x_tables: simplify ѕeq_file code

2018-04-19 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 14/39] proc: introduce proc_create_net_single

2018-04-19 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 |  47 +++-
 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, 84 insertions(+), 307 deletions(-)

diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
index 9a1948d58f10..518b39025b23 100644
--- a/fs/proc/proc_net.c
+++ b/fs/proc/proc_net.c
@@ -93,37 +93,48 @@ 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_data(name, mode, parent, _net_single_fops, data);
+   if (p)
+   p->single_show = show;
+   return 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 d58976e93ecd..84ec3cd44f8b 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,
size_t state_size, void *data);
 #define proc_create_net(name, mode, parent, state_size, ops) \
proc_create_net_data(name, mode, parent, state_size, ops, NULL)
+struct proc_dir_entry *proc_create_net_single(const char *name, umode_t mode,
+   struct proc_dir_entry *parent,
+   int (*show)(struct seq_file *, void *), void *data);
 
 #else /* CONFIG_PROC_FS */
 
@@ -97,6 +100,7 @@ static inline int remove_proc_subtree(const char *name, 
struct proc_dir_entry *p
 
 #define proc_create_net_data(name, mode, parent, ops, state_size, data) 
({NULL;})
 #define proc_create_net(name, mode, parent, state_size, ops) ({NULL;})
+#define proc_create_net_single(name, mode, parent, show, data) ({NULL;})
 
 #endif /* CONFIG_PROC_FS */
 
diff --git a/include/linux/seq_file_net.h b/include/linux/seq_file_net.h
index 5ea18a16291a..0fdbe1ddd8d1 100644
--- a/include/linux/seq_file_net.h
+++ b/include/linux/seq_file_net.h
@@ -13,9 +13,6 @@ struct seq_net_private {
 #endif
 };
 
-int single_open_net(struct inode *, struct file *file,
-   int (*show)(struct seq_file *, void *));
-int single_release_net(struct inode *, struct file *);
 static inline struct net *seq_file_net(struct seq_file *seq)
 {
 #ifdef CONFIG_NET_NS
@@ -26,8 +23,8 @@ static inline struct net *seq_file_net(struct seq_file *seq)
 }
 
 /*
- * This one is needed for single_open_net since net is stored directly in
- * private not as a struct i.e. seq_file_net can't be used.
+ * This one is needed for proc_create_net_single since net is stored directly
+ * in private not as a struct i.e. seq_file_net can't be used.
  */
 static inline struct net 

simplify procfs code for seq_file instances

2018-04-19 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

Gitweb:

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

Diffstat:  268 files changed, 1193 insertions(+), 6194 deletions(-)
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 35/39] isdn: replace ->proc_fops with ->proc_show

2018-04-19 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 32/39] bluetooth: switch to proc_create_seq_data

2018-04-19 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 27/39] bonding: switch to proc_create_seq_data

2018-04-19 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 03/39] proc: introduce proc_create_seq_private

2018-04-19 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 
---
 drivers/s390/cio/blacklist.c | 21 -
 fs/locks.c   | 16 ++--
 fs/proc/generic.c| 13 +
 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 +++
 13 files changed, 44 insertions(+), 131 deletions(-)

diff --git a/drivers/s390/cio/blacklist.c b/drivers/s390/cio/blacklist.c
index 2a3f874a21d5..ad35cddcf6af 100644
--- a/drivers/s390/cio/blacklist.c
+++ b/drivers/s390/cio/blacklist.c
@@ -391,28 +391,15 @@ static const struct seq_operations 
cio_ignore_proc_seq_ops = {
.show  = cio_ignore_proc_seq_show,
 };
 
-static int
-cio_ignore_proc_open(struct inode *inode, struct file *file)
-{
-   return seq_open_private(file, _ignore_proc_seq_ops,
-   sizeof(struct ccwdev_iter));
-}
-
-static const struct file_operations cio_ignore_proc_fops = {
-   .open= cio_ignore_proc_open,
-   .read= seq_read,
-   .llseek  = seq_lseek,
-   .release = seq_release_private,
-   .write   = cio_ignore_write,
-};
-
 static int
 cio_ignore_proc_init (void)
 {
struct proc_dir_entry *entry;
 
-   entry = proc_create("cio_ignore", S_IFREG | S_IRUGO | S_IWUSR, NULL,
-   _ignore_proc_fops);
+   entry = proc_create_seq_private("cio_ignore",
+   S_IFREG | S_IRUGO | S_IWUSR, NULL,
+   _ignore_proc_seq_ops, sizeof(struct ccwdev_iter),
+   NULL);
if (!entry)
return -ENOENT;
return 0;
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 2135443e52ef..19c40c6f8fd2 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -554,6 +554,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);
 }
 
@@ -564,18 +566,21 @@ 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)
+   size_t state_size, void *data)
 {
struct proc_dir_entry *p;
 
p = proc_create_data(name, mode, parent, _seq_fops, data);
-   if (p)
+   if (p) {
p->seq_ops = ops;
+   p->state_size = state_size;
+   }
+
return p;
 }
-EXPORT_SYMBOL(proc_create_seq_data);
+EXPORT_SYMBOL(proc_create_seq_private);
  
 struct proc_dir_entry *proc_create(const char *name, umode_t mode,
   struct proc_dir_entry *parent,
diff --git a/fs/proc/internal.h b/fs/proc/internal.h
index 4430fd38dfc4..90756a26f710 100644
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -45,6 +45,7 @@ struct proc_dir_entry {
const struct inode_operations *proc_iops;
const struct file_operations *proc_fops;
const struct seq_operations *seq_ops;
+   size_t state_size;
void *data;
unsigned int low_ino;
nlink_t nlink;
diff --git a/include/linux/atalk.h b/include/linux/atalk.h
index 

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

2018-04-19 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 09/39] ipv6/flowlabel: simplify pid namespace lookup

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

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

diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c
index c05c4e82a7ca..a9f221d45ef9 100644
--- a/net/ipv6/ip6_flowlabel.c
+++ b/net/ipv6/ip6_flowlabel.c
@@ -754,7 +754,10 @@ static struct ip6_flowlabel *ip6fl_get_idx(struct seq_file 
*seq, loff_t pos)
 static void *ip6fl_seq_start(struct seq_file *seq, loff_t *pos)
__acquires(RCU)
 {
+   struct ip6fl_iter_state *state = ip6fl_seq_private(seq);
+
rcu_read_lock_bh();
+   state->pid_ns = task_active_pid_ns(current);
return *pos ? ip6fl_get_idx(seq, *pos - 1) : SEQ_START_TOKEN;
 }
 
@@ -810,36 +813,15 @@ static const struct seq_operations ip6fl_seq_ops = {
 
 static int ip6fl_seq_open(struct inode *inode, struct file *file)
 {
-   struct seq_file *seq;
-   struct ip6fl_iter_state *state;
-   int err;
-
-   err = seq_open_net(inode, file, _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 06/39] ipv{4,6}/tcp: simplify procfs registration

2018-04-19 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 10/39] net/kcm: simplify proc registration

2018-04-19 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


Re: [PATCH 20/39] afs: simplify procfs code

2018-04-19 Thread David Howells
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.

Note that this is likely going to clash with my patch to net-namespace all of
the afs proc files:


https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/commit/?h=mount-context=f60c26c827c073583107ebf19d87bc5c0e71c3d2

If it helps, I should be able to disentangle this from the mount-api changes
since the subsequent patch connects the dots to propagate the network
namespace over automount using the new fs_context to do it.

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


Re: [PATCH 05/15] media: staging/imx7: add MIPI CSI-2 receiver subdev for i.MX7

2018-04-19 Thread Dan Carpenter

> +static int mipi_csis_clk_get(struct csi_state *state)
> +{
> + struct device *dev = >pdev->dev;
> + int ret = true;

Better to leave ret unitialized.

> +
> + state->mipi_clk = devm_clk_get(dev, "mipi");
> + if (IS_ERR(state->mipi_clk)) {
> + dev_err(dev, "Could not get mipi csi clock\n");
> + return -ENODEV;
> + }
> +
> + state->phy_clk = devm_clk_get(dev, "phy");
> + if (IS_ERR(state->phy_clk)) {
> + dev_err(dev, "Could not get mipi phy clock\n");
> + return -ENODEV;
> + }
> +
> + /* Set clock rate */
> + if (state->clk_frequency)
> + ret = clk_set_rate(state->mipi_clk, state->clk_frequency);
> + else
> + dev_warn(dev, "No clock frequency specified!\n");
> + if (ret < 0) {
> + dev_err(dev, "set rate=%d failed: %d\n", state->clk_frequency,
> + ret);
> + return -EINVAL;

Preserve the error code.

> + }
> +
> + return ret;

This could be "return 0;" (let's not return true).  It might be nicer
like:

if (!state->clk_frequency) {
dev_warn(dev, "No clock frequency specified!\n");
return 0;
}

ret = clk_set_rate(state->mipi_clk, state->clk_frequency);
if (ret < 0)
dev_err(dev, "set rate=%d failed: %d\n", state->clk_frequency,
ret);

return ret;


> +}
> +

[ snip ]

> +static irqreturn_t mipi_csis_irq_handler(int irq, void *dev_id)
> +{
> + struct csi_state *state = dev_id;
> + unsigned long flags;
> + u32 status;
> + int i;
> +
> + status = mipi_csis_read(state, MIPI_CSIS_INTSRC);
> +
> + spin_lock_irqsave(>slock, flags);
> +
> + /* Update the event/error counters */
> + if ((status & MIPI_CSIS_INTSRC_ERRORS) || 1) {
 ^^^
Was this supposed to make it into the published code?

> + for (i = 0; i < MIPI_CSIS_NUM_EVENTS; i++) {
> + if (!(status & state->events[i].mask))
> + continue;
> + state->events[i].counter++;
> + }
> + }
> + spin_unlock_irqrestore(>slock, flags);
> +
> + mipi_csis_write(state, MIPI_CSIS_INTSRC, status);
> +
> + return IRQ_HANDLED;
> +}
> +

regards,
dan carpenter


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


Re: [PATCH 02/15] media: staging/imx7: add imx7 CSI subdev driver

2018-04-19 Thread Dan Carpenter
On Thu, Apr 19, 2018 at 11:17:59AM +0100, Rui Miguel Silva wrote:
> +static int imx7_csi_link_setup(struct media_entity *entity,
> +const struct media_pad *local,
> +const struct media_pad *remote, u32 flags)
> +{
> + struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
> + struct imx7_csi *csi = v4l2_get_subdevdata(sd);
> + struct v4l2_subdev *remote_sd;
> + int ret = 0;
> +
> + dev_dbg(csi->dev, "link setup %s -> %s\n", remote->entity->name,
> + local->entity->name);
> +
> + mutex_lock(>lock);
> +
> + if (local->flags & MEDIA_PAD_FL_SINK) {
> + if (!is_media_entity_v4l2_subdev(remote->entity)) {
> + ret = -EINVAL;
> + goto unlock;
> + }
> +
> + remote_sd = media_entity_to_v4l2_subdev(remote->entity);
> +
> + if (flags & MEDIA_LNK_FL_ENABLED) {
> + if (csi->src_sd) {
> + ret = -EBUSY;
> + goto unlock;
> + }
> + csi->src_sd = remote_sd;
> + } else {
> + csi->src_sd = NULL;
> + }
> +
> + goto init;
> + }
> +
> + /* source pad */
> + if (flags & MEDIA_LNK_FL_ENABLED) {
> + if (csi->sink) {
> + ret = -EBUSY;
> + goto unlock;
> + }
> + csi->sink = remote->entity;
> + } else {
> + v4l2_ctrl_handler_free(>ctrl_hdlr);
> + v4l2_ctrl_handler_init(>ctrl_hdlr, 0);
> + csi->sink = NULL;
> + }
> +
> +init:
> + if (csi->sink || csi->src_sd)
> + imx7_csi_init(csi);
> + else
> + imx7_csi_deinit(csi);
> +
> +unlock:
> + mutex_unlock(>lock);
> +
> + return 0;

This should be "return ret;" because the failure paths go through here
as well.

> +}
> +
> +static int imx7_csi_pad_link_validate(struct v4l2_subdev *sd,
> +   struct media_link *link,
> +   struct v4l2_subdev_format *source_fmt,
> +   struct v4l2_subdev_format *sink_fmt)
> +{
> + struct imx7_csi *csi = v4l2_get_subdevdata(sd);
> + struct v4l2_fwnode_endpoint upstream_ep;
> + int ret;
> +
> + ret = v4l2_subdev_link_validate_default(sd, link, source_fmt, sink_fmt);
> + if (ret)
> + return ret;
> +
> + ret = imx7_csi_get_upstream_endpoint(csi, _ep, true);
> + if (ret) {
> + v4l2_err(>sd, "failed to find upstream endpoint\n");
> + return ret;
> + }
> +
> + mutex_lock(>lock);
> +
> + csi->upstream_ep = upstream_ep;
> + csi->is_csi2 = (upstream_ep.bus_type == V4L2_MBUS_CSI2);
> +
> + mutex_unlock(>lock);
> +
> + return ret;

return 0;

> +}
> +

[ snip ]

> +
> +static int imx7_csi_remove(struct platform_device *pdev)
> +{
> + return 0;
> +}

There is no need for this empty (struct platform_driver)->remove()
function.  See platform_drv_remove() for how it's called.

This looks nice, though.

regards,
dan carpenter


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


Re: [PATCH 01/15] media: staging/imx: add support to media dev for no IPU systems

2018-04-19 Thread Dan Carpenter
On Thu, Apr 19, 2018 at 11:17:58AM +0100, Rui Miguel Silva wrote:
> Some i.MX SoC do not have IPU, like the i.MX7, add to the the media device
> infrastructure support to be used in this type of systems that do not have
> internal subdevices besides the CSI.
> 
> Signed-off-by: Rui Miguel Silva 
> ---
>  drivers/staging/media/imx/imx-media-dev.c| 16 +++-
>  .../staging/media/imx/imx-media-internal-sd.c|  3 +++
>  drivers/staging/media/imx/imx-media.h|  3 +++
>  3 files changed, 17 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/media/imx/imx-media-dev.c 
> b/drivers/staging/media/imx/imx-media-dev.c
> index f67ec8e27093..a8afe0ec4134 100644
> --- a/drivers/staging/media/imx/imx-media-dev.c
> +++ b/drivers/staging/media/imx/imx-media-dev.c
> @@ -92,6 +92,9 @@ static int imx_media_get_ipu(struct imx_media_dev *imxmd,
>   struct ipu_soc *ipu;
>   int ipu_id;
>  
> + if (imxmd->no_ipu_present)

It's sort of nicer if variables don't have a negative built in because
otherwise you get confusing double negatives like "if (!no_ipu) {".
It's not hard to invert the varible in this case, because the only thing
we need to change is imx_media_probe() to set:

+   imxmd->ipu_present = true;

regards,
dan carpenter

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


Re: [PATCH 7/9] staging: nvec: Augment TODO file with GPIO work item

2018-04-19 Thread Marc Dietrich
Hi Linus,

Am Donnerstag, 19. April 2018, 10:41:19 CEST schrieb Linus Walleij:
> To make sure that this driver does not leave staging before it
> is properly converted to use the new GPIO descriptor API,
> augment the TODO file with this work item.

I just sent a patch to convert it. Thanks for the reminder!

Marc

> 
> Cc: Marc Dietrich 
> Signed-off-by: Linus Walleij 
> ---
>  drivers/staging/nvec/TODO | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/staging/nvec/TODO b/drivers/staging/nvec/TODO
> index e4d85d9b4681..78b84c243df4 100644
> --- a/drivers/staging/nvec/TODO
> +++ b/drivers/staging/nvec/TODO
> @@ -4,3 +4,8 @@ ToDo list (incomplete, unordered)
>   - move event handling to nvec_events
>   - finish suspend/resume support
>   - add support for more device implementations
> + - convert all uses of the old GPIO API from  to the
> +   GPIO descriptor API in  and look up GPIO
> +   line descriptor from device tree, ACPI or board files
> + - drop the dependency on  altogether when migrating
> +   to GPIO descriptors




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


[PATCH 2/2] staging: nvec: convert to use GPIO descriptors

2018-04-19 Thread Marc Dietrich
Use GPIO descriptors instead of relying on the old method.

Cc: Linus Walleij 
Signed-off-by: Marc Dietrich 
---
This obsolets the ToDo reminder sent by Linus a few hours ago.
---
 drivers/staging/nvec/nvec.c | 42 +
 drivers/staging/nvec/nvec.h |  2 +-
 2 files changed, 11 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
index 599b01f2ad58..5a3a621bb84b 100644
--- a/drivers/staging/nvec/nvec.c
+++ b/drivers/staging/nvec/nvec.c
@@ -17,12 +17,11 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -236,8 +235,8 @@ static size_t nvec_msg_size(struct nvec_msg *msg)
 static void nvec_gpio_set_value(struct nvec_chip *nvec, int value)
 {
dev_dbg(nvec->dev, "GPIO changed from %u to %u\n",
-   gpio_get_value(nvec->gpio), value);
-   gpio_set_value(nvec->gpio, value);
+   gpiod_get_value(nvec->gpiod), value);
+   gpiod_set_value(nvec->gpiod, value);
 }
 
 /**
@@ -761,27 +760,6 @@ static void nvec_power_off(void)
nvec_write_async(nvec_power_handle, ap_pwr_down, 2);
 }
 
-/*
- *  Parse common device tree data
- */
-static int nvec_i2c_parse_dt_pdata(struct nvec_chip *nvec)
-{
-   nvec->gpio = of_get_named_gpio(nvec->dev->of_node, "request-gpios", 0);
-
-   if (nvec->gpio < 0) {
-   dev_err(nvec->dev, "no gpio specified");
-   return -ENODEV;
-   }
-
-   if (of_property_read_u32(nvec->dev->of_node, "slave-addr",
->i2c_addr)) {
-   dev_err(nvec->dev, "no i2c address specified");
-   return -ENODEV;
-   }
-
-   return 0;
-}
-
 static int tegra_nvec_probe(struct platform_device *pdev)
 {
int err, ret;
@@ -807,9 +785,10 @@ static int tegra_nvec_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, nvec);
nvec->dev = dev;
 
-   err = nvec_i2c_parse_dt_pdata(nvec);
-   if (err < 0)
-   return err;
+   if (of_property_read_u32(dev->of_node, "slave-addr", >i2c_addr)) {
+   dev_err(dev, "no i2c address specified");
+   return -ENODEV;
+   }
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
base = devm_ioremap_resource(dev, res);
@@ -850,11 +829,10 @@ static int tegra_nvec_probe(struct platform_device *pdev)
INIT_WORK(>rx_work, nvec_dispatch);
INIT_WORK(>tx_work, nvec_request_master);
 
-   err = devm_gpio_request_one(dev, nvec->gpio, GPIOF_OUT_INIT_HIGH,
-   "nvec gpio");
-   if (err < 0) {
+   nvec->gpiod = devm_gpiod_get(dev, "request", GPIOD_OUT_HIGH);
+   if (IS_ERR(nvec->gpiod)) {
dev_err(dev, "couldn't request gpio\n");
-   return -ENODEV;
+   return PTR_ERR(nvec->gpiod);
}
 
err = devm_request_irq(dev, nvec->irq, nvec_interrupt, 0,
diff --git a/drivers/staging/nvec/nvec.h b/drivers/staging/nvec/nvec.h
index 25efcdfa4f20..80c0353f141c 100644
--- a/drivers/staging/nvec/nvec.h
+++ b/drivers/staging/nvec/nvec.h
@@ -132,7 +132,7 @@ struct nvec_msg {
  */
 struct nvec_chip {
struct device *dev;
-   int gpio;
+   struct gpio_desc *gpiod;
int irq;
u32 i2c_addr;
void __iomem *base;
-- 
2.17.0

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


[PATCH 1/2] staging: nvec: cleanup use of dev in probe function

2018-04-19 Thread Marc Dietrich
This cleanups the probe function a bit by using a dev variable instead
of 

Signed-off-by: Marc Dietrich 
---
 drivers/staging/nvec/nvec.c | 35 ++-
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
index 52054a528723..599b01f2ad58 100644
--- a/drivers/staging/nvec/nvec.c
+++ b/drivers/staging/nvec/nvec.c
@@ -786,6 +786,7 @@ static int tegra_nvec_probe(struct platform_device *pdev)
 {
int err, ret;
struct clk *i2c_clk;
+   struct device *dev = >dev;
struct nvec_chip *nvec;
struct nvec_msg *msg;
struct resource *res;
@@ -794,42 +795,42 @@ static int tegra_nvec_probe(struct platform_device *pdev)
unmute_speakers[] = { NVEC_OEM0, 0x10, 0x59, 0x95 },
enable_event[7] = { NVEC_SYS, CNF_EVENT_REPORTING, true };
 
-   if (!pdev->dev.of_node) {
-   dev_err(>dev, "must be instantiated using device tree\n");
+   if (!dev->of_node) {
+   dev_err(dev, "must be instantiated using device tree\n");
return -ENODEV;
}
 
-   nvec = devm_kzalloc(>dev, sizeof(struct nvec_chip), GFP_KERNEL);
+   nvec = devm_kzalloc(dev, sizeof(struct nvec_chip), GFP_KERNEL);
if (!nvec)
return -ENOMEM;
 
platform_set_drvdata(pdev, nvec);
-   nvec->dev = >dev;
+   nvec->dev = dev;
 
err = nvec_i2c_parse_dt_pdata(nvec);
if (err < 0)
return err;
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   base = devm_ioremap_resource(>dev, res);
+   base = devm_ioremap_resource(dev, res);
if (IS_ERR(base))
return PTR_ERR(base);
 
nvec->irq = platform_get_irq(pdev, 0);
if (nvec->irq < 0) {
-   dev_err(>dev, "no irq resource?\n");
+   dev_err(dev, "no irq resource?\n");
return -ENODEV;
}
 
-   i2c_clk = devm_clk_get(>dev, "div-clk");
+   i2c_clk = devm_clk_get(dev, "div-clk");
if (IS_ERR(i2c_clk)) {
-   dev_err(nvec->dev, "failed to get controller clock\n");
+   dev_err(dev, "failed to get controller clock\n");
return -ENODEV;
}
 
-   nvec->rst = devm_reset_control_get_exclusive(>dev, "i2c");
+   nvec->rst = devm_reset_control_get_exclusive(dev, "i2c");
if (IS_ERR(nvec->rst)) {
-   dev_err(nvec->dev, "failed to get controller reset\n");
+   dev_err(dev, "failed to get controller reset\n");
return PTR_ERR(nvec->rst);
}
 
@@ -849,17 +850,17 @@ static int tegra_nvec_probe(struct platform_device *pdev)
INIT_WORK(>rx_work, nvec_dispatch);
INIT_WORK(>tx_work, nvec_request_master);
 
-   err = devm_gpio_request_one(>dev, nvec->gpio, GPIOF_OUT_INIT_HIGH,
+   err = devm_gpio_request_one(dev, nvec->gpio, GPIOF_OUT_INIT_HIGH,
"nvec gpio");
if (err < 0) {
-   dev_err(nvec->dev, "couldn't request gpio\n");
+   dev_err(dev, "couldn't request gpio\n");
return -ENODEV;
}
 
-   err = devm_request_irq(>dev, nvec->irq, nvec_interrupt, 0,
+   err = devm_request_irq(dev, nvec->irq, nvec_interrupt, 0,
   "nvec", nvec);
if (err) {
-   dev_err(nvec->dev, "couldn't request irq\n");
+   dev_err(dev, "couldn't request irq\n");
return -ENODEV;
}
disable_irq(nvec->irq);
@@ -879,7 +880,7 @@ static int tegra_nvec_probe(struct platform_device *pdev)
err = nvec_write_sync(nvec, get_firmware_version, 2, );
 
if (!err) {
-   dev_warn(nvec->dev,
+   dev_warn(dev,
 "ec firmware version %02x.%02x.%02x / %02x\n",
 msg->data[4], msg->data[5],
 msg->data[6], msg->data[7]);
@@ -887,10 +888,10 @@ static int tegra_nvec_probe(struct platform_device *pdev)
nvec_msg_free(nvec, msg);
}
 
-   ret = mfd_add_devices(nvec->dev, 0, nvec_devices,
+   ret = mfd_add_devices(dev, 0, nvec_devices,
  ARRAY_SIZE(nvec_devices), NULL, 0, NULL);
if (ret)
-   dev_err(nvec->dev, "error adding subdevices\n");
+   dev_err(dev, "error adding subdevices\n");
 
/* unmute speakers? */
nvec_write_async(nvec, unmute_speakers, 4);
-- 
2.17.0

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


Re: [PATCH 1/2] staging: fsl-dpaa2/rtc: add rtc driver

2018-04-19 Thread Dan Carpenter
On Thu, Apr 19, 2018 at 04:31:36PM +0800, Yangbo Lu wrote:
> +int dprtc_open(struct fsl_mc_io *mc_io,
> +u32 cmd_flags,
> +int dprtc_id,
> +u16 *token)
> +{
> + struct dprtc_cmd_open *cmd_params;
> + struct fsl_mc_command cmd = { 0 };
> + int err;
> +
> + /* prepare command */

These comments are a bit obvious.  Just remove them.

> + cmd.header = mc_encode_cmd_header(DPRTC_CMDID_OPEN,
> +   cmd_flags,
> +   0);
> + cmd_params = (struct dprtc_cmd_open *)cmd.params;
> + cmd_params->dprtc_id = cpu_to_le32(dprtc_id);
> +
> + /* send command to mc*/

remove

> + err = mc_send_command(mc_io, );
> + if (err)
> + return err;
> +
> + /* retrieve response parameters */

remove

> + *token = mc_cmd_hdr_read_token();
> +
> + return err;

return 0;

> +}
> +
> +/**
> + * dprtc_close() - Close the control session of the object
> + * @mc_io:   Pointer to MC portal's I/O object
> + * @cmd_flags:   Command flags; one or more of 'MC_CMD_FLAG_'
> + * @token:   Token of DPRTC object
> + *
> + * After this function is called, no further operations are
> + * allowed on the object without opening a new control session.
> + *
> + * Return:   '0' on Success; Error code otherwise.
> + */
> +int dprtc_close(struct fsl_mc_io *mc_io,
> + u32 cmd_flags,
> + u16 token)
> +{
> + struct fsl_mc_command cmd = { 0 };
> +
> + /* prepare command */
> + cmd.header = mc_encode_cmd_header(DPRTC_CMDID_CLOSE, cmd_flags,
> +   token);
> +
> + /* send command to mc*/
> + return mc_send_command(mc_io, );
> +}
> +
> +/**
> + * dprtc_create() - Create the DPRTC object.
> + * @mc_io:   Pointer to MC portal's I/O object
> + * @dprc_token:  Parent container token; '0' for default container
> + * @cmd_flags:   Command flags; one or more of 'MC_CMD_FLAG_'
> + * @cfg: Configuration structure
> + * @obj_id:  Returned object id
> + *
> + * Create the DPRTC object, allocate required resources and
> + * perform required initialization.
> + *
> + * The function accepts an authentication token of a parent
> + * container that this object should be assigned to. The token
> + * can be '0' so the object will be assigned to the default container.
> + * The newly created object can be opened with the returned
> + * object id and using the container's associated tokens and MC portals.
> + *
> + * Return:   '0' on Success; Error code otherwise.
> + */
> +int dprtc_create(struct fsl_mc_io *mc_io,
> +  u16 dprc_token,
> +  u32 cmd_flags,
> +  const struct dprtc_cfg *cfg,
> +  u32 *obj_id)
> +{
> + struct fsl_mc_command cmd = { 0 };
> + int err;
> +
> + (void)(cfg); /* unused */

You can just remove these.  Static checkers which complain about this
are stupid and a bit lazy.

This driver seems nice and so far as I can see it doesn't need to be in
staging once we get the other parts merged.

regards,
dan carpenter

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


Re: [PATCH v2] staging: pi433: cleanup tx_fifo locking

2018-04-19 Thread Marcus Wolf
Reviewed-by: Marcus Wolf 

Am 19.04.2018 um 12:25 schrieb Valentin Vidic:
> pi433_write requires locking due to multiple writers.  After acquiring
> the lock check if enough free space is available in the kfifo to write
> the whole message. This check should prevent partial writes to tx_fifo
> so kfifo_reset is not needed anymore.
> 
> pi433_tx_thread is the only reader so it does not require locking
> after kfifo_reset is removed.
> 
> Signed-off-by: Valentin Vidic 
> ---
> v2: print a warning if partial fifo write happens
> 
>  drivers/staging/pi433/pi433_if.c | 23 ++-
>  1 file changed, 14 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/staging/pi433/pi433_if.c 
> b/drivers/staging/pi433/pi433_if.c
> index d1e0ddbc79ce..2a05eff88469 100644
> --- a/drivers/staging/pi433/pi433_if.c
> +++ b/drivers/staging/pi433/pi433_if.c
> @@ -87,7 +87,7 @@ struct pi433_device {
>  
>   /* tx related values */
>   STRUCT_KFIFO_REC_1(MSG_FIFO_SIZE) tx_fifo;
> - struct mutextx_fifo_lock; // TODO: check, whether necessary 
> or obsolete
> + struct mutextx_fifo_lock; /* serialize userspace writers */
>   struct task_struct  *tx_task_struct;
>   wait_queue_head_t   tx_wait_queue;
>   u8  free_in_fifo;
> @@ -589,19 +589,15 @@ pi433_tx_thread(void *data)
>* - size of message
>* - message
>*/
> - mutex_lock(>tx_fifo_lock);
> -
>   retval = kfifo_out(>tx_fifo, _cfg, sizeof(tx_cfg));
>   if (retval != sizeof(tx_cfg)) {
>   dev_dbg(device->dev, "reading tx_cfg from fifo failed: 
> got %d byte(s), expected %d", retval, (unsigned int)sizeof(tx_cfg));
> - mutex_unlock(>tx_fifo_lock);
>   continue;
>   }
>  
>   retval = kfifo_out(>tx_fifo, , sizeof(size_t));
>   if (retval != sizeof(size_t)) {
>   dev_dbg(device->dev, "reading msg size from fifo 
> failed: got %d, expected %d", retval, (unsigned int)sizeof(size_t));
> - mutex_unlock(>tx_fifo_lock);
>   continue;
>   }
>  
> @@ -634,7 +630,6 @@ pi433_tx_thread(void *data)
>  sizeof(device->buffer) - position);
>   dev_dbg(device->dev,
>   "read %d message byte(s) from fifo queue.", retval);
> - mutex_unlock(>tx_fifo_lock);
>  
>   /* if rx is active, we need to interrupt the waiting for
>* incoming telegrams, to be able to send something.
> @@ -818,7 +813,7 @@ pi433_write(struct file *filp, const char __user *buf,
>   struct pi433_instance   *instance;
>   struct pi433_device *device;
>   int retval;
> - unsigned intcopied;
> + unsigned intrequired, available, copied;
>  
>   instance = filp->private_data;
>   device = instance->device;
> @@ -833,6 +828,16 @@ pi433_write(struct file *filp, const char __user *buf,
>* - message
>*/
>   mutex_lock(>tx_fifo_lock);
> +
> + required = sizeof(instance->tx_cfg) + sizeof(size_t) + count;
> + available = kfifo_avail(>tx_fifo);
> + if (required > available) {
> + dev_dbg(device->dev, "write to fifo failed: %d bytes required 
> but %d available",
> + required, available);
> + mutex_unlock(>tx_fifo_lock);
> + return -EAGAIN;
> + }
> +
>   retval = kfifo_in(>tx_fifo, >tx_cfg,
> sizeof(instance->tx_cfg));
>   if (retval != sizeof(instance->tx_cfg))
> @@ -855,8 +860,8 @@ pi433_write(struct file *filp, const char __user *buf,
>   return copied;
>  
>  abort:
> - dev_dbg(device->dev, "write to fifo failed: 0x%x", retval);
> - kfifo_reset(>tx_fifo); // TODO: maybe find a solution, not to 
> discard already stored, valid entries
> + dev_warn(device->dev,
> +  "write to fifo failed, non recoverable: 0x%x", retval);
>   mutex_unlock(>tx_fifo_lock);
>   return -EAGAIN;
>  }
> 


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


[PATCH 09/15] media: dt-bindings: add bindings for i.MX7 media driver

2018-04-19 Thread Rui Miguel Silva
Add bindings documentation for i.MX7 media drivers.

Signed-off-by: Rui Miguel Silva 
---
 .../devicetree/bindings/media/imx7.txt| 158 ++
 1 file changed, 158 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/imx7.txt

diff --git a/Documentation/devicetree/bindings/media/imx7.txt 
b/Documentation/devicetree/bindings/media/imx7.txt
new file mode 100644
index ..7e058ea25102
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/imx7.txt
@@ -0,0 +1,158 @@
+Freescale i.MX7 Media Video Device
+==
+
+Video Media Controller node
+---
+
+This is the media controller node for video capture support. It is a
+virtual device that lists the camera serial interface nodes that the
+media device will control.
+
+Required properties:
+- compatible : "fsl,imx7-capture-subsystem";
+- ports  : Should contain a list of phandles pointing to camera
+   sensor interface port of CSI
+
+example:
+
+capture-subsystem {
+   compatible = "fsl,imx7-capture-subsystem";
+   ports = <>;
+};
+
+
+mipi_csi2 node
+--
+
+This is the device node for the MIPI CSI-2 receiver core in i.MX7 SoC. It is
+compatible with previous version of Samsung D-phy.
+
+Required properties:
+
+- compatible: "fsl,imx7-mipi-csi2";
+- reg   : base address and length of the register set for the device;
+- interrupts: should contain MIPI CSIS interrupt;
+- clocks: list of clock specifiers, see
+Documentation/devicetree/bindings/clock/clock-bindings.txt for details;
+- clock-names   : must contain "mipi" and "phy" entries, matching entries in 
the
+  clock property;
+- power-domains : a phandle to the power domain, see
+  Documentation/devicetree/bindings/power/power_domain.txt for details.
+- reset-names   : should include following entry "mrst";
+- resets: a list of phandle, should contain reset entry of
+  reset-names;
+- phy-supply: from the generic phy bindings, a phandle to a regulator that
+ provides power to VBUS;
+- bus-width : maximum number of data lanes supported (SoC specific);
+
+Optional properties:
+
+- clock-frequency : The IP's main (system bus) clock frequency in Hz, default
+   value when this property is not specified is 166 MHz;
+
+port node
+-
+
+- reg: (required) can take the values 0 or 1, where 0 is the
+ related sink port and port 1 should be the source one;
+
+endpoint node
+-
+
+- data-lanes: (required) an array specifying active physical MIPI-CSI2
+   data input lanes and their mapping to logical lanes; the
+   array's content is unused, only its length is meaningful;
+
+- csis-hs-settle : (optional) differential receiver (HS-RX) settle time;
+- csis-clk-settle : (optional) D-PHY control register;
+- csis-wclk : CSI-2 wrapper clock selection. If this property is present
+ external clock from CMU will be used, or the bus clock if
+ if it's not specified.
+
+example:
+
+   mipi_csi: mipi-csi@3075 {
+clock-frequency = <16600>;
+status = "okay";
+#address-cells = <1>;
+#size-cells = <0>;
+
+   compatible = "fsl,imx7-mipi-csi2";
+   reg = <0x3075 0x1>;
+   interrupts = ;
+   clocks = < IMX7D_MIPI_CSI_ROOT_CLK>,
+   < IMX7D_MIPI_DPHY_ROOT_CLK>;
+   clock-names = "mipi", "phy";
+   power-domains = <_mipi_phy>;
+   phy-supply = <_1p0d>;
+   resets = < IMX7_RESET_MIPI_PHY_MRST>;
+   reset-names = "mrst";
+   bus-width = <4>;
+   status = "disabled";
+
+port@0 {
+reg = <0>;
+
+mipi_from_sensor: endpoint {
+remote-endpoint = <_to_mipi>;
+data-lanes = <1>;
+csis-hs-settle = <3>;
+csis-clk-settle = <0>;
+csis-wclk;
+};
+};
+
+port@1 {
+reg = <1>;
+
+mipi_vc0_to_csi_mux: endpoint {
+remote-endpoint = <_mux_from_mipi_vc0>;
+};
+};
+   };
+
+
+csi node
+
+
+This is device node for the CMOS Sensor Interface (CSI) which enables the chip
+to connect directly to external CMOS image sensors.
+
+Required properties:
+
+- compatible: "fsl,imx7-csi";
+- reg   : base address and length of the register set for the device;
+- interrupts: should contain CSI interrupt;
+- clocks: list 

[PATCH 14/15] media: imx7.rst: add documentation for i.MX7 media driver

2018-04-19 Thread Rui Miguel Silva
Add rst document to describe the i.MX7 media driver and also a working example
from the Warp7 board usage with a OV2680 sensor.

Signed-off-by: Rui Miguel Silva 
---
 Documentation/media/v4l-drivers/imx7.rst  | 157 ++
 Documentation/media/v4l-drivers/index.rst |   1 +
 2 files changed, 158 insertions(+)
 create mode 100644 Documentation/media/v4l-drivers/imx7.rst

diff --git a/Documentation/media/v4l-drivers/imx7.rst 
b/Documentation/media/v4l-drivers/imx7.rst
new file mode 100644
index ..64b97b442277
--- /dev/null
+++ b/Documentation/media/v4l-drivers/imx7.rst
@@ -0,0 +1,157 @@
+i.MX7 Video Capture Driver
+==
+
+Introduction
+
+
+The i.MX7 contrary to the i.MX5/6 family does not contain an Image Processing
+Unit (IPU), because of that the capabilities to perform operations or
+manipulation of the capture frames is less feature rich.
+
+For image capture the i.MX7 have three units:
+- CMOS Sensor Interface (CSI)
+- Video Multiplexer
+- MIPI CSI-2 Receiver
+
+::
+   |\
+   MIPI Camera Input ---> MIPI CSI-2 --- > | \
+   |  \
+   | M |
+   | U | -->  CSI ---> Capture
+   | X |
+   |  /
+   Parallel Camera Input > | /
+   |/
+
+For additional information, please refer to the latest versions of the i.MX7
+reference manual [#f1]_.
+
+Entities
+
+
+imx7-mipi-csi2
+--
+
+This is the MIPI CSI-2 recevier entity. It has one sink pad to receive the 
pixel
+data from MIPI CSI-2 camera sensor. It has one source pad, corresponding to the
+virtual channel 0. This module is compliant to previous version of Samsung
+D-phy, and support two D-PHY Rx Data lanes.
+
+csi_mux
+---
+
+This is the video multiplexer. It has two sink pads to select from either 
camera
+sensors with a parallel interface or from MIPI CSI-2 virtual channel 0.  It has
+a single source pad that routes to the CSI.
+
+csi
+---
+
+The CSI enables the chip to connect directly to external CMOS image sensor. CSI
+can interfaces directly with Parallel and MIPI CSI-2 buses. It has 256 x 64 
FIFO
+to store received image pixel data and embedded DMA controllers to transfer 
data
+from the FIFO through AHB bus.
+
+This entity has one sink pad that receive from the csi_mux entity and a single
+source pad that route video frames directly to memory buffers, this pad is
+routed to a capture device node.
+
+Usage Notes
+---
+
+To aid in configuration and for backward compatibility with V4L2 applications
+that access controls only from video device nodes, the capture device 
interfaces
+inherit controls from the active entities in the current pipeline, so controls
+can be accessed either directly from the subdev or from the active capture
+device interface. For example, the sensor controls are available either from 
the
+sensor subdevs or from the active capture device.
+
+Warp7 with OV2680
+-
+
+On this platform an OV2680 MIPI CSI-2 module is connected to the internal MIPI
+CSI-2 receiver. The following example configures a video capture pipeline with
+an output of 800x600, and BGGR 10 bit bayer format:
+
+.. code-block:: none
+   # Setup links
+   media-ctl -l "'ov2680 1-0036':0 -> 'imx7-mipi-csis.0':0[1]"
+   media-ctl -l "'imx7-mipi-csis.0':1 -> 'csi_mux':1[1]"
+   media-ctl -l "'csi_mux':2 -> 'csi':0[1]"
+   media-ctl -l "'csi':1 -> 'csi capture':0[1]"
+
+   # Configure pads for pipeline
+   media-ctl -V "'ov2680 1-0036':0 [fmt:SBGGR10_1X10/800x600 field:none]"
+   media-ctl -V "'csi_mux':1 [fmt:SBGGR10_1X10/800x600 field:none]"
+   media-ctl -V "'csi_mux':2 [fmt:SBGGR10_1X10/800x600 field:none]"
+   media-ctl -V "'imx7-mipi-csis.0':0 [fmt:SBGGR10_1X10/800x600 field:none]"
+   media-ctl -V "'csi':0 [fmt:SBGGR10_1X10/800x600 field:none]"
+
+After this streaming can start, the v4l2-ctl tool can be used to select any of
+the resolutions supported by the sensor.
+
+.. code-block:: none
+root@imx7s-warp:~# media-ctl -p
+Media controller API version 4.17.0
+
+Media device information
+
+driver  imx-media
+model   imx-media
+serial
+bus info
+hw revision 0x0
+driver version  4.17.0
+
+Device topology
+- entity 1: csi (2 pads, 2 links)
+   type V4L2 subdev subtype Unknown flags 0
+   device node name /dev/v4l-subdev0
+   pad0: Sink
+   [fmt:SBGGR10_1X10/800x600 field:none]
+   <- "csi_mux":2 [ENABLED]
+   pad1: Source
+   [fmt:SBGGR10_1X10/800x600 field:none]
+   -> "csi capture":0 [ENABLED]
+
+- entity 4: csi capture (1 pad, 1 link)
+ 

[PATCH 02/15] media: staging/imx7: add imx7 CSI subdev driver

2018-04-19 Thread Rui Miguel Silva
This add the media entity subdevice and control driver for the i.MX7 CMOS Sensor
Interface.

Signed-off-by: Rui Miguel Silva 
---
 drivers/staging/media/imx/Kconfig  |9 +-
 drivers/staging/media/imx/Makefile |2 +
 drivers/staging/media/imx/imx7-media-csi.c | 1327 
 3 files changed, 1337 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/media/imx/imx7-media-csi.c

diff --git a/drivers/staging/media/imx/Kconfig 
b/drivers/staging/media/imx/Kconfig
index bfc17de56b17..40a11f988fc6 100644
--- a/drivers/staging/media/imx/Kconfig
+++ b/drivers/staging/media/imx/Kconfig
@@ -11,7 +11,7 @@ config VIDEO_IMX_MEDIA
  driver for the i.MX5/6 SOC.
 
 if VIDEO_IMX_MEDIA
-menu "i.MX5/6 Media Sub devices"
+menu "i.MX5/6/7 Media Sub devices"
 
 config VIDEO_IMX_CSI
tristate "i.MX5/6 Camera Sensor Interface driver"
@@ -20,5 +20,12 @@ config VIDEO_IMX_CSI
---help---
  A video4linux camera sensor interface driver for i.MX5/6.
 
+config VIDEO_IMX7_CSI
+   tristate "i.MX7 Camera Sensor Interface driver"
+   depends on VIDEO_IMX_MEDIA && VIDEO_DEV && I2C
+   default y
+   ---help---
+ A video4linux camera sensor interface driver for i.MX7.
+
 endmenu
 endif
diff --git a/drivers/staging/media/imx/Makefile 
b/drivers/staging/media/imx/Makefile
index 698a4210316e..771846717146 100644
--- a/drivers/staging/media/imx/Makefile
+++ b/drivers/staging/media/imx/Makefile
@@ -11,3 +11,5 @@ obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-ic.o
 
 obj-$(CONFIG_VIDEO_IMX_CSI) += imx-media-csi.o
 obj-$(CONFIG_VIDEO_IMX_CSI) += imx6-mipi-csi2.o
+
+obj-$(CONFIG_VIDEO_IMX7_CSI) += imx7-media-csi.o
diff --git a/drivers/staging/media/imx/imx7-media-csi.c 
b/drivers/staging/media/imx/imx7-media-csi.c
new file mode 100644
index ..167043869419
--- /dev/null
+++ b/drivers/staging/media/imx/imx7-media-csi.c
@@ -0,0 +1,1327 @@
+// SPDX-License-Identifier: GPL
+/*
+ * V4L2 Capture CSI Subdev for Freescale i.MX7 SOC
+ *
+ * Copyright (c) 2018 Linaro Ltd
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include "imx-media.h"
+
+#define IMX7_CSI_PAD_SINK  0
+#define IMX7_CSI_PAD_SRC   1
+#define IMX7_CSI_PADS_NUM  2
+
+/* reset values */
+#define CSICR1_RESET_VAL   0x4800
+#define CSICR2_RESET_VAL   0x0
+#define CSICR3_RESET_VAL   0x0
+
+/* csi control reg 1 */
+#define BIT_SWAP16_EN  BIT(31)
+#define BIT_EXT_VSYNC  BIT(30)
+#define BIT_EOF_INT_EN BIT(29)
+#define BIT_PRP_IF_EN  BIT(28)
+#define BIT_CCIR_MODE  BIT(27)
+#define BIT_COF_INT_EN BIT(26)
+#define BIT_SF_OR_INTENBIT(25)
+#define BIT_RF_OR_INTENBIT(24)
+#define BIT_SFF_DMA_DONE_INTEN  BIT(22)
+#define BIT_STATFF_INTEN   BIT(21)
+#define BIT_FB2_DMA_DONE_INTEN  BIT(20)
+#define BIT_FB1_DMA_DONE_INTEN  BIT(19)
+#define BIT_RXFF_INTEN BIT(18)
+#define BIT_SOF_POLBIT(17)
+#define BIT_SOF_INTEN  BIT(16)
+#define BIT_MCLKDIV(0xF << 12)
+#define BIT_HSYNC_POL  BIT(11)
+#define BIT_CCIR_ENBIT(10)
+#define BIT_MCLKEN BIT(9)
+#define BIT_FCCBIT(8)
+#define BIT_PACK_DIR   BIT(7)
+#define BIT_CLR_STATFIFO   BIT(6)
+#define BIT_CLR_RXFIFO BIT(5)
+#define BIT_GCLK_MODE  BIT(4)
+#define BIT_INV_DATA   BIT(3)
+#define BIT_INV_PCLK   BIT(2)
+#define BIT_REDGE  BIT(1)
+#define BIT_PIXEL_BIT  BIT(0)
+
+#define SHIFT_MCLKDIV  12
+
+/* control reg 3 */
+#define BIT_FRMCNT (0x << 16)
+#define BIT_FRMCNT_RST BIT(15)
+#define BIT_DMA_REFLASH_RFFBIT(14)
+#define BIT_DMA_REFLASH_SFFBIT(13)
+#define BIT_DMA_REQ_EN_RFF BIT(12)
+#define BIT_DMA_REQ_EN_SFF BIT(11)
+#define BIT_STATFF_LEVEL   (0x7 << 8)
+#define BIT_HRESP_ERR_EN   BIT(7)
+#define BIT_RXFF_LEVEL (0x7 << 4)
+#define BIT_TWO_8BIT_SENSORBIT(3)
+#define BIT_ZERO_PACK_EN   BIT(2)
+#define BIT_ECC_INT_EN BIT(1)
+#define BIT_ECC_AUTO_ENBIT(0)
+
+#define SHIFT_FRMCNT   16
+#define SHIFT_RXFIFO_LEVEL 4
+
+/* csi status reg */
+#define BIT_ADDR_CH_ERR_INTBIT(28)
+#define BIT_FIELD0_INT BIT(27)
+#define BIT_FIELD1_INT BIT(26)
+#define BIT_SFF_OR_INT BIT(25)
+#define BIT_RFF_OR_INT BIT(24)
+#define BIT_DMA_TSF_DONE_SFF   BIT(22)
+#define BIT_STATFF_INT BIT(21)
+#define BIT_DMA_TSF_DONE_FB2   BIT(20)
+#define BIT_DMA_TSF_DONE_FB1   BIT(19)
+#define BIT_RXFF_INT   BIT(18)
+#define BIT_EOF_INTBIT(17)
+#define BIT_SOF_INTBIT(16)
+#define BIT_F2_INT BIT(15)
+#define BIT_F1_INT BIT(14)
+#define 

[PATCH v2] staging: pi433: cleanup tx_fifo locking

2018-04-19 Thread Valentin Vidic
pi433_write requires locking due to multiple writers.  After acquiring
the lock check if enough free space is available in the kfifo to write
the whole message. This check should prevent partial writes to tx_fifo
so kfifo_reset is not needed anymore.

pi433_tx_thread is the only reader so it does not require locking
after kfifo_reset is removed.

Signed-off-by: Valentin Vidic 
---
v2: print a warning if partial fifo write happens

 drivers/staging/pi433/pi433_if.c | 23 ++-
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index d1e0ddbc79ce..2a05eff88469 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -87,7 +87,7 @@ struct pi433_device {
 
/* tx related values */
STRUCT_KFIFO_REC_1(MSG_FIFO_SIZE) tx_fifo;
-   struct mutextx_fifo_lock; // TODO: check, whether necessary 
or obsolete
+   struct mutextx_fifo_lock; /* serialize userspace writers */
struct task_struct  *tx_task_struct;
wait_queue_head_t   tx_wait_queue;
u8  free_in_fifo;
@@ -589,19 +589,15 @@ pi433_tx_thread(void *data)
 * - size of message
 * - message
 */
-   mutex_lock(>tx_fifo_lock);
-
retval = kfifo_out(>tx_fifo, _cfg, sizeof(tx_cfg));
if (retval != sizeof(tx_cfg)) {
dev_dbg(device->dev, "reading tx_cfg from fifo failed: 
got %d byte(s), expected %d", retval, (unsigned int)sizeof(tx_cfg));
-   mutex_unlock(>tx_fifo_lock);
continue;
}
 
retval = kfifo_out(>tx_fifo, , sizeof(size_t));
if (retval != sizeof(size_t)) {
dev_dbg(device->dev, "reading msg size from fifo 
failed: got %d, expected %d", retval, (unsigned int)sizeof(size_t));
-   mutex_unlock(>tx_fifo_lock);
continue;
}
 
@@ -634,7 +630,6 @@ pi433_tx_thread(void *data)
   sizeof(device->buffer) - position);
dev_dbg(device->dev,
"read %d message byte(s) from fifo queue.", retval);
-   mutex_unlock(>tx_fifo_lock);
 
/* if rx is active, we need to interrupt the waiting for
 * incoming telegrams, to be able to send something.
@@ -818,7 +813,7 @@ pi433_write(struct file *filp, const char __user *buf,
struct pi433_instance   *instance;
struct pi433_device *device;
int retval;
-   unsigned intcopied;
+   unsigned intrequired, available, copied;
 
instance = filp->private_data;
device = instance->device;
@@ -833,6 +828,16 @@ pi433_write(struct file *filp, const char __user *buf,
 * - message
 */
mutex_lock(>tx_fifo_lock);
+
+   required = sizeof(instance->tx_cfg) + sizeof(size_t) + count;
+   available = kfifo_avail(>tx_fifo);
+   if (required > available) {
+   dev_dbg(device->dev, "write to fifo failed: %d bytes required 
but %d available",
+   required, available);
+   mutex_unlock(>tx_fifo_lock);
+   return -EAGAIN;
+   }
+
retval = kfifo_in(>tx_fifo, >tx_cfg,
  sizeof(instance->tx_cfg));
if (retval != sizeof(instance->tx_cfg))
@@ -855,8 +860,8 @@ pi433_write(struct file *filp, const char __user *buf,
return copied;
 
 abort:
-   dev_dbg(device->dev, "write to fifo failed: 0x%x", retval);
-   kfifo_reset(>tx_fifo); // TODO: maybe find a solution, not to 
discard already stored, valid entries
+   dev_warn(device->dev,
+"write to fifo failed, non recoverable: 0x%x", retval);
mutex_unlock(>tx_fifo_lock);
return -EAGAIN;
 }
-- 
2.17.0

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


[PATCH 01/15] media: staging/imx: add support to media dev for no IPU systems

2018-04-19 Thread Rui Miguel Silva
Some i.MX SoC do not have IPU, like the i.MX7, add to the the media device
infrastructure support to be used in this type of systems that do not have
internal subdevices besides the CSI.

Signed-off-by: Rui Miguel Silva 
---
 drivers/staging/media/imx/imx-media-dev.c| 16 +++-
 .../staging/media/imx/imx-media-internal-sd.c|  3 +++
 drivers/staging/media/imx/imx-media.h|  3 +++
 3 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-dev.c 
b/drivers/staging/media/imx/imx-media-dev.c
index f67ec8e27093..a8afe0ec4134 100644
--- a/drivers/staging/media/imx/imx-media-dev.c
+++ b/drivers/staging/media/imx/imx-media-dev.c
@@ -92,6 +92,9 @@ static int imx_media_get_ipu(struct imx_media_dev *imxmd,
struct ipu_soc *ipu;
int ipu_id;
 
+   if (imxmd->no_ipu_present)
+   return 0;
+
ipu = dev_get_drvdata(csi_sd->dev->parent);
if (!ipu) {
v4l2_err(>v4l2_dev,
@@ -481,16 +484,19 @@ static int imx_media_probe(struct platform_device *pdev)
goto notifier_cleanup;
}
 
-   ret = imx_media_add_internal_subdevs(imxmd);
-   if (ret) {
-   v4l2_err(>v4l2_dev,
-"add_internal_subdevs failed with %d\n", ret);
-   goto notifier_cleanup;
+   if (!imxmd->no_ipu_present) {
+   ret = imx_media_add_internal_subdevs(imxmd);
+   if (ret) {
+   v4l2_err(>v4l2_dev,
+"add_internal_subdevs failed with %d\n", ret);
+   goto notifier_cleanup;
+   }
}
 
/* no subdevs? just bail */
if (imxmd->notifier.num_subdevs == 0) {
ret = -ENODEV;
+   v4l2_err(>v4l2_dev, "no subdevs\n");
goto notifier_cleanup;
}
 
diff --git a/drivers/staging/media/imx/imx-media-internal-sd.c 
b/drivers/staging/media/imx/imx-media-internal-sd.c
index 0fdc45dbfb76..4a246813b4e1 100644
--- a/drivers/staging/media/imx/imx-media-internal-sd.c
+++ b/drivers/staging/media/imx/imx-media-internal-sd.c
@@ -238,6 +238,9 @@ int imx_media_create_internal_links(struct imx_media_dev 
*imxmd,
struct media_pad *pad;
int i, j, ret;
 
+   if (imxmd->no_ipu_present)
+   return 0;
+
intsd = find_intsd_by_grp_id(sd->grp_id);
if (!intsd)
return -ENODEV;
diff --git a/drivers/staging/media/imx/imx-media.h 
b/drivers/staging/media/imx/imx-media.h
index 44532cd5b812..0c63132861a0 100644
--- a/drivers/staging/media/imx/imx-media.h
+++ b/drivers/staging/media/imx/imx-media.h
@@ -147,6 +147,9 @@ struct imx_media_dev {
 
/* for async subdev registration */
struct v4l2_async_notifier notifier;
+
+   /* indicator to if the system lack IPU */
+   bool no_ipu_present;
 };
 
 enum codespace_sel {
-- 
2.17.0

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


[PATCH 05/15] media: staging/imx7: add MIPI CSI-2 receiver subdev for i.MX7

2018-04-19 Thread Rui Miguel Silva
Adds MIPI CSI-2 subdev for i.MX7 to connect with sensors with a MIPI CSI-2
interface.

Signed-off-by: Rui Miguel Silva 
---
 drivers/staging/media/imx/Makefile |1 +
 drivers/staging/media/imx/imx7-mipi-csis.c | 1154 
 2 files changed, 1155 insertions(+)
 create mode 100644 drivers/staging/media/imx/imx7-mipi-csis.c

diff --git a/drivers/staging/media/imx/Makefile 
b/drivers/staging/media/imx/Makefile
index 771846717146..c11d51259af1 100644
--- a/drivers/staging/media/imx/Makefile
+++ b/drivers/staging/media/imx/Makefile
@@ -13,3 +13,4 @@ obj-$(CONFIG_VIDEO_IMX_CSI) += imx-media-csi.o
 obj-$(CONFIG_VIDEO_IMX_CSI) += imx6-mipi-csi2.o
 
 obj-$(CONFIG_VIDEO_IMX7_CSI) += imx7-media-csi.o
+obj-$(CONFIG_VIDEO_IMX7_CSI) += imx7-mipi-csis.o
diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c 
b/drivers/staging/media/imx/imx7-mipi-csis.c
new file mode 100644
index ..45c5f442ac8e
--- /dev/null
+++ b/drivers/staging/media/imx/imx7-mipi-csis.c
@@ -0,0 +1,1154 @@
+// SPDX-License-Identifier: GPL
+/*
+ * Freescale i.MX7 SoC series MIPI-CSI V3.3 receiver driver
+ *
+ * Copyright (C) 2018 Linaro Ltd
+ * Copyright (C) 2015-2016 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "imx-media.h"
+
+static int debug;
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "Debug level (0-2)");
+
+#define CSIS_DRIVER_NAME   "imx7-mipi-csis"
+#define CSIS_SUBDEV_NAME   CSIS_DRIVER_NAME
+
+#define CSIS_PAD_SINK  0
+#define CSIS_PAD_SOURCE1
+#define CSIS_PADS_NUM  2
+
+#define MIPI_CSIS_DEF_PIX_WIDTH640
+#define MIPI_CSIS_DEF_PIX_HEIGHT   480
+
+/* Register map definition */
+
+/* CSIS common control */
+#define MIPI_CSIS_CMN_CTRL 0x04
+#define MIPI_CSIS_CMN_CTRL_UPDATE_SHADOW   BIT(16)
+#define MIPI_CSIS_CMN_CTRL_INTER_MODE  BIT(10)
+#define MIPI_CSIS_CMN_CTRL_UPDATE_SHADOW_CTRL  BIT(2)
+#define MIPI_CSIS_CMN_CTRL_RESET   BIT(1)
+#define MIPI_CSIS_CMN_CTRL_ENABLE  BIT(0)
+
+#define MIPI_CSIS_CMN_CTRL_LANE_NR_OFFSET  8
+#define MIPI_CSIS_CMN_CTRL_LANE_NR_MASK(3 << 8)
+
+/* CSIS clock control */
+#define MIPI_CSIS_CLK_CTRL 0x08
+#define MIPI_CSIS_CLK_CTRL_CLKGATE_TRAIL_CH3(x)(x << 28)
+#define MIPI_CSIS_CLK_CTRL_CLKGATE_TRAIL_CH2(x)(x << 24)
+#define MIPI_CSIS_CLK_CTRL_CLKGATE_TRAIL_CH1(x)(x << 20)
+#define MIPI_CSIS_CLK_CTRL_CLKGATE_TRAIL_CH0(x)(x << 16)
+#define MIPI_CSIS_CLK_CTRL_CLKGATE_EN_MSK  (0xf << 4)
+#define MIPI_CSIS_CLK_CTRL_WCLK_SRCBIT(0)
+
+/* CSIS Interrupt mask */
+#define MIPI_CSIS_INTMSK   0x10
+#define MIPI_CSIS_INTMSK_EVEN_BEFORE   BIT(31)
+#define MIPI_CSIS_INTMSK_EVEN_AFTERBIT(30)
+#define MIPI_CSIS_INTMSK_ODD_BEFOREBIT(29)
+#define MIPI_CSIS_INTMSK_ODD_AFTER BIT(28)
+#define MIPI_CSIS_INTMSK_FRAME_START   BIT(24)
+#define MIPI_CSIS_INTMSK_FRAME_END BIT(20)
+#define MIPI_CSIS_INTMSK_ERR_SOT_HSBIT(16)
+#define MIPI_CSIS_INTMSK_ERR_LOST_FS   BIT(12)
+#define MIPI_CSIS_INTMSK_ERR_LOST_FE   BIT(8)
+#define MIPI_CSIS_INTMSK_ERR_OVER  BIT(4)
+#define MIPI_CSIS_INTMSK_ERR_WRONG_CFG BIT(3)
+#define MIPI_CSIS_INTMSK_ERR_ECC   BIT(2)
+#define MIPI_CSIS_INTMSK_ERR_CRC   BIT(1)
+#define MIPI_CSIS_INTMSK_ERR_UNKNOWN   BIT(0)
+
+/* CSIS Interrupt source */
+#define MIPI_CSIS_INTSRC   0x14
+#define MIPI_CSIS_INTSRC_EVEN_BEFORE   BIT(31)
+#define MIPI_CSIS_INTSRC_EVEN_AFTERBIT(30)
+#define MIPI_CSIS_INTSRC_EVEN  BIT(30)
+#define MIPI_CSIS_INTSRC_ODD_BEFOREBIT(29)
+#define MIPI_CSIS_INTSRC_ODD_AFTER BIT(28)
+#define MIPI_CSIS_INTSRC_ODD   (0x3 << 28)
+#define MIPI_CSIS_INTSRC_NON_IMAGE_DATA(0xf << 28)
+#define MIPI_CSIS_INTSRC_FRAME_START   BIT(24)
+#define MIPI_CSIS_INTSRC_FRAME_END BIT(20)
+#define MIPI_CSIS_INTSRC_ERR_SOT_HSBIT(16)
+#define MIPI_CSIS_INTSRC_ERR_LOST_FS   BIT(12)
+#define MIPI_CSIS_INTSRC_ERR_LOST_FE   BIT(8)
+#define MIPI_CSIS_INTSRC_ERR_OVER  BIT(4)
+#define MIPI_CSIS_INTSRC_ERR_WRONG_CFG BIT(3)
+#define MIPI_CSIS_INTSRC_ERR_ECC   BIT(2)
+#define MIPI_CSIS_INTSRC_ERR_CRC   BIT(1)
+#define MIPI_CSIS_INTSRC_ERR_UNKNOWN   BIT(0)
+#define MIPI_CSIS_INTSRC_ERRORS0xf
+
+/* D-PHY status control */
+#define MIPI_CSIS_DPHYSTATUS   0x20
+#define MIPI_CSIS_DPHYSTATUS_ULPS_DAT  BIT(8)
+#define MIPI_CSIS_DPHYSTATUS_STOPSTATE_DAT BIT(4)
+#define MIPI_CSIS_DPHYSTATUS_ULPS_CLK  BIT(1)
+#define MIPI_CSIS_DPHYSTATUS_STOPSTATE_CLK BIT(0)
+
+/* D-PHY common control */
+#define MIPI_CSIS_DPHYCTRL

[PATCH 11/15] ARM: dts: imx7s: add multiplexer controls

2018-04-19 Thread Rui Miguel Silva
The IOMUXC General Purpose Register has bitfield to control video bus
multiplexer to control the CSI input between the MIPI-CSI2 and parallel
interface. Add that register and mask.

Signed-off-by: Rui Miguel Silva 
---
 arch/arm/boot/dts/imx7s.dtsi | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/imx7s.dtsi b/arch/arm/boot/dts/imx7s.dtsi
index d913c3f9c284..3027d6a62021 100644
--- a/arch/arm/boot/dts/imx7s.dtsi
+++ b/arch/arm/boot/dts/imx7s.dtsi
@@ -534,8 +534,15 @@
 
gpr: iomuxc-gpr@3034 {
compatible = "fsl,imx7d-iomuxc-gpr",
-   "fsl,imx6q-iomuxc-gpr", "syscon";
+   "fsl,imx6q-iomuxc-gpr", "syscon", 
"simple-mfd";
reg = <0x3034 0x1>;
+
+   mux: mux-controller {
+   compatible = "mmio-mux";
+   #mux-control-cells = <1>;
+
+   mux-reg-masks = <0x14 0x0010>;
+   };
};
 
ocotp: ocotp-ctrl@3035 {
-- 
2.17.0

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


[PATCH 12/15] ARM: dts: imx7: Add video mux, csi and mipi_csi and connections

2018-04-19 Thread Rui Miguel Silva
This patch adds the device tree nodes for csi, video multiplexer and mipi-csi
besides the graph connecting the necessary endpoints to make the media capture
entities to work in imx7 Warp board.

Also add the pin control related with the mipi_csi in that board.

Signed-off-by: Rui Miguel Silva 
---
 arch/arm/boot/dts/imx7s-warp.dts | 80 
 arch/arm/boot/dts/imx7s.dtsi | 27 +++
 2 files changed, 107 insertions(+)

diff --git a/arch/arm/boot/dts/imx7s-warp.dts b/arch/arm/boot/dts/imx7s-warp.dts
index 8a30b148534d..91d06adf7c24 100644
--- a/arch/arm/boot/dts/imx7s-warp.dts
+++ b/arch/arm/boot/dts/imx7s-warp.dts
@@ -310,6 +310,79 @@
status = "okay";
 };
 
+ {
+   csi_mux {
+   compatible = "video-mux";
+   mux-controls = < 0>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@0 {
+   reg = <0>;
+
+   csi_mux_from_parallel_sensor: endpoint {
+   };
+   };
+
+   port@1 {
+   reg = <1>;
+
+   csi_mux_from_mipi_vc0: endpoint {
+   remote-endpoint = <_vc0_to_csi_mux>;
+   };
+   };
+
+   port@2 {
+   reg = <2>;
+
+   csi_mux_to_csi: endpoint {
+   remote-endpoint = <_from_csi_mux>;
+   };
+   };
+   };
+};
+
+ {
+   status = "okay";
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@0 {
+   reg = <0>;
+
+   csi_from_csi_mux: endpoint {
+   remote-endpoint = <_mux_to_csi>;
+   };
+   };
+};
+
+_csi {
+   clock-frequency = <16600>;
+   status = "okay";
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@0 {
+   reg = <0>;
+
+   mipi_from_sensor: endpoint {
+   remote-endpoint = <_to_mipi>;
+   data-lanes = <1>;
+   csis-hs-settle = <3>;
+   csis-clk-settle = <0>;
+   csis-wclk;
+   };
+   };
+
+   port@1 {
+   reg = <1>;
+
+   mipi_vc0_to_csi_mux: endpoint {
+   remote-endpoint = <_mux_from_mipi_vc0>;
+   };
+   };
+};
+
  {
pinctrl-names = "default";
pinctrl-0 = <_wdog>;
@@ -357,6 +430,13 @@
>;
};
 
+   pinctrl_mipi_csi: mipi_csi {
+   fsl,pins = <
+   MX7D_PAD_LPSR_GPIO1_IO03__GPIO1_IO3 0x14
+   MX7D_PAD_ENET1_RGMII_TD0__GPIO7_IO6 0x14
+   >;
+   };
+
pinctrl_sai1: sai1grp {
fsl,pins = <
MX7D_PAD_SAI1_RX_DATA__SAI1_RX_DATA00x1f
diff --git a/arch/arm/boot/dts/imx7s.dtsi b/arch/arm/boot/dts/imx7s.dtsi
index 3027d6a62021..6b49b73053f9 100644
--- a/arch/arm/boot/dts/imx7s.dtsi
+++ b/arch/arm/boot/dts/imx7s.dtsi
@@ -46,6 +46,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "imx7d-pinfunc.h"
 
 / {
@@ -753,6 +754,17 @@
status = "disabled";
};
 
+   csi: csi@3071 {
+   compatible = "fsl,imx7-csi";
+   reg = <0x3071 0x1>;
+   interrupts = ;
+   clocks = < IMX7D_CLK_DUMMY>,
+   < IMX7D_CSI_MCLK_ROOT_CLK>,
+   < IMX7D_CLK_DUMMY>;
+   clock-names = "axi", "mclk", "dcic";
+   status = "disabled";
+   };
+
lcdif: lcdif@3073 {
compatible = "fsl,imx7d-lcdif", 
"fsl,imx28-lcdif";
reg = <0x3073 0x1>;
@@ -762,6 +774,21 @@
clock-names = "pix", "axi";
status = "disabled";
};
+
+   mipi_csi: mipi-csi@3075 {
+   compatible = "fsl,imx7-mipi-csi2";
+   reg = <0x3075 0x1>;
+   interrupts = ;
+   clocks = < IMX7D_MIPI_CSI_ROOT_CLK>,
+   < 
IMX7D_MIPI_DPHY_ROOT_CLK>;
+   clock-names = "mipi", "phy";
+   power-domains = <_mipi_phy>;
+   phy-supply = <_1p0d>;
+   resets = < IMX7_RESET_MIPI_PHY_MRST>;
+   reset-names = "mrst";
+   

[PATCH 06/15] media: staging/imx: add imx7 capture subsystem

2018-04-19 Thread Rui Miguel Silva
Add imx7 capture subsystem to imx-media core to allow the use some of the
existing modules for i.MX5/6 with i.MX7 SoC.

Since i.MX7 does not have an IPU set the no_ipu_present flag to differentiate
some runtime behaviors.

Signed-off-by: Rui Miguel Silva 
---
 drivers/staging/media/imx/imx-media-dev.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/staging/media/imx/imx-media-dev.c 
b/drivers/staging/media/imx/imx-media-dev.c
index a8afe0ec4134..967d172f1447 100644
--- a/drivers/staging/media/imx/imx-media-dev.c
+++ b/drivers/staging/media/imx/imx-media-dev.c
@@ -484,6 +484,9 @@ static int imx_media_probe(struct platform_device *pdev)
goto notifier_cleanup;
}
 
+   if (of_device_is_compatible(node, "fsl,imx7-capture-subsystem"))
+   imxmd->no_ipu_present = true;
+
if (!imxmd->no_ipu_present) {
ret = imx_media_add_internal_subdevs(imxmd);
if (ret) {
@@ -541,6 +544,7 @@ static int imx_media_remove(struct platform_device *pdev)
 
 static const struct of_device_id imx_media_dt_ids[] = {
{ .compatible = "fsl,imx-capture-subsystem" },
+   { .compatible = "fsl,imx7-capture-subsystem" },
{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, imx_media_dt_ids);
-- 
2.17.0

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


[PATCH 00/15] media: staging/imx7: add i.MX7 media driver

2018-04-19 Thread Rui Miguel Silva
*** BLURB HERE ***
Hi,
This series introduces the Media driver to work with the i.MX7 SoC. it uses the
already existing imx media core drivers but since the i.MX7, contrary to
i.MX5/6, do not have an IPU and because of that some changes in the imx media
core are made along this series to make it support that case.

This patches adds CSI and MIPI-CSI2 drivers for i.MX7, along with several
configurations changes for this to work as a capture subsystem. Some bugs are
also fixed along the line. And necessary documentation.

For a more detailed view of the capture paths, pads links in the i.MX7 please
take a look at the documentation in PATCH 14.

The system used to test and develop this was the Warp7 board with an OV2680
sensor, which output format is 10-bit bayer. So, only MIPI interface was
tested, a scenario with an parallel input would nice to have.

*Important note*, this code depends on Steve Longerbeam series [0]:
[PATCH v3 00/13] media: imx: Switch to subdev notifiers
which the merging status is not clear to me, but the changes in there make
senses to this series

Bellow goes an example of the output of the pads and links and the output of
v4l2-compliance testing.

The v4l-utils version used is:
v4l2-compliance SHA   : 47d43b130dc6e9e0edc900759fb37649208371e4 from Apr 4th.

The Media Driver fail some tests but this failures are coming from code out of
scope of this series (video-mux, imx-capture), and some from the sensor OV2680
but that I think not related with the sensor driver but with the testing and
core.

The csi and mipi-csi entities pass all compliance tests.

Cheers,
Rui
[0]: https://www.mail-archive.com/linux-media@vger.kernel.org/msg128015.html

 media-ctl -p
Media controller API version 4.17.0

Media device information

driver  imx-media
model   imx-media
serial  
bus info
hw revision 0x0
driver version  4.17.0

Device topology
- entity 1: csi (2 pads, 2 links)
type V4L2 subdev subtype Unknown flags 0
device node name /dev/v4l-subdev0
pad0: Sink
[fmt:SBGGR10_1X10/800x600 field:none]
<- "csi_mux":2 [ENABLED]
pad1: Source
[fmt:SBGGR10_1X10/800x600 field:none]
-> "csi capture":0 [ENABLED]

- entity 4: csi capture (1 pad, 1 link)
type Node subtype V4L flags 0
device node name /dev/video0
pad0: Sink
<- "csi":1 [ENABLED]

- entity 10: csi_mux (3 pads, 2 links)
 type V4L2 subdev subtype Unknown flags 0
 device node name /dev/v4l-subdev1
pad0: Sink
[fmt:unknown/0x0]
pad1: Sink
[fmt:SBGGR10_1X10/800x600 field:none]
<- "imx7-mipi-csis.0":1 [ENABLED]
pad2: Source
[fmt:SBGGR10_1X10/800x600 field:none]
-> "csi":0 [ENABLED]

- entity 14: imx7-mipi-csis.0 (2 pads, 2 links)
 type V4L2 subdev subtype Unknown flags 0
 device node name /dev/v4l-subdev2
pad0: Sink
[fmt:SBGGR10_1X10/800x600 field:none]
<- "ov2680 1-0036":0 [ENABLED]
pad1: Source
[fmt:SBGGR10_1X10/800x600 field:none]
-> "csi_mux":1 [ENABLED]

- entity 17: ov2680 1-0036 (1 pad, 1 link)
 type V4L2 subdev subtype Sensor flags 0
 device node name /dev/v4l-subdev3
pad0: Source
[fmt:SBGGR10_1X10/800x600 field:none]
-> "imx7-mipi-csis.0":0 [ENABLED]

compliance tests:
v4l2-compliance SHA   : 47d43b130dc6e9e0edc900759fb37649208371e4

Compliance test for device /dev/media0:

Media Driver Info:
Driver name  : imx-media
Model: imx-media
Serial   : 
Bus info : 
Media version: 4.17.0
Hardware revision: 0x (0)
Driver version   : 4.17.0

Required ioctls:
test MEDIA_IOC_DEVICE_INFO: OK

Allow for multiple opens:
test second /dev/media0 open: OK
test MEDIA_IOC_DEVICE_INFO: OK
test for unlimited opens: OK

Media Controller ioctls:
Entity: 0x0001 (Name: 'csi', Function: 0x5002)
Entity: 0x0004 (Name: 'csi capture', Function: 0x00010001)
Entity: 0x000a (Name: 'csi_mux', Function: 0x5001)
Entity: 0x000e (Name: 'imx7-mipi-csis.0', Function: 
0x5002)
Entity: 0x0011 (Name: 'ov2680 1-0036', Function: 0x00020001)
Interface: 0x0305 (Type: 0x0200)
Interface: 0x0319 (Type: 0x0203)
Interface: 0x031b (Type: 0x0203)
Interface: 0x031d (Type: 0x0203)
Interface: 0x031f (Type: 0x0203)
Pad: 0x0102
Pad: 0x0103
Pad: 0x0107
Pad: 0x010b

[PATCH 13/15] ARM: dts: imx7s: add capture subsystem

2018-04-19 Thread Rui Miguel Silva
Add media capture subsystem device to i.MX7 definitions.

Signed-off-by: Rui Miguel Silva 
---
 arch/arm/boot/dts/imx7s.dtsi | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/boot/dts/imx7s.dtsi b/arch/arm/boot/dts/imx7s.dtsi
index 6b49b73053f9..333d9fe6b989 100644
--- a/arch/arm/boot/dts/imx7s.dtsi
+++ b/arch/arm/boot/dts/imx7s.dtsi
@@ -1189,4 +1189,9 @@
assigned-clock-parents = < 
IMX7D_PLL_ENET_MAIN_500M_CLK>;
};
};
+
+   capture-subsystem {
+   compatible = "fsl,imx7-capture-subsystem";
+   ports = <>;
+   };
 };
-- 
2.17.0

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


[PATCH 15/15] media: staging/imx: add i.MX7 entries to TODO file

2018-04-19 Thread Rui Miguel Silva
Add some i.MX7 related entries to TODO file.

Signed-off-by: Rui Miguel Silva 
---
 drivers/staging/media/imx/TODO | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/staging/media/imx/TODO b/drivers/staging/media/imx/TODO
index aeeb15494a49..6f29b5ca5324 100644
--- a/drivers/staging/media/imx/TODO
+++ b/drivers/staging/media/imx/TODO
@@ -45,3 +45,12 @@
 
  Which means a port must not contain mixed-use endpoints, they
  must all refer to media links between V4L2 subdevices.
+
+- i.MX7: all of the above, since it uses the imx media core
+
+- i.MX7: use Frame Interval Monitor
+
+- i.MX7: runtime testing with parallel sensor, links setup and streaming
+
+- i.MX7: runtime testing with different formats, for the time only 10-bit bayer
+  is tested
-- 
2.17.0

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


[PATCH 04/15] clk: imx7d: reset parent for mipi csi root

2018-04-19 Thread Rui Miguel Silva
To guarantee that we do not get Overflow in image FIFO the outer bandwidth has
to be faster than inputer bandwidth. For that it must be possible to set a
faster frequency clock. So set new parent to sys_pfd3 clock for the mipi csi
block.

Signed-off-by: Rui Miguel Silva 
---
 drivers/clk/imx/clk-imx7d.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/clk/imx/clk-imx7d.c b/drivers/clk/imx/clk-imx7d.c
index f7f4db2e6fa6..9a1a18ceb132 100644
--- a/drivers/clk/imx/clk-imx7d.c
+++ b/drivers/clk/imx/clk-imx7d.c
@@ -891,6 +891,9 @@ static void __init imx7d_clocks_init(struct device_node 
*ccm_node)
clk_set_parent(clks[IMX7D_PLL_AUDIO_MAIN_BYPASS], 
clks[IMX7D_PLL_AUDIO_MAIN]);
clk_set_parent(clks[IMX7D_PLL_VIDEO_MAIN_BYPASS], 
clks[IMX7D_PLL_VIDEO_MAIN]);
 
+   clk_set_parent(clks[IMX7D_MIPI_CSI_ROOT_SRC],
+  clks[IMX7D_PLL_SYS_PFD3_CLK]);
+
/* use old gpt clk setting, gpt1 root clk must be twice as gpt counter 
freq */
clk_set_parent(clks[IMX7D_GPT1_ROOT_SRC], clks[IMX7D_OSC_24M_CLK]);
 
-- 
2.17.0

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


[PATCH 10/15] ARM: dts: imx7s: add mipi phy power domain

2018-04-19 Thread Rui Miguel Silva
Add power domain index 0 related with mipi-phy to imx7s.

Signed-off-by: Rui Miguel Silva 
---
 arch/arm/boot/dts/imx7s.dtsi | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm/boot/dts/imx7s.dtsi b/arch/arm/boot/dts/imx7s.dtsi
index 142ea709d296..d913c3f9c284 100644
--- a/arch/arm/boot/dts/imx7s.dtsi
+++ b/arch/arm/boot/dts/imx7s.dtsi
@@ -650,6 +650,12 @@
#address-cells = <1>;
#size-cells = <0>;
 
+   pgc_mipi_phy: pgc-power-domain@0 {
+   #power-domain-cells = <0>;
+   reg = <0>;
+   power-supply = <_1p0d>;
+   };
+
pgc_pcie_phy: pgc-power-domain@1 {
#power-domain-cells = <0>;
reg = <1>;
-- 
2.17.0

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


[PATCH 03/15] clk: imx7d: fix mipi dphy div parent

2018-04-19 Thread Rui Miguel Silva
Fix the mipi dphy root divider to mipi_dphy_pre_div, this would remove a orphan
clock and set the correct parent.

before:
cat clk_orphan_summary
 enable  prepare  protect
   clock  countcountcountrate   
accuracy   phase

 mipi_dphy_post_div   110   0  
0 0
mipi_dphy_root_clk110   0  
0 0

cat clk_dump | grep mipi_dphy
mipi_dphy_post_div110   0  
0 0
mipi_dphy_root_clk110   0  
0 0

after:
cat clk_dump | grep mipi_dphy
   mipi_dphy_src 1102400  0 0
   mipi_dphy_cg  1102400  0 0
  mipi_dphy_pre_div  1102400  0 0
 mipi_dphy_post_div  1102400  0 0
mipi_dphy_root_clk   1102400  0 0

Signed-off-by: Rui Miguel Silva 

Signed-off-by: Rui Miguel Silva 
---
 drivers/clk/imx/clk-imx7d.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/imx/clk-imx7d.c b/drivers/clk/imx/clk-imx7d.c
index 975a20d3cc94..f7f4db2e6fa6 100644
--- a/drivers/clk/imx/clk-imx7d.c
+++ b/drivers/clk/imx/clk-imx7d.c
@@ -729,7 +729,7 @@ static void __init imx7d_clocks_init(struct device_node 
*ccm_node)
clks[IMX7D_LCDIF_PIXEL_ROOT_DIV] = 
imx_clk_divider2("lcdif_pixel_post_div", "lcdif_pixel_pre_div", base + 0xa300, 
0, 6);
clks[IMX7D_MIPI_DSI_ROOT_DIV] = imx_clk_divider2("mipi_dsi_post_div", 
"mipi_dsi_pre_div", base + 0xa380, 0, 6);
clks[IMX7D_MIPI_CSI_ROOT_DIV] = imx_clk_divider2("mipi_csi_post_div", 
"mipi_csi_pre_div", base + 0xa400, 0, 6);
-   clks[IMX7D_MIPI_DPHY_ROOT_DIV] = imx_clk_divider2("mipi_dphy_post_div", 
"mipi_csi_dphy_div", base + 0xa480, 0, 6);
+   clks[IMX7D_MIPI_DPHY_ROOT_DIV] = imx_clk_divider2("mipi_dphy_post_div", 
"mipi_dphy_pre_div", base + 0xa480, 0, 6);
clks[IMX7D_SAI1_ROOT_DIV] = imx_clk_divider2("sai1_post_div", 
"sai1_pre_div", base + 0xa500, 0, 6);
clks[IMX7D_SAI2_ROOT_DIV] = imx_clk_divider2("sai2_post_div", 
"sai2_pre_div", base + 0xa580, 0, 6);
clks[IMX7D_SAI3_ROOT_DIV] = imx_clk_divider2("sai3_post_div", 
"sai3_pre_div", base + 0xa600, 0, 6);
-- 
2.17.0

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


[PATCH 08/15] ARM: dts: increase default cma size to 40MB

2018-04-19 Thread Rui Miguel Silva
To support camera in i.MX7 the cma heap is used to allocate frame buffers. The
default size of CMA is 16MB which is not enough for higher resolutions (ex:
1600x1200).

So, increase the default CMA size to 40MB.

Signed-off-by: Rui Miguel Silva 
---
 arch/arm/boot/dts/imx7s.dtsi | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/arch/arm/boot/dts/imx7s.dtsi b/arch/arm/boot/dts/imx7s.dtsi
index 4d42335c0dee..142ea709d296 100644
--- a/arch/arm/boot/dts/imx7s.dtsi
+++ b/arch/arm/boot/dts/imx7s.dtsi
@@ -182,6 +182,20 @@
 ;
};
 
+   reserved-memory {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges;
+
+   /* global autoconfigured region for contiguous allocations */
+   linux,cma {
+   compatible = "shared-dma-pool";
+   reusable;
+   size = <0x280>;
+   linux,cma-default;
+   };
+   };
+
soc {
#address-cells = <1>;
#size-cells = <1>;
-- 
2.17.0

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


[PATCH 07/15] media: staging/imx: add 10 bit bayer support

2018-04-19 Thread Rui Miguel Silva
Some sensors can only output 10 bit bayer formats, like the OV2680. Add support
for that in imx-media.

Signed-off-by: Rui Miguel Silva 
---
 drivers/staging/media/imx/imx-media-utils.c | 24 +
 1 file changed, 24 insertions(+)

diff --git a/drivers/staging/media/imx/imx-media-utils.c 
b/drivers/staging/media/imx/imx-media-utils.c
index fab98fc0d6a0..99527daba29a 100644
--- a/drivers/staging/media/imx/imx-media-utils.c
+++ b/drivers/staging/media/imx/imx-media-utils.c
@@ -118,6 +118,30 @@ static const struct imx_media_pixfmt rgb_formats[] = {
.cs = IPUV3_COLORSPACE_RGB,
.bpp= 8,
.bayer  = true,
+   }, {
+   .fourcc = V4L2_PIX_FMT_SBGGR10,
+   .codes  = {MEDIA_BUS_FMT_SBGGR10_1X10},
+   .cs = IPUV3_COLORSPACE_RGB,
+   .bpp= 16,
+   .bayer  = true,
+   }, {
+   .fourcc = V4L2_PIX_FMT_SGBRG10,
+   .codes  = {MEDIA_BUS_FMT_SGBRG10_1X10},
+   .cs = IPUV3_COLORSPACE_RGB,
+   .bpp= 16,
+   .bayer  = true,
+   }, {
+   .fourcc = V4L2_PIX_FMT_SGRBG10,
+   .codes  = {MEDIA_BUS_FMT_SGRBG10_1X10},
+   .cs = IPUV3_COLORSPACE_RGB,
+   .bpp= 16,
+   .bayer  = true,
+   }, {
+   .fourcc = V4L2_PIX_FMT_SRGGB10,
+   .codes  = {MEDIA_BUS_FMT_SRGGB10_1X10},
+   .cs = IPUV3_COLORSPACE_RGB,
+   .bpp= 16,
+   .bayer  = true,
}, {
.fourcc = V4L2_PIX_FMT_SBGGR16,
.codes  = {
-- 
2.17.0

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


[PATCH 1/2] staging: fsl-dpaa2/rtc: add rtc driver

2018-04-19 Thread Yangbo Lu
This patch is to add driver for the DPAA2 1588 timer module (RTC)
which interfaces to up to an unlimited number of 10/100/1000 or
10G ethernet MACs, providing current time, alarm, and fiper support.
The 1588 IP control block includes these distinctive features.

- External GPIO trigger for time-stamping
- 2 Time-stamp alarms
- 3 FIPER pulse generators
- Phase adjusted output timer clock

Currently this driver only supports basic functions like
settime/gettime/adjtime/adjfreq.

Signed-off-by: Yangbo Lu 
---
 drivers/staging/fsl-dpaa2/Kconfig |8 +
 drivers/staging/fsl-dpaa2/Makefile|5 +-
 drivers/staging/fsl-dpaa2/rtc/Makefile|7 +
 drivers/staging/fsl-dpaa2/rtc/dprtc-cmd.h |  137 ++
 drivers/staging/fsl-dpaa2/rtc/dprtc.c |  754 +
 drivers/staging/fsl-dpaa2/rtc/dprtc.h |  164 +++
 drivers/staging/fsl-dpaa2/rtc/rtc.c   |  231 +
 7 files changed, 1304 insertions(+), 2 deletions(-)
 create mode 100644 drivers/staging/fsl-dpaa2/rtc/Makefile
 create mode 100644 drivers/staging/fsl-dpaa2/rtc/dprtc-cmd.h
 create mode 100644 drivers/staging/fsl-dpaa2/rtc/dprtc.c
 create mode 100644 drivers/staging/fsl-dpaa2/rtc/dprtc.h
 create mode 100644 drivers/staging/fsl-dpaa2/rtc/rtc.c

diff --git a/drivers/staging/fsl-dpaa2/Kconfig 
b/drivers/staging/fsl-dpaa2/Kconfig
index bbb7af5..ea2d4aa 100644
--- a/drivers/staging/fsl-dpaa2/Kconfig
+++ b/drivers/staging/fsl-dpaa2/Kconfig
@@ -24,3 +24,11 @@ config FSL_DPAA2_ETHSW
---help---
Driver for Freescale DPAA2 Ethernet Switch. Select
BRIDGE to have support for bridge tools.
+
+config FSL_DPAA2_PTP_CLOCK
+   tristate "Freescale DPAA2 PTP Clock"
+   depends on FSL_DPAA2
+   select PTP_1588_CLOCK
+   help
+ This driver adds support for using the DPAA2 1588 timer module
+ as a PTP clock.
diff --git a/drivers/staging/fsl-dpaa2/Makefile 
b/drivers/staging/fsl-dpaa2/Makefile
index 6cfd76b..9c70629 100644
--- a/drivers/staging/fsl-dpaa2/Makefile
+++ b/drivers/staging/fsl-dpaa2/Makefile
@@ -2,5 +2,6 @@
 # Freescale DataPath Acceleration Architecture Gen2 (DPAA2) drivers
 #
 
-obj-$(CONFIG_FSL_DPAA2_ETH)+= ethernet/
-obj-$(CONFIG_FSL_DPAA2_ETHSW)  += ethsw/
+obj-$(CONFIG_FSL_DPAA2_ETH)+= ethernet/
+obj-$(CONFIG_FSL_DPAA2_ETHSW)  += ethsw/
+obj-$(CONFIG_FSL_DPAA2_PTP_CLOCK)  += rtc/
diff --git a/drivers/staging/fsl-dpaa2/rtc/Makefile 
b/drivers/staging/fsl-dpaa2/rtc/Makefile
new file mode 100644
index 000..5468da0
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/rtc/Makefile
@@ -0,0 +1,7 @@
+#
+# Makefile for the Freescale DPAA2 PTP clock
+#
+
+obj-$(CONFIG_FSL_DPAA2_PTP_CLOCK) += dpaa2-rtc.o
+
+dpaa2-rtc-objs := rtc.o dprtc.o
diff --git a/drivers/staging/fsl-dpaa2/rtc/dprtc-cmd.h 
b/drivers/staging/fsl-dpaa2/rtc/dprtc-cmd.h
new file mode 100644
index 000..ba7d5a5
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/rtc/dprtc-cmd.h
@@ -0,0 +1,137 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2013-2016 Freescale Semiconductor Inc.
+ * Copyright 2016-2018 NXP
+ */
+
+#ifndef _FSL_DPRTC_CMD_H
+#define _FSL_DPRTC_CMD_H
+
+/* DPRTC Version */
+#define DPRTC_VER_MAJOR2
+#define DPRTC_VER_MINOR0
+
+/* Command versioning */
+#define DPRTC_CMD_BASE_VERSION 1
+#define DPRTC_CMD_ID_OFFSET4
+
+#define DPRTC_CMD(id)  (((id) << DPRTC_CMD_ID_OFFSET) | DPRTC_CMD_BASE_VERSION)
+
+/* Command IDs */
+#define DPRTC_CMDID_CLOSE  DPRTC_CMD(0x800)
+#define DPRTC_CMDID_OPEN   DPRTC_CMD(0x810)
+#define DPRTC_CMDID_CREATE DPRTC_CMD(0x910)
+#define DPRTC_CMDID_DESTROYDPRTC_CMD(0x990)
+#define DPRTC_CMDID_GET_API_VERSIONDPRTC_CMD(0xa10)
+
+#define DPRTC_CMDID_ENABLE DPRTC_CMD(0x002)
+#define DPRTC_CMDID_DISABLEDPRTC_CMD(0x003)
+#define DPRTC_CMDID_GET_ATTR   DPRTC_CMD(0x004)
+#define DPRTC_CMDID_RESET  DPRTC_CMD(0x005)
+#define DPRTC_CMDID_IS_ENABLED DPRTC_CMD(0x006)
+
+#define DPRTC_CMDID_SET_IRQ_ENABLE DPRTC_CMD(0x012)
+#define DPRTC_CMDID_GET_IRQ_ENABLE DPRTC_CMD(0x013)
+#define DPRTC_CMDID_SET_IRQ_MASK   DPRTC_CMD(0x014)
+#define DPRTC_CMDID_GET_IRQ_MASK   DPRTC_CMD(0x015)
+#define DPRTC_CMDID_GET_IRQ_STATUS DPRTC_CMD(0x016)
+#define DPRTC_CMDID_CLEAR_IRQ_STATUS   DPRTC_CMD(0x017)
+
+#define DPRTC_CMDID_SET_CLOCK_OFFSET   DPRTC_CMD(0x1d0)
+#define DPRTC_CMDID_SET_FREQ_COMPENSATION  DPRTC_CMD(0x1d1)
+#define DPRTC_CMDID_GET_FREQ_COMPENSATION  DPRTC_CMD(0x1d2)
+#define DPRTC_CMDID_GET_TIME   DPRTC_CMD(0x1d3)
+#define DPRTC_CMDID_SET_TIME   DPRTC_CMD(0x1d4)
+#define DPRTC_CMDID_SET_ALARM  DPRTC_CMD(0x1d5)
+#define DPRTC_CMDID_SET_PERIODIC_PULSE   

Re: [PATCH] staging: pi433: add descriptions for mutex locks

2018-04-19 Thread Marcus Wolf
Hi!

So if you like, give me your address, and I'll send you two development
samples of Pi433.

Cheers,

Marcus

Am 19.04.2018 um 11:47 schrieb Valentin Vidic:
> On Thu, Apr 19, 2018 at 11:25:19AM +0200, Marcus Wolf wrote:
>> let me know, what you like to have. For sure with just one station and
>> no other 433MHz equipment, options for testing are quite limited.
> 
> I can get Rpi3 and with two shields test 433MHz communication between
> Rpi2 and Rpi3.
> 

-- 
Smarthome-Wolf UG (haftungsbeschränkt)
Helene-Lange-Weg 23
80637 München
Amtsgericht München, HRB 223529
Umastzsteuer-ID: DE304719911
Geschäftsführer: Marcus Wolf
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: pi433: add descriptions for mutex locks

2018-04-19 Thread Valentin Vidic
On Thu, Apr 19, 2018 at 11:25:19AM +0200, Marcus Wolf wrote:
> let me know, what you like to have. For sure with just one station and
> no other 433MHz equipment, options for testing are quite limited.

I can get Rpi3 and with two shields test 433MHz communication between
Rpi2 and Rpi3.

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


RE: [PATCH 4/9] staging: iio: Augment TODO file with GPIO work item

2018-04-19 Thread Jonathan Cameron
> To make sure that these drivers do not leave staging before they
> are properly converted to use the new GPIO descriptor API,
> augment the TODO file with this work item.
> 
> Cc: Jonathan Cameron 
> Signed-off-by: Linus Walleij 
Acked-by: Jonathan Cameron 

I hope I haven't missed any so far!

Jonathan

> ---
>  drivers/staging/iio/TODO | 9 -
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/iio/TODO b/drivers/staging/iio/TODO
> index 4922402e2e98..1b8ebf2c1b69 100644
> --- a/drivers/staging/iio/TODO
> +++ b/drivers/staging/iio/TODO
> @@ -1,4 +1,11 @@
> -2016 10/09
> +2018-04-15
> +
> +All affected drivers:
> +Convert all uses of the old GPIO API from  to the
> +GPIO descriptor API in  and look up GPIO
> +lines from device tree, ACPI or board files, board files should
> +use .
> +
> 
>  ADI Drivers:
>  CC the device-drivers-de...@blackfin.uclinux.org mailing list when
> --
> 2.14.3

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


Re: [PATCH] staging: pi433: add descriptions for mutex locks

2018-04-19 Thread Marcus Wolf


Am 12.04.2018 um 20:46 schrieb Valentin Vidic:
> On Sun, Apr 08, 2018 at 05:22:46PM +0200, Marcus Wolf wrote:
>> Regarding your patch, I did not understand, why you did not remove
>> the mutex_lock in pi433_write. Wasn't it the goal to remove it?
> 
> Is it possible for more than one userspace program to open the pi433
> device and send messages?  In that case more than one pi433_write
> could be running and it needs to hold a mutex_lock before calling
> kfifo_in.

You are right. The write function is open for multiple userspace programs.
So mutex_lock schould remain.

>> Below find a proposal of pi433_write function, I wrote on base
>> of my outdated (!), private repo. It is not compiled and not tested.
>> Since there is no more handling in case of an error (as well in the
>> propsal as in your patch), I removed the error handling completely.
>> I only do a test to detect proplems while writing to the tx_fifo,
>> but (like in your patch) do nothing for solving, just printing a line.
>> If this unexpected situation will occur (most probably never),
>> the tx_fifo will be (and stay) out of sync until driver gets unloaded.
>> We have to decide, whether we can stay with that. Like written above,
>> I thinkt the benefits are great, the chance of such kind of error
>> very low.
>> What do you think?
> 
> Yes, if there is only one writer and it checks the available size,
> kfifo_in should not fail.  The only problem might be copy_from_user
> but perhaps that is also quite unlikely.  A workaround for that could
> be to copy the data into a temporary kernel buffer first and than
> start kfifo writes using only kernel memory.

For my feeling, that's a safe solution but most probably oversized.

>> It could be discussed, whether it is better to return EMSGSIZE or
>> EAGAIN on the first check. On the one hand, there is a problem with
>> the message size, on the other hand (if message isn't generally too
>> big) after a while, there should be some more space available in
>> fifo, so EAGAIN may be better choice.
> 
> EAGAIN does seem better unless the message is too big to ever fit
> in the kfifo.
> 
>>  if (retval != required ) {
>>  dev_dbg(device->dev, "write to fifo failed, reason unknown, non 
>> recoverable.");
>>  return -EAGAIN;
>>  }
> 
> Maybe this should be dev_warn or even dev_crit if the driver is not
> usable anymore when this happens?  The error message should than also
> be adjusted to EBADF or something similar.

>From my point of veiew, the warning is (in combination of the
size-check) the by far better solution then the fifo reset.

So all in all, I think, we should go with your proposal.

Unfortunaly still no time to setup my test environment with a current
version of the driver in order to give it a try :-(
Sorry,

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


Re: [PATCH] staging: pi433: add descriptions for mutex locks

2018-04-19 Thread Marcus Wolf

Am 12.04.2018 um 19:15 schrieb Valentin Vidic:
> On Sun, Apr 08, 2018 at 04:15:30PM +0200, Marcus Wolf wrote:
>> The hardware of Pi433 is working with every Raspberry Pi (on zero, you
>> need to solder the GPIO-pins) and with several other fruits like banana
>> pi. The only thing is, that you need different versions of the driver,
>> according to the processor, mounted on your fruit.
>>
>> If you'd like to test more then ther is no hang up or crash, you will
>> need a second party. You could use a 433MHz socket for testing TX or a
>> 433 thermometer for testing RX. An example code for communication with a
>> socket is available on the Pi433 productpage (www.pi433.de). The sample
>> for the thermometer isn't published yet (as always lack of time).
>>
>> If you want to test more deeply (using different features of the Rf69
>> chip or even do some long time testing, you have more options, if you
>> use to Pis with Pi433.
>>
>> Just let me know, what you'd like to do and what equipment, you need.
> 
> At the moment I have Rpi2 but not any other 433MHz equipment, so I
> could only do some basic testing unfortunately.  In case I get the
> new Rpi3 some time soon I would be able to do something better.
> 
Hi Valentin,



let me know, what you like to have. For sure with just one station and
no other 433MHz equipment, options for testing are quite limited.



Marcus

-- 
Smarthome-Wolf UG (haftungsbeschränkt)
Helene-Lange-Weg 23
80637 München
Amtsgericht München, HRB 223529
Umastzsteuer-ID: DE304719911
Geschäftsführer: Marcus Wolf
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/2] MAINTAINERS: add maintainer for the DPAA2 PTP clock driver

2018-04-19 Thread Yangbo Lu
This patch is to add maintainer for the DPAA2 PTP clock driver.

Signed-off-by: Yangbo Lu 
---
 MAINTAINERS |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 0a1410d..7733efa 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4395,6 +4395,12 @@ L:   linux-ker...@vger.kernel.org
 S: Maintained
 F: drivers/staging/fsl-dpaa2/ethsw
 
+DPAA2 PTP CLOCK DRIVER
+M: Yangbo Lu 
+L: linux-ker...@vger.kernel.org
+S: Maintained
+F: drivers/staging/fsl-dpaa2/rtc
+
 DPT_I2O SCSI RAID DRIVER
 M: Adaptec OEM Raid Solutions 
 L: linux-s...@vger.kernel.org
-- 
1.7.1

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


[PATCH 3/9] staging: greybus: Add TODO file with GPIO work items

2018-04-19 Thread Linus Walleij
To make sure that these drivers do not leave staging before they
are properly converted to use the new GPIO descriptor API, and the
GPIOLIB_IRQCHIP helper library, create the TODO file with these work
items.

Cc: Johan Hovold 
Signed-off-by: Linus Walleij 
---
I started some work in this area, make sure to just throw me in
on CC whenever anyone works on it and I will happily help and
provide examples!
---
 drivers/staging/greybus/TODO | 5 +
 1 file changed, 5 insertions(+)
 create mode 100644 drivers/staging/greybus/TODO

diff --git a/drivers/staging/greybus/TODO b/drivers/staging/greybus/TODO
new file mode 100644
index ..3b90a5711998
--- /dev/null
+++ b/drivers/staging/greybus/TODO
@@ -0,0 +1,5 @@
+* Convert all uses of the old GPIO API from  to the
+  GPIO descriptor API in  and look up GPIO
+  lines from device tree or ACPI.
+* Convert the GPIO driver to use the GPIO irqchip library
+  GPIOLIB_IRQCHIP instead of reimplementing the same.
-- 
2.14.3

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


[PATCH 6/9] staging: gpio-mt7621: Include the right header

2018-04-19 Thread Linus Walleij
GPIO drivers should include  only, the
 header is deprecated.

Cc: John Crispin 
Cc: Zhiyong Tao 
Cc: Sean Wang 
Signed-off-by: Linus Walleij 
---
I was philosophizing whether pinctrl/mediatek/pinctrl-mt7622 is
similar to this and can drive also the mt7621 but what do I know.
Sean can you have a look at this staging driver and give some
directions?
---
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index 51235687ddb6..ca105b171a06 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -9,7 +9,7 @@
 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
-- 
2.14.3

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


[PATCH 8/9] staging: olpc_dcon: Augment TODO file with GPIO work item

2018-04-19 Thread Linus Walleij
To make sure that this driver does not leave staging before it
is properly converted to use the new GPIO descriptor API,
augment the TODO file with this work item.

Cc: Andres Salomon 
Cc: Jens Frederich 
Signed-off-by: Linus Walleij 
---
 drivers/staging/olpc_dcon/TODO | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/staging/olpc_dcon/TODO b/drivers/staging/olpc_dcon/TODO
index 61c2e65ac354..665a0b061719 100644
--- a/drivers/staging/olpc_dcon/TODO
+++ b/drivers/staging/olpc_dcon/TODO
@@ -1,6 +1,10 @@
 TODO:
- see if vx855 gpio API can be made similar enough to cs5535 so we can
  share more code
+   - convert all uses of the old GPIO API from  to the
+ GPIO descriptor API in  and look up GPIO
+ lines from device tree, ACPI or board files, board files should
+ use 
- allow simultaneous XO-1 and XO-1.5 support
 
 Please send patches to Greg Kroah-Hartman  and
-- 
2.14.3

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


  1   2   >