Re: [PATCH v5 2/2] Input: add MStar MSG2638 touchscreen driver
flat view
From: Linus Walleij <hidden>
Date: 2021-03-02 09:35:24
Also in:
linux-devicetree, lkml, phone-devel
Hi Vincent, thanks for your patch! On Tue, Feb 16, 2021 at 5:38 PM Vincent Knecht [off-list ref] 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 <redacted> --- 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>
quoted hunk ↗ jump to hunk
+#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.
quoted hunk ↗ jump to hunk
+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.
quoted hunk ↗ jump to hunk
+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.
quoted hunk ↗ jump to hunk
+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?
quoted hunk ↗ jump to hunk
+#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