Ticket #193: pmu-allow-neg-current.patch

File pmu-allow-neg-current.patch, 1.1 KB (added by alex@…, 12 years ago)

Allow to read negative currents

  • drivers/i2c/chips/pcf50606.c

    old new  
    949949} 
    950950static DEVICE_ATTR(battemp, S_IRUGO | S_IWUSR, show_battemp, NULL); 
    951951 
    952 static inline u_int16_t adc_to_chg_milliamps(struct pcf50606_data *pcf, 
     952static inline int16_t adc_to_chg_milliamps(struct pcf50606_data *pcf, 
    953953                                             u_int16_t adc_adcin1, 
    954954                                             u_int16_t adc_batvolt) 
    955955{ 
    956         u_int32_t res = ((adc_adcin1 - adc_batvolt) * 6000); 
     956        int32_t res = ((adc_adcin1 - adc_batvolt) * 6000); 
    957957        return res / (pcf->pdata->r_sense_milli * 1024 / 1000); 
    958958} 
    959959 
     
    963963        struct i2c_client *client = to_i2c_client(dev); 
    964964        struct pcf50606_data *pcf = i2c_get_clientdata(client); 
    965965        u_int16_t adc_batvolt, adc_adcin1; 
    966         u_int16_t ma; 
     966        int16_t ma; 
    967967 
    968968        adc_batvolt = adc_read(pcf, PCF50606_ADCMUX_BATVOLT_ADCIN1, 
    969969                               &adc_adcin1); 
    970970        ma = adc_to_chg_milliamps(pcf, adc_adcin1, adc_batvolt); 
    971971 
    972         return sprintf(buf, "%u\n", ma); 
     972        return sprintf(buf, "%i\n", ma); 
    973973} 
    974974static DEVICE_ATTR(chgcur, S_IRUGO | S_IWUSR, show_chgcur, NULL); 
    975975