mmc: mmc_getcd/getwp: use sensible defaults
PATCH 1/2 mmc: mmc_getcd/getwp: use sensible defaults
Let mmc_getcd() return true and mmc_getwp() false if mmc driver doesn't provide handlers for them.
--- drivers/mmc/mmc.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/mmc/mmc.c +10 -4
@@ -51,8 +51,11 @@ int mmc_getwp(struct mmc *mmc) wp =board_mmc_getwp (mmc); -if ((wp <0 ) && mmc->getwp) - wp = mmc->getwp (mmc); +if (wp <0 ) +if (mmc->getwp) + wp = mmc->getwp (mmc); +else + wp =0 ;return wp; }
@@ -692,8 +695,11 @@ int mmc_getcd(struct mmc *mmc) cd =board_mmc_getcd (mmc); -if ((cd <0 ) && mmc->getcd) - cd = mmc->getcd (mmc); +if (cd <0 ) +if (mmc->getcd) + cd = mmc->getcd (mmc); +else + cd =1 ;return cd; }
Signature · 1 line
1.7.10.4
PATCH 2/2 mmc: omap_hsmmc.c: only register getcd/getwp callbacks if gpio could be used
Gets rid of warnings from omap_gpio:
ERROR : check_gpio: invalid GPIO -1
(and undefined behaviour as the -1 error code is interpreted as gpio value)
--- drivers/mmc/omap_hsmmc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/mmc/omap_hsmmc.c +6 -2
@@ -593,8 +593,6 @@ int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max, int cd_gpio, mmc->send_cmd = mmc_send_cmd; mmc->set_ios = mmc_set_ios; mmc->init = mmc_init_setup; - mmc->getcd = omap_mmc_getcd; - mmc->getwp = omap_mmc_getwp; mmc->priv = priv_data;switch (dev_index) {
@@ -616,7 +614,13 @@ int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max, int cd_gpio,return 1 ; } priv_data->cd_gpio =omap_mmc_setup_gpio_in (cd_gpio,"mmc_cd" ); +if (priv_data->cd_gpio !=-1 ) + mmc->getcd = omap_mmc_getcd; + priv_data->wp_gpio =omap_mmc_setup_gpio_in (wp_gpio,"mmc_wp" ); +if (priv_data->wp_gpio !=-1 ) + mmc->getwp = omap_mmc_getwp; + mmc->voltages =MMC_VDD_32_33 |MMC_VDD_33_34 |MMC_VDD_165_195 ; mmc->host_caps = (MMC_MODE_4BIT | MMC_MODE_HS_52MHz |MMC_MODE_HS |MMC_MODE_HC ) & ~host_caps_mask;
Signature · 1 line
1.7.10.4
PATCH 2/2 mmc: omap_hsmmc.c: only register getcd/getwp callbacks if gpio could be used
Quoted 24 lines · Peter Korsgaard
Gets rid of warnings from
omap_gpio:
ERROR :check_gpio: invalid GPIO -1(and undefined behaviour as the -1 error code is interpreted as gpio value)
Signed-off-by Peter Korsgaard <[email protected]>--- drivers/mmc/omap_hsmmc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/mmc/omap_hsmmc.c +0
-2@@ -593,8 +593,6 @@ int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max, int cd_gpio, mmc->send_cmd = mmc_send_cmd; mmc->set_ios = mmc_set_ios; mmc->init = mmc_init_setup; - mmc->getcd = omap_mmc_getcd; - mmc->getwp = omap_mmc_getwp; mmc->priv = priv_data;switch (dev_index) {
drivers/mmc/omap_hsmmc.c int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max, int cd_gpio, · line 623
Quoted 10 lines
drivers/mmc/omap_hsmmc.c +6
-0@@ -616,7 +614,13 @@ int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max, int cd_gpio,return 1 ; } priv_data->cd_gpio =omap_mmc_setup_gpio_in (cd_gpio,"mmc_cd" ); +if (priv_data->cd_gpio !=-1 ) + mmc->getcd = omap_mmc_getcd; + priv_data->wp_gpio =omap_mmc_setup_gpio_in (wp_gpio,"mmc_wp" ); +if (priv_data->wp_gpio !=-1 ) + mmc->getwp = omap_mmc_getwp; +
OK, but this should be gpio_is_valid rather than != -1, and then this is probably a better way than my series.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130321/90359c77/attachment.pgp>
PATCH 2/2 mmc: omap_hsmmc.c: only register getcd/getwp callbacks if gpio could be used
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Tom" == Tom Rini <[email protected]> writes:
priv_data-> cd_gpio = omap_mmc_setup_gpio_in(cd_gpio, "mmc_cd");
Quoted 3 lines
drivers/mmc/omap_hsmmc.c int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max, int cd_gpio, · line 619
Quoted 3 lines
drivers/mmc/omap_hsmmc.c +3
-0+if (priv_data->cd_gpio !=-1 ) + mmc->getcd = omap_mmc_getcd; +
priv_data-> wp_gpio = omap_mmc_setup_gpio_in(wp_gpio, "mmc_wp");
Quoted 3 lines
drivers/mmc/omap_hsmmc.c int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max, int cd_gpio, · line 623
Quoted 3 lines
drivers/mmc/omap_hsmmc.c +3
-0+if (priv_data->wp_gpio !=-1 ) + mmc->getwp = omap_mmc_getwp; +
Tom> OK, but this should be gpio_is_valid rather than != -1, and then this is Tom> probably a better way than my series.
Well, omap_mmc_setup_gpio_in() explicitly return -1 on errors (could be a valid gpio, just already reserved or unable to make input).
Signature · 1 line
Bye, Peter Korsgaard
PATCH 2/2 mmc: omap_hsmmc.c: only register getcd/getwp callbacks if gpio could be used
Quoted 14 lines · Peter Korsgaard
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Tom" == Tom Rini <[email protected]> writes:
priv_data->
cd_gpio=omap_mmc_setup_gpio_in(cd_gpio, "mmc_cd");Quoted 3 lines
drivers/mmc/omap_hsmmc.c int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max, int cd_gpio, · line 619
Quoted 3 lines
drivers/mmc/omap_hsmmc.c +3
-0+if (priv_data->cd_gpio !=-1 ) + mmc->getcd = omap_mmc_getcd; +priv_data->
wp_gpio=omap_mmc_setup_gpio_in(wp_gpio, "mmc_wp");Quoted 3 lines
drivers/mmc/omap_hsmmc.c int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max, int cd_gpio, · line 623
Quoted 3 lines
drivers/mmc/omap_hsmmc.c +3
-0+if (priv_data->wp_gpio !=-1 ) + mmc->getwp = omap_mmc_getwp; +Tom> OK, but this should be
gpio_is_validrather than != -1, and then this is Tom> probably a better way than my series.
Quoted 2 lines
Well,
omap_mmc_setup_gpio_in()explicitly return -1 on errors (could be a valid gpio, just already reserved or unable to make input).
Ah, OK, that works.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130321/39c71e8d/attachment.pgp>
PATCH 2/2 mmc: omap_hsmmc.c: only register getcd/getwp callbacks if gpio could be used
In reply to Peter KorsgaardQuoted 6 lines · Peter Korsgaard
Gets rid of warnings from
omap_gpio:
ERROR :check_gpio: invalid GPIO -1(and undefined behaviour as the -1 error code is interpreted as gpio value)
Signed-off-by Peter Korsgaard <[email protected]>
Applied to u-boot-ti/master (and already pulled into u-boot-arm), thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130326/e399d8c4/attachment.pgp>
PATCH 1/2 mmc: mmc_getcd/getwp: use sensible defaults
In reply to Peter KorsgaardQuoted 4 lines · Peter Korsgaard
Let
mmc_getcd()return true andmmc_getwp()false if mmc driver doesn't provide handlers for them.Signed-off-by Peter Korsgaard <[email protected]>
Do we really need to do this? It seems like we should be working correctly here already, or we also need to fixup the weak function and/or the callers too.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130321/48683a45/attachment.pgp>
PATCH 1/2 mmc: mmc_getcd/getwp: use sensible defaults
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Tom" == Tom Rini <[email protected]> writes:
Quoted 4 lines · Peter Korsgaard
Quoted 4 lines
Let
mmc_getcd()return true andmmc_getwp()false if mmc driver doesn't provide handlers for them.Signed-off-by Peter Korsgaard <[email protected]>
Tom> Do we really need to do this? It seems like we should be working Tom> correctly here already, or we also need to fixup the weak function Tom> and/or the callers too.
Well, for omap_hsmmc we currently return -1, which is kind of okay for getcd(), but if getwp() ever gets used it means we cannot write to cards.
Signature · 1 line
Bye, Peter Korsgaard
PATCH 1/2 mmc: mmc_getcd/getwp: use sensible defaults
In reply to Peter KorsgaardQuoted 30 lines · Peter Korsgaard
Let
mmc_getcd()return true andmmc_getwp()false if mmc driver doesn't provide handlers for them.Signed-off-by Peter Korsgaard <[email protected]>--- drivers/mmc/mmc.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)drivers/mmc/mmc.c +5
-2@@ -51,8 +51,11 @@ int mmc_getwp(struct mmc *mmc) wp =board_mmc_getwp (mmc); -if ((wp <0 ) && mmc->getwp) - wp = mmc->getwp (mmc); +if (wp <0 ) +if (mmc->getwp) + wp = mmc->getwp (mmc); +else + wp =0 ;return wp; }@@ -692,8 +695,11 @@ int mmc_getcd(struct mmc *mmc) cd =board_mmc_getcd (mmc);
drivers/mmc/mmc.c int mmc_getcd(struct mmc *mmc) · line 705
Quoted 10 lines
drivers/mmc/mmc.c +5
-2-if ((cd <0 ) && mmc->getcd) - cd = mmc->getcd (mmc); +if (cd <0 ) +if (mmc->getcd) + cd = mmc->getcd (mmc); +else + cd =1 ;return cd; }
With the following to fix a build warning:
drivers/mmc/mmc.c +4 -2
@@ -51,11 +51,12 @@ int mmc_getwp(struct mmc *mmc) wp =board_mmc_getwp (mmc); -if (wp <0 ) +if (wp <0 ) {if (mmc->getwp) wp = mmc->getwp (mmc);else wp =0 ; + }return wp; }
@@ -695,11 +696,12 @@ int mmc_getcd(struct mmc *mmc) cd =board_mmc_getcd (mmc); -if (cd <0 ) +if (cd <0 ) {if (mmc->getcd) cd = mmc->getcd (mmc);else cd =1 ; + }return cd; }
Applied to u-boot-ti/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130326/2dcc1dd4/attachment.pgp>