~ubuntu-branches/ubuntu/trusty/linux-ti-omap4/trusty

« back to all changes in this revision

Viewing changes to drivers/hwmon/adm1021.c

  • Committer: Package Import Robot
  • Author(s): Paolo Pisati, Paolo Pisati
  • Date: 2013-07-11 18:35:20 UTC
  • Revision ID: package-import@ubuntu.com-20130711183520-htnf1x4y5r11hndr
Tags: 3.5.0-229.42
* Release Tracking Bug
  - LP: #1199276

[ Paolo Pisati ]

* [Config] CONFIG_ATH9K_LEGACY_RATE_CONTROL is not set

Show diffs side-by-side

added added

removed removed

Lines of Context:
332
332
        man_id = i2c_smbus_read_byte_data(client, ADM1021_REG_MAN_ID);
333
333
        dev_id = i2c_smbus_read_byte_data(client, ADM1021_REG_DEV_ID);
334
334
 
 
335
        if (man_id < 0 || dev_id < 0)
 
336
                return -ENODEV;
 
337
 
335
338
        if (man_id == 0x4d && dev_id == 0x01)
336
339
                type_name = "max1617a";
337
340
        else if (man_id == 0x41) {
338
341
                if ((dev_id & 0xF0) == 0x30)
339
342
                        type_name = "adm1023";
 
343
                else if ((dev_id & 0xF0) == 0x00)
 
344
                        type_name = "adm1021";
340
345
                else
341
 
                        type_name = "adm1021";
 
346
                        return -ENODEV;
342
347
        } else if (man_id == 0x49)
343
348
                type_name = "thmc10";
344
349
        else if (man_id == 0x23)
345
350
                type_name = "gl523sm";
346
351
        else if (man_id == 0x54)
347
352
                type_name = "mc1066";
348
 
        /* LM84 Mfr ID in a different place, and it has more unused bits */
349
 
        else if (conv_rate == 0x00
350
 
                 && (config & 0x7F) == 0x00
351
 
                 && (status & 0xAB) == 0x00)
352
 
                type_name = "lm84";
353
 
        else
354
 
                type_name = "max1617";
 
353
        else {
 
354
                int lte, rte, lhi, rhi, llo, rlo;
 
355
 
 
356
                /* extra checks for LM84 and MAX1617 to avoid misdetections */
 
357
 
 
358
                llo = i2c_smbus_read_byte_data(client, ADM1021_REG_THYST_R(0));
 
359
                rlo = i2c_smbus_read_byte_data(client, ADM1021_REG_THYST_R(1));
 
360
 
 
361
                /* fail if any of the additional register reads failed */
 
362
                if (llo < 0 || rlo < 0)
 
363
                        return -ENODEV;
 
364
 
 
365
                lte = i2c_smbus_read_byte_data(client, ADM1021_REG_TEMP(0));
 
366
                rte = i2c_smbus_read_byte_data(client, ADM1021_REG_TEMP(1));
 
367
                lhi = i2c_smbus_read_byte_data(client, ADM1021_REG_TOS_R(0));
 
368
                rhi = i2c_smbus_read_byte_data(client, ADM1021_REG_TOS_R(1));
 
369
 
 
370
                /*
 
371
                 * Fail for negative temperatures and negative high limits.
 
372
                 * This check also catches read errors on the tested registers.
 
373
                 */
 
374
                if ((s8)lte < 0 || (s8)rte < 0 || (s8)lhi < 0 || (s8)rhi < 0)
 
375
                        return -ENODEV;
 
376
 
 
377
                /* fail if all registers hold the same value */
 
378
                if (lte == rte && lte == lhi && lte == rhi && lte == llo
 
379
                    && lte == rlo)
 
380
                        return -ENODEV;
 
381
 
 
382
                /*
 
383
                 * LM84 Mfr ID is in a different place,
 
384
                 * and it has more unused bits.
 
385
                 */
 
386
                if (conv_rate == 0x00
 
387
                    && (config & 0x7F) == 0x00
 
388
                    && (status & 0xAB) == 0x00) {
 
389
                        type_name = "lm84";
 
390
                } else {
 
391
                        /* fail if low limits are larger than high limits */
 
392
                        if ((s8)llo > lhi || (s8)rlo > rhi)
 
393
                                return -ENODEV;
 
394
                        type_name = "max1617";
 
395
                }
 
396
        }
355
397
 
356
398
        pr_debug("adm1021: Detected chip %s at adapter %d, address 0x%02x.\n",
357
399
                 type_name, i2c_adapter_id(adapter), client->addr);