diff options
author | Stefan Wahren <stefan.wahren@i2se.com> | 2017-04-28 07:47:21 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-05-18 10:45:53 -0400 |
commit | 6bdc00d01e202ae11fa1cae0dacbef895434483d (patch) | |
tree | a63599f56e4bb468fa627f040d7f678cfe09be2e | |
parent | 88e2582e90bb89fe895ff0dceeb5d5ab65d07997 (diff) |
serdev: Restore serdev_device_write_buf for atomic context
Starting with commit 6fe729c4bdae ("serdev: Add serdev_device_write
subroutine") the function serdev_device_write_buf cannot be used in
atomic context anymore (mutex_lock is sleeping). So restore the old
behavior.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Fixes: 6fe729c4bdae ("serdev: Add serdev_device_write subroutine")
Acked-by: Rob Herring <robh@kernel.org>
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/tty/serdev/core.c | 12 | ||||
-rw-r--r-- | include/linux/serdev.h | 14 |
2 files changed, 19 insertions, 7 deletions
diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c index 433de5ea9b02..f71b47334149 100644 --- a/drivers/tty/serdev/core.c +++ b/drivers/tty/serdev/core.c | |||
@@ -122,6 +122,18 @@ void serdev_device_write_wakeup(struct serdev_device *serdev) | |||
122 | } | 122 | } |
123 | EXPORT_SYMBOL_GPL(serdev_device_write_wakeup); | 123 | EXPORT_SYMBOL_GPL(serdev_device_write_wakeup); |
124 | 124 | ||
125 | int serdev_device_write_buf(struct serdev_device *serdev, | ||
126 | const unsigned char *buf, size_t count) | ||
127 | { | ||
128 | struct serdev_controller *ctrl = serdev->ctrl; | ||
129 | |||
130 | if (!ctrl || !ctrl->ops->write_buf) | ||
131 | return -EINVAL; | ||
132 | |||
133 | return ctrl->ops->write_buf(ctrl, buf, count); | ||
134 | } | ||
135 | EXPORT_SYMBOL_GPL(serdev_device_write_buf); | ||
136 | |||
125 | int serdev_device_write(struct serdev_device *serdev, | 137 | int serdev_device_write(struct serdev_device *serdev, |
126 | const unsigned char *buf, size_t count, | 138 | const unsigned char *buf, size_t count, |
127 | unsigned long timeout) | 139 | unsigned long timeout) |
diff --git a/include/linux/serdev.h b/include/linux/serdev.h index cda76c6506ca..e2a225bf716d 100644 --- a/include/linux/serdev.h +++ b/include/linux/serdev.h | |||
@@ -195,6 +195,7 @@ int serdev_device_open(struct serdev_device *); | |||
195 | void serdev_device_close(struct serdev_device *); | 195 | void serdev_device_close(struct serdev_device *); |
196 | unsigned int serdev_device_set_baudrate(struct serdev_device *, unsigned int); | 196 | unsigned int serdev_device_set_baudrate(struct serdev_device *, unsigned int); |
197 | void serdev_device_set_flow_control(struct serdev_device *, bool); | 197 | void serdev_device_set_flow_control(struct serdev_device *, bool); |
198 | int serdev_device_write_buf(struct serdev_device *, const unsigned char *, size_t); | ||
198 | void serdev_device_wait_until_sent(struct serdev_device *, long); | 199 | void serdev_device_wait_until_sent(struct serdev_device *, long); |
199 | int serdev_device_get_tiocm(struct serdev_device *); | 200 | int serdev_device_get_tiocm(struct serdev_device *); |
200 | int serdev_device_set_tiocm(struct serdev_device *, int, int); | 201 | int serdev_device_set_tiocm(struct serdev_device *, int, int); |
@@ -236,6 +237,12 @@ static inline unsigned int serdev_device_set_baudrate(struct serdev_device *sdev | |||
236 | return 0; | 237 | return 0; |
237 | } | 238 | } |
238 | static inline void serdev_device_set_flow_control(struct serdev_device *sdev, bool enable) {} | 239 | static inline void serdev_device_set_flow_control(struct serdev_device *sdev, bool enable) {} |
240 | static inline int serdev_device_write_buf(struct serdev_device *serdev, | ||
241 | const unsigned char *buf, | ||
242 | size_t count) | ||
243 | { | ||
244 | return -ENODEV; | ||
245 | } | ||
239 | static inline void serdev_device_wait_until_sent(struct serdev_device *sdev, long timeout) {} | 246 | static inline void serdev_device_wait_until_sent(struct serdev_device *sdev, long timeout) {} |
240 | static inline int serdev_device_get_tiocm(struct serdev_device *serdev) | 247 | static inline int serdev_device_get_tiocm(struct serdev_device *serdev) |
241 | { | 248 | { |
@@ -312,11 +319,4 @@ static inline struct device *serdev_tty_port_register(struct tty_port *port, | |||
312 | static inline void serdev_tty_port_unregister(struct tty_port *port) {} | 319 | static inline void serdev_tty_port_unregister(struct tty_port *port) {} |
313 | #endif /* CONFIG_SERIAL_DEV_CTRL_TTYPORT */ | 320 | #endif /* CONFIG_SERIAL_DEV_CTRL_TTYPORT */ |
314 | 321 | ||
315 | static inline int serdev_device_write_buf(struct serdev_device *serdev, | ||
316 | const unsigned char *data, | ||
317 | size_t count) | ||
318 | { | ||
319 | return serdev_device_write(serdev, data, count, 0); | ||
320 | } | ||
321 | |||
322 | #endif /*_LINUX_SERDEV_H */ | 322 | #endif /*_LINUX_SERDEV_H */ |