aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@stericsson.com>2009-08-13 05:49:23 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2009-09-17 03:47:15 -0400
commit956f25a6778a2510d52973ab8a3ac2e03e2c3704 (patch)
tree71a9627cd02f02091982459dd03af9f36a20c0c7 /drivers/mfd
parent35c86bf66d9d0ebc3f32f8c56251197b3921394e (diff)
mfd: AB3100 accessor function cleanups
This adds the _interruptible suffix to the AB3100 accessor functions on par with mutex_lock_interruptible() that's used for blocking simultaneous calls to the AB3100 acessor functions. Since these accesses are slow on a 100kHz I2C bus and may line up waiting for the mutex, we need to handle interruption by system shutdown or kill signals and may just as well denote that in the function names. Signed-off-by: Linus Walleij <linus.walleij@stericsson.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd')
-rw-r--r--drivers/mfd/ab3100-core.c43
1 files changed, 24 insertions, 19 deletions
diff --git a/drivers/mfd/ab3100-core.c b/drivers/mfd/ab3100-core.c
index 8ff10cb77cac..ffe4b6415465 100644
--- a/drivers/mfd/ab3100-core.c
+++ b/drivers/mfd/ab3100-core.c
@@ -77,7 +77,7 @@ u8 ab3100_get_chip_type(struct ab3100 *ab3100)
77} 77}
78EXPORT_SYMBOL(ab3100_get_chip_type); 78EXPORT_SYMBOL(ab3100_get_chip_type);
79 79
80int ab3100_set_register(struct ab3100 *ab3100, u8 reg, u8 regval) 80int ab3100_set_register_interruptible(struct ab3100 *ab3100, u8 reg, u8 regval)
81{ 81{
82 u8 regandval[2] = {reg, regval}; 82 u8 regandval[2] = {reg, regval};
83 int err; 83 int err;
@@ -109,7 +109,8 @@ int ab3100_set_register(struct ab3100 *ab3100, u8 reg, u8 regval)
109 mutex_unlock(&ab3100->access_mutex); 109 mutex_unlock(&ab3100->access_mutex);
110 return 0; 110 return 0;
111} 111}
112EXPORT_SYMBOL(ab3100_set_register); 112EXPORT_SYMBOL(ab3100_set_register_interruptible);
113
113 114
114/* 115/*
115 * The test registers exist at an I2C bus address up one 116 * The test registers exist at an I2C bus address up one
@@ -118,7 +119,7 @@ EXPORT_SYMBOL(ab3100_set_register);
118 * anyway. It's currently only used from this file so declare 119 * anyway. It's currently only used from this file so declare
119 * it static and do not export. 120 * it static and do not export.
120 */ 121 */
121static int ab3100_set_test_register(struct ab3100 *ab3100, 122static int ab3100_set_test_register_interruptible(struct ab3100 *ab3100,
122 u8 reg, u8 regval) 123 u8 reg, u8 regval)
123{ 124{
124 u8 regandval[2] = {reg, regval}; 125 u8 regandval[2] = {reg, regval};
@@ -148,7 +149,8 @@ static int ab3100_set_test_register(struct ab3100 *ab3100,
148 return err; 149 return err;
149} 150}
150 151
151int ab3100_get_register(struct ab3100 *ab3100, u8 reg, u8 *regval) 152
153int ab3100_get_register_interruptible(struct ab3100 *ab3100, u8 reg, u8 *regval)
152{ 154{
153 int err; 155 int err;
154 156
@@ -202,9 +204,10 @@ int ab3100_get_register(struct ab3100 *ab3100, u8 reg, u8 *regval)
202 mutex_unlock(&ab3100->access_mutex); 204 mutex_unlock(&ab3100->access_mutex);
203 return err; 205 return err;
204} 206}
205EXPORT_SYMBOL(ab3100_get_register); 207EXPORT_SYMBOL(ab3100_get_register_interruptible);
208
206 209
207int ab3100_get_register_page(struct ab3100 *ab3100, 210int ab3100_get_register_page_interruptible(struct ab3100 *ab3100,
208 u8 first_reg, u8 *regvals, u8 numregs) 211 u8 first_reg, u8 *regvals, u8 numregs)
209{ 212{
210 int err; 213 int err;
@@ -258,9 +261,10 @@ int ab3100_get_register_page(struct ab3100 *ab3100,
258 mutex_unlock(&ab3100->access_mutex); 261 mutex_unlock(&ab3100->access_mutex);
259 return err; 262 return err;
260} 263}
261EXPORT_SYMBOL(ab3100_get_register_page); 264EXPORT_SYMBOL(ab3100_get_register_page_interruptible);
262 265
263int ab3100_mask_and_set_register(struct ab3100 *ab3100, 266
267int ab3100_mask_and_set_register_interruptible(struct ab3100 *ab3100,
264 u8 reg, u8 andmask, u8 ormask) 268 u8 reg, u8 andmask, u8 ormask)
265{ 269{
266 u8 regandval[2] = {reg, 0}; 270 u8 regandval[2] = {reg, 0};
@@ -328,7 +332,8 @@ int ab3100_mask_and_set_register(struct ab3100 *ab3100,
328 mutex_unlock(&ab3100->access_mutex); 332 mutex_unlock(&ab3100->access_mutex);
329 return err; 333 return err;
330} 334}
331EXPORT_SYMBOL(ab3100_mask_and_set_register); 335EXPORT_SYMBOL(ab3100_mask_and_set_register_interruptible);
336
332 337
333/* 338/*
334 * Register a simple callback for handling any AB3100 events. 339 * Register a simple callback for handling any AB3100 events.
@@ -371,7 +376,7 @@ static void ab3100_work(struct work_struct *work)
371 u32 fatevent; 376 u32 fatevent;
372 int err; 377 int err;
373 378
374 err = ab3100_get_register_page(ab3100, AB3100_EVENTA1, 379 err = ab3100_get_register_page_interruptible(ab3100, AB3100_EVENTA1,
375 event_regs, 3); 380 event_regs, 3);
376 if (err) 381 if (err)
377 goto err_event_wq; 382 goto err_event_wq;
@@ -435,7 +440,7 @@ static int ab3100_registers_print(struct seq_file *s, void *p)
435 seq_printf(s, "AB3100 registers:\n"); 440 seq_printf(s, "AB3100 registers:\n");
436 441
437 for (reg = 0; reg < 0xff; reg++) { 442 for (reg = 0; reg < 0xff; reg++) {
438 ab3100_get_register(ab3100, reg, &value); 443 ab3100_get_register_interruptible(ab3100, reg, &value);
439 seq_printf(s, "[0x%x]: 0x%x\n", reg, value); 444 seq_printf(s, "[0x%x]: 0x%x\n", reg, value);
440 } 445 }
441 return 0; 446 return 0;
@@ -515,7 +520,7 @@ static ssize_t ab3100_get_set_reg(struct file *file,
515 u8 reg = (u8) user_reg; 520 u8 reg = (u8) user_reg;
516 u8 regvalue; 521 u8 regvalue;
517 522
518 ab3100_get_register(ab3100, reg, &regvalue); 523 ab3100_get_register_interruptible(ab3100, reg, &regvalue);
519 524
520 dev_info(ab3100->dev, 525 dev_info(ab3100->dev,
521 "debug read AB3100 reg[0x%02x]: 0x%02x\n", 526 "debug read AB3100 reg[0x%02x]: 0x%02x\n",
@@ -547,8 +552,8 @@ static ssize_t ab3100_get_set_reg(struct file *file,
547 return -EINVAL; 552 return -EINVAL;
548 553
549 value = (u8) user_value; 554 value = (u8) user_value;
550 ab3100_set_register(ab3100, reg, value); 555 ab3100_set_register_interruptible(ab3100, reg, value);
551 ab3100_get_register(ab3100, reg, &regvalue); 556 ab3100_get_register_interruptible(ab3100, reg, &regvalue);
552 557
553 dev_info(ab3100->dev, 558 dev_info(ab3100->dev,
554 "debug write reg[0x%02x] with 0x%02x, " 559 "debug write reg[0x%02x] with 0x%02x, "
@@ -696,7 +701,7 @@ static int __init ab3100_setup(struct ab3100 *ab3100)
696 int i; 701 int i;
697 702
698 for (i = 0; i < ARRAY_SIZE(ab3100_init_settings); i++) { 703 for (i = 0; i < ARRAY_SIZE(ab3100_init_settings); i++) {
699 err = ab3100_set_register(ab3100, 704 err = ab3100_set_register_interruptible(ab3100,
700 ab3100_init_settings[i].abreg, 705 ab3100_init_settings[i].abreg,
701 ab3100_init_settings[i].setting); 706 ab3100_init_settings[i].setting);
702 if (err) 707 if (err)
@@ -705,14 +710,14 @@ static int __init ab3100_setup(struct ab3100 *ab3100)
705 710
706 /* 711 /*
707 * Special trick to make the AB3100 use the 32kHz clock (RTC) 712 * Special trick to make the AB3100 use the 32kHz clock (RTC)
708 * bit 3 in test registe 0x02 is a special, undocumented test 713 * bit 3 in test register 0x02 is a special, undocumented test
709 * register bit that only exist in AB3100 P1E 714 * register bit that only exist in AB3100 P1E
710 */ 715 */
711 if (ab3100->chip_id == 0xc4) { 716 if (ab3100->chip_id == 0xc4) {
712 dev_warn(ab3100->dev, 717 dev_warn(ab3100->dev,
713 "AB3100 P1E variant detected, " 718 "AB3100 P1E variant detected, "
714 "forcing chip to 32KHz\n"); 719 "forcing chip to 32KHz\n");
715 err = ab3100_set_test_register(ab3100, 0x02, 0x08); 720 err = ab3100_set_test_register_interruptible(ab3100, 0x02, 0x08);
716 } 721 }
717 722
718 exit_no_setup: 723 exit_no_setup:
@@ -852,8 +857,8 @@ static int __init ab3100_probe(struct i2c_client *client,
852 i2c_set_clientdata(client, ab3100); 857 i2c_set_clientdata(client, ab3100);
853 858
854 /* Read chip ID register */ 859 /* Read chip ID register */
855 err = ab3100_get_register(ab3100, AB3100_CID, 860 err = ab3100_get_register_interruptible(ab3100, AB3100_CID,
856 &ab3100->chip_id); 861 &ab3100->chip_id);
857 if (err) { 862 if (err) {
858 dev_err(&client->dev, 863 dev_err(&client->dev,
859 "could not communicate with the AB3100 analog " 864 "could not communicate with the AB3100 analog "