]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/gma500: Make gma_i2c_chan a subclass of i2c_adapter
authorPatrik Jakobsson <patrik.r.jakobsson@gmail.com>
Wed, 1 Jun 2022 09:23:05 +0000 (11:23 +0200)
committerPatrik Jakobsson <patrik.r.jakobsson@gmail.com>
Thu, 2 Jun 2022 08:06:21 +0000 (10:06 +0200)
This makes it easier to get at the full gma_i2c_chan when having an
i2c_adapter from eg. drm_connector->ddc.

Signed-off-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20220601092311.22648-3-patrik.r.jakobsson@gmail.com
drivers/gpu/drm/gma500/cdv_intel_crt.c
drivers/gpu/drm/gma500/cdv_intel_hdmi.c
drivers/gpu/drm/gma500/cdv_intel_lvds.c
drivers/gpu/drm/gma500/intel_i2c.c
drivers/gpu/drm/gma500/oaktrail_lvds.c
drivers/gpu/drm/gma500/oaktrail_lvds_i2c.c
drivers/gpu/drm/gma500/psb_intel_drv.h
drivers/gpu/drm/gma500/psb_intel_lvds.c

index 36c72a379d9f427eaf59816e51719f07dc62ec47..be0d6a4591bf41d6f487368cd57eb0d23ae1ec0b 100644 (file)
@@ -203,7 +203,7 @@ static int cdv_intel_crt_get_modes(struct drm_connector *connector)
 {
        struct gma_encoder *gma_encoder = gma_attached_encoder(connector);
        return psb_intel_ddc_get_modes(connector,
-                                      &gma_encoder->ddc_bus->adapter);
+                                      &gma_encoder->ddc_bus->base);
 }
 
 static int cdv_intel_crt_set_property(struct drm_connector *connector,
index e87272c9d35841a0a939ed9d71787e9018ff2104..bd6791522160411db9e972d977755db731af879c 100644 (file)
@@ -130,7 +130,7 @@ static enum drm_connector_status cdv_hdmi_detect(
        struct edid *edid = NULL;
        enum drm_connector_status status = connector_status_disconnected;
 
-       edid = drm_get_edid(connector, &gma_encoder->i2c_bus->adapter);
+       edid = drm_get_edid(connector, &gma_encoder->i2c_bus->base);
 
        hdmi_priv->has_hdmi_sink = false;
        hdmi_priv->has_hdmi_audio = false;
@@ -212,7 +212,7 @@ static int cdv_hdmi_get_modes(struct drm_connector *connector)
        struct edid *edid = NULL;
        int ret = 0;
 
-       edid = drm_get_edid(connector, &gma_encoder->i2c_bus->adapter);
+       edid = drm_get_edid(connector, &gma_encoder->i2c_bus->base);
        if (edid) {
                drm_connector_update_edid_property(connector, edid);
                ret = drm_add_edid_modes(connector, edid);
@@ -350,7 +350,7 @@ void cdv_hdmi_init(struct drm_device *dev,
                goto failed_ddc;
        }
 
-       hdmi_priv->hdmi_i2c_adapter = &(gma_encoder->i2c_bus->adapter);
+       hdmi_priv->hdmi_i2c_adapter = &gma_encoder->i2c_bus->base;
        hdmi_priv->dev = dev;
        return;
 
index 02dedf5dfa62f4afed0fac4f9d8a6843fb831ca4..d76c3ecc951ce019f27b9176854e55a8ed182f7a 100644 (file)
@@ -302,7 +302,7 @@ static int cdv_intel_lvds_get_modes(struct drm_connector *connector)
        struct psb_intel_mode_device *mode_dev = &dev_priv->mode_dev;
        int ret;
 
-       ret = psb_intel_ddc_get_modes(connector, &gma_encoder->i2c_bus->adapter);
+       ret = psb_intel_ddc_get_modes(connector, &gma_encoder->i2c_bus->base);
 
        if (ret)
                return ret;
@@ -583,7 +583,7 @@ void cdv_intel_lvds_init(struct drm_device *dev,
         */
        mutex_lock(&dev->mode_config.mutex);
        psb_intel_ddc_get_modes(connector,
-                               &gma_encoder->ddc_bus->adapter);
+                               &gma_encoder->ddc_bus->base);
        list_for_each_entry(scan, &connector->probed_modes, head) {
                if (scan->type & DRM_MODE_TYPE_PREFERRED) {
                        mode_dev->panel_fixed_mode =
index 6e9e2061ff3b19285fe9d0462b8f678d9e03f37f..9d02a7b6d9a30f4142d8aa36ebd8ae60e99e5ef5 100644 (file)
@@ -113,10 +113,10 @@ struct gma_i2c_chan *gma_i2c_create(struct drm_device *dev, const u32 reg,
 
        chan->drm_dev = dev;
        chan->reg = reg;
-       snprintf(chan->adapter.name, I2C_NAME_SIZE, "intel drm %s", name);
-       chan->adapter.owner = THIS_MODULE;
-       chan->adapter.algo_data = &chan->algo;
-       chan->adapter.dev.parent = dev->dev;
+       snprintf(chan->base.name, I2C_NAME_SIZE, "intel drm %s", name);
+       chan->base.owner = THIS_MODULE;
+       chan->base.algo_data = &chan->algo;
+       chan->base.dev.parent = dev->dev;
        chan->algo.setsda = set_data;
        chan->algo.setscl = set_clock;
        chan->algo.getsda = get_data;
@@ -125,9 +125,9 @@ struct gma_i2c_chan *gma_i2c_create(struct drm_device *dev, const u32 reg,
        chan->algo.timeout = usecs_to_jiffies(2200);
        chan->algo.data = chan;
 
-       i2c_set_adapdata(&chan->adapter, chan);
+       i2c_set_adapdata(&chan->base, chan);
 
-       if (i2c_bit_add_bus(&chan->adapter))
+       if (i2c_bit_add_bus(&chan->base))
                goto out_free;
 
        /* JJJ:  raise SCL and SDA? */
@@ -153,6 +153,6 @@ void gma_i2c_destroy(struct gma_i2c_chan *chan)
        if (!chan)
                return;
 
-       i2c_del_adapter(&chan->adapter);
+       i2c_del_adapter(&chan->base);
        kfree(chan);
 }
index 58b38e35909852f875988389d35833202d00797a..8609f6249c4ce6ee00ee37c3797d73222f8150ab 100644 (file)
@@ -359,7 +359,7 @@ void oaktrail_lvds_init(struct drm_device *dev,
        if (edid == NULL && dev_priv->lpc_gpio_base) {
                oaktrail_lvds_i2c_init(encoder);
                if (gma_encoder->ddc_bus != NULL) {
-                       i2c_adap = &gma_encoder->ddc_bus->adapter;
+                       i2c_adap = &gma_encoder->ddc_bus->base;
                        edid = drm_get_edid(connector, i2c_adap);
                }
        }
index 9a6de6ff8b0c86b2748cf6ae2b1a49e946de4bfc..ee163fb972d9836770ce551d19d1319f58622288 100644 (file)
@@ -142,10 +142,10 @@ void oaktrail_lvds_i2c_init(struct drm_encoder *encoder)
 
        chan->drm_dev = dev;
        chan->reg = dev_priv->lpc_gpio_base;
-       strncpy(chan->adapter.name, "gma500 LPC",  I2C_NAME_SIZE - 1);
-       chan->adapter.owner = THIS_MODULE;
-       chan->adapter.algo_data = &chan->algo;
-       chan->adapter.dev.parent = dev->dev;
+       strncpy(chan->base.name, "gma500 LPC",  I2C_NAME_SIZE - 1);
+       chan->base.owner = THIS_MODULE;
+       chan->base.algo_data = &chan->algo;
+       chan->base.dev.parent = dev->dev;
        chan->algo.setsda = set_data;
        chan->algo.setscl = set_clock;
        chan->algo.getsda = get_data;
@@ -154,13 +154,13 @@ void oaktrail_lvds_i2c_init(struct drm_encoder *encoder)
        chan->algo.timeout = usecs_to_jiffies(2200);
        chan->algo.data = chan;
 
-       i2c_set_adapdata(&chan->adapter, chan);
+       i2c_set_adapdata(&chan->base, chan);
 
        set_data(chan, 1);
        set_clock(chan, 1);
        udelay(50);
 
-       if (i2c_bit_add_bus(&chan->adapter)) {
+       if (i2c_bit_add_bus(&chan->base)) {
                kfree(chan);
                return;
        }
index 72585a3df25d3e91021fae9fcf896a35f1ca9a0d..1c28288f36a064427d92e6bbc003086dcb077054 100644 (file)
@@ -79,12 +79,13 @@ struct psb_intel_mode_device {
 };
 
 struct gma_i2c_chan {
-       /* for getting at dev. private (mmio etc.) */
-       struct drm_device *drm_dev;
-       u32 reg;                /* GPIO reg */
-       struct i2c_adapter adapter;
+       struct i2c_adapter base;
        struct i2c_algo_bit_data algo;
        u8 slave_addr;
+
+       /* for getting at dev. private (mmio etc.) */
+       struct drm_device *drm_dev;
+       u32 reg; /* GPIO reg */
 };
 
 struct gma_encoder {
@@ -175,6 +176,8 @@ struct gma_crtc {
                container_of(x, struct gma_encoder, base)
 #define to_psb_intel_framebuffer(x)    \
                container_of(x, struct psb_intel_framebuffer, base)
+#define to_gma_i2c_chan(x)     \
+               container_of(x, struct gma_i2c_chan, base)
 
 struct gma_i2c_chan *gma_i2c_create(struct drm_device *dev, const u32 reg,
                                    const char *name);
index 07631891531aba59ad931f7d7090ebbda7f8c5d4..c28fabdcfd7350518d40e6b39d6a0e3eacea8747 100644 (file)
@@ -113,7 +113,7 @@ static int psb_lvds_i2c_set_brightness(struct drm_device *dev,
        out_buf[0] = dev_priv->lvds_bl->brightnesscmd;
        out_buf[1] = (u8)blc_i2c_brightness;
 
-       if (i2c_transfer(&lvds_i2c_bus->adapter, msgs, 1) == 1) {
+       if (i2c_transfer(&lvds_i2c_bus->base, msgs, 1) == 1) {
                dev_dbg(dev->dev, "I2C set brightness.(command, value) (%d, %d)\n",
                        dev_priv->lvds_bl->brightnesscmd,
                        blc_i2c_brightness);
@@ -497,7 +497,7 @@ static int psb_intel_lvds_get_modes(struct drm_connector *connector)
        int ret = 0;
 
        if (!IS_MRST(dev))
-               ret = psb_intel_ddc_get_modes(connector, &lvds_priv->i2c_bus->adapter);
+               ret = psb_intel_ddc_get_modes(connector, &lvds_priv->i2c_bus->base);
 
        if (ret)
                return ret;
@@ -727,7 +727,7 @@ void psb_intel_lvds_init(struct drm_device *dev,
         * preferred mode is the right one.
         */
        mutex_lock(&dev->mode_config.mutex);
-       psb_intel_ddc_get_modes(connector, &lvds_priv->ddc_bus->adapter);
+       psb_intel_ddc_get_modes(connector, &lvds_priv->ddc_bus->base);
        list_for_each_entry(scan, &connector->probed_modes, head) {
                if (scan->type & DRM_MODE_TYPE_PREFERRED) {
                        mode_dev->panel_fixed_mode =