本文整理汇总了C++中scnprintf函数的典型用法代码示例。如果您正苦于以下问题:C++ scnprintf函数的具体用法?C++ scnprintf怎么用?C++ scnprintf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了scnprintf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: msm_rpm_log_copy
/*
* msm_rpm_log_copy() - Copies messages from a volatile circular buffer in
* the RPM's shared memory into a private local buffer
* msg_buffer: pointer to local buffer (string)
* buf_len: length of local buffer in bytes
* read_start_idx: index into shared memory buffer
*
* Return value: number of bytes written to the local buffer
*
* Copies messages stored in a circular buffer in the RPM Message Memory into
* a specified local buffer. The RPM processor is unaware of these reading
* efforts, so care is taken to make sure that messages are valid both before
* and after reading. The RPM processor utilizes a ULog driver to write the
* log. The RPM processor maintains tail and head indices. These correspond
* to the next byte to write into, and the first valid byte, respectively.
* Both indices increase monotonically (except for rollover).
*
* Messages take the form of [(u32)length] [(char)data0,1,...] in which the
* length specifies the number of payload bytes. Messages must be 4 byte
* aligned, so padding is added at the end of a message as needed.
*
* Print format:
* - 0xXX, 0xXX, 0xXX
* - 0xXX
* etc...
*/
static u32 msm_rpm_log_copy(const struct msm_rpm_log_platform_data *pdata,
char *msg_buffer, u32 buf_len, u32 *read_idx)
{
u32 head_idx, tail_idx;
u32 pos = 0;
u32 i = 0;
u32 msg_len;
u32 pos_start;
char temp[4];
tail_idx = msm_rpm_log_read(pdata, MSM_RPM_LOG_PAGE_INDICES,
MSM_RPM_LOG_TAIL);
head_idx = msm_rpm_log_read(pdata, MSM_RPM_LOG_PAGE_INDICES,
MSM_RPM_LOG_HEAD);
while (tail_idx - head_idx > 0 && tail_idx - *read_idx > 0) {
head_idx = msm_rpm_log_read(pdata, MSM_RPM_LOG_PAGE_INDICES,
MSM_RPM_LOG_HEAD);
if (tail_idx - *read_idx > tail_idx - head_idx) {
*read_idx = head_idx;
continue;
}
if (tail_idx - head_idx > pdata->log_len ||
!IS_ALIGNED((tail_idx | head_idx | *read_idx), 4))
break;
msg_len = msm_rpm_log_read(pdata, MSM_RPM_LOG_PAGE_BUFFER,
(*read_idx >> 2) & pdata->log_len_mask);
if (PADDED_LENGTH(msg_len) > tail_idx - *read_idx - 4)
msg_len = tail_idx - *read_idx - 4;
if (pos + PRINTED_LENGTH(msg_len) > buf_len)
break;
pos_start = pos;
pos += scnprintf(msg_buffer + pos, buf_len - pos, "- ");
for (i = 0; i < msg_len; i++) {
if (IS_ALIGNED(i, 4))
*((u32 *)temp) = msm_rpm_log_read(pdata,
MSM_RPM_LOG_PAGE_BUFFER,
((*read_idx + 4 + i) >> 2) &
pdata->log_len_mask);
pos += scnprintf(msg_buffer + pos, buf_len - pos,
"0x%02X, ", temp[i & 0x03]);
}
pos += scnprintf(msg_buffer + pos, buf_len - pos, "\n");
head_idx = msm_rpm_log_read(pdata, MSM_RPM_LOG_PAGE_INDICES,
MSM_RPM_LOG_HEAD);
if (tail_idx - *read_idx > tail_idx - head_idx)
pos = pos_start;
*read_idx += PADDED_LENGTH(msg_len) + 4;
}
return pos;
}
示例2: scnprintf
/*
* There's very little reason to use this, you should really
* have a struct block_device just about everywhere and use
* bdevname() instead.
*/
const char *__bdevname(dev_t dev, char *buffer)
{
scnprintf(buffer, BDEVNAME_SIZE, "unknown-block(%u,%u)",
MAJOR(dev), MINOR(dev));
return buffer;
}
示例3: qos_if_dls_mac
static ssize_t qos_if_dls_mac(const struct ieee80211_sub_if_data *sdata,
char *buf, int buflen)
{
return scnprintf(buf, buflen, MAC_FMT "\n",
MAC_ARG(sdata->u.sta.dls_mac));
}
示例4: ins__raw_scnprintf
static int ins__raw_scnprintf(struct ins *ins, char *bf, size_t size,
struct ins_operands *ops)
{
return scnprintf(bf, size, "%-6.6s %s", ins->name, ops->raw);
}
示例5: acpi_pad_idlepct_show
static ssize_t acpi_pad_idlepct_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
return scnprintf(buf, PAGE_SIZE, "%d\n", idle_pct);
}
示例6: il_dbgfs_interrupt_read
static ssize_t
il_dbgfs_interrupt_read(struct file *file, char __user *user_buf, size_t count,
loff_t *ppos)
{
struct il_priv *il = file->private_data;
int pos = 0;
int cnt = 0;
char *buf;
int bufsz = 24 * 64; /* 24 items * 64 char per item */
ssize_t ret;
buf = kzalloc(bufsz, GFP_KERNEL);
if (!buf) {
IL_ERR("Can not allocate Buffer\n");
return -ENOMEM;
}
pos +=
scnprintf(buf + pos, bufsz - pos, "Interrupt Statistics Report:\n");
pos +=
scnprintf(buf + pos, bufsz - pos, "HW Error:\t\t\t %u\n",
il->isr_stats.hw);
pos +=
scnprintf(buf + pos, bufsz - pos, "SW Error:\t\t\t %u\n",
il->isr_stats.sw);
if (il->isr_stats.sw || il->isr_stats.hw) {
pos +=
scnprintf(buf + pos, bufsz - pos,
"\tLast Restarting Code: 0x%X\n",
il->isr_stats.err_code);
}
#ifdef CONFIG_IWLEGACY_DEBUG
pos +=
scnprintf(buf + pos, bufsz - pos, "Frame transmitted:\t\t %u\n",
il->isr_stats.sch);
pos +=
scnprintf(buf + pos, bufsz - pos, "Alive interrupt:\t\t %u\n",
il->isr_stats.alive);
#endif
pos +=
scnprintf(buf + pos, bufsz - pos,
"HW RF KILL switch toggled:\t %u\n",
il->isr_stats.rfkill);
pos +=
scnprintf(buf + pos, bufsz - pos, "CT KILL:\t\t\t %u\n",
il->isr_stats.ctkill);
pos +=
scnprintf(buf + pos, bufsz - pos, "Wakeup Interrupt:\t\t %u\n",
il->isr_stats.wakeup);
pos +=
scnprintf(buf + pos, bufsz - pos, "Rx command responses:\t\t %u\n",
il->isr_stats.rx);
for (cnt = 0; cnt < IL_CN_MAX; cnt++) {
if (il->isr_stats.handlers[cnt] > 0)
pos +=
scnprintf(buf + pos, bufsz - pos,
"\tRx handler[%36s]:\t\t %u\n",
il_get_cmd_string(cnt),
il->isr_stats.handlers[cnt]);
}
pos +=
scnprintf(buf + pos, bufsz - pos, "Tx/FH interrupt:\t\t %u\n",
il->isr_stats.tx);
pos +=
scnprintf(buf + pos, bufsz - pos, "Unexpected INTA:\t\t %u\n",
il->isr_stats.unhandled);
ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
kfree(buf);
return ret;
}
示例7: p9_printfcall
int
p9_printfcall(char *buf, int buflen, struct p9_fcall *fc, int extended)
{
int i, ret, type, tag;
if (!fc)
return scnprintf(buf, buflen, "<NULL>");
type = fc->id;
tag = fc->tag;
ret = 0;
switch (type) {
case P9_TVERSION:
ret += scnprintf(buf+ret, buflen-ret,
"Tversion tag %u msize %u version '%.*s'", tag,
fc->params.tversion.msize,
fc->params.tversion.version.len,
fc->params.tversion.version.str);
break;
case P9_RVERSION:
ret += scnprintf(buf+ret, buflen-ret,
"Rversion tag %u msize %u version '%.*s'", tag,
fc->params.rversion.msize,
fc->params.rversion.version.len,
fc->params.rversion.version.str);
break;
case P9_TAUTH:
ret += scnprintf(buf+ret, buflen-ret,
"Tauth tag %u afid %d uname '%.*s' aname '%.*s'", tag,
fc->params.tauth.afid, fc->params.tauth.uname.len,
fc->params.tauth.uname.str, fc->params.tauth.aname.len,
fc->params.tauth.aname.str);
break;
case P9_RAUTH:
ret += scnprintf(buf+ret, buflen-ret, "Rauth tag %u qid ", tag);
p9_printqid(buf+ret, buflen-ret, &fc->params.rauth.qid);
break;
case P9_TATTACH:
ret += scnprintf(buf+ret, buflen-ret,
"Tattach tag %u fid %d afid %d uname '%.*s' aname '%.*s'", tag,
fc->params.tattach.fid, fc->params.tattach.afid,
fc->params.tattach.uname.len, fc->params.tattach.uname.str,
fc->params.tattach.aname.len, fc->params.tattach.aname.str);
break;
case P9_RATTACH:
ret += scnprintf(buf+ret, buflen-ret, "Rattach tag %u qid ",
tag);
p9_printqid(buf+ret, buflen-ret, &fc->params.rattach.qid);
break;
case P9_RERROR:
ret += scnprintf(buf+ret, buflen-ret,
"Rerror tag %u ename '%.*s'", tag,
fc->params.rerror.error.len,
fc->params.rerror.error.str);
if (extended)
ret += scnprintf(buf+ret, buflen-ret, " ecode %d\n",
fc->params.rerror.errno);
break;
case P9_TFLUSH:
ret += scnprintf(buf+ret, buflen-ret, "Tflush tag %u oldtag %u",
tag, fc->params.tflush.oldtag);
break;
case P9_RFLUSH:
ret += scnprintf(buf+ret, buflen-ret, "Rflush tag %u", tag);
break;
case P9_TWALK:
ret += scnprintf(buf+ret, buflen-ret,
"Twalk tag %u fid %d newfid %d nwname %d", tag,
fc->params.twalk.fid, fc->params.twalk.newfid,
fc->params.twalk.nwname);
for (i = 0; i < fc->params.twalk.nwname; i++)
ret += scnprintf(buf+ret, buflen-ret, " '%.*s'",
fc->params.twalk.wnames[i].len,
fc->params.twalk.wnames[i].str);
break;
case P9_RWALK:
ret += scnprintf(buf+ret, buflen-ret, "Rwalk tag %u nwqid %d",
tag, fc->params.rwalk.nwqid);
for (i = 0; i < fc->params.rwalk.nwqid; i++)
ret += p9_printqid(buf+ret, buflen-ret,
&fc->params.rwalk.wqids[i]);
break;
case P9_TOPEN:
ret += scnprintf(buf+ret, buflen-ret,
"Topen tag %u fid %d mode %d", tag,
fc->params.topen.fid, fc->params.topen.mode);
break;
//.........这里部分代码省略.........
示例8: debug_test_smsm
static int debug_test_smsm(char *buf, int max)
{
int i = 0;
int test_num = 0;
int ret;
/* Test case 1 - Register new callback for notification */
do {
test_num++;
SMSM_CB_TEST_INIT();
ret = smsm_state_cb_register(SMSM_APPS_STATE, SMSM_SMDINIT,
smsm_state_cb, (void *)0x1234);
UT_EQ_INT(ret, 0);
/* de-assert SMSM_SMD_INIT to trigger state update */
UT_EQ_INT(smsm_cb_data.cb_count, 0);
INIT_COMPLETION(smsm_cb_completion);
smsm_change_state(SMSM_APPS_STATE, SMSM_SMDINIT, 0x0);
UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion,
msecs_to_jiffies(20)), 0);
UT_EQ_INT(smsm_cb_data.cb_count, 1);
UT_EQ_INT(smsm_cb_data.old_state & SMSM_SMDINIT, SMSM_SMDINIT);
UT_EQ_INT(smsm_cb_data.new_state & SMSM_SMDINIT, 0x0);
UT_EQ_INT((int)smsm_cb_data.data, 0x1234);
/* re-assert SMSM_SMD_INIT to trigger state update */
INIT_COMPLETION(smsm_cb_completion);
smsm_change_state(SMSM_APPS_STATE, 0x0, SMSM_SMDINIT);
UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion,
msecs_to_jiffies(20)), 0);
UT_EQ_INT(smsm_cb_data.cb_count, 2);
UT_EQ_INT(smsm_cb_data.old_state & SMSM_SMDINIT, 0x0);
UT_EQ_INT(smsm_cb_data.new_state & SMSM_SMDINIT, SMSM_SMDINIT);
/* deregister callback */
ret = smsm_state_cb_deregister(SMSM_APPS_STATE, SMSM_SMDINIT,
smsm_state_cb, (void *)0x1234);
UT_EQ_INT(ret, 2);
/* make sure state change doesn't cause any more callbacks */
INIT_COMPLETION(smsm_cb_completion);
smsm_change_state(SMSM_APPS_STATE, SMSM_SMDINIT, 0x0);
smsm_change_state(SMSM_APPS_STATE, 0x0, SMSM_SMDINIT);
UT_EQ_INT((int)wait_for_completion_timeout(&smsm_cb_completion,
msecs_to_jiffies(20)), 0);
UT_EQ_INT(smsm_cb_data.cb_count, 2);
i += scnprintf(buf + i, max - i, "Test %d - PASS\n", test_num);
} while (0);
/* Test case 2 - Update already registered callback */
do {
test_num++;
SMSM_CB_TEST_INIT();
ret = smsm_state_cb_register(SMSM_APPS_STATE, SMSM_SMDINIT,
smsm_state_cb, (void *)0x1234);
UT_EQ_INT(ret, 0);
ret = smsm_state_cb_register(SMSM_APPS_STATE, SMSM_INIT,
smsm_state_cb, (void *)0x1234);
UT_EQ_INT(ret, 1);
/* verify both callback bits work */
INIT_COMPLETION(smsm_cb_completion);
UT_EQ_INT(smsm_cb_data.cb_count, 0);
smsm_change_state(SMSM_APPS_STATE, SMSM_SMDINIT, 0x0);
UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion,
msecs_to_jiffies(20)), 0);
UT_EQ_INT(smsm_cb_data.cb_count, 1);
INIT_COMPLETION(smsm_cb_completion);
smsm_change_state(SMSM_APPS_STATE, 0x0, SMSM_SMDINIT);
UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion,
msecs_to_jiffies(20)), 0);
UT_EQ_INT(smsm_cb_data.cb_count, 2);
INIT_COMPLETION(smsm_cb_completion);
smsm_change_state(SMSM_APPS_STATE, SMSM_INIT, 0x0);
UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion,
msecs_to_jiffies(20)), 0);
UT_EQ_INT(smsm_cb_data.cb_count, 3);
INIT_COMPLETION(smsm_cb_completion);
smsm_change_state(SMSM_APPS_STATE, 0x0, SMSM_INIT);
UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion,
msecs_to_jiffies(20)), 0);
UT_EQ_INT(smsm_cb_data.cb_count, 4);
/* deregister 1st callback */
ret = smsm_state_cb_deregister(SMSM_APPS_STATE, SMSM_SMDINIT,
smsm_state_cb, (void *)0x1234);
UT_EQ_INT(ret, 1);
INIT_COMPLETION(smsm_cb_completion);
smsm_change_state(SMSM_APPS_STATE, SMSM_SMDINIT, 0x0);
smsm_change_state(SMSM_APPS_STATE, 0x0, SMSM_SMDINIT);
UT_EQ_INT((int)wait_for_completion_timeout(&smsm_cb_completion,
msecs_to_jiffies(20)), 0);
UT_EQ_INT(smsm_cb_data.cb_count, 4);
INIT_COMPLETION(smsm_cb_completion);
smsm_change_state(SMSM_APPS_STATE, SMSM_INIT, 0x0);
UT_GT_INT((int)wait_for_completion_timeout(&smsm_cb_completion,
//.........这里部分代码省略.........
示例9: FIX_PTR
static char *arc_cpu_mumbojumbo(int cpu_id, char *buf, int len)
{
struct cpuinfo_arc *cpu = &cpuinfo_arc700[cpu_id];
struct bcr_identity *core = &cpu->core;
const struct cpuinfo_data *tbl;
char *isa_nm;
int i, be, atomic;
int n = 0;
FIX_PTR(cpu);
if (is_isa_arcompact()) {
isa_nm = "ARCompact";
be = IS_ENABLED(CONFIG_CPU_BIG_ENDIAN);
atomic = cpu->isa.atomic1;
if (!cpu->isa.ver) /* ISA BCR absent, use Kconfig info */
atomic = IS_ENABLED(CONFIG_ARC_HAS_LLSC);
} else {
isa_nm = "ARCv2";
be = cpu->isa.be;
atomic = cpu->isa.atomic;
}
n += scnprintf(buf + n, len - n,
"\nIDENTITY\t: ARCVER [%#02x] ARCNUM [%#02x] CHIPID [%#4x]\n",
core->family, core->cpu_id, core->chip_id);
for (tbl = &arc_cpu_tbl[0]; tbl->info.id != 0; tbl++) {
if ((core->family >= tbl->info.id) &&
(core->family <= tbl->up_range)) {
n += scnprintf(buf + n, len - n,
"processor [%d]\t: %s (%s ISA) %s\n",
cpu_id, tbl->info.str, isa_nm,
IS_AVAIL1(be, "[Big-Endian]"));
break;
}
}
if (tbl->info.id == 0)
n += scnprintf(buf + n, len - n, "UNKNOWN ARC Processor\n");
n += scnprintf(buf + n, len - n, "CPU speed\t: %u.%02u Mhz\n",
(unsigned int)(arc_get_core_freq() / 1000000),
(unsigned int)(arc_get_core_freq() / 10000) % 100);
n += scnprintf(buf + n, len - n, "Timers\t\t: %s%s%s%s\nISA Extn\t: ",
IS_AVAIL1(cpu->timers.t0, "Timer0 "),
IS_AVAIL1(cpu->timers.t1, "Timer1 "),
IS_AVAIL2(cpu->timers.rtc, "64-bit RTC ",
CONFIG_ARC_HAS_RTC));
n += i = scnprintf(buf + n, len - n, "%s%s%s%s%s",
IS_AVAIL2(atomic, "atomic ", CONFIG_ARC_HAS_LLSC),
IS_AVAIL2(cpu->isa.ldd, "ll64 ", CONFIG_ARC_HAS_LL64),
IS_AVAIL1(cpu->isa.unalign, "unalign (not used)"));
if (i)
n += scnprintf(buf + n, len - n, "\n\t\t: ");
if (cpu->extn_mpy.ver) {
if (cpu->extn_mpy.ver <= 0x2) { /* ARCompact */
n += scnprintf(buf + n, len - n, "mpy ");
} else {
int opt = 2; /* stock MPY/MPYH */
if (cpu->extn_mpy.dsp) /* OPT 7-9 */
opt = cpu->extn_mpy.dsp + 6;
n += scnprintf(buf + n, len - n, "mpy[opt %d] ", opt);
}
n += scnprintf(buf + n, len - n, "%s",
IS_USED_CFG(CONFIG_ARC_HAS_HW_MPY));
}
n += scnprintf(buf + n, len - n, "%s%s%s%s%s%s%s%s\n",
IS_AVAIL1(cpu->isa.div_rem, "div_rem "),
IS_AVAIL1(cpu->extn.norm, "norm "),
IS_AVAIL1(cpu->extn.barrel, "barrel-shift "),
IS_AVAIL1(cpu->extn.swap, "swap "),
IS_AVAIL1(cpu->extn.minmax, "minmax "),
IS_AVAIL1(cpu->extn.crc, "crc "),
IS_AVAIL2(1, "swape", CONFIG_ARC_HAS_SWAPE));
if (cpu->bpu.ver)
n += scnprintf(buf + n, len - n,
"BPU\t\t: %s%s match, cache:%d, Predict Table:%d\n",
IS_AVAIL1(cpu->bpu.full, "full"),
IS_AVAIL1(!cpu->bpu.full, "partial"),
cpu->bpu.num_cache, cpu->bpu.num_pred);
return buf;
}
示例10: ieee80211_if_fmt_num_buffered_multicast
static ssize_t ieee80211_if_fmt_num_buffered_multicast(
const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
{
return scnprintf(buf, buflen, "%u\n",
skb_queue_len(&sdata->u.ap.ps.bc_buf));
}
示例11: smp2p_item
/**
* Dump individual input/output item pair.
*
* @s: pointer to output file
*/
static void smp2p_item(struct seq_file *s, int remote_pid)
{
struct smp2p_smem *out_ptr;
struct smp2p_smem *in_ptr;
struct smp2p_interrupt_config *int_cfg;
char tmp_buff[64];
int state;
int entry;
struct smp2p_entry_v1 *out_entries = NULL;
struct smp2p_entry_v1 *in_entries = NULL;
int out_valid = 0;
int in_valid = 0;
int_cfg = smp2p_get_interrupt_config();
if (!int_cfg)
return;
if (!int_cfg[remote_pid].is_configured &&
remote_pid != SMP2P_REMOTE_MOCK_PROC)
return;
out_ptr = smp2p_get_out_item(remote_pid, &state);
in_ptr = smp2p_get_in_item(remote_pid);
if (!out_ptr && !in_ptr)
return;
/* print item headers */
seq_printf(s, "%s%s\n",
" ====================================== ",
"======================================");
scnprintf(tmp_buff, sizeof(tmp_buff),
"Apps(%d)->%s(%d)",
SMP2P_APPS_PROC, int_cfg[remote_pid].name, remote_pid);
seq_printf(s, "| %-37s", tmp_buff);
scnprintf(tmp_buff, sizeof(tmp_buff),
"%s(%d)->Apps(%d)",
int_cfg[remote_pid].name, remote_pid, SMP2P_APPS_PROC);
seq_printf(s, "| %-37s|\n", tmp_buff);
seq_printf(s, "%s%s\n",
" ====================================== ",
"======================================");
smp2p_item_header1(tmp_buff, sizeof(tmp_buff), out_ptr, state);
seq_printf(s, "| %-37s", tmp_buff);
smp2p_item_header1(tmp_buff, sizeof(tmp_buff), in_ptr, -1);
seq_printf(s, "| %-37s|\n", tmp_buff);
smp2p_item_header2(tmp_buff, sizeof(tmp_buff), out_ptr);
seq_printf(s, "| %-37s", tmp_buff);
smp2p_item_header2(tmp_buff, sizeof(tmp_buff), in_ptr);
seq_printf(s, "| %-37s|\n", tmp_buff);
smp2p_item_header3(tmp_buff, sizeof(tmp_buff), out_ptr);
seq_printf(s, "| %-37s", tmp_buff);
smp2p_item_header3(tmp_buff, sizeof(tmp_buff), in_ptr);
seq_printf(s, "| %-37s|\n", tmp_buff);
seq_printf(s, " %s%s\n",
"-------------------------------------- ",
"--------------------------------------");
seq_printf(s, "| %-37s",
"Entry Name Value");
seq_printf(s, "| %-37s|\n",
"Entry Name Value");
seq_printf(s, " %s%s\n",
"-------------------------------------- ",
"--------------------------------------");
/* print entries */
if (out_ptr) {
out_entries = (struct smp2p_entry_v1 *)((void *)out_ptr +
sizeof(struct smp2p_smem));
out_valid = SMP2P_GET_ENT_VALID(out_ptr->valid_total_ent);
}
if (in_ptr) {
in_entries = (struct smp2p_entry_v1 *)((void *)in_ptr +
sizeof(struct smp2p_smem));
in_valid = SMP2P_GET_ENT_VALID(in_ptr->valid_total_ent);
}
for (entry = 0; out_entries || in_entries; ++entry) {
if (out_entries && entry < out_valid) {
scnprintf(tmp_buff, sizeof(tmp_buff),
"%-16s 0x%08x",
out_entries->name,
out_entries->entry);
++out_entries;
} else {
out_entries = NULL;
scnprintf(tmp_buff, sizeof(tmp_buff), "None");
}
seq_printf(s, "| %-37s", tmp_buff);
//.........这里部分代码省略.........
示例12: read_file_antenna_diversity
static ssize_t read_file_antenna_diversity(struct file *file,
char __user *user_buf,
size_t count, loff_t *ppos)
{
struct ath_softc *sc = file->private_data;
struct ath_hw *ah = sc->sc_ah;
struct ath9k_hw_capabilities *pCap = &ah->caps;
struct ath_antenna_stats *as_main = &sc->debug.stats.ant_stats[ANT_MAIN];
struct ath_antenna_stats *as_alt = &sc->debug.stats.ant_stats[ANT_ALT];
struct ath_hw_antcomb_conf div_ant_conf;
unsigned int len = 0;
const unsigned int size = 1024;
ssize_t retval = 0;
char *buf;
static const char *lna_conf_str[4] = {
"LNA1_MINUS_LNA2", "LNA2", "LNA1", "LNA1_PLUS_LNA2"
};
buf = kzalloc(size, GFP_KERNEL);
if (buf == NULL)
return -ENOMEM;
if (!(pCap->hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB)) {
len += scnprintf(buf + len, size - len, "%s\n",
"Antenna Diversity Combining is disabled");
goto exit;
}
ath9k_ps_wakeup(sc);
ath9k_hw_antdiv_comb_conf_get(ah, &div_ant_conf);
len += scnprintf(buf + len, size - len, "Current MAIN config : %s\n",
lna_conf_str[div_ant_conf.main_lna_conf]);
len += scnprintf(buf + len, size - len, "Current ALT config : %s\n",
lna_conf_str[div_ant_conf.alt_lna_conf]);
len += scnprintf(buf + len, size - len, "Average MAIN RSSI : %d\n",
as_main->rssi_avg);
len += scnprintf(buf + len, size - len, "Average ALT RSSI : %d\n\n",
as_alt->rssi_avg);
ath9k_ps_restore(sc);
len += scnprintf(buf + len, size - len, "Packet Receive Cnt:\n");
len += scnprintf(buf + len, size - len, "-------------------\n");
len += scnprintf(buf + len, size - len, "%30s%15s\n",
"MAIN", "ALT");
len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
"TOTAL COUNT",
as_main->recv_cnt,
as_alt->recv_cnt);
len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
"LNA1",
as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1],
as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1]);
len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
"LNA2",
as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA2],
as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA2]);
len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
"LNA1 + LNA2",
as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2],
as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2]);
len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
"LNA1 - LNA2",
as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2],
as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2]);
len += scnprintf(buf + len, size - len, "\nLNA Config Attempts:\n");
len += scnprintf(buf + len, size - len, "--------------------\n");
len += scnprintf(buf + len, size - len, "%30s%15s\n",
"MAIN", "ALT");
len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
"LNA1",
as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1],
as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1]);
len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
"LNA2",
as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA2],
as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA2]);
len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
"LNA1 + LNA2",
as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2],
as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2]);
len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
"LNA1 - LNA2",
as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2],
as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2]);
exit:
if (len > size)
len = size;
retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
kfree(buf);
return retval;
}
示例13: iwl_print_event_log
/**
* iwl_print_event_log - Dump error event log to syslog
*
*/
static int iwl_print_event_log(struct iwl_trans *trans, u32 start_idx,
u32 num_events, u32 mode,
int pos, char **buf, size_t bufsz)
{
u32 i;
u32 base; /* SRAM byte address of event log header */
u32 event_size; /* 2 u32s, or 3 u32s if timestamp recorded */
u32 ptr; /* SRAM byte address of log data */
u32 ev, time, data; /* event log data */
unsigned long reg_flags;
if (num_events == 0)
return pos;
base = trans->shrd->device_pointers.log_event_table;
if (trans->shrd->ucode_type == IWL_UCODE_INIT) {
if (!base)
base = trans->shrd->fw->init_evtlog_ptr;
} else {
if (!base)
base = trans->shrd->fw->inst_evtlog_ptr;
}
if (mode == 0)
event_size = 2 * sizeof(u32);
else
event_size = 3 * sizeof(u32);
ptr = base + EVENT_START_OFFSET + (start_idx * event_size);
/* Make sure device is powered up for SRAM reads */
spin_lock_irqsave(&trans->reg_lock, reg_flags);
if (unlikely(!iwl_grab_nic_access(trans)))
goto out_unlock;
/* Set starting address; reads will auto-increment */
iwl_write32(trans, HBUS_TARG_MEM_RADDR, ptr);
/* "time" is actually "data" for mode 0 (no timestamp).
* place event id # at far right for easier visual parsing. */
for (i = 0; i < num_events; i++) {
ev = iwl_read32(trans, HBUS_TARG_MEM_RDAT);
time = iwl_read32(trans, HBUS_TARG_MEM_RDAT);
if (mode == 0) {
/* data, ev */
if (bufsz) {
pos += scnprintf(*buf + pos, bufsz - pos,
"EVT_LOG:0x%08x:%04u\n",
time, ev);
} else {
trace_iwlwifi_dev_ucode_event(trans->dev, 0,
time, ev);
IWL_ERR(trans, "EVT_LOG:0x%08x:%04u\n",
time, ev);
}
} else {
data = iwl_read32(trans, HBUS_TARG_MEM_RDAT);
if (bufsz) {
pos += scnprintf(*buf + pos, bufsz - pos,
"EVT_LOGT:%010u:0x%08x:%04u\n",
time, data, ev);
} else {
IWL_ERR(trans, "EVT_LOGT:%010u:0x%08x:%04u\n",
time, data, ev);
trace_iwlwifi_dev_ucode_event(trans->dev, time,
data, ev);
}
}
}
/* Allow device to power down */
iwl_release_nic_access(trans);
out_unlock:
spin_unlock_irqrestore(&trans->reg_lock, reg_flags);
return pos;
}
示例14: dso__read_binary_type_filename
int dso__read_binary_type_filename(const struct dso *dso,
enum dso_binary_type type,
char *root_dir, char *filename, size_t size)
{
char build_id_hex[BUILD_ID_SIZE * 2 + 1];
int ret = 0;
switch (type) {
case DSO_BINARY_TYPE__DEBUGLINK: {
char *debuglink;
strncpy(filename, dso->long_name, size);
debuglink = filename + dso->long_name_len;
while (debuglink != filename && *debuglink != '/')
debuglink--;
if (*debuglink == '/')
debuglink++;
filename__read_debuglink(dso->long_name, debuglink,
size - (debuglink - filename));
}
break;
case DSO_BINARY_TYPE__BUILD_ID_CACHE:
/* skip the locally configured cache if a symfs is given */
if (symbol_conf.symfs[0] ||
(dso__build_id_filename(dso, filename, size) == NULL))
ret = -1;
break;
case DSO_BINARY_TYPE__FEDORA_DEBUGINFO:
snprintf(filename, size, "%s/usr/lib/debug%s.debug",
symbol_conf.symfs, dso->long_name);
break;
case DSO_BINARY_TYPE__UBUNTU_DEBUGINFO:
snprintf(filename, size, "%s/usr/lib/debug%s",
symbol_conf.symfs, dso->long_name);
break;
case DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO:
{
const char *last_slash;
size_t len;
size_t dir_size;
last_slash = dso->long_name + dso->long_name_len;
while (last_slash != dso->long_name && *last_slash != '/')
last_slash--;
len = scnprintf(filename, size, "%s", symbol_conf.symfs);
dir_size = last_slash - dso->long_name + 2;
if (dir_size > (size - len)) {
ret = -1;
break;
}
len += scnprintf(filename + len, dir_size, "%s", dso->long_name);
len += scnprintf(filename + len , size - len, ".debug%s",
last_slash);
break;
}
case DSO_BINARY_TYPE__BUILDID_DEBUGINFO:
if (!dso->has_build_id) {
ret = -1;
break;
}
build_id__sprintf(dso->build_id,
sizeof(dso->build_id),
build_id_hex);
snprintf(filename, size,
"%s/usr/lib/debug/.build-id/%.2s/%s.debug",
symbol_conf.symfs, build_id_hex, build_id_hex + 2);
break;
case DSO_BINARY_TYPE__VMLINUX:
case DSO_BINARY_TYPE__GUEST_VMLINUX:
case DSO_BINARY_TYPE__SYSTEM_PATH_DSO:
snprintf(filename, size, "%s%s",
symbol_conf.symfs, dso->long_name);
break;
case DSO_BINARY_TYPE__GUEST_KMODULE:
snprintf(filename, size, "%s%s%s", symbol_conf.symfs,
root_dir, dso->long_name);
break;
case DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE:
snprintf(filename, size, "%s%s", symbol_conf.symfs,
dso->long_name);
break;
case DSO_BINARY_TYPE__KCORE:
case DSO_BINARY_TYPE__GUEST_KCORE:
snprintf(filename, size, "%s", dso->long_name);
break;
default:
case DSO_BINARY_TYPE__KALLSYMS:
case DSO_BINARY_TYPE__GUEST_KALLSYMS:
case DSO_BINARY_TYPE__JAVA_JIT:
//.........这里部分代码省略.........
示例15: il_dbgfs_channels_read
static ssize_t
il_dbgfs_channels_read(struct file *file, char __user *user_buf, size_t count,
loff_t *ppos)
{
struct il_priv *il = file->private_data;
struct ieee80211_channel *channels = NULL;
const struct ieee80211_supported_band *supp_band = NULL;
int pos = 0, i, bufsz = PAGE_SIZE;
char *buf;
ssize_t ret;
if (!test_bit(S_GEO_CONFIGURED, &il->status))
return -EAGAIN;
buf = kzalloc(bufsz, GFP_KERNEL);
if (!buf) {
IL_ERR("Can not allocate Buffer\n");
return -ENOMEM;
}
supp_band = il_get_hw_mode(il, IEEE80211_BAND_2GHZ);
if (supp_band) {
channels = supp_band->channels;
pos +=
scnprintf(buf + pos, bufsz - pos,
"Displaying %d channels in 2.4GHz band 802.11bg):\n",
supp_band->n_channels);
for (i = 0; i < supp_band->n_channels; i++)
pos +=
scnprintf(buf + pos, bufsz - pos,
"%d: %ddBm: BSS%s%s, %s.\n",
channels[i].hw_value,
channels[i].max_power,
channels[i].
flags & IEEE80211_CHAN_RADAR ?
" (IEEE 802.11h required)" : "",
((channels[i].
flags & IEEE80211_CHAN_NO_IR) ||
(channels[i].
flags & IEEE80211_CHAN_RADAR)) ? "" :
", IBSS",
channels[i].
flags & IEEE80211_CHAN_NO_IR ?
"passive only" : "active/passive");
}
supp_band = il_get_hw_mode(il, IEEE80211_BAND_5GHZ);
if (supp_band) {
channels = supp_band->channels;
pos +=
scnprintf(buf + pos, bufsz - pos,
"Displaying %d channels in 5.2GHz band (802.11a)\n",
supp_band->n_channels);
for (i = 0; i < supp_band->n_channels; i++)
pos +=
scnprintf(buf + pos, bufsz - pos,
"%d: %ddBm: BSS%s%s, %s.\n",
channels[i].hw_value,
channels[i].max_power,
channels[i].
flags & IEEE80211_CHAN_RADAR ?
" (IEEE 802.11h required)" : "",
((channels[i].
flags & IEEE80211_CHAN_NO_IR) ||
(channels[i].
flags & IEEE80211_CHAN_RADAR)) ? "" :
", IBSS",
channels[i].
flags & IEEE80211_CHAN_NO_IR ?
"passive only" : "active/passive");
}
ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
kfree(buf);
return ret;
}