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: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Sui Jingfeng <sui.jingfeng@linux.dev>
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240325200855.21150-8-tzimmermann@suse.de
This commit is contained in:
Thomas Zimmermann 2024-03-25 21:06:52 +01:00
parent 42f4980da5
commit 0872fee2e1
3 changed files with 8 additions and 4 deletions

View File

@ -110,8 +110,9 @@ static void ast_ddc_release(struct drm_device *dev, void *res)
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 i2c_adapter *adapter;
struct i2c_algo_bit_data *bit;

View File

@ -6,6 +6,7 @@
#include <linux/i2c.h>
#include <linux/i2c-algo-bit.h>
struct ast_device;
struct drm_device;
struct ast_ddc {
@ -14,6 +15,6 @@ struct ast_ddc {
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

View File

@ -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)
{
struct ast_device *ast = to_ast_device(dev);
struct ast_ddc *ddc;
int ret;
ddc = ast_ddc_create(dev);
ddc = ast_ddc_create(ast);
if (IS_ERR(ddc)) {
ret = PTR_ERR(ddc);
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 = {
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;
int ret;
ddc = ast_ddc_create(dev);
ddc = ast_ddc_create(ast);
if (IS_ERR(ddc)) {
ret = PTR_ERR(ddc);
drm_err(dev, "failed to add DDC bus for connector; ret=%d\n", ret);