static void qmi_read_work(struct work_struct *ws) { struct qmi_ctxt *ctxt = container_of(ws, struct qmi_ctxt, read_work); struct smd_channel *ch = ctxt->ch; unsigned char buf[QMI_MAX_PACKET]; int sz; for (;;) { sz = smd_cur_packet_size(ch); if (sz == 0) break; if (sz < smd_read_avail(ch)) break; if (sz > QMI_MAX_PACKET) { smd_read(ch, 0, sz); continue; } if (smd_read(ch, buf, sz) != sz) { printk(KERN_ERR "qmi: not enough data?!\n"); continue; } /* interface selector must be 1 */ if (buf[0] != 0x01) continue; qmi_process_qmux(ctxt, buf + 1, sz - 1); } }
static void qmi_read_work(struct work_struct *ws) { //struct qmi_ctxt *ctxt = container_of(ws, struct qmi_ctxt, read_work); //struct smd_channel *ch = ctxt->ch; unsigned char buf[QMI_MAX_PACKET]; struct qmi_ctxt *ctxt; int sz; uint32_t chnum; for (;;) { sz = smd_cur_packet_size(ctrl_ch); if (sz == 0) break; if (sz < smd_read_avail(ctrl_ch)) break; if (sz > QMI_MAX_PACKET) { smd_read(ctrl_ch, NULL, sz); continue; } if (smd_read(ctrl_ch, buf, sz) != sz) { printk(KERN_ERR "qmi: not enough data?!\n"); continue; } DBG("packet: %d\n", sz); // print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, buf, sz); if (sz <= 4) { DBG("packet size less 4\n"); continue; } chnum = *(uint32_t*)&buf[sz - 4]; DBG("chnum = %d\n", chnum); /* interface selector must be 1 */ if (buf[0] != 0x01) continue; if (qmi_device0.ch_num == chnum) ctxt = &qmi_device0; else if (qmi_device1.ch_num == chnum) ctxt = &qmi_device1; else if (qmi_device2.ch_num == chnum) ctxt = &qmi_device2; else { DBG("bad chnum %d\n", chnum); continue; } qmi_process_qmux(ctxt, buf + 1, sz - 1 - 4); } }