lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACRpkdb0HZFGnNm=5NdSJjM1-3kUzLigfnz9Ks-CX8U9a51Zmg@mail.gmail.com>
Date:   Fri, 29 Sep 2023 23:43:15 +0200
From:   Linus Walleij <linus.walleij@...aro.org>
To:     Duje Mihanović <duje.mihanovic@...le.hr>
Cc:     Daniel Mack <daniel@...que.org>,
        Haojian Zhuang <haojian.zhuang@...il.com>,
        Robert Jarzmik <robert.jarzmik@...e.fr>,
        Russell King <linux@...linux.org.uk>,
        Alan Stern <stern@...land.harvard.edu>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Bartosz Golaszewski <brgl@...ev.pl>,
        Andy Shevchenko <andy@...nel.org>,
        linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
        linux-usb@...r.kernel.org, linux-gpio@...r.kernel.org
Subject: Re: [PATCH RFC v3 5/6] ARM: pxa: Convert Spitz hsync to GPIO descriptors

Hi Duje,

thanks for your patch!

On Fri, Sep 29, 2023 at 3:15 PM Duje Mihanović <duje.mihanovic@...le.hr> wrote:

> Sharp's Spitz still uses the legacy GPIO interface in its
> wait_for_hsync() function.
>
> Convert it to use the GPIO descriptor interface.
>
> Signed-off-by: Duje Mihanović <duje.mihanovic@...le.hr>

Overall this looks fine, but can't help but notice:

>  static void spitz_ads7846_wait_for_hsync(void)
>  {
> -       while (gpio_get_value(SPITZ_GPIO_HSYNC))
> +       while (gpiod_get_value(hsync))
>                 cpu_relax();

Waits while the line is high...

> -       while (!gpio_get_value(SPITZ_GPIO_HSYNC))
> +       while (!gpiod_get_value(hsync))
>                 cpu_relax();

Then as it goes low, waits for it to go high again.

So the hsync signal is *active* when it is *low*.

> @@ -543,6 +545,8 @@ static struct gpiod_lookup_table spitz_ads7846_gpio_table = {
>         .table = {
>                 GPIO_LOOKUP("gpio-pxa", SPITZ_GPIO_TP_INT,
>                             "pendown", GPIO_ACTIVE_LOW),
> +               GPIO_LOOKUP("gpio-pxa", SPITZ_GPIO_HSYNC,
> +                           "hsync", GPIO_ACTIVE_LOW),

Which is what you appropriately flag it for.

BUT: the signal is now inverted in gpiolib, so the

spitz_ads7846_wait_for_hsync() loops needs to be rewritten
inverted, because the value from gpiod_get_value() now means
"asserted" if high.

/* Wait while de-asserted */
while (!gpiod_get_value(hsync))
                cpu_relax();
/* Wait while asserted */
while (gpiod_get_value(hsync))
                cpu_relax();
return;

Right?

> @@ -622,8 +626,13 @@ static void __init spitz_spi_init(void)
>
>         gpiod_add_lookup_table(&spitz_ads7846_gpio_table);
>         gpiod_add_lookup_table(&spitz_spi_gpio_table);
> +       hsync = gpiod_get(NULL, "hsync", GPIOD_IN);

You are getting the gpiod from device NULL which is probably correct
when you do this in the board file.

But the spitz_ads7846_gpio_table where you put the descriptor
is associated with the ads7846 device so this will not work.

You either have to add a one-gpio table just for this, or (better)
move the whole spitz_ads7846_wait_for_hsync() down into the
touchscreen driver instead, so the device driver can (optionally) obtain
this gpio and deal with it. Which is easy because:

[linus@...usia linux-nomadik]$ git grep ads7846_platform_data
Documentation/spi/spi-summary.rst:      static struct
ads7846_platform_data ads_info = {
arch/arm/mach-pxa/spitz.c:static struct ads7846_platform_data
spitz_ads7846_info = {
arch/mips/alchemy/devboards/db1000.c:static struct
ads7846_platform_data db1100_touch_pd = {
arch/powerpc/platforms/512x/pdm360ng.c:static struct
ads7846_platform_data pdm360ng_ads7846_pdata = {

Only three users in the kernel, and sptiz is the only one using the
void    (*wait_for_sync)(void) callback in ads7846_platform_data!

So delete that callback from ads7846_platform_data in
include/linux/spi/ads7846.h
and augment drivers/input/touchscreen/ads7846.c to get the
GPIO optionally with gpiod_get_optional() from the device,
then copy the code from spitz_ads7846_wait_for_hsync() right
into the driver and make sure it gets called if and only
if the "hsync" gpio exists.

Yours,
Linus Walleij

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ