lkml.org 
[lkml]   [2018]   [Jun]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 20/24] serdev: Make match_id accessible by drivers
Date
Drivers that make use of the driver_data field require to transverse the
id_table. There is no reason to have one implementation per driver.

Cc: Rob Herring <robh@kernel.org>
Cc: Johan Hovold <johan@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
drivers/tty/serdev/core.c | 12 +++++++-----
include/linux/serdev.h | 3 +++
2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
index 587d2796b3d5..3084b6d10179 100644
--- a/drivers/tty/serdev/core.c
+++ b/drivers/tty/serdev/core.c
@@ -158,17 +158,19 @@ static const struct device_type serdev_ctrl_type = {
.release = serdev_ctrl_release,
};

-static int serdev_match_id(const struct serdev_device_id *id,
- const struct serdev_device *sdev)
+const struct serdev_device_id *serdev_match_id(
+ const struct serdev_device_id *id,
+ const struct serdev_device *sdev)
{
while (id->name[0]) {
if (!strcmp(sdev->modalias, id->name))
- return 1;
+ return id;
id++;
}

- return 0;
+ return NULL;
}
+EXPORT_SYMBOL_GPL(serdev_match_id);

static int serdev_device_match(struct device *dev, struct device_driver *drv)
{
@@ -186,7 +188,7 @@ static int serdev_device_match(struct device *dev, struct device_driver *drv)
return 1;

if (sdrv->id_table)
- return serdev_match_id(sdrv->id_table, sdev);
+ return serdev_match_id(sdrv->id_table, sdev) != NULL;

return strcmp(sdev->modalias, drv->name) == 0;
}
diff --git a/include/linux/serdev.h b/include/linux/serdev.h
index 07d63933bdb9..bf282b3781b9 100644
--- a/include/linux/serdev.h
+++ b/include/linux/serdev.h
@@ -172,6 +172,9 @@ static inline void serdev_controller_put(struct serdev_controller *ctrl)
put_device(&ctrl->dev);
}

+const struct serdev_device_id *serdev_match_id(
+ const struct serdev_device_id *id,
+ const struct serdev_device *sdev);
struct serdev_device *serdev_device_alloc(struct serdev_controller *);
int serdev_device_add(struct serdev_device *);
void serdev_device_remove(struct serdev_device *);
--
2.17.1
\
 
 \ /
  Last update: 2018-06-11 13:54    [W:0.282 / U:0.192 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site