linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: Oleh Kuzhylnyi <kuzhylol@gmail.com>, linux-input@vger.kernel.org
Cc: dmitry.torokhov@gmail.com, artur.serhiienko@gmail.com,
	igor.opaniuk@gmail.com
Subject: Re: [PATCH 1/2] input: add driver for Hynitron CST816X touchscreen
Date: Sun, 19 May 2024 13:49:35 +0200	[thread overview]
Message-ID: <c7f43a40-40ab-4029-9446-84e46c4fb5ab@kernel.org> (raw)
In-Reply-To: <20240517092732.47715-1-kuzhylol@gmail.com>

On 17/05/2024 11:27, Oleh Kuzhylnyi wrote:
> Introduce support for the Hynitron CST816X touchscreen controller
> used for 240×240 1.28-inch Round LCD Display Module manufactured
> by Waveshare Electronics. The driver is designed based on an Arduino
> implementation marked as under MIT License. This driver is written
> for a particular round display based on the CST816S controller, which
> is not compatiable with existing driver for Hynitron controllers.
> 


...

> +static int cst816x_process_touch(struct cst816x_priv *priv)
> +{
> +	u8 *raw;
> +	int rc;
> +
> +	rc = cst816x_i2c_read_reg(priv, CST816X_FRAME);
> +	if (!rc) {
> +		raw = priv->rxtx;
> +
> +		priv->info.gesture = raw[0];
> +		priv->info.x = ((raw[2] & 0x0F) << 8) | raw[3];
> +		priv->info.y = ((raw[4] & 0x0F) << 8) | raw[5];
> +
> +		dev_dbg(priv->dev, "x: %d, y: %d, gesture: 0x%x\n",
> +			priv->info.x, priv->info.y, priv->info.gesture);
> +	} else {
> +		dev_warn(priv->dev, "request was dropped\n");

Not a warn. First, it feels like really spamming the log, second,
drivers should be moderately quiet.

> +	}
> +
> +	return rc;
> +}
> +
> +static int cst816x_register_input(struct cst816x_priv *priv)
> +{
> +	int rc;
> +
> +	priv->input = devm_input_allocate_device(priv->dev);
> +	if (!priv->input) {
> +		rc = -ENOMEM;
> +		dev_err(priv->dev, "input device alloc err: %d\n", rc);

Memory allocation errors are *never* printk'ed by drivers.

> +		goto err;
> +	}

...


> +static int cst816x_resume(struct device *dev)
> +{
> +	struct cst816x_priv *priv = i2c_get_clientdata(to_i2c_client(dev));
> +	int rc;
> +
> +	cst816x_reset(priv);
> +	rc = cst816x_regs_setup(priv);
> +	if (!rc)
> +		enable_irq(priv->irq);
> +
> +	return rc;
> +}
> +
> +static DEFINE_SIMPLE_DEV_PM_OPS(cst816x_pm_ops, cst816x_suspend, cst816x_resume);
> +
> +static int cst816x_probe(struct i2c_client *client)
> +{
> +	struct cst816x_priv *priv;
> +	struct device *dev = &client->dev;
> +	int rc;
> +
> +	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> +	if (!priv) {
> +		rc = -ENOMEM;

No, just return.

> +		dev_err(dev, "devm alloc failed: %d\n", rc);

No, drop. This is some ancient, downstream code. Do you see anything
like this anywhere else?

> +		goto err;
> +	}
> +
> +	INIT_DELAYED_WORK(&priv->dw, cst816x_dw_cb);
> +	timer_setup(&priv->timer, cst816x_timer_cb, 0);
> +
> +	priv->dev = dev;
> +	priv->client = client;
> +
> +	priv->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
> +	if (priv->reset == NULL) {
> +		rc = -EIO;

Syntax is return dev_err_probe().

Same everywhere else.



Best regards,
Krzysztof


      parent reply	other threads:[~2024-05-19 11:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-17  9:27 [PATCH 1/2] input: add driver for Hynitron CST816X touchscreen Oleh Kuzhylnyi
2024-05-17  9:27 ` [PATCH 2/2] dt-bindings: input: touchscreen: add Hynitron CST816X Oleh Kuzhylnyi
2024-05-19 11:46   ` Krzysztof Kozlowski
2024-05-19 11:49 ` Krzysztof Kozlowski [this message]

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=c7f43a40-40ab-4029-9446-84e46c4fb5ab@kernel.org \
    --to=krzk@kernel.org \
    --cc=artur.serhiienko@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=igor.opaniuk@gmail.com \
    --cc=kuzhylol@gmail.com \
    --cc=linux-input@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;
as well as URLs for NNTP newsgroup(s).