512-ath9k_channelbw_debugfs.patch 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. --- a/drivers/net/wireless/ath/ath9k/debug.c
  2. +++ b/drivers/net/wireless/ath/ath9k/debug.c
  3. @@ -1348,6 +1348,52 @@ static const struct file_operations fops
  4. .owner = THIS_MODULE
  5. };
  6. +
  7. +static ssize_t read_file_chan_bw(struct file *file, char __user *user_buf,
  8. + size_t count, loff_t *ppos)
  9. +{
  10. + struct ath_softc *sc = file->private_data;
  11. + struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  12. + char buf[32];
  13. + unsigned int len;
  14. +
  15. + len = sprintf(buf, "0x%08x\n", common->chan_bw);
  16. + return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  17. +}
  18. +
  19. +static ssize_t write_file_chan_bw(struct file *file, const char __user *user_buf,
  20. + size_t count, loff_t *ppos)
  21. +{
  22. + struct ath_softc *sc = file->private_data;
  23. + struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  24. + unsigned long chan_bw;
  25. + char buf[32];
  26. + ssize_t len;
  27. +
  28. + len = min(count, sizeof(buf) - 1);
  29. + if (copy_from_user(buf, user_buf, len))
  30. + return -EFAULT;
  31. +
  32. + buf[len] = '\0';
  33. + if (kstrtoul(buf, 0, &chan_bw))
  34. + return -EINVAL;
  35. +
  36. + common->chan_bw = chan_bw;
  37. + if (!test_bit(ATH_OP_INVALID, &common->op_flags))
  38. + ath9k_ops.config(sc->hw, IEEE80211_CONF_CHANGE_CHANNEL);
  39. +
  40. + return count;
  41. +}
  42. +
  43. +static const struct file_operations fops_chanbw = {
  44. + .read = read_file_chan_bw,
  45. + .write = write_file_chan_bw,
  46. + .open = simple_open,
  47. + .owner = THIS_MODULE,
  48. + .llseek = default_llseek,
  49. +};
  50. +
  51. +
  52. int ath9k_init_debug(struct ath_hw *ah)
  53. {
  54. struct ath_common *common = ath9k_hw_common(ah);
  55. @@ -1369,6 +1415,8 @@ int ath9k_init_debug(struct ath_hw *ah)
  56. debugfs_create_file("eeprom", S_IRUSR, sc->debug.debugfs_phy, sc,
  57. &fops_eeprom);
  58. + debugfs_create_file("chanbw", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
  59. + sc, &fops_chanbw);
  60. debugfs_create_devm_seqfile(sc->dev, "dma", sc->debug.debugfs_phy,
  61. read_file_dma);
  62. debugfs_create_devm_seqfile(sc->dev, "interrupt", sc->debug.debugfs_phy,
  63. --- a/drivers/net/wireless/ath/ath.h
  64. +++ b/drivers/net/wireless/ath/ath.h
  65. @@ -151,6 +151,7 @@ struct ath_common {
  66. int debug_mask;
  67. enum ath_device_state state;
  68. unsigned long op_flags;
  69. + u32 chan_bw;
  70. struct ath_ani ani;
  71. --- a/drivers/net/wireless/ath/ath9k/common.c
  72. +++ b/drivers/net/wireless/ath/ath9k/common.c
  73. @@ -296,11 +296,13 @@ EXPORT_SYMBOL(ath9k_cmn_get_hw_crypto_ke
  74. /*
  75. * Update internal channel flags.
  76. */
  77. -static void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan,
  78. +static void ath9k_cmn_update_ichannel(struct ath_common *common,
  79. + struct ath9k_channel *ichan,
  80. struct cfg80211_chan_def *chandef)
  81. {
  82. struct ieee80211_channel *chan = chandef->chan;
  83. u16 flags = 0;
  84. + int width;
  85. ichan->channel = chan->center_freq;
  86. ichan->chan = chan;
  87. @@ -308,7 +310,19 @@ static void ath9k_cmn_update_ichannel(st
  88. if (chan->band == IEEE80211_BAND_5GHZ)
  89. flags |= CHANNEL_5GHZ;
  90. - switch (chandef->width) {
  91. + switch (common->chan_bw) {
  92. + case 5:
  93. + width = NL80211_CHAN_WIDTH_5;
  94. + break;
  95. + case 10:
  96. + width = NL80211_CHAN_WIDTH_10;
  97. + break;
  98. + default:
  99. + width = chandef->width;
  100. + break;
  101. + }
  102. +
  103. + switch (width) {
  104. case NL80211_CHAN_WIDTH_5:
  105. flags |= CHANNEL_QUARTER;
  106. break;
  107. @@ -341,10 +355,11 @@ struct ath9k_channel *ath9k_cmn_get_chan
  108. struct cfg80211_chan_def *chandef)
  109. {
  110. struct ieee80211_channel *curchan = chandef->chan;
  111. + struct ath_common *common = ath9k_hw_common(ah);
  112. struct ath9k_channel *channel;
  113. channel = &ah->channels[curchan->hw_value];
  114. - ath9k_cmn_update_ichannel(channel, chandef);
  115. + ath9k_cmn_update_ichannel(common, channel, chandef);
  116. return channel;
  117. }