Skip to content

Commit 37dfdc5

Browse files
committed
drm/dp_mst: Cleanup drm_dp_send_link_address() a bit
Declare local pointer to the drm_dp_link_address_ack_reply struct instead of constantly dereferencing it through the union in txmsg->reply. Then, invert the order of conditionals so we don't have to do the bulk of the work inside them, and can wrap lines even less. Then finally, rearrange variable declarations a bit. Cc: Juston Li <juston.li@intel.com> Cc: Imre Deak <imre.deak@intel.com> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> Cc: Harry Wentland <hwentlan@amd.com> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Lyude Paul <lyude@redhat.com> Reviewed-by: Dave Airlie <airlied@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20190903204645.25487-16-lyude@redhat.com
1 parent 8b1e589 commit 37dfdc5

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

drivers/gpu/drm/drm_dp_mst_topology.c

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2424,9 +2424,9 @@ drm_dp_dump_link_address(struct drm_dp_link_address_ack_reply *reply)
24242424
static void drm_dp_send_link_address(struct drm_dp_mst_topology_mgr *mgr,
24252425
struct drm_dp_mst_branch *mstb)
24262426
{
2427-
int len;
24282427
struct drm_dp_sideband_msg_tx *txmsg;
2429-
int ret;
2428+
struct drm_dp_link_address_ack_reply *reply;
2429+
int i, len, ret;
24302430

24312431
txmsg = kzalloc(sizeof(*txmsg), GFP_KERNEL);
24322432
if (!txmsg)
@@ -2438,28 +2438,32 @@ static void drm_dp_send_link_address(struct drm_dp_mst_topology_mgr *mgr,
24382438
mstb->link_address_sent = true;
24392439
drm_dp_queue_down_tx(mgr, txmsg);
24402440

2441+
/* FIXME: Actually do some real error handling here */
24412442
ret = drm_dp_mst_wait_tx_reply(mstb, txmsg);
2442-
if (ret > 0) {
2443-
int i;
2443+
if (ret <= 0) {
2444+
DRM_ERROR("Sending link address failed with %d\n", ret);
2445+
goto out;
2446+
}
2447+
if (txmsg->reply.reply_type == DP_SIDEBAND_REPLY_NAK) {
2448+
DRM_ERROR("link address NAK received\n");
2449+
ret = -EIO;
2450+
goto out;
2451+
}
24442452

2445-
if (txmsg->reply.reply_type == DP_SIDEBAND_REPLY_NAK) {
2446-
DRM_DEBUG_KMS("link address nak received\n");
2447-
} else {
2448-
DRM_DEBUG_KMS("link address reply: %d\n", txmsg->reply.u.link_addr.nports);
2449-
drm_dp_dump_link_address(&txmsg->reply.u.link_addr);
2453+
reply = &txmsg->reply.u.link_addr;
2454+
DRM_DEBUG_KMS("link address reply: %d\n", reply->nports);
2455+
drm_dp_dump_link_address(reply);
24502456

2451-
drm_dp_check_mstb_guid(mstb, txmsg->reply.u.link_addr.guid);
2457+
drm_dp_check_mstb_guid(mstb, reply->guid);
24522458

2453-
for (i = 0; i < txmsg->reply.u.link_addr.nports; i++) {
2454-
drm_dp_add_port(mstb, mgr->dev, &txmsg->reply.u.link_addr.ports[i]);
2455-
}
2456-
drm_kms_helper_hotplug_event(mgr->dev);
2457-
}
2458-
} else {
2459-
mstb->link_address_sent = false;
2460-
DRM_DEBUG_KMS("link address failed %d\n", ret);
2461-
}
2459+
for (i = 0; i < reply->nports; i++)
2460+
drm_dp_add_port(mstb, mgr->dev, &reply->ports[i]);
2461+
2462+
drm_kms_helper_hotplug_event(mgr->dev);
24622463

2464+
out:
2465+
if (ret <= 0)
2466+
mstb->link_address_sent = false;
24632467
kfree(txmsg);
24642468
}
24652469

0 commit comments

Comments
 (0)