]> xenbits.xensource.com Git - people/royger/freebsd.git/commitdiff
mmc-fdt: fix mmc_fdt_gpio_get_{present,readonly}
authorPriit Trees <trees@neti.ee>
Wed, 31 Mar 2021 20:15:31 +0000 (20:15 +0000)
committerWarner Losh <imp@FreeBSD.org>
Thu, 3 Jun 2021 03:58:30 +0000 (21:58 -0600)
Currently, mmc_fdt_gpio_get_{present,readonly} return all time true.
true   ^ 100b = true
false  ^ 100b = true
since that's done after promotion to integers. Use !! to convert
the bit to a bool before xor.

Reviewed by: imp@ (converted to (bool) to !! for portability)
Pull Request: https://github.com/freebsd/freebsd-src/pull/461

sys/dev/mmc/mmc_fdt_helpers.c

index 4e8a1730d2404ddc81540b95cdafb426cb1aa843..9d120fa01a265b81f9b4424af830841096a80d65 100644 (file)
@@ -407,7 +407,7 @@ mmc_fdt_gpio_get_present(struct mmc_fdt_helper *helper)
 
        gpio_pin_is_active(helper->cd_pin, &pinstate);
 
-       return (pinstate ^ (helper->props & MMC_PROP_CD_INVERTED));
+       return (pinstate ^ !!(helper->props & MMC_PROP_CD_INVERTED));
 }
 
 bool
@@ -423,7 +423,7 @@ mmc_fdt_gpio_get_readonly(struct mmc_fdt_helper *helper)
 
        gpio_pin_is_active(helper->wp_pin, &pinstate);
 
-       return (pinstate ^ (helper->props & MMC_PROP_WP_INVERTED));
+       return (pinstate ^ !!(helper->props & MMC_PROP_WP_INVERTED));
 }
 
 void