tty: serdev: convert to u8 and size_t
authorJiri Slaby (SUSE) <jirislaby@kernel.org>
Wed, 6 Dec 2023 07:37:08 +0000 (08:37 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Dec 2023 11:02:38 +0000 (12:02 +0100)
Switch character types to u8 and sizes to size_t. To conform to
characters/sizes in the rest of the tty layer.

This patch converts struct serdev_device_ops hooks and its
instantiations.

Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Cc: Rob Herring <robh@kernel.org>
Acked-by: Johan Hovold <johan@kernel.org>
Link: https://lore.kernel.org/r/20231206073712.17776-24-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22 files changed:
drivers/bluetooth/btmtkuart.c
drivers/bluetooth/btnxpuart.c
drivers/bluetooth/hci_serdev.c
drivers/gnss/serial.c
drivers/gnss/sirf.c
drivers/greybus/gb-beagleplay.c
drivers/iio/chemical/pms7003.c
drivers/iio/chemical/scd30_serial.c
drivers/iio/chemical/sps30_serial.c
drivers/iio/imu/bno055/bno055_ser_core.c
drivers/mfd/rave-sp.c
drivers/net/ethernet/qualcomm/qca_uart.c
drivers/nfc/pn533/uart.c
drivers/nfc/s3fwrn5/uart.c
drivers/platform/chrome/cros_ec_uart.c
drivers/platform/surface/aggregator/controller.h
drivers/platform/surface/aggregator/core.c
drivers/platform/surface/aggregator/ssh_packet_layer.c
drivers/platform/surface/aggregator/ssh_packet_layer.h
drivers/tty/serdev/core.c
include/linux/serdev.h
sound/drivers/serial-generic.c

index 935feab815d97317d32b898626f8118d2293f605..d4f4e40ac5d2b351ca22a4fcefc792970900c3a1 100644 (file)
@@ -385,8 +385,8 @@ static int btmtkuart_recv(struct hci_dev *hdev, const u8 *data, size_t count)
        return 0;
 }
 
-static int btmtkuart_receive_buf(struct serdev_device *serdev, const u8 *data,
-                                size_t count)
+static ssize_t btmtkuart_receive_buf(struct serdev_device *serdev,
+                                    const u8 *data, size_t count)
 {
        struct btmtkuart_dev *bdev = serdev_device_get_drvdata(serdev);
        int err;
index b7e66b7ac570227da5d9222948e06e191e50133b..d75487a90bbacc7dd5d376932c74b259bbc2d497 100644 (file)
@@ -1264,8 +1264,8 @@ static const struct h4_recv_pkt nxp_recv_pkts[] = {
        { NXP_RECV_FW_REQ_V3,   .recv = nxp_recv_fw_req_v3 },
 };
 
-static int btnxpuart_receive_buf(struct serdev_device *serdev, const u8 *data,
-                                size_t count)
+static ssize_t btnxpuart_receive_buf(struct serdev_device *serdev,
+                                    const u8 *data, size_t count)
 {
        struct btnxpuart_dev *nxpdev = serdev_device_get_drvdata(serdev);
 
index f16fd79bc02b8ab6c8e984faf6bf4c5bdb42bd8f..39c8b567da3c0e82d7ec3707db6fb909ea05f8ff 100644 (file)
@@ -271,8 +271,8 @@ static void hci_uart_write_wakeup(struct serdev_device *serdev)
  *
  * Return: number of processed bytes
  */
-static int hci_uart_receive_buf(struct serdev_device *serdev, const u8 *data,
-                                  size_t count)
+static ssize_t hci_uart_receive_buf(struct serdev_device *serdev,
+                                   const u8 *data, size_t count)
 {
        struct hci_uart *hu = serdev_device_get_drvdata(serdev);
 
index 5d8e9bfb24d020a59573b319f3b89d1a564f7181..baa956494e79f0aa3651d5c0ab2e550f2337aff3 100644 (file)
@@ -80,8 +80,8 @@ static const struct gnss_operations gnss_serial_gnss_ops = {
        .write_raw      = gnss_serial_write_raw,
 };
 
-static int gnss_serial_receive_buf(struct serdev_device *serdev,
-                                       const unsigned char *buf, size_t count)
+static ssize_t gnss_serial_receive_buf(struct serdev_device *serdev,
+                                      const u8 *buf, size_t count)
 {
        struct gnss_serial *gserial = serdev_device_get_drvdata(serdev);
        struct gnss_device *gdev = gserial->gdev;
index bcb53ccfee4d553ba87caa26e4766f65b6b8ec4a..6801a8fb20401a484aba805be4fe1c0f0ca8e940 100644 (file)
@@ -160,8 +160,8 @@ static const struct gnss_operations sirf_gnss_ops = {
        .write_raw      = sirf_write_raw,
 };
 
-static int sirf_receive_buf(struct serdev_device *serdev,
-                               const unsigned char *buf, size_t count)
+static ssize_t sirf_receive_buf(struct serdev_device *serdev,
+                               const u8 *buf, size_t count)
 {
        struct sirf_data *data = serdev_device_get_drvdata(serdev);
        struct gnss_device *gdev = data->gdev;
index 43318c1993ba9f567367660cd1e715e3a65798a1..2da37ff92cf1cdbb271f49f3cb2196b74f01009c 100644 (file)
@@ -257,7 +257,7 @@ static void hdlc_rx_frame(struct gb_beagleplay *bg)
        }
 }
 
-static int hdlc_rx(struct gb_beagleplay *bg, const u8 *data, size_t count)
+static ssize_t hdlc_rx(struct gb_beagleplay *bg, const u8 *data, size_t count)
 {
        size_t i;
        u8 c;
@@ -317,7 +317,8 @@ static void hdlc_deinit(struct gb_beagleplay *bg)
        flush_work(&bg->tx_work);
 }
 
-static int gb_tty_receive(struct serdev_device *sd, const unsigned char *data, size_t count)
+static ssize_t gb_tty_receive(struct serdev_device *sd, const u8 *data,
+                             size_t count)
 {
        struct gb_beagleplay *bg = serdev_device_get_drvdata(sd);
 
index e9857d93b307e4a3989177b09d554a4894e3db70..b5cf15a515d251a3cb4d862cf7a11ba82596baa8 100644 (file)
@@ -211,13 +211,13 @@ static bool pms7003_frame_is_okay(struct pms7003_frame *frame)
        return checksum == pms7003_calc_checksum(frame);
 }
 
-static int pms7003_receive_buf(struct serdev_device *serdev,
-                              const unsigned char *buf, size_t size)
+static ssize_t pms7003_receive_buf(struct serdev_device *serdev, const u8 *buf,
+                                  size_t size)
 {
        struct iio_dev *indio_dev = serdev_device_get_drvdata(serdev);
        struct pms7003_state *state = iio_priv(indio_dev);
        struct pms7003_frame *frame = &state->frame;
-       int num;
+       size_t num;
 
        if (!frame->expected_length) {
                u16 magic;
index 3c519103d30b54fc664b2751ceb0b90754bc374f..a47654591e555fcf107e5c23180438b99921a15d 100644 (file)
@@ -174,13 +174,13 @@ static int scd30_serdev_command(struct scd30_state *state, enum scd30_cmd cmd, u
        return 0;
 }
 
-static int scd30_serdev_receive_buf(struct serdev_device *serdev,
-                                   const unsigned char *buf, size_t size)
+static ssize_t scd30_serdev_receive_buf(struct serdev_device *serdev,
+                                       const u8 *buf, size_t size)
 {
        struct iio_dev *indio_dev = serdev_device_get_drvdata(serdev);
        struct scd30_serdev_priv *priv;
        struct scd30_state *state;
-       int num;
+       size_t num;
 
        if (!indio_dev)
                return 0;
index 164f4b3e025c94f831cabface303bee6c1848e59..3afa89f8acc329c73cf39f22cec98251a32d6120 100644 (file)
@@ -74,8 +74,8 @@ static int sps30_serial_xfer(struct sps30_state *state, const unsigned char *buf
 }
 
 static const struct {
-       unsigned char byte;
-       unsigned char byte2;
+       u8 byte;
+       u8 byte2;
 } sps30_serial_bytes[] = {
        { 0x11, 0x31 },
        { 0x13, 0x33 },
@@ -83,7 +83,7 @@ static const struct {
        { 0x7d, 0x5d },
 };
 
-static int sps30_serial_put_byte(unsigned char *buf, unsigned char byte)
+static int sps30_serial_put_byte(u8 *buf, u8 byte)
 {
        int i;
 
@@ -102,7 +102,7 @@ static int sps30_serial_put_byte(unsigned char *buf, unsigned char byte)
        return 1;
 }
 
-static char sps30_serial_get_byte(bool escaped, unsigned char byte2)
+static u8 sps30_serial_get_byte(bool escaped, u8 byte2)
 {
        int i;
 
@@ -130,8 +130,8 @@ static unsigned char sps30_serial_calc_chksum(const unsigned char *buf, size_t n
        return ~chksum;
 }
 
-static int sps30_serial_prep_frame(unsigned char *buf, unsigned char cmd,
-                                  const unsigned char *arg, size_t arg_size)
+static int sps30_serial_prep_frame(u8 *buf, u8 cmd, const u8 *arg,
+                                  size_t arg_size)
 {
        unsigned char chksum;
        int num = 0;
@@ -210,14 +210,14 @@ static int sps30_serial_command(struct sps30_state *state, unsigned char cmd,
        return rsp_size;
 }
 
-static int sps30_serial_receive_buf(struct serdev_device *serdev,
-                                   const unsigned char *buf, size_t size)
+static ssize_t sps30_serial_receive_buf(struct serdev_device *serdev,
+                                       const u8 *buf, size_t size)
 {
        struct iio_dev *indio_dev = dev_get_drvdata(&serdev->dev);
        struct sps30_serial_priv *priv;
        struct sps30_state *state;
-       unsigned char byte;
        size_t i;
+       u8 byte;
 
        if (!indio_dev)
                return 0;
index 57728a568471560a18dc94d6c06eb05359a6cd39..5677bdf4f846ebd0405fbba43d1b9ad108033a3a 100644 (file)
@@ -378,12 +378,12 @@ static void bno055_ser_handle_rx(struct bno055_ser_priv *priv, int status)
  * Also, we assume to RX one pkt per time (i.e. the HW doesn't send anything
  * unless we require to AND we don't queue more than one request per time).
  */
-static int bno055_ser_receive_buf(struct serdev_device *serdev,
-                                 const unsigned char *buf, size_t size)
+static ssize_t bno055_ser_receive_buf(struct serdev_device *serdev,
+                                     const u8 *buf, size_t size)
 {
        int status;
        struct bno055_ser_priv *priv = serdev_device_get_drvdata(serdev);
-       int remaining = size;
+       size_t remaining = size;
 
        if (size == 0)
                return 0;
index da50eba1001494e07e36640b7bf311dc2d6362e2..b1229bb143ee7bc4db35e0e144fde97135160818 100644 (file)
@@ -471,17 +471,17 @@ static void rave_sp_receive_frame(struct rave_sp *sp,
                rave_sp_receive_reply(sp, data, length);
 }
 
-static int rave_sp_receive_buf(struct serdev_device *serdev,
-                              const unsigned char *buf, size_t size)
+static ssize_t rave_sp_receive_buf(struct serdev_device *serdev,
+                                  const u8 *buf, size_t size)
 {
        struct device *dev = &serdev->dev;
        struct rave_sp *sp = dev_get_drvdata(dev);
        struct rave_sp_deframer *deframer = &sp->deframer;
-       const unsigned char *src = buf;
-       const unsigned char *end = buf + size;
+       const u8 *src = buf;
+       const u8 *end = buf + size;
 
        while (src < end) {
-               const unsigned char byte = *src++;
+               const u8 byte = *src++;
 
                switch (deframer->state) {
                case RAVE_SP_EXPECT_SOF:
index 9adec91f35e947c97efc6d34bf7f4aa0aef92e5d..223321897b9613e1d112c888f6adaf5c46a625b1 100644 (file)
@@ -58,9 +58,8 @@ struct qcauart {
        unsigned char *tx_buffer;
 };
 
-static int
-qca_tty_receive(struct serdev_device *serdev, const unsigned char *data,
-               size_t count)
+static ssize_t
+qca_tty_receive(struct serdev_device *serdev, const u8 *data, size_t count)
 {
        struct qcauart *qca = serdev_device_get_drvdata(serdev);
        struct net_device *netdev = qca->net_dev;
index a556acdb947bbe200a66e234a6d75de833ae18f4..2eb5978bd79e1b5114bb34bab409fbeaae00faf8 100644 (file)
@@ -203,8 +203,8 @@ static int pn532_uart_rx_is_frame(struct sk_buff *skb)
        return 0;
 }
 
-static int pn532_receive_buf(struct serdev_device *serdev,
-               const unsigned char *data, size_t count)
+static ssize_t pn532_receive_buf(struct serdev_device *serdev,
+                                const u8 *data, size_t count)
 {
        struct pn532_uart_phy *dev = serdev_device_get_drvdata(serdev);
        size_t i;
index 82ea35d748a5de5ff39bb3328e16c38cdbd78837..456d3947116c1c4029fa2477bdf1c12f508927aa 100644 (file)
@@ -51,9 +51,8 @@ static const struct s3fwrn5_phy_ops uart_phy_ops = {
        .write = s3fwrn82_uart_write,
 };
 
-static int s3fwrn82_uart_read(struct serdev_device *serdev,
-                             const unsigned char *data,
-                             size_t count)
+static ssize_t s3fwrn82_uart_read(struct serdev_device *serdev,
+                                 const u8 *data, size_t count)
 {
        struct s3fwrn82_uart_phy *phy = serdev_device_get_drvdata(serdev);
        size_t i;
index 788246559bbba2556d6d980c670bc5edeaf03b30..68d80559fddc25b076648aa6c69f99951c15f262 100644 (file)
@@ -81,9 +81,8 @@ struct cros_ec_uart {
        struct response_info response;
 };
 
-static int cros_ec_uart_rx_bytes(struct serdev_device *serdev,
-                                const u8 *data,
-                                size_t count)
+static ssize_t cros_ec_uart_rx_bytes(struct serdev_device *serdev,
+                                    const u8 *data, size_t count)
 {
        struct ec_host_response *host_response;
        struct cros_ec_device *ec_dev = serdev_device_get_drvdata(serdev);
index f0d987abc51e3cdcacfdbecb5fb284a8682fbd06..f1638c2081e8bbb19826d9a75df3995d93a02e39 100644 (file)
@@ -238,8 +238,8 @@ struct ssam_controller {
  * layer of the controller has been shut down, %-ESHUTDOWN.
  */
 static inline
-int ssam_controller_receive_buf(struct ssam_controller *ctrl,
-                               const unsigned char *buf, size_t n)
+ssize_t ssam_controller_receive_buf(struct ssam_controller *ctrl, const u8 *buf,
+                                   size_t n)
 {
        return ssh_ptl_rx_rcvbuf(&ctrl->rtl.ptl, buf, n);
 }
index 1a6373dea109cc2b63ad887bb0adb08cadd4a7e5..72d7314a4efd7bbfbae6413c8b9b62f63ba19380 100644 (file)
@@ -227,8 +227,8 @@ EXPORT_SYMBOL_GPL(ssam_client_bind);
 
 /* -- Glue layer (serdev_device -> ssam_controller). ------------------------ */
 
-static int ssam_receive_buf(struct serdev_device *dev, const unsigned char *buf,
-                           size_t n)
+static ssize_t ssam_receive_buf(struct serdev_device *dev, const u8 *buf,
+                               size_t n)
 {
        struct ssam_controller *ctrl;
 
index def8d7ac541f790f88dfe373ce1c758fb2f3fbe4..d726b1a8631999f74f6ad621ec410ae7060ba258 100644 (file)
@@ -1887,9 +1887,9 @@ int ssh_ptl_rx_stop(struct ssh_ptl *ptl)
  * Return: Returns the number of bytes transferred (positive or zero) on
  * success. Returns %-ESHUTDOWN if the packet layer has been shut down.
  */
-int ssh_ptl_rx_rcvbuf(struct ssh_ptl *ptl, const u8 *buf, size_t n)
+ssize_t ssh_ptl_rx_rcvbuf(struct ssh_ptl *ptl, const u8 *buf, size_t n)
 {
-       int used;
+       size_t used;
 
        if (test_bit(SSH_PTL_SF_SHUTDOWN_BIT, &ptl->state))
                return -ESHUTDOWN;
index 64633522f9716ea60e4ca9f35fa2ae2485c23574..c80e822070dfdd0e675b8fc420846dde0e1e6806 100644 (file)
@@ -162,7 +162,7 @@ void ssh_ptl_shutdown(struct ssh_ptl *ptl);
 int ssh_ptl_submit(struct ssh_ptl *ptl, struct ssh_packet *p);
 void ssh_ptl_cancel(struct ssh_packet *p);
 
-int ssh_ptl_rx_rcvbuf(struct ssh_ptl *ptl, const u8 *buf, size_t n);
+ssize_t ssh_ptl_rx_rcvbuf(struct ssh_ptl *ptl, const u8 *buf, size_t n);
 
 /**
  * ssh_ptl_tx_wakeup_transfer() - Wake up packet transmitter thread for
index 3090e3454c447c9da2011ff270e5ce1fbe6738cb..de8d87d4858d4891d41334157c53e50c064143a4 100644 (file)
@@ -225,8 +225,7 @@ EXPORT_SYMBOL_GPL(serdev_device_write_wakeup);
  * Return: The number of bytes written (less than count if not enough room in
  * the write buffer), or a negative errno on errors.
  */
-int serdev_device_write_buf(struct serdev_device *serdev,
-                           const unsigned char *buf, size_t count)
+int serdev_device_write_buf(struct serdev_device *serdev, const u8 *buf, size_t count)
 {
        struct serdev_controller *ctrl = serdev->ctrl;
 
@@ -259,13 +258,12 @@ EXPORT_SYMBOL_GPL(serdev_device_write_buf);
  * -ETIMEDOUT or -ERESTARTSYS if interrupted before any bytes were written, or
  * a negative errno on errors.
  */
-int serdev_device_write(struct serdev_device *serdev,
-                       const unsigned char *buf, size_t count,
-                       long timeout)
+ssize_t serdev_device_write(struct serdev_device *serdev, const u8 *buf,
+                           size_t count, long timeout)
 {
        struct serdev_controller *ctrl = serdev->ctrl;
-       int written = 0;
-       int ret;
+       size_t written = 0;
+       ssize_t ret;
 
        if (!ctrl || !ctrl->ops->write_buf || !serdev->ops->write_wakeup)
                return -EINVAL;
index 8cdab2c3b6d58affb0cbdde896a7656cc3f30f7c..3fab88ba265ee1d44ce48d9efe0ddc31d5c8e934 100644 (file)
@@ -27,7 +27,7 @@ struct serdev_device;
  *                     not sleep.
  */
 struct serdev_device_ops {
-       int (*receive_buf)(struct serdev_device *, const unsigned char *, size_t);
+       ssize_t (*receive_buf)(struct serdev_device *, const u8 *, size_t);
        void (*write_wakeup)(struct serdev_device *);
 };
 
@@ -204,13 +204,13 @@ void serdev_device_close(struct serdev_device *);
 int devm_serdev_device_open(struct device *, struct serdev_device *);
 unsigned int serdev_device_set_baudrate(struct serdev_device *, unsigned int);
 void serdev_device_set_flow_control(struct serdev_device *, bool);
-int serdev_device_write_buf(struct serdev_device *, const unsigned char *, size_t);
+int serdev_device_write_buf(struct serdev_device *, const u8 *, size_t);
 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_break_ctl(struct serdev_device *serdev, int break_state);
 void serdev_device_write_wakeup(struct serdev_device *);
-int serdev_device_write(struct serdev_device *, const unsigned char *, size_t, long);
+ssize_t serdev_device_write(struct serdev_device *, const u8 *, size_t, long);
 void serdev_device_write_flush(struct serdev_device *);
 int serdev_device_write_room(struct serdev_device *);
 
@@ -248,7 +248,7 @@ static inline unsigned int serdev_device_set_baudrate(struct serdev_device *sdev
 }
 static inline void serdev_device_set_flow_control(struct serdev_device *sdev, bool enable) {}
 static inline int serdev_device_write_buf(struct serdev_device *serdev,
-                                         const unsigned char *buf,
+                                         const u8 *buf,
                                          size_t count)
 {
        return -ENODEV;
@@ -266,8 +266,9 @@ static inline int serdev_device_break_ctl(struct serdev_device *serdev, int brea
 {
        return -EOPNOTSUPP;
 }
-static inline int serdev_device_write(struct serdev_device *sdev, const unsigned char *buf,
-                                     size_t count, unsigned long timeout)
+static inline ssize_t serdev_device_write(struct serdev_device *sdev,
+                                         const u8 *buf, size_t count,
+                                         unsigned long timeout)
 {
        return -ENODEV;
 }
index c8db6c75d133d152cdd29c02e7ae7a77ffe519b2..d6e5aafd697c7e4e06ae8692e935de4bc206c192 100644 (file)
@@ -100,8 +100,8 @@ static void snd_serial_generic_write_wakeup(struct serdev_device *serdev)
        snd_serial_generic_tx_wakeup(drvdata);
 }
 
-static int snd_serial_generic_receive_buf(struct serdev_device *serdev,
-                               const unsigned char *buf, size_t count)
+static ssize_t snd_serial_generic_receive_buf(struct serdev_device *serdev,
+                                             const u8 *buf, size_t count)
 {
        int ret;
        struct snd_serial_generic *drvdata = serdev_device_get_drvdata(serdev);