mirror of
https://github.com/torvalds/linux.git
synced 2026-05-28 17:13:52 +02:00
wifi: rtw89: debugfs: implement file_ops::read/write to replace seq_file
Since debugfs needs wiphy lock held, wiphy_locked_debugfs_{read,write}()
will be adopted, so implmenet file_ops::read/write along with their
arguments.
For reading part, it needs lots of changes because seq_file is not
suitable for wiphy_locked_debugfs_{read,write}(), so use spatch script
below to convert basically, and manually implement the functions.
@ rule1 @
identifier m;
@@
- seq_printf(m,
+ p += scnprintf(p, end - p,
...)
@ rule2 @
identifier m;
@@
- seq_puts(m,
+ p += scnprintf(p, end - p,
...)
For current version, only 4K buffer to output. To note ourselves, add
ellipsis symbol "..." to trailing if buffer is full. Later, add an option
to specify buffer size needed by a debugfs entry.
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250122060310.31976-4-pkshih@realtek.com
This commit is contained in:
parent
4afde17d26
commit
831cceed3b
File diff suppressed because it is too large
Load Diff
|
|
@ -282,7 +282,7 @@ void rtw89_btc_ntfy_wl_rfk(struct rtw89_dev *rtwdev, u8 phy_map,
|
|||
void rtw89_btc_ntfy_wl_sta(struct rtw89_dev *rtwdev);
|
||||
void rtw89_btc_c2h_handle(struct rtw89_dev *rtwdev, struct sk_buff *skb,
|
||||
u32 len, u8 class, u8 func);
|
||||
void rtw89_btc_dump_info(struct rtw89_dev *rtwdev, struct seq_file *m);
|
||||
ssize_t rtw89_btc_dump_info(struct rtw89_dev *rtwdev, char *buf, size_t bufsz);
|
||||
void rtw89_coex_act1_work(struct wiphy *wiphy, struct wiphy_work *work);
|
||||
void rtw89_coex_bt_devinfo_work(struct wiphy *wiphy, struct wiphy_work *work);
|
||||
void rtw89_coex_rfk_chk_work(struct wiphy *wiphy, struct wiphy_work *work);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -2070,24 +2070,28 @@ s16 rtw89_phy_ant_gain_pwr_offset(struct rtw89_dev *rtwdev,
|
|||
}
|
||||
EXPORT_SYMBOL(rtw89_phy_ant_gain_pwr_offset);
|
||||
|
||||
void rtw89_print_ant_gain(struct seq_file *m, struct rtw89_dev *rtwdev,
|
||||
const struct rtw89_chan *chan)
|
||||
int rtw89_print_ant_gain(struct rtw89_dev *rtwdev, char *buf, size_t bufsz,
|
||||
const struct rtw89_chan *chan)
|
||||
{
|
||||
struct rtw89_ant_gain_info *ant_gain = &rtwdev->ant_gain;
|
||||
const struct rtw89_chip_info *chip = rtwdev->chip;
|
||||
u8 regd = rtw89_regd_get(rtwdev, chan->band_type);
|
||||
char *p = buf, *end = buf + bufsz;
|
||||
s8 offset_patha, offset_pathb;
|
||||
|
||||
if (!chip->support_ant_gain || !(ant_gain->regd_enabled & BIT(regd))) {
|
||||
seq_puts(m, "no DAG is applied\n");
|
||||
return;
|
||||
p += scnprintf(p, end - p, "no DAG is applied\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
offset_patha = rtw89_phy_ant_gain_query(rtwdev, RF_PATH_A, chan->freq);
|
||||
offset_pathb = rtw89_phy_ant_gain_query(rtwdev, RF_PATH_B, chan->freq);
|
||||
|
||||
seq_printf(m, "ChainA offset: %d dBm\n", offset_patha);
|
||||
seq_printf(m, "ChainB offset: %d dBm\n", offset_pathb);
|
||||
p += scnprintf(p, end - p, "ChainA offset: %d dBm\n", offset_patha);
|
||||
p += scnprintf(p, end - p, "ChainB offset: %d dBm\n", offset_pathb);
|
||||
|
||||
out:
|
||||
return p - buf;
|
||||
}
|
||||
|
||||
static const u8 rtw89_rs_idx_num_ax[] = {
|
||||
|
|
|
|||
|
|
@ -835,8 +835,8 @@ s8 rtw89_phy_read_txpwr_byrate(struct rtw89_dev *rtwdev, u8 band, u8 bw,
|
|||
void rtw89_phy_ant_gain_init(struct rtw89_dev *rtwdev);
|
||||
s16 rtw89_phy_ant_gain_pwr_offset(struct rtw89_dev *rtwdev,
|
||||
const struct rtw89_chan *chan);
|
||||
void rtw89_print_ant_gain(struct seq_file *m, struct rtw89_dev *rtwdev,
|
||||
const struct rtw89_chan *chan);
|
||||
int rtw89_print_ant_gain(struct rtw89_dev *rtwdev, char *buf, size_t bufsz,
|
||||
const struct rtw89_chan *chan);
|
||||
void rtw89_phy_load_txpwr_byrate(struct rtw89_dev *rtwdev,
|
||||
const struct rtw89_txpwr_table *tbl);
|
||||
s8 rtw89_phy_read_txpwr_limit(struct rtw89_dev *rtwdev, u8 band,
|
||||
|
|
|
|||
|
|
@ -178,12 +178,14 @@ s8 rtw89_query_sar(struct rtw89_dev *rtwdev, u32 center_freq)
|
|||
return rtw89_txpwr_sar_to_mac(rtwdev, fct, cfg);
|
||||
}
|
||||
|
||||
void rtw89_print_sar(struct seq_file *m, struct rtw89_dev *rtwdev, u32 center_freq)
|
||||
int rtw89_print_sar(struct rtw89_dev *rtwdev, char *buf, size_t bufsz,
|
||||
u32 center_freq)
|
||||
{
|
||||
const enum rtw89_sar_sources src = rtwdev->sar.src;
|
||||
/* its members are protected by rtw89_sar_set_src() */
|
||||
const struct rtw89_sar_handler *sar_hdl = &rtw89_sar_handlers[src];
|
||||
const u8 fct_mac = rtwdev->chip->txpwr_factor_mac;
|
||||
char *p = buf, *end = buf + bufsz;
|
||||
int ret;
|
||||
s32 cfg;
|
||||
u8 fct;
|
||||
|
|
@ -191,36 +193,46 @@ void rtw89_print_sar(struct seq_file *m, struct rtw89_dev *rtwdev, u32 center_fr
|
|||
lockdep_assert_held(&rtwdev->mutex);
|
||||
|
||||
if (src == RTW89_SAR_SOURCE_NONE) {
|
||||
seq_puts(m, "no SAR is applied\n");
|
||||
return;
|
||||
p += scnprintf(p, end - p, "no SAR is applied\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
seq_printf(m, "source: %d (%s)\n", src, sar_hdl->descr_sar_source);
|
||||
p += scnprintf(p, end - p, "source: %d (%s)\n", src,
|
||||
sar_hdl->descr_sar_source);
|
||||
|
||||
ret = sar_hdl->query_sar_config(rtwdev, center_freq, &cfg);
|
||||
if (ret) {
|
||||
seq_printf(m, "config: return code: %d\n", ret);
|
||||
seq_printf(m, "assign: max setting: %d (unit: 1/%lu dBm)\n",
|
||||
RTW89_SAR_TXPWR_MAC_MAX, BIT(fct_mac));
|
||||
return;
|
||||
p += scnprintf(p, end - p, "config: return code: %d\n", ret);
|
||||
p += scnprintf(p, end - p,
|
||||
"assign: max setting: %d (unit: 1/%lu dBm)\n",
|
||||
RTW89_SAR_TXPWR_MAC_MAX, BIT(fct_mac));
|
||||
goto out;
|
||||
}
|
||||
|
||||
fct = sar_hdl->txpwr_factor_sar;
|
||||
|
||||
seq_printf(m, "config: %d (unit: 1/%lu dBm)\n", cfg, BIT(fct));
|
||||
p += scnprintf(p, end - p, "config: %d (unit: 1/%lu dBm)\n", cfg,
|
||||
BIT(fct));
|
||||
|
||||
out:
|
||||
return p - buf;
|
||||
}
|
||||
|
||||
void rtw89_print_tas(struct seq_file *m, struct rtw89_dev *rtwdev)
|
||||
int rtw89_print_tas(struct rtw89_dev *rtwdev, char *buf, size_t bufsz)
|
||||
{
|
||||
struct rtw89_tas_info *tas = &rtwdev->tas;
|
||||
char *p = buf, *end = buf + bufsz;
|
||||
|
||||
if (!tas->enable) {
|
||||
seq_puts(m, "no TAS is applied\n");
|
||||
return;
|
||||
p += scnprintf(p, end - p, "no TAS is applied\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
seq_printf(m, "DPR gap: %d\n", tas->dpr_gap);
|
||||
seq_printf(m, "TAS delta: %d\n", tas->delta);
|
||||
p += scnprintf(p, end - p, "DPR gap: %d\n", tas->dpr_gap);
|
||||
p += scnprintf(p, end - p, "TAS delta: %d\n", tas->delta);
|
||||
|
||||
out:
|
||||
return p - buf;
|
||||
}
|
||||
|
||||
static int rtw89_apply_sar_common(struct rtw89_dev *rtwdev,
|
||||
|
|
|
|||
|
|
@ -19,8 +19,9 @@ struct rtw89_sar_handler {
|
|||
extern const struct cfg80211_sar_capa rtw89_sar_capa;
|
||||
|
||||
s8 rtw89_query_sar(struct rtw89_dev *rtwdev, u32 center_freq);
|
||||
void rtw89_print_sar(struct seq_file *m, struct rtw89_dev *rtwdev, u32 center_freq);
|
||||
void rtw89_print_tas(struct seq_file *m, struct rtw89_dev *rtwdev);
|
||||
int rtw89_print_sar(struct rtw89_dev *rtwdev, char *buf, size_t bufsz,
|
||||
u32 center_freq);
|
||||
int rtw89_print_tas(struct rtw89_dev *rtwdev, char *buf, size_t bufsz);
|
||||
int rtw89_ops_set_sar_specs(struct ieee80211_hw *hw,
|
||||
const struct cfg80211_sar_specs *sar);
|
||||
void rtw89_tas_init(struct rtw89_dev *rtwdev);
|
||||
|
|
|
|||
|
|
@ -104,3 +104,14 @@ u64 rtw89_db_2_linear(u32 db)
|
|||
return linear;
|
||||
}
|
||||
EXPORT_SYMBOL(rtw89_db_2_linear);
|
||||
|
||||
void rtw89_might_trailing_ellipsis(char *buf, size_t size, ssize_t used)
|
||||
{
|
||||
static const char ellipsis[] = "...";
|
||||
|
||||
/* length of null terminiator isn't included in 'used' */
|
||||
if (used + 1 < size || size < sizeof(ellipsis))
|
||||
return;
|
||||
|
||||
memcpy(buf + size - sizeof(ellipsis), ellipsis, sizeof(ellipsis));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,5 +77,6 @@ static inline void ether_addr_copy_mask(u8 *dst, const u8 *src, u8 mask)
|
|||
|
||||
u32 rtw89_linear_2_db(u64 linear);
|
||||
u64 rtw89_db_2_linear(u32 db);
|
||||
void rtw89_might_trailing_ellipsis(char *buf, size_t size, ssize_t used);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user