Skip to content

Commit 87d322e

Browse files
committed
drm/msm/dsi: simplify connector creation
Instead of having two functions, msm_dsi_manager_bridge_init() and msm_dsi_manager_ext_bridge_init(), merge them into msm_dsi_manager_connector_init(), moving drm_bridge_attach() to be called from the bridge's attach callback (as most other bridges do). Signed-off-by: Dmitry Baryshkov <[email protected]> Reviewed-by: Abhinav Kumar <[email protected]> Patchwork: https://patchwork.freedesktop.org/patch/582212/ Link: https://lore.kernel.org/r/[email protected]
1 parent c73588c commit 87d322e

File tree

3 files changed

+21
-35
lines changed

3 files changed

+21
-35
lines changed

drivers/gpu/drm/msm/dsi/dsi.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ void __exit msm_dsi_unregister(void)
232232
int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev,
233233
struct drm_encoder *encoder)
234234
{
235-
struct drm_bridge *bridge;
236235
int ret;
237236

238237
msm_dsi->dev = dev;
@@ -252,14 +251,7 @@ int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev,
252251
return 0;
253252
}
254253

255-
bridge = msm_dsi_manager_bridge_init(msm_dsi, encoder);
256-
if (IS_ERR(bridge)) {
257-
ret = PTR_ERR(bridge);
258-
DRM_DEV_ERROR(dev->dev, "failed to create dsi bridge: %d\n", ret);
259-
return ret;
260-
}
261-
262-
ret = msm_dsi_manager_ext_bridge_init(msm_dsi->id, bridge);
254+
ret = msm_dsi_manager_connector_init(msm_dsi, encoder);
263255
if (ret) {
264256
DRM_DEV_ERROR(dev->dev,
265257
"failed to create dsi connector: %d\n", ret);

drivers/gpu/drm/msm/dsi/dsi.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,8 @@ struct msm_dsi {
4747
};
4848

4949
/* dsi manager */
50-
struct drm_bridge *msm_dsi_manager_bridge_init(struct msm_dsi *msm_dsi,
51-
struct drm_encoder *encoder);
52-
int msm_dsi_manager_ext_bridge_init(u8 id, struct drm_bridge *int_bridge);
50+
int msm_dsi_manager_connector_init(struct msm_dsi *msm_dsi,
51+
struct drm_encoder *encoder);
5352
int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg);
5453
bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 dma_base, u32 len);
5554
int msm_dsi_manager_register(struct msm_dsi *msm_dsi);

drivers/gpu/drm/msm/dsi/dsi_manager.c

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -423,25 +423,38 @@ static enum drm_mode_status dsi_mgr_bridge_mode_valid(struct drm_bridge *bridge,
423423
return msm_dsi_host_check_dsc(host, mode);
424424
}
425425

426+
static int dsi_mgr_bridge_attach(struct drm_bridge *bridge,
427+
enum drm_bridge_attach_flags flags)
428+
{
429+
int id = dsi_mgr_bridge_get_id(bridge);
430+
struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id);
431+
432+
return drm_bridge_attach(bridge->encoder, msm_dsi->next_bridge,
433+
bridge, flags);
434+
}
435+
426436
static const struct drm_bridge_funcs dsi_mgr_bridge_funcs = {
437+
.attach = dsi_mgr_bridge_attach,
427438
.pre_enable = dsi_mgr_bridge_pre_enable,
428439
.post_disable = dsi_mgr_bridge_post_disable,
429440
.mode_set = dsi_mgr_bridge_mode_set,
430441
.mode_valid = dsi_mgr_bridge_mode_valid,
431442
};
432443

433444
/* initialize bridge */
434-
struct drm_bridge *msm_dsi_manager_bridge_init(struct msm_dsi *msm_dsi,
435-
struct drm_encoder *encoder)
445+
int msm_dsi_manager_connector_init(struct msm_dsi *msm_dsi,
446+
struct drm_encoder *encoder)
436447
{
448+
struct drm_device *dev = msm_dsi->dev;
437449
struct drm_bridge *bridge;
438450
struct dsi_bridge *dsi_bridge;
451+
struct drm_connector *connector;
439452
int ret;
440453

441454
dsi_bridge = devm_kzalloc(msm_dsi->dev->dev,
442455
sizeof(*dsi_bridge), GFP_KERNEL);
443456
if (!dsi_bridge)
444-
return ERR_PTR(-ENOMEM);
457+
return -ENOMEM;
445458

446459
dsi_bridge->id = msm_dsi->id;
447460

@@ -450,27 +463,9 @@ struct drm_bridge *msm_dsi_manager_bridge_init(struct msm_dsi *msm_dsi,
450463

451464
ret = devm_drm_bridge_add(msm_dsi->dev->dev, bridge);
452465
if (ret)
453-
return ERR_PTR(ret);
454-
455-
ret = drm_bridge_attach(encoder, bridge, NULL, 0);
456-
if (ret)
457-
return ERR_PTR(ret);
458-
459-
return bridge;
460-
}
461-
462-
int msm_dsi_manager_ext_bridge_init(u8 id, struct drm_bridge *int_bridge)
463-
{
464-
struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id);
465-
struct drm_device *dev = msm_dsi->dev;
466-
struct drm_encoder *encoder;
467-
struct drm_connector *connector;
468-
int ret;
469-
470-
encoder = int_bridge->encoder;
466+
return ret;
471467

472-
ret = drm_bridge_attach(encoder, msm_dsi->next_bridge, int_bridge,
473-
DRM_BRIDGE_ATTACH_NO_CONNECTOR);
468+
ret = drm_bridge_attach(encoder, bridge, NULL, DRM_BRIDGE_ATTACH_NO_CONNECTOR);
474469
if (ret)
475470
return ret;
476471

0 commit comments

Comments
 (0)