diff options
author | Dan Willemsen <dwillemsen@nvidia.com> | 2012-02-10 17:37:41 -0800 |
---|---|---|
committer | Simone Willett <swillett@nvidia.com> | 2012-02-18 10:58:30 -0800 |
commit | 09041edc214ed1d0155e292e44bbbb0e6994e797 (patch) | |
tree | 86ccd2b35ca4933b1c86a27d8f3ce5d8ae168b42 | |
parent | a5fcda903c132124873ae0a965c1fd81789aa31a (diff) |
hwmon: adt7461: Remove usage of irq_to_gpio
This API is being removed in v3.2
Change-Id: I3d864dabd2273e737604776aa43c45a64eae90b3
Signed-off-by: Dan Willemsen <dwillemsen@nvidia.com>
Reviewed-on: http://git-master/r/83561
Reviewed-by: Prashant Gaikwad <pgaikwad@nvidia.com>
Reviewed-by: Varun Wadekar <vwadekar@nvidia.com>
-rw-r--r-- | arch/arm/mach-tegra/board-whistler-sensors.c | 3 | ||||
-rw-r--r-- | drivers/hwmon/adt7461.c | 24 | ||||
-rw-r--r-- | include/linux/adt7461.h | 1 |
3 files changed, 21 insertions, 7 deletions
diff --git a/arch/arm/mach-tegra/board-whistler-sensors.c b/arch/arm/mach-tegra/board-whistler-sensors.c index 5177770f4cbe..95bb2f1dd405 100644 --- a/arch/arm/mach-tegra/board-whistler-sensors.c +++ b/arch/arm/mach-tegra/board-whistler-sensors.c @@ -319,8 +319,6 @@ static struct i2c_board_info whistler_i2c1_board_info[] = { static void whistler_adt7461_init(void) { tegra_gpio_enable(ADT7461_IRQ_GPIO); - gpio_request(ADT7461_IRQ_GPIO, "adt7461"); - gpio_direction_input(ADT7461_IRQ_GPIO); } static struct adt7461_platform_data whistler_adt7461_pdata = { @@ -334,6 +332,7 @@ static struct adt7461_platform_data whistler_adt7461_pdata = { .shutdown_local_limit = 120, .throttling_ext_limit = 90, .alarm_fn = tegra_throttling_enable, + .irq_gpio = ADT7461_IRQ_GPIO, }; static struct i2c_board_info whistler_i2c4_board_info[] = { diff --git a/drivers/hwmon/adt7461.c b/drivers/hwmon/adt7461.c index bf71f993cd2c..10ea2eb80668 100644 --- a/drivers/hwmon/adt7461.c +++ b/drivers/hwmon/adt7461.c @@ -120,6 +120,7 @@ struct adt7461_data { u8 temp_hyst; u8 alarms; /* bitvector */ void (*alarm_fn)(bool raised); + int irq_gpio; }; /* @@ -498,11 +499,10 @@ static void adt7461_work_func(struct work_struct *work) { struct adt7461_data *data = container_of(work, struct adt7461_data, work); - int irq = data->client->irq; if (data->alarm_fn) { /* Therm2 line is active low */ - data->alarm_fn(!gpio_get_value(irq_to_gpio(irq))); + data->alarm_fn(!gpio_get_value(data->irq_gpio)); } } @@ -572,9 +572,19 @@ static int adt7461_init_client(struct i2c_client *client) if (!pdata || !pdata->supported_hwrev) return -ENODEV; - if (pdata->therm2) + data->irq_gpio = -1; + + if (pdata->therm2) { data->flags |= ADT7461_FLAG_THERM2; + if (gpio_is_valid(pdata->irq_gpio)) { + if (!IS_ERR(gpio_request(pdata->irq_gpio, "adt7461"))) { + gpio_direction_input(pdata->irq_gpio); + data->irq_gpio = pdata->irq_gpio; + } + } + } + if (pdata->ext_range) data->flags |= ADT7461_FLAG_ADT7461_EXT; @@ -708,8 +718,12 @@ static int adt7461_remove(struct i2c_client *client) { struct adt7461_data *data = i2c_get_clientdata(client); - free_irq(client->irq, data); - cancel_work_sync(&data->work); + if (data->flags & ADT7461_FLAG_THERM2) { + free_irq(client->irq, data); + cancel_work_sync(&data->work); + } + if (gpio_is_valid(data->irq_gpio)) + gpio_free(data->irq_gpio); hwmon_device_unregister(data->hwmon_dev); sysfs_remove_group(&client->dev.kobj, &adt7461_group); device_remove_file(&client->dev, diff --git a/include/linux/adt7461.h b/include/linux/adt7461.h index 7307395ba7c8..36f637ad287e 100644 --- a/include/linux/adt7461.h +++ b/include/linux/adt7461.h @@ -36,6 +36,7 @@ struct adt7461_platform_data { u8 shutdown_local_limit; u8 throttling_ext_limit; void (*alarm_fn)(bool raised); + int irq_gpio; }; #endif /* _LINUX_ADT7461_H */ |