Commit d676e37f authored by Aishwarya Pant's avatar Aishwarya Pant Committed by Greg Kroah-Hartman

staging: bcm2835-audio: replace null with error pointer value

This patch replaces NULL values returned by vc_vchi_audio_init(...) with
error pointer values:
	- Return ERR_PTR(-EINVAL) when too many instances of audio
	  service are initialised
	- Return ERR_PTR(-ENOMEM) when kzalloc fails
	- RETURN ERR_PTR(-EPERM) when vchi connections fail to open

Similarly, a NULL check where vc_vchi_audio_init(...) is called is
replaced by IS_ERR(..)
Signed-off-by: default avatarAishwarya Pant <aishpant@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent fc8612b1
...@@ -280,6 +280,7 @@ vc_vchi_audio_init(VCHI_INSTANCE_T vchi_instance, ...@@ -280,6 +280,7 @@ vc_vchi_audio_init(VCHI_INSTANCE_T vchi_instance,
unsigned int i; unsigned int i;
struct bcm2835_audio_instance *instance; struct bcm2835_audio_instance *instance;
int status; int status;
int ret;
LOG_DBG("%s: start", __func__); LOG_DBG("%s: start", __func__);
...@@ -287,12 +288,12 @@ vc_vchi_audio_init(VCHI_INSTANCE_T vchi_instance, ...@@ -287,12 +288,12 @@ vc_vchi_audio_init(VCHI_INSTANCE_T vchi_instance,
LOG_ERR("%s: unsupported number of connections %u (max=%u)\n", LOG_ERR("%s: unsupported number of connections %u (max=%u)\n",
__func__, num_connections, VCHI_MAX_NUM_CONNECTIONS); __func__, num_connections, VCHI_MAX_NUM_CONNECTIONS);
return NULL; return ERR_PTR(-EINVAL);
} }
/* Allocate memory for this instance */ /* Allocate memory for this instance */
instance = kzalloc(sizeof(*instance), GFP_KERNEL); instance = kzalloc(sizeof(*instance), GFP_KERNEL);
if (!instance) if (!instance)
return NULL; return ERR_PTR(-ENOMEM);
instance->num_connections = num_connections; instance->num_connections = num_connections;
...@@ -321,7 +322,7 @@ vc_vchi_audio_init(VCHI_INSTANCE_T vchi_instance, ...@@ -321,7 +322,7 @@ vc_vchi_audio_init(VCHI_INSTANCE_T vchi_instance,
if (status) { if (status) {
LOG_ERR("%s: failed to open VCHI service connection (status=%d)\n", LOG_ERR("%s: failed to open VCHI service connection (status=%d)\n",
__func__, status); __func__, status);
ret = -EPERM;
goto err_close_services; goto err_close_services;
} }
/* Finished with the service for now */ /* Finished with the service for now */
...@@ -341,7 +342,7 @@ vc_vchi_audio_init(VCHI_INSTANCE_T vchi_instance, ...@@ -341,7 +342,7 @@ vc_vchi_audio_init(VCHI_INSTANCE_T vchi_instance,
kfree(instance); kfree(instance);
LOG_ERR("%s: error\n", __func__); LOG_ERR("%s: error\n", __func__);
return NULL; return ERR_PTR(ret);
} }
static int vc_vchi_audio_deinit(struct bcm2835_audio_instance *instance) static int vc_vchi_audio_deinit(struct bcm2835_audio_instance *instance)
...@@ -432,7 +433,7 @@ static int bcm2835_audio_open_connection(struct bcm2835_alsa_stream *alsa_stream ...@@ -432,7 +433,7 @@ static int bcm2835_audio_open_connection(struct bcm2835_alsa_stream *alsa_stream
/* Initialize an instance of the audio service */ /* Initialize an instance of the audio service */
instance = vc_vchi_audio_init(vchi_instance, &vchi_connection, 1); instance = vc_vchi_audio_init(vchi_instance, &vchi_connection, 1);
if (!instance) { if (IS_ERR(instance)) {
LOG_ERR("%s: failed to initialize audio service\n", __func__); LOG_ERR("%s: failed to initialize audio service\n", __func__);
ret = -EPERM; ret = -EPERM;
......
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