From: Hans de Goede <hdegoede@redhat.com>
To: Andy Shevchenko <andy@kernel.org>
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:25:34 +0200 [thread overview]
Message-ID: <30821935-7431-4f87-86ed-bd87cbf9a36e@redhat.com> (raw)
In-Reply-To: <ZkILom0Ee5ei9xF-@smile.fi.intel.com>
Hi,
On 5/13/24 2:46 PM, Andy Shevchenko wrote:
> 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.
But that is a GNU / glibc extension. I would prefer to stick with plain libc
here, so that this can be build with other libc-s too.
> 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?
the +1 code is for when the cmdline argument is likely wrong , -1 / 255 is
for IO errors.
>
>> + }
>
> ...
>
>> + /* 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.
Ack will fix.
Regards,
Hans
>
>> + fprintf(stderr, "Error writing %d bytes: %d\n",
>> + len + 3, ret);
>> + }
>
prev parent reply other threads:[~2024-05-13 13:25 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
2024-05-13 13:25 ` Hans de Goede [this message]
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=30821935-7431-4f87-86ed-bd87cbf9a36e@redhat.com \
--to=hdegoede@redhat.com \
--cc=acelan.kao@canonical.com \
--cc=andy@kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.