Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next
Johan Hedberg says: ==================== pull request: bluetooth-next 2017-04-14 Here's the main batch of Bluetooth & 802.15.4 patches for the 4.12 kernel. - Many fixes to 6LoWPAN, in particular for BLE - New CA8210 IEEE 802.15.4 device driver (accounting for most of the lines of code added in this pull request) - Added Nokia Bluetooth (UART) HCI driver - Some serdev & TTY changes that are dependencies for the Nokia driver (with acks from relevant maintainers and an agreement that these come through the bluetooth tree) - Support for new Intel Bluetooth device - Various other minor cleanups/fixes here and there Please let me know if there are any issues pulling. Thanks. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/termios.h>
|
||||
#include <linux/delay.h>
|
||||
|
||||
struct serdev_controller;
|
||||
struct serdev_device;
|
||||
@@ -81,6 +83,9 @@ struct serdev_controller_ops {
|
||||
void (*close)(struct serdev_controller *);
|
||||
void (*set_flow_control)(struct serdev_controller *, bool);
|
||||
unsigned int (*set_baudrate)(struct serdev_controller *, unsigned int);
|
||||
void (*wait_until_sent)(struct serdev_controller *, long);
|
||||
int (*get_tiocm)(struct serdev_controller *);
|
||||
int (*set_tiocm)(struct serdev_controller *, unsigned int, unsigned int);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -186,6 +191,9 @@ int serdev_device_open(struct serdev_device *);
|
||||
void serdev_device_close(struct serdev_device *);
|
||||
unsigned int serdev_device_set_baudrate(struct serdev_device *, unsigned int);
|
||||
void serdev_device_set_flow_control(struct serdev_device *, bool);
|
||||
void serdev_device_wait_until_sent(struct serdev_device *, long);
|
||||
int serdev_device_get_tiocm(struct serdev_device *);
|
||||
int serdev_device_set_tiocm(struct serdev_device *, int, int);
|
||||
int serdev_device_write_buf(struct serdev_device *, const unsigned char *, size_t);
|
||||
void serdev_device_write_flush(struct serdev_device *);
|
||||
int serdev_device_write_room(struct serdev_device *);
|
||||
@@ -223,6 +231,15 @@ static inline unsigned int serdev_device_set_baudrate(struct serdev_device *sdev
|
||||
return 0;
|
||||
}
|
||||
static inline void serdev_device_set_flow_control(struct serdev_device *sdev, bool enable) {}
|
||||
static inline void serdev_device_wait_until_sent(struct serdev_device *sdev, long timeout) {}
|
||||
static inline int serdev_device_get_tiocm(struct serdev_device *serdev)
|
||||
{
|
||||
return -ENOTSUPP;
|
||||
}
|
||||
static inline int serdev_device_set_tiocm(struct serdev_device *serdev, int set, int clear)
|
||||
{
|
||||
return -ENOTSUPP;
|
||||
}
|
||||
static inline int serdev_device_write_buf(struct serdev_device *sdev, const unsigned char *buf, size_t count)
|
||||
{
|
||||
return -ENODEV;
|
||||
@@ -238,6 +255,36 @@ static inline int serdev_device_write_room(struct serdev_device *sdev)
|
||||
|
||||
#endif /* CONFIG_SERIAL_DEV_BUS */
|
||||
|
||||
static inline bool serdev_device_get_cts(struct serdev_device *serdev)
|
||||
{
|
||||
int status = serdev_device_get_tiocm(serdev);
|
||||
return !!(status & TIOCM_CTS);
|
||||
}
|
||||
|
||||
static inline int serdev_device_wait_for_cts(struct serdev_device *serdev, bool state, int timeout_ms)
|
||||
{
|
||||
unsigned long timeout;
|
||||
bool signal;
|
||||
|
||||
timeout = jiffies + msecs_to_jiffies(timeout_ms);
|
||||
while (time_is_after_jiffies(timeout)) {
|
||||
signal = serdev_device_get_cts(serdev);
|
||||
if (signal == state)
|
||||
return 0;
|
||||
usleep_range(1000, 2000);
|
||||
}
|
||||
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
static inline int serdev_device_set_rts(struct serdev_device *serdev, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
return serdev_device_set_tiocm(serdev, TIOCM_RTS, 0);
|
||||
else
|
||||
return serdev_device_set_tiocm(serdev, 0, TIOCM_RTS);
|
||||
}
|
||||
|
||||
/*
|
||||
* serdev hooks into TTY core
|
||||
*/
|
||||
|
Reference in New Issue
Block a user