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>
This commit is contained in:
Jiri Slaby (SUSE) 2023-12-06 08:37:08 +01:00 committed by Greg Kroah-Hartman
parent f2470d2bc4
commit 475fc6e2de
22 changed files with 65 additions and 68 deletions

View 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;

View 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);

View 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);

View 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;

View 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;

View 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);

View 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;

View 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;

View 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;

View 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;

View 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:

View 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;

View 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;

View 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;

View 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);

View 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);
}

View 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;

View 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;

View 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

View 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;

View 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;
}

View 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);