aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharles Keepax <ckeepax@opensource.cirrus.com>2019-06-27 05:24:07 -0400
committerWolfram Sang <wsa@the-dreams.de>2019-06-29 07:17:27 -0400
commitc2223ddcfe64864c9a6541c0ffe22d96255597e0 (patch)
treeae561db584464254634b4559b86e46f939a0a391
parent1d7534b6adcd3e4a9673c4e7fdc5bf4770f5ab81 (diff)
i2c: acpi: Use available IRQ helper functions
Use the available IRQ helper functions, most of the functions have additional helpful side affects like configuring the trigger type of the IRQ. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
-rw-r--r--drivers/i2c/i2c-core-acpi.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
index 964687534754..d3474d1f5e09 100644
--- a/drivers/i2c/i2c-core-acpi.c
+++ b/drivers/i2c/i2c-core-acpi.c
@@ -137,13 +137,23 @@ static int i2c_acpi_do_lookup(struct acpi_device *adev,
137 return 0; 137 return 0;
138} 138}
139 139
140static int i2c_acpi_add_resource(struct acpi_resource *ares, void *data)
141{
142 int *irq = data;
143 struct resource r;
144
145 if (*irq <= 0 && acpi_dev_resource_interrupt(ares, 0, &r))
146 *irq = i2c_dev_irq_from_resources(&r, 1);
147
148 return 1; /* No need to add resource to the list */
149}
150
140static int i2c_acpi_get_info(struct acpi_device *adev, 151static int i2c_acpi_get_info(struct acpi_device *adev,
141 struct i2c_board_info *info, 152 struct i2c_board_info *info,
142 struct i2c_adapter *adapter, 153 struct i2c_adapter *adapter,
143 acpi_handle *adapter_handle) 154 acpi_handle *adapter_handle)
144{ 155{
145 struct list_head resource_list; 156 struct list_head resource_list;
146 struct resource_entry *entry;
147 struct i2c_acpi_lookup lookup; 157 struct i2c_acpi_lookup lookup;
148 int ret; 158 int ret;
149 159
@@ -176,17 +186,11 @@ static int i2c_acpi_get_info(struct acpi_device *adev,
176 186
177 /* Then fill IRQ number if any */ 187 /* Then fill IRQ number if any */
178 INIT_LIST_HEAD(&resource_list); 188 INIT_LIST_HEAD(&resource_list);
179 ret = acpi_dev_get_resources(adev, &resource_list, NULL, NULL); 189 ret = acpi_dev_get_resources(adev, &resource_list,
190 i2c_acpi_add_resource, &info->irq);
180 if (ret < 0) 191 if (ret < 0)
181 return -EINVAL; 192 return -EINVAL;
182 193
183 resource_list_for_each_entry(entry, &resource_list) {
184 if (resource_type(entry->res) == IORESOURCE_IRQ) {
185 info->irq = entry->res->start;
186 break;
187 }
188 }
189
190 acpi_dev_free_resource_list(&resource_list); 194 acpi_dev_free_resource_list(&resource_list);
191 195
192 acpi_set_modalias(adev, dev_name(&adev->dev), info->type, 196 acpi_set_modalias(adev, dev_name(&adev->dev), info->type,