From: Javier Martinez Canillas <javierm@redhat.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-kernel@vger.kernel.org,
"Daniel Vetter" <daniel.vetter@ffwll.ch>,
linux-fbdev@vger.kernel.org, "Sam Ravnborg" <sam@ravnborg.org>,
"Maxime Ripard" <maxime@cerno.tech>,
dri-devel@lists.freedesktop.org,
"Noralf Trønnes" <noralf@tronnes.org>,
"Geert Uytterhoeven" <geert@linux-m68k.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"Daniel Vetter" <daniel@ffwll.ch>,
"David Airlie" <airlied@linux.ie>,
"Lee Jones" <lee.jones@linaro.org>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thierry Reding" <thierry.reding@gmail.com>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
linux-pwm@vger.kernel.org
Subject: Re: [PATCH v5 3/6] drm: Add driver for Solomon SSD130x OLED displays
Date: Fri, 11 Feb 2022 20:19:08 +0100 [thread overview]
Message-ID: <001ee392-d457-31e5-0087-272ef82afd12@redhat.com> (raw)
In-Reply-To: <YgaLGDVscXlANxcZ@smile.fi.intel.com>
Hello Andy,
On 2/11/22 17:13, Andy Shevchenko wrote:
[snip]
>
>> +#define SSD130X_SET_COM_PINS_CONFIG1_MASK GENMASK(4, 4)
>
> BIT(4)
>
>> +#define SSD130X_SET_COM_PINS_CONFIG1_SET(val) FIELD_PREP(SSD130X_SET_COM_PINS_CONFIG1_MASK, (!val))
>> +#define SSD130X_SET_COM_PINS_CONFIG2_MASK GENMASK(5, 5)
>
> BIT(5)
>
I actually thought about that when using these macros and considered
just using BIT(N) instead but at the end decided to do GENMASK(n, n)
for two reasons:
1) It better documents what this is about, that's bitmask of 1 -bit.
One of the main advantages of using these macros for me is to better
express what these are, otherwise could just use 1 << n or whatever.
2) It's consistent with the other definitions for bitmasks that have
more than one bit.
Looked at other drivers using these macros and noticed that is not
uncommon to have GENMASK(n, n), so I went for that.
>> +#define SSD130X_SET_COM_PINS_CONFIG2_SET(val) FIELD_PREP(SSD130X_SET_COM_PINS_CONFIG2_MASK, (val))
>
> I would put GENMASK() directly into FIELD(), but it's up to you
> (and I haven't checked the use of *_MASK anyway).
>
Same. I also considered just using GENMASK() directly, but since I was
already reworking these, I thought that having the _MASK constant macros
would make the code more explicit about these being masks and what for.
>
> ...
>
>> +static int ssd130x_write_data(struct ssd130x_device *ssd130x, u8 *values, int count)
>> +{
>> + int ret;
>> +
>> + ret = regmap_bulk_write(ssd130x->regmap, SSD130X_DATA, values, count);
>> + if (ret)
>> + return ret;
>> +
>> + return 0;
>
> return regmap_bulk_write(...);
>
Sure.
>> +}
>
> ...
>
>> +/*
>> + * Helper to write command (SSD130X_COMMAND). The fist variadic argument
>> + * is the command to write and the following are the command options.
>> + *
>> + * Note that the ssd130x protocol requires each command and option to be
>> + * written as a SSD130X_COMMAND device register value. That is why a call
>> + * to regmap_write(..., SSD130X_COMMAND, ...) is done for each argument.
>> + */
>
> Thanks!
>
You are welcome.
>> +static int ssd130x_write_cmd(struct ssd130x_device *ssd130x, int count,
>> + /* u8 cmd, u8 option, ... */...)
>> +{
>> + va_list ap;
>> + u8 value;
>> + int ret;
>> +
>> + va_start(ap, count);
>> +
>> + do {
>> + value = va_arg(ap, int);
>> + ret = regmap_write(ssd130x->regmap, SSD130X_COMMAND, (u8)value);
>
> Wondering if you really need this casting. value is u8 by definition.
>
Yeah, I'll drop it too.
[snip]
>> + ssd130x = devm_drm_dev_alloc(dev, &ssd130x_drm_driver,
>> + struct ssd130x_device, drm);
>> + if (IS_ERR(ssd130x)) {
>
>> + dev_err_probe(dev, PTR_ERR(ssd130x),
>> + "Failed to allocate DRM device\n");
>> + return ssd130x;
>
> This...
>
>> + }
>
> ...
>
>> + bl = devm_backlight_device_register(dev, dev_name(dev), dev, ssd130x,
>> + &ssd130xfb_bl_ops, NULL);
>> + if (IS_ERR(bl))
>> + return ERR_PTR(dev_err_probe(dev, PTR_ERR(bl),
>> + "Unable to register backlight device\n"));
>
> Can be consistent with this then.
>
Yes. I meant to change it everywhere but seems that one slipped it through.
It's not worth to send a v6 just for the changes you mentioned but I can do
them before pushing the patches to drm-misc (once I get ack for this patch).
Best regards,
--
Javier Martinez Canillas
Linux Engineering
Red Hat
next prev parent reply other threads:[~2022-02-11 19:19 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-11 14:33 [PATCH v5 0/6] drm: Add driver for Solomon SSD130x OLED displays Javier Martinez Canillas
2022-02-11 14:33 ` [PATCH v5 1/6] drm/format-helper: Add drm_fb_xrgb8888_to_gray8_line() Javier Martinez Canillas
2022-02-11 15:58 ` Andy Shevchenko
2022-02-11 14:33 ` [PATCH v5 2/6] drm/format-helper: Add drm_fb_xrgb8888_to_mono_reversed() Javier Martinez Canillas
2022-02-11 16:04 ` Andy Shevchenko
2022-02-12 15:54 ` Geert Uytterhoeven
2022-02-14 8:57 ` Javier Martinez Canillas
2022-02-11 14:33 ` [PATCH v5 3/6] drm: Add driver for Solomon SSD130x OLED displays Javier Martinez Canillas
2022-02-11 16:13 ` Andy Shevchenko
2022-02-11 19:19 ` Javier Martinez Canillas [this message]
2022-02-12 11:59 ` Javier Martinez Canillas
2022-02-11 14:33 ` [PATCH v5 4/6] drm/solomon: Add SSD130x OLED displays I2C support Javier Martinez Canillas
2022-02-11 14:35 ` [PATCH v5 5/6] MAINTAINERS: Add entry for Solomon SSD130x OLED displays DRM driver Javier Martinez Canillas
2022-02-11 14:36 ` [PATCH v5 6/6] dt-bindings: display: ssd1307fb: Add myself as binding co-maintainer Javier Martinez Canillas
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=001ee392-d457-31e5-0087-272ef82afd12@redhat.com \
--to=javierm@redhat.com \
--cc=airlied@linux.ie \
--cc=andriy.shevchenko@linux.intel.com \
--cc=daniel.vetter@ffwll.ch \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=geert@linux-m68k.org \
--cc=lee.jones@linaro.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=maxime@cerno.tech \
--cc=mripard@kernel.org \
--cc=noralf@tronnes.org \
--cc=sam@ravnborg.org \
--cc=thierry.reding@gmail.com \
--cc=tzimmermann@suse.de \
--cc=u.kleine-koenig@pengutronix.de \
/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).