diff mbox

[3/4] Input: tsc2005 - simplify drvdata acquisition

Message ID 1436962408-5206-4-git-send-email-sre@kernel.org (mailing list archive)
State Superseded
Headers show

Commit Message

Sebastian Reichel July 15, 2015, 12:13 p.m. UTC
Do not convert device to spi_device just for getting
the driver data, since spi_get_drvdata() just calls
dev_get_drvdata().

Signed-off-by: Sebastian Reichel <sre@kernel.org>
---
 drivers/input/touchscreen/tsc2005.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

Comments

Dmitry Torokhov July 15, 2015, 9:31 p.m. UTC | #1
On Wed, Jul 15, 2015 at 02:13:27PM +0200, Sebastian Reichel wrote:
> Do not convert device to spi_device just for getting
> the driver data, since spi_get_drvdata() just calls
> dev_get_drvdata().

Even though at the moment they all share the same data I consider them
logically different and so would prefer not to substityte one for
another.

Thanks.
Sebastian Reichel July 15, 2015, 10:02 p.m. UTC | #2
Hi,

On Wed, Jul 15, 2015 at 02:31:07PM -0700, Dmitry Torokhov wrote:
> On Wed, Jul 15, 2015 at 02:13:27PM +0200, Sebastian Reichel wrote:
> > Do not convert device to spi_device just for getting
> > the driver data, since spi_get_drvdata() just calls
> > dev_get_drvdata().
> 
> Even though at the moment they all share the same data I consider them
> logically different and so would prefer not to substityte one for
> another.

I guess your problem is with mixing spi_*_drvdata and dev_*_drvdata
calls? In that case I will also change spi_set_drvdata to
dev_set_drvdata, so that spi_*_drvdata is not used at all.

This will still reduce lines of code and flatten the way for tsc2004
support (which is i2c based).

-- Sebastian
Dmitry Torokhov July 16, 2015, 12:22 a.m. UTC | #3
On Thu, Jul 16, 2015 at 12:02:21AM +0200, Sebastian Reichel wrote:
> Hi,
> 
> On Wed, Jul 15, 2015 at 02:31:07PM -0700, Dmitry Torokhov wrote:
> > On Wed, Jul 15, 2015 at 02:13:27PM +0200, Sebastian Reichel wrote:
> > > Do not convert device to spi_device just for getting
> > > the driver data, since spi_get_drvdata() just calls
> > > dev_get_drvdata().
> > 
> > Even though at the moment they all share the same data I consider them
> > logically different and so would prefer not to substityte one for
> > another.
> 
> I guess your problem is with mixing spi_*_drvdata and dev_*_drvdata
> calls? In that case I will also change spi_set_drvdata to
> dev_set_drvdata, so that spi_*_drvdata is not used at all.
> 
> This will still reduce lines of code and flatten the way for tsc2004
> support (which is i2c based).

OK, that will work.

Thanks.
diff mbox

Patch

diff --git a/drivers/input/touchscreen/tsc2005.c b/drivers/input/touchscreen/tsc2005.c
index 0aec45a..83508d8 100644
--- a/drivers/input/touchscreen/tsc2005.c
+++ b/drivers/input/touchscreen/tsc2005.c
@@ -354,8 +354,7 @@  static ssize_t tsc2005_selftest_show(struct device *dev,
 				     struct device_attribute *attr,
 				     char *buf)
 {
-	struct spi_device *spi = to_spi_device(dev);
-	struct tsc2005 *ts = spi_get_drvdata(spi);
+	struct tsc2005 *ts = dev_get_drvdata(dev);
 	unsigned int temp_high;
 	unsigned int temp_high_orig;
 	unsigned int temp_high_test;
@@ -440,8 +439,7 @@  static umode_t tsc2005_attr_is_visible(struct kobject *kobj,
 				      struct attribute *attr, int n)
 {
 	struct device *dev = container_of(kobj, struct device, kobj);
-	struct spi_device *spi = to_spi_device(dev);
-	struct tsc2005 *ts = spi_get_drvdata(spi);
+	struct tsc2005 *ts = dev_get_drvdata(dev);
 	umode_t mode = attr->mode;
 
 	if (attr == &dev_attr_selftest.attr) {
@@ -729,8 +727,7 @@  static int tsc2005_remove(struct spi_device *spi)
 
 static int __maybe_unused tsc2005_suspend(struct device *dev)
 {
-	struct spi_device *spi = to_spi_device(dev);
-	struct tsc2005 *ts = spi_get_drvdata(spi);
+	struct tsc2005 *ts = dev_get_drvdata(dev);
 
 	mutex_lock(&ts->mutex);
 
@@ -746,8 +743,7 @@  static int __maybe_unused tsc2005_suspend(struct device *dev)
 
 static int __maybe_unused tsc2005_resume(struct device *dev)
 {
-	struct spi_device *spi = to_spi_device(dev);
-	struct tsc2005 *ts = spi_get_drvdata(spi);
+	struct tsc2005 *ts = dev_get_drvdata(dev);
 
 	mutex_lock(&ts->mutex);