Skip to contentSkip to conversation

pcmcia: pcmcia_resource: return 0 if success

PATCH In review Jason Wang 2 participants 2 messages Dec 12, 2021 – Jan 2, 2022 Pcmcia

lore
Share & tools
lore

Jason Wang

author
#0 lore raw

PATCH 1/1 pcmcia: pcmcia_resource: return 0 if success

The initial value of variable ret' is -EINVAL, which is used for returning the error status in pcmcia_release_io' when errors occur. But if there is no error in pcmcia_release_io', ret' should be changed to a successful value to return. Thus we change `ret' value to 0 when the function's status is successful.

---
 drivers/pcmcia/pcmcia_resource.c | 1 +
 1 file changed, 1 insertion(+)
drivers/pcmcia/pcmcia_resource.c +1 -0
index c1c197292111..257181cb686f 100644
@@ -409,6 +409,7 @@ static int pcmcia_release_io(struct pcmcia_device *p_dev)
 
 	p_dev->_io = 0;
 	c->state &= ~CONFIG_IO_REQ;
+	ret = 0;
 
 out:
 	mutex_unlock(&s->ops_mutex);
Signature · 1 line
2.34.1
#1 lore raw

Am Sun, Dec 12, 2021 at 03:56:30PM +0800 schrieb Jason Wang:

Quoted 5 lines

The initial value of variable ret' is -EINVAL, which is used for returning the error status in pcmcia_release_io' when errors occur. But if there is no error in pcmcia_release_io', ret' should be changed to a successful value to return. Thus we change `ret' value to 0 when the function's status is successful.

Thanks for your patch! However, the sole user of pcmcia_release_io() is not interested in the return value anyway. Therefore, I'd suggest the following.

Thanks,
Dominik

pcmcia: make pcmcia_release_io() void, as no-one is interested in return value

As the only user of pcmcia_release_io() is not interested in its return value, and we cannot do anything on failure, convert the function to return void.

drivers/pcmcia/pcmcia_resource.c +1 -4
index c1c197292111..d78091e79a0f 100644
@@ -390,10 +390,9 @@ int pcmcia_release_configuration(struct pcmcia_device *p_dev)
  * "stale", we don't bother checking the port ranges against the
  * current socket values.
  */
-static int pcmcia_release_io(struct pcmcia_device *p_dev)
+static void pcmcia_release_io(struct pcmcia_device *p_dev)
 {
 	struct pcmcia_socket *s = p_dev->socket;
-	int ret = -EINVAL;
 	config_t *c;
 
 	mutex_lock(&s->ops_mutex);
@@ -412,8 +411,6 @@ static int pcmcia_release_io(struct pcmcia_device *p_dev)
 
 out:
 	mutex_unlock(&s->ops_mutex);
-
-	return ret;
 } /* pcmcia_release_io */