/* * called in protocol stack drivers * via the write function pointer */ long st_write(struct sk_buff *skb) { struct st_data_s *st_gdata; long len; st_kim_ref(&st_gdata, 0); if (unlikely(skb == NULL || st_gdata == NULL || st_gdata->tty == NULL)) { pr_err("data/tty unavailable to perform write"); return -EINVAL; } pr_debug("%d to be written", skb->len); len = skb->len; /* * Refresh inactivity timeout for Power Management protection mechanism * It will prevent from S3 sleeping for a while as it is very likely * some incoming data will be received soon. */ wake_lock_timeout(&st_gdata->wake_lock, ST_PM_PROTECT_INACTIVITY_TIMEOUT); /* st_ll to decide where to enqueue the skb */ st_int_enqueue(st_gdata, skb); /* wake up */ st_tx_wakeup(st_gdata); /* return number of bytes written */ return len; }
/* * internal wakeup function * called from either * - TTY layer when write's finished * - st_write (in context of the protocol stack) */ static void work_fn_write_wakeup(struct work_struct *work) { struct st_data_s *st_gdata = container_of(work, struct st_data_s, work_write_wakeup); st_tx_wakeup((void *)st_gdata); }
/* wake-up function called in from the TTY layer * inside the internal wakeup function will be called */ static void st_tty_wakeup(struct tty_struct *tty) { struct st_data_s *st_gdata = tty->disc_data; pr_debug("%s ", __func__); /* don't do an wakeup for now */ clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); /* call our internal wakeup */ st_tx_wakeup((void *)st_gdata); }
/** * st_wakeup_ack - internal function for action when wake-up ack * received */ static inline void st_wakeup_ack(struct st_data_s *st_gdata, unsigned char cmd) { struct sk_buff *waiting_skb; unsigned long flags = 0; spin_lock_irqsave(&st_gdata->lock, flags); /* de-Q from waitQ and Q in txQ now that the * chip is awake */ while ((waiting_skb = skb_dequeue(&st_gdata->tx_waitq))) skb_queue_tail(&st_gdata->txq, waiting_skb); /* state forwarded to ST LL */ st_ll_sleep_state(st_gdata, (unsigned long)cmd); spin_unlock_irqrestore(&st_gdata->lock, flags); /* wake up to send the recently copied skbs from waitQ */ st_tx_wakeup(st_gdata); }
/* * called in protocol stack drivers * via the write function pointer */ long st_write(struct sk_buff *skb) { struct st_data_s *st_gdata; long len; st_kim_ref(&st_gdata, 0); if (unlikely(skb == NULL || st_gdata == NULL || st_gdata->tty == NULL)) { pr_err("data/tty unavailable to perform write"); return -EINVAL; } pr_debug("%d to be written", skb->len); len = skb->len; /* st_ll to decide where to enqueue the skb */ st_int_enqueue(st_gdata, skb); /* wake up */ st_tx_wakeup(st_gdata); /* return number of bytes written */ return len; }