From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Mark Jonas <mark.jonas@de.bosch.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
linux-input <linux-input@vger.kernel.org>,
devicetree <devicetree@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Heiko Schocher <hs@denx.de>, Zhu Yi <yi.zhu5@cn.bosch.com>
Subject: Re: [PATCH v3] Input: add bu21029 touch driver
Date: Sun, 13 May 2018 17:56:43 +0300 [thread overview]
Message-ID: <CAHp75Vf=eJbJPv5=y3fDKZapAnmABD0=v+WRhrBhMv+RSoBnKg@mail.gmail.com> (raw)
In-Reply-To: <1526048528-3613-1-git-send-email-mark.jonas@de.bosch.com>
On Fri, May 11, 2018 at 5:22 PM, Mark Jonas <mark.jonas@de.bosch.com> wrote:
> Add Rohm BU21029 resistive touch panel controller support with I2C
> interface.
> +#include <linux/of.h>
This becomes redundant (see below).
> +#define STOP_DELAY_US 50L
> +#define START_DELAY_MS 2L
> +#define BUF_LEN 8L
No need to use L for such small numbers. Integer promotion is a part
of C standard.
> +#define SCALE_12BIT (1 << 12)
> +#define MAX_12BIT ((1 << 12) - 1)
BIT(12)
GENMASK(11, 0)
> +static int bu21029_touch_report(struct bu21029_ts_data *bu21029)
> +{
> + struct i2c_client *i2c = bu21029->client;
> + u8 buf[BUF_LEN];
> + int error = bu21029_touch_report(bu21029);
> +
Redundant empty line.
> + if (error) {
> + dev_err(&i2c->dev, "failed to report (error: %d)\n", error);
Potential spamming case.
> + return IRQ_NONE;
> + }
> +static void bu21029_stop_chip(struct input_dev *dev)
> +{
> + struct bu21029_ts_data *bu21029 = input_get_drvdata(dev);
> +
> + disable_irq(bu21029->client->irq);
> + del_timer_sync(&bu21029->timer);
> +
> + /* put chip into reset */
> + gpiod_set_value_cansleep(bu21029->reset_gpios, 1);
> + udelay(STOP_DELAY_US);
udelay() ?!
> +}
> +
> +static int bu21029_start_chip(struct input_dev *dev)
> +{
> + u16 hwid;
> +
> + /* take chip out of reset */
> + gpiod_set_value_cansleep(bu21029->reset_gpios, 0);
> + mdelay(START_DELAY_MS);
mdelay()?!
> +
> + error = i2c_smbus_read_i2c_block_data(i2c,
> + BU21029_HWID_REG,
> + 2,
> + (u8 *)&hwid);
> + if (error < 0) {
> + dev_err(&i2c->dev, "failed to read HW ID\n");
> + goto out;
> + }
> +
> + if (cpu_to_be16(hwid) != SUPPORTED_HWID) {
Hmm... Why cpu_to_be16() is required?
> + dev_err(&i2c->dev, "unsupported HW ID 0x%x\n", hwid);
> + error = -ENODEV;
> + goto out;
> + }
> +}
> +static int bu21029_parse_dt(struct bu21029_ts_data *bu21029)
You can get rid of DT requirement by...
> +{
> + struct device *dev = &bu21029->client->dev;
> + struct device_node *np = dev->of_node;
> + u32 val32;
> + int error;
> + if (!np) {
> + dev_err(dev, "no device tree data\n");
> + return -EINVAL;
> + }
(this becomes redundant)
> +
> + bu21029->reset_gpios = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
> + if (IS_ERR(bu21029->reset_gpios)) {
> + error = PTR_ERR(bu21029->reset_gpios);
> + if (error != -EPROBE_DEFER)
> + dev_err(dev, "invalid 'reset-gpios':%d\n", error);
> + return error;
> + }
> +
> + if (of_property_read_u32(np, "rohm,x-plate-ohms", &val32)) {
...simple calling device_property_read_u32() instead.
> + dev_err(dev, "invalid 'x-plate-ohms' supplied\n");
> + return -EINVAL;
> + }
> + bu21029->x_plate_ohms = val32;
> +
> + touchscreen_parse_properties(bu21029->in_dev, false, &bu21029->prop);
> +
> + return 0;
> +}
> +#ifdef CONFIG_PM_SLEEP
Instead...
> +static int bu21029_suspend(struct device *dev)
...use __maby_unused annotation.
> +static int bu21029_resume(struct device *dev)
Ditto.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2018-05-13 14:56 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-21 17:04 [PATCH] Input: add bu21029 touch driver Mark Jonas
2018-03-26 22:24 ` Rob Herring
2018-03-26 22:39 ` Dmitry Torokhov
2018-03-26 22:53 ` Dmitry Torokhov
2018-04-16 16:49 ` [PATCH v2] " Mark Jonas
2018-04-16 21:44 ` Rob Herring
2018-04-26 6:40 ` AW: " Jonas Mark (BT-FIR/ENG1)
2018-05-11 14:22 ` [PATCH v3] " Mark Jonas
2018-05-13 14:56 ` Andy Shevchenko [this message]
2018-05-16 13:24 ` AW: " Jonas Mark (BT-FIR/ENG1)
2018-05-16 17:43 ` Dmitry Torokhov
2018-05-17 20:10 ` AW: " Jonas Mark (BT-FIR/ENG1)
2018-06-17 19:19 ` kbuild test robot
2018-05-16 13:25 ` [PATCH v4] " Mark Jonas
2018-05-17 10:03 ` kbuild test robot
2018-05-17 20:06 ` [PATCH v5] " Mark Jonas
2018-06-18 9:35 [PATCH v3] " Jonas Mark (BT-FIR/ENG1)
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='CAHp75Vf=eJbJPv5=y3fDKZapAnmABD0=v+WRhrBhMv+RSoBnKg@mail.gmail.com' \
--to=andy.shevchenko@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=hs@denx.de \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.jonas@de.bosch.com \
--cc=mark.rutland@arm.com \
--cc=robh+dt@kernel.org \
--cc=yi.zhu5@cn.bosch.com \
/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).