]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
mfd: input: iio: ti_am335x_adc: use one structure for ti_tscadc_dev
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Wed, 5 Jun 2013 14:13:47 +0000 (16:13 +0200)
committerSebastian Andrzej Siewior <bigeasy@linutronix.de>
Wed, 12 Jun 2013 15:58:59 +0000 (17:58 +0200)
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>
drivers/iio/adc/ti_am335x_adc.c
drivers/input/touchscreen/ti_am335x_tsc.c
drivers/mfd/ti_am335x_tscadc.c
include/linux/mfd/ti_am335x_tscadc.h

index 5f9a7e7d313520c71529ffcea02c6f59cc816a93..9db352e413e49a1c2e90f59c9cd1e6a2f52d6620 100644 (file)
@@ -140,7 +140,7 @@ static int tiadc_probe(struct platform_device *pdev)
 {
        struct iio_dev          *indio_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;
        int                     err;
 
@@ -205,9 +205,10 @@ static int tiadc_suspend(struct device *dev)
 {
        struct iio_dev *indio_dev = dev_get_drvdata(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;
 
+       tscadc_dev = ti_tscadc_dev_get(to_platform_device(dev));
        if (!device_may_wakeup(tscadc_dev->dev)) {
                idle = tiadc_readl(adc_dev, REG_CTRL);
                idle &= ~(CNTRLREG_TSCSSENB);
index 51e7b87827a45ff0bd1c5335d2dc7b7b0ce70d8a..16077d3d80ba6236bd6a508d1fec4137cacb9859 100644 (file)
@@ -262,7 +262,7 @@ static int titsc_probe(struct platform_device *pdev)
 {
        struct titsc *ts_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;
        int err;
 
@@ -329,8 +329,8 @@ err_free_mem:
 
 static int titsc_remove(struct platform_device *pdev)
 {
-       struct ti_tscadc_dev *tscadc_dev = pdev->dev.platform_data;
-       struct titsc *ts_dev = tscadc_dev->tsc;
+       struct titsc *ts_dev = platform_get_drvdata(pdev);
+       u32 steps;
 
        free_irq(ts_dev->irq, ts_dev);
 
@@ -344,10 +344,11 @@ static int titsc_remove(struct platform_device *pdev)
 #ifdef CONFIG_PM
 static int titsc_suspend(struct device *dev)
 {
-       struct ti_tscadc_dev *tscadc_dev = dev->platform_data;
-       struct titsc *ts_dev = tscadc_dev->tsc;
+       struct titsc *ts_dev = dev_get_drvdata(dev);
+       struct ti_tscadc_dev *tscadc_dev;
        unsigned int idle;
 
+       tscadc_dev = ti_tscadc_dev_get(to_platform_device(dev));
        if (device_may_wakeup(tscadc_dev->dev)) {
                idle = titsc_readl(ts_dev, REG_IRQENABLE);
                titsc_writel(ts_dev, REG_IRQENABLE,
@@ -359,9 +360,10 @@ static int titsc_suspend(struct device *dev)
 
 static int titsc_resume(struct device *dev)
 {
-       struct ti_tscadc_dev *tscadc_dev = dev->platform_data;
-       struct titsc *ts_dev = tscadc_dev->tsc;
+       struct titsc *ts_dev = dev_get_drvdata(dev);
+       struct ti_tscadc_dev *tscadc_dev;
 
+       tscadc_dev = ti_tscadc_dev_get(to_platform_device(dev));
        if (device_may_wakeup(tscadc_dev->dev)) {
                titsc_writel(ts_dev, REG_IRQWAKEUP,
                                0x00);
index e9f3fb510b44f965795bc87f56c26bffeefe2078..772ea2adb539e62f40a47a60f8ae1af0e5b0bcc6 100644 (file)
@@ -176,14 +176,14 @@ static    int ti_tscadc_probe(struct platform_device *pdev)
        /* TSC Cell */
        cell = &tscadc->cells[TSC_CELL];
        cell->name = "tsc";
-       cell->platform_data = tscadc;
-       cell->pdata_size = sizeof(*tscadc);
+       cell->platform_data = &tscadc;
+       cell->pdata_size = sizeof(tscadc);
 
        /* ADC Cell */
        cell = &tscadc->cells[ADC_CELL];
        cell->name = "tiadc";
-       cell->platform_data = tscadc;
-       cell->pdata_size = sizeof(*tscadc);
+       cell->platform_data = &tscadc;
+       cell->pdata_size = sizeof(tscadc);
 
        err = mfd_add_devices(&pdev->dev, pdev->id, tscadc->cells,
                        TSCADC_CELLS, NULL, 0, NULL);
index c79ad5d2f2716d38aaee8054b74af1c41734761d..8114e4e8b91b2de512bb31dba7ef2724927f53e3 100644 (file)
@@ -149,4 +149,11 @@ struct ti_tscadc_dev {
        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