sdhci: Forward EPROBE_DEFER on vmmc and vqmmc regulators
PATCH 1/1 sdhci: Forward EPROBE_DEFER on vmmc and vqmmc regulators
If vmmc or vqmmc regulators are controlled by an I2C device, the request for the regulator is likely to fail because the I2C bus has not been probed yet. The sdhci then incorrectly assumes that the user never wanted to use a regulator anyway and continues without ever enabling or configuring the required regulator.
To solve this, when a required voltage regulator returns EPROBE_DEFER, signalling that the regulator exists but is not available yet, forward this error to the probe method instead of simply assuming that the user never wanted to use a regulator anyway.
Tested on a custom board that has an I2C regulator for one of the sdhcis and no regulators at all for the other. This patch enables such a system to work correctly.
--- drivers/mmc/host/sdhci.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci.c +6 -2
@@ -2972,6 +2972,8 @@ int sdhci_add_host(struct sdhci_host *host) host->vqmmc =regulator_get_optional (mmc_dev (mmc),"vqmmc" );if (IS_ERR_OR_NULL (host->vqmmc)) {if (PTR_ERR (host->vqmmc) <0 ) { +if (PTR_ERR (host->vqmmc) == -EPROBE_DEFER ) +return -EPROBE_DEFER ;pr_info ("%s: no vqmmc regulator found\n" ,mmc_hostname (mmc)); host->vqmmc =NULL ;
@@ -3048,8 +3050,10 @@ int sdhci_add_host(struct sdhci_host *host) host->vmmc =regulator_get_optional (mmc_dev (mmc),"vmmc" );if (IS_ERR_OR_NULL (host->vmmc)) {if (PTR_ERR (host->vmmc) <0 ) { -pr_info ("%s: no vmmc regulator found\n" , -mmc_hostname (mmc)); +if (PTR_ERR (host->vmmc) == -EPROBE_DEFER ) +return -EPROBE_DEFER ; +pr_info ("%s: no vmmc regulator found (%d)\n" , +mmc_hostname (mmc),PTR_ERR (host->vmmc)); host->vmmc =NULL ; } }
Signature · 1 line
1.7.9.5
Quoted 33 lines · Mike Looijmans
If vmmc or vqmmc regulators are controlled by an I2C device, the request for the regulator is likely to fail because the I2C bus has not been probed yet. The sdhci then incorrectly assumes that the user never wanted to use a regulator anyway and continues without ever enabling or configuring the required regulator.
To solve this, when a required voltage regulator returns
EPROBE_DEFER, signalling that the regulator exists but is not available yet, forward this error to the probe method instead of simply assuming that the user never wanted to use a regulator anyway.Tested on a custom board that has an I2C regulator for one of the sdhcis and no regulators at all for the other. This patch enables such a system to work correctly.
--- drivers/mmc/host/sdhci.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/mmc/host/sdhci.c +2
-0@@ -2972,6 +2972,8 @@ int sdhci_add_host(struct sdhci_host *host) host->vqmmc =regulator_get_optional (mmc_dev (mmc),"vqmmc" );if (IS_ERR_OR_NULL (host->vqmmc)) {if (PTR_ERR (host->vqmmc) <0 ) { +if (PTR_ERR (host->vqmmc) == -EPROBE_DEFER ) +return -EPROBE_DEFER ;pr_info ("%s: no vqmmc regulator found\n" ,mmc_hostname (mmc)); host->vqmmc =NULL ;
drivers/mmc/host/sdhci.c int sdhci_add_host(struct sdhci_host *host) · line 3055
Quoted 8 lines
drivers/mmc/host/sdhci.c +3
-2@@ -3048,8 +3050,10 @@ int sdhci_add_host(struct sdhci_host *host) host->vmmc =regulator_get_optional (mmc_dev (mmc),"vmmc" );if (IS_ERR_OR_NULL (host->vmmc)) {if (PTR_ERR (host->vmmc) <0 ) { -pr_info ("%s: no vmmc regulator found\n" , -mmc_hostname (mmc)); +if (PTR_ERR (host->vmmc) == -EPROBE_DEFER ) +return -EPROBE_DEFER ; + pr_info("%s: no vmmc regulator found (%d)\n",
I suggest using %ld here. The rest looks fine to me! Thanks!
drivers/mmc/host/sdhci.c int sdhci_add_host(struct sdhci_host *host) · line 3059
Quoted 5 lines
drivers/mmc/host/sdhci.c +1
-0+ mmc_hostname(mmc), PTR_ERR(host->vmmc)); host->vmmc =NULL ; } }
BR,
Georgi
Quoted 36 lines · Georgi Djakov
Quoted 35 lines · Mike Looijmans
If vmmc or vqmmc regulators are controlled by an I2C device, the request for the regulator is likely to fail because the I2C bus has not been probed yet. The sdhci then incorrectly assumes that the user never wanted to use a regulator anyway and continues without ever enabling or configuring the required regulator.
To solve this, when a required voltage regulator returns
EPROBE_DEFER, signalling that the regulator exists but is not available yet, forward this error to the probe method instead of simply assuming that the user never wanted to use a regulator anyway.Tested on a custom board that has an I2C regulator for one of the sdhcis and no regulators at all for the other. This patch enables such a system to work correctly.
--- drivers/mmc/host/sdhci.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/mmc/host/sdhci.c +2
-0@@ -2972,6 +2972,8 @@ int sdhci_add_host(struct sdhci_host *host) host->vqmmc =regulator_get_optional (mmc_dev (mmc),"vqmmc" );if (IS_ERR_OR_NULL (host->vqmmc)) {if (PTR_ERR (host->vqmmc) <0 ) { +if (PTR_ERR (host->vqmmc) == -EPROBE_DEFER ) +return -EPROBE_DEFER ;pr_info ("%s: no vqmmc regulator found\n" ,mmc_hostname (mmc)); host->vqmmc =NULL ;@@ -3048,8 +3050,10 @@ int sdhci_add_host(struct sdhci_host *host) host->vmmc =regulator_get_optional (mmc_dev (mmc),"vmmc" );if (IS_ERR_OR_NULL (host->vmmc)) {
Quoted 8 lines
drivers/mmc/host/sdhci.c int sdhci_add_host(struct sdhci_host *host) · line 3055
Quoted 6 lines
drivers/mmc/host/sdhci.c +3
-2if (PTR_ERR (host->vmmc) <0 ) { -pr_info ("%s: no vmmc regulator found\n" , -mmc_hostname (mmc)); +if (PTR_ERR (host->vmmc) == -EPROBE_DEFER ) +return -EPROBE_DEFER ; + pr_info("%s: no vmmc regulator found (%d)\n",I suggest using %ld here. The rest looks fine to me! Thanks!
Does this mean you're waiting for a patch v2 that I should submit?
Quoted 10 lines
drivers/mmc/host/sdhci.c int sdhci_add_host(struct sdhci_host *host) · line 3059
Quoted 6 lines
drivers/mmc/host/sdhci.c +1
-0+ mmc_hostname(mmc), PTR_ERR(host->vmmc)); host->vmmc =NULL ; } }BR,
Georgi
Signature · 1 line
Mike Looijmans
Quoted 46 lines · Mike Looijmans
Quoted 36 lines · Georgi Djakov
Quoted 35 lines · Mike Looijmans
If vmmc or vqmmc regulators are controlled by an I2C device, the request for the regulator is likely to fail because the I2C bus has not been probed yet. The sdhci then incorrectly assumes that the user never wanted to use a regulator anyway and continues without ever enabling or configuring the required regulator.
To solve this, when a required voltage regulator returns
EPROBE_DEFER, signalling that the regulator exists but is not available yet, forward this error to the probe method instead of simply assuming that the user never wanted to use a regulator anyway.Tested on a custom board that has an I2C regulator for one of the sdhcis and no regulators at all for the other. This patch enables such a system to work correctly.
--- drivers/mmc/host/sdhci.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/mmc/host/sdhci.c +2
-0@@ -2972,6 +2972,8 @@ int sdhci_add_host(struct sdhci_host *host) host->vqmmc =regulator_get_optional (mmc_dev (mmc),"vqmmc" );if (IS_ERR_OR_NULL (host->vqmmc)) {if (PTR_ERR (host->vqmmc) <0 ) { +if (PTR_ERR (host->vqmmc) == -EPROBE_DEFER ) +return -EPROBE_DEFER ;pr_info ("%s: no vqmmc regulator found\n" ,mmc_hostname (mmc)); host->vqmmc =NULL ;@@ -3048,8 +3050,10 @@ int sdhci_add_host(struct sdhci_host *host) host->vmmc =regulator_get_optional (mmc_dev (mmc),"vmmc" );if (IS_ERR_OR_NULL (host->vmmc)) {Quoted 8 lines
drivers/mmc/host/sdhci.c int sdhci_add_host(struct sdhci_host *host) · line 3055
Quoted 6 lines
drivers/mmc/host/sdhci.c +3
-2if (PTR_ERR (host->vmmc) <0 ) { -pr_info ("%s: no vmmc regulator found\n" , -mmc_hostname (mmc)); +if (PTR_ERR (host->vmmc) == -EPROBE_DEFER ) +return -EPROBE_DEFER ; + pr_info("%s: no vmmc regulator found (%d)\n",I suggest using %ld here. The rest looks fine to me! Thanks!
Quoted 2 lines
Does this mean you're waiting for a patch v2 that I should submit?
Yes, please submit v2 and hope to get some more feedback from the community.
Thanks,
Georgi
Quoted 10 lines
Quoted 10 lines
drivers/mmc/host/sdhci.c int sdhci_add_host(struct sdhci_host *host) · line 3059
Quoted 6 lines
drivers/mmc/host/sdhci.c +1
-0+ mmc_hostname(mmc), PTR_ERR(host->vmmc)); host->vmmc =NULL ; } }BR,
Georgi
PATCH 1/1 sdhci: Forward EPROBE_DEFER on vmmc and vqmmc regulators
In reply to Mike LooijmansIf vmmc or vqmmc regulators are controlled by an I2C device, the request for the regulator is likely to fail because the I2C bus has not been probed yet. The sdhci then incorrectly assumes that the user never wanted to use a regulator anyway and continues without ever enabling or configuring the required regulator.
To solve this, when a required voltage regulator returns EPROBE_DEFER, signalling that the regulator exists but is not available yet, forward this error to the probe method instead of simply assuming that the user never wanted to use a regulator anyway.
Tested on a custom board that has an I2C regulator for one of the sdhcis and no regulators at all for the other. This patch enables such a system to work correctly.
v2: Changed "%d" into "%ld" for PTR_ERR value.
--- drivers/mmc/host/sdhci.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci.c +6 -2
@@ -2972,6 +2972,8 @@ int sdhci_add_host(struct sdhci_host *host) host->vqmmc =regulator_get_optional (mmc_dev (mmc),"vqmmc" );if (IS_ERR_OR_NULL (host->vqmmc)) {if (PTR_ERR (host->vqmmc) <0 ) { +if (PTR_ERR (host->vqmmc) == -EPROBE_DEFER ) +return -EPROBE_DEFER ;pr_info ("%s: no vqmmc regulator found\n" ,mmc_hostname (mmc)); host->vqmmc =NULL ;
@@ -3048,8 +3050,10 @@ int sdhci_add_host(struct sdhci_host *host) host->vmmc =regulator_get_optional (mmc_dev (mmc),"vmmc" );if (IS_ERR_OR_NULL (host->vmmc)) {if (PTR_ERR (host->vmmc) <0 ) { -pr_info ("%s: no vmmc regulator found\n" , -mmc_hostname (mmc)); +if (PTR_ERR (host->vmmc) == -EPROBE_DEFER ) +return -EPROBE_DEFER ; +pr_info ("%s: no vmmc regulator found (%ld)\n" , +mmc_hostname (mmc),PTR_ERR (host->vmmc)); host->vmmc =NULL ; } }
Signature · 1 line
1.7.9.5
Quoted 12 lines · Mike Looijmans
If vmmc or vqmmc regulators are controlled by an I2C device, the request for the regulator is likely to fail because the I2C bus has not been probed yet. The sdhci then incorrectly assumes that the user never wanted to use a regulator anyway and continues without ever enabling or configuring the required regulator.
To solve this, when a required voltage regulator returns
EPROBE_DEFER, signalling that the regulator exists but is not available yet, forward this error to the probe method instead of simply assuming that the user never wanted to use a regulator anyway.
Quoted 3 lines
Tested on a custom board that has an I2C regulator for one of the sdhcis and no regulators at all for the other. This patch enables such a system to work correctly.
Missing Signed-off-by, could you resend?
Otherwise looks good, you may have my ack.
Kind regards
Ulf Hansson
Quoted 40 lines
v2: Changed "%d" into "%ld" for
PTR_ERRvalue.--- drivers/mmc/host/sdhci.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/mmc/host/sdhci.c +6
-3@@ -2972,6 +2972,8 @@ int sdhci_add_host(struct sdhci_host *host) host->vqmmc =regulator_get_optional (mmc_dev (mmc),"vqmmc" );if (IS_ERR_OR_NULL (host->vqmmc)) {if (PTR_ERR (host->vqmmc) <0 ) { +if (PTR_ERR (host->vqmmc) == -EPROBE_DEFER ) +return -EPROBE_DEFER ;pr_info ("%s: no vqmmc regulator found\n" ,mmc_hostname (mmc)); host->vqmmc =NULL ;@@ -3048,8 +3050,10 @@ int sdhci_add_host(struct sdhci_host *host) host->vmmc =regulator_get_optional (mmc_dev (mmc),"vmmc" );if (IS_ERR_OR_NULL (host->vmmc)) {if (PTR_ERR (host->vmmc) <0 ) { -pr_info ("%s: no vmmc regulator found\n" , -mmc_hostname (mmc)); +if (PTR_ERR (host->vmmc) == -EPROBE_DEFER ) +return -EPROBE_DEFER ; +pr_info ("%s: no vmmc regulator found (%ld)\n" , +mmc_hostname (mmc),PTR_ERR (host->vmmc)); host->vmmc =NULL ; } } --1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
PATCH 1/1 sdhci: Forward EPROBE_DEFER on vmmc and vqmmc regulators
In reply to Mike LooijmansIf vmmc or vqmmc regulators are controlled by an I2C device, the request for the regulator is likely to fail because the I2C bus has not been probed yet. The sdhci then incorrectly assumes that the user never wanted to use a regulator anyway and continues without ever enabling or configuring the required regulator.
To solve this, when a required voltage regulator returns EPROBE_DEFER, signalling that the regulator exists but is not available yet, forward this error to the probe method instead of simply assuming that the user never wanted to use a regulator anyway.
Tested on a custom board that has an I2C regulator for one of the sdhcis and no regulators at all for the other. This patch enables such a system to work correctly.
--- drivers/mmc/host/sdhci.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci.c +6 -2
@@ -2972,6 +2972,8 @@ int sdhci_add_host(struct sdhci_host *host) host->vqmmc =regulator_get_optional (mmc_dev (mmc),"vqmmc" );if (IS_ERR_OR_NULL (host->vqmmc)) {if (PTR_ERR (host->vqmmc) <0 ) { +if (PTR_ERR (host->vqmmc) == -EPROBE_DEFER ) +return -EPROBE_DEFER ;pr_info ("%s: no vqmmc regulator found\n" ,mmc_hostname (mmc)); host->vqmmc =NULL ;
@@ -3048,8 +3050,10 @@ int sdhci_add_host(struct sdhci_host *host) host->vmmc =regulator_get_optional (mmc_dev (mmc),"vmmc" );if (IS_ERR_OR_NULL (host->vmmc)) {if (PTR_ERR (host->vmmc) <0 ) { -pr_info ("%s: no vmmc regulator found\n" , -mmc_hostname (mmc)); +if (PTR_ERR (host->vmmc) == -EPROBE_DEFER ) +return -EPROBE_DEFER ; +pr_info ("%s: no vmmc regulator found (%d)\n" , +mmc_hostname (mmc),PTR_ERR (host->vmmc)); host->vmmc =NULL ; } }
Signature · 1 line
1.7.9.5
PATCH 1/1 sdhci: Forward EPROBE_DEFER on vmmc and vqmmc regulators
If vmmc or vqmmc regulators are controlled by an I2C device, the request for the regulator is likely to fail because the I2C bus has not been probed yet. The sdhci then incorrectly assumes that the user never wanted to use a regulator anyway and continues without ever enabling or configuring the required regulator.
To solve this, when a required voltage regulator returns EPROBE_DEFER, signalling that the regulator exists but is not available yet, forward this error to the probe method instead of simply assuming that the user never wanted to use a regulator anyway.
Tested on a custom board that has an I2C regulator for one of the sdhcis and no regulators at all for the other. This patch enables such a system to work correctly.
v2: Do not change logging output
--- drivers/mmc/host/sdhci.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/mmc/host/sdhci.c +4 -0
@@ -2972,6 +2972,8 @@ int sdhci_add_host(struct sdhci_host *host) host->vqmmc =regulator_get_optional (mmc_dev (mmc),"vqmmc" );if (IS_ERR_OR_NULL (host->vqmmc)) {if (PTR_ERR (host->vqmmc) <0 ) { +if (PTR_ERR (host->vqmmc) == -EPROBE_DEFER ) +return -EPROBE_DEFER ;pr_info ("%s: no vqmmc regulator found\n" ,mmc_hostname (mmc)); host->vqmmc =NULL ;
@@ -3048,6 +3050,8 @@ int sdhci_add_host(struct sdhci_host *host) host->vmmc =regulator_get_optional (mmc_dev (mmc),"vmmc" );if (IS_ERR_OR_NULL (host->vmmc)) {if (PTR_ERR (host->vmmc) <0 ) { +if (PTR_ERR (host->vmmc) == -EPROBE_DEFER ) +return -EPROBE_DEFER ;pr_info ("%s: no vmmc regulator found\n" ,mmc_hostname (mmc)); host->vmmc =NULL ;
Signature · 1 line
1.7.9.5
Quoted 14 lines · On Monday 07 April 2014 08:38:28 Mike Looijmans wrote:
index 34aef81..43b90c1 100644
drivers/mmc/host/sdhci.c +2
-0@@ -2972,6 +2972,8 @@ int sdhci_add_host(struct sdhci_host *host) host->vqmmc =regulator_get_optional (mmc_dev (mmc),"vqmmc" );if (IS_ERR_OR_NULL (host->vqmmc)) {if (PTR_ERR (host->vqmmc) <0 ) { +if (PTR_ERR (host->vqmmc) == -EPROBE_DEFER ) +return -EPROBE_DEFER ;pr_info ("%s: no vqmmc regulator found\n" ,mmc_hostname (mmc)); host->vqmmc =NULL ;@@ -3048,8 +3050,10 @@ int sdhci_add_host(struct sdhci_host *host) host->vmmc =regulator_get_optional (mmc_dev (mmc),"vmmc" );
drivers/mmc/host/sdhci.c int sdhci_add_host(struct sdhci_host *host) · line 3058
Quoted 10 lines
drivers/mmc/host/sdhci.c +4
-2if (IS_ERR_OR_NULL (host->vmmc)) {if (PTR_ERR (host->vmmc) <0 ) { -pr_info ("%s: no vmmc regulator found\n" , -mmc_hostname (mmc)); +if (PTR_ERR (host->vmmc) == -EPROBE_DEFER ) +return -EPROBE_DEFER ; +pr_info ("%s: no vmmc regulator found (%d)\n" , +mmc_hostname (mmc),PTR_ERR (host->vmmc)); host->vmmc =NULL ; }
Please change the code to not use IS_ERR_OR_NULL() instead, getting a NULL return value from regulator_get_optional() should not be considered a bug, while getting an error return should always cause the probe function to fail.
Arnd
Quoted 22 lines · Arnd Bergmann
Quoted 21 lines · On Monday 07 April 2014 08:38:28 Mike Looijmans wrote:
index 34aef81..43b90c1 100644
drivers/mmc/host/sdhci.c +5
-2@@ -2972,6 +2972,8 @@ int sdhci_add_host(struct sdhci_host *host) host->vqmmc =regulator_get_optional (mmc_dev (mmc),"vqmmc" );if (IS_ERR_OR_NULL (host->vqmmc)) {if (PTR_ERR (host->vqmmc) <0 ) { +if (PTR_ERR (host->vqmmc) == -EPROBE_DEFER ) +return -EPROBE_DEFER ;pr_info ("%s: no vqmmc regulator found\n" ,mmc_hostname (mmc)); host->vqmmc =NULL ;@@ -3048,8 +3050,10 @@ int sdhci_add_host(struct sdhci_host *host) host->vmmc =regulator_get_optional (mmc_dev (mmc),"vmmc" );if (IS_ERR_OR_NULL (host->vmmc)) {if (PTR_ERR (host->vmmc) <0 ) { -pr_info ("%s: no vmmc regulator found\n" , -mmc_hostname (mmc)); +if (PTR_ERR (host->vmmc) == -EPROBE_DEFER ) +return -EPROBE_DEFER ; + pr_info("%s: no vmmc regulator found (%d)\n",
Quoted 8 lines
drivers/mmc/host/sdhci.c int sdhci_add_host(struct sdhci_host *host) · line 3058
Quoted 3 lines
drivers/mmc/host/sdhci.c +1
-0+ mmc_hostname(mmc), PTR_ERR(host->vmmc)); host->vmmc =NULL ; }Please change the code to not use
IS_ERR_OR_NULL()instead, getting a NULL return value fromregulator_get_optional()should not be considered a bug, while getting an error return should always cause the probe function to fail.
Please make that a separate patch, because doing so will break most (if not all) boards using this controller.
Mike.
Met vriendelijke groet / kind regards,
Mike Looijmans
TOPIC Embedded Systems Eindhovenseweg 32-C, NL-5683 KH Best Postbus 440, NL-5680 AK Best
Telefoon: (+31) (0) 499 33 69 79
Telefax: (+31) (0) 499 33 69 70
E-mail: [email protected]
Website: www.topic.nl
Please consider the environment before printing this e-mail
Visit us at the Hannover Messe 7 - 11 April 2014 - Hall 002/D10 (Dutch Pavillion)
http://www.hannovermesse.de/exhibitor/topic-embedded-products/V229623
Quoted 23 lines · Mike Looijmans
Quoted 22 lines · Arnd Bergmann
Quoted 21 lines · On Monday 07 April 2014 08:38:28 Mike Looijmans wrote:
index 34aef81..43b90c1 100644
drivers/mmc/host/sdhci.c +5
-2@@ -2972,6 +2972,8 @@ int sdhci_add_host(struct sdhci_host *host) host->vqmmc =regulator_get_optional (mmc_dev (mmc),"vqmmc" );if (IS_ERR_OR_NULL (host->vqmmc)) {if (PTR_ERR (host->vqmmc) <0 ) { +if (PTR_ERR (host->vqmmc) == -EPROBE_DEFER ) +return -EPROBE_DEFER ;pr_info ("%s: no vqmmc regulator found\n" ,mmc_hostname (mmc)); host->vqmmc =NULL ;@@ -3048,8 +3050,10 @@ int sdhci_add_host(struct sdhci_host *host) host->vmmc =regulator_get_optional (mmc_dev (mmc),"vmmc" );if (IS_ERR_OR_NULL (host->vmmc)) {if (PTR_ERR (host->vmmc) <0 ) { -pr_info ("%s: no vmmc regulator found\n" , -mmc_hostname (mmc)); +if (PTR_ERR (host->vmmc) == -EPROBE_DEFER ) +return -EPROBE_DEFER ; + pr_info("%s: no vmmc regulator found (%d)\n",
Quoted 8 lines
Quoted 8 lines
drivers/mmc/host/sdhci.c int sdhci_add_host(struct sdhci_host *host) · line 3058
Quoted 3 lines
drivers/mmc/host/sdhci.c +1
-0+ mmc_hostname(mmc), PTR_ERR(host->vmmc)); host->vmmc =NULL ; }Please change the code to not use
IS_ERR_OR_NULL()instead, getting a NULL return value fromregulator_get_optional()should not be considered a bug, while getting an error return should always cause the probe function to fail.
Surely it needs to be changed to IS_ERR(), nor IS_ERR_OR_NULL()?
Signature · 2 lines
Ben Dooks http://www.codethink.co.uk/ Senior Engineer Codethink - Providing Genius
Quoted 34 lines · Ben Dooks
Quoted 24 lines · Mike Looijmans
Quoted 23 lines · Arnd Bergmann
Quoted 22 lines · On Monday 07 April 2014 08:38:28 Mike Looijmans wrote:
index 34aef81..43b90c1 100644
drivers/mmc/host/sdhci.c +6
-2@@ -2972,6 +2972,8 @@ int sdhci_add_host(struct sdhci_host *host) host->vqmmc =regulator_get_optional (mmc_dev (mmc),"vqmmc" );if (IS_ERR_OR_NULL (host->vqmmc)) {if (PTR_ERR (host->vqmmc) <0 ) { +if (PTR_ERR (host->vqmmc) == -EPROBE_DEFER ) +return -EPROBE_DEFER ;pr_info ("%s: no vqmmc regulator found\n" ,mmc_hostname (mmc)); host->vqmmc =NULL ;@@ -3048,8 +3050,10 @@ int sdhci_add_host(struct sdhci_host *host) host->vmmc =regulator_get_optional (mmc_dev (mmc),"vmmc" );if (IS_ERR_OR_NULL (host->vmmc)) {if (PTR_ERR (host->vmmc) <0 ) { -pr_info ("%s: no vmmc regulator found\n" , -mmc_hostname (mmc)); +if (PTR_ERR (host->vmmc) == -EPROBE_DEFER ) +return -EPROBE_DEFER ; + pr_info("%s: no vmmc regulator found (%d)\n", + mmc_hostname(mmc),Quoted 8 lines
Quoted 8 lines
drivers/mmc/host/sdhci.c int sdhci_add_host(struct sdhci_host *host) · line 3058
Quoted 3 lines
drivers/mmc/host/sdhci.c +0
-0PTR_ERR(host->vmmc)); host->vmmc =NULL ; }Please change the code to not use
IS_ERR_OR_NULL()instead, getting a NULL return value fromregulator_get_optional()should not be considered a bug, while getting an error return should always cause the probe function to fail.
Quoted 1 line
Surely it needs to be changed to
IS_ERR(), norIS_ERR_OR_NULL()?
And by that, I mean the use of "PTR_ERR(host->vmmc) < 0" to be changed to IS_ERR(), which I think Arnd was originally complaining about.
Signature · 2 lines
Ben Dooks http://www.codethink.co.uk/ Senior Engineer Codethink - Providing Genius
Quoted 35 lines · On Monday 07 April 2014 13:18:54 Ben Dooks wrote:
Quoted 34 lines · Ben Dooks
Quoted 32 lines · Mike Looijmans
Quoted 31 lines · Arnd Bergmann
Quoted 15 lines · On Monday 07 April 2014 08:38:28 Mike Looijmans wrote:
index 34aef81..43b90c1 100644
drivers/mmc/host/sdhci.c +2
-0@@ -2972,6 +2972,8 @@ int sdhci_add_host(struct sdhci_host *host) host->vqmmc =regulator_get_optional (mmc_dev (mmc),"vqmmc" );if (IS_ERR_OR_NULL (host->vqmmc)) {if (PTR_ERR (host->vqmmc) <0 ) { +if (PTR_ERR (host->vqmmc) == -EPROBE_DEFER ) +return -EPROBE_DEFER ;pr_info ("%s: no vqmmc regulator found\n" ,mmc_hostname (mmc)); host->vqmmc =NULL ;@@ -3048,8 +3050,10 @@ int sdhci_add_host(struct sdhci_host *host) host->vmmc =regulator_get_optional (mmc_dev (mmc),"vmmc" );if (IS_ERR_OR_NULL (host->vmmc)) {drivers/mmc/host/sdhci.c int sdhci_add_host(struct sdhci_host *host) · line 3059
Quoted 10 lines
drivers/mmc/host/sdhci.c +4
-2if (PTR_ERR (host->vmmc) <0 ) { -pr_info ("%s: no vmmc regulator found\n" , -mmc_hostname (mmc)); +if (PTR_ERR (host->vmmc) == -EPROBE_DEFER ) +return -EPROBE_DEFER ; +pr_info ("%s: no vmmc regulator found (%d)\n" , +mmc_hostname (mmc),PTR_ERR (host->vmmc)); host->vmmc =NULL ; }Please change the code to not use
IS_ERR_OR_NULL()instead, getting a NULL return value fromregulator_get_optional()should not be considered a bug, while getting an error return should always cause the probe function to fail.
Quoted 6 lines
Quoted 1 line
Surely it needs to be changed to
IS_ERR(), norIS_ERR_OR_NULL()?And by that, I mean the use of "
PTR_ERR(host->vmmc)< 0" to be changed toIS_ERR(), which I think Arnd was originally complaining about.
I mean something like
host->vqmmc = regulator_get_optional(mmc_dev(mmc), "vqmmc");
if (IS_ERR(host->vqmmc)) {
if (PTR_ERR(host->vqmmc) != -EPROBE_DEFER)
complain(); /* only print a message if we won't retry */
return ERR_PTR(host->vqmmc); /* never ignore an error */
}
/* silently continue if no regulator is defined */regulator_get_optional() means we can continue if it's not there, but we should not continue if there is a regulator that we fail to use for some reason.
As has been found a number of times, any use of IS_ERR_OR_NULL() means that the person responsible for the code is confused about what the API is supposed to be.
Arnd
Quoted 54 lines · Arnd Bergmann
Quoted 35 lines · On Monday 07 April 2014 13:18:54 Ben Dooks wrote:
Quoted 34 lines · Ben Dooks
Quoted 32 lines · Mike Looijmans
Quoted 31 lines · Arnd Bergmann
Quoted 15 lines · On Monday 07 April 2014 08:38:28 Mike Looijmans wrote:
index 34aef81..43b90c1 100644
drivers/mmc/host/sdhci.c +2
-0@@ -2972,6 +2972,8 @@ int sdhci_add_host(struct sdhci_host *host) host->vqmmc =regulator_get_optional (mmc_dev (mmc),"vqmmc" );if (IS_ERR_OR_NULL (host->vqmmc)) {if (PTR_ERR (host->vqmmc) <0 ) { +if (PTR_ERR (host->vqmmc) == -EPROBE_DEFER ) +return -EPROBE_DEFER ;pr_info ("%s: no vqmmc regulator found\n" ,mmc_hostname (mmc)); host->vqmmc =NULL ;@@ -3048,8 +3050,10 @@ int sdhci_add_host(struct sdhci_host *host) host->vmmc =regulator_get_optional (mmc_dev (mmc),"vmmc" );if (IS_ERR_OR_NULL (host->vmmc)) {drivers/mmc/host/sdhci.c int sdhci_add_host(struct sdhci_host *host) · line 3059
Quoted 10 lines
drivers/mmc/host/sdhci.c +4
-2if (PTR_ERR (host->vmmc) <0 ) { -pr_info ("%s: no vmmc regulator found\n" , -mmc_hostname (mmc)); +if (PTR_ERR (host->vmmc) == -EPROBE_DEFER ) +return -EPROBE_DEFER ; +pr_info ("%s: no vmmc regulator found (%d)\n" , +mmc_hostname (mmc),PTR_ERR (host->vmmc)); host->vmmc =NULL ; }Please change the code to not use
IS_ERR_OR_NULL()instead, getting a NULL return value fromregulator_get_optional()should not be considered a bug, while getting an error return should always cause the probe function to fail.Quoted 6 lines
Quoted 1 line
Surely it needs to be changed to
IS_ERR(), norIS_ERR_OR_NULL()?And by that, I mean the use of "
PTR_ERR(host->vmmc)< 0" to be changed toIS_ERR(), which I think Arnd was originally complaining about.I mean something like
host->vqmmc = regulator_get_optional(mmc_dev(mmc), "vqmmc"); if (IS_ERR(host->vqmmc)) { if (PTR_ERR(host->vqmmc) != -EPROBE_DEFER) complain(); /* only print a message if we won't retry */ return ERR_PTR(host->vqmmc); /* never ignore an error */ } /* silently continue if no regulator is defined */
Quoted 7 lines
regulator_get_optional()means we can continue if it's not there, but we should not continue if there is a regulator that we fail to use for some reason.As has been found a number of times, any use of
IS_ERR_OR_NULL()means that the person responsible for the code is confused about what the API is supposed to be.
Judging from the kernel output, regulator_get_optional returns -ENODEV if the supply wasn't found.
Maybe the API is confusing (or wrong?) here.
If you change the code as per your suggestion, the SD will not work unless you explicitly assign supplies. And judging from what I've seen so far, I am the first to have ever attached a power supply to this controller...
Mike.
Met vriendelijke groet / kind regards,
Mike Looijmans
TOPIC Embedded Systems Eindhovenseweg 32-C, NL-5683 KH Best Postbus 440, NL-5680 AK Best
Telefoon: (+31) (0) 499 33 69 79
Telefax: (+31) (0) 499 33 69 70
E-mail: [email protected]
Website: www.topic.nl
Please consider the environment before printing this e-mail
Visit us at the Hannover Messe 7 - 11 April 2014 - Hall 002/D10 (Dutch Pavillion)
http://www.hannovermesse.de/exhibitor/topic-embedded-products/V229623
Quoted 10 lines · On Monday 07 April 2014 14:32:20 Mike Looijmans wrote:
On 04/07/2014 02:25 PM, Arnd Bergmann wrote:
Judging from the kernel output,
regulator_get_optionalreturns-ENODEVif the supply wasn't found.Maybe the API is confusing (or wrong?) here.
If you change the code as per your suggestion, the SD will not work unless you explicitly assign supplies. And judging from what I've seen so far, I am the first to have ever attached a power supply to this controller...
It's certainly not very "optional" if it returns an error here.
You could try to special-case the "-ENODEV" return here, but I think it would be better to change the regulator interface to be less confusing.
Arnd
Quoted 8 lines · Arnd Bergmann
Quoted 7 lines · On Monday 07 April 2014 14:32:20 Mike Looijmans wrote:
On 04/07/2014 02:25 PM, Arnd Bergmann wrote:
Judging from the kernel output,
regulator_get_optionalreturns-ENODEVif the supply wasn't found.Maybe the API is confusing (or wrong?) here.
Quoted 9 lines
Quoted 3 lines
If you change the code as per your suggestion, the SD will not work unless you explicitly assign supplies. And judging from what I've seen so far, I am the first to have ever attached a power supply to this controller...
It's certainly not very "optional" if it returns an error here.
You could try to special-case the "
-ENODEV" return here, but I think it would be better to change the regulator interface to be less confusing.
Judging from the code:
http://lxr.free-electrons.com/source/drivers/regulator/core.c#L1476
The behaviour is supposed to be something like "regulator_get_optional" will return an error if the supply wasn't found, but "regulator_get" will create a dummy supply for you instead of returning an error code.
So "regulator_get_optional" means: "I handle my own problems, just gimme the bad news". But "regulator_get" appears to imply: "I will shoot the messenger, so do whatever you can to get me something to say 'enable' to".
In this case, the IS_NULL part is wrong indeed, it will never return NULL.
I still think it's unrelated to my patch and should be submitted separately.
Mike.
Met vriendelijke groet / kind regards,
Mike Looijmans
TOPIC Embedded Systems Eindhovenseweg 32-C, NL-5683 KH Best Postbus 440, NL-5680 AK Best
Telefoon: (+31) (0) 499 33 69 79
Telefax: (+31) (0) 499 33 69 70
E-mail: [email protected]
Website: www.topic.nl
Please consider the environment before printing this e-mail
Visit us at the Hannover Messe 7 - 11 April 2014 - Hall 002/D10 (Dutch Pavillion)
http://www.hannovermesse.de/exhibitor/topic-embedded-products/V229623
Hi Mike,
Quoted 32 lines · Mike Looijmans
Quoted 18 lines · Arnd Bergmann
Quoted 7 lines · On Monday 07 April 2014 14:32:20 Mike Looijmans wrote:
On 04/07/2014 02:25 PM, Arnd Bergmann wrote:
Judging from the kernel output,
regulator_get_optionalreturns-ENODEVif the
supply wasn't found.Quoted 7 lines
Maybe the API is confusing (or wrong?) here.
If you change the code as per your suggestion, the SD will not work unless you
explicitly assign supplies. And judging from what I've seen so far, I am the
first to have ever attached a power supply to this controller...Quoted 5 lines
It's certainly not very "optional" if it returns an error here.
You could try to special-case the "
-ENODEV" return here, but I think it would be better to change the regulator interface to be less confusing.Judging from the code:
http://lxr.free-electrons.com/source/drivers/regulator/core.c#L1476The behaviour is supposed to be something like "
regulator_get_optional" will return an error if the supply wasn't found, but "regulator_get" will create a dummy supply for you instead of returning an error code.
Quoted 5 lines
So "
regulator_get_optional" means: "I handle my own problems, just gimme the bad news". But "regulator_get" appears to imply: "I will shoot the messenger, so do whatever you can to get me something to say 'enable' to".In this case, the
IS_NULLpart is wrong indeed, it will never return NULL.
Not true. If !CONFIG_REGULATOR, regulator_get() and co. will return NULL. Normally it is ok to ignore this case, but the sdhci driver will call regulator_is_supported_voltage() on vqmmc to determine whether 1.8V signalling is supported. With !CONFIG_REGULATOR, regulator_is_supported_voltage() will always return false, causing the sdhci driver to disable all UHS modes. So we still need to handle the NULL (!CONFIG_REGULATOR) case. One possibility is to guard the voltage check with #ifdef CONFIG_REGULATOR, as is done later with vmmc.
BTW, I was working on a similar patch at:
https://patchwork.kernel.org/patch/3988271/.
Thanks,
Andrew
Quoted 30 lines
I still think it's unrelated to my patch and should be submitted separately.
Mike.
Met vriendelijke groet / kind regards,
Mike Looijmans
TOPIC Embedded Systems
Eindhovenseweg 32-C, NL-5683 KH Best
Postbus 440, NL-5680 AK Best
Telefoon: (+31) (0) 499 33 69 79
Telefax: (+31) (0) 499 33 69 70
E-mail: [email protected]
Website: www.topic.nlPlease consider the environment before printing this e-mail
Visit us at the Hannover Messe 7 - 11 April 2014 - Hall 002/D10 (Dutch Pavillion)
http://www.hannovermesse.de/exhibitor/topic-embedded-products/V229623--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Quoted 9 lines · Andrew Bresticker
Not true. If !CONFIG_REGULATOR,
regulator_get()and co. will return NULL. Normally it is ok to ignore this case, but the sdhci driver will callregulator_is_supported_voltage()on vqmmc to determine whether 1.8V signalling is supported. With !CONFIG_REGULATOR,regulator_is_supported_voltage()will always return false, causing the sdhci driver to disable all UHS modes. So we still need to handle the NULL (!CONFIG_REGULATOR) case. One possibility is to guard the voltage check with #ifdefCONFIG_REGULATOR, as is done later with vmmc.
It seems better to just fix regulator_get_optional() to return an error if the API is disabled, that case didn't really get considered since it's a bit surprising that something actively using regulators (rather than simply ensuring they're enabled) would be using that function. Though if you already have ifdefs the ifdef is probably fine.