Commit 0872fee2 authored by Thomas Zimmermann's avatar Thomas Zimmermann

drm/ast: Pass AST device to ast_ddc_create()

The DDC code needs the AST device. Pass it to ast_ddc_create() and
avoid an internal upcast. Improves type safety within the DDC code.
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-8-tzimmermann@suse.de
parent 42f4980d
...@@ -110,8 +110,9 @@ static void ast_ddc_release(struct drm_device *dev, void *res) ...@@ -110,8 +110,9 @@ static void ast_ddc_release(struct drm_device *dev, void *res)
i2c_del_adapter(&ddc->adapter); i2c_del_adapter(&ddc->adapter);
} }
struct ast_ddc *ast_ddc_create(struct drm_device *dev) struct ast_ddc *ast_ddc_create(struct ast_device *ast)
{ {
struct drm_device *dev = &ast->base;
struct ast_ddc *ddc; struct ast_ddc *ddc;
struct i2c_adapter *adapter; struct i2c_adapter *adapter;
struct i2c_algo_bit_data *bit; struct i2c_algo_bit_data *bit;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/i2c-algo-bit.h> #include <linux/i2c-algo-bit.h>
struct ast_device;
struct drm_device; struct drm_device;
struct ast_ddc { struct ast_ddc {
...@@ -14,6 +15,6 @@ struct ast_ddc { ...@@ -14,6 +15,6 @@ struct ast_ddc {
struct i2c_algo_bit_data bit; struct i2c_algo_bit_data bit;
}; };
struct ast_ddc *ast_ddc_create(struct drm_device *dev); struct ast_ddc *ast_ddc_create(struct ast_device *ast);
#endif #endif
...@@ -1388,10 +1388,11 @@ static const struct drm_connector_funcs ast_vga_connector_funcs = { ...@@ -1388,10 +1388,11 @@ 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_device *ast = to_ast_device(dev);
struct ast_ddc *ddc; struct ast_ddc *ddc;
int ret; int ret;
ddc = ast_ddc_create(dev); ddc = ast_ddc_create(ast);
if (IS_ERR(ddc)) { if (IS_ERR(ddc)) {
ret = PTR_ERR(ddc); 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);
...@@ -1485,10 +1486,11 @@ static const struct drm_connector_funcs ast_sil164_connector_funcs = { ...@@ -1485,10 +1486,11 @@ 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_device *ast = to_ast_device(dev);
struct ast_ddc *ddc; struct ast_ddc *ddc;
int ret; int ret;
ddc = ast_ddc_create(dev); ddc = ast_ddc_create(ast);
if (IS_ERR(ddc)) { if (IS_ERR(ddc)) {
ret = PTR_ERR(ddc); 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);
......
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