diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-10 11:57:03 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-10 11:57:03 -0500 |
commit | 0bd2cbcdfaff9cb22267d66fc843fa4f73f0c281 (patch) | |
tree | 7d9732bcf5f2f646cb0c2c529c48b454b15d4ae2 /drivers/misc | |
parent | 57cc7215b70856dc6bae8e55b00ecd7b1d7429b1 (diff) | |
parent | a081748735c5feb96b1365e78a5ff0fb6ca7e3a4 (diff) |
Merge branch 'next-devicetree' of git://git.secretlab.ca/git/linux-2.6
* 'next-devicetree' of git://git.secretlab.ca/git/linux-2.6: (29 commits)
of/flattree: forward declare struct device_node in of_fdt.h
ipmi: explicitly include of_address.h and of_irq.h
sparc: explicitly cast negative phandle checks to s32
powerpc/405: Fix missing #{address,size}-cells in i2c node
powerpc/5200: dts: refactor dts files
powerpc/5200: dts: Change combatible strings on localbus
powerpc/5200: dts: remove unused properties
powerpc/5200: dts: rename nodes to prepare for refactoring dts files
of/flattree: Update dtc to current mainline.
of/device: Don't register disabled devices
powerpc/dts: fix syntax bugs in bluestone.dts
of: Fixes for OF probing on little endian systems
of: make drivers depend on CONFIG_OF instead of CONFIG_PPC_OF
of/flattree: Add of_flat_dt_match() helper function
of_serial: explicitly include of_irq.h
of/flattree: Refactor unflatten_device_tree and add fdt_unflatten_tree
of/flattree: Reorder unflatten_dt_node
of/flattree: Refactor unflatten_dt_node
of/flattree: Add non-boottime device tree functions
of/flattree: Add Kconfig for EARLY_FLATTREE
...
Fix up trivial conflict in arch/sparc/prom/tree_32.c as per Grant.
Diffstat (limited to 'drivers/misc')
-rw-r--r-- | drivers/misc/eeprom/at24.c | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index 559b0b3c16c3..ab1ad41786d1 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/log2.h> | 20 | #include <linux/log2.h> |
21 | #include <linux/bitops.h> | 21 | #include <linux/bitops.h> |
22 | #include <linux/jiffies.h> | 22 | #include <linux/jiffies.h> |
23 | #include <linux/of.h> | ||
23 | #include <linux/i2c.h> | 24 | #include <linux/i2c.h> |
24 | #include <linux/i2c/at24.h> | 25 | #include <linux/i2c/at24.h> |
25 | 26 | ||
@@ -457,6 +458,27 @@ static ssize_t at24_macc_write(struct memory_accessor *macc, const char *buf, | |||
457 | 458 | ||
458 | /*-------------------------------------------------------------------------*/ | 459 | /*-------------------------------------------------------------------------*/ |
459 | 460 | ||
461 | #ifdef CONFIG_OF | ||
462 | static void at24_get_ofdata(struct i2c_client *client, | ||
463 | struct at24_platform_data *chip) | ||
464 | { | ||
465 | const __be32 *val; | ||
466 | struct device_node *node = client->dev.of_node; | ||
467 | |||
468 | if (node) { | ||
469 | if (of_get_property(node, "read-only", NULL)) | ||
470 | chip->flags |= AT24_FLAG_READONLY; | ||
471 | val = of_get_property(node, "pagesize", NULL); | ||
472 | if (val) | ||
473 | chip->page_size = be32_to_cpup(val); | ||
474 | } | ||
475 | } | ||
476 | #else | ||
477 | static void at24_get_ofdata(struct i2c_client *client, | ||
478 | struct at24_platform_data *chip) | ||
479 | { } | ||
480 | #endif /* CONFIG_OF */ | ||
481 | |||
460 | static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) | 482 | static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) |
461 | { | 483 | { |
462 | struct at24_platform_data chip; | 484 | struct at24_platform_data chip; |
@@ -485,6 +507,9 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
485 | */ | 507 | */ |
486 | chip.page_size = 1; | 508 | chip.page_size = 1; |
487 | 509 | ||
510 | /* update chipdata if OF is present */ | ||
511 | at24_get_ofdata(client, &chip); | ||
512 | |||
488 | chip.setup = NULL; | 513 | chip.setup = NULL; |
489 | chip.context = NULL; | 514 | chip.context = NULL; |
490 | } | 515 | } |
@@ -492,6 +517,11 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
492 | if (!is_power_of_2(chip.byte_len)) | 517 | if (!is_power_of_2(chip.byte_len)) |
493 | dev_warn(&client->dev, | 518 | dev_warn(&client->dev, |
494 | "byte_len looks suspicious (no power of 2)!\n"); | 519 | "byte_len looks suspicious (no power of 2)!\n"); |
520 | if (!chip.page_size) { | ||
521 | dev_err(&client->dev, "page_size must not be 0!\n"); | ||
522 | err = -EINVAL; | ||
523 | goto err_out; | ||
524 | } | ||
495 | if (!is_power_of_2(chip.page_size)) | 525 | if (!is_power_of_2(chip.page_size)) |
496 | dev_warn(&client->dev, | 526 | dev_warn(&client->dev, |
497 | "page_size looks suspicious (no power of 2)!\n"); | 527 | "page_size looks suspicious (no power of 2)!\n"); |
@@ -597,19 +627,15 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
597 | 627 | ||
598 | i2c_set_clientdata(client, at24); | 628 | i2c_set_clientdata(client, at24); |
599 | 629 | ||
600 | dev_info(&client->dev, "%zu byte %s EEPROM %s\n", | 630 | dev_info(&client->dev, "%zu byte %s EEPROM, %s, %u bytes/write\n", |
601 | at24->bin.size, client->name, | 631 | at24->bin.size, client->name, |
602 | writable ? "(writable)" : "(read-only)"); | 632 | writable ? "writable" : "read-only", at24->write_max); |
603 | if (use_smbus == I2C_SMBUS_WORD_DATA || | 633 | if (use_smbus == I2C_SMBUS_WORD_DATA || |
604 | use_smbus == I2C_SMBUS_BYTE_DATA) { | 634 | use_smbus == I2C_SMBUS_BYTE_DATA) { |
605 | dev_notice(&client->dev, "Falling back to %s reads, " | 635 | dev_notice(&client->dev, "Falling back to %s reads, " |
606 | "performance will suffer\n", use_smbus == | 636 | "performance will suffer\n", use_smbus == |
607 | I2C_SMBUS_WORD_DATA ? "word" : "byte"); | 637 | I2C_SMBUS_WORD_DATA ? "word" : "byte"); |
608 | } | 638 | } |
609 | dev_dbg(&client->dev, | ||
610 | "page_size %d, num_addresses %d, write_max %d, use_smbus %d\n", | ||
611 | chip.page_size, num_addresses, | ||
612 | at24->write_max, use_smbus); | ||
613 | 639 | ||
614 | /* export data to kernel code */ | 640 | /* export data to kernel code */ |
615 | if (chip.setup) | 641 | if (chip.setup) |
@@ -660,6 +686,11 @@ static struct i2c_driver at24_driver = { | |||
660 | 686 | ||
661 | static int __init at24_init(void) | 687 | static int __init at24_init(void) |
662 | { | 688 | { |
689 | if (!io_limit) { | ||
690 | pr_err("at24: io_limit must not be 0!\n"); | ||
691 | return -EINVAL; | ||
692 | } | ||
693 | |||
663 | io_limit = rounddown_pow_of_two(io_limit); | 694 | io_limit = rounddown_pow_of_two(io_limit); |
664 | return i2c_add_driver(&at24_driver); | 695 | return i2c_add_driver(&at24_driver); |
665 | } | 696 | } |