Skip to contentSkip to conversation

bus: mhi: core: Fix some error return code

PATCH In review Wei Yongjun 4 participants 5 messages May 9, 2020 – May 11, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bus: mhi: core: Fix some error return code

Fix to return negative error code from the error handling case instead of 0 in mhi_init_dev_ctxt() and mhi_driver_probe().

Fixes 3000f85b8f47 ("bus: mhi: core: Add support for basic PM operations")
---
 drivers/bus/mhi/core/init.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/bus/mhi/core/init.c +2 -0
index eb2ab058a01d..1f8c82603179 100644
@@ -291,6 +291,7 @@ int mhi_init_dev_ctxt(struct mhi_controller *mhi_cntrl)
 	}
 
 	/* Setup cmd context */
+	ret = -ENOMEM;
 	mhi_ctxt->cmd_ctxt = mhi_alloc_coherent(mhi_cntrl,
 						sizeof(*mhi_ctxt->cmd_ctxt) *
 						NR_OF_CMD_RINGS,
@@ -1100,6 +1101,7 @@ static int mhi_driver_probe(struct device *dev)
 		}
 	}
 
+	ret = -EINVAL;
 	if (dl_chan) {
 		/*
 		 * If channel supports LPM notifications then status_cb should
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Wei Yongjun

Fix to return negative error code from the error handling case instead of 0 in mhi_init_dev_ctxt() and mhi_driver_probe().

Fixes 3000f85b8f47 ("bus: mhi: core: Add support for basic PM operations")

Thanks,
Mani

Quoted 27 lines
---
 drivers/bus/mhi/core/init.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/bus/mhi/core/init.c +2 -0
index eb2ab058a01d..1f8c82603179 100644
@@ -291,6 +291,7 @@ int mhi_init_dev_ctxt(struct mhi_controller *mhi_cntrl)
 	}
 
 	/* Setup cmd context */
+	ret = -ENOMEM;
 	mhi_ctxt->cmd_ctxt = mhi_alloc_coherent(mhi_cntrl,
 						sizeof(*mhi_ctxt->cmd_ctxt) *
 						NR_OF_CMD_RINGS,
@@ -1100,6 +1101,7 @@ static int mhi_driver_probe(struct device *dev)
 		}
 	}
 
+	ret = -EINVAL;
 	if (dl_chan) {
 		/*
 		 * If channel supports LPM notifications then status_cb should
Reviewed-by Manivannan Sadhasivam
#2 lore raw

Hello guys,
some nitpicking ...
the prefered kernalstyle is:

if (condition)
set error_code
do something

from what i can see it is

set error_code
if (condition)

jm2c
re,
wh

________________________________________
Von: [email protected] <[email protected]> im Auftrag von Manivannan Sadhasivam <[email protected]>
Gesendet: Montag, 11. Mai 2020 12:31:24
An: Wei Yongjun
Cc: Hemant Kumar; Jeffrey Hugo; Greg Kroah-Hartman; Sujeev Dias; Siddartha Mohanadoss; [email protected]; [email protected]; Hulk Robot
Betreff: Re: [PATCH -next] bus: mhi: core: Fix some error return code

Quoted 6 lines · Wei Yongjun

Fix to return negative error code from the error handling case instead of 0 in mhi_init_dev_ctxt() and mhi_driver_probe().

Fixes 3000f85b8f47 ("bus: mhi: core: Add support for basic PM operations")

Thanks,
Mani

Quoted 27 lines
---
 drivers/bus/mhi/core/init.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/bus/mhi/core/init.c +2 -0
index eb2ab058a01d..1f8c82603179 100644
@@ -291,6 +291,7 @@ int mhi_init_dev_ctxt(struct mhi_controller *mhi_cntrl)
      }
 
      /* Setup cmd context */
+     ret = -ENOMEM;
      mhi_ctxt->cmd_ctxt = mhi_alloc_coherent(mhi_cntrl,
                                              sizeof(*mhi_ctxt->cmd_ctxt) *
                                              NR_OF_CMD_RINGS,
@@ -1100,6 +1101,7 @@ static int mhi_driver_probe(struct device *dev)
              }
      }
 
+     ret = -EINVAL;
      if (dl_chan) {
              /*
               * If channel supports LPM notifications then status_cb should
#3 lore raw
Quoted 4 lines · Walter Harms

Hello guys,
some nitpicking ...
the prefered kernalstyle is:

Quoted 9 lines

if (condition)
set error_code
do something

from what i can see it is

set error_code
if (condition)

There are multiple error paths which share the same error code. So I don't see any benefit of setting same error code in all the paths.

The recommended style makes perfect sense for an error path which has a unique error code but not for the above.

Thanks,
Mani

Quoted 51 lines

jm2c
re,
wh

________________________________________
Von: [email protected] <[email protected]> im Auftrag von Manivannan Sadhasivam <[email protected]>
Gesendet: Montag, 11. Mai 2020 12:31:24
An: Wei Yongjun
Cc: Hemant Kumar; Jeffrey Hugo; Greg Kroah-Hartman; Sujeev Dias; Siddartha Mohanadoss; [email protected]; [email protected]; Hulk Robot
Betreff: Re: [PATCH -next] bus: mhi: core: Fix some error return code

Quoted 6 lines · Wei Yongjun

Fix to return negative error code from the error handling case instead of 0 in mhi_init_dev_ctxt() and mhi_driver_probe().

Fixes 3000f85b8f47 ("bus: mhi: core: Add support for basic PM operations")

Thanks,
Mani

Quoted 27 lines
---
 drivers/bus/mhi/core/init.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/bus/mhi/core/init.c +2 -0
index eb2ab058a01d..1f8c82603179 100644
@@ -291,6 +291,7 @@ int mhi_init_dev_ctxt(struct mhi_controller *mhi_cntrl)
      }
 
      /* Setup cmd context */
+     ret = -ENOMEM;
      mhi_ctxt->cmd_ctxt = mhi_alloc_coherent(mhi_cntrl,
                                              sizeof(*mhi_ctxt->cmd_ctxt) *
                                              NR_OF_CMD_RINGS,
@@ -1100,6 +1101,7 @@ static int mhi_driver_probe(struct device *dev)
              }
      }
 
+     ret = -EINVAL;
      if (dl_chan) {
              /*
               * If channel supports LPM notifications then status_cb should
#4 lore raw
In reply to Walter Harms
Quoted 4 lines · Walter Harms

Hello guys,
some nitpicking ...
the prefered kernalstyle is:

Quoted 8 lines

if (condition)
set error_code
do something

from what i can see it is

set error_code
if (condition)

There isn't a prefered style. Both are accepted. Most people have a personal preference, but there isn't an official preference.

regards,
dan carpenter