aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm78.c
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
committerAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
commitada47b5fe13d89735805b566185f4885f5a3f750 (patch)
tree644b88f8a71896307d71438e9b3af49126ffb22b /drivers/hwmon/lm78.c
parent43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff)
parent3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff)
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/hwmon/lm78.c')
-rw-r--r--drivers/hwmon/lm78.c90
1 files changed, 35 insertions, 55 deletions
diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c
index f7e70163e016..72ff2c4e757d 100644
--- a/drivers/hwmon/lm78.c
+++ b/drivers/hwmon/lm78.c
@@ -41,8 +41,7 @@ static const unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d,
41 0x2e, 0x2f, I2C_CLIENT_END }; 41 0x2e, 0x2f, I2C_CLIENT_END };
42static unsigned short isa_address = 0x290; 42static unsigned short isa_address = 0x290;
43 43
44/* Insmod parameters */ 44enum chips { lm78, lm79 };
45I2C_CLIENT_INSMOD_2(lm78, lm79);
46 45
47/* Many LM78 constants specified below */ 46/* Many LM78 constants specified below */
48 47
@@ -142,7 +141,7 @@ struct lm78_data {
142}; 141};
143 142
144 143
145static int lm78_i2c_detect(struct i2c_client *client, int kind, 144static int lm78_i2c_detect(struct i2c_client *client,
146 struct i2c_board_info *info); 145 struct i2c_board_info *info);
147static int lm78_i2c_probe(struct i2c_client *client, 146static int lm78_i2c_probe(struct i2c_client *client,
148 const struct i2c_device_id *id); 147 const struct i2c_device_id *id);
@@ -173,7 +172,7 @@ static struct i2c_driver lm78_driver = {
173 .remove = lm78_i2c_remove, 172 .remove = lm78_i2c_remove,
174 .id_table = lm78_i2c_id, 173 .id_table = lm78_i2c_id,
175 .detect = lm78_i2c_detect, 174 .detect = lm78_i2c_detect,
176 .address_data = &addr_data, 175 .address_list = normal_i2c,
177}; 176};
178 177
179static struct platform_driver lm78_isa_driver = { 178static struct platform_driver lm78_isa_driver = {
@@ -558,7 +557,7 @@ static int lm78_alias_detect(struct i2c_client *client, u8 chipid)
558 return 1; 557 return 1;
559} 558}
560 559
561static int lm78_i2c_detect(struct i2c_client *client, int kind, 560static int lm78_i2c_detect(struct i2c_client *client,
562 struct i2c_board_info *info) 561 struct i2c_board_info *info)
563{ 562{
564 int i; 563 int i;
@@ -576,52 +575,34 @@ static int lm78_i2c_detect(struct i2c_client *client, int kind,
576 if (isa) 575 if (isa)
577 mutex_lock(&isa->update_lock); 576 mutex_lock(&isa->update_lock);
578 577
579 if (kind < 0) { 578 if ((i2c_smbus_read_byte_data(client, LM78_REG_CONFIG) & 0x80)
580 if ((i2c_smbus_read_byte_data(client, LM78_REG_CONFIG) & 0x80) 579 || i2c_smbus_read_byte_data(client, LM78_REG_I2C_ADDR) != address)
581 || i2c_smbus_read_byte_data(client, LM78_REG_I2C_ADDR) 580 goto err_nodev;
582 != address)
583 goto err_nodev;
584 581
585 /* Explicitly prevent the misdetection of Winbond chips */ 582 /* Explicitly prevent the misdetection of Winbond chips */
586 i = i2c_smbus_read_byte_data(client, 0x4f); 583 i = i2c_smbus_read_byte_data(client, 0x4f);
587 if (i == 0xa3 || i == 0x5c) 584 if (i == 0xa3 || i == 0x5c)
588 goto err_nodev; 585 goto err_nodev;
589 }
590 586
591 /* Determine the chip type. */ 587 /* Determine the chip type. */
592 if (kind <= 0) { 588 i = i2c_smbus_read_byte_data(client, LM78_REG_CHIPID);
593 i = i2c_smbus_read_byte_data(client, LM78_REG_CHIPID); 589 if (i == 0x00 || i == 0x20 /* LM78 */
594 if (i == 0x00 || i == 0x20 /* LM78 */ 590 || i == 0x40) /* LM78-J */
595 || i == 0x40) /* LM78-J */ 591 client_name = "lm78";
596 kind = lm78; 592 else if ((i & 0xfe) == 0xc0)
597 else if ((i & 0xfe) == 0xc0) 593 client_name = "lm79";
598 kind = lm79; 594 else
599 else { 595 goto err_nodev;
600 if (kind == 0)
601 dev_warn(&adapter->dev, "Ignoring 'force' "
602 "parameter for unknown chip at "
603 "adapter %d, address 0x%02x\n",
604 i2c_adapter_id(adapter), address);
605 goto err_nodev;
606 }
607 596
608 if (lm78_alias_detect(client, i)) { 597 if (lm78_alias_detect(client, i)) {
609 dev_dbg(&adapter->dev, "Device at 0x%02x appears to " 598 dev_dbg(&adapter->dev, "Device at 0x%02x appears to "
610 "be the same as ISA device\n", address); 599 "be the same as ISA device\n", address);
611 goto err_nodev; 600 goto err_nodev;
612 }
613 } 601 }
614 602
615 if (isa) 603 if (isa)
616 mutex_unlock(&isa->update_lock); 604 mutex_unlock(&isa->update_lock);
617 605
618 switch (kind) {
619 case lm79:
620 client_name = "lm79";
621 break;
622 default:
623 client_name = "lm78";
624 }
625 strlcpy(info->type, client_name, I2C_NAME_SIZE); 606 strlcpy(info->type, client_name, I2C_NAME_SIZE);
626 607
627 return 0; 608 return 0;
@@ -870,17 +851,16 @@ static struct lm78_data *lm78_update_device(struct device *dev)
870static int __init lm78_isa_found(unsigned short address) 851static int __init lm78_isa_found(unsigned short address)
871{ 852{
872 int val, save, found = 0; 853 int val, save, found = 0;
873 854 int port;
874 /* We have to request the region in two parts because some 855
875 boards declare base+4 to base+7 as a PNP device */ 856 /* Some boards declare base+0 to base+7 as a PNP device, some base+4
876 if (!request_region(address, 4, "lm78")) { 857 * to base+7 and some base+5 to base+6. So we better request each port
877 pr_debug("lm78: Failed to request low part of region\n"); 858 * individually for the probing phase. */
878 return 0; 859 for (port = address; port < address + LM78_EXTENT; port++) {
879 } 860 if (!request_region(port, 1, "lm78")) {
880 if (!request_region(address + 4, 4, "lm78")) { 861 pr_debug("lm78: Failed to request port 0x%x\n", port);
881 pr_debug("lm78: Failed to request high part of region\n"); 862 goto release;
882 release_region(address, 4); 863 }
883 return 0;
884 } 864 }
885 865
886#define REALLY_SLOW_IO 866#define REALLY_SLOW_IO
@@ -944,8 +924,8 @@ static int __init lm78_isa_found(unsigned short address)
944 val & 0x80 ? "LM79" : "LM78", (int)address); 924 val & 0x80 ? "LM79" : "LM78", (int)address);
945 925
946 release: 926 release:
947 release_region(address + 4, 4); 927 for (port--; port >= address; port--)
948 release_region(address, 4); 928 release_region(port, 1);
949 return found; 929 return found;
950} 930}
951 931