mirror of
https://github.com/AsahiLinux/m1n1
synced 2024-11-12 18:37:07 +00:00
iodev: Make iodev_can_read() return the queued byte count
Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
parent
3bdf036161
commit
31bf2b5ac9
6 changed files with 7 additions and 7 deletions
|
@ -30,7 +30,7 @@ char con_buf[CONSOLE_BUFFER_SIZE];
|
||||||
size_t con_wp;
|
size_t con_wp;
|
||||||
size_t con_rp[IODEV_MAX];
|
size_t con_rp[IODEV_MAX];
|
||||||
|
|
||||||
bool iodev_can_read(iodev_id_t id)
|
ssize_t iodev_can_read(iodev_id_t id)
|
||||||
{
|
{
|
||||||
if (!iodevs[id]->ops->can_read)
|
if (!iodevs[id]->ops->can_read)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -22,7 +22,7 @@ typedef enum _iodev_usage_t {
|
||||||
} iodev_usage_t;
|
} iodev_usage_t;
|
||||||
|
|
||||||
struct iodev_ops {
|
struct iodev_ops {
|
||||||
bool (*can_read)(void *opaque);
|
ssize_t (*can_read)(void *opaque);
|
||||||
bool (*can_write)(void *opaque);
|
bool (*can_write)(void *opaque);
|
||||||
ssize_t (*read)(void *opaque, void *buf, size_t length);
|
ssize_t (*read)(void *opaque, void *buf, size_t length);
|
||||||
ssize_t (*write)(void *opaque, const void *buf, size_t length);
|
ssize_t (*write)(void *opaque, const void *buf, size_t length);
|
||||||
|
@ -40,7 +40,7 @@ struct iodev {
|
||||||
|
|
||||||
extern struct iodev *iodevs[IODEV_MAX];
|
extern struct iodev *iodevs[IODEV_MAX];
|
||||||
|
|
||||||
bool iodev_can_read(iodev_id_t id);
|
ssize_t iodev_can_read(iodev_id_t id);
|
||||||
bool iodev_can_write(iodev_id_t id);
|
bool iodev_can_write(iodev_id_t id);
|
||||||
ssize_t iodev_read(iodev_id_t id, void *buf, size_t length);
|
ssize_t iodev_read(iodev_id_t id, void *buf, size_t length);
|
||||||
ssize_t iodev_write(iodev_id_t id, const void *buf, size_t length);
|
ssize_t iodev_write(iodev_id_t id, const void *buf, size_t length);
|
||||||
|
|
|
@ -111,7 +111,7 @@ static bool uart_iodev_can_write(void *opaque)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool uart_iodev_can_read(void *opaque)
|
static ssize_t uart_iodev_can_read(void *opaque)
|
||||||
{
|
{
|
||||||
UNUSED(opaque);
|
UNUSED(opaque);
|
||||||
return read32(UART_BASE + UTRSTAT) & 0x01;
|
return read32(UART_BASE + UTRSTAT) & 0x01;
|
||||||
|
|
|
@ -162,7 +162,7 @@ dwc3_dev_t *usb_iodev_bringup(u32 idx)
|
||||||
}
|
}
|
||||||
|
|
||||||
#define USB_IODEV_WRAPPER(name, pipe) \
|
#define USB_IODEV_WRAPPER(name, pipe) \
|
||||||
static bool usb_##name##_can_read(void *dev) \
|
static ssize_t usb_##name##_can_read(void *dev) \
|
||||||
{ \
|
{ \
|
||||||
return usb_dwc3_can_read(dev, pipe); \
|
return usb_dwc3_can_read(dev, pipe); \
|
||||||
} \
|
} \
|
||||||
|
|
|
@ -1365,7 +1365,7 @@ size_t usb_dwc3_read(dwc3_dev_t *dev, cdc_acm_pipe_id_t pipe, void *buf, size_t
|
||||||
return recvd;
|
return recvd;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool usb_dwc3_can_read(dwc3_dev_t *dev, cdc_acm_pipe_id_t pipe)
|
ssize_t usb_dwc3_can_read(dwc3_dev_t *dev, cdc_acm_pipe_id_t pipe)
|
||||||
{
|
{
|
||||||
if (!dev || !dev->ready)
|
if (!dev || !dev->ready)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -19,7 +19,7 @@ void usb_dwc3_shutdown(dwc3_dev_t *dev);
|
||||||
|
|
||||||
void usb_dwc3_handle_events(dwc3_dev_t *dev);
|
void usb_dwc3_handle_events(dwc3_dev_t *dev);
|
||||||
|
|
||||||
bool usb_dwc3_can_read(dwc3_dev_t *dev, cdc_acm_pipe_id_t pipe);
|
ssize_t usb_dwc3_can_read(dwc3_dev_t *dev, cdc_acm_pipe_id_t pipe);
|
||||||
bool usb_dwc3_can_write(dwc3_dev_t *dev, cdc_acm_pipe_id_t pipe);
|
bool usb_dwc3_can_write(dwc3_dev_t *dev, cdc_acm_pipe_id_t pipe);
|
||||||
|
|
||||||
u8 usb_dwc3_getbyte(dwc3_dev_t *dev, cdc_acm_pipe_id_t pipe);
|
u8 usb_dwc3_getbyte(dwc3_dev_t *dev, cdc_acm_pipe_id_t pipe);
|
||||||
|
|
Loading…
Reference in a new issue