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 23/24] serdev: get/put controller
    Date
    Allow access serdev controllers by other drivers in a safe way.

    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 | 23 +++++++++++++++++++++++
    include/linux/serdev.h | 2 ++
    2 files changed, 25 insertions(+)

    diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
    index 6b24b0a74fbf..06310110104a 100644
    --- a/drivers/tty/serdev/core.c
    +++ b/drivers/tty/serdev/core.c
    @@ -724,6 +724,29 @@ void serdev_controller_remove(struct serdev_controller *ctrl)
    }
    EXPORT_SYMBOL_GPL(serdev_controller_remove);

    +struct serdev_controller *serdev_get_controller(int nr)
    +{
    + struct serdev_controller *ctrl;
    +
    + ctrl = idr_find(&ctrl_idr, nr);
    + if (!ctrl)
    + return NULL;
    +
    + get_device(&ctrl->dev);
    +
    + return ctrl;
    +}
    +EXPORT_SYMBOL_GPL(serdev_get_controller);
    +
    +void serdev_put_controller(struct serdev_controller *ctrl)
    +{
    + if (!ctrl)
    + return;
    +
    + put_device(&ctrl->dev);
    +}
    +EXPORT_SYMBOL_GPL(serdev_put_controller);
    +
    /**
    * serdev_driver_register() - Register client driver with serdev core
    * @sdrv: client driver to be associated with client-device.
    diff --git a/include/linux/serdev.h b/include/linux/serdev.h
    index bf282b3781b9..1ef6e6503650 100644
    --- a/include/linux/serdev.h
    +++ b/include/linux/serdev.h
    @@ -182,6 +182,8 @@ void serdev_device_remove(struct serdev_device *);
    struct serdev_controller *serdev_controller_alloc(struct device *, size_t);
    int serdev_controller_add(struct serdev_controller *);
    void serdev_controller_remove(struct serdev_controller *);
    +void serdev_put_controller(struct serdev_controller *ctrl);
    +struct serdev_controller *serdev_get_controller(int nr);

    static inline void serdev_controller_write_wakeup(struct serdev_controller *ctrl)
    {
    --
    2.17.1
    \
     
     \ /
      Last update: 2018-06-11 13:54    [W:2.224 / U:0.092 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site