diff options
author | Felipe Balbi <balbi@ti.com> | 2012-08-23 06:32:42 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-09-05 16:26:10 -0400 |
commit | e5b57c037a656c694c7f3674f96352297a6ee7d8 (patch) | |
tree | 2f1c423ecfddd3336320eac34ad238a8e8ff9240 /drivers/tty/serial/omap-serial.c | |
parent | c990f3510357586be63bbe9faf7972212a0dc78f (diff) |
serial: omap: define helpers for pdata function pointers
this patch is in preparation to a few other changes
which will align on the prototype for function
pointers passed through pdata.
It also helps cleaning up the driver a little by
agregating checks for pdata in a single location.
Tested-by: Shubhrajyoti D <shubhrajyoti@ti.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial/omap-serial.c')
-rw-r--r-- | drivers/tty/serial/omap-serial.c | 66 |
1 files changed, 47 insertions, 19 deletions
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c index 8d7a18ab045e..3a60b86ab0f4 100644 --- a/drivers/tty/serial/omap-serial.c +++ b/drivers/tty/serial/omap-serial.c | |||
@@ -102,6 +102,40 @@ static inline void serial_omap_clear_fifos(struct uart_omap_port *up) | |||
102 | serial_out(up, UART_FCR, 0); | 102 | serial_out(up, UART_FCR, 0); |
103 | } | 103 | } |
104 | 104 | ||
105 | static int serial_omap_get_context_loss_count(struct uart_omap_port *up) | ||
106 | { | ||
107 | struct omap_uart_port_info *pdata = up->pdev->dev.platform_data; | ||
108 | |||
109 | if (!pdata->get_context_loss_count) | ||
110 | return 0; | ||
111 | |||
112 | return pdata->get_context_loss_count(&up->pdev->dev); | ||
113 | } | ||
114 | |||
115 | static void serial_omap_set_forceidle(struct uart_omap_port *up) | ||
116 | { | ||
117 | struct omap_uart_port_info *pdata = up->pdev->dev.platform_data; | ||
118 | |||
119 | if (pdata->set_forceidle) | ||
120 | pdata->set_forceidle(up->pdev); | ||
121 | } | ||
122 | |||
123 | static void serial_omap_set_noidle(struct uart_omap_port *up) | ||
124 | { | ||
125 | struct omap_uart_port_info *pdata = up->pdev->dev.platform_data; | ||
126 | |||
127 | if (pdata->set_noidle) | ||
128 | pdata->set_noidle(up->pdev); | ||
129 | } | ||
130 | |||
131 | static void serial_omap_enable_wakeup(struct uart_omap_port *up, bool enable) | ||
132 | { | ||
133 | struct omap_uart_port_info *pdata = up->pdev->dev.platform_data; | ||
134 | |||
135 | if (pdata->enable_wakeup) | ||
136 | pdata->enable_wakeup(up->pdev, enable); | ||
137 | } | ||
138 | |||
105 | /* | 139 | /* |
106 | * serial_omap_get_divisor - calculate divisor value | 140 | * serial_omap_get_divisor - calculate divisor value |
107 | * @port: uart port info | 141 | * @port: uart port info |
@@ -178,8 +212,8 @@ static void serial_omap_stop_tx(struct uart_port *port) | |||
178 | serial_out(up, UART_IER, up->ier); | 212 | serial_out(up, UART_IER, up->ier); |
179 | } | 213 | } |
180 | 214 | ||
181 | if (!up->use_dma && pdata && pdata->set_forceidle) | 215 | if (!up->use_dma && pdata) |
182 | pdata->set_forceidle(up->pdev); | 216 | serial_omap_set_forceidle(up); |
183 | 217 | ||
184 | pm_runtime_mark_last_busy(&up->pdev->dev); | 218 | pm_runtime_mark_last_busy(&up->pdev->dev); |
185 | pm_runtime_put_autosuspend(&up->pdev->dev); | 219 | pm_runtime_put_autosuspend(&up->pdev->dev); |
@@ -309,7 +343,6 @@ static inline void serial_omap_enable_ier_thri(struct uart_omap_port *up) | |||
309 | static void serial_omap_start_tx(struct uart_port *port) | 343 | static void serial_omap_start_tx(struct uart_port *port) |
310 | { | 344 | { |
311 | struct uart_omap_port *up = to_uart_omap_port(port); | 345 | struct uart_omap_port *up = to_uart_omap_port(port); |
312 | struct omap_uart_port_info *pdata = up->pdev->dev.platform_data; | ||
313 | struct circ_buf *xmit; | 346 | struct circ_buf *xmit; |
314 | unsigned int start; | 347 | unsigned int start; |
315 | int ret = 0; | 348 | int ret = 0; |
@@ -317,8 +350,7 @@ static void serial_omap_start_tx(struct uart_port *port) | |||
317 | if (!up->use_dma) { | 350 | if (!up->use_dma) { |
318 | pm_runtime_get_sync(&up->pdev->dev); | 351 | pm_runtime_get_sync(&up->pdev->dev); |
319 | serial_omap_enable_ier_thri(up); | 352 | serial_omap_enable_ier_thri(up); |
320 | if (pdata && pdata->set_noidle) | 353 | serial_omap_set_noidle(up); |
321 | pdata->set_noidle(up->pdev); | ||
322 | pm_runtime_mark_last_busy(&up->pdev->dev); | 354 | pm_runtime_mark_last_busy(&up->pdev->dev); |
323 | pm_runtime_put_autosuspend(&up->pdev->dev); | 355 | pm_runtime_put_autosuspend(&up->pdev->dev); |
324 | return; | 356 | return; |
@@ -1681,28 +1713,26 @@ static int serial_omap_runtime_suspend(struct device *dev) | |||
1681 | if (!up) | 1713 | if (!up) |
1682 | return -EINVAL; | 1714 | return -EINVAL; |
1683 | 1715 | ||
1684 | if (!pdata || !pdata->enable_wakeup) | 1716 | if (!pdata) |
1685 | return 0; | 1717 | return 0; |
1686 | 1718 | ||
1687 | if (pdata->get_context_loss_count) | 1719 | up->context_loss_cnt = serial_omap_get_context_loss_count(up); |
1688 | up->context_loss_cnt = pdata->get_context_loss_count(dev); | ||
1689 | 1720 | ||
1690 | if (device_may_wakeup(dev)) { | 1721 | if (device_may_wakeup(dev)) { |
1691 | if (!up->wakeups_enabled) { | 1722 | if (!up->wakeups_enabled) { |
1692 | pdata->enable_wakeup(up->pdev, true); | 1723 | serial_omap_enable_wakeup(up, true); |
1693 | up->wakeups_enabled = true; | 1724 | up->wakeups_enabled = true; |
1694 | } | 1725 | } |
1695 | } else { | 1726 | } else { |
1696 | if (up->wakeups_enabled) { | 1727 | if (up->wakeups_enabled) { |
1697 | pdata->enable_wakeup(up->pdev, false); | 1728 | serial_omap_enable_wakeup(up, false); |
1698 | up->wakeups_enabled = false; | 1729 | up->wakeups_enabled = false; |
1699 | } | 1730 | } |
1700 | } | 1731 | } |
1701 | 1732 | ||
1702 | /* Errata i291 */ | 1733 | /* Errata i291 */ |
1703 | if (up->use_dma && pdata->set_forceidle && | 1734 | if (up->use_dma && (up->errata & UART_ERRATA_i291_DMA_FORCEIDLE)) |
1704 | (up->errata & UART_ERRATA_i291_DMA_FORCEIDLE)) | 1735 | serial_omap_set_forceidle(up); |
1705 | pdata->set_forceidle(up->pdev); | ||
1706 | 1736 | ||
1707 | up->latency = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE; | 1737 | up->latency = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE; |
1708 | schedule_work(&up->qos_work); | 1738 | schedule_work(&up->qos_work); |
@@ -1716,17 +1746,15 @@ static int serial_omap_runtime_resume(struct device *dev) | |||
1716 | struct omap_uart_port_info *pdata = dev->platform_data; | 1746 | struct omap_uart_port_info *pdata = dev->platform_data; |
1717 | 1747 | ||
1718 | if (up && pdata) { | 1748 | if (up && pdata) { |
1719 | if (pdata->get_context_loss_count) { | 1749 | u32 loss_cnt = serial_omap_get_context_loss_count(up); |
1720 | u32 loss_cnt = pdata->get_context_loss_count(dev); | ||
1721 | 1750 | ||
1722 | if (up->context_loss_cnt != loss_cnt) | 1751 | if (up->context_loss_cnt != loss_cnt) |
1723 | serial_omap_restore_context(up); | 1752 | serial_omap_restore_context(up); |
1724 | } | ||
1725 | 1753 | ||
1726 | /* Errata i291 */ | 1754 | /* Errata i291 */ |
1727 | if (up->use_dma && pdata->set_noidle && | 1755 | if ((up->errata & UART_ERRATA_i291_DMA_FORCEIDLE) && |
1728 | (up->errata & UART_ERRATA_i291_DMA_FORCEIDLE)) | 1756 | up->use_dma) |
1729 | pdata->set_noidle(up->pdev); | 1757 | serial_omap_set_noidle(up); |
1730 | 1758 | ||
1731 | up->latency = up->calc_latency; | 1759 | up->latency = up->calc_latency; |
1732 | schedule_work(&up->qos_work); | 1760 | schedule_work(&up->qos_work); |