From: Markus Elfring <Markus.Elfring@web.de>
To: Philipp Zabel <p.zabel@pengutronix.de>,
kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org,
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] reset: Further simplify locking with guard()
Date: Sun, 29 Sep 2024 12:45:27 +0200 [thread overview]
Message-ID: <b050730e-ac7d-401b-8210-82453d05b0e5@web.de> (raw)
In-Reply-To: <20240927-reset-guard-v1-1-293bf1302210@pengutronix.de>
> Use guard(mutex) to automatically unlock mutexes when going out of
> scope. Simplify error paths by removing a goto and manual mutex
> unlocking in multiple places.
…
> +++ b/drivers/reset/core.c
…
@@ -1041,29 +1036,27 @@ __of_reset_control_get(struct device_node *node, const char *id, int index,
}
}
- mutex_lock(&reset_list_mutex);
+ guard(mutex)(&reset_list_mutex);
rcdev = __reset_find_rcdev(&args, gpio_fallback);
…
rstc = __reset_control_get_internal(rcdev, rstc_id, shared, acquired);
-out_unlock:
- mutex_unlock(&reset_list_mutex);
out_put:
of_node_put(args.np);
…
Would you like to preserve the same lock scope (which ended before this function call)?
@@ -1098,7 +1091,7 @@ __reset_control_get_from_lookup(struct device *dev, const char *con_id,
const char *dev_id = dev_name(dev);
struct reset_control *rstc = NULL;
- mutex_lock(&reset_lookup_mutex);
+ guard(mutex)(&reset_lookup_mutex);
list_for_each_entry(lookup, &reset_lookup_list, list) {
…
break;
}
}
- mutex_unlock(&reset_lookup_mutex);
-
if (!rstc)
return optional ? NULL : ERR_PTR(-ENOENT);
…
Would you really like to increase the lock scope here?
Regards,
Markus
next prev parent reply other threads:[~2024-09-29 10:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-27 14:02 Philipp Zabel
2024-09-28 22:27 ` [heads-up] " Al Viro
2024-09-29 18:48 ` Krzysztof Kozlowski
2024-09-30 15:22 ` Philipp Zabel
2024-09-29 7:39 ` kernel test robot
2024-09-29 10:45 ` Markus Elfring [this message]
2024-09-30 15:26 ` Philipp Zabel
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=b050730e-ac7d-401b-8210-82453d05b0e5@web.de \
--to=markus.elfring@web.de \
--cc=kernel-janitors@vger.kernel.org \
--cc=kernel@pengutronix.de \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
/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
Powered by JetHome