misc: nct1008: remove busy check
Matt Wagner [Sat, 3 Dec 2011 00:41:05 +0000 (16:41 -0800)]
Reverts 664afa7de06d4c1df98f6cec50c2c850cd48fee6.  Busy check was causing reads
of the temperature to block until conversion was completed.
This caused issues with higher level code perf.

Bug 909918

Change-Id: I57dd9d2ac1df8e3272aba03cd7f0c1e55bfd4eb8
Reviewed-on: http://git-master/r/68043
Tested-by: Matt Wagner <mwagner@nvidia.com>
Reviewed-by: Dan Willemsen <dwillemsen@nvidia.com>

drivers/misc/nct1008.c

index 86f4030..9a4015e 100644 (file)
 #define STANDBY_BIT                    BIT(6)
 #define ALERT_BIT                      BIT(7)
 
-/* Status register bits */
-#define STATUS_BUSY                    BIT(7)
-
-/* Worst-case wait when nct1008 is busy */
-#define BUSY_TIMEOUT_MSEC              1000
-
 /* Max Temperature Measurements */
 #define EXTENDED_RANGE_OFFSET          64U
 #define STANDARD_RANGE_MAX             127U
@@ -94,41 +88,6 @@ static inline u8 temperature_to_value(bool extended, s8 temp)
        return extended ? (u8)(temp + EXTENDED_RANGE_OFFSET) : (u8)temp;
 }
 
-/* Wait with timeout if busy */
-static int nct1008_wait_till_busy(struct i2c_client *client)
-{
-       int intr_status;
-       int msec_left = BUSY_TIMEOUT_MSEC;
-       bool is_busy;
-
-       do {
-               intr_status = i2c_smbus_read_byte_data(client, STATUS_RD);
-
-               if (intr_status < 0) {
-                       dev_err(&client->dev, "%s, line=%d, i2c read error=%d\n"
-                               , __func__, __LINE__, intr_status);
-                       return intr_status;
-               }
-
-               /* check for busy bit */
-               is_busy = (intr_status & STATUS_BUSY) ? true : false;
-               if (is_busy) {
-                       /* fastest nct1008 conversion rate ~15msec */
-                       /* using 20msec since msleep below 20 is not
-                        * guaranteed to complete in specified duration */
-                       msleep(MIN_SLEEP_MSEC);
-                       msec_left -= MIN_SLEEP_MSEC;
-               }
-       } while ((is_busy) && (msec_left > 0));
-
-       if (msec_left <= 0) {
-               dev_err(&client->dev, "error: nct1008 busy timed out\n");
-               return -ETIMEDOUT;
-       }
-
-       return 0;
-}
-
 static int nct1008_get_temp(struct device *dev, long *pTemp)
 {
        struct i2c_client *client = to_i2c_client(dev);
@@ -140,10 +99,6 @@ static int nct1008_get_temp(struct device *dev, long *pTemp)
        long temp_local_milli;
        u8 value;
 
-       value = nct1008_wait_till_busy(client);
-       if (value < 0)
-               goto error;
-
        /* Read Local Temp */
        value = i2c_smbus_read_byte_data(client, LOCAL_TEMP_RD);
        if (value < 0)
@@ -189,10 +144,6 @@ static ssize_t nct1008_show_temp(struct device *dev,
        if (!dev || !buf || !attr)
                return -EINVAL;
 
-       value = nct1008_wait_till_busy(client);
-       if (value < 0)
-               goto error;
-
        value = i2c_smbus_read_byte_data(client, LOCAL_TEMP_RD);
        if (value < 0)
                goto error;
@@ -380,10 +331,6 @@ static ssize_t nct1008_show_ext_temp(struct device *dev,
        if (!dev || !buf || !attr)
                return -EINVAL;
 
-       data = nct1008_wait_till_busy(client);
-       if (data < 0)
-               goto error;
-
        /* When reading the full external temperature value, read the
         * LSB first. This causes the MSB to be locked (that is, the
         * ADC does not write to it) until it is read */