[Pdbg] [PATCH 2/2] libsbefifo: Implement long read timeout for chip-ops
Joel Stanley
joel at jms.id.au
Tue Feb 22 17:29:31 AEDT 2022
On Tue, 22 Feb 2022 at 02:51, Joel Stanley <joel at jms.id.au> wrote:
> +int sbefifo_set_long_timeout(struct sbefifo_context *sctx)
> +{
> + unsigned int long_timeout = 30;
> + int rc;
> +
> + LOG("long_timeout: %u sec\n", long_timeout);
> + rc = ioctl(sctx->fd, FSI_SBEFIFO_READ_TIMEOUT, &long_timeout);
> + if (rc == -1 && errno == EINVAL) {
> + /* Do not fail if kernel does not implement ioctl */
> + rc = 0;
> + }
> +
> + return rc;
> +}
> +
> +int sbefifo_reset_timeout(struct sbefifo_context *sctx)
> +{
> + unsigned int timeout = 0;
> + int rc;
> +
> + LOG("reset_timeout\n");
> + rc = ioctl(sctx->fd, FSI_SBEFIFO_READ_TIMEOUT, &timeout);
> + if (rc == -1 && errno == EINVAL) {
The kernel will set rc = -1 and errno to ENOTTY if the ioctl is not supported.
We should test for that instead of EINVAL, or even not test if the
ioctl failed at all?
> + /* Do not fail if kernel does not implement ioctl */
> + rc = 0;
> + }
> +
> + return rc;
> +}
> +
> void sbefifo_debug(const char *fmt, ...)
> {
> va_list ap;
> --
> 2.34.1
>
More information about the Pdbg
mailing list