rtl8366_smi: sanitize gpio values to a 0/1 boolean
authorGabor Juhos <juhosg@openwrt.org>
Sat, 30 Jan 2010 15:25:12 +0000 (15:25 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Sat, 30 Jan 2010 15:25:12 +0000 (15:25 +0000)
SVN-Revision: 19402

target/linux/generic-2.6/files/drivers/net/phy/rtl8366_smi.c

index 70218fc6ca86020b11cd971f63fa502767781d4a..7091190b8dd641b89e30995c0b063edca296d51f 100644 (file)
@@ -91,10 +91,7 @@ static void rtl8366_smi_write_bits(struct rtl8366_smi *smi, u32 data, u32 len)
                rtl8366_smi_clk_delay(smi);
 
                /* prepare data */
-               if ( data & ( 1 << (len - 1)) )
-                       gpio_set_value(sda, 1);
-               else
-                       gpio_set_value(sda, 0);
+               gpio_set_value(sda, !!(data & ( 1 << (len - 1))));
                rtl8366_smi_clk_delay(smi);
 
                /* clocking */
@@ -119,7 +116,7 @@ static void rtl8366_smi_read_bits(struct rtl8366_smi *smi, u32 len, u32 *data)
                /* clocking */
                gpio_set_value(sck, 1);
                rtl8366_smi_clk_delay(smi);
-               u = gpio_get_value(sda);
+               u = !!gpio_get_value(sda);
                gpio_set_value(sck, 0);
 
                *data |= (u << (len - 1));