Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tty: serdev: convert to u8 and size_t

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>

authored by

Jiri Slaby (SUSE) and committed by
Greg Kroah-Hartman
475fc6e2 f2470d2b

+65 -68
+2 -2
drivers/bluetooth/btmtkuart.c
··· 385 385 return 0; 386 386 } 387 387 388 - static int btmtkuart_receive_buf(struct serdev_device *serdev, const u8 *data, 389 - size_t count) 388 + static ssize_t btmtkuart_receive_buf(struct serdev_device *serdev, 389 + const u8 *data, size_t count) 390 390 { 391 391 struct btmtkuart_dev *bdev = serdev_device_get_drvdata(serdev); 392 392 int err;
+2 -2
drivers/bluetooth/btnxpuart.c
··· 1264 1264 { NXP_RECV_FW_REQ_V3, .recv = nxp_recv_fw_req_v3 }, 1265 1265 }; 1266 1266 1267 - static int btnxpuart_receive_buf(struct serdev_device *serdev, const u8 *data, 1268 - size_t count) 1267 + static ssize_t btnxpuart_receive_buf(struct serdev_device *serdev, 1268 + const u8 *data, size_t count) 1269 1269 { 1270 1270 struct btnxpuart_dev *nxpdev = serdev_device_get_drvdata(serdev); 1271 1271
+2 -2
drivers/bluetooth/hci_serdev.c
··· 271 271 * 272 272 * Return: number of processed bytes 273 273 */ 274 - static int hci_uart_receive_buf(struct serdev_device *serdev, const u8 *data, 275 - size_t count) 274 + static ssize_t hci_uart_receive_buf(struct serdev_device *serdev, 275 + const u8 *data, size_t count) 276 276 { 277 277 struct hci_uart *hu = serdev_device_get_drvdata(serdev); 278 278
+2 -2
drivers/gnss/serial.c
··· 80 80 .write_raw = gnss_serial_write_raw, 81 81 }; 82 82 83 - static int gnss_serial_receive_buf(struct serdev_device *serdev, 84 - const unsigned char *buf, size_t count) 83 + static ssize_t gnss_serial_receive_buf(struct serdev_device *serdev, 84 + const u8 *buf, size_t count) 85 85 { 86 86 struct gnss_serial *gserial = serdev_device_get_drvdata(serdev); 87 87 struct gnss_device *gdev = gserial->gdev;
+2 -2
drivers/gnss/sirf.c
··· 160 160 .write_raw = sirf_write_raw, 161 161 }; 162 162 163 - static int sirf_receive_buf(struct serdev_device *serdev, 164 - const unsigned char *buf, size_t count) 163 + static ssize_t sirf_receive_buf(struct serdev_device *serdev, 164 + const u8 *buf, size_t count) 165 165 { 166 166 struct sirf_data *data = serdev_device_get_drvdata(serdev); 167 167 struct gnss_device *gdev = data->gdev;
+3 -2
drivers/greybus/gb-beagleplay.c
··· 257 257 } 258 258 } 259 259 260 - static int hdlc_rx(struct gb_beagleplay *bg, const u8 *data, size_t count) 260 + static ssize_t hdlc_rx(struct gb_beagleplay *bg, const u8 *data, size_t count) 261 261 { 262 262 size_t i; 263 263 u8 c; ··· 317 317 flush_work(&bg->tx_work); 318 318 } 319 319 320 - static int gb_tty_receive(struct serdev_device *sd, const unsigned char *data, size_t count) 320 + static ssize_t gb_tty_receive(struct serdev_device *sd, const u8 *data, 321 + size_t count) 321 322 { 322 323 struct gb_beagleplay *bg = serdev_device_get_drvdata(sd); 323 324
+3 -3
drivers/iio/chemical/pms7003.c
··· 211 211 return checksum == pms7003_calc_checksum(frame); 212 212 } 213 213 214 - static int pms7003_receive_buf(struct serdev_device *serdev, 215 - const unsigned char *buf, size_t size) 214 + static ssize_t pms7003_receive_buf(struct serdev_device *serdev, const u8 *buf, 215 + size_t size) 216 216 { 217 217 struct iio_dev *indio_dev = serdev_device_get_drvdata(serdev); 218 218 struct pms7003_state *state = iio_priv(indio_dev); 219 219 struct pms7003_frame *frame = &state->frame; 220 - int num; 220 + size_t num; 221 221 222 222 if (!frame->expected_length) { 223 223 u16 magic;
+3 -3
drivers/iio/chemical/scd30_serial.c
··· 174 174 return 0; 175 175 } 176 176 177 - static int scd30_serdev_receive_buf(struct serdev_device *serdev, 178 - const unsigned char *buf, size_t size) 177 + static ssize_t scd30_serdev_receive_buf(struct serdev_device *serdev, 178 + const u8 *buf, size_t size) 179 179 { 180 180 struct iio_dev *indio_dev = serdev_device_get_drvdata(serdev); 181 181 struct scd30_serdev_priv *priv; 182 182 struct scd30_state *state; 183 - int num; 183 + size_t num; 184 184 185 185 if (!indio_dev) 186 186 return 0;
+9 -9
drivers/iio/chemical/sps30_serial.c
··· 74 74 } 75 75 76 76 static const struct { 77 - unsigned char byte; 78 - unsigned char byte2; 77 + u8 byte; 78 + u8 byte2; 79 79 } sps30_serial_bytes[] = { 80 80 { 0x11, 0x31 }, 81 81 { 0x13, 0x33 }, ··· 83 83 { 0x7d, 0x5d }, 84 84 }; 85 85 86 - static int sps30_serial_put_byte(unsigned char *buf, unsigned char byte) 86 + static int sps30_serial_put_byte(u8 *buf, u8 byte) 87 87 { 88 88 int i; 89 89 ··· 102 102 return 1; 103 103 } 104 104 105 - static char sps30_serial_get_byte(bool escaped, unsigned char byte2) 105 + static u8 sps30_serial_get_byte(bool escaped, u8 byte2) 106 106 { 107 107 int i; 108 108 ··· 130 130 return ~chksum; 131 131 } 132 132 133 - static int sps30_serial_prep_frame(unsigned char *buf, unsigned char cmd, 134 - const unsigned char *arg, size_t arg_size) 133 + static int sps30_serial_prep_frame(u8 *buf, u8 cmd, const u8 *arg, 134 + size_t arg_size) 135 135 { 136 136 unsigned char chksum; 137 137 int num = 0; ··· 210 210 return rsp_size; 211 211 } 212 212 213 - static int sps30_serial_receive_buf(struct serdev_device *serdev, 214 - const unsigned char *buf, size_t size) 213 + static ssize_t sps30_serial_receive_buf(struct serdev_device *serdev, 214 + const u8 *buf, size_t size) 215 215 { 216 216 struct iio_dev *indio_dev = dev_get_drvdata(&serdev->dev); 217 217 struct sps30_serial_priv *priv; 218 218 struct sps30_state *state; 219 - unsigned char byte; 220 219 size_t i; 220 + u8 byte; 221 221 222 222 if (!indio_dev) 223 223 return 0;
+3 -3
drivers/iio/imu/bno055/bno055_ser_core.c
··· 378 378 * Also, we assume to RX one pkt per time (i.e. the HW doesn't send anything 379 379 * unless we require to AND we don't queue more than one request per time). 380 380 */ 381 - static int bno055_ser_receive_buf(struct serdev_device *serdev, 382 - const unsigned char *buf, size_t size) 381 + static ssize_t bno055_ser_receive_buf(struct serdev_device *serdev, 382 + const u8 *buf, size_t size) 383 383 { 384 384 int status; 385 385 struct bno055_ser_priv *priv = serdev_device_get_drvdata(serdev); 386 - int remaining = size; 386 + size_t remaining = size; 387 387 388 388 if (size == 0) 389 389 return 0;
+5 -5
drivers/mfd/rave-sp.c
··· 471 471 rave_sp_receive_reply(sp, data, length); 472 472 } 473 473 474 - static int rave_sp_receive_buf(struct serdev_device *serdev, 475 - const unsigned char *buf, size_t size) 474 + static ssize_t rave_sp_receive_buf(struct serdev_device *serdev, 475 + const u8 *buf, size_t size) 476 476 { 477 477 struct device *dev = &serdev->dev; 478 478 struct rave_sp *sp = dev_get_drvdata(dev); 479 479 struct rave_sp_deframer *deframer = &sp->deframer; 480 - const unsigned char *src = buf; 481 - const unsigned char *end = buf + size; 480 + const u8 *src = buf; 481 + const u8 *end = buf + size; 482 482 483 483 while (src < end) { 484 - const unsigned char byte = *src++; 484 + const u8 byte = *src++; 485 485 486 486 switch (deframer->state) { 487 487 case RAVE_SP_EXPECT_SOF:
+2 -3
drivers/net/ethernet/qualcomm/qca_uart.c
··· 58 58 unsigned char *tx_buffer; 59 59 }; 60 60 61 - static int 62 - qca_tty_receive(struct serdev_device *serdev, const unsigned char *data, 63 - size_t count) 61 + static ssize_t 62 + qca_tty_receive(struct serdev_device *serdev, const u8 *data, size_t count) 64 63 { 65 64 struct qcauart *qca = serdev_device_get_drvdata(serdev); 66 65 struct net_device *netdev = qca->net_dev;
+2 -2
drivers/nfc/pn533/uart.c
··· 203 203 return 0; 204 204 } 205 205 206 - static int pn532_receive_buf(struct serdev_device *serdev, 207 - const unsigned char *data, size_t count) 206 + static ssize_t pn532_receive_buf(struct serdev_device *serdev, 207 + const u8 *data, size_t count) 208 208 { 209 209 struct pn532_uart_phy *dev = serdev_device_get_drvdata(serdev); 210 210 size_t i;
+2 -3
drivers/nfc/s3fwrn5/uart.c
··· 51 51 .write = s3fwrn82_uart_write, 52 52 }; 53 53 54 - static int s3fwrn82_uart_read(struct serdev_device *serdev, 55 - const unsigned char *data, 56 - size_t count) 54 + static ssize_t s3fwrn82_uart_read(struct serdev_device *serdev, 55 + const u8 *data, size_t count) 57 56 { 58 57 struct s3fwrn82_uart_phy *phy = serdev_device_get_drvdata(serdev); 59 58 size_t i;
+2 -3
drivers/platform/chrome/cros_ec_uart.c
··· 81 81 struct response_info response; 82 82 }; 83 83 84 - static int cros_ec_uart_rx_bytes(struct serdev_device *serdev, 85 - const u8 *data, 86 - size_t count) 84 + static ssize_t cros_ec_uart_rx_bytes(struct serdev_device *serdev, 85 + const u8 *data, size_t count) 87 86 { 88 87 struct ec_host_response *host_response; 89 88 struct cros_ec_device *ec_dev = serdev_device_get_drvdata(serdev);
+2 -2
drivers/platform/surface/aggregator/controller.h
··· 238 238 * layer of the controller has been shut down, %-ESHUTDOWN. 239 239 */ 240 240 static inline 241 - int ssam_controller_receive_buf(struct ssam_controller *ctrl, 242 - const unsigned char *buf, size_t n) 241 + ssize_t ssam_controller_receive_buf(struct ssam_controller *ctrl, const u8 *buf, 242 + size_t n) 243 243 { 244 244 return ssh_ptl_rx_rcvbuf(&ctrl->rtl.ptl, buf, n); 245 245 }
+2 -2
drivers/platform/surface/aggregator/core.c
··· 227 227 228 228 /* -- Glue layer (serdev_device -> ssam_controller). ------------------------ */ 229 229 230 - static int ssam_receive_buf(struct serdev_device *dev, const unsigned char *buf, 231 - size_t n) 230 + static ssize_t ssam_receive_buf(struct serdev_device *dev, const u8 *buf, 231 + size_t n) 232 232 { 233 233 struct ssam_controller *ctrl; 234 234
+2 -2
drivers/platform/surface/aggregator/ssh_packet_layer.c
··· 1887 1887 * Return: Returns the number of bytes transferred (positive or zero) on 1888 1888 * success. Returns %-ESHUTDOWN if the packet layer has been shut down. 1889 1889 */ 1890 - int ssh_ptl_rx_rcvbuf(struct ssh_ptl *ptl, const u8 *buf, size_t n) 1890 + ssize_t ssh_ptl_rx_rcvbuf(struct ssh_ptl *ptl, const u8 *buf, size_t n) 1891 1891 { 1892 - int used; 1892 + size_t used; 1893 1893 1894 1894 if (test_bit(SSH_PTL_SF_SHUTDOWN_BIT, &ptl->state)) 1895 1895 return -ESHUTDOWN;
+1 -1
drivers/platform/surface/aggregator/ssh_packet_layer.h
··· 162 162 int ssh_ptl_submit(struct ssh_ptl *ptl, struct ssh_packet *p); 163 163 void ssh_ptl_cancel(struct ssh_packet *p); 164 164 165 - int ssh_ptl_rx_rcvbuf(struct ssh_ptl *ptl, const u8 *buf, size_t n); 165 + ssize_t ssh_ptl_rx_rcvbuf(struct ssh_ptl *ptl, const u8 *buf, size_t n); 166 166 167 167 /** 168 168 * ssh_ptl_tx_wakeup_transfer() - Wake up packet transmitter thread for
+5 -7
drivers/tty/serdev/core.c
··· 225 225 * Return: The number of bytes written (less than count if not enough room in 226 226 * the write buffer), or a negative errno on errors. 227 227 */ 228 - int serdev_device_write_buf(struct serdev_device *serdev, 229 - const unsigned char *buf, size_t count) 228 + int serdev_device_write_buf(struct serdev_device *serdev, const u8 *buf, size_t count) 230 229 { 231 230 struct serdev_controller *ctrl = serdev->ctrl; 232 231 ··· 258 259 * -ETIMEDOUT or -ERESTARTSYS if interrupted before any bytes were written, or 259 260 * a negative errno on errors. 260 261 */ 261 - int serdev_device_write(struct serdev_device *serdev, 262 - const unsigned char *buf, size_t count, 263 - long timeout) 262 + ssize_t serdev_device_write(struct serdev_device *serdev, const u8 *buf, 263 + size_t count, long timeout) 264 264 { 265 265 struct serdev_controller *ctrl = serdev->ctrl; 266 - int written = 0; 267 - int ret; 266 + size_t written = 0; 267 + ssize_t ret; 268 268 269 269 if (!ctrl || !ctrl->ops->write_buf || !serdev->ops->write_wakeup) 270 270 return -EINVAL;
+7 -6
include/linux/serdev.h
··· 27 27 * not sleep. 28 28 */ 29 29 struct serdev_device_ops { 30 - int (*receive_buf)(struct serdev_device *, const unsigned char *, size_t); 30 + ssize_t (*receive_buf)(struct serdev_device *, const u8 *, size_t); 31 31 void (*write_wakeup)(struct serdev_device *); 32 32 }; 33 33 ··· 204 204 int devm_serdev_device_open(struct device *, struct serdev_device *); 205 205 unsigned int serdev_device_set_baudrate(struct serdev_device *, unsigned int); 206 206 void serdev_device_set_flow_control(struct serdev_device *, bool); 207 - int serdev_device_write_buf(struct serdev_device *, const unsigned char *, size_t); 207 + int serdev_device_write_buf(struct serdev_device *, const u8 *, size_t); 208 208 void serdev_device_wait_until_sent(struct serdev_device *, long); 209 209 int serdev_device_get_tiocm(struct serdev_device *); 210 210 int serdev_device_set_tiocm(struct serdev_device *, int, int); 211 211 int serdev_device_break_ctl(struct serdev_device *serdev, int break_state); 212 212 void serdev_device_write_wakeup(struct serdev_device *); 213 - int serdev_device_write(struct serdev_device *, const unsigned char *, size_t, long); 213 + ssize_t serdev_device_write(struct serdev_device *, const u8 *, size_t, long); 214 214 void serdev_device_write_flush(struct serdev_device *); 215 215 int serdev_device_write_room(struct serdev_device *); 216 216 ··· 248 248 } 249 249 static inline void serdev_device_set_flow_control(struct serdev_device *sdev, bool enable) {} 250 250 static inline int serdev_device_write_buf(struct serdev_device *serdev, 251 - const unsigned char *buf, 251 + const u8 *buf, 252 252 size_t count) 253 253 { 254 254 return -ENODEV; ··· 266 266 { 267 267 return -EOPNOTSUPP; 268 268 } 269 - static inline int serdev_device_write(struct serdev_device *sdev, const unsigned char *buf, 270 - size_t count, unsigned long timeout) 269 + static inline ssize_t serdev_device_write(struct serdev_device *sdev, 270 + const u8 *buf, size_t count, 271 + unsigned long timeout) 271 272 { 272 273 return -ENODEV; 273 274 }
+2 -2
sound/drivers/serial-generic.c
··· 100 100 snd_serial_generic_tx_wakeup(drvdata); 101 101 } 102 102 103 - static int snd_serial_generic_receive_buf(struct serdev_device *serdev, 104 - const unsigned char *buf, size_t count) 103 + static ssize_t snd_serial_generic_receive_buf(struct serdev_device *serdev, 104 + const u8 *buf, size_t count) 105 105 { 106 106 int ret; 107 107 struct snd_serial_generic *drvdata = serdev_device_get_drvdata(serdev);