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]
Date:   Fri, 8 Jul 2022 16:40:01 +0200
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     William Breathitt Gray <william.gray@...aro.org>
Cc:     Linus Walleij <linus.walleij@...aro.org>,
        Bartosz Golaszewski <brgl@...ev.pl>,
        "open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Fred Eckert <Frede@...laser.com>,
        John Hentges <jhentges@...esio.com>,
        Jay Dolan <jay.dolan@...esio.com>
Subject: Re: [PATCH v2 1/6] gpio: i8255: Introduce the i8255 module

On Fri, Jul 8, 2022 at 1:16 AM William Breathitt Gray
<william.gray@...aro.org> wrote:
>
> Exposes consumer functions providing support for Intel 8255 Programmable
> Peripheral Interface devices. A CONFIG_GPIO_I8255 Kconfig option is
> introduced; modules wanting access to these functions should select this
> Kconfig option.

Spent much time with these chips in my teenage times :-)

Very good written library, see my comments below.

...

> +#include <linux/compiler_types.h>

Should be simple types.h as you are using u8, etc.

> +#include <linux/err.h>
> +#include <linux/export.h>

> +#include <linux/gpio/i8255.h>

gpio/driver.h ?

And since it belongs to GPIO, I would group them and move after all
other include/* to emphasize the relationship.

Also, why is it in the global header folder? Do you expect some
drivers outside of drivers/gpio/? Maybe we can move after when the
user comes?

> +#include <linux/io.h>
> +#include <linux/module.h>

...

> +#define I8255_CONTROL_PORTCLOWER_DIRECTION BIT(0)
> +#define I8255_CONTROL_PORTCUPPER_DIRECTION BIT(3)

Missed underscore.

...

> +static u8 i8255_direction_mask(const unsigned long offset)
> +{
> +       const unsigned long io_port = offset / 8;
> +       const unsigned long ppi_port = io_port % 3;
> +
> +       switch (ppi_port) {
> +       case I8255_PORTA:
> +               return I8255_CONTROL_PORTA_DIRECTION;
> +       case I8255_PORTB:
> +               return I8255_CONTROL_PORTB_DIRECTION;
> +       case I8255_PORTC:
> +               /* Port C can be configured by nibble */

> +               if (offset % 8 > 3)

I would move it to the local definition block close to offset/8. On
some architectures this may give one assembly instruction for two
variables.

> +                       return I8255_CONTROL_PORTCUPPER_DIRECTION;
> +               return I8255_CONTROL_PORTCLOWER_DIRECTION;
> +       default:
> +               /* Should never reach this path */
> +               return 0;
> +       }
> +}

> +void i8255_direction_input(struct i8255 __iomem *const ppi,
> +                          u8 *const control_state, const unsigned long offset)
> +{
> +       const unsigned long io_port = offset / 8;
> +       const unsigned long group = io_port / 3;
> +
> +       control_state[group] |= I8255_CONTROL_MODE_SET;
> +       control_state[group] |= i8255_direction_mask(offset);
> +
> +       iowrite8(control_state[group], &ppi[group].control);

No I/O serialization? Can this be accessed during interrupt? (It may
be that the code is correct, but please go through it and check with a
question "can this register be accessed during IRQ and if yes, will
the user get the correct / meaningful data?")

> +}
> +EXPORT_SYMBOL_GPL(i8255_direction_input);

Make it with a namespace. Ditto for the rest.

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ