aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2005-07-31 15:20:43 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-09-05 12:14:18 -0400
commit9fc6adfa9adf2be84119a3c2592287f33bd1dff2 (patch)
tree6a8e52520c4f99e52de428afc6cd24b844fcb72d
parent5cb802293e87035920d47979107af8cf42a2f62a (diff)
[PATCH] hwmon: hwmon vs i2c, second round (01/11)
Add support for kind-forced addresses to i2c_probe, like i2c_detect has for (essentially) hardware monitoring drivers. Note that this change will slightly increase the size of the drivers using I2C_CLIENT_INSMOD, with no immediate benefit. This is a requirement if we want to merge i2c_probe and i2c_detect though, and seems a reasonable price to pay in comparison with the previous cleanups which saved much more than that (such as the i2c-isa cleanup or the i2c address ranges removal.) Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/i2c/chips/ds1374.c1
-rw-r--r--drivers/i2c/chips/m41t00.c1
-rw-r--r--drivers/i2c/chips/rtc8564.c1
-rw-r--r--drivers/i2c/i2c-core.c38
-rw-r--r--drivers/media/video/adv7170.c1
-rw-r--r--drivers/media/video/adv7175.c1
-rw-r--r--drivers/media/video/bt819.c1
-rw-r--r--drivers/media/video/bt856.c1
-rw-r--r--drivers/media/video/saa7110.c1
-rw-r--r--drivers/media/video/saa7111.c1
-rw-r--r--drivers/media/video/saa7114.c1
-rw-r--r--drivers/media/video/saa7185.c1
-rw-r--r--drivers/media/video/tuner-3036.c1
-rw-r--r--drivers/media/video/vpx3220.c1
-rw-r--r--include/linux/i2c.h9
15 files changed, 34 insertions, 26 deletions
diff --git a/drivers/i2c/chips/ds1374.c b/drivers/i2c/chips/ds1374.c
index a445736d8838..e2d1daf79880 100644
--- a/drivers/i2c/chips/ds1374.c
+++ b/drivers/i2c/chips/ds1374.c
@@ -53,7 +53,6 @@ static struct i2c_client_address_data addr_data = {
53 .normal_i2c = normal_addr, 53 .normal_i2c = normal_addr,
54 .probe = ignore, 54 .probe = ignore,
55 .ignore = ignore, 55 .ignore = ignore,
56 .force = ignore,
57}; 56};
58 57
59static ulong ds1374_read_rtc(void) 58static ulong ds1374_read_rtc(void)
diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c
index 778d7e12859d..e516dadc453f 100644
--- a/drivers/i2c/chips/m41t00.c
+++ b/drivers/i2c/chips/m41t00.c
@@ -42,7 +42,6 @@ static struct i2c_client_address_data addr_data = {
42 .normal_i2c = normal_addr, 42 .normal_i2c = normal_addr,
43 .probe = ignore, 43 .probe = ignore,
44 .ignore = ignore, 44 .ignore = ignore,
45 .force = ignore,
46}; 45};
47 46
48ulong 47ulong
diff --git a/drivers/i2c/chips/rtc8564.c b/drivers/i2c/chips/rtc8564.c
index 588fc2261a91..0b5385c892b1 100644
--- a/drivers/i2c/chips/rtc8564.c
+++ b/drivers/i2c/chips/rtc8564.c
@@ -67,7 +67,6 @@ static struct i2c_client_address_data addr_data = {
67 .normal_i2c = normal_addr, 67 .normal_i2c = normal_addr,
68 .probe = ignore, 68 .probe = ignore,
69 .ignore = ignore, 69 .ignore = ignore,
70 .force = ignore,
71}; 70};
72 71
73static int rtc8564_read_mem(struct i2c_client *client, struct mem *mem); 72static int rtc8564_read_mem(struct i2c_client *client, struct mem *mem);
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 19d8a994b3b7..372b5996d045 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -662,6 +662,28 @@ int i2c_control(struct i2c_client *client,
662 * Will not work for 10-bit addresses! 662 * Will not work for 10-bit addresses!
663 * ---------------------------------------------------- 663 * ----------------------------------------------------
664 */ 664 */
665/* Return: kind (>= 0) if force found, -1 if not found */
666static inline int i2c_probe_forces(struct i2c_adapter *adapter, int addr,
667 unsigned short **forces)
668{
669 unsigned short kind;
670 int j, adap_id = i2c_adapter_id(adapter);
671
672 for (kind = 0; forces[kind]; kind++) {
673 for (j = 0; forces[kind][j] != I2C_CLIENT_END; j += 2) {
674 if ((forces[kind][j] == adap_id ||
675 forces[kind][j] == ANY_I2C_BUS)
676 && forces[kind][j + 1] == addr) {
677 dev_dbg(&adapter->dev, "found force parameter, "
678 "addr 0x%02x, kind %u\n", addr, kind);
679 return kind;
680 }
681 }
682 }
683
684 return -1;
685}
686
665int i2c_probe(struct i2c_adapter *adapter, 687int i2c_probe(struct i2c_adapter *adapter,
666 struct i2c_client_address_data *address_data, 688 struct i2c_client_address_data *address_data,
667 int (*found_proc) (struct i2c_adapter *, int, int)) 689 int (*found_proc) (struct i2c_adapter *, int, int))
@@ -683,19 +705,15 @@ int i2c_probe(struct i2c_adapter *adapter,
683 at all */ 705 at all */
684 found = 0; 706 found = 0;
685 707
686 for (i = 0; !found && (address_data->force[i] != I2C_CLIENT_END); i += 2) { 708 if (address_data->forces) {
687 if (((adap_id == address_data->force[i]) || 709 int kind = i2c_probe_forces(adapter, addr,
688 (address_data->force[i] == ANY_I2C_BUS)) && 710 address_data->forces);
689 (addr == address_data->force[i+1])) { 711 if (kind >= 0) { /* force found */
690 dev_dbg(&adapter->dev, "found force parameter for adapter %d, addr %04x\n", 712 if ((err = found_proc(adapter, addr, kind)))
691 adap_id, addr);
692 if ((err = found_proc(adapter,addr,0)))
693 return err; 713 return err;
694 found = 1; 714 continue;
695 } 715 }
696 } 716 }
697 if (found)
698 continue;
699 717
700 /* If this address is in one of the ignores, we can forget about 718 /* If this address is in one of the ignores, we can forget about
701 it right now */ 719 it right now */
diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c
index 48989eda2400..52e32f05d625 100644
--- a/drivers/media/video/adv7170.c
+++ b/drivers/media/video/adv7170.c
@@ -391,7 +391,6 @@ static struct i2c_client_address_data addr_data = {
391 .normal_i2c = normal_i2c, 391 .normal_i2c = normal_i2c,
392 .probe = &ignore, 392 .probe = &ignore,
393 .ignore = &ignore, 393 .ignore = &ignore,
394 .force = &ignore,
395}; 394};
396 395
397static struct i2c_driver i2c_driver_adv7170; 396static struct i2c_driver i2c_driver_adv7170;
diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c
index f898b6586374..b5ed9544bdea 100644
--- a/drivers/media/video/adv7175.c
+++ b/drivers/media/video/adv7175.c
@@ -441,7 +441,6 @@ static struct i2c_client_address_data addr_data = {
441 .normal_i2c = normal_i2c, 441 .normal_i2c = normal_i2c,
442 .probe = &ignore, 442 .probe = &ignore,
443 .ignore = &ignore, 443 .ignore = &ignore,
444 .force = &ignore,
445}; 444};
446 445
447static struct i2c_driver i2c_driver_adv7175; 446static struct i2c_driver i2c_driver_adv7175;
diff --git a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c
index 8733588f6db3..c6cfa7c48b04 100644
--- a/drivers/media/video/bt819.c
+++ b/drivers/media/video/bt819.c
@@ -507,7 +507,6 @@ static struct i2c_client_address_data addr_data = {
507 .normal_i2c = normal_i2c, 507 .normal_i2c = normal_i2c,
508 .probe = &ignore, 508 .probe = &ignore,
509 .ignore = &ignore, 509 .ignore = &ignore,
510 .force = &ignore,
511}; 510};
512 511
513static struct i2c_driver i2c_driver_bt819; 512static struct i2c_driver i2c_driver_bt819;
diff --git a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c
index a5d529ccf3ad..c13d28658868 100644
--- a/drivers/media/video/bt856.c
+++ b/drivers/media/video/bt856.c
@@ -295,7 +295,6 @@ static struct i2c_client_address_data addr_data = {
295 .normal_i2c = normal_i2c, 295 .normal_i2c = normal_i2c,
296 .probe = &ignore, 296 .probe = &ignore,
297 .ignore = &ignore, 297 .ignore = &ignore,
298 .force = &ignore,
299}; 298};
300 299
301static struct i2c_driver i2c_driver_bt856; 300static struct i2c_driver i2c_driver_bt856;
diff --git a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c
index 22d055d8a695..e116bdbed310 100644
--- a/drivers/media/video/saa7110.c
+++ b/drivers/media/video/saa7110.c
@@ -470,7 +470,6 @@ static struct i2c_client_address_data addr_data = {
470 .normal_i2c = normal_i2c, 470 .normal_i2c = normal_i2c,
471 .probe = &ignore, 471 .probe = &ignore,
472 .ignore = &ignore, 472 .ignore = &ignore,
473 .force = &ignore,
474}; 473};
475 474
476static struct i2c_driver i2c_driver_saa7110; 475static struct i2c_driver i2c_driver_saa7110;
diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c
index fcd897382fcf..f18df53d98ff 100644
--- a/drivers/media/video/saa7111.c
+++ b/drivers/media/video/saa7111.c
@@ -489,7 +489,6 @@ static struct i2c_client_address_data addr_data = {
489 .normal_i2c = normal_i2c, 489 .normal_i2c = normal_i2c,
490 .probe = &ignore, 490 .probe = &ignore,
491 .ignore = &ignore, 491 .ignore = &ignore,
492 .force = &ignore,
493}; 492};
494 493
495static struct i2c_driver i2c_driver_saa7111; 494static struct i2c_driver i2c_driver_saa7111;
diff --git a/drivers/media/video/saa7114.c b/drivers/media/video/saa7114.c
index 2ba997f5ef1d..e0c70f54f073 100644
--- a/drivers/media/video/saa7114.c
+++ b/drivers/media/video/saa7114.c
@@ -827,7 +827,6 @@ static struct i2c_client_address_data addr_data = {
827 .normal_i2c = normal_i2c, 827 .normal_i2c = normal_i2c,
828 .probe = &ignore, 828 .probe = &ignore,
829 .ignore = &ignore, 829 .ignore = &ignore,
830 .force = &ignore,
831}; 830};
832 831
833static struct i2c_driver i2c_driver_saa7114; 832static struct i2c_driver i2c_driver_saa7114;
diff --git a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c
index 108e7a4a0273..e93412f4407c 100644
--- a/drivers/media/video/saa7185.c
+++ b/drivers/media/video/saa7185.c
@@ -387,7 +387,6 @@ static struct i2c_client_address_data addr_data = {
387 .normal_i2c = normal_i2c, 387 .normal_i2c = normal_i2c,
388 .probe = &ignore, 388 .probe = &ignore,
389 .ignore = &ignore, 389 .ignore = &ignore,
390 .force = &ignore,
391}; 390};
392 391
393static struct i2c_driver i2c_driver_saa7185; 392static struct i2c_driver i2c_driver_saa7185;
diff --git a/drivers/media/video/tuner-3036.c b/drivers/media/video/tuner-3036.c
index 7d825e510ffd..103def1abe3c 100644
--- a/drivers/media/video/tuner-3036.c
+++ b/drivers/media/video/tuner-3036.c
@@ -41,7 +41,6 @@ static struct i2c_client_address_data addr_data = {
41 .normal_i2c = normal_i2c, 41 .normal_i2c = normal_i2c,
42 .probe = &ignore, 42 .probe = &ignore,
43 .ignore = &ignore, 43 .ignore = &ignore,
44 .force = &ignore,
45}; 44};
46 45
47/* ---------------------------------------------------------------------- */ 46/* ---------------------------------------------------------------------- */
diff --git a/drivers/media/video/vpx3220.c b/drivers/media/video/vpx3220.c
index 5dbd9f6bf353..4437bdebe24f 100644
--- a/drivers/media/video/vpx3220.c
+++ b/drivers/media/video/vpx3220.c
@@ -576,7 +576,6 @@ static struct i2c_client_address_data addr_data = {
576 .normal_i2c = normal_i2c, 576 .normal_i2c = normal_i2c,
577 .probe = &ignore, 577 .probe = &ignore,
578 .ignore = &ignore, 578 .ignore = &ignore,
579 .force = &ignore,
580}; 579};
581 580
582static struct i2c_driver vpx3220_i2c_driver; 581static struct i2c_driver vpx3220_i2c_driver;
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index ad1c0fb164bc..9419bc5584ad 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -48,7 +48,6 @@ struct i2c_algorithm;
48struct i2c_adapter; 48struct i2c_adapter;
49struct i2c_client; 49struct i2c_client;
50struct i2c_driver; 50struct i2c_driver;
51struct i2c_client_address_data;
52union i2c_smbus_data; 51union i2c_smbus_data;
53 52
54/* 53/*
@@ -301,7 +300,7 @@ struct i2c_client_address_data {
301 unsigned short *normal_i2c; 300 unsigned short *normal_i2c;
302 unsigned short *probe; 301 unsigned short *probe;
303 unsigned short *ignore; 302 unsigned short *ignore;
304 unsigned short *force; 303 unsigned short **forces;
305}; 304};
306 305
307/* Internal numbers to terminate lists */ 306/* Internal numbers to terminate lists */
@@ -575,11 +574,15 @@ union i2c_smbus_data {
575 I2C_CLIENT_MODULE_PARM(force, \ 574 I2C_CLIENT_MODULE_PARM(force, \
576 "List of adapter,address pairs to boldly assume " \ 575 "List of adapter,address pairs to boldly assume " \
577 "to be present"); \ 576 "to be present"); \
577 static unsigned short *addr_forces[] = { \
578 force, \
579 NULL \
580 }; \
578 static struct i2c_client_address_data addr_data = { \ 581 static struct i2c_client_address_data addr_data = { \
579 .normal_i2c = normal_i2c, \ 582 .normal_i2c = normal_i2c, \
580 .probe = probe, \ 583 .probe = probe, \
581 .ignore = ignore, \ 584 .ignore = ignore, \
582 .force = force, \ 585 .forces = addr_forces, \
583 } 586 }
584 587
585#endif /* _LINUX_I2C_H */ 588#endif /* _LINUX_I2C_H */