2
0

500-ath9k_eeprom_debugfs.patch 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. --- a/drivers/net/wireless/ath/ath9k/debug.c
  2. +++ b/drivers/net/wireless/ath/ath9k/debug.c
  3. @@ -1315,6 +1315,53 @@ void ath9k_deinit_debug(struct ath_softc
  4. ath9k_cmn_spectral_deinit_debug(&sc->spec_priv);
  5. }
  6. +static ssize_t read_file_eeprom(struct file *file, char __user *user_buf,
  7. + size_t count, loff_t *ppos)
  8. +{
  9. + struct ath_softc *sc = file->private_data;
  10. + struct ath_hw *ah = sc->sc_ah;
  11. + struct ath_common *common = ath9k_hw_common(ah);
  12. + int bytes = 0;
  13. + int pos = *ppos;
  14. + int size = 4096;
  15. + u16 val;
  16. + int i;
  17. +
  18. + if (AR_SREV_9300_20_OR_LATER(ah))
  19. + size = 16384;
  20. +
  21. + if (*ppos < 0)
  22. + return -EINVAL;
  23. +
  24. + if (count > size - *ppos)
  25. + count = size - *ppos;
  26. +
  27. + for (i = *ppos / 2; count > 0; count -= bytes, *ppos += bytes, i++) {
  28. + void *from = &val;
  29. +
  30. + if (!common->bus_ops->eeprom_read(common, i, &val))
  31. + val = 0xffff;
  32. +
  33. + if (*ppos % 2) {
  34. + from++;
  35. + bytes = 1;
  36. + } else if (count == 1) {
  37. + bytes = 1;
  38. + } else {
  39. + bytes = 2;
  40. + }
  41. + copy_to_user(user_buf, from, bytes);
  42. + user_buf += bytes;
  43. + }
  44. + return *ppos - pos;
  45. +}
  46. +
  47. +static const struct file_operations fops_eeprom = {
  48. + .read = read_file_eeprom,
  49. + .open = simple_open,
  50. + .owner = THIS_MODULE
  51. +};
  52. +
  53. int ath9k_init_debug(struct ath_hw *ah)
  54. {
  55. struct ath_common *common = ath9k_hw_common(ah);
  56. @@ -1334,6 +1381,8 @@ int ath9k_init_debug(struct ath_hw *ah)
  57. ath9k_tx99_init_debug(sc);
  58. ath9k_cmn_spectral_init_debug(&sc->spec_priv, sc->debug.debugfs_phy);
  59. + debugfs_create_file("eeprom", S_IRUSR, sc->debug.debugfs_phy, sc,
  60. + &fops_eeprom);
  61. debugfs_create_devm_seqfile(sc->dev, "dma", sc->debug.debugfs_phy,
  62. read_file_dma);
  63. debugfs_create_devm_seqfile(sc->dev, "interrupt", sc->debug.debugfs_phy,