diff options
author | Grygorii Strashko <grygorii.strashko@ti.com> | 2016-03-04 10:25:35 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2016-03-09 06:07:14 -0500 |
commit | 7b1e5dc86c0030314f8f6e828177a6c5bb7b9006 (patch) | |
tree | 433c5b6c5caa1a53cce1b45dc90343102ce0c31e | |
parent | 0bae2f17323a4630c487a9b77c37bebf407424af (diff) |
gpio: omap: drop dev field from gpio_bank structure
GPIO chip structure already has "parent" field which is used for the
same purpose as "dev" field in gpio_bank structure - store pointer on
GPIO device.
Hence, drop duplicated "dev" field from gpio_bank structure.
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Acked-by: Santosh Shilimkar <ssantosh@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | drivers/gpio/gpio-omap.c | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index 189f672bebc1..551dfa9d97ab 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c | |||
@@ -66,7 +66,6 @@ struct gpio_bank { | |||
66 | u32 irq_usage; | 66 | u32 irq_usage; |
67 | u32 dbck_enable_mask; | 67 | u32 dbck_enable_mask; |
68 | bool dbck_enabled; | 68 | bool dbck_enabled; |
69 | struct device *dev; | ||
70 | bool is_mpuio; | 69 | bool is_mpuio; |
71 | bool dbck_flag; | 70 | bool dbck_flag; |
72 | bool loses_context; | 71 | bool loses_context; |
@@ -627,7 +626,7 @@ static int omap_set_gpio_wakeup(struct gpio_bank *bank, unsigned offset, | |||
627 | unsigned long flags; | 626 | unsigned long flags; |
628 | 627 | ||
629 | if (bank->non_wakeup_gpios & gpio_bit) { | 628 | if (bank->non_wakeup_gpios & gpio_bit) { |
630 | dev_err(bank->dev, | 629 | dev_err(bank->chip.parent, |
631 | "Unable to modify wakeup on non-wakeup GPIO%d\n", | 630 | "Unable to modify wakeup on non-wakeup GPIO%d\n", |
632 | offset); | 631 | offset); |
633 | return -EINVAL; | 632 | return -EINVAL; |
@@ -669,7 +668,7 @@ static int omap_gpio_request(struct gpio_chip *chip, unsigned offset) | |||
669 | * enable the bank module. | 668 | * enable the bank module. |
670 | */ | 669 | */ |
671 | if (!BANK_USED(bank)) | 670 | if (!BANK_USED(bank)) |
672 | pm_runtime_get_sync(bank->dev); | 671 | pm_runtime_get_sync(chip->parent); |
673 | 672 | ||
674 | raw_spin_lock_irqsave(&bank->lock, flags); | 673 | raw_spin_lock_irqsave(&bank->lock, flags); |
675 | omap_enable_gpio_module(bank, offset); | 674 | omap_enable_gpio_module(bank, offset); |
@@ -698,7 +697,7 @@ static void omap_gpio_free(struct gpio_chip *chip, unsigned offset) | |||
698 | * disable the bank module. | 697 | * disable the bank module. |
699 | */ | 698 | */ |
700 | if (!BANK_USED(bank)) | 699 | if (!BANK_USED(bank)) |
701 | pm_runtime_put(bank->dev); | 700 | pm_runtime_put(chip->parent); |
702 | } | 701 | } |
703 | 702 | ||
704 | /* | 703 | /* |
@@ -723,7 +722,7 @@ static irqreturn_t omap_gpio_irq_handler(int irq, void *gpiobank) | |||
723 | if (WARN_ON(!isr_reg)) | 722 | if (WARN_ON(!isr_reg)) |
724 | goto exit; | 723 | goto exit; |
725 | 724 | ||
726 | pm_runtime_get_sync(bank->dev); | 725 | pm_runtime_get_sync(bank->chip.parent); |
727 | 726 | ||
728 | while (1) { | 727 | while (1) { |
729 | u32 isr_saved, level_mask = 0; | 728 | u32 isr_saved, level_mask = 0; |
@@ -776,7 +775,7 @@ static irqreturn_t omap_gpio_irq_handler(int irq, void *gpiobank) | |||
776 | } | 775 | } |
777 | } | 776 | } |
778 | exit: | 777 | exit: |
779 | pm_runtime_put(bank->dev); | 778 | pm_runtime_put(bank->chip.parent); |
780 | return IRQ_HANDLED; | 779 | return IRQ_HANDLED; |
781 | } | 780 | } |
782 | 781 | ||
@@ -826,7 +825,7 @@ static void omap_gpio_irq_bus_lock(struct irq_data *data) | |||
826 | struct gpio_bank *bank = omap_irq_data_get_bank(data); | 825 | struct gpio_bank *bank = omap_irq_data_get_bank(data); |
827 | 826 | ||
828 | if (!BANK_USED(bank)) | 827 | if (!BANK_USED(bank)) |
829 | pm_runtime_get_sync(bank->dev); | 828 | pm_runtime_get_sync(bank->chip.parent); |
830 | } | 829 | } |
831 | 830 | ||
832 | static void gpio_irq_bus_sync_unlock(struct irq_data *data) | 831 | static void gpio_irq_bus_sync_unlock(struct irq_data *data) |
@@ -838,7 +837,7 @@ static void gpio_irq_bus_sync_unlock(struct irq_data *data) | |||
838 | * disable the bank module. | 837 | * disable the bank module. |
839 | */ | 838 | */ |
840 | if (!BANK_USED(bank)) | 839 | if (!BANK_USED(bank)) |
841 | pm_runtime_put(bank->dev); | 840 | pm_runtime_put(bank->chip.parent); |
842 | } | 841 | } |
843 | 842 | ||
844 | static void omap_gpio_ack_irq(struct irq_data *d) | 843 | static void omap_gpio_ack_irq(struct irq_data *d) |
@@ -1100,7 +1099,8 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc) | |||
1100 | 1099 | ||
1101 | ret = gpiochip_add_data(&bank->chip, bank); | 1100 | ret = gpiochip_add_data(&bank->chip, bank); |
1102 | if (ret) { | 1101 | if (ret) { |
1103 | dev_err(bank->dev, "Could not register gpio chip %d\n", ret); | 1102 | dev_err(bank->chip.parent, |
1103 | "Could not register gpio chip %d\n", ret); | ||
1104 | return ret; | 1104 | return ret; |
1105 | } | 1105 | } |
1106 | 1106 | ||
@@ -1114,7 +1114,7 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc) | |||
1114 | */ | 1114 | */ |
1115 | irq_base = irq_alloc_descs(-1, 0, bank->width, 0); | 1115 | irq_base = irq_alloc_descs(-1, 0, bank->width, 0); |
1116 | if (irq_base < 0) { | 1116 | if (irq_base < 0) { |
1117 | dev_err(bank->dev, "Couldn't allocate IRQ numbers\n"); | 1117 | dev_err(bank->chip.parent, "Couldn't allocate IRQ numbers\n"); |
1118 | return -ENODEV; | 1118 | return -ENODEV; |
1119 | } | 1119 | } |
1120 | #endif | 1120 | #endif |
@@ -1131,15 +1131,17 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc) | |||
1131 | IRQ_TYPE_NONE); | 1131 | IRQ_TYPE_NONE); |
1132 | 1132 | ||
1133 | if (ret) { | 1133 | if (ret) { |
1134 | dev_err(bank->dev, "Couldn't add irqchip to gpiochip %d\n", ret); | 1134 | dev_err(bank->chip.parent, |
1135 | "Couldn't add irqchip to gpiochip %d\n", ret); | ||
1135 | gpiochip_remove(&bank->chip); | 1136 | gpiochip_remove(&bank->chip); |
1136 | return -ENODEV; | 1137 | return -ENODEV; |
1137 | } | 1138 | } |
1138 | 1139 | ||
1139 | gpiochip_set_chained_irqchip(&bank->chip, irqc, bank->irq, NULL); | 1140 | gpiochip_set_chained_irqchip(&bank->chip, irqc, bank->irq, NULL); |
1140 | 1141 | ||
1141 | ret = devm_request_irq(bank->dev, bank->irq, omap_gpio_irq_handler, | 1142 | ret = devm_request_irq(bank->chip.parent, bank->irq, |
1142 | 0, dev_name(bank->dev), bank); | 1143 | omap_gpio_irq_handler, |
1144 | 0, dev_name(bank->chip.parent), bank); | ||
1143 | if (ret) | 1145 | if (ret) |
1144 | gpiochip_remove(&bank->chip); | 1146 | gpiochip_remove(&bank->chip); |
1145 | 1147 | ||
@@ -1196,7 +1198,6 @@ static int omap_gpio_probe(struct platform_device *pdev) | |||
1196 | return bank->irq; | 1198 | return bank->irq; |
1197 | } | 1199 | } |
1198 | 1200 | ||
1199 | bank->dev = dev; | ||
1200 | bank->chip.parent = dev; | 1201 | bank->chip.parent = dev; |
1201 | bank->chip.owner = THIS_MODULE; | 1202 | bank->chip.owner = THIS_MODULE; |
1202 | bank->dbck_flag = pdata->dbck_flag; | 1203 | bank->dbck_flag = pdata->dbck_flag; |
@@ -1235,9 +1236,9 @@ static int omap_gpio_probe(struct platform_device *pdev) | |||
1235 | } | 1236 | } |
1236 | 1237 | ||
1237 | if (bank->dbck_flag) { | 1238 | if (bank->dbck_flag) { |
1238 | bank->dbck = devm_clk_get(bank->dev, "dbclk"); | 1239 | bank->dbck = devm_clk_get(dev, "dbclk"); |
1239 | if (IS_ERR(bank->dbck)) { | 1240 | if (IS_ERR(bank->dbck)) { |
1240 | dev_err(bank->dev, | 1241 | dev_err(dev, |
1241 | "Could not get gpio dbck. Disable debounce\n"); | 1242 | "Could not get gpio dbck. Disable debounce\n"); |
1242 | bank->dbck_flag = false; | 1243 | bank->dbck_flag = false; |
1243 | } else { | 1244 | } else { |
@@ -1247,9 +1248,9 @@ static int omap_gpio_probe(struct platform_device *pdev) | |||
1247 | 1248 | ||
1248 | platform_set_drvdata(pdev, bank); | 1249 | platform_set_drvdata(pdev, bank); |
1249 | 1250 | ||
1250 | pm_runtime_enable(bank->dev); | 1251 | pm_runtime_enable(dev); |
1251 | pm_runtime_irq_safe(bank->dev); | 1252 | pm_runtime_irq_safe(dev); |
1252 | pm_runtime_get_sync(bank->dev); | 1253 | pm_runtime_get_sync(dev); |
1253 | 1254 | ||
1254 | if (bank->is_mpuio) | 1255 | if (bank->is_mpuio) |
1255 | omap_mpuio_init(bank); | 1256 | omap_mpuio_init(bank); |
@@ -1258,14 +1259,14 @@ static int omap_gpio_probe(struct platform_device *pdev) | |||
1258 | 1259 | ||
1259 | ret = omap_gpio_chip_init(bank, irqc); | 1260 | ret = omap_gpio_chip_init(bank, irqc); |
1260 | if (ret) { | 1261 | if (ret) { |
1261 | pm_runtime_put_sync(bank->dev); | 1262 | pm_runtime_put_sync(dev); |
1262 | pm_runtime_disable(bank->dev); | 1263 | pm_runtime_disable(dev); |
1263 | return ret; | 1264 | return ret; |
1264 | } | 1265 | } |
1265 | 1266 | ||
1266 | omap_gpio_show_rev(bank); | 1267 | omap_gpio_show_rev(bank); |
1267 | 1268 | ||
1268 | pm_runtime_put(bank->dev); | 1269 | pm_runtime_put(dev); |
1269 | 1270 | ||
1270 | list_add_tail(&bank->node, &omap_gpio_list); | 1271 | list_add_tail(&bank->node, &omap_gpio_list); |
1271 | 1272 | ||
@@ -1278,7 +1279,7 @@ static int omap_gpio_remove(struct platform_device *pdev) | |||
1278 | 1279 | ||
1279 | list_del(&bank->node); | 1280 | list_del(&bank->node); |
1280 | gpiochip_remove(&bank->chip); | 1281 | gpiochip_remove(&bank->chip); |
1281 | pm_runtime_disable(bank->dev); | 1282 | pm_runtime_disable(&pdev->dev); |
1282 | if (bank->dbck_flag) | 1283 | if (bank->dbck_flag) |
1283 | clk_unprepare(bank->dbck); | 1284 | clk_unprepare(bank->dbck); |
1284 | 1285 | ||
@@ -1348,7 +1349,7 @@ static int omap_gpio_runtime_suspend(struct device *dev) | |||
1348 | update_gpio_context_count: | 1349 | update_gpio_context_count: |
1349 | if (bank->get_context_loss_count) | 1350 | if (bank->get_context_loss_count) |
1350 | bank->context_loss_count = | 1351 | bank->context_loss_count = |
1351 | bank->get_context_loss_count(bank->dev); | 1352 | bank->get_context_loss_count(dev); |
1352 | 1353 | ||
1353 | omap_gpio_dbck_disable(bank); | 1354 | omap_gpio_dbck_disable(bank); |
1354 | raw_spin_unlock_irqrestore(&bank->lock, flags); | 1355 | raw_spin_unlock_irqrestore(&bank->lock, flags); |
@@ -1378,7 +1379,7 @@ static int omap_gpio_runtime_resume(struct device *dev) | |||
1378 | 1379 | ||
1379 | if (bank->get_context_loss_count) | 1380 | if (bank->get_context_loss_count) |
1380 | bank->context_loss_count = | 1381 | bank->context_loss_count = |
1381 | bank->get_context_loss_count(bank->dev); | 1382 | bank->get_context_loss_count(dev); |
1382 | } | 1383 | } |
1383 | 1384 | ||
1384 | omap_gpio_dbck_enable(bank); | 1385 | omap_gpio_dbck_enable(bank); |
@@ -1398,7 +1399,7 @@ static int omap_gpio_runtime_resume(struct device *dev) | |||
1398 | if (!bank->get_context_loss_count) { | 1399 | if (!bank->get_context_loss_count) { |
1399 | omap_gpio_restore_context(bank); | 1400 | omap_gpio_restore_context(bank); |
1400 | } else { | 1401 | } else { |
1401 | c = bank->get_context_loss_count(bank->dev); | 1402 | c = bank->get_context_loss_count(dev); |
1402 | if (c != bank->context_loss_count) { | 1403 | if (c != bank->context_loss_count) { |
1403 | omap_gpio_restore_context(bank); | 1404 | omap_gpio_restore_context(bank); |
1404 | } else { | 1405 | } else { |
@@ -1481,7 +1482,7 @@ void omap2_gpio_prepare_for_idle(int pwr_mode) | |||
1481 | 1482 | ||
1482 | bank->power_mode = pwr_mode; | 1483 | bank->power_mode = pwr_mode; |
1483 | 1484 | ||
1484 | pm_runtime_put_sync_suspend(bank->dev); | 1485 | pm_runtime_put_sync_suspend(bank->chip.parent); |
1485 | } | 1486 | } |
1486 | } | 1487 | } |
1487 | 1488 | ||
@@ -1493,7 +1494,7 @@ void omap2_gpio_resume_after_idle(void) | |||
1493 | if (!BANK_USED(bank) || !bank->loses_context) | 1494 | if (!BANK_USED(bank) || !bank->loses_context) |
1494 | continue; | 1495 | continue; |
1495 | 1496 | ||
1496 | pm_runtime_get_sync(bank->dev); | 1497 | pm_runtime_get_sync(bank->chip.parent); |
1497 | } | 1498 | } |
1498 | } | 1499 | } |
1499 | #endif | 1500 | #endif |