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: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
parent d683b96b
...@@ -140,7 +140,7 @@ static int tiadc_probe(struct platform_device *pdev) ...@@ -140,7 +140,7 @@ static int tiadc_probe(struct platform_device *pdev)
{ {
struct iio_dev *indio_dev; struct iio_dev *indio_dev;
struct tiadc_device *adc_dev; struct tiadc_device *adc_dev;
struct ti_tscadc_dev *tscadc_dev = pdev->dev.platform_data; struct ti_tscadc_dev *tscadc_dev = ti_tscadc_dev_get(pdev);
struct mfd_tscadc_board *pdata; struct mfd_tscadc_board *pdata;
int err; int err;
...@@ -205,9 +205,10 @@ static int tiadc_suspend(struct device *dev) ...@@ -205,9 +205,10 @@ static int tiadc_suspend(struct device *dev)
{ {
struct iio_dev *indio_dev = dev_get_drvdata(dev); struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct tiadc_device *adc_dev = iio_priv(indio_dev); struct tiadc_device *adc_dev = iio_priv(indio_dev);
struct ti_tscadc_dev *tscadc_dev = dev->platform_data; struct ti_tscadc_dev *tscadc_dev;
unsigned int idle; unsigned int idle;
tscadc_dev = ti_tscadc_dev_get(to_platform_device(dev));
if (!device_may_wakeup(tscadc_dev->dev)) { if (!device_may_wakeup(tscadc_dev->dev)) {
idle = tiadc_readl(adc_dev, REG_CTRL); idle = tiadc_readl(adc_dev, REG_CTRL);
idle &= ~(CNTRLREG_TSCSSENB); idle &= ~(CNTRLREG_TSCSSENB);
......
...@@ -262,7 +262,7 @@ static int titsc_probe(struct platform_device *pdev) ...@@ -262,7 +262,7 @@ static int titsc_probe(struct platform_device *pdev)
{ {
struct titsc *ts_dev; struct titsc *ts_dev;
struct input_dev *input_dev; struct input_dev *input_dev;
struct ti_tscadc_dev *tscadc_dev = pdev->dev.platform_data; struct ti_tscadc_dev *tscadc_dev = ti_tscadc_dev_get(pdev);
struct mfd_tscadc_board *pdata; struct mfd_tscadc_board *pdata;
int err; int err;
...@@ -329,8 +329,8 @@ static int titsc_probe(struct platform_device *pdev) ...@@ -329,8 +329,8 @@ static int titsc_probe(struct platform_device *pdev)
static int titsc_remove(struct platform_device *pdev) static int titsc_remove(struct platform_device *pdev)
{ {
struct ti_tscadc_dev *tscadc_dev = pdev->dev.platform_data; struct titsc *ts_dev = platform_get_drvdata(pdev);
struct titsc *ts_dev = tscadc_dev->tsc; u32 steps;
free_irq(ts_dev->irq, ts_dev); free_irq(ts_dev->irq, ts_dev);
...@@ -344,10 +344,11 @@ static int titsc_remove(struct platform_device *pdev) ...@@ -344,10 +344,11 @@ static int titsc_remove(struct platform_device *pdev)
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int titsc_suspend(struct device *dev) static int titsc_suspend(struct device *dev)
{ {
struct ti_tscadc_dev *tscadc_dev = dev->platform_data; struct titsc *ts_dev = dev_get_drvdata(dev);
struct titsc *ts_dev = tscadc_dev->tsc; struct ti_tscadc_dev *tscadc_dev;
unsigned int idle; unsigned int idle;
tscadc_dev = ti_tscadc_dev_get(to_platform_device(dev));
if (device_may_wakeup(tscadc_dev->dev)) { if (device_may_wakeup(tscadc_dev->dev)) {
idle = titsc_readl(ts_dev, REG_IRQENABLE); idle = titsc_readl(ts_dev, REG_IRQENABLE);
titsc_writel(ts_dev, REG_IRQENABLE, titsc_writel(ts_dev, REG_IRQENABLE,
...@@ -359,9 +360,10 @@ static int titsc_suspend(struct device *dev) ...@@ -359,9 +360,10 @@ static int titsc_suspend(struct device *dev)
static int titsc_resume(struct device *dev) static int titsc_resume(struct device *dev)
{ {
struct ti_tscadc_dev *tscadc_dev = dev->platform_data; struct titsc *ts_dev = dev_get_drvdata(dev);
struct titsc *ts_dev = tscadc_dev->tsc; struct ti_tscadc_dev *tscadc_dev;
tscadc_dev = ti_tscadc_dev_get(to_platform_device(dev));
if (device_may_wakeup(tscadc_dev->dev)) { if (device_may_wakeup(tscadc_dev->dev)) {
titsc_writel(ts_dev, REG_IRQWAKEUP, titsc_writel(ts_dev, REG_IRQWAKEUP,
0x00); 0x00);
......
...@@ -176,14 +176,14 @@ static int ti_tscadc_probe(struct platform_device *pdev) ...@@ -176,14 +176,14 @@ static int ti_tscadc_probe(struct platform_device *pdev)
/* TSC Cell */ /* TSC Cell */
cell = &tscadc->cells[TSC_CELL]; cell = &tscadc->cells[TSC_CELL];
cell->name = "tsc"; cell->name = "tsc";
cell->platform_data = tscadc; cell->platform_data = &tscadc;
cell->pdata_size = sizeof(*tscadc); cell->pdata_size = sizeof(tscadc);
/* ADC Cell */ /* ADC Cell */
cell = &tscadc->cells[ADC_CELL]; cell = &tscadc->cells[ADC_CELL];
cell->name = "tiadc"; cell->name = "tiadc";
cell->platform_data = tscadc; cell->platform_data = &tscadc;
cell->pdata_size = sizeof(*tscadc); cell->pdata_size = sizeof(tscadc);
err = mfd_add_devices(&pdev->dev, pdev->id, tscadc->cells, err = mfd_add_devices(&pdev->dev, pdev->id, tscadc->cells,
TSCADC_CELLS, NULL, 0, NULL); TSCADC_CELLS, NULL, 0, NULL);
......
...@@ -149,4 +149,11 @@ struct ti_tscadc_dev { ...@@ -149,4 +149,11 @@ struct ti_tscadc_dev {
struct adc_device *adc; struct adc_device *adc;
}; };
static inline struct ti_tscadc_dev *ti_tscadc_dev_get(struct platform_device *p)
{
struct ti_tscadc_dev **tscadc_dev = p->dev.platform_data;
return *tscadc_dev;
}
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment