static void qti_ctrl_queue_notify(struct qti_ctrl_port *port) { unsigned long flags; struct rmnet_ctrl_pkt *cpkt = NULL; pr_debug("%s: Queue empty packet for QTI for port%d", __func__, port->index); spin_lock_irqsave(&port->lock, flags); if (!port->is_open) { pr_err("%s: rmnet ctrl file handler %p is not open", __func__, port); spin_unlock_irqrestore(&port->lock, flags); return; } cpkt = alloc_rmnet_ctrl_pkt(0, GFP_ATOMIC); if (!cpkt) { pr_err("%s: Unable to allocate reset function pkt\n", __func__); spin_unlock_irqrestore(&port->lock, flags); return; } list_add_tail(&cpkt->list, &port->cpkt_req_q); spin_unlock_irqrestore(&port->lock, flags); pr_debug("%s: Wake up read queue", __func__); wake_up(&port->read_wq); }
static int gqti_ctrl_send_cpkt_tomodem(u8 portno, void *buf, size_t len) { unsigned long flags; struct qti_ctrl_port *port; struct rmnet_ctrl_pkt *cpkt; if (len > MAX_QTI_PKT_SIZE) { pr_err("given pkt size too big:%zu > max_pkt_size:%d\n", len, MAX_QTI_PKT_SIZE); return -EINVAL; } if (portno >= NR_QTI_PORTS) { pr_err("%s: Invalid QTI port %d\n", __func__, portno); return -ENODEV; } port = ctrl_port[portno]; cpkt = alloc_rmnet_ctrl_pkt(len, GFP_ATOMIC); if (IS_ERR(cpkt)) { pr_err("%s: Unable to allocate ctrl pkt\n", __func__); return -ENOMEM; } memcpy(cpkt->buf, buf, len); cpkt->len = len; pr_debug("%s: gtype:%d: Add to cpkt_req_q packet with len = %zu\n", __func__, port->gtype, len); spin_lock_irqsave(&port->lock, flags); /* drop cpkt if port is not open */ if (!port->is_open) { pr_debug("rmnet file handler %p(index=%d) is not open", port, port->index); port->drp_cpkt_cnt++; spin_unlock_irqrestore(&port->lock, flags); free_rmnet_ctrl_pkt(cpkt); return 0; } list_add_tail(&cpkt->list, &port->cpkt_req_q); port->host_to_modem++; spin_unlock_irqrestore(&port->lock, flags); /* wakeup read thread */ pr_debug("%s: Wake up read queue", __func__); wake_up(&port->read_wq); return 0; }
static int grmnet_ctrl_smd_send_cpkt_tomodem(u8 portno, void *buf, size_t len) { unsigned long flags; struct rmnet_ctrl_port *port; struct smd_ch_info *c; struct rmnet_ctrl_pkt *cpkt; if (portno >= n_rmnet_ctrl_ports) { pr_err("%s: Invalid portno#%d\n", __func__, portno); return -ENODEV; } port = ctrl_smd_ports[portno].port; cpkt = alloc_rmnet_ctrl_pkt(len, GFP_ATOMIC); if (IS_ERR(cpkt)) { pr_err("%s: Unable to allocate ctrl pkt\n", __func__); return -ENOMEM; } memcpy(cpkt->buf, buf, len); cpkt->len = len; spin_lock_irqsave(&port->port_lock, flags); c = &port->ctrl_ch; /* drop cpkt if ch is not open */ if (!test_bit(CH_OPENED, &c->flags)) { free_rmnet_ctrl_pkt(cpkt); spin_unlock_irqrestore(&port->port_lock, flags); return 0; } list_add_tail(&cpkt->list, &c->tx_q); queue_work(grmnet_ctrl_wq, &c->write_w); spin_unlock_irqrestore(&port->port_lock, flags); return 0; }