diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2013-06-05 10:13:47 -0400 |
---|---|---|
committer | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2013-06-12 11:58:59 -0400 |
commit | a9bce1b03c2199e66d36cda8aac675338bc074a7 (patch) | |
tree | 1f02ee8522388834c2a31de21dd8b7b38409f457 | |
parent | d683b96b072dc4680fc74964eca77e6a23d1fa6e (diff) |
mfd: input: iio: ti_am335x_adc: use one structure for ti_tscadc_dev
The mfd driver creates platform data for the child devices and it is the
ti_tscadc_dev struct. This struct is copied for the two devices.
The copy of the structure makes a common lock in this structure a little
less usefull. Therefore the platform data is not a pointer to the
structure and the same structure is used.
While doing the change I noticed that the suspend/resume code assumes
the wrong pointer for ti_tscadc_dev and this has been fixed as well.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-rw-r--r-- | drivers/iio/adc/ti_am335x_adc.c | 5 | ||||
-rw-r--r-- | drivers/input/touchscreen/ti_am335x_tsc.c | 16 | ||||
-rw-r--r-- | drivers/mfd/ti_am335x_tscadc.c | 8 | ||||
-rw-r--r-- | include/linux/mfd/ti_am335x_tscadc.h | 7 |
4 files changed, 23 insertions, 13 deletions
diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c index 5f9a7e7d3135..9db352e413e4 100644 --- a/drivers/iio/adc/ti_am335x_adc.c +++ b/drivers/iio/adc/ti_am335x_adc.c | |||
@@ -140,7 +140,7 @@ static int tiadc_probe(struct platform_device *pdev) | |||
140 | { | 140 | { |
141 | struct iio_dev *indio_dev; | 141 | struct iio_dev *indio_dev; |
142 | struct tiadc_device *adc_dev; | 142 | struct tiadc_device *adc_dev; |
143 | struct ti_tscadc_dev *tscadc_dev = pdev->dev.platform_data; | 143 | struct ti_tscadc_dev *tscadc_dev = ti_tscadc_dev_get(pdev); |
144 | struct mfd_tscadc_board *pdata; | 144 | struct mfd_tscadc_board *pdata; |
145 | int err; | 145 | int err; |
146 | 146 | ||
@@ -205,9 +205,10 @@ static int tiadc_suspend(struct device *dev) | |||
205 | { | 205 | { |
206 | struct iio_dev *indio_dev = dev_get_drvdata(dev); | 206 | struct iio_dev *indio_dev = dev_get_drvdata(dev); |
207 | struct tiadc_device *adc_dev = iio_priv(indio_dev); | 207 | struct tiadc_device *adc_dev = iio_priv(indio_dev); |
208 | struct ti_tscadc_dev *tscadc_dev = dev->platform_data; | 208 | struct ti_tscadc_dev *tscadc_dev; |
209 | unsigned int idle; | 209 | unsigned int idle; |
210 | 210 | ||
211 | tscadc_dev = ti_tscadc_dev_get(to_platform_device(dev)); | ||
211 | if (!device_may_wakeup(tscadc_dev->dev)) { | 212 | if (!device_may_wakeup(tscadc_dev->dev)) { |
212 | idle = tiadc_readl(adc_dev, REG_CTRL); | 213 | idle = tiadc_readl(adc_dev, REG_CTRL); |
213 | idle &= ~(CNTRLREG_TSCSSENB); | 214 | idle &= ~(CNTRLREG_TSCSSENB); |
diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c index 51e7b87827a4..16077d3d80ba 100644 --- a/drivers/input/touchscreen/ti_am335x_tsc.c +++ b/drivers/input/touchscreen/ti_am335x_tsc.c | |||
@@ -262,7 +262,7 @@ static int titsc_probe(struct platform_device *pdev) | |||
262 | { | 262 | { |
263 | struct titsc *ts_dev; | 263 | struct titsc *ts_dev; |
264 | struct input_dev *input_dev; | 264 | struct input_dev *input_dev; |
265 | struct ti_tscadc_dev *tscadc_dev = pdev->dev.platform_data; | 265 | struct ti_tscadc_dev *tscadc_dev = ti_tscadc_dev_get(pdev); |
266 | struct mfd_tscadc_board *pdata; | 266 | struct mfd_tscadc_board *pdata; |
267 | int err; | 267 | int err; |
268 | 268 | ||
@@ -329,8 +329,8 @@ err_free_mem: | |||
329 | 329 | ||
330 | static int titsc_remove(struct platform_device *pdev) | 330 | static int titsc_remove(struct platform_device *pdev) |
331 | { | 331 | { |
332 | struct ti_tscadc_dev *tscadc_dev = pdev->dev.platform_data; | 332 | struct titsc *ts_dev = platform_get_drvdata(pdev); |
333 | struct titsc *ts_dev = tscadc_dev->tsc; | 333 | u32 steps; |
334 | 334 | ||
335 | free_irq(ts_dev->irq, ts_dev); | 335 | free_irq(ts_dev->irq, ts_dev); |
336 | 336 | ||
@@ -344,10 +344,11 @@ static int titsc_remove(struct platform_device *pdev) | |||
344 | #ifdef CONFIG_PM | 344 | #ifdef CONFIG_PM |
345 | static int titsc_suspend(struct device *dev) | 345 | static int titsc_suspend(struct device *dev) |
346 | { | 346 | { |
347 | struct ti_tscadc_dev *tscadc_dev = dev->platform_data; | 347 | struct titsc *ts_dev = dev_get_drvdata(dev); |
348 | struct titsc *ts_dev = tscadc_dev->tsc; | 348 | struct ti_tscadc_dev *tscadc_dev; |
349 | unsigned int idle; | 349 | unsigned int idle; |
350 | 350 | ||
351 | tscadc_dev = ti_tscadc_dev_get(to_platform_device(dev)); | ||
351 | if (device_may_wakeup(tscadc_dev->dev)) { | 352 | if (device_may_wakeup(tscadc_dev->dev)) { |
352 | idle = titsc_readl(ts_dev, REG_IRQENABLE); | 353 | idle = titsc_readl(ts_dev, REG_IRQENABLE); |
353 | titsc_writel(ts_dev, REG_IRQENABLE, | 354 | titsc_writel(ts_dev, REG_IRQENABLE, |
@@ -359,9 +360,10 @@ static int titsc_suspend(struct device *dev) | |||
359 | 360 | ||
360 | static int titsc_resume(struct device *dev) | 361 | static int titsc_resume(struct device *dev) |
361 | { | 362 | { |
362 | struct ti_tscadc_dev *tscadc_dev = dev->platform_data; | 363 | struct titsc *ts_dev = dev_get_drvdata(dev); |
363 | struct titsc *ts_dev = tscadc_dev->tsc; | 364 | struct ti_tscadc_dev *tscadc_dev; |
364 | 365 | ||
366 | tscadc_dev = ti_tscadc_dev_get(to_platform_device(dev)); | ||
365 | if (device_may_wakeup(tscadc_dev->dev)) { | 367 | if (device_may_wakeup(tscadc_dev->dev)) { |
366 | titsc_writel(ts_dev, REG_IRQWAKEUP, | 368 | titsc_writel(ts_dev, REG_IRQWAKEUP, |
367 | 0x00); | 369 | 0x00); |
diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c index e9f3fb510b44..772ea2adb539 100644 --- a/drivers/mfd/ti_am335x_tscadc.c +++ b/drivers/mfd/ti_am335x_tscadc.c | |||
@@ -176,14 +176,14 @@ static int ti_tscadc_probe(struct platform_device *pdev) | |||
176 | /* TSC Cell */ | 176 | /* TSC Cell */ |
177 | cell = &tscadc->cells[TSC_CELL]; | 177 | cell = &tscadc->cells[TSC_CELL]; |
178 | cell->name = "tsc"; | 178 | cell->name = "tsc"; |
179 | cell->platform_data = tscadc; | 179 | cell->platform_data = &tscadc; |
180 | cell->pdata_size = sizeof(*tscadc); | 180 | cell->pdata_size = sizeof(tscadc); |
181 | 181 | ||
182 | /* ADC Cell */ | 182 | /* ADC Cell */ |
183 | cell = &tscadc->cells[ADC_CELL]; | 183 | cell = &tscadc->cells[ADC_CELL]; |
184 | cell->name = "tiadc"; | 184 | cell->name = "tiadc"; |
185 | cell->platform_data = tscadc; | 185 | cell->platform_data = &tscadc; |
186 | cell->pdata_size = sizeof(*tscadc); | 186 | cell->pdata_size = sizeof(tscadc); |
187 | 187 | ||
188 | err = mfd_add_devices(&pdev->dev, pdev->id, tscadc->cells, | 188 | err = mfd_add_devices(&pdev->dev, pdev->id, tscadc->cells, |
189 | TSCADC_CELLS, NULL, 0, NULL); | 189 | TSCADC_CELLS, NULL, 0, NULL); |
diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h index c79ad5d2f271..8114e4e8b91b 100644 --- a/include/linux/mfd/ti_am335x_tscadc.h +++ b/include/linux/mfd/ti_am335x_tscadc.h | |||
@@ -149,4 +149,11 @@ struct ti_tscadc_dev { | |||
149 | struct adc_device *adc; | 149 | struct adc_device *adc; |
150 | }; | 150 | }; |
151 | 151 | ||
152 | static inline struct ti_tscadc_dev *ti_tscadc_dev_get(struct platform_device *p) | ||
153 | { | ||
154 | struct ti_tscadc_dev **tscadc_dev = p->dev.platform_data; | ||
155 | |||
156 | return *tscadc_dev; | ||
157 | } | ||
158 | |||
152 | #endif | 159 | #endif |