From: Marcus Folkesson <marcus.folkesson@gmail.com>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>,
Simona Vetter <simona@ffwll.ch>,
Javier Martinez Canillas <javierm@redhat.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org,
Marcus Folkesson <marcus.folkesson@gmail.com>
Subject: [PATCH v3 2/7] drm/sitronix/st7571-i2c: add 'struct device' to st7571_device
Date: Mon, 15 Dec 2025 10:46:44 +0100 [thread overview]
Message-ID: <20251215-st7571-split-v3-2-d5f3205c3138@gmail.com> (raw)
In-Reply-To: <20251215-st7571-split-v3-0-d5f3205c3138@gmail.com>
Keep a copy of the device structure instead of referring to i2c_client.
This is a preparation step to separate the generic part from all i2c
stuff.
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---
drivers/gpu/drm/sitronix/st7571-i2c.c | 30 ++++++++++++++++--------------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/sitronix/st7571-i2c.c b/drivers/gpu/drm/sitronix/st7571-i2c.c
index 71814a3eb93b..2b52919d7dd4 100644
--- a/drivers/gpu/drm/sitronix/st7571-i2c.c
+++ b/drivers/gpu/drm/sitronix/st7571-i2c.c
@@ -113,6 +113,7 @@ struct st7571_panel_format {
struct st7571_device {
struct drm_device drm;
+ struct device *dev;
struct drm_plane primary_plane;
struct drm_crtc crtc;
@@ -741,7 +742,7 @@ static const struct regmap_config st7571_regmap_config = {
static int st7571_validate_parameters(struct st7571_device *st7571)
{
- struct device *dev = st7571->dev.dev;
+ struct device *dev = st7571->dev;
const struct st7571_panel_constraints *constraints = &st7571->pdata->constraints;
if (st7571->width_mm == 0) {
@@ -781,7 +782,7 @@ static int st7571_validate_parameters(struct st7571_device *st7571)
static int st7567_parse_dt(struct st7571_device *st7567)
{
- struct device *dev = &st7567->client->dev;
+ struct device *dev = st7567->dev;
struct device_node *np = dev->of_node;
struct display_timing dt;
int ret;
@@ -808,7 +809,7 @@ static int st7567_parse_dt(struct st7571_device *st7567)
static int st7571_parse_dt(struct st7571_device *st7571)
{
- struct device *dev = &st7571->client->dev;
+ struct device *dev = st7571->dev;
struct device_node *np = dev->of_node;
struct display_timing dt;
int ret;
@@ -943,9 +944,10 @@ static int st7571_probe(struct i2c_client *client)
return PTR_ERR(st7571);
drm = &st7571->drm;
+ st7571->dev = &client->dev;
st7571->client = client;
i2c_set_clientdata(client, st7571);
- st7571->pdata = device_get_match_data(&client->dev);
+ st7571->pdata = device_get_match_data(st7571->dev);
ret = st7571->pdata->parse_dt(st7571);
if (ret)
@@ -966,20 +968,20 @@ static int st7571_probe(struct i2c_client *client)
if (i2c_check_functionality(client->adapter, I2C_FUNC_PROTOCOL_MANGLING))
st7571->ignore_nak = true;
- st7571->regmap = devm_regmap_init(&client->dev, &st7571_regmap_bus,
+ st7571->regmap = devm_regmap_init(st7571->dev, &st7571_regmap_bus,
client, &st7571_regmap_config);
if (IS_ERR(st7571->regmap)) {
- return dev_err_probe(&client->dev, PTR_ERR(st7571->regmap),
+ return dev_err_probe(st7571->dev, PTR_ERR(st7571->regmap),
"Failed to initialize regmap\n");
}
- st7571->hwbuf = devm_kzalloc(&client->dev,
+ st7571->hwbuf = devm_kzalloc(st7571->dev,
(st7571->nlines * st7571->ncols * st7571->bpp) / 8,
GFP_KERNEL);
if (!st7571->hwbuf)
return -ENOMEM;
- st7571->row = devm_kzalloc(&client->dev,
+ st7571->row = devm_kzalloc(st7571->dev,
(st7571->ncols * st7571->bpp),
GFP_KERNEL);
if (!st7571->row)
@@ -987,34 +989,34 @@ static int st7571_probe(struct i2c_client *client)
ret = st7571_mode_config_init(st7571);
if (ret)
- return dev_err_probe(&client->dev, ret,
+ return dev_err_probe(st7571->dev, ret,
"Failed to initialize mode config\n");
ret = st7571_plane_init(st7571, st7571->pformat);
if (ret)
- return dev_err_probe(&client->dev, ret,
+ return dev_err_probe(st7571->dev, ret,
"Failed to initialize primary plane\n");
ret = st7571_crtc_init(st7571);
if (ret < 0)
- return dev_err_probe(&client->dev, ret,
+ return dev_err_probe(st7571->dev, ret,
"Failed to initialize CRTC\n");
ret = st7571_encoder_init(st7571);
if (ret < 0)
- return dev_err_probe(&client->dev, ret,
+ return dev_err_probe(st7571->dev, ret,
"Failed to initialize encoder\n");
ret = st7571_connector_init(st7571);
if (ret < 0)
- return dev_err_probe(&client->dev, ret,
+ return dev_err_probe(st7571->dev, ret,
"Failed to initialize connector\n");
drm_mode_config_reset(drm);
ret = drm_dev_register(drm, 0);
if (ret)
- return dev_err_probe(&client->dev, ret,
+ return dev_err_probe(st7571->dev, ret,
"Failed to register DRM device\n");
drm_client_setup(drm, NULL);
--
2.51.2
next prev parent reply other threads:[~2025-12-15 9:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-15 9:46 [PATCH v3 0/7] drm/sitronix/st7571: split up driver to support both I2C and SPI Marcus Folkesson
2025-12-15 9:46 ` [PATCH v3 1/7] drm/sitronix/st7571-i2c: rename 'struct drm_device' in st7571_device Marcus Folkesson
2025-12-15 9:46 ` Marcus Folkesson [this message]
2025-12-15 9:46 ` [PATCH v3 3/7] drm/sitronix/st7571-i2c: move common structures to st7571.h Marcus Folkesson
2025-12-15 9:46 ` [PATCH v3 4/7] drm/sitronix/st7571-i2c: make probe independent of hw interface Marcus Folkesson
2025-12-15 9:46 ` [PATCH v3 5/7] drm/sitronix/st7571: split up the driver into a common and an i2c part Marcus Folkesson
2025-12-15 9:46 ` [PATCH v3 6/7] drm/sitronix/st7571-spi: add support for SPI interface Marcus Folkesson
2025-12-15 9:46 ` [PATCH v3 7/7] dt-bindings: display: sitronix,st7571: add example for SPI Marcus Folkesson
2025-12-15 12:57 ` [PATCH v3 0/7] drm/sitronix/st7571: split up driver to support both I2C and SPI 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=20251215-st7571-split-v3-2-d5f3205c3138@gmail.com \
--to=marcus.folkesson@gmail.com \
--cc=airlied@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=javierm@redhat.com \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=robh@kernel.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.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).