Skip to content

Commit 6bdc00d

Browse files
lategoodbyegregkh
authored andcommitted
serdev: Restore serdev_device_write_buf for atomic context
Starting with commit 6fe729c ("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: 6fe729c ("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>
1 parent 88e2582 commit 6bdc00d

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

drivers/tty/serdev/core.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,18 @@ void serdev_device_write_wakeup(struct serdev_device *serdev)
122122
}
123123
EXPORT_SYMBOL_GPL(serdev_device_write_wakeup);
124124

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+
125137
int serdev_device_write(struct serdev_device *serdev,
126138
const unsigned char *buf, size_t count,
127139
unsigned long timeout)

include/linux/serdev.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ int serdev_device_open(struct serdev_device *);
195195
void serdev_device_close(struct serdev_device *);
196196
unsigned int serdev_device_set_baudrate(struct serdev_device *, unsigned int);
197197
void serdev_device_set_flow_control(struct serdev_device *, bool);
198+
int serdev_device_write_buf(struct serdev_device *, const unsigned char *, size_t);
198199
void serdev_device_wait_until_sent(struct serdev_device *, long);
199200
int serdev_device_get_tiocm(struct serdev_device *);
200201
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
236237
return 0;
237238
}
238239
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+
}
239246
static inline void serdev_device_wait_until_sent(struct serdev_device *sdev, long timeout) {}
240247
static inline int serdev_device_get_tiocm(struct serdev_device *serdev)
241248
{
@@ -312,11 +319,4 @@ static inline struct device *serdev_tty_port_register(struct tty_port *port,
312319
static inline void serdev_tty_port_unregister(struct tty_port *port) {}
313320
#endif /* CONFIG_SERIAL_DEV_CTRL_TTYPORT */
314321

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-
322322
#endif /*_LINUX_SERDEV_H */

0 commit comments

Comments
 (0)