tData* get_pBuf(uint8_t sock) { if (IS_BUF_EMPTY(sock)) return NULL; if (IS_BUF_AVAIL(sock)) { tData* p = &(pBufStore[tailBuf[sock]][sock]); INFO_UTIL_VER("%p [%d,%d]\n", p, headBuf[sock], tailBuf[sock]); return p; } return NULL; }
static int _74ls165_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { // unsigned char tmp=0xff; switch(cmd) { case _IOC_GET_VALUE: if(!IS_BUF_EMPTY(&g_value_buf)) { copy_to_user((void __user *)arg, &g_value_buf.value[g_value_buf.read], sizeof(unsigned char)); UPDATE_READ(&g_value_buf); } else { char tmp = 0; copy_to_user((void __user *)arg, &tmp, sizeof(unsigned char)); } break; default: return -1; } return 0; }