All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] ath5k: added debugfs file for dumping eeprom
@ 2014-09-06 17:00 Jade Bilkey
  2014-09-09 19:32 ` John W. Linville
  0 siblings, 1 reply; 3+ messages in thread
From: Jade Bilkey @ 2014-09-06 17:00 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, ath5k-devel

Signed-off-by: Jade Bilkey <herself@thefumon.com>
---

v2: vmalloc not included in some configs
   Switched to using kmalloc

 drivers/net/wireless/ath/ath5k/debug.c | 96 ++++++++++++++++++++++++++++++++++
 1 file changed, 96 insertions(+)

diff --git a/drivers/net/wireless/ath/ath5k/debug.c b/drivers/net/wireless/ath/ath5k/debug.c
index b8d031a..ca3cd06 100644
--- a/drivers/net/wireless/ath/ath5k/debug.c
+++ b/drivers/net/wireless/ath/ath5k/debug.c
@@ -894,6 +894,100 @@ static const struct file_operations fops_queue = {
 	.llseek = default_llseek,
 };
 
+/* debugfs: eeprom */
+
+struct eeprom_private {
+	u16 *buf;
+	int len;
+};
+
+static int open_file_eeprom(struct inode *inode, struct file *file)
+{
+	struct eeprom_private *ep;
+	struct ath5k_hw *ah = inode->i_private;
+	bool res;
+	int i, ret;
+	u32 eesize;
+	u16 val, *buf;
+
+	/* Get eeprom size */
+
+	res = ath5k_hw_nvram_read(ah, AR5K_EEPROM_SIZE_UPPER, &val);
+	if (!res)
+		return -EACCES;
+
+	if (val == 0) {
+		eesize = AR5K_EEPROM_INFO_MAX + AR5K_EEPROM_INFO_BASE;
+	} else {
+		eesize = (val & AR5K_EEPROM_SIZE_UPPER_MASK) <<
+			AR5K_EEPROM_SIZE_ENDLOC_SHIFT;
+		ath5k_hw_nvram_read(ah, AR5K_EEPROM_SIZE_LOWER, &val);
+		eesize = eesize | val;
+	}
+
+	if (eesize > 4096)
+		return -EINVAL;
+
+	/* Create buffer and read in eeprom */
+
+	buf = kmalloc(eesize, GFP_KERNEL);
+	if (!buf) {
+		ret = -ENOMEM;
+		goto err;
+	}
+
+	for (i = 0; i < eesize; ++i) {
+		AR5K_EEPROM_READ(i, val);
+		buf[i] = val;
+	}
+
+	/* Create private struct and assign to file */
+
+	ep = kmalloc(sizeof(*ep), GFP_KERNEL);
+	if (!ep) {
+		ret = -ENOMEM;
+		goto freebuf;
+	}
+
+	ep->buf = buf;
+	ep->len = i;
+
+	file->private_data = (void *)ep;
+
+	return 0;
+
+freebuf:
+	kfree(buf);
+err:
+	return ret;
+
+}
+
+static ssize_t read_file_eeprom(struct file *file, char __user *user_buf,
+				   size_t count, loff_t *ppos)
+{
+	struct eeprom_private *ep = file->private_data;
+
+	return simple_read_from_buffer(user_buf, count, ppos, ep->buf, ep->len);
+}
+
+static int release_file_eeprom(struct inode *inode, struct file *file)
+{
+	struct eeprom_private *ep = file->private_data;
+
+	kfree(ep->buf);
+	kfree(ep);
+
+	return 0;
+}
+
+static const struct file_operations fops_eeprom = {
+	.open = open_file_eeprom,
+	.read = read_file_eeprom,
+	.release = release_file_eeprom,
+	.owner = THIS_MODULE,
+};
+
 
 void
 ath5k_debug_init_device(struct ath5k_hw *ah)
@@ -921,6 +1015,8 @@ ath5k_debug_init_device(struct ath5k_hw *ah)
 
 	debugfs_create_file("misc", S_IRUSR, phydir, ah, &fops_misc);
 
+	debugfs_create_file("eeprom", S_IRUSR, phydir, ah, &fops_eeprom);
+
 	debugfs_create_file("frameerrors", S_IWUSR | S_IRUSR, phydir, ah,
 			    &fops_frameerrors);
 
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] ath5k: added debugfs file for dumping eeprom
  2014-09-06 17:00 [PATCH v2] ath5k: added debugfs file for dumping eeprom Jade Bilkey
@ 2014-09-09 19:32 ` John W. Linville
  2014-09-11 18:11   ` John W. Linville
  0 siblings, 1 reply; 3+ messages in thread
From: John W. Linville @ 2014-09-09 19:32 UTC (permalink / raw)
  To: Jade Bilkey; +Cc: linux-wireless, ath5k-devel

The original patch was already merged.  To make a change, you need
to post a new patch based on the new head of the tree.  This one just
conflicts with what is already there now.

Also, I think all you really need is a "#include <linux/vmalloc.h>".

Post a v3 that just adds the #include?

John

On Sat, Sep 06, 2014 at 01:00:48PM -0400, Jade Bilkey wrote:
> Signed-off-by: Jade Bilkey <herself@thefumon.com>
> ---
> 
> v2: vmalloc not included in some configs
>    Switched to using kmalloc
> 
>  drivers/net/wireless/ath/ath5k/debug.c | 96 ++++++++++++++++++++++++++++++++++
>  1 file changed, 96 insertions(+)
> 
> diff --git a/drivers/net/wireless/ath/ath5k/debug.c b/drivers/net/wireless/ath/ath5k/debug.c
> index b8d031a..ca3cd06 100644
> --- a/drivers/net/wireless/ath/ath5k/debug.c
> +++ b/drivers/net/wireless/ath/ath5k/debug.c
> @@ -894,6 +894,100 @@ static const struct file_operations fops_queue = {
>  	.llseek = default_llseek,
>  };
>  
> +/* debugfs: eeprom */
> +
> +struct eeprom_private {
> +	u16 *buf;
> +	int len;
> +};
> +
> +static int open_file_eeprom(struct inode *inode, struct file *file)
> +{
> +	struct eeprom_private *ep;
> +	struct ath5k_hw *ah = inode->i_private;
> +	bool res;
> +	int i, ret;
> +	u32 eesize;
> +	u16 val, *buf;
> +
> +	/* Get eeprom size */
> +
> +	res = ath5k_hw_nvram_read(ah, AR5K_EEPROM_SIZE_UPPER, &val);
> +	if (!res)
> +		return -EACCES;
> +
> +	if (val == 0) {
> +		eesize = AR5K_EEPROM_INFO_MAX + AR5K_EEPROM_INFO_BASE;
> +	} else {
> +		eesize = (val & AR5K_EEPROM_SIZE_UPPER_MASK) <<
> +			AR5K_EEPROM_SIZE_ENDLOC_SHIFT;
> +		ath5k_hw_nvram_read(ah, AR5K_EEPROM_SIZE_LOWER, &val);
> +		eesize = eesize | val;
> +	}
> +
> +	if (eesize > 4096)
> +		return -EINVAL;
> +
> +	/* Create buffer and read in eeprom */
> +
> +	buf = kmalloc(eesize, GFP_KERNEL);
> +	if (!buf) {
> +		ret = -ENOMEM;
> +		goto err;
> +	}
> +
> +	for (i = 0; i < eesize; ++i) {
> +		AR5K_EEPROM_READ(i, val);
> +		buf[i] = val;
> +	}
> +
> +	/* Create private struct and assign to file */
> +
> +	ep = kmalloc(sizeof(*ep), GFP_KERNEL);
> +	if (!ep) {
> +		ret = -ENOMEM;
> +		goto freebuf;
> +	}
> +
> +	ep->buf = buf;
> +	ep->len = i;
> +
> +	file->private_data = (void *)ep;
> +
> +	return 0;
> +
> +freebuf:
> +	kfree(buf);
> +err:
> +	return ret;
> +
> +}
> +
> +static ssize_t read_file_eeprom(struct file *file, char __user *user_buf,
> +				   size_t count, loff_t *ppos)
> +{
> +	struct eeprom_private *ep = file->private_data;
> +
> +	return simple_read_from_buffer(user_buf, count, ppos, ep->buf, ep->len);
> +}
> +
> +static int release_file_eeprom(struct inode *inode, struct file *file)
> +{
> +	struct eeprom_private *ep = file->private_data;
> +
> +	kfree(ep->buf);
> +	kfree(ep);
> +
> +	return 0;
> +}
> +
> +static const struct file_operations fops_eeprom = {
> +	.open = open_file_eeprom,
> +	.read = read_file_eeprom,
> +	.release = release_file_eeprom,
> +	.owner = THIS_MODULE,
> +};
> +
>  
>  void
>  ath5k_debug_init_device(struct ath5k_hw *ah)
> @@ -921,6 +1015,8 @@ ath5k_debug_init_device(struct ath5k_hw *ah)
>  
>  	debugfs_create_file("misc", S_IRUSR, phydir, ah, &fops_misc);
>  
> +	debugfs_create_file("eeprom", S_IRUSR, phydir, ah, &fops_eeprom);
> +
>  	debugfs_create_file("frameerrors", S_IWUSR | S_IRUSR, phydir, ah,
>  			    &fops_frameerrors);
>  
> -- 
> 2.1.0
> 
> 

-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] ath5k: added debugfs file for dumping eeprom
  2014-09-09 19:32 ` John W. Linville
@ 2014-09-11 18:11   ` John W. Linville
  0 siblings, 0 replies; 3+ messages in thread
From: John W. Linville @ 2014-09-11 18:11 UTC (permalink / raw)
  To: Jade Bilkey; +Cc: linux-wireless, ath5k-devel

On Tue, Sep 09, 2014 at 03:32:38PM -0400, John W. Linville wrote:
> The original patch was already merged.  To make a change, you need
> to post a new patch based on the new head of the tree.  This one just
> conflicts with what is already there now.
> 
> Also, I think all you really need is a "#include <linux/vmalloc.h>".
> 
> Post a v3 that just adds the #include?

Nevermind, Dave M. already merged such a patch in net-next...

-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-09-11 18:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-06 17:00 [PATCH v2] ath5k: added debugfs file for dumping eeprom Jade Bilkey
2014-09-09 19:32 ` John W. Linville
2014-09-11 18:11   ` John W. Linville

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.