[Ftdi-usb-sio-devel] questions about ftdi_sio.c:update_mctrl()
Brought to you by:
bryder
From: Leisner, M. <Mar...@xe...> - 2007-01-11 18:42:13
|
I was looking at ftdi_sio in 2.6.10 -- and I noticed something I didn't understand -- so I looked in 2.6.18.2 and it was also there (but a little of the structure changed). Why do we kmalloc/kfree 1 byte...it seems it wouldn't be used in usb_control_msg since the size is 0... So why don't we just do: NULL, 0 instead of buf, 0 static int update_mctrl(struct usb_serial_port *port, unsigned int set, unsigned int clear) { struct ftdi_private *priv =3D usb_get_serial_port_data(port); char *buf; unsigned urb_value; int rv; if (((set | clear) & (TIOCM_DTR | TIOCM_RTS)) =3D=3D 0) { dbg("%s - DTR|RTS not being set|cleared", __FUNCTION__); return 0; /* no change */ } buf =3D kmalloc(1, GFP_NOIO); if (!buf) { return -ENOMEM; } .... rv =3D usb_control_msg(port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0), FTDI_SIO_SET_MODEM_CTRL_REQUEST, FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE, urb_value, priv->interface, buf, 0, WDR_TIMEOUT); kfree(buf); marty |