mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux PM <linux-pm@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Lukasz Luba <lukasz.luba@arm.com>,
	Daniel Lezcano <daniel.lezcano@linaro.org>
Subject: [PATCH v1 1/2] thermal: testing: Simplify tt_get_tt_zone()
Date: Sun, 10 Nov 2024 14:04:47 +0100	[thread overview]
Message-ID: <6120304.lOV4Wx5bFT@rjwysocki.net> (raw)
In-Reply-To: <12569620.O9o76ZdvQC@rjwysocki.net>

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Notice that tt_get_tt_zone() need not use the ret variable in
the tt_thermal_zones list walk and make it return right after
incrementing the reference counter of the matching entry.

No functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/thermal/testing/zone.c |    9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

Index: linux-pm/drivers/thermal/testing/zone.c
===================================================================
--- linux-pm.orig/drivers/thermal/testing/zone.c
+++ linux-pm/drivers/thermal/testing/zone.c
@@ -288,19 +288,14 @@ static struct tt_thermal_zone *tt_get_tt
 
 	guard(mutex)(&tt_thermal_zones_lock);
 
-	ret = -EINVAL;
 	list_for_each_entry(tt_zone, &tt_thermal_zones, list_node) {
 		if (tt_zone->id == id) {
 			tt_zone->refcount++;
-			ret = 0;
-			break;
+			return tt_zone;
 		}
 	}
 
-	if (ret)
-		return ERR_PTR(ret);
-
-	return tt_zone;
+	return ERR_PTR(-EINVAL);
 }
 
 static void tt_put_tt_zone(struct tt_thermal_zone *tt_zone)




  reply	other threads:[~2024-11-10 13:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-10 13:03 [PATCH v1 0/2] thermal: testing: Simplifications related to thermal zone template reference counting Rafael J. Wysocki
2024-11-10 13:04 ` Rafael J. Wysocki [this message]
2024-11-10 13:06 ` [PATCH v1 2/2] thermal: testing: Use DEFINE_FREE() and __free() to simplify code Rafael J. Wysocki

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=6120304.lOV4Wx5bFT@rjwysocki.net \
    --to=rjw@rjwysocki.net \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    /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

all inboxes | Powered by JetHome®