X86 platform drivers
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy@kernel.org>
To: Hans de Goede <hdegoede@redhat.com>
Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"AceLan Kao" <acelan.kao@canonical.com>,
	"Roman Bogoyev" <roman@computercheck.com.au>,
	"Kai Heng Feng" <kai.heng.feng@canonical.com>,
	platform-driver-x86@vger.kernel.org
Subject: Re: [PATCH v2 2/2] tools arch x86: Add dell-uart-backlight-emulator
Date: Mon, 13 May 2024 15:46:26 +0300	[thread overview]
Message-ID: <ZkILom0Ee5ei9xF-@smile.fi.intel.com> (raw)
In-Reply-To: <20240513111552.44880-3-hdegoede@redhat.com>

On Mon, May 13, 2024 at 01:15:51PM +0200, Hans de Goede wrote:
> Dell All In One (AIO) models released after 2017 use a backlight controller
> board connected to an UART.
> 
> Add a small emulator to allow development and testing of
> the drivers/platform/x86/dell/dell-uart-backlight.c driver for
> this board, without requiring access to an actual Dell All In One.

...

> +	if (argc != 2) {
> +		fprintf(stderr, "Invalid or missing arguments\n");
> +		fprintf(stderr, "Usage: %s <serial-port>\n", argv[0]);
> +		return 1;
> +	}
> +
> +	serial_fd = open(argv[1], O_RDWR | O_NOCTTY);
> +	if (serial_fd == -1) {
> +		fprintf(stderr, "Error opening %s: %s\n", argv[1], strerror(errno));
> +		return 1;

So, looking at the `man error` it works like your custom approach with an
additional things.

Also, don't you want to use either different error codes (above is +1 and all
below seems using -1), or be consistent and return -1 always?

> +	}

...

> +		/* Respond with <total-len> <cmd> <data...> <csum> */
> +		response[0] = len + 3; /* response length in bytes */
> +		response[1] = buf[1];  /* ack cmd */
> +		csum = dell_uart_checksum(response, len + 2);
> +		response[len + 2] = csum;

> +		ret = write(serial_fd, response, len + 3);

response[0] can be reused here.

> +		if (ret != (len + 3))

And here.

> +			fprintf(stderr, "Error writing %d bytes: %d\n",
> +				len + 3, ret);
> +	}

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2024-05-13 12:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-13 11:15 [PATCH v2 0/2] platform/x86: Add new Dell UART backlight driver Hans de Goede
2024-05-13 11:15 ` [PATCH v2 1/2] " Hans de Goede
2024-05-13 12:58   ` Andy Shevchenko
2024-05-13 13:18     ` Hans de Goede
2024-05-13 15:19       ` Andy Shevchenko
2024-05-13 15:33         ` Hans de Goede
2024-05-13 15:44           ` Andy Shevchenko
2024-05-13 15:45             ` Andy Shevchenko
2024-05-13 15:54             ` Ilpo Järvinen
2024-05-13 16:04               ` Andy Shevchenko
2024-05-13 11:15 ` [PATCH v2 2/2] tools arch x86: Add dell-uart-backlight-emulator Hans de Goede
2024-05-13 12:46   ` Andy Shevchenko [this message]
2024-05-13 13:25     ` Hans de Goede

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZkILom0Ee5ei9xF-@smile.fi.intel.com \
    --to=andy@kernel.org \
    --cc=acelan.kao@canonical.com \
    --cc=hdegoede@redhat.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=kai.heng.feng@canonical.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=roman@computercheck.com.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox