From: Thierry Reding Date: Tue, 28 Feb 2017 14:46:43 +0000 (+0100) Subject: drm: Rename connector list iterator API X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=b982dab1e66d2b998e80a97acb6eaf56518988d3;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git drm: Rename connector list iterator API Currently the functions that initialize and tear down a connector iterator use the _get() and _put() suffixes. However, these suffixes are typically used by reference counting functions. Make these function names a little more consistent by changing the suffixes to _begin() and _end(), which is a fairly common pattern in the rest of the Linux kernel. Suggested-by: Jani Nikula Signed-off-by: Thierry Reding Link: http://patchwork.freedesktop.org/patch/msgid/20170228144643.5668-8-thierry.reding@gmail.com --- diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index aea8bbad1674..236d947011f9 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -1449,18 +1449,18 @@ drm_atomic_add_affected_connectors(struct drm_atomic_state *state, * Changed connectors are already in @state, so only need to look * at the connector_mask in crtc_state. */ - drm_connector_list_iter_get(state->dev, &conn_iter); + drm_connector_list_iter_begin(state->dev, &conn_iter); drm_for_each_connector_iter(connector, &conn_iter) { if (!(crtc_state->connector_mask & (1 << drm_connector_index(connector)))) continue; conn_state = drm_atomic_get_connector_state(state, connector); if (IS_ERR(conn_state)) { - drm_connector_list_iter_put(&conn_iter); + drm_connector_list_iter_end(&conn_iter); return PTR_ERR(conn_state); } } - drm_connector_list_iter_put(&conn_iter); + drm_connector_list_iter_end(&conn_iter); return 0; } @@ -1722,10 +1722,10 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p) list_for_each_entry(crtc, &config->crtc_list, head) drm_atomic_crtc_print_state(p, crtc->state); - drm_connector_list_iter_get(dev, &conn_iter); + drm_connector_list_iter_begin(dev, &conn_iter); drm_for_each_connector_iter(connector, &conn_iter) drm_atomic_connector_print_state(p, connector->state); - drm_connector_list_iter_put(&conn_iter); + drm_connector_list_iter_end(&conn_iter); } EXPORT_SYMBOL(drm_state_dump); diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index ffcae3fa94f9..6b12396f718b 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -145,7 +145,7 @@ static int handle_conflicting_encoders(struct drm_atomic_state *state, * and the crtc is disabled if no encoder is left. This preserves * compatibility with the legacy set_config behavior. */ - drm_connector_list_iter_get(state->dev, &conn_iter); + drm_connector_list_iter_begin(state->dev, &conn_iter); drm_for_each_connector_iter(connector, &conn_iter) { struct drm_crtc_state *crtc_state; @@ -193,7 +193,7 @@ static int handle_conflicting_encoders(struct drm_atomic_state *state, } } out: - drm_connector_list_iter_put(&conn_iter); + drm_connector_list_iter_end(&conn_iter); return ret; } @@ -3018,7 +3018,7 @@ retry: WARN_ON(!drm_modeset_is_locked(&config->connection_mutex)); - drm_connector_list_iter_get(connector->dev, &conn_iter); + drm_connector_list_iter_begin(connector->dev, &conn_iter); drm_for_each_connector_iter(tmp_connector, &conn_iter) { if (tmp_connector->state->crtc != crtc) continue; @@ -3028,7 +3028,7 @@ retry: break; } } - drm_connector_list_iter_put(&conn_iter); + drm_connector_list_iter_end(&conn_iter); crtc_state->active = active; ret = drm_atomic_commit(state); @@ -3439,18 +3439,18 @@ drm_atomic_helper_duplicate_state(struct drm_device *dev, } } - drm_connector_list_iter_get(dev, &conn_iter); + drm_connector_list_iter_begin(dev, &conn_iter); drm_for_each_connector_iter(conn, &conn_iter) { struct drm_connector_state *conn_state; conn_state = drm_atomic_get_connector_state(state, conn); if (IS_ERR(conn_state)) { err = PTR_ERR(conn_state); - drm_connector_list_iter_put(&conn_iter); + drm_connector_list_iter_end(&conn_iter); goto free; } } - drm_connector_list_iter_put(&conn_iter); + drm_connector_list_iter_end(&conn_iter); /* clear the acquire context so that it isn't accidentally reused */ state->acquire_ctx = NULL; diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 5a4be752a85e..9f847615ac74 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -435,10 +435,10 @@ void drm_connector_unregister_all(struct drm_device *dev) struct drm_connector *connector; struct drm_connector_list_iter conn_iter; - drm_connector_list_iter_get(dev, &conn_iter); + drm_connector_list_iter_begin(dev, &conn_iter); drm_for_each_connector_iter(connector, &conn_iter) drm_connector_unregister(connector); - drm_connector_list_iter_put(&conn_iter); + drm_connector_list_iter_end(&conn_iter); } int drm_connector_register_all(struct drm_device *dev) @@ -447,13 +447,13 @@ int drm_connector_register_all(struct drm_device *dev) struct drm_connector_list_iter conn_iter; int ret = 0; - drm_connector_list_iter_get(dev, &conn_iter); + drm_connector_list_iter_begin(dev, &conn_iter); drm_for_each_connector_iter(connector, &conn_iter) { ret = drm_connector_register(connector); if (ret) break; } - drm_connector_list_iter_put(&conn_iter); + drm_connector_list_iter_end(&conn_iter); if (ret) drm_connector_unregister_all(dev); @@ -507,23 +507,23 @@ static struct lockdep_map connector_list_iter_dep_map = { #endif /** - * drm_connector_list_iter_get - initialize a connector_list iterator + * drm_connector_list_iter_begin - initialize a connector_list iterator * @dev: DRM device * @iter: connector_list iterator * * Sets @iter up to walk the &drm_mode_config.connector_list of @dev. @iter - * must always be cleaned up again by calling drm_connector_list_iter_put(). + * must always be cleaned up again by calling drm_connector_list_iter_end(). * Iteration itself happens using drm_connector_list_iter_next() or * drm_for_each_connector_iter(). */ -void drm_connector_list_iter_get(struct drm_device *dev, - struct drm_connector_list_iter *iter) +void drm_connector_list_iter_begin(struct drm_device *dev, + struct drm_connector_list_iter *iter) { iter->dev = dev; iter->conn = NULL; lock_acquire_shared_recursive(&connector_list_iter_dep_map, 0, 1, NULL, _RET_IP_); } -EXPORT_SYMBOL(drm_connector_list_iter_get); +EXPORT_SYMBOL(drm_connector_list_iter_begin); /** * drm_connector_list_iter_next - return next connector @@ -564,7 +564,7 @@ drm_connector_list_iter_next(struct drm_connector_list_iter *iter) EXPORT_SYMBOL(drm_connector_list_iter_next); /** - * drm_connector_list_iter_put - tear down a connector_list iterator + * drm_connector_list_iter_end - tear down a connector_list iterator * @iter: connector_list iterator * * Tears down @iter and releases any resources (like &drm_connector references) @@ -572,14 +572,14 @@ EXPORT_SYMBOL(drm_connector_list_iter_next); * iteration completes fully or when it was aborted without walking the entire * list. */ -void drm_connector_list_iter_put(struct drm_connector_list_iter *iter) +void drm_connector_list_iter_end(struct drm_connector_list_iter *iter) { iter->dev = NULL; if (iter->conn) drm_connector_put(iter->conn); lock_release(&connector_list_iter_dep_map, 0, _RET_IP_); } -EXPORT_SYMBOL(drm_connector_list_iter_put); +EXPORT_SYMBOL(drm_connector_list_iter_end); static const struct drm_prop_enum_list drm_subpixel_enum_list[] = { { SubPixelUnknown, "Unknown" }, diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c index 536051c627d8..8aa8c1084121 100644 --- a/drivers/gpu/drm/drm_crtc_helper.c +++ b/drivers/gpu/drm/drm_crtc_helper.c @@ -102,14 +102,14 @@ bool drm_helper_encoder_in_use(struct drm_encoder *encoder) } - drm_connector_list_iter_get(dev, &conn_iter); + drm_connector_list_iter_begin(dev, &conn_iter); drm_for_each_connector_iter(connector, &conn_iter) { if (connector->encoder == encoder) { - drm_connector_list_iter_put(&conn_iter); + drm_connector_list_iter_end(&conn_iter); return true; } } - drm_connector_list_iter_put(&conn_iter); + drm_connector_list_iter_end(&conn_iter); return false; } EXPORT_SYMBOL(drm_helper_encoder_in_use); @@ -449,7 +449,7 @@ drm_crtc_helper_disable(struct drm_crtc *crtc) if (encoder->crtc != crtc) continue; - drm_connector_list_iter_get(dev, &conn_iter); + drm_connector_list_iter_begin(dev, &conn_iter); drm_for_each_connector_iter(connector, &conn_iter) { if (connector->encoder != encoder) continue; @@ -467,7 +467,7 @@ drm_crtc_helper_disable(struct drm_crtc *crtc) /* we keep a reference while the encoder is bound */ drm_connector_put(connector); } - drm_connector_list_iter_put(&conn_iter); + drm_connector_list_iter_end(&conn_iter); } __drm_helper_disable_unused_functions(dev); @@ -583,10 +583,10 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set) } count = 0; - drm_connector_list_iter_get(dev, &conn_iter); + drm_connector_list_iter_begin(dev, &conn_iter); drm_for_each_connector_iter(connector, &conn_iter) save_connector_encoders[count++] = connector->encoder; - drm_connector_list_iter_put(&conn_iter); + drm_connector_list_iter_end(&conn_iter); save_set.crtc = set->crtc; save_set.mode = &set->crtc->mode; @@ -628,7 +628,7 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set) /* a) traverse passed in connector list and get encoders for them */ count = 0; - drm_connector_list_iter_get(dev, &conn_iter); + drm_connector_list_iter_begin(dev, &conn_iter); drm_for_each_connector_iter(connector, &conn_iter) { const struct drm_connector_helper_funcs *connector_funcs = connector->helper_private; @@ -662,7 +662,7 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set) connector->encoder = new_encoder; } } - drm_connector_list_iter_put(&conn_iter); + drm_connector_list_iter_end(&conn_iter); if (fail) { ret = -EINVAL; @@ -670,7 +670,7 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set) } count = 0; - drm_connector_list_iter_get(dev, &conn_iter); + drm_connector_list_iter_begin(dev, &conn_iter); drm_for_each_connector_iter(connector, &conn_iter) { if (!connector->encoder) continue; @@ -689,7 +689,7 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set) if (new_crtc && !drm_encoder_crtc_ok(connector->encoder, new_crtc)) { ret = -EINVAL; - drm_connector_list_iter_put(&conn_iter); + drm_connector_list_iter_end(&conn_iter); goto fail; } if (new_crtc != connector->encoder->crtc) { @@ -706,7 +706,7 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set) connector->base.id, connector->name); } } - drm_connector_list_iter_put(&conn_iter); + drm_connector_list_iter_end(&conn_iter); /* mode_set_base is not a required function */ if (fb_changed && !crtc_funcs->mode_set_base) @@ -761,10 +761,10 @@ fail: } count = 0; - drm_connector_list_iter_get(dev, &conn_iter); + drm_connector_list_iter_begin(dev, &conn_iter); drm_for_each_connector_iter(connector, &conn_iter) connector->encoder = save_connector_encoders[count++]; - drm_connector_list_iter_put(&conn_iter); + drm_connector_list_iter_end(&conn_iter); /* after fail drop reference on all unbound connectors in set, let * bound connectors keep their reference @@ -794,12 +794,12 @@ static int drm_helper_choose_encoder_dpms(struct drm_encoder *encoder) struct drm_connector_list_iter conn_iter; struct drm_device *dev = encoder->dev; - drm_connector_list_iter_get(dev, &conn_iter); + drm_connector_list_iter_begin(dev, &conn_iter); drm_for_each_connector_iter(connector, &conn_iter) if (connector->encoder == encoder) if (connector->dpms < dpms) dpms = connector->dpms; - drm_connector_list_iter_put(&conn_iter); + drm_connector_list_iter_end(&conn_iter); return dpms; } @@ -835,12 +835,12 @@ static int drm_helper_choose_crtc_dpms(struct drm_crtc *crtc) struct drm_connector_list_iter conn_iter; struct drm_device *dev = crtc->dev; - drm_connector_list_iter_get(dev, &conn_iter); + drm_connector_list_iter_begin(dev, &conn_iter); drm_for_each_connector_iter(connector, &conn_iter) if (connector->encoder && connector->encoder->crtc == crtc) if (connector->dpms < dpms) dpms = connector->dpms; - drm_connector_list_iter_put(&conn_iter); + drm_connector_list_iter_end(&conn_iter); return dpms; } diff --git a/drivers/gpu/drm/drm_encoder.c b/drivers/gpu/drm/drm_encoder.c index 634ae0244ea9..0708779840d2 100644 --- a/drivers/gpu/drm/drm_encoder.c +++ b/drivers/gpu/drm/drm_encoder.c @@ -188,7 +188,7 @@ static struct drm_crtc *drm_encoder_get_crtc(struct drm_encoder *encoder) /* For atomic drivers only state objects are synchronously updated and * protected by modeset locks, so check those first. */ - drm_connector_list_iter_get(dev, &conn_iter); + drm_connector_list_iter_begin(dev, &conn_iter); drm_for_each_connector_iter(connector, &conn_iter) { if (!connector->state) continue; @@ -198,10 +198,10 @@ static struct drm_crtc *drm_encoder_get_crtc(struct drm_encoder *encoder) if (connector->state->best_encoder != encoder) continue; - drm_connector_list_iter_put(&conn_iter); + drm_connector_list_iter_end(&conn_iter); return connector->state->crtc; } - drm_connector_list_iter_put(&conn_iter); + drm_connector_list_iter_end(&conn_iter); /* Don't return stale data (e.g. pending async disable). */ if (uses_atomic) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index b243fdbdbb08..2c92ccf5266a 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -134,7 +134,7 @@ int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper) return 0; mutex_lock(&dev->mode_config.mutex); - drm_connector_list_iter_get(dev, &conn_iter); + drm_connector_list_iter_begin(dev, &conn_iter); drm_for_each_connector_iter(connector, &conn_iter) { ret = drm_fb_helper_add_one_connector(fb_helper, connector); @@ -155,7 +155,7 @@ fail: } fb_helper->connector_count = 0; out: - drm_connector_list_iter_put(&conn_iter); + drm_connector_list_iter_end(&conn_iter); mutex_unlock(&dev->mode_config.mutex); return ret; diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c index 37779b9f0c1e..d9862259a2a7 100644 --- a/drivers/gpu/drm/drm_mode_config.c +++ b/drivers/gpu/drm/drm_mode_config.c @@ -139,19 +139,19 @@ int drm_mode_getresources(struct drm_device *dev, void *data, } card_res->count_encoders = count; - drm_connector_list_iter_get(dev, &conn_iter); + drm_connector_list_iter_begin(dev, &conn_iter); count = 0; connector_id = u64_to_user_ptr(card_res->connector_id_ptr); drm_for_each_connector_iter(connector, &conn_iter) { if (count < card_res->count_connectors && put_user(connector->base.id, connector_id + count)) { - drm_connector_list_iter_put(&conn_iter); + drm_connector_list_iter_end(&conn_iter); return -EFAULT; } count++; } card_res->count_connectors = count; - drm_connector_list_iter_put(&conn_iter); + drm_connector_list_iter_end(&conn_iter); return ret; } @@ -184,11 +184,11 @@ void drm_mode_config_reset(struct drm_device *dev) if (encoder->funcs->reset) encoder->funcs->reset(encoder); - drm_connector_list_iter_get(dev, &conn_iter); + drm_connector_list_iter_begin(dev, &conn_iter); drm_for_each_connector_iter(connector, &conn_iter) if (connector->funcs->reset) connector->funcs->reset(connector); - drm_connector_list_iter_put(&conn_iter); + drm_connector_list_iter_end(&conn_iter); } EXPORT_SYMBOL(drm_mode_config_reset); @@ -412,7 +412,7 @@ void drm_mode_config_cleanup(struct drm_device *dev) encoder->funcs->destroy(encoder); } - drm_connector_list_iter_get(dev, &conn_iter); + drm_connector_list_iter_begin(dev, &conn_iter); drm_for_each_connector_iter(connector, &conn_iter) { /* drm_connector_list_iter holds an full reference to the * current connector itself, which means it is inherently safe @@ -420,12 +420,12 @@ void drm_mode_config_cleanup(struct drm_device *dev) * deleting it right away. */ drm_connector_put(connector); } - drm_connector_list_iter_put(&conn_iter); + drm_connector_list_iter_end(&conn_iter); if (WARN_ON(!list_empty(&dev->mode_config.connector_list))) { - drm_connector_list_iter_get(dev, &conn_iter); + drm_connector_list_iter_begin(dev, &conn_iter); drm_for_each_connector_iter(connector, &conn_iter) DRM_ERROR("connector %s leaked!\n", connector->name); - drm_connector_list_iter_put(&conn_iter); + drm_connector_list_iter_end(&conn_iter); } list_for_each_entry_safe(property, pt, &dev->mode_config.property_list, diff --git a/drivers/gpu/drm/drm_plane_helper.c b/drivers/gpu/drm/drm_plane_helper.c index d8639e46bd2b..244cf2619294 100644 --- a/drivers/gpu/drm/drm_plane_helper.c +++ b/drivers/gpu/drm/drm_plane_helper.c @@ -85,7 +85,7 @@ static int get_connectors_for_crtc(struct drm_crtc *crtc, */ WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex)); - drm_connector_list_iter_get(dev, &conn_iter); + drm_connector_list_iter_begin(dev, &conn_iter); drm_for_each_connector_iter(connector, &conn_iter) { if (connector->encoder && connector->encoder->crtc == crtc) { if (connector_list != NULL && count < num_connectors) @@ -94,7 +94,7 @@ static int get_connectors_for_crtc(struct drm_crtc *crtc, count++; } } - drm_connector_list_iter_put(&conn_iter); + drm_connector_list_iter_end(&conn_iter); return count; } diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c index 358957118ca9..03d376f91c23 100644 --- a/drivers/gpu/drm/drm_probe_helper.c +++ b/drivers/gpu/drm/drm_probe_helper.c @@ -140,13 +140,13 @@ void drm_kms_helper_poll_enable(struct drm_device *dev) if (!dev->mode_config.poll_enabled || !drm_kms_helper_poll) return; - drm_connector_list_iter_get(dev, &conn_iter); + drm_connector_list_iter_begin(dev, &conn_iter); drm_for_each_connector_iter(connector, &conn_iter) { if (connector->polled & (DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT)) poll = true; } - drm_connector_list_iter_put(&conn_iter); + drm_connector_list_iter_end(&conn_iter); if (dev->mode_config.delayed_event) { /* @@ -420,7 +420,7 @@ static void output_poll_execute(struct work_struct *work) goto out; } - drm_connector_list_iter_get(dev, &conn_iter); + drm_connector_list_iter_begin(dev, &conn_iter); drm_for_each_connector_iter(connector, &conn_iter) { /* Ignore forced connectors. */ if (connector->force) @@ -474,7 +474,7 @@ static void output_poll_execute(struct work_struct *work) changed = true; } } - drm_connector_list_iter_put(&conn_iter); + drm_connector_list_iter_end(&conn_iter); mutex_unlock(&dev->mode_config.mutex); @@ -580,7 +580,7 @@ bool drm_helper_hpd_irq_event(struct drm_device *dev) return false; mutex_lock(&dev->mode_config.mutex); - drm_connector_list_iter_get(dev, &conn_iter); + drm_connector_list_iter_begin(dev, &conn_iter); drm_for_each_connector_iter(connector, &conn_iter) { /* Only handle HPD capable connectors. */ if (!(connector->polled & DRM_CONNECTOR_POLL_HPD)) @@ -597,7 +597,7 @@ bool drm_helper_hpd_irq_event(struct drm_device *dev) if (old_status != connector->status) changed = true; } - drm_connector_list_iter_put(&conn_iter); + drm_connector_list_iter_end(&conn_iter); mutex_unlock(&dev->mode_config.mutex); if (changed) diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index e0acdb674d85..ccc0770b2de0 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -926,7 +926,7 @@ void drm_mode_put_tile_group(struct drm_device *dev, * * This iterator tracks state needed to be able to walk the connector_list * within struct drm_mode_config. Only use together with - * drm_connector_list_iter_get(), drm_connector_list_iter_put() and + * drm_connector_list_iter_begin(), drm_connector_list_iter_end() and * drm_connector_list_iter_next() respectively the convenience macro * drm_for_each_connector_iter(). */ @@ -936,11 +936,11 @@ struct drm_connector_list_iter { struct drm_connector *conn; }; -void drm_connector_list_iter_get(struct drm_device *dev, - struct drm_connector_list_iter *iter); +void drm_connector_list_iter_begin(struct drm_device *dev, + struct drm_connector_list_iter *iter); struct drm_connector * drm_connector_list_iter_next(struct drm_connector_list_iter *iter); -void drm_connector_list_iter_put(struct drm_connector_list_iter *iter); +void drm_connector_list_iter_end(struct drm_connector_list_iter *iter); /** * drm_for_each_connector_iter - connector_list iterator macro @@ -948,8 +948,8 @@ void drm_connector_list_iter_put(struct drm_connector_list_iter *iter); * @iter: &struct drm_connector_list_iter * * Note that @connector is only valid within the list body, if you want to use - * @connector after calling drm_connector_list_iter_put() then you need to grab - * your own reference first using drm_connector_get(). + * @connector after calling drm_connector_list_iter_end() then you need to grab + * your own reference first using drm_connector_begin(). */ #define drm_for_each_connector_iter(connector, iter) \ while ((connector = drm_connector_list_iter_next(iter)))