Commit 42f4980d authored by Thomas Zimmermann's avatar Thomas Zimmermann

drm/ast: Rename struct ast_i2c_chan to struct ast_ddc

The struct struct ast_i2c_chan represents the Display Data Channel
(DDC); I2C is the underlying bus. Rename the structure, the variables
and the helper ast_i2c_create() to ddc-like terms. No functional
changes.
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarSui Jingfeng <sui.jingfeng@linux.dev>
Reviewed-by: default avatarJocelyn Falempe <jfalempe@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240325200855.21150-7-tzimmermann@suse.de
parent 0a7f04b4
...@@ -29,8 +29,8 @@ ...@@ -29,8 +29,8 @@
static void ast_i2c_setsda(void *i2c_priv, int data) static void ast_i2c_setsda(void *i2c_priv, int data)
{ {
struct ast_i2c_chan *i2c = i2c_priv; struct ast_ddc *ddc = i2c_priv;
struct ast_device *ast = to_ast_device(i2c->dev); struct ast_device *ast = to_ast_device(ddc->dev);
int i; int i;
u8 ujcrb7, jtemp; u8 ujcrb7, jtemp;
...@@ -45,8 +45,8 @@ static void ast_i2c_setsda(void *i2c_priv, int data) ...@@ -45,8 +45,8 @@ static void ast_i2c_setsda(void *i2c_priv, int data)
static void ast_i2c_setscl(void *i2c_priv, int clock) static void ast_i2c_setscl(void *i2c_priv, int clock)
{ {
struct ast_i2c_chan *i2c = i2c_priv; struct ast_ddc *ddc = i2c_priv;
struct ast_device *ast = to_ast_device(i2c->dev); struct ast_device *ast = to_ast_device(ddc->dev);
int i; int i;
u8 ujcrb7, jtemp; u8 ujcrb7, jtemp;
...@@ -61,8 +61,8 @@ static void ast_i2c_setscl(void *i2c_priv, int clock) ...@@ -61,8 +61,8 @@ static void ast_i2c_setscl(void *i2c_priv, int clock)
static int ast_i2c_getsda(void *i2c_priv) static int ast_i2c_getsda(void *i2c_priv)
{ {
struct ast_i2c_chan *i2c = i2c_priv; struct ast_ddc *ddc = i2c_priv;
struct ast_device *ast = to_ast_device(i2c->dev); struct ast_device *ast = to_ast_device(ddc->dev);
uint32_t val, val2, count, pass; uint32_t val, val2, count, pass;
count = 0; count = 0;
...@@ -83,8 +83,8 @@ static int ast_i2c_getsda(void *i2c_priv) ...@@ -83,8 +83,8 @@ static int ast_i2c_getsda(void *i2c_priv)
static int ast_i2c_getscl(void *i2c_priv) static int ast_i2c_getscl(void *i2c_priv)
{ {
struct ast_i2c_chan *i2c = i2c_priv; struct ast_ddc *ddc = i2c_priv;
struct ast_device *ast = to_ast_device(i2c->dev); struct ast_device *ast = to_ast_device(ddc->dev);
uint32_t val, val2, count, pass; uint32_t val, val2, count, pass;
count = 0; count = 0;
...@@ -103,45 +103,50 @@ static int ast_i2c_getscl(void *i2c_priv) ...@@ -103,45 +103,50 @@ static int ast_i2c_getscl(void *i2c_priv)
return val & 1 ? 1 : 0; return val & 1 ? 1 : 0;
} }
static void ast_i2c_release(struct drm_device *dev, void *res) static void ast_ddc_release(struct drm_device *dev, void *res)
{ {
struct ast_i2c_chan *i2c = res; struct ast_ddc *ddc = res;
i2c_del_adapter(&i2c->adapter); i2c_del_adapter(&ddc->adapter);
} }
struct ast_i2c_chan *ast_i2c_create(struct drm_device *dev) struct ast_ddc *ast_ddc_create(struct drm_device *dev)
{ {
struct ast_i2c_chan *i2c; struct ast_ddc *ddc;
struct i2c_adapter *adapter;
struct i2c_algo_bit_data *bit;
int ret; int ret;
i2c = drmm_kzalloc(dev->dev, sizeof(*i2c), GFP_KERNEL); ddc = drmm_kzalloc(dev, sizeof(*ddc), GFP_KERNEL);
if (!i2c) if (!ddc)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
ddc->dev = dev;
i2c->adapter.owner = THIS_MODULE;
i2c->adapter.dev.parent = dev->dev; adapter = &ddc->adapter;
i2c->dev = dev; adapter->owner = THIS_MODULE;
i2c_set_adapdata(&i2c->adapter, i2c); adapter->dev.parent = dev->dev;
snprintf(i2c->adapter.name, sizeof(i2c->adapter.name), "AST DDC bus"); i2c_set_adapdata(adapter, ddc);
i2c->adapter.algo_data = &i2c->bit; snprintf(adapter->name, sizeof(adapter->name), "AST DDC bus");
i2c->bit.udelay = 20; bit = &ddc->bit;
i2c->bit.timeout = 2; bit->udelay = 20;
i2c->bit.data = i2c; bit->timeout = 2;
i2c->bit.setsda = ast_i2c_setsda; bit->data = ddc;
i2c->bit.setscl = ast_i2c_setscl; bit->setsda = ast_i2c_setsda;
i2c->bit.getsda = ast_i2c_getsda; bit->setscl = ast_i2c_setscl;
i2c->bit.getscl = ast_i2c_getscl; bit->getsda = ast_i2c_getsda;
ret = i2c_bit_add_bus(&i2c->adapter); bit->getscl = ast_i2c_getscl;
adapter->algo_data = bit;
ret = i2c_bit_add_bus(adapter);
if (ret) { if (ret) {
drm_err(dev, "Failed to register bit i2c\n"); drm_err(dev, "Failed to register bit i2c\n");
return ERR_PTR(ret); return ERR_PTR(ret);
} }
ret = drmm_add_action_or_reset(dev, ast_i2c_release, i2c); ret = drmm_add_action_or_reset(dev, ast_ddc_release, ddc);
if (ret) if (ret)
return ERR_PTR(ret); return ERR_PTR(ret);
return i2c; return ddc;
} }
...@@ -8,12 +8,12 @@ ...@@ -8,12 +8,12 @@
struct drm_device; struct drm_device;
struct ast_i2c_chan { struct ast_ddc {
struct i2c_adapter adapter; struct i2c_adapter adapter;
struct drm_device *dev; struct drm_device *dev;
struct i2c_algo_bit_data bit; struct i2c_algo_bit_data bit;
}; };
struct ast_i2c_chan *ast_i2c_create(struct drm_device *dev); struct ast_ddc *ast_ddc_create(struct drm_device *dev);
#endif #endif
...@@ -1388,18 +1388,18 @@ static const struct drm_connector_funcs ast_vga_connector_funcs = { ...@@ -1388,18 +1388,18 @@ static const struct drm_connector_funcs ast_vga_connector_funcs = {
static int ast_vga_connector_init(struct drm_device *dev, struct drm_connector *connector) static int ast_vga_connector_init(struct drm_device *dev, struct drm_connector *connector)
{ {
struct ast_i2c_chan *i2c; struct ast_ddc *ddc;
int ret; int ret;
i2c = ast_i2c_create(dev); ddc = ast_ddc_create(dev);
if (IS_ERR(i2c)) { if (IS_ERR(ddc)) {
ret = PTR_ERR(i2c); ret = PTR_ERR(ddc);
drm_err(dev, "failed to add ddc bus for connector; ret=%d\n", ret); drm_err(dev, "failed to add DDC bus for connector; ret=%d\n", ret);
return ret; return ret;
} }
ret = drm_connector_init_with_ddc(dev, connector, &ast_vga_connector_funcs, ret = drm_connector_init_with_ddc(dev, connector, &ast_vga_connector_funcs,
DRM_MODE_CONNECTOR_VGA, &i2c->adapter); DRM_MODE_CONNECTOR_VGA, &ddc->adapter);
if (ret) if (ret)
return ret; return ret;
...@@ -1485,18 +1485,18 @@ static const struct drm_connector_funcs ast_sil164_connector_funcs = { ...@@ -1485,18 +1485,18 @@ static const struct drm_connector_funcs ast_sil164_connector_funcs = {
static int ast_sil164_connector_init(struct drm_device *dev, struct drm_connector *connector) static int ast_sil164_connector_init(struct drm_device *dev, struct drm_connector *connector)
{ {
struct ast_i2c_chan *i2c; struct ast_ddc *ddc;
int ret; int ret;
i2c = ast_i2c_create(dev); ddc = ast_ddc_create(dev);
if (IS_ERR(i2c)) { if (IS_ERR(ddc)) {
ret = PTR_ERR(i2c); ret = PTR_ERR(ddc);
drm_err(dev, "failed to add ddc bus for connector; ret=%d\n", ret); drm_err(dev, "failed to add DDC bus for connector; ret=%d\n", ret);
return ret; return ret;
} }
ret = drm_connector_init_with_ddc(dev, connector, &ast_sil164_connector_funcs, ret = drm_connector_init_with_ddc(dev, connector, &ast_sil164_connector_funcs,
DRM_MODE_CONNECTOR_DVII, &i2c->adapter); DRM_MODE_CONNECTOR_DVII, &ddc->adapter);
if (ret) if (ret)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment