STREAMS-UX Programmer's Guide (February 2007)

Modules and Drivers
STREAMS Driver
Chapter 4
102
* this instance of the module.
*/
if (q->q_ptr)
kmem_free((caddr_t)q->q_ptr, sizeof(drv_priv_t));
/*
* Free the minor number allocated for this stream
*/
...
/*
* Assign NULL to both the read and the write side q_ptr's
*/
q->q_ptr = WR(q)->q_ptr = NULL;
return 0 ; /* Success */
}
Put Procedure
The put procedure is the third entry point for the STREAMS driver.
Outbound Processing
The write (2) and ioctl (2) system calls are only seen by the stream head. The stream head translates the write
(2) and ioctl (2) system calls into messages and sends them downstream to be processed by the drivers’s
write-side put procedure. If the message cannot be sent immediately to the hardware or the software device, it
may be stored on a driver’s write queue if a write-side service procedure exists else may be in the driver’s
private data structures.
An example of a driver’s write-side put procedure is shown:
int
drv_wput(q, mp)
queue_t *q;
mblk_t *mp;
{
...
if ((mp->b_datap->db_type >= QPCTL) &&
(mp->b_datap->db_type != M_FLUSH)) {
/*
* Process the high priority message
*/
...
return;
}