mmc: mvsdio: fix non-DT probing of GPIOs
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Fri, 22 Mar 2013 13:30:23 +0000 (14:30 +0100)
committerChris Ball <cjb@laptop.org>
Fri, 22 Mar 2013 17:29:46 +0000 (13:29 -0400)
commit5e81441e24336f8fa475ab3eae12c2195e0d9064
tree454c52bfebec4acdd8f35cf556f3cead0162c60d
parentb3b665b0a9d13d731a61aeed92a02c1c9c55cd70
mmc: mvsdio: fix non-DT probing of GPIOs

Ralph Droms <rdroms@gmail.com> reported that 3.9-rc was breaking the
SDIO interface on his Sheevaplug platform, and that the recent changes
to the mvsdio driver are responsible for this breakage. Precisely, the
regression has been introduced by 07728b77c03d (mmc: mvsdio: use
slot-gpio for card detect gpio).

After investigation, is turns out that the Sheevaplug does not have
any "card detect" GPIO, and the Sheevaplug has not been converted to
the Device Tree. Therefore, the Sheevaplug board code does not define
a value for the .gpio_card_detect field of the mvsdio_platform_data
structure, which means that its value is 0. Unfortunately,
gpio_is_valid() considers 0 as a valid GPIO, and therefore calls
mmc_gpio_request_cd(), which fails and makes the entire probing of the
driver fail.

In fact, in the previous mvsdio code, before the Device Tree binding
was introduced, 0 was not considered as a valid GPIO. Therefore, this
fix revert back to this behavior in the non-DT case, by setting the
gpio_card_detect and gpio_write_protect local variables to -EINVAL
when the corresponding fields of the mvsdio_platform_data structure
are set to zero (i.e, left undefined). Of course, it prevents to use
GPIO 0 as a card detect or write protect GPIO, but it was a defiency
of the previous non-DT code, and the fix moving forward is to convert
platforms to the Device Tree.

The problem has been reproduced successfully on the Kirkwood-based
Marvell DB-88F6281-BP Development Board (that doesn't use the Device
Tree) and the fix has proven to work properly, after of course
removing the gpio_card_detect field of the mvsdio_platform_data
instance for this board.

Reported-by: Ralph Droms <rdroms@gmail.com>
Tested-by: Ralph Droms <rdroms@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
drivers/mmc/host/mvsdio.c