Re: [PATCH v5 2/2] Input: add MStar MSG2638 touchscreen driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Vincent,

thanks for your patch!

On Tue, Feb 16, 2021 at 5:38 PM Vincent Knecht
<vincent.knecht@xxxxxxxxxx> wrote:

> Add support for the msg2638 touchscreen IC from MStar.
> This driver reuses zinitix.c structure, while the checksum and irq handler
> functions are based on out-of-tree driver for Alcatel Idol 3 (4.7").
>
> Signed-off-by: Vincent Knecht <vincent.knecht@xxxxxxxxxx>
> ---
> Changed in v5:
> - use gpiod_set_value_cansleep() (Stephan G)
> - use msleep/usleep_range() rathen than mdelay() (Stephan G)

(...)

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

Please only include
#include <linux/gpio/consumer.h>

> +#define CHIP_ON_DELAY                  15 // ms
> +#define FIRMWARE_ON_DELAY              50 // ms
> +#define RESET_DELAY_MIN                        10000 // µs
> +#define RESET_DELAY_MAX                        11000 // µs

Rename the defines with _MS and _US suffixes so you don't
need the comments, CHIP_ON_DELAY_MS etc.

> +static int msg2638_init_regulators(struct msg2638_ts_data *msg2638)
> +{
> +       struct i2c_client *client = msg2638->client;
> +       int error;

I usually prefer a short name like "err" (cognitive load) but your choice.

> +static u8 msg2638_checksum(u8 *data, u32 length)
> +{
> +       s32 sum = 0;
> +       u32 i;
> +
> +       for (i = 0; i < length; i++)
> +               sum += data[i];
> +
> +       return (u8)((-sum) & 0xFF);
> +}

Interesting checksum algoritm.

> +static int msg2638_start(struct msg2638_ts_data *msg2638)
> +{
> +       int error;
> +
> +       error = regulator_bulk_enable(ARRAY_SIZE(msg2638->supplies),
> +                                     msg2638->supplies);
> +       if (error) {
> +               dev_err(&msg2638->client->dev, "Failed to enable regulators: %d\n", error);
> +               return error;
> +       }
> +
> +       msleep(CHIP_ON_DELAY);
> +
> +       msg2638_power_on(msg2638);

Maybe move enable_irq() here from power on to mirror
the stop() function below?

> +#ifdef CONFIG_OF
> +static const struct of_device_id msg2638_of_match[] = {
> +       { .compatible = "mstar,msg2638" },
> +       { }
> +};
> +MODULE_DEVICE_TABLE(of, msg2638_of_match);
> +#endif

I think these #ifdefs are not needed anymore. We just have struct of_device_id
available at all times.

Yours,
Linus Walleij




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux