From: Hans de Goede <hdegoede@redhat.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Andy Shevchenko" <andy@kernel.org>,
"AceLan Kao" <acelan.kao@canonical.com>,
"Kai-Heng Feng" <kai.heng.feng@canonical.com>,
platform-driver-x86@vger.kernel.org
Subject: Re: [PATCH 2/2] tools arch x86: Add dell-uart-backlight-emulator
Date: Sun, 12 May 2024 21:47:19 +0200 [thread overview]
Message-ID: <ebd60bb3-fb6b-4f01-a513-5b3ee7d81b45@redhat.com> (raw)
In-Reply-To: <CAHp75Vccu8gse93ZcYGq08eoMtJ5+vGTWOs2yvBkSSit783bzw@mail.gmail.com>
Hi,
On 5/12/24 9:32 PM, Andy Shevchenko wrote:
> On Sun, May 12, 2024 at 7:24 PM Hans de Goede <hdegoede@redhat.com> 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.
>
> ...
>
>> +++ b/tools/arch/x86/dell-uart-backlight-emulator/Makefile
>> @@ -0,0 +1,19 @@
>> +# SPDX-License-Identifier: GPL-2.0
>> +# Makefile for Intel Software Defined Silicon provisioning tool
>> +
>> +dell-uart-backlight-emulator: dell-uart-backlight-emulator.c
>> +
>> +BINDIR ?= /usr/bin
>> +
>> +override CFLAGS += -O2 -Wall
>> +
>> +%: %.c
>> + $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
>> +
>> +.PHONY : clean
>> +clean :
>> + @rm -f dell-uart-backlight-emulator
>> +
>> +install : dell-uart-backlight-emulator
>> + install -d $(DESTDIR)$(BINDIR)
>> + install -m 755 -p dell-uart-backlight-emulator $(DESTDIR)$(BINDIR)/dell-uart-backlight-emulator
>
> Is it possible to fix this to (at least) honour `make O=...` cases?
> (See, e.g., tools/gpio.)
I'll take a look at what the tools/gpio Makefile is doing.
>
> ...
>
>> +/* read() will return -1 on SIGINT / SIGTERM causing the mainloop to cleanly exit */
>
> Interesting... usually we handle error codes, such as EAGAIN and
> EINTR from read() syscall separately.
EAGAIN cannot happen since the fd is kept in its default blocking
mode. Other errors are also not expected to happen and would likely
lead to aborting the program anyway.
So just having an empty signal handler and then exit on the
EINTR error from read() is a nice KISS way to exit the main loop.
>
>> +void signalhdlr(int signum)
>> +{
>> +}
>
> ...
>
>> + fprintf(stderr, "Error opening %s: %s\n", argv[1], strerror(errno));
>
>> + fprintf(stderr, "Error getting tcattr: %s\n", strerror(errno));
>
> (and so on)
>
> Wouldn't perror() call be better?
perror() takes a fixed string, so for your first example it won't work since that
requires printf style formatted string support and once I made the choice there
to use fprintf(stderr, ) I used it everywhere for consistency.
>
> ...
>
>> + switch ((buf[0] << 8) | buf[1]) {
>
> byteorder.h is part of UAPI, you can use it, but OTOH it might be too
> complicated for the small thing like this.
>
>> + }
>
> ...
>
>> + return ret;
>
> Hmm... Hopefully you checked the possible returned codes, in user
> space it's only a positive 8-bit value used.
That is a good point, actually in normal use ret will be (len + 3)
from the last write() call done in the loop. So you're right that
needs some work.
Regards,
Hans
next prev parent reply other threads:[~2024-05-12 19:47 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-12 16:23 [PATCH 0/2] platform/x86: Add new Dell UART backlight driver Hans de Goede
2024-05-12 16:23 ` [PATCH 1/2] " Hans de Goede
2024-05-12 19:35 ` Andy Shevchenko
2024-05-13 10:01 ` Hans de Goede
2024-05-13 12:28 ` Andy Shevchenko
2024-05-13 12:36 ` Ilpo Järvinen
2024-05-13 8:34 ` Ilpo Järvinen
2024-05-13 9:55 ` Hans de Goede
2024-05-13 12:12 ` Ilpo Järvinen
2024-05-13 12:14 ` Ilpo Järvinen
2024-05-13 13:07 ` Hans de Goede
2024-05-13 13:14 ` Ilpo Järvinen
2024-05-13 13:21 ` Hans de Goede
2024-05-13 13:34 ` Ilpo Järvinen
2024-05-13 14:23 ` Hans de Goede
2024-05-13 14:36 ` Ilpo Järvinen
2024-05-13 14:39 ` Hans de Goede
2024-05-12 16:23 ` [PATCH 2/2] tools arch x86: Add dell-uart-backlight-emulator Hans de Goede
2024-05-12 19:32 ` Andy Shevchenko
2024-05-12 19:47 ` Hans de Goede [this message]
2024-05-13 11:03 ` 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=ebd60bb3-fb6b-4f01-a513-5b3ee7d81b45@redhat.com \
--to=hdegoede@redhat.com \
--cc=acelan.kao@canonical.com \
--cc=andy.shevchenko@gmail.com \
--cc=andy@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=kai.heng.feng@canonical.com \
--cc=platform-driver-x86@vger.kernel.org \
/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.