static void do_scan(void) { int flg = 1, len; unsigned char *p; int stateid = 0; while(flg || bufpos < buffill) { const short *next_tbl = statemap[stateid]; flg = refill_buf(); for(;;) { if(next_tbl[0] < 0 || next_tbl[0] == buf[bufpos]) { stateid = next_tbl[1]; break; } next_tbl += 2; } bufpos++; if(stateid == STATE_FOUND_PUBKEY || stateid == STATE_FOUND_PUBKEY_2 || stateid == STATE_FOUND_PUBKEY_COMP ) { //printf("Found potential key!\n"); refill_buf(); do_recover_pubkey(); } else if(stateid == STATE_FOUND_PUBKEY_J ) { refill_buf(); do_recover_pubkey_j(); } else if(stateid == STATE_FOUND_PRIVKEY) { refill_buf(); do_recover_privkey(bufpos); } } }
static ssize_t perf_read(struct file *file, char __user *buf, size_t sz, loff_t *ppos) { struct msm_perf_state *perf = file->private_data; int n = 0, ret; mutex_lock(&perf->read_lock); if (perf->bufpos >= perf->buftot) { ret = refill_buf(perf); if (ret) goto out; } n = min((int)sz, perf->buftot - perf->bufpos); ret = copy_to_user(buf, &perf->buf[perf->bufpos], n); if (ret) goto out; perf->bufpos += n; *ppos += n; out: mutex_unlock(&perf->read_lock); if (ret) return ret; return n; }