~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to drivers/hwmon/lm75.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno
  • Date: 2011-06-07 12:14:05 UTC
  • mfrom: (43.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20110607121405-i3h1rd7nrnd2b73h
Tags: 2.6.39-2
[ Ben Hutchings ]
* [x86] Enable BACKLIGHT_APPLE, replacing BACKLIGHT_MBP_NVIDIA
  (Closes: #627492)
* cgroups: Disable memory resource controller by default. Allow it
  to be enabled using kernel parameter 'cgroup_enable=memory'.
* rt2800usb: Enable support for more USB devices including
  Linksys WUSB600N (Closes: #596626) (this change was accidentally
  omitted from 2.6.39-1)
* [x86] Remove Celeron from list of processors supporting PAE. Most
  'Celeron M' models do not.
* Update debconf template translations:
  - Swedish (Martin Bagge) (Closes: #628932)
  - French (David Prévot) (Closes: #628191)
* aufs: Update for 2.6.39 (Closes: #627837)
* Add stable 2.6.39.1, including:
  - ext4: dont set PageUptodate in ext4_end_bio()
  - pata_cmd64x: fix boot crash on parisc (Closes: #622997, #622745)
  - ext3: Fix fs corruption when make_indexed_dir() fails
  - netfilter: nf_ct_sip: validate Content-Length in TCP SIP messages
  - sctp: fix race between sctp_bind_addr_free() and
    sctp_bind_addr_conflict()
  - sctp: fix memory leak of the ASCONF queue when free asoc
  - md/bitmap: fix saving of events_cleared and other state
  - cdc_acm: Fix oops when Droids MuIn LCD is connected
  - cx88: Fix conversion from BKL to fine-grained locks (Closes: #619827)
  - keys: Set cred->user_ns in key_replace_session_keyring (CVE-2011-2184)
  - tmpfs: fix race between truncate and writepage
  - nfs41: Correct offset for LAYOUTCOMMIT
  - xen/mmu: fix a race window causing leave_mm BUG()
  - ext4: fix possible use-after-free in ext4_remove_li_request()
  For the complete list of changes, see:
   http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.39.1
* Bump ABI to 2
* netfilter: Enable IP_SET, IP_SET_BITMAP_IP, IP_SET_BITMAP_IPMAC,
  IP_SET_BITMAP_PORT, IP_SET_HASH_IP, IP_SET_HASH_IPPORT,
  IP_SET_HASH_IPPORTIP, IP_SET_HASH_IPPORTNET, IP_SET_HASH_NET,
  IP_SET_HASH_NETPORT, IP_SET_LIST_SET, NETFILTER_XT_SET as modules
  (Closes: #629401)

[ Aurelien Jarno ]
* [mipsel/loongson-2f] Disable_SCSI_LPFC to workaround GCC ICE.

Show diffs side-by-side

added added

removed removed

Lines of Context:
232
232
};
233
233
MODULE_DEVICE_TABLE(i2c, lm75_ids);
234
234
 
 
235
#define LM75A_ID 0xA1
 
236
 
235
237
/* Return 0 if detection is successful, -ENODEV otherwise */
236
238
static int lm75_detect(struct i2c_client *new_client,
237
239
                       struct i2c_board_info *info)
238
240
{
239
241
        struct i2c_adapter *adapter = new_client->adapter;
240
242
        int i;
241
 
        int cur, conf, hyst, os;
 
243
        int conf, hyst, os;
 
244
        bool is_lm75a = 0;
242
245
 
243
246
        if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |
244
247
                                     I2C_FUNC_SMBUS_WORD_DATA))
250
253
           addresses 0x04-0x07 returning the last read value.
251
254
           The cycling+unused addresses combination is not tested,
252
255
           since it would significantly slow the detection down and would
253
 
           hardly add any value. */
254
 
 
255
 
        /* Unused addresses */
256
 
        cur = i2c_smbus_read_word_data(new_client, 0);
 
256
           hardly add any value.
 
257
 
 
258
           The National Semiconductor LM75A is different than earlier
 
259
           LM75s.  It has an ID byte of 0xaX (where X is the chip
 
260
           revision, with 1 being the only revision in existence) in
 
261
           register 7, and unused registers return 0xff rather than the
 
262
           last read value. */
 
263
 
 
264
        /* Unused bits */
257
265
        conf = i2c_smbus_read_byte_data(new_client, 1);
258
 
        hyst = i2c_smbus_read_word_data(new_client, 2);
259
 
        if (i2c_smbus_read_word_data(new_client, 4) != hyst
260
 
         || i2c_smbus_read_word_data(new_client, 5) != hyst
261
 
         || i2c_smbus_read_word_data(new_client, 6) != hyst
262
 
         || i2c_smbus_read_word_data(new_client, 7) != hyst)
263
 
                return -ENODEV;
264
 
        os = i2c_smbus_read_word_data(new_client, 3);
265
 
        if (i2c_smbus_read_word_data(new_client, 4) != os
266
 
         || i2c_smbus_read_word_data(new_client, 5) != os
267
 
         || i2c_smbus_read_word_data(new_client, 6) != os
268
 
         || i2c_smbus_read_word_data(new_client, 7) != os)
269
 
                return -ENODEV;
270
 
 
271
 
        /* Unused bits */
272
266
        if (conf & 0xe0)
273
267
                return -ENODEV;
274
268
 
 
269
        /* First check for LM75A */
 
270
        if (i2c_smbus_read_byte_data(new_client, 7) == LM75A_ID) {
 
271
                /* LM75A returns 0xff on unused registers so
 
272
                   just to be sure we check for that too. */
 
273
                if (i2c_smbus_read_byte_data(new_client, 4) != 0xff
 
274
                 || i2c_smbus_read_byte_data(new_client, 5) != 0xff
 
275
                 || i2c_smbus_read_byte_data(new_client, 6) != 0xff)
 
276
                        return -ENODEV;
 
277
                is_lm75a = 1;
 
278
                hyst = i2c_smbus_read_byte_data(new_client, 2);
 
279
                os = i2c_smbus_read_byte_data(new_client, 3);
 
280
        } else { /* Traditional style LM75 detection */
 
281
                /* Unused addresses */
 
282
                hyst = i2c_smbus_read_byte_data(new_client, 2);
 
283
                if (i2c_smbus_read_byte_data(new_client, 4) != hyst
 
284
                 || i2c_smbus_read_byte_data(new_client, 5) != hyst
 
285
                 || i2c_smbus_read_byte_data(new_client, 6) != hyst
 
286
                 || i2c_smbus_read_byte_data(new_client, 7) != hyst)
 
287
                        return -ENODEV;
 
288
                os = i2c_smbus_read_byte_data(new_client, 3);
 
289
                if (i2c_smbus_read_byte_data(new_client, 4) != os
 
290
                 || i2c_smbus_read_byte_data(new_client, 5) != os
 
291
                 || i2c_smbus_read_byte_data(new_client, 6) != os
 
292
                 || i2c_smbus_read_byte_data(new_client, 7) != os)
 
293
                        return -ENODEV;
 
294
        }
 
295
 
275
296
        /* Addresses cycling */
276
 
        for (i = 8; i < 0xff; i += 8) {
 
297
        for (i = 8; i <= 248; i += 40) {
277
298
                if (i2c_smbus_read_byte_data(new_client, i + 1) != conf
278
 
                 || i2c_smbus_read_word_data(new_client, i + 2) != hyst
279
 
                 || i2c_smbus_read_word_data(new_client, i + 3) != os)
 
299
                 || i2c_smbus_read_byte_data(new_client, i + 2) != hyst
 
300
                 || i2c_smbus_read_byte_data(new_client, i + 3) != os)
 
301
                        return -ENODEV;
 
302
                if (is_lm75a && i2c_smbus_read_byte_data(new_client, i + 7)
 
303
                                != LM75A_ID)
280
304
                        return -ENODEV;
281
305
        }
282
306
 
283
 
        strlcpy(info->type, "lm75", I2C_NAME_SIZE);
 
307
        strlcpy(info->type, is_lm75a ? "lm75a" : "lm75", I2C_NAME_SIZE);
284
308
 
285
309
        return 0;
286
310
}