From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: dri-devel@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 7/8] drm/client: Move variables to tighter scope
Date: Thu, 3 Oct 2024 17:59:44 +0300 [thread overview]
Message-ID: <Zv6xYL1rBckwFMJS@intel.com> (raw)
In-Reply-To: <20241003113304.11700-8-ville.syrjala@linux.intel.com>
On Thu, Oct 03, 2024 at 02:33:03PM +0300, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Bunch of variables are only needed inside loops and whatnot.
> Move them to a tighter scope to make the code less confusing.
>
> Also replace the 'unsigned int i' footguns with plain signed
> ints.
I moved that last part to a separate patch but forgot
to update the commit message here.
>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
> drivers/gpu/drm/drm_client_modeset.c | 33 +++++++++++++++-------------
> 1 file changed, 18 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_client_modeset.c b/drivers/gpu/drm/drm_client_modeset.c
> index b82bb3119cb2..ccf5c9b5537b 100644
> --- a/drivers/gpu/drm/drm_client_modeset.c
> +++ b/drivers/gpu/drm/drm_client_modeset.c
> @@ -73,9 +73,10 @@ int drm_client_modeset_create(struct drm_client_dev *client)
> static void drm_client_modeset_release(struct drm_client_dev *client)
> {
> struct drm_mode_set *modeset;
> - unsigned int i;
>
> drm_client_for_each_modeset(modeset, client) {
> + unsigned int i;
> +
> drm_mode_destroy(client->dev, modeset->mode);
> modeset->mode = NULL;
> modeset->fb = NULL;
> @@ -277,9 +278,8 @@ static bool drm_client_target_cloned(struct drm_device *dev,
> struct drm_client_offset offsets[],
> bool enabled[], int width, int height)
> {
> - int count, i, j;
> + int count, i;
> bool can_clone = false;
> - const struct drm_display_mode *mode;
> struct drm_display_mode *dmt_mode;
>
> /* only contemplate cloning in the single crtc case */
> @@ -299,6 +299,8 @@ static bool drm_client_target_cloned(struct drm_device *dev,
> /* check the command line or if nothing common pick 1024x768 */
> can_clone = true;
> for (i = 0; i < connector_count; i++) {
> + int j;
> +
> if (!enabled[i])
> continue;
>
> @@ -332,6 +334,8 @@ static bool drm_client_target_cloned(struct drm_device *dev,
> goto fail;
>
> for (i = 0; i < connector_count; i++) {
> + const struct drm_display_mode *mode;
> +
> if (!enabled[i])
> continue;
>
> @@ -365,12 +369,12 @@ static int drm_client_get_tile_offsets(struct drm_device *dev,
> int idx,
> int h_idx, int v_idx)
> {
> - struct drm_connector *connector;
> int i;
> int hoffset = 0, voffset = 0;
>
> for (i = 0; i < connector_count; i++) {
> - connector = connectors[i];
> + struct drm_connector *connector = connectors[i];
> +
> if (!connector->has_tile)
> continue;
>
> @@ -400,7 +404,6 @@ static bool drm_client_target_preferred(struct drm_device *dev,
> bool enabled[], int width, int height)
> {
> const u64 mask = BIT_ULL(connector_count) - 1;
> - struct drm_connector *connector;
> u64 conn_configured = 0;
> int tile_pass = 0;
> int num_tiled_conns = 0;
> @@ -414,9 +417,9 @@ static bool drm_client_target_preferred(struct drm_device *dev,
>
> retry:
> for (i = 0; i < connector_count; i++) {
> + struct drm_connector *connector = connectors[i];
> const char *mode_type;
>
> - connector = connectors[i];
>
> if (conn_configured & BIT_ULL(i))
> continue;
> @@ -526,9 +529,8 @@ static int drm_client_pick_crtcs(struct drm_client_dev *client,
> struct drm_device *dev = client->dev;
> struct drm_connector *connector;
> int my_score, best_score, score;
> - struct drm_crtc **crtcs, *crtc;
> + struct drm_crtc **crtcs;
> struct drm_mode_set *modeset;
> - int o;
>
> if (n == connector_count)
> return 0;
> @@ -558,7 +560,8 @@ static int drm_client_pick_crtcs(struct drm_client_dev *client,
> * remaining connectors
> */
> drm_client_for_each_modeset(modeset, client) {
> - crtc = modeset->crtc;
> + struct drm_crtc *crtc = modeset->crtc;
> + int o;
>
> if (!connector_has_possible_crtc(connector, crtc))
> continue;
> @@ -602,7 +605,7 @@ static bool drm_client_firmware_config(struct drm_client_dev *client,
> const int count = min_t(unsigned int, connector_count, BITS_PER_LONG);
> unsigned long conn_configured, conn_seq, mask;
> struct drm_device *dev = client->dev;
> - int i, j;
> + int i;
> bool *save_enabled;
> bool fallback = true, ret = true;
> int num_connectors_enabled = 0;
> @@ -636,12 +639,11 @@ static bool drm_client_firmware_config(struct drm_client_dev *client,
> retry:
> conn_seq = conn_configured;
> for (i = 0; i < count; i++) {
> - struct drm_connector *connector;
> + struct drm_connector *connector = connectors[i];
> struct drm_encoder *encoder;
> struct drm_crtc *crtc;
> const char *mode_type;
> -
> - connector = connectors[i];
> + int j;
>
> if (conn_configured & BIT(i))
> continue;
> @@ -1204,11 +1206,12 @@ static void drm_client_modeset_dpms_legacy(struct drm_client_dev *client, int dp
> struct drm_connector *connector;
> struct drm_mode_set *modeset;
> struct drm_modeset_acquire_ctx ctx;
> - int j;
> int ret;
>
> DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx, 0, ret);
> drm_client_for_each_modeset(modeset, client) {
> + int j;
> +
> if (!modeset->crtc->enabled)
> continue;
>
> --
> 2.45.2
--
Ville Syrjälä
Intel
next prev parent reply other threads:[~2024-10-03 14:59 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-03 11:32 [PATCH 0/8] drm/client: Stop using legacy crtc->mode and a bunch of cleanups Ville Syrjala
2024-10-03 11:32 ` [PATCH 1/8] drm/client: Constify modes Ville Syrjala
2024-10-04 23:59 ` kernel test robot
2024-10-05 0:19 ` kernel test robot
2024-10-03 11:32 ` [PATCH 2/8] drm/client: Use array notation for function arguments Ville Syrjala
2024-10-03 11:32 ` [PATCH 3/8] drm/client: Streamline mode selection debugs Ville Syrjala
2024-10-03 11:33 ` [PATCH 4/8] drm/client: Make copies of modes Ville Syrjala
2024-10-03 16:45 ` Ville Syrjälä
2024-10-03 18:15 ` [PATCH v2 " Ville Syrjala
2024-10-07 7:36 ` [PATCH " Thomas Zimmermann
2024-10-08 19:33 ` Ville Syrjälä
2024-10-10 19:28 ` Ville Syrjälä
2024-10-09 14:09 ` kernel test robot
2024-10-03 11:33 ` [PATCH 5/8] drm/client: Stop using the legacy crtc->mode Ville Syrjala
2024-10-03 18:16 ` [PATCH v2 " Ville Syrjala
2024-10-03 11:33 ` [PATCH 6/8] drm/client: s/new_crtc/crtc/ Ville Syrjala
2024-10-03 18:17 ` [PATCH v2 " Ville Syrjala
2024-10-03 11:33 ` [PATCH 7/8] drm/client: Move variables to tighter scope Ville Syrjala
2024-10-03 14:59 ` Ville Syrjälä [this message]
2024-10-03 11:33 ` [PATCH 8/8] drm/client: s/unsigned int i/int i/ Ville Syrjala
2024-10-07 7:43 ` Thomas Zimmermann
2024-10-08 19:12 ` Ville Syrjälä
2024-10-09 14:32 ` Jani Nikula
2024-10-03 17:57 ` ✗ Fi.CI.CHECKPATCH: warning for drm/client: Stop using legacy crtc->mode and a bunch of cleanups Patchwork
2024-10-03 18:07 ` ✗ Fi.CI.BAT: failure " Patchwork
2024-10-03 21:40 ` ✗ Fi.CI.CHECKPATCH: warning for drm/client: Stop using legacy crtc->mode and a bunch of cleanups (rev4) Patchwork
2024-10-03 21:49 ` ✓ Fi.CI.BAT: success " Patchwork
2024-10-08 6:36 ` ✓ Fi.CI.IGT: " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zv6xYL1rBckwFMJS@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox