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.

Signed-off-by: Marcus Folkesson <[email protected]>
---
 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 
71814a3eb93b7adf554da082a0237da371e5f5b5..2b52919d7dd434bb16aa66274eae8730649f62f1
 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.50.1

Reply via email to