media: drivers: Adjust checks for null pointers

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written !…

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
This commit is contained in:
Markus Elfring 2017-08-28 06:50:28 -04:00 committed by Mauro Carvalho Chehab
parent 2d3da59ff1
commit af28c99628
9 changed files with 44 additions and 44 deletions

View File

@ -749,7 +749,7 @@ static int smscore_sendrequest_and_wait(struct smscore_device_t *coredev,
void *buffer, size_t size, struct completion *completion) { void *buffer, size_t size, struct completion *completion) {
int rc; int rc;
if (completion == NULL) if (!completion)
return -EINVAL; return -EINVAL;
init_completion(completion); init_completion(completion);
@ -1151,8 +1151,8 @@ static int smscore_load_firmware_from_file(struct smscore_device_t *coredev,
} }
pr_debug("Firmware name: %s\n", fw_filename); pr_debug("Firmware name: %s\n", fw_filename);
if (loadfirmware_handler == NULL && !(coredev->device_flags if (!loadfirmware_handler &&
& SMS_DEVICE_FAMILY2)) !(coredev->device_flags & SMS_DEVICE_FAMILY2))
return -EINVAL; return -EINVAL;
rc = request_firmware(&fw, fw_filename, coredev->device); rc = request_firmware(&fw, fw_filename, coredev->device);
@ -1789,7 +1789,7 @@ int smsclient_sendrequest(struct smscore_client_t *client,
struct sms_msg_hdr *phdr = (struct sms_msg_hdr *) buffer; struct sms_msg_hdr *phdr = (struct sms_msg_hdr *) buffer;
int rc; int rc;
if (client == NULL) { if (!client) {
pr_err("Got NULL client\n"); pr_err("Got NULL client\n");
return -EINVAL; return -EINVAL;
} }
@ -1797,7 +1797,7 @@ int smsclient_sendrequest(struct smscore_client_t *client,
coredev = client->coredev; coredev = client->coredev;
/* check that no other channel with same id exists */ /* check that no other channel with same id exists */
if (coredev == NULL) { if (!coredev) {
pr_err("Got NULL coredev\n"); pr_err("Got NULL coredev\n");
return -EINVAL; return -EINVAL;
} }
@ -1954,7 +1954,7 @@ int smscore_gpio_configure(struct smscore_device_t *coredev, u8 pin_num,
if (pin_num > MAX_GPIO_PIN_NUMBER) if (pin_num > MAX_GPIO_PIN_NUMBER)
return -EINVAL; return -EINVAL;
if (p_gpio_config == NULL) if (!p_gpio_config)
return -EINVAL; return -EINVAL;
total_len = sizeof(struct sms_msg_hdr) + (sizeof(u32) * 6); total_len = sizeof(struct sms_msg_hdr) + (sizeof(u32) * 6);

View File

@ -328,7 +328,7 @@ static int WriteTable(struct drxd_state *state, u8 * pTable)
{ {
int status = 0; int status = 0;
if (pTable == NULL) if (!pTable)
return 0; return 0;
while (!status) { while (!status) {
@ -909,7 +909,7 @@ static int load_firmware(struct drxd_state *state, const char *fw_name)
} }
state->microcode = kmemdup(fw->data, fw->size, GFP_KERNEL); state->microcode = kmemdup(fw->data, fw->size, GFP_KERNEL);
if (state->microcode == NULL) { if (!state->microcode) {
release_firmware(fw); release_firmware(fw);
return -ENOMEM; return -ENOMEM;
} }
@ -2629,7 +2629,7 @@ static int DRXD_init(struct drxd_state *state, const u8 *fw, u32 fw_size)
break; break;
/* Apply I2c address patch to B1 */ /* Apply I2c address patch to B1 */
if (!state->type_A && state->m_HiI2cPatch != NULL) { if (!state->type_A && state->m_HiI2cPatch) {
status = WriteTable(state, state->m_HiI2cPatch); status = WriteTable(state, state->m_HiI2cPatch);
if (status < 0) if (status < 0)
break; break;

View File

@ -357,14 +357,14 @@ static int sp2_exit(struct i2c_client *client)
dev_dbg(&client->dev, "\n"); dev_dbg(&client->dev, "\n");
if (client == NULL) if (!client)
return 0; return 0;
s = i2c_get_clientdata(client); s = i2c_get_clientdata(client);
if (s == NULL) if (!s)
return 0; return 0;
if (s->ca.data == NULL) if (!s->ca.data)
return 0; return 0;
dvb_ca_en50221_release(&s->ca); dvb_ca_en50221_release(&s->ca);

View File

@ -1948,7 +1948,7 @@ static int adv76xx_set_format(struct v4l2_subdev *sd,
return -EINVAL; return -EINVAL;
info = adv76xx_format_info(state, format->format.code); info = adv76xx_format_info(state, format->format.code);
if (info == NULL) if (!info)
info = adv76xx_format_info(state, MEDIA_BUS_FMT_YUYV8_2X8); info = adv76xx_format_info(state, MEDIA_BUS_FMT_YUYV8_2X8);
adv76xx_fill_format(state, &format->format); adv76xx_fill_format(state, &format->format);
@ -2256,7 +2256,7 @@ static int adv76xx_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
return 0; return 0;
} }
if (data == NULL) if (!data)
return -ENODATA; return -ENODATA;
if (edid->start_block >= state->edid.blocks) if (edid->start_block >= state->edid.blocks)
@ -3480,7 +3480,7 @@ static int adv76xx_probe(struct i2c_client *client,
state->i2c_clients[i] = state->i2c_clients[i] =
adv76xx_dummy_client(sd, state->pdata.i2c_addresses[i], adv76xx_dummy_client(sd, state->pdata.i2c_addresses[i],
0xf2 + i); 0xf2 + i);
if (state->i2c_clients[i] == NULL) { if (!state->i2c_clients[i]) {
err = -ENOMEM; err = -ENOMEM;
v4l2_err(sd, "failed to create i2c client %u\n", i); v4l2_err(sd, "failed to create i2c client %u\n", i);
goto err_i2c; goto err_i2c;

View File

@ -255,7 +255,7 @@ static void request_module_async(struct work_struct *work)
request_module("cx18-alsa"); request_module("cx18-alsa");
/* Initialize cx18-alsa for this instance of the cx18 device */ /* Initialize cx18-alsa for this instance of the cx18 device */
if (cx18_ext_init != NULL) if (cx18_ext_init)
cx18_ext_init(dev); cx18_ext_init(dev);
} }
@ -291,11 +291,11 @@ int cx18_msleep_timeout(unsigned int msecs, int intr)
/* Release ioremapped memory */ /* Release ioremapped memory */
static void cx18_iounmap(struct cx18 *cx) static void cx18_iounmap(struct cx18 *cx)
{ {
if (cx == NULL) if (!cx)
return; return;
/* Release io memory */ /* Release io memory */
if (cx->enc_mem != NULL) { if (cx->enc_mem) {
CX18_DEBUG_INFO("releasing enc_mem\n"); CX18_DEBUG_INFO("releasing enc_mem\n");
iounmap(cx->enc_mem); iounmap(cx->enc_mem);
cx->enc_mem = NULL; cx->enc_mem = NULL;
@ -649,15 +649,15 @@ static void cx18_process_options(struct cx18 *cx)
CX18_INFO("User specified %s card\n", cx->card->name); CX18_INFO("User specified %s card\n", cx->card->name);
else if (cx->options.cardtype != 0) else if (cx->options.cardtype != 0)
CX18_ERR("Unknown user specified type, trying to autodetect card\n"); CX18_ERR("Unknown user specified type, trying to autodetect card\n");
if (cx->card == NULL) { if (!cx->card) {
if (cx->pci_dev->subsystem_vendor == CX18_PCI_ID_HAUPPAUGE) { if (cx->pci_dev->subsystem_vendor == CX18_PCI_ID_HAUPPAUGE) {
cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT); cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT);
CX18_INFO("Autodetected Hauppauge card\n"); CX18_INFO("Autodetected Hauppauge card\n");
} }
} }
if (cx->card == NULL) { if (!cx->card) {
for (i = 0; (cx->card = cx18_get_card(i)); i++) { for (i = 0; (cx->card = cx18_get_card(i)); i++) {
if (cx->card->pci_list == NULL) if (!cx->card->pci_list)
continue; continue;
for (j = 0; cx->card->pci_list[j].device; j++) { for (j = 0; cx->card->pci_list[j].device; j++) {
if (cx->pci_dev->device != if (cx->pci_dev->device !=
@ -676,7 +676,7 @@ static void cx18_process_options(struct cx18 *cx)
} }
done: done:
if (cx->card == NULL) { if (!cx->card) {
cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT); cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT);
CX18_ERR("Unknown card: vendor/device: [%04x:%04x]\n", CX18_ERR("Unknown card: vendor/device: [%04x:%04x]\n",
cx->pci_dev->vendor, cx->pci_dev->device); cx->pci_dev->vendor, cx->pci_dev->device);
@ -698,7 +698,7 @@ static int cx18_create_in_workq(struct cx18 *cx)
snprintf(cx->in_workq_name, sizeof(cx->in_workq_name), "%s-in", snprintf(cx->in_workq_name, sizeof(cx->in_workq_name), "%s-in",
cx->v4l2_dev.name); cx->v4l2_dev.name);
cx->in_work_queue = alloc_ordered_workqueue("%s", 0, cx->in_workq_name); cx->in_work_queue = alloc_ordered_workqueue("%s", 0, cx->in_workq_name);
if (cx->in_work_queue == NULL) { if (!cx->in_work_queue) {
CX18_ERR("Unable to create incoming mailbox handler thread\n"); CX18_ERR("Unable to create incoming mailbox handler thread\n");
return -ENOMEM; return -ENOMEM;
} }
@ -1254,7 +1254,7 @@ static void cx18_cancel_out_work_orders(struct cx18 *cx)
{ {
int i; int i;
for (i = 0; i < CX18_MAX_STREAMS; i++) for (i = 0; i < CX18_MAX_STREAMS; i++)
if (&cx->streams[i].video_dev != NULL) if (&cx->streams[i].video_dev)
cancel_work_sync(&cx->streams[i].out_work_order); cancel_work_sync(&cx->streams[i].out_work_order);
} }
@ -1299,7 +1299,7 @@ static void cx18_remove(struct pci_dev *pci_dev)
pci_disable_device(cx->pci_dev); pci_disable_device(cx->pci_dev);
if (cx->vbi.sliced_mpeg_data[0] != NULL) if (cx->vbi.sliced_mpeg_data[0])
for (i = 0; i < CX18_VBI_FRAMES; i++) for (i = 0; i < CX18_VBI_FRAMES; i++)
kfree(cx->vbi.sliced_mpeg_data[i]); kfree(cx->vbi.sliced_mpeg_data[i]);

View File

@ -72,7 +72,7 @@ static irqreturn_t hopper_irq_handler(int irq, void *dev_id)
struct mantis_ca *ca; struct mantis_ca *ca;
mantis = (struct mantis_pci *) dev_id; mantis = (struct mantis_pci *) dev_id;
if (unlikely(mantis == NULL)) { if (unlikely(!mantis)) {
dprintk(MANTIS_ERROR, 1, "Mantis == NULL"); dprintk(MANTIS_ERROR, 1, "Mantis == NULL");
return IRQ_NONE; return IRQ_NONE;
} }
@ -164,7 +164,7 @@ static int hopper_pci_probe(struct pci_dev *pdev,
int err; int err;
mantis = kzalloc(sizeof(*mantis), GFP_KERNEL); mantis = kzalloc(sizeof(*mantis), GFP_KERNEL);
if (mantis == NULL) { if (!mantis) {
err = -ENOMEM; err = -ENOMEM;
goto fail0; goto fail0;
} }

View File

@ -1590,7 +1590,7 @@ static int isc_async_complete(struct v4l2_async_notifier *notifier)
spin_lock_init(&isc->dma_queue_lock); spin_lock_init(&isc->dma_queue_lock);
sd_entity->config = v4l2_subdev_alloc_pad_config(sd_entity->sd); sd_entity->config = v4l2_subdev_alloc_pad_config(sd_entity->sd);
if (sd_entity->config == NULL) if (!sd_entity->config)
return -ENOMEM; return -ENOMEM;
ret = isc_formats_init(isc); ret = isc_formats_init(isc);
@ -1714,7 +1714,7 @@ static int isc_parse_dt(struct device *dev, struct isc_device *isc)
subdev_entity = devm_kzalloc(dev, subdev_entity = devm_kzalloc(dev,
sizeof(*subdev_entity), GFP_KERNEL); sizeof(*subdev_entity), GFP_KERNEL);
if (subdev_entity == NULL) { if (!subdev_entity) {
of_node_put(rem); of_node_put(rem);
ret = -ENOMEM; ret = -ENOMEM;
break; break;
@ -1722,7 +1722,7 @@ static int isc_parse_dt(struct device *dev, struct isc_device *isc)
subdev_entity->asd = devm_kzalloc(dev, subdev_entity->asd = devm_kzalloc(dev,
sizeof(*subdev_entity->asd), GFP_KERNEL); sizeof(*subdev_entity->asd), GFP_KERNEL);
if (subdev_entity->asd == NULL) { if (!subdev_entity->asd) {
of_node_put(rem); of_node_put(rem);
ret = -ENOMEM; ret = -ENOMEM;
break; break;

View File

@ -411,7 +411,7 @@ static void buffer_queue(struct vb2_buffer *vb)
spin_lock_irqsave(&isi->irqlock, flags); spin_lock_irqsave(&isi->irqlock, flags);
list_add_tail(&buf->list, &isi->video_buffer_list); list_add_tail(&buf->list, &isi->video_buffer_list);
if (isi->active == NULL) { if (!isi->active) {
isi->active = buf; isi->active = buf;
if (vb2_is_streaming(vb->vb2_queue)) if (vb2_is_streaming(vb->vb2_queue))
start_dma(isi, buf); start_dma(isi, buf);
@ -1141,7 +1141,7 @@ static int isi_graph_init(struct atmel_isi *isi)
/* Register the subdevices notifier. */ /* Register the subdevices notifier. */
subdevs = devm_kzalloc(isi->dev, sizeof(*subdevs), GFP_KERNEL); subdevs = devm_kzalloc(isi->dev, sizeof(*subdevs), GFP_KERNEL);
if (subdevs == NULL) { if (!subdevs) {
of_node_put(isi->entity.node); of_node_put(isi->entity.node);
return -ENOMEM; return -ENOMEM;
} }
@ -1200,7 +1200,7 @@ static int atmel_isi_probe(struct platform_device *pdev)
return ret; return ret;
isi->vdev = video_device_alloc(); isi->vdev = video_device_alloc();
if (isi->vdev == NULL) { if (!isi->vdev) {
ret = -ENOMEM; ret = -ENOMEM;
goto err_vdev_alloc; goto err_vdev_alloc;
} }

View File

@ -385,9 +385,9 @@ static int buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
vb); vb);
int rc; int rc;
DBG("%s, field=%d, fmt name = %s\n", __func__, field, cam->fmt != NULL ? DBG("%s, field=%d, fmt name = %s\n", __func__, field,
cam->fmt->name : ""); cam->fmt ? cam->fmt->name : "");
if (cam->fmt == NULL) if (!cam->fmt)
return -EINVAL; return -EINVAL;
buf->vb.size = cam->width * cam->height * (cam->fmt->depth >> 3); buf->vb.size = cam->width * cam->height * (cam->fmt->depth >> 3);
@ -787,7 +787,7 @@ static int zr364xx_vidioc_try_fmt_vid_cap(struct file *file, void *priv,
struct zr364xx_camera *cam = video_drvdata(file); struct zr364xx_camera *cam = video_drvdata(file);
char pixelformat_name[5]; char pixelformat_name[5];
if (cam == NULL) if (!cam)
return -ENODEV; return -ENODEV;
if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_JPEG) { if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_JPEG) {
@ -817,7 +817,7 @@ static int zr364xx_vidioc_g_fmt_vid_cap(struct file *file, void *priv,
{ {
struct zr364xx_camera *cam; struct zr364xx_camera *cam;
if (file == NULL) if (!file)
return -ENODEV; return -ENODEV;
cam = video_drvdata(file); cam = video_drvdata(file);
@ -979,13 +979,13 @@ static void read_pipe_completion(struct urb *purb)
pipe_info = purb->context; pipe_info = purb->context;
_DBG("%s %p, status %d\n", __func__, purb, purb->status); _DBG("%s %p, status %d\n", __func__, purb, purb->status);
if (pipe_info == NULL) { if (!pipe_info) {
printk(KERN_ERR KBUILD_MODNAME ": no context!\n"); printk(KERN_ERR KBUILD_MODNAME ": no context!\n");
return; return;
} }
cam = pipe_info->cam; cam = pipe_info->cam;
if (cam == NULL) { if (!cam) {
printk(KERN_ERR KBUILD_MODNAME ": no context!\n"); printk(KERN_ERR KBUILD_MODNAME ": no context!\n");
return; return;
} }
@ -1069,7 +1069,7 @@ static void zr364xx_stop_readpipe(struct zr364xx_camera *cam)
{ {
struct zr364xx_pipeinfo *pipe_info; struct zr364xx_pipeinfo *pipe_info;
if (cam == NULL) { if (!cam) {
printk(KERN_ERR KBUILD_MODNAME ": invalid device\n"); printk(KERN_ERR KBUILD_MODNAME ": invalid device\n");
return; return;
} }
@ -1273,7 +1273,7 @@ static int zr364xx_mmap(struct file *file, struct vm_area_struct *vma)
struct zr364xx_camera *cam = video_drvdata(file); struct zr364xx_camera *cam = video_drvdata(file);
int ret; int ret;
if (cam == NULL) { if (!cam) {
DBG("%s: cam == NULL\n", __func__); DBG("%s: cam == NULL\n", __func__);
return -ENODEV; return -ENODEV;
} }
@ -1357,7 +1357,7 @@ static int zr364xx_board_init(struct zr364xx_camera *cam)
pipe->transfer_buffer = kzalloc(pipe->transfer_size, pipe->transfer_buffer = kzalloc(pipe->transfer_size,
GFP_KERNEL); GFP_KERNEL);
if (pipe->transfer_buffer == NULL) { if (!pipe->transfer_buffer) {
DBG("out of memory!\n"); DBG("out of memory!\n");
return -ENOMEM; return -ENOMEM;
} }
@ -1373,7 +1373,7 @@ static int zr364xx_board_init(struct zr364xx_camera *cam)
DBG("valloc %p, idx %lu, pdata %p\n", DBG("valloc %p, idx %lu, pdata %p\n",
&cam->buffer.frame[i], i, &cam->buffer.frame[i], i,
cam->buffer.frame[i].lpvbits); cam->buffer.frame[i].lpvbits);
if (cam->buffer.frame[i].lpvbits == NULL) { if (!cam->buffer.frame[i].lpvbits) {
printk(KERN_INFO KBUILD_MODNAME ": out of memory. Using less frames\n"); printk(KERN_INFO KBUILD_MODNAME ": out of memory. Using less frames\n");
break; break;
} }