Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

clk: qcom: smd-rpm: simplify locking with guard()

Simplify error handling (less gotos) over locks with guard().

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240823-cleanup-h-guard-clk-qcom-v1-2-68bb9601c9dd@linaro.org
Signed-off-by: Bjorn Andersson <andersson@kernel.org>

authored by

Krzysztof Kozlowski and committed by
Bjorn Andersson
e534612e e18e8bbb

+10 -15
+10 -15
drivers/clk/qcom/clk-smd-rpm.c
··· 4 4 * Copyright (c) 2014, The Linux Foundation. All rights reserved. 5 5 */ 6 6 7 + #include <linux/cleanup.h> 7 8 #include <linux/clk-provider.h> 8 9 #include <linux/err.h> 9 10 #include <linux/export.h> ··· 310 309 unsigned long active_rate, sleep_rate; 311 310 int ret; 312 311 313 - mutex_lock(&rpm_smd_clk_lock); 312 + guard(mutex)(&rpm_smd_clk_lock); 314 313 315 314 if (!r->rate) 316 - goto out; 315 + return; 317 316 318 317 /* Take peer clock's rate into account only if it's enabled. */ 319 318 if (peer->enabled) ··· 323 322 active_rate = r->branch ? !!peer_rate : peer_rate; 324 323 ret = clk_smd_rpm_set_rate_active(r, active_rate); 325 324 if (ret) 326 - goto out; 325 + return; 327 326 328 327 sleep_rate = r->branch ? !!peer_sleep_rate : peer_sleep_rate; 329 328 ret = clk_smd_rpm_set_rate_sleep(r, sleep_rate); 330 329 if (ret) 331 - goto out; 330 + return; 332 331 333 332 r->enabled = false; 334 - 335 - out: 336 - mutex_unlock(&rpm_smd_clk_lock); 337 333 } 338 334 339 335 static int clk_smd_rpm_set_rate(struct clk_hw *hw, unsigned long rate, ··· 343 345 unsigned long peer_rate = 0, peer_sleep_rate = 0; 344 346 int ret = 0; 345 347 346 - mutex_lock(&rpm_smd_clk_lock); 348 + guard(mutex)(&rpm_smd_clk_lock); 347 349 348 350 if (!r->enabled) 349 - goto out; 351 + return 0; 350 352 351 353 to_active_sleep(r, rate, &this_rate, &this_sleep_rate); 352 354 ··· 358 360 active_rate = max(this_rate, peer_rate); 359 361 ret = clk_smd_rpm_set_rate_active(r, active_rate); 360 362 if (ret) 361 - goto out; 363 + return ret; 362 364 363 365 sleep_rate = max(this_sleep_rate, peer_sleep_rate); 364 366 ret = clk_smd_rpm_set_rate_sleep(r, sleep_rate); 365 367 if (ret) 366 - goto out; 368 + return ret; 367 369 368 370 r->rate = rate; 369 371 370 - out: 371 - mutex_unlock(&rpm_smd_clk_lock); 372 - 373 - return ret; 372 + return 0; 374 373 } 375 374 376 375 static long clk_smd_rpm_round_rate(struct clk_hw *hw, unsigned long rate,