Commit de7b428e authored by Alexey Dobriyan's avatar Alexey Dobriyan Committed by Greg Kroah-Hartman

[PATCH] USB: drivers/usb/*: s/0/NULL/ in pointer context

Signed-off-by: default avatarAlexey Dobriyan <adobriyan@mail.ru>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent e3055f60
......@@ -1096,7 +1096,7 @@ static int usblp_set_protocol(struct usblp *usblp, int protocol)
usblp->writebuf, 0,
usblp_bulk_write, usblp);
usblp->bidir = (usblp->protocol[protocol].epread != 0);
usblp->bidir = (usblp->protocol[protocol].epread != NULL);
if (usblp->bidir)
usb_fill_bulk_urb(usblp->readurb, usblp->dev,
usb_rcvbulkpipe(usblp->dev,
......
......@@ -1127,7 +1127,7 @@ static int proc_ioctl (struct dev_state *ps, void __user *arg)
if (copy_from_user(&ctrl, arg, sizeof (ctrl)))
return -EFAULT;
if ((size = _IOC_SIZE (ctrl.ioctl_code)) > 0) {
if ((buf = kmalloc (size, GFP_KERNEL)) == 0)
if ((buf = kmalloc (size, GFP_KERNEL)) == NULL)
return -ENOMEM;
if ((_IOC_DIR(ctrl.ioctl_code) & _IOC_WRITE)) {
if (copy_from_user (buf, ctrl.data, size)) {
......@@ -1187,7 +1187,7 @@ static int proc_ioctl (struct dev_state *ps, void __user *arg)
down_read(&usb_bus_type.subsys.rwsem);
if (intf->dev.driver)
driver = to_usb_driver(intf->dev.driver);
if (driver == 0 || driver->ioctl == 0) {
if (driver == NULL || driver->ioctl == NULL) {
retval = -ENOTTY;
} else {
retval = driver->ioctl (intf, ctrl.ioctl_code, buf);
......@@ -1203,7 +1203,7 @@ static int proc_ioctl (struct dev_state *ps, void __user *arg)
&& size > 0
&& copy_to_user (ctrl.data, buf, size) != 0)
retval = -EFAULT;
if (buf != 0)
if (buf != NULL)
kfree (buf);
return retval;
}
......
......@@ -524,7 +524,7 @@ static void rh_report_status (unsigned long ptr)
/* do nothing if the urb's been unlinked */
if (!urb->dev
|| urb->status != -EINPROGRESS
|| (hcd = urb->dev->bus->hcpriv) == 0) {
|| (hcd = urb->dev->bus->hcpriv) == NULL) {
spin_unlock (&urb->lock);
local_irq_restore (flags);
return;
......
......@@ -405,7 +405,7 @@ void usb_hub_tt_clear_buffer (struct usb_device *udev, int pipe)
* since each TT has "at least two" buffers that can need it (and
* there can be many TTs per hub). even if they're uncommon.
*/
if ((clear = kmalloc (sizeof *clear, SLAB_ATOMIC)) == 0) {
if ((clear = kmalloc (sizeof *clear, SLAB_ATOMIC)) == NULL) {
dev_err (&udev->dev, "can't save CLEAR_TT_BUFFER state\n");
/* FIXME recover somehow ... RESET_TT? */
return;
......@@ -2299,7 +2299,7 @@ check_highspeed (struct usb_hub *hub, struct usb_device *udev, int port1)
int status;
qual = kmalloc (sizeof *qual, SLAB_KERNEL);
if (qual == 0)
if (qual == NULL)
return;
status = usb_get_descriptor (udev, USB_DT_DEVICE_QUALIFIER, 0,
......@@ -2831,7 +2831,7 @@ static int config_descriptors_changed(struct usb_device *udev)
len = le16_to_cpu(udev->config[index].desc.wTotalLength);
}
buf = kmalloc (len, SLAB_KERNEL);
if (buf == 0) {
if (buf == NULL) {
dev_err(&udev->dev, "no mem to re-read configs after reset\n");
/* assume the worst */
return 1;
......
......@@ -209,7 +209,7 @@ static void sg_clean (struct usb_sg_request *io)
kfree (io->urbs);
io->urbs = NULL;
}
if (io->dev->dev.dma_mask != 0)
if (io->dev->dev.dma_mask != NULL)
usb_buffer_unmap_sg (io->dev, io->pipe, io->sg, io->nents);
io->dev = NULL;
}
......@@ -334,7 +334,7 @@ int usb_sg_init (
/* not all host controllers use DMA (like the mainstream pci ones);
* they can use PIO (sl811) or be software over another transport.
*/
dma = (dev->dev.dma_mask != 0);
dma = (dev->dev.dma_mask != NULL);
if (dma)
io->entries = usb_buffer_map_sg (dev, pipe, sg, nents);
else
......
......@@ -796,7 +796,7 @@ static void ehci_work (struct ehci_hcd *ehci, struct pt_regs *regs)
* such lossage has been observed on both VT6202 and VT8235.
*/
if (HCD_IS_RUNNING (ehci_to_hcd(ehci)->state) &&
(ehci->async->qh_next.ptr != 0 ||
(ehci->async->qh_next.ptr != NULL ||
ehci->periodic_sched != 0))
timer_action (ehci, TIMER_IO_WATCHDOG);
}
......
......@@ -51,7 +51,7 @@ static struct ehci_qtd *ehci_qtd_alloc (struct ehci_hcd *ehci, int flags)
dma_addr_t dma;
qtd = dma_pool_alloc (ehci->qtd_pool, flags, &dma);
if (qtd != 0) {
if (qtd != NULL) {
ehci_qtd_init (qtd, dma);
}
return qtd;
......@@ -98,7 +98,7 @@ static struct ehci_qh *ehci_qh_alloc (struct ehci_hcd *ehci, int flags)
/* dummy td enables safe urb queuing */
qh->dummy = ehci_qtd_alloc (ehci, flags);
if (qh->dummy == 0) {
if (qh->dummy == NULL) {
ehci_dbg (ehci, "no dummy td\n");
dma_pool_free (ehci->qh_pool, qh, qh->qh_dma);
qh = NULL;
......@@ -215,7 +215,7 @@ static int ehci_mem_init (struct ehci_hcd *ehci, int flags)
dma_alloc_coherent (ehci_to_hcd(ehci)->self.controller,
ehci->periodic_size * sizeof(__le32),
&ehci->periodic_dma, 0);
if (ehci->periodic == 0) {
if (ehci->periodic == NULL) {
goto fail;
}
for (i = 0; i < ehci->periodic_size; i++)
......@@ -223,7 +223,7 @@ static int ehci_mem_init (struct ehci_hcd *ehci, int flags)
/* software shadow of hardware table */
ehci->pshadow = kmalloc (ehci->periodic_size * sizeof (void *), flags);
if (ehci->pshadow == 0) {
if (ehci->pshadow == NULL) {
goto fail;
}
memset (ehci->pshadow, 0, ehci->periodic_size * sizeof (void *));
......
......@@ -218,7 +218,7 @@ ehci_urb_done (struct ehci_hcd *ehci, struct urb *urb, struct pt_regs *regs)
__releases(ehci->lock)
__acquires(ehci->lock)
{
if (likely (urb->hcpriv != 0)) {
if (likely (urb->hcpriv != NULL)) {
struct ehci_qh *qh = (struct ehci_qh *) urb->hcpriv;
/* S-mask in a QH means it's an interrupt urb */
......@@ -404,7 +404,7 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh, struct pt_regs *regs)
}
/* last urb's completion might still need calling */
if (likely (last != 0)) {
if (likely (last != NULL)) {
ehci_urb_done (ehci, last->urb, regs);
count++;
ehci_qtd_free (ehci, last);
......@@ -846,7 +846,7 @@ static struct ehci_qh *qh_append_tds (
/* just one way to queue requests: swap with the dummy qtd.
* only hc or qh_refresh() ever modify the overlay.
*/
if (likely (qtd != 0)) {
if (likely (qtd != NULL)) {
struct ehci_qtd *dummy;
dma_addr_t dma;
__le32 token;
......@@ -921,12 +921,12 @@ submit_async (
/* Control/bulk operations through TTs don't need scheduling,
* the HC and TT handle it when the TT has a buffer ready.
*/
if (likely (qh != 0)) {
if (likely (qh != NULL)) {
if (likely (qh->qh_state == QH_STATE_IDLE))
qh_link_async (ehci, qh_get (qh));
}
spin_unlock_irqrestore (&ehci->lock, flags);
if (unlikely (qh == 0)) {
if (unlikely (qh == NULL)) {
qtd_list_free (ehci, urb, qtd_list);
return -ENOMEM;
}
......@@ -967,7 +967,7 @@ static void end_unlink_async (struct ehci_hcd *ehci, struct pt_regs *regs)
* active but idle for a while once it empties.
*/
if (HCD_IS_RUNNING (ehci_to_hcd(ehci)->state)
&& ehci->async->qh_next.qh == 0)
&& ehci->async->qh_next.qh == NULL)
timer_action (ehci, TIMER_ASYNC_OFF);
}
......@@ -1048,7 +1048,7 @@ scan_async (struct ehci_hcd *ehci, struct pt_regs *regs)
timer_action_done (ehci, TIMER_ASYNC_SHRINK);
rescan:
qh = ehci->async->qh_next.qh;
if (likely (qh != 0)) {
if (likely (qh != NULL)) {
do {
/* clean any finished work for this qh */
if (!list_empty (&qh->qtd_list)
......
......@@ -604,7 +604,7 @@ static int intr_submit (
/* get qh and force any scheduling errors */
INIT_LIST_HEAD (&empty);
qh = qh_append_tds (ehci, urb, &empty, epnum, &ep->hcpriv);
if (qh == 0) {
if (qh == NULL) {
status = -ENOMEM;
goto done;
}
......@@ -615,7 +615,7 @@ static int intr_submit (
/* then queue the urb's tds to the qh */
qh = qh_append_tds (ehci, urb, qtd_list, epnum, &ep->hcpriv);
BUG_ON (qh == 0);
BUG_ON (qh == NULL);
/* ... update usbfs periodic stats */
ehci_to_hcd(ehci)->self.bandwidth_int_reqs++;
......@@ -638,7 +638,7 @@ iso_stream_alloc (int mem_flags)
struct ehci_iso_stream *stream;
stream = kmalloc(sizeof *stream, mem_flags);
if (likely (stream != 0)) {
if (likely (stream != NULL)) {
memset (stream, 0, sizeof(*stream));
INIT_LIST_HEAD(&stream->td_list);
INIT_LIST_HEAD(&stream->free_list);
......@@ -791,7 +791,7 @@ iso_stream_put(struct ehci_hcd *ehci, struct ehci_iso_stream *stream)
static inline struct ehci_iso_stream *
iso_stream_get (struct ehci_iso_stream *stream)
{
if (likely (stream != 0))
if (likely (stream != NULL))
stream->refcount++;
return stream;
}
......@@ -813,9 +813,9 @@ iso_stream_find (struct ehci_hcd *ehci, struct urb *urb)
spin_lock_irqsave (&ehci->lock, flags);
stream = ep->hcpriv;
if (unlikely (stream == 0)) {
if (unlikely (stream == NULL)) {
stream = iso_stream_alloc(GFP_ATOMIC);
if (likely (stream != 0)) {
if (likely (stream != NULL)) {
/* dev->ep owns the initial refcount */
ep->hcpriv = stream;
stream->ep = ep;
......@@ -850,7 +850,7 @@ iso_sched_alloc (unsigned packets, int mem_flags)
size += packets * sizeof (struct ehci_iso_packet);
iso_sched = kmalloc (size, mem_flags);
if (likely (iso_sched != 0)) {
if (likely (iso_sched != NULL)) {
memset(iso_sched, 0, size);
INIT_LIST_HEAD (&iso_sched->td_list);
}
......@@ -927,7 +927,7 @@ itd_urb_transaction (
unsigned long flags;
sched = iso_sched_alloc (urb->number_of_packets, mem_flags);
if (unlikely (sched == 0))
if (unlikely (sched == NULL))
return -ENOMEM;
itd_sched_init (sched, stream, urb);
......@@ -961,7 +961,7 @@ itd_urb_transaction (
spin_lock_irqsave (&ehci->lock, flags);
}
if (unlikely (0 == itd)) {
if (unlikely (NULL == itd)) {
iso_sched_free (stream, sched);
spin_unlock_irqrestore (&ehci->lock, flags);
return -ENOMEM;
......@@ -1416,7 +1416,7 @@ static int itd_submit (struct ehci_hcd *ehci, struct urb *urb, int mem_flags)
/* Get iso_stream head */
stream = iso_stream_find (ehci, urb);
if (unlikely (stream == 0)) {
if (unlikely (stream == NULL)) {
ehci_dbg (ehci, "can't get iso stream\n");
return -ENOMEM;
}
......@@ -1530,7 +1530,7 @@ sitd_urb_transaction (
unsigned long flags;
iso_sched = iso_sched_alloc (urb->number_of_packets, mem_flags);
if (iso_sched == 0)
if (iso_sched == NULL)
return -ENOMEM;
sitd_sched_init (iso_sched, stream, urb);
......@@ -1784,7 +1784,7 @@ static int sitd_submit (struct ehci_hcd *ehci, struct urb *urb, int mem_flags)
/* Get iso_stream head */
stream = iso_stream_find (ehci, urb);
if (stream == 0) {
if (stream == NULL) {
ehci_dbg (ehci, "can't get iso stream\n");
return -ENOMEM;
}
......@@ -1889,7 +1889,7 @@ scan_periodic (struct ehci_hcd *ehci, struct pt_regs *regs)
type = Q_NEXT_TYPE (*hw_p);
modified = 0;
while (q.ptr != 0) {
while (q.ptr != NULL) {
unsigned uf;
union ehci_shadow temp;
int live;
......
......@@ -1042,7 +1042,7 @@ sl811h_endpoint_disable(struct usb_hcd *hcd, struct usb_host_endpoint *hep)
usb_put_dev(ep->udev);
kfree(ep);
hep->hcpriv = 0;
hep->hcpriv = NULL;
}
static int
......
......@@ -456,7 +456,7 @@ static int mdc800_usb_probe (struct usb_interface *intf,
dbg ("(mdc800_usb_probe) called.");
if (mdc800->dev != 0)
if (mdc800->dev != NULL)
{
warn ("only one Mustek MDC800 is supported.");
return -ENODEV;
......@@ -1045,7 +1045,7 @@ static int __init usb_mdc800_init (void)
cleanup_on_fail:
if (mdc800 != 0)
if (mdc800 != NULL)
{
err ("can't alloc memory!");
......
......@@ -676,7 +676,7 @@ static struct hid_device *hid_parse_report(__u8 *start, unsigned size)
parser->device = device;
end = start + size;
while ((start = fetch_item(start, end, &item)) != 0) {
while ((start = fetch_item(start, end, &item)) != NULL) {
if (item.format != HID_ITEM_FORMAT_SHORT) {
dbg("unexpected long global item");
......
......@@ -1204,7 +1204,7 @@ static int halt_simple (struct usbtest_dev *dev)
struct urb *urb;
urb = simple_alloc_urb (testdev_to_usbdev (dev), 0, 512);
if (urb == 0)
if (urb == NULL)
return -ENOMEM;
if (dev->in_pipe) {
......@@ -1862,7 +1862,7 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id)
dev->intf = intf;
/* cacheline-aligned scratch for i/o */
if ((dev->buf = kmalloc (TBUF_SIZE, SLAB_KERNEL)) == 0) {
if ((dev->buf = kmalloc (TBUF_SIZE, SLAB_KERNEL)) == NULL) {
kfree (dev);
return -ENOMEM;
}
......
......@@ -745,7 +745,7 @@ static int ax8817x_bind(struct usbnet *dev, struct usb_interface *intf)
dev->out = usb_sndbulkpipe(dev->udev, 2);
// allocate irq urb
if ((data->int_urb = usb_alloc_urb (0, GFP_KERNEL)) == 0) {
if ((data->int_urb = usb_alloc_urb (0, GFP_KERNEL)) == NULL) {
dbg ("%s: cannot allocate interrupt URB",
dev->net->name);
return -ENOMEM;
......@@ -2384,7 +2384,7 @@ static void rx_submit (struct usbnet *dev, struct urb *urb, int flags)
#endif
size = (sizeof (struct ethhdr) + dev->net->mtu);
if ((skb = alloc_skb (size, flags)) == 0) {
if ((skb = alloc_skb (size, flags)) == NULL) {
devdbg (dev, "no rx skb");
defer_kevent (dev, EVENT_RX_MEMORY);
usb_free_urb (urb);
......@@ -2769,7 +2769,7 @@ kevent (void *data)
urb = usb_alloc_urb (0, GFP_KERNEL);
else
clear_bit (EVENT_RX_MEMORY, &dev->flags);
if (urb != 0) {
if (urb != NULL) {
clear_bit (EVENT_RX_MEMORY, &dev->flags);
rx_submit (dev, urb, GFP_KERNEL);
tasklet_schedule (&dev->bh);
......@@ -2996,7 +2996,8 @@ static void usbnet_bh (unsigned long param)
// don't refill the queue all at once
for (i = 0; i < 10 && dev->rxq.qlen < qlen; i++) {
if ((urb = usb_alloc_urb (0, GFP_ATOMIC)) != 0)
urb = usb_alloc_urb (0, GFP_ATOMIC);
if (urb != NULL)
rx_submit (dev, urb, GFP_ATOMIC);
}
if (temp != dev->rxq.qlen)
......
......@@ -316,7 +316,7 @@ static int pkt_add(struct garmin_data * garmin_data_p,
garmin_data_p->flags |= FLAGS_QUEUING;
pkt = kmalloc(sizeof(struct garmin_packet)+data_length,
GFP_ATOMIC);
if (pkt == 0) {
if (pkt == NULL) {
dev_err(&garmin_data_p->port->dev, "out of memory\n");
return 0;
}
......@@ -739,7 +739,7 @@ static void gsp_next_packet(struct garmin_data * garmin_data_p)
{
struct garmin_packet *pkt = NULL;
while ((pkt = pkt_pop(garmin_data_p)) != 0) {
while ((pkt = pkt_pop(garmin_data_p)) != NULL) {
dbg("%s - next pkt: %d", __FUNCTION__, pkt->seq);
if (gsp_send(garmin_data_p, pkt->data, pkt->size) > 0) {
kfree(pkt);
......@@ -877,7 +877,7 @@ static int garmin_clear(struct garmin_data * garmin_data_p)
struct usb_serial_port *port = garmin_data_p->port;
if (port != 0 && garmin_data_p->flags & FLAGS_APP_RESP_SEEN) {
if (port != NULL && garmin_data_p->flags & FLAGS_APP_RESP_SEEN) {
/* send a terminate command */
status = garmin_write_bulk(port, GARMIN_STOP_TRANSFER_REQ,
sizeof(GARMIN_STOP_TRANSFER_REQ));
......@@ -1366,7 +1366,7 @@ static int garmin_flush_queue(struct garmin_data * garmin_data_p)
if ((garmin_data_p->flags & FLAGS_THROTTLED) == 0) {
pkt = pkt_pop(garmin_data_p);
if (pkt != 0) {
if (pkt != NULL) {
send_to_tty(garmin_data_p->port, pkt->data, pkt->size);
kfree(pkt);
......
......@@ -374,7 +374,7 @@ static int keyspan_write(struct usb_serial_port *port,
flip = p_priv->out_flip;
/* Check we have a valid urb/endpoint before we use it... */
if ((this_urb = p_priv->out_urbs[flip]) == 0) {
if ((this_urb = p_priv->out_urbs[flip]) == NULL) {
/* no bulk out, so return 0 bytes written */
dbg("%s - no output urb :(", __FUNCTION__);
return count;
......@@ -1020,11 +1020,11 @@ static int keyspan_write_room (struct usb_serial_port *port)
flip = p_priv->out_flip;
/* Check both endpoints to see if any are available. */
if ((this_urb = p_priv->out_urbs[flip]) != 0) {
if ((this_urb = p_priv->out_urbs[flip]) != NULL) {
if (this_urb->status != -EINPROGRESS)
return (data_len);
flip = (flip + 1) & d_details->outdat_endp_flip;
if ((this_urb = p_priv->out_urbs[flip]) != 0)
if ((this_urb = p_priv->out_urbs[flip]) != NULL)
if (this_urb->status != -EINPROGRESS)
return (data_len);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment