@@ -384,7 +384,8 @@ static void btmtkuart_recv(struct hci_dev *hdev, const u8 *data, size_t count)
}
static size_t btmtkuart_receive_buf(struct serdev_device *serdev,
- const u8 *data, size_t count)
+ const u8 *data, const u8 *flags,
+ size_t count)
{
struct btmtkuart_dev *bdev = serdev_device_get_drvdata(serdev);
@@ -1286,7 +1286,8 @@ static const struct h4_recv_pkt nxp_recv_pkts[] = {
};
static size_t btnxpuart_receive_buf(struct serdev_device *serdev,
- const u8 *data, size_t count)
+ const u8 *data, const u8 *flags,
+ size_t count)
{
struct btnxpuart_dev *nxpdev = serdev_device_get_drvdata(serdev);
@@ -272,7 +272,8 @@ static void hci_uart_write_wakeup(struct serdev_device *serdev)
* Return: number of processed bytes
*/
static size_t hci_uart_receive_buf(struct serdev_device *serdev,
- const u8 *data, size_t count)
+ const u8 *data, const u8 *flags,
+ size_t count)
{
struct hci_uart *hu = serdev_device_get_drvdata(serdev);
@@ -81,7 +81,7 @@ static const struct gnss_operations gnss_serial_gnss_ops = {
};
static size_t gnss_serial_receive_buf(struct serdev_device *serdev,
- const u8 *buf, size_t count)
+ const u8 *buf, const u8 *flags, size_t count)
{
struct gnss_serial *gserial = serdev_device_get_drvdata(serdev);
struct gnss_device *gdev = gserial->gdev;
@@ -161,7 +161,7 @@ static const struct gnss_operations sirf_gnss_ops = {
};
static size_t sirf_receive_buf(struct serdev_device *serdev,
- const u8 *buf, size_t count)
+ const u8 *buf, const u8 *flags, size_t count)
{
struct sirf_data *data = serdev_device_get_drvdata(serdev);
struct gnss_device *gdev = data->gdev;
@@ -332,7 +332,7 @@ static void hdlc_deinit(struct gb_beagleplay *bg)
}
static size_t gb_tty_receive(struct serdev_device *sd, const u8 *data,
- size_t count)
+ const u8 *flags, size_t count)
{
struct gb_beagleplay *bg = serdev_device_get_drvdata(sd);
@@ -212,7 +212,7 @@ static bool pms7003_frame_is_okay(struct pms7003_frame *frame)
}
static size_t pms7003_receive_buf(struct serdev_device *serdev, const u8 *buf,
- size_t size)
+ const u8 *flags, size_t size)
{
struct iio_dev *indio_dev = serdev_device_get_drvdata(serdev);
struct pms7003_state *state = iio_priv(indio_dev);
@@ -175,7 +175,8 @@ static int scd30_serdev_command(struct scd30_state *state, enum scd30_cmd cmd, u
}
static size_t scd30_serdev_receive_buf(struct serdev_device *serdev,
- const u8 *buf, size_t size)
+ const u8 *buf, const u8 *flags,
+ size_t size)
{
struct iio_dev *indio_dev = serdev_device_get_drvdata(serdev);
struct scd30_serdev_priv *priv;
@@ -211,7 +211,8 @@ static int sps30_serial_command(struct sps30_state *state, unsigned char cmd,
}
static size_t sps30_serial_receive_buf(struct serdev_device *serdev,
- const u8 *buf, size_t size)
+ const u8 *buf, const u8 *flags,
+ size_t size)
{
struct iio_dev *indio_dev = dev_get_drvdata(&serdev->dev);
struct sps30_serial_priv *priv;
@@ -379,7 +379,8 @@ static void bno055_ser_handle_rx(struct bno055_ser_priv *priv, int status)
* unless we require to AND we don't queue more than one request per time).
*/
static size_t bno055_ser_receive_buf(struct serdev_device *serdev,
- const u8 *buf, size_t size)
+ const u8 *buf, const u8 *flags,
+ size_t size)
{
int status;
struct bno055_ser_priv *priv = serdev_device_get_drvdata(serdev);
@@ -472,7 +472,7 @@ static void rave_sp_receive_frame(struct rave_sp *sp,
}
static size_t rave_sp_receive_buf(struct serdev_device *serdev,
- const u8 *buf, size_t size)
+ const u8 *buf, const u8 *flags, size_t size)
{
struct device *dev = &serdev->dev;
struct rave_sp *sp = dev_get_drvdata(dev);
@@ -46,7 +46,8 @@ struct qcauart {
};
static size_t
-qca_tty_receive(struct serdev_device *serdev, const u8 *data, size_t count)
+qca_tty_receive(struct serdev_device *serdev, const u8 *data, const u8 *flags,
+ size_t count)
{
struct qcauart *qca = serdev_device_get_drvdata(serdev);
struct net_device *netdev = qca->net_dev;
@@ -204,7 +204,7 @@ static int pn532_uart_rx_is_frame(struct sk_buff *skb)
}
static size_t pn532_receive_buf(struct serdev_device *serdev,
- const u8 *data, size_t count)
+ const u8 *data, const u8 *flags, size_t count)
{
struct pn532_uart_phy *dev = serdev_device_get_drvdata(serdev);
size_t i;
@@ -52,7 +52,8 @@ static const struct s3fwrn5_phy_ops uart_phy_ops = {
};
static size_t s3fwrn82_uart_read(struct serdev_device *serdev,
- const u8 *data, size_t count)
+ const u8 *data, const u8 *flags,
+ size_t count)
{
struct s3fwrn82_uart_phy *phy = serdev_device_get_drvdata(serdev);
size_t i;
@@ -82,7 +82,8 @@ struct cros_ec_uart {
};
static size_t cros_ec_uart_rx_bytes(struct serdev_device *serdev,
- const u8 *data, size_t count)
+ const u8 *data, const u8 *flags,
+ size_t count)
{
struct ec_host_response *host_response;
struct cros_ec_device *ec_dev = serdev_device_get_drvdata(serdev);
@@ -228,7 +228,7 @@ EXPORT_SYMBOL_GPL(ssam_client_bind);
/* -- Glue layer (serdev_device -> ssam_controller). ------------------------ */
static size_t ssam_receive_buf(struct serdev_device *dev, const u8 *buf,
- size_t n)
+ const u8 *flags, size_t n)
{
struct ssam_controller *ctrl;
int ret;
@@ -133,7 +133,8 @@ static int yt2_1380_fc_extcon_evt(struct notifier_block *nb,
return NOTIFY_OK;
}
-static size_t yt2_1380_fc_receive(struct serdev_device *serdev, const u8 *data, size_t len)
+static size_t yt2_1380_fc_receive(struct serdev_device *serdev, const u8 *data,
+ const u8 *flags, size_t len)
{
/*
* Since the USB data lines are shorted for DCP detection, echos of
@@ -32,7 +32,7 @@ static size_t ttyport_receive_buf(struct tty_port *port, const u8 *cp,
if (!test_bit(SERPORT_ACTIVE, &serport->flags))
return 0;
- ret = serdev_controller_receive_buf(ctrl, cp, count);
+ ret = serdev_controller_receive_buf(ctrl, cp, fp, count);
dev_WARN_ONCE(&ctrl->dev, ret > count,
"receive_buf returns %zu (count = %zu)\n",
@@ -290,7 +290,8 @@ static int w1_uart_serdev_tx_rx(struct w1_uart_device *w1dev,
}
static size_t w1_uart_serdev_receive_buf(struct serdev_device *serdev,
- const u8 *buf, size_t count)
+ const u8 *buf, const u8 *flags,
+ size_t count)
{
struct w1_uart_device *w1dev = serdev_device_get_drvdata(serdev);
@@ -21,13 +21,16 @@ struct serdev_device;
/**
* struct serdev_device_ops - Callback operations for a serdev device
- * @receive_buf: Function called with data received from device;
+ * @receive_buf: Function called with data received from device (char
+ * buffer), flags buffer (%TTY_NORMAL, %TTY_BREAK, etc)
+ * and number of bytes;
* returns number of bytes accepted; may sleep.
* @write_wakeup: Function called when ready to transmit more data; must
* not sleep.
*/
struct serdev_device_ops {
- size_t (*receive_buf)(struct serdev_device *, const u8 *, size_t);
+ size_t (*receive_buf)(struct serdev_device *, const u8 *, const u8 *,
+ size_t);
void (*write_wakeup)(struct serdev_device *);
};
@@ -187,6 +190,7 @@ static inline void serdev_controller_write_wakeup(struct serdev_controller *ctrl
static inline size_t serdev_controller_receive_buf(struct serdev_controller *ctrl,
const u8 *data,
+ const u8 *flags,
size_t count)
{
struct serdev_device *serdev = ctrl->serdev;
@@ -194,7 +198,7 @@ static inline size_t serdev_controller_receive_buf(struct serdev_controller *ctr
if (!serdev || !serdev->ops->receive_buf)
return 0;
- return serdev->ops->receive_buf(serdev, data, count);
+ return serdev->ops->receive_buf(serdev, data, flags, count);
}
#if IS_ENABLED(CONFIG_SERIAL_DEV_BUS)
@@ -101,7 +101,8 @@ static void snd_serial_generic_write_wakeup(struct serdev_device *serdev)
}
static size_t snd_serial_generic_receive_buf(struct serdev_device *serdev,
- const u8 *buf, size_t count)
+ const u8 *buf, const u8 *flags,
+ size_t count)
{
int ret;
struct snd_serial_generic *drvdata = serdev_device_get_drvdata(serdev);
For serdev device drivers to be able to detect TTY_BREAK and other flags in the buffer, pass the flag buffer pointer down to serdev its receive function and update all drivers using it. The changes were mostly done using the following Coccinelle semantic patch: // <smpl> @ rule1 @ identifier fn; identifier opsname; @@ struct serdev_device_ops opsname = { .receive_buf = fn, }; @@ identifier rule1.fn; parameter E1, E2, E3; typedef u8; @@ fn(E1, E2, + const u8 *flags, E3) { ... } // </smpl> Signed-off-by: Christoph Fritz <christoph.fritz@hexdev.de> --- drivers/bluetooth/btmtkuart.c | 3 ++- drivers/bluetooth/btnxpuart.c | 3 ++- drivers/bluetooth/hci_serdev.c | 3 ++- drivers/gnss/serial.c | 2 +- drivers/gnss/sirf.c | 2 +- drivers/greybus/gb-beagleplay.c | 2 +- drivers/iio/chemical/pms7003.c | 2 +- drivers/iio/chemical/scd30_serial.c | 3 ++- drivers/iio/chemical/sps30_serial.c | 3 ++- drivers/iio/imu/bno055/bno055_ser_core.c | 3 ++- drivers/mfd/rave-sp.c | 2 +- drivers/net/ethernet/qualcomm/qca_uart.c | 3 ++- drivers/nfc/pn533/uart.c | 2 +- drivers/nfc/s3fwrn5/uart.c | 3 ++- drivers/platform/chrome/cros_ec_uart.c | 3 ++- drivers/platform/surface/aggregator/core.c | 2 +- .../x86/lenovo-yoga-tab2-pro-1380-fastcharger.c | 3 ++- drivers/tty/serdev/serdev-ttyport.c | 2 +- drivers/w1/masters/w1-uart.c | 3 ++- include/linux/serdev.h | 10 +++++++--- sound/drivers/serial-generic.c | 3 ++- 21 files changed, 39 insertions(+), 23 deletions(-)