本文整理汇总了C++中smd_read_avail函数的典型用法代码示例。如果您正苦于以下问题:C++ smd_read_avail函数的具体用法?C++ smd_read_avail怎么用?C++ smd_read_avail使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了smd_read_avail函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: smd_vt_release
static int smd_vt_release(struct inode *ip, struct file *fp)
{
int r = 0;
int sz;
unsigned long flags;
printk(KERN_INFO "smd_vt_release\n");
mutex_lock(&smd_vt_ch_lock);
smd_vt_devp->open_count--;
if ((smd_vt_devp->open_count == 0) && (smd_vt_devp->ch != 0)) {
mutex_lock(&smd_vt_rx_buf_lock);
spin_lock_irqsave(&smd_vt_read_lock, flags);
smd_vt_devp->read_avail = 0;
spin_unlock_irqrestore(&smd_vt_read_lock, flags);
sz = smd_cur_packet_size(smd_vt_devp->ch);
while((sz != 0) && (sz <= smd_read_avail(smd_vt_devp->ch))) {
if (sz > MAX_RX_BUF_SIZE) {
smd_read(smd_vt_devp->ch, smd_vt_devp->rx_buf, MAX_RX_BUF_SIZE);
sz= sz -MAX_RX_BUF_SIZE;
}
else{
smd_read(smd_vt_devp->ch, smd_vt_devp->rx_buf, sz);
sz =0;
}
}
mutex_unlock(&smd_vt_rx_buf_lock);
r = smd_close(smd_vt_devp->ch);
smd_vt_devp->ch = 0;
smd_vt_devp->open_flag=0;
}
mutex_unlock(&smd_vt_ch_lock);
return r;
}
示例2: __diag_smd_wcnss_send_req
void __diag_smd_wcnss_send_req(void)
{
void *buf = driver->buf_in_wcnss;
int *in_busy_wcnss_ptr = &(driver->in_busy_wcnss);
struct diag_request *write_ptr_wcnss = driver->write_ptr_wcnss;
#if DIAG_XPST
int type;
#endif
if ((!driver->in_busy_wcnss) && driver->ch_wcnss && buf) {
int r = smd_read_avail(driver->ch_wcnss);
if (r > IN_BUF_SIZE) {
if (r < MAX_IN_BUF_SIZE) {
pr_err("diag: wcnss packets > %d bytes", r);
buf = krealloc(buf, r, GFP_KERNEL);
} else {
pr_err("diag: wcnss pkt > %d", MAX_IN_BUF_SIZE);
return;
}
}
if (r > 0) {
if (!buf) {
pr_err("Out of diagmem for wcnss\n");
} else {
APPEND_DEBUG('i');
smd_read(driver->ch_wcnss, buf, r);
APPEND_DEBUG('j');
#if DIAG_XPST
type = checkcmd_modem_epst(buf);
if (type) {
modem_to_userspace(buf, r, type, 0);
return;
}
#endif
write_ptr_wcnss->length = r;
*in_busy_wcnss_ptr = 1;
diag_device_write(buf, WCNSS_DATA,
write_ptr_wcnss);
}
}
}
}
示例3: grmnet_ctrl_smd_notify
static void grmnet_ctrl_smd_notify(void *p, unsigned event)
{
struct rmnet_ctrl_port *port = p;
struct smd_ch_info *c = &port->ctrl_ch;
struct rmnet_ctrl_pkt *cpkt;
unsigned long flags;
pr_debug("%s: EVENT_(%s)\n", __func__, get_smd_event(event));
switch (event) {
case SMD_EVENT_DATA:
if (smd_read_avail(c->ch))
queue_work(grmnet_ctrl_wq, &c->read_w);
if (smd_write_avail(c->ch))
queue_work(grmnet_ctrl_wq, &c->write_w);
break;
case SMD_EVENT_OPEN:
set_bit(CH_OPENED, &c->flags);
if (port && port->port_usb && port->port_usb->connect)
port->port_usb->connect(port->port_usb);
break;
case SMD_EVENT_CLOSE:
clear_bit(CH_OPENED, &c->flags);
if (port && port->port_usb && port->port_usb->disconnect)
port->port_usb->disconnect(port->port_usb);
spin_lock_irqsave(&port->port_lock, flags);
while (!list_empty(&c->tx_q)) {
cpkt = list_first_entry(&c->tx_q,
struct rmnet_ctrl_pkt, list);
list_del(&cpkt->list);
free_rmnet_ctrl_pkt(cpkt);
}
spin_unlock_irqrestore(&port->port_lock, flags);
break;
}
}
示例4: wcnss_fw_status
static unsigned char wcnss_fw_status(void)
{
int len = 0;
int rc = 0;
unsigned char fw_status = 0xFF;
len = smd_read_avail(penv->smd_ch);
if (len < 1) {
pr_err("%s: invalid firmware status", __func__);
return fw_status;
}
rc = smd_read(penv->smd_ch, &fw_status, 1);
if (rc < 0) {
pr_err("%s: incomplete data read from smd\n", __func__);
return fw_status;
}
return fw_status;
}
示例5: hci_smd_notify_event
static void hci_smd_notify_event(void *data, unsigned int event)
{
struct hci_dev *hdev = hs.hdev;
struct hci_smd_data *hsmd = &hs;
struct work_struct *reset_worker;
int len = 0;
if (!hdev) {
BT_ERR("Frame for unknown HCI device (hdev=NULL)");
return;
}
switch (event) {
case SMD_EVENT_DATA:
len = smd_read_avail(hsmd->event_channel);
if (len > 0)
tasklet_hi_schedule(&hs.rx_task);
else if (len < 0)
BT_ERR("Failed to read event from smd %d", len);
break;
case SMD_EVENT_OPEN:
BT_INFO("opening HCI-SMD channel :%s", EVENT_CHANNEL);
hci_smd_open(hdev);
break;
case SMD_EVENT_CLOSE:
BT_INFO("Closing HCI-SMD channel :%s", EVENT_CHANNEL);
hci_smd_close(hdev);
reset_worker = kzalloc(sizeof(*reset_worker), GFP_ATOMIC);
if (!reset_worker) {
BT_ERR("Out of memory");
break;
}
INIT_WORK(reset_worker, hci_dev_restart);
schedule_work(reset_worker);
break;
default:
break;
}
}
示例6: smd_try_to_send
static void smd_try_to_send(struct diag_context *ctxt)
{
if (ctxt->ch) {
int r = smd_read_avail(ctxt->ch);
if (r > RXN_MAX) {
printk(KERN_ERR "The SMD data is too large to send (%d) !!\n", r);
r = RXN_MAX;
}
if (r > 0) {
struct diag_request *req = get_req(ctxt, &ctxt->rx_arm9_idle);
if (!req) {
printk(KERN_ERR "There is no enough request to ARM11!!\n");
return;
}
smd_read(ctxt->ch, req->buf, r);
smd_xfer_count_func(r, data_set_rx);
req->actual = r;
put_req(ctxt, &ctxt->rx_arm9_done, req);
wake_up(&ctxt->read_arm9_wq);
}
}
}
示例7: grmnet_ctrl_smd_read_w
static void grmnet_ctrl_smd_read_w(struct work_struct *w)
{
struct smd_ch_info *c = container_of(w, struct smd_ch_info, read_w);
struct rmnet_ctrl_port *port = c->port;
int sz;
size_t len;
void *buf;
unsigned long flags;
spin_lock_irqsave(&port->port_lock, flags);
while (c->ch) {
if (c->ch == NULL)
break;
sz = smd_cur_packet_size(c->ch);
if (sz <= 0)
break;
if (smd_read_avail(c->ch) < sz)
break;
spin_unlock_irqrestore(&port->port_lock, flags);
buf = kmalloc(sz, GFP_KERNEL);
if (!buf)
return;
len = smd_read(c->ch, buf, sz);
/* send it to USB here */
spin_lock_irqsave(&port->port_lock, flags);
if (port->port_usb && port->port_usb->send_cpkt_response) {
port->port_usb->send_cpkt_response(port->port_usb,
buf, len);
c->to_host++;
}
kfree(buf);
}
spin_unlock_irqrestore(&port->port_lock, flags);
}
示例8: __diag_smd_send_req
void __diag_smd_send_req(int context)
{
void *buf;
if (driver->ch && (!driver->in_busy)) {
int r = smd_read_avail(driver->ch);
if (r > USB_MAX_IN_BUF) {
if (r < MAX_BUF_SIZE) {
printk(KERN_ALERT "\n diag: SMD sending in "
"packets upto %d bytes", r);
driver->usb_buf_in = krealloc(
driver->usb_buf_in, r, GFP_KERNEL);
} else {
printk(KERN_ALERT "\n diag: SMD sending in "
"packets more than %d bytes", MAX_BUF_SIZE);
return;
}
}
if (r > 0) {
buf = driver->usb_buf_in;
if (!buf) {
printk(KERN_INFO "Out of diagmem for a9\n");
} else {
APPEND_DEBUG('i');
if (context == SMD_CONTEXT)
smd_read_from_cb(driver->ch, buf, r);
else
smd_read(driver->ch, buf, r);
APPEND_DEBUG('j');
driver->usb_write_ptr->length = r;
driver->in_busy = 1;
diag_device_write(buf, MODEM_DATA);
}
}
}
}
示例9: wcn36xx_smd_work
static void wcn36xx_smd_work(struct work_struct *work)
{
int msg_len;
int avail;
void *msg;
int ret;
struct wcn36xx *wcn =
container_of(work, struct wcn36xx, smd_work);
if (!wcn)
return;
while (1) {
msg_len = smd_cur_packet_size(wcn->smd_ch);
if (0 == msg_len) {
complete(&wcn->smd_compl);
return;
}
avail = smd_read_avail(wcn->smd_ch);
if (avail < msg_len) {
complete(&wcn->smd_compl);
return;
}
msg = kmalloc(msg_len, GFP_KERNEL);
if (NULL == msg) {
complete(&wcn->smd_compl);
return;
}
ret = smd_read(wcn->smd_ch, msg, msg_len);
if (ret != msg_len) {
complete(&wcn->smd_compl);
return;
}
wcn36xx_smd_rsp_process(wcn, msg, msg_len);
kfree(msg);
}
}
示例10: qmi_notify
static void qmi_notify(void *priv, unsigned event)
{
struct qmi_ctxt *ctxt = priv;
switch (event) {
case SMD_EVENT_DATA: {
int sz;
sz = smd_cur_packet_size(ctxt->ch);
if ((sz > 0) && (sz <= smd_read_avail(ctxt->ch))) {
wake_lock_timeout(&ctxt->wake_lock, HZ / 2);
queue_work(qmi_wq, &ctxt->read_work);
}
break;
}
case SMD_EVENT_OPEN:
printk(KERN_INFO "qmi: smd opened\n");
queue_work(qmi_wq, &ctxt->open_work);
break;
case SMD_EVENT_CLOSE:
printk(KERN_INFO "qmi: smd closed\n");
break;
}
}
示例11: grmnet_ctrl_smd_notify
static void grmnet_ctrl_smd_notify(void *p, unsigned event)
{
struct rmnet_ctrl_port *port = p;
struct smd_ch_info *c = &port->ctrl_ch;
pr_debug("%s: EVENT_(%s)\n", __func__, get_smd_event(event));
switch (event) {
case SMD_EVENT_DATA:
if (smd_read_avail(c->ch))
queue_work(grmnet_ctrl_wq, &c->read_w);
if (smd_write_avail(c->ch))
queue_work(grmnet_ctrl_wq, &c->write_w);
break;
case SMD_EVENT_OPEN:
set_bit(CH_OPENED, &c->flags);
wake_up(&c->wait);
break;
case SMD_EVENT_CLOSE:
clear_bit(CH_OPENED, &c->flags);
break;
}
}
示例12: diag_smd_wcnss_cntl_notify
void diag_smd_wcnss_cntl_notify(void *ctxt, unsigned event)
{
int r1, r2;
if (!(driver->ch_wcnss_cntl))
return;
switch (event) {
case SMD_EVENT_DATA:
r1 = smd_read_avail(driver->ch_wcnss_cntl);
r2 = smd_cur_packet_size(driver->ch_wcnss_cntl);
if (r1 > 0 && r1 == r2)
queue_work(driver->diag_wq,
&(driver->diag_read_smd_wcnss_cntl_work));
else
pr_debug("diag: incomplete pkt on WCNSS CNTL ch\n");
break;
case SMD_EVENT_OPEN:
queue_work(driver->diag_cntl_wq,
&(driver->diag_wcnss_mask_update_work));
break;
}
}
示例13: wcnss_smd_notify_event
static void wcnss_smd_notify_event(void *data, unsigned int event)
{
int len = 0;
if (penv != data) {
pr_err("wcnss: invalid env pointer in smd callback\n");
return;
}
switch (event) {
case SMD_EVENT_DATA:
len = smd_read_avail(penv->smd_ch);
if (len < 0) {
pr_err("wcnss: failed to read from smd %d\n", len);
return;
}
schedule_work(&penv->wcnssctrl_rx_work);
break;
case SMD_EVENT_OPEN:
pr_debug("wcnss: opening WCNSS SMD channel :%s",
WCNSS_CTRL_CHANNEL);
schedule_work(&penv->wcnssctrl_version_work);
break;
case SMD_EVENT_CLOSE:
pr_debug("wcnss: closing WCNSS SMD channel :%s",
WCNSS_CTRL_CHANNEL);
/* This SMD is closed only during SSR */
penv->ssr_boot = true;
penv->nv_downloaded = 0;
break;
default:
break;
}
}
示例14: ssm_app_modem_work_fn
static void ssm_app_modem_work_fn(struct work_struct *work)
{
int sz, rc;
struct ssm_common_msg pkt;
struct ssm_driver *ssm;
ssm = container_of(work, struct ssm_driver, ipc_work);
mutex_lock(&ssm->mutex);
sz = smd_cur_packet_size(ssm->ch);
if ((sz < SSM_MSG_FIELD_LEN) || (sz > ATOM_MSG_LEN)) {
dev_dbg(ssm_drv->dev, "Garbled message size\n");
goto unlock;
}
if (smd_read_avail(ssm->ch) < sz) {
dev_err(ssm_drv->dev, "SMD error data in channel\n");
goto unlock;
}
if (smd_read(ssm->ch, ssm->smd_buffer, sz) != sz) {
dev_err(ssm_drv->dev, "Incomplete data\n");
goto unlock;
}
rc = decode_packet(ssm->smd_buffer, &pkt);
if (rc < 0) {
dev_err(ssm_drv->dev, "Corrupted header\n");
goto unlock;
}
process_message(pkt, ssm);
unlock:
mutex_unlock(&ssm->mutex);
}
示例15: smd_tty_read
static void smd_tty_read(unsigned long param)
{
unsigned char *ptr;
int avail;
struct smd_tty_info *info = (struct smd_tty_info *)param;
struct tty_struct *tty = info->tty;
if (!tty)
return;
for (;;) {
if (test_bit(TTY_THROTTLED, &tty->flags)) break;
avail = smd_read_avail(info->ch);
if (avail == 0)
break;
if (avail > MAX_TTY_BUF_SIZE)
avail = MAX_TTY_BUF_SIZE;
avail = tty_prepare_flip_string(tty, &ptr, avail);
if (smd_read(info->ch, ptr, avail) != avail) {
/* shouldn't be possible since we're in interrupt
** context here and nobody else could 'steal' our
** characters.
*/
printk(KERN_ERR "OOPS - smd_tty_buffer mismatch?!");
}
wake_lock_timeout(&info->wake_lock, HZ / 2);
tty_flip_buffer_push(tty);
}
/* XXX only when writable and necessary */
tty_wakeup(tty);
}