Linux backports project
 help / color / mirror / Atom feed
From: Arend van Spriel <arend@broadcom.com>
To: Hauke Mehrtens <hauke@hauke-m.de>
Cc: <backports@vger.kernel.org>
Subject: Re: [PATCH 06/14] backport: add debugfs_create_devm_seqfile()
Date: Sun, 21 Dec 2014 09:28:32 +0100	[thread overview]
Message-ID: <549684B0.1000308@broadcom.com> (raw)
In-Reply-To: <1419111577-22174-7-git-send-email-hauke@hauke-m.de>

On 12/20/14 22:39, Hauke Mehrtens wrote:
> This new functions is used by ath9k.

Are you sure? In the driver-core repo the ath9k patch adding this was 
reverted as I made a stupid mistake with driver data. I have the revised 
patch ready, but it will be for 3.20.

Regards,
Arend

> Signed-off-by: Hauke Mehrtens<hauke@hauke-m.de>
> ---
>   backport/backport-include/linux/debugfs.h | 23 +++++++++++++
>   backport/compat/backport-3.19.c           | 56 +++++++++++++++++++++++++++++++
>   2 files changed, 79 insertions(+)
>   create mode 100644 backport/backport-include/linux/debugfs.h
>
> diff --git a/backport/backport-include/linux/debugfs.h b/backport/backport-include/linux/debugfs.h
> new file mode 100644
> index 0000000..77b2e64
> --- /dev/null
> +++ b/backport/backport-include/linux/debugfs.h
> @@ -0,0 +1,23 @@
> +#ifndef __BACKPORT_DEBUGFS_H_
> +#define __BACKPORT_DEBUGFS_H_
> +#include_next<linux/debugfs.h>
> +#include<linux/version.h>
> +#include<generated/utsrelease.h>
> +
> +#if defined(CONFIG_DEBUG_FS)
> +struct dentry *debugfs_create_devm_seqfile(struct device *dev, const char *name,
> +					   struct dentry *parent,
> +					   int (*read_fn)(struct seq_file *s,
> +							  void *data));
> +#else
> +static inline struct dentry *debugfs_create_devm_seqfile(struct device *dev,
> +							 const char *name,
> +							 struct dentry *parent,
> +					   int (*read_fn)(struct seq_file *s,
> +							  void *data))
> +{
> +	return ERR_PTR(-ENODEV);
> +}
> +#endif /* CONFIG_DEBUG_FS */
> +
> +#endif /* __BACKPORT_DEBUGFS_H_ */
> diff --git a/backport/compat/backport-3.19.c b/backport/compat/backport-3.19.c
> index fd13400..c633f38 100644
> --- a/backport/compat/backport-3.19.c
> +++ b/backport/compat/backport-3.19.c
> @@ -13,6 +13,7 @@
>   #include<linux/export.h>
>   #include<linux/net.h>
>   #include<linux/netdevice.h>
> +#include<linux/debugfs.h>
>
>   static inline bool is_kthread_should_stop(void)
>   {
> @@ -90,3 +91,58 @@ void netdev_rss_key_fill(void *buffer, size_t len)
>   }
>   EXPORT_SYMBOL_GPL(netdev_rss_key_fill);
>   #endif /* __BACKPORT_NETDEV_RSS_KEY_FILL */
> +
> +#if defined(CONFIG_DEBUG_FS)
> +struct debugfs_devm_entry {
> +	int (*read)(struct seq_file *seq, void *data);
> +	struct device *dev;
> +};
> +
> +static int debugfs_devm_entry_open(struct inode *inode, struct file *f)
> +{
> +	struct debugfs_devm_entry *entry = inode->i_private;
> +
> +	return single_open(f, entry->read, entry->dev);
> +}
> +
> +static const struct file_operations debugfs_devm_entry_ops = {
> +	.owner = THIS_MODULE,
> +	.open = debugfs_devm_entry_open,
> +	.release = single_release,
> +	.read = seq_read,
> +	.llseek = seq_lseek
> +};
> +
> +/**
> + * debugfs_create_devm_seqfile - create a debugfs file that is bound to device.
> + *
> + * @dev: device related to this debugfs file.
> + * @name: name of the debugfs file.
> + * @parent: a pointer to the parent dentry for this file.  This should be a
> + *	directory dentry if set.  If this parameter is %NULL, then the
> + *	file will be created in the root of the debugfs filesystem.
> + * @read_fn: function pointer called to print the seq_file content.
> + */
> +struct dentry *debugfs_create_devm_seqfile(struct device *dev, const char *name,
> +					   struct dentry *parent,
> +					   int (*read_fn)(struct seq_file *s,
> +							  void *data))
> +{
> +	struct debugfs_devm_entry *entry;
> +
> +	if (IS_ERR(parent))
> +		return ERR_PTR(-ENOENT);
> +
> +	entry = devm_kzalloc(dev, sizeof(*entry), GFP_KERNEL);
> +	if (!entry)
> +		return ERR_PTR(-ENOMEM);
> +
> +	entry->read = read_fn;
> +	entry->dev = dev;
> +
> +	return debugfs_create_file(name, S_IRUGO, parent, entry,
> +				&debugfs_devm_entry_ops);
> +}
> +EXPORT_SYMBOL_GPL(debugfs_create_devm_seqfile);
> +
> +#endif /* CONFIG_DEBUG_FS */


  reply	other threads:[~2014-12-21  8:28 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-20 21:39 [PATCH 00/14] backports: updates for next-20141201 Hauke Mehrtens
2014-12-20 21:39 ` [PATCH 01/14] header: add for_each_compatible_node() Hauke Mehrtens
2014-12-20 21:39 ` [PATCH 02/14] header: add memcpy_from_msg() Hauke Mehrtens
2014-12-20 21:39 ` [PATCH 03/14] header: add empty of_find_compatible_node() Hauke Mehrtens
2014-12-20 21:39 ` [PATCH 04/14] header: include some other dma headers in dma-buf.h Hauke Mehrtens
2014-12-20 21:39 ` [PATCH 05/14] header: backport drain_workqueue() by calling flush_workqueue() Hauke Mehrtens
2014-12-20 21:39 ` [PATCH 06/14] backport: add debugfs_create_devm_seqfile() Hauke Mehrtens
2014-12-21  8:28   ` Arend van Spriel [this message]
2014-12-21 12:29     ` Hauke Mehrtens
2014-12-21 13:27       ` Arend van Spriel
2014-12-20 21:39 ` [PATCH 07/14] backport: add pci_device_is_present() Hauke Mehrtens
2014-12-20 21:39 ` [PATCH 08/14] backport: add of_property_read_u32() Hauke Mehrtens
2014-12-20 21:39 ` [PATCH 09/14] patches: disable tx status support in mwifiex Hauke Mehrtens
2014-12-20 21:39 ` [PATCH 10/14] patches: fix some v4l2 dma stuff Hauke Mehrtens
2014-12-20 21:39 ` [PATCH 11/14] patches: do not use DMA_ATTR_SKIP_CPU_SYNC Hauke Mehrtens
2014-12-20 21:39 ` [PATCH 12/14] patches: adapt api change of rchan_callbacks->create_buf_file in ath9k Hauke Mehrtens
2014-12-20 21:39 ` [PATCH 13/14] patches: refresh on next-20141201 Hauke Mehrtens
2014-12-20 21:39 ` [PATCH 14/14] devel: update the test kernels Hauke Mehrtens

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=549684B0.1000308@broadcom.com \
    --to=arend@broadcom.com \
    --cc=backports@vger.kernel.org \
    --cc=hauke@hauke-m.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox