public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Yauhen Kharuzhy <jekhor@gmail.com>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Hans de Goede <hansg@kernel.org>
Subject: Re: [PATCH 3/5] input: drv260x: Check the device ID at initialization
Date: Thu, 12 Feb 2026 09:28:51 -0800	[thread overview]
Message-ID: <aY4NfZm80ofkxzNW@google.com> (raw)
In-Reply-To: <20260211235902.4156624-4-jekhor@gmail.com>

On Thu, Feb 12, 2026 at 01:46:53AM +0200, Yauhen Kharuzhy wrote:
> To ensure that the device is accessible on the I2C bus, read the status
> register and check the Device ID field in drv260x_init().
> 
> Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com>
> ---
>  drivers/input/misc/drv260x.c | 44 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 44 insertions(+)
> 
> diff --git a/drivers/input/misc/drv260x.c b/drivers/input/misc/drv260x.c
> index f613c81fa2ba..f08a3d6c3ed8 100644
> --- a/drivers/input/misc/drv260x.c
> +++ b/drivers/input/misc/drv260x.c
> @@ -56,6 +56,13 @@
>  #define DRV260X_LRA_RES_PERIOD	0x22
>  #define DRV260X_MAX_REG			0x23
>  
> +#define DRV260X_STATUS_ID_MASK		0xe0
> +#define DRV260X_STATUS_ID_SHIFT		5
> +#define DRV260X_ID_DRV2605		3
> +#define DRV260X_ID_DRV2604		4
> +#define DRV260X_ID_DRV2604L		6
> +#define DRV260X_ID_DRV2605L		7
> +
>  #define DRV260X_GO_BIT				0x01
>  
>  /* Library Selection */
> @@ -305,10 +312,47 @@ static const struct reg_sequence drv260x_erm_cal_regs[] = {
>  	{ DRV260X_CTRL4, DRV260X_AUTOCAL_TIME_500MS },
>  };
>  
> +struct drv260x_id_map {
> +	u8 id;
> +	char *name;
> +};
> +
> +static const struct drv260x_id_map drv_260x_devids[] = {
> +	{ DRV260X_ID_DRV2605, "DRV2605"},
> +	{ DRV260X_ID_DRV2604, "DRV2604"},
> +	{ DRV260X_ID_DRV2604L, "DRV2604L"},
> +	{ DRV260X_ID_DRV2605L, "DRV2605L"},
> +};
> +
> +static char *drv260x_get_model(u8 id)
> +{
> +	int i;
> +
> +	for (i = 0; i < ARRAY_SIZE(drv_260x_devids); i++)
> +		if (id == drv_260x_devids[i].id)
> +			return drv_260x_devids[i].name;
> +
> +	return NULL;
> +}
> +
>  static int drv260x_init(struct drv260x_data *haptics)
>  {
>  	int error;
>  	unsigned int cal_buf;
> +	u8 id;
> +
> +	error = regmap_read(haptics->regmap, DRV260X_STATUS, &cal_buf);
> +	if (error) {
> +		dev_err(&haptics->client->dev,
> +				"Failed to read DRV260X_status register: %d\n",
> +				error);
> +		return error;
> +	}
> +
> +	id = (cal_buf & DRV260X_STATUS_ID_MASK) >> DRV260X_STATUS_ID_SHIFT;
> +
> +	dev_info(&haptics->client->dev, "ID: %u (%s)\n", id,
> +		 drv260x_get_model(id));
>  
>  	error = regmap_write(haptics->regmap,
>  			     DRV260X_RATED_VOLT, haptics->rated_voltage);

If the device is not available this regmap_write() will fail so I am not
sure why we need all this new code.

Thanks.

-- 
Dmitry

  reply	other threads:[~2026-02-12 17:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-11 23:46 DRV260x: Support ACPI-enumerated devices Yauhen Kharuzhy
2026-02-11 23:46 ` [PATCH 1/5] input: drv260x: Add I2C IDs for all device variants Yauhen Kharuzhy
2026-02-11 23:46 ` [PATCH 2/5] input: drv260x: Add support for ACPI-enumerated devices Yauhen Kharuzhy
2026-02-12 17:26   ` Dmitry Torokhov
2026-02-13 20:48     ` Yauhen Kharuzhy
2026-02-11 23:46 ` [PATCH 3/5] input: drv260x: Check the device ID at initialization Yauhen Kharuzhy
2026-02-12 17:28   ` Dmitry Torokhov [this message]
2026-02-13 20:53     ` Yauhen Kharuzhy
2026-02-11 23:46 ` [PATCH 4/5] input: drv260x: Stop waiting for GO bit clearing after timeout Yauhen Kharuzhy
2026-02-12 17:34   ` Dmitry Torokhov
2026-02-13 21:00     ` Yauhen Kharuzhy
2026-02-11 23:46 ` [PATCH 5/5] input: drv260x: Don't try to disable dummy regulator Yauhen Kharuzhy
2026-02-12 17:41   ` Dmitry Torokhov
2026-02-13 21:56     ` Yauhen Kharuzhy

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=aY4NfZm80ofkxzNW@google.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=hansg@kernel.org \
    --cc=jekhor@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox