]> Pileus Git - ~andy/linux/commitdiff
iwlwifi: debugfs EEPROM dump
authorTomas Winkler <tomas.winkler@intel.com>
Mon, 5 May 2008 02:22:32 +0000 (10:22 +0800)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 14 May 2008 20:29:42 +0000 (16:29 -0400)
This patch adds EEPROM dump in debugfs.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Abhijeet Kolekar <abhijeet.kolekar@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/iwlwifi/iwl-debug.h
drivers/net/wireless/iwlwifi/iwl-debugfs.c

index c60724c21db8a9bdd41abcb7214261f08afdff38..7e68d24114f868bba6c9c6872f7c856663c6bb32 100644 (file)
@@ -57,6 +57,7 @@ struct iwl_debugfs {
        struct dentry *dir_data;
        struct dir_data_files{
                struct dentry *file_sram;
+               struct dentry *file_eeprom;
                struct dentry *file_stations;
                struct dentry *file_rx_statistics;
                struct dentry *file_tx_statistics;
index 37b52e63739b6ca46dd1d39649928a5018fcd230..ad25806dfaf1862aa690a7bf37c067d0b27443b0 100644 (file)
@@ -277,8 +277,48 @@ static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
        return ret;
 }
 
+static ssize_t iwl_dbgfs_eeprom_read(struct file *file,
+                                      char __user *user_buf,
+                                      size_t count,
+                                      loff_t *ppos)
+{
+       ssize_t ret;
+       struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
+       int pos = 0, ofs = 0, buf_size = 0;
+       const u8 *ptr;
+       char *buf;
+       size_t eeprom_len = priv->cfg->eeprom_size;
+       buf_size = 4 * eeprom_len + 256;
+
+       if (eeprom_len % 16) {
+               IWL_ERROR("EEPROM size is not multiple of 16.\n");
+               return -ENODATA;
+       }
+
+       /* 4 characters for byte 0xYY */
+       buf = kzalloc(buf_size, GFP_KERNEL);
+       if (!buf) {
+               IWL_ERROR("Can not allocate Buffer\n");
+               return -ENOMEM;
+       }
+
+       ptr = priv->eeprom;
+       for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) {
+               pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs);
+               hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos,
+                                  buf_size - pos, 0);
+               pos += strlen(buf);
+               if (buf_size - pos > 0)
+                       buf[pos++] = '\n';
+       }
+
+       ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+       kfree(buf);
+       return ret;
+}
 
 DEBUGFS_READ_WRITE_FILE_OPS(sram);
+DEBUGFS_READ_FILE_OPS(eeprom);
 DEBUGFS_READ_FILE_OPS(stations);
 DEBUGFS_READ_FILE_OPS(rx_statistics);
 DEBUGFS_READ_FILE_OPS(tx_statistics);
@@ -304,6 +344,7 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
        }
 
        DEBUGFS_ADD_DIR(data, dbgfs->dir_drv);
+       DEBUGFS_ADD_FILE(eeprom, data);
        DEBUGFS_ADD_FILE(sram, data);
        DEBUGFS_ADD_FILE(stations, data);
        DEBUGFS_ADD_FILE(rx_statistics, data);
@@ -327,6 +368,7 @@ void iwl_dbgfs_unregister(struct iwl_priv *priv)
        if (!(priv->dbgfs))
                return;
 
+       DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_eeprom);
        DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_rx_statistics);
        DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_tx_statistics);
        DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_sram);