Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: v4l2-core: Remove BUG() from i2c and spi helpers

Currently, the i2c and spi subdev creation helpers
are calling BUG() when passed a NULL v4l2_device parameter.

This makes little sense; simply returning NULL seems more
sensible.

These two helpers may already return NULL on error, so callers
should already be checking for this, or at least be prepared
for a NULL result.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

authored by

Ezequiel Garcia and committed by
Mauro Carvalho Chehab
1a065ee3 51ff392c

+4 -3
+2 -1
drivers/media/v4l2-core/v4l2-i2c.c
··· 64 64 struct v4l2_subdev *sd = NULL; 65 65 struct i2c_client *client; 66 66 67 - BUG_ON(!v4l2_dev); 67 + if (!v4l2_dev) 68 + return NULL; 68 69 69 70 request_module(I2C_MODULE_PREFIX "%s", info->type); 70 71
+2 -2
drivers/media/v4l2-core/v4l2-spi.c
··· 39 39 struct v4l2_subdev *sd = NULL; 40 40 struct spi_device *spi = NULL; 41 41 42 - BUG_ON(!v4l2_dev); 43 - 42 + if (!v4l2_dev) 43 + return NULL; 44 44 if (info->modalias[0]) 45 45 request_module(info->modalias); 46 46