Re: [PATCH 4/4] MXS-MMC: Add wp-inverted property
Copy Chris and linux-mmc, as I assume that the patch should go via mmc tree after the merge window. On Mon, May 21, 2012 at 03:02:20AM +0200, Marek Vasut wrote: The write-protect GPIO is inverted on some boards. Handle such case. Signed-off-by: Marek Vasut ma...@denx.de Cc: Shawn Guo shawn@linaro.org Cc: Fabio Estevam fabio.este...@freescale.com Acked-by: Shawn Guo shawn@linaro.org A coupe of nits though: The subject prefix can better be mmc: mxs-mmc: . --- Documentation/devicetree/bindings/mmc/mxs-mmc.txt |1 + drivers/mmc/host/mxs-mmc.c| 11 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/mmc/mxs-mmc.txt b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt index 14d870a..0a7d2cd 100644 --- a/Documentation/devicetree/bindings/mmc/mxs-mmc.txt +++ b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt @@ -13,6 +13,7 @@ Required properties: Optional properties: - wp-gpios: Specify GPIOs for write protection +- wp-inverted: Set if the write protection GPIO is inverted Examples: diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c index 277161d..119beb9 100644 --- a/drivers/mmc/host/mxs-mmc.c +++ b/drivers/mmc/host/mxs-mmc.c @@ -164,16 +164,23 @@ struct mxs_mmc_host { spinlock_t lock; int sdio_irq_en; int wp_gpio; + int wp_inverted:1; }; static int mxs_mmc_get_ro(struct mmc_host *mmc) { struct mxs_mmc_host *host = mmc_priv(mmc); + int ret; if (!gpio_is_valid(host-wp_gpio)) return -EINVAL; - return gpio_get_value(host-wp_gpio); + ret = gpio_get_value(host-wp_gpio); + + if (host-wp_inverted) + ret = !ret; + + return ret; The above lines can just be the one below? return (host-wp_inverted) ? !ret : ret; } -- Regards, Shawn -- To unsubscribe from this list: send the line unsubscribe linux-mmc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 4/4] MXS-MMC: Add wp-inverted property
Dear Shawn Guo, Copy Chris and linux-mmc, as I assume that the patch should go via mmc tree after the merge window. On Mon, May 21, 2012 at 03:02:20AM +0200, Marek Vasut wrote: The write-protect GPIO is inverted on some boards. Handle such case. Signed-off-by: Marek Vasut ma...@denx.de Cc: Shawn Guo shawn@linaro.org Cc: Fabio Estevam fabio.este...@freescale.com Acked-by: Shawn Guo shawn@linaro.org A coupe of nits though: The subject prefix can better be mmc: mxs-mmc: . Want me to resend it ? --- Documentation/devicetree/bindings/mmc/mxs-mmc.txt |1 + drivers/mmc/host/mxs-mmc.c| 11 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/mmc/mxs-mmc.txt b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt index 14d870a..0a7d2cd 100644 --- a/Documentation/devicetree/bindings/mmc/mxs-mmc.txt +++ b/Documentation/devicetree/bindings/mmc/mxs-mmc.txt @@ -13,6 +13,7 @@ Required properties: Optional properties: - wp-gpios: Specify GPIOs for write protection +- wp-inverted: Set if the write protection GPIO is inverted Examples: diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c index 277161d..119beb9 100644 --- a/drivers/mmc/host/mxs-mmc.c +++ b/drivers/mmc/host/mxs-mmc.c @@ -164,16 +164,23 @@ struct mxs_mmc_host { spinlock_t lock; int sdio_irq_en; int wp_gpio; + int wp_inverted:1; }; static int mxs_mmc_get_ro(struct mmc_host *mmc) { struct mxs_mmc_host *host = mmc_priv(mmc); + int ret; if (!gpio_is_valid(host-wp_gpio)) return -EINVAL; - return gpio_get_value(host-wp_gpio); + ret = gpio_get_value(host-wp_gpio); + + if (host-wp_inverted) + ret = !ret; + + return ret; The above lines can just be the one below? return (host-wp_inverted) ? !ret : ret; I'd prefer to avoid the ternary operator, it's more readable as it is. } Best regards, Marek Vasut -- To unsubscribe from this list: send the line unsubscribe linux-mmc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 4/4] MXS-MMC: Add wp-inverted property
On 21 May 2012 10:38, Marek Vasut ma...@denx.de wrote: The subject prefix can better be mmc: mxs-mmc: . Want me to resend it ? It's Chris' call. Regards, Shawn -- To unsubscribe from this list: send the line unsubscribe linux-mmc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 4/4] MXS-MMC: Add wp-inverted property
Hi, On Sun, May 20 2012, Shawn Guo wrote: On 21 May 2012 10:38, Marek Vasut ma...@denx.de wrote: The subject prefix can better be mmc: mxs-mmc: . Want me to resend it ? It's Chris' call. Yes, please -- actually not just because of the subject prefix, which I wouldn't mind fixing myself, but because I like having patches posted to linux-mmc@ before they're applied. Thanks! - Chris. -- Chris Ball c...@laptop.org http://printf.net/ One Laptop Per Child -- To unsubscribe from this list: send the line unsubscribe linux-mmc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 4/4] MXS-MMC: Add wp-inverted property
Dear Chris Ball, Hi, On Sun, May 20 2012, Shawn Guo wrote: On 21 May 2012 10:38, Marek Vasut ma...@denx.de wrote: The subject prefix can better be mmc: mxs-mmc: . Want me to resend it ? It's Chris' call. Yes, please -- actually not just because of the subject prefix, which I wouldn't mind fixing myself, but because I like having patches posted to linux-mmc@ before they're applied. Fixed now Thanks! You're welcome :) - Chris. Best regards, Marek Vasut -- To unsubscribe from this list: send the line unsubscribe linux-mmc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html