From: Tom Rini Date: Thu, 21 Mar 2013 10:22:06 -0400 Subject: [U-Boot] [PATCH 2/2] mmc: omap_hsmmc.c: only register getcd/getwp callbacks if gpio could be used In-Reply-To: <1363874404-7356-2-git-send-email-peter.korsgaard@barco.com> References: <1363874404-7356-1-git-send-email-peter.korsgaard@barco.com> <1363874404-7356-2-git-send-email-peter.korsgaard@barco.com> Message-ID: <20130321142206.GC26945@bill-the-cat> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Thu, Mar 21, 2013 at 03:00:04PM +0100, Peter Korsgaard wrote: > 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 > --- > drivers/mmc/omap_hsmmc.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c > index 67cfcc2..166744c 100644 > --- a/drivers/mmc/omap_hsmmc.c > +++ b/drivers/mmc/omap_hsmmc.c > @@ -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; > + OK, but this should be gpio_is_valid rather than != -1, and then this is probably a better way than my series. -- Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: