Skip to content

Commit 62b5848

Browse files
author
Bartosz Golaszewski
committed
power: sequencing: add defines for return values of the match() callback
Instead of using 0 and 1 as magic numbers, let's add proper defines whose names tell the reader what the meaning behind them is. Reviewed-by: Ulf Hansson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 1a7312b commit 62b5848

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

drivers/power/sequencing/core.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ static int pwrseq_match_device(struct device *pwrseq_dev, void *data)
628628
return 0;
629629

630630
ret = pwrseq->match(pwrseq, match_data->dev);
631-
if (ret <= 0)
631+
if (ret == PWRSEQ_NO_MATCH || ret < 0)
632632
return ret;
633633

634634
/* We got the matching device, let's find the right target. */
@@ -651,7 +651,7 @@ static int pwrseq_match_device(struct device *pwrseq_dev, void *data)
651651

652652
match_data->desc->pwrseq = pwrseq_device_get(pwrseq);
653653

654-
return 1;
654+
return PWRSEQ_MATCH_OK;
655655
}
656656

657657
/**
@@ -684,7 +684,7 @@ struct pwrseq_desc *pwrseq_get(struct device *dev, const char *target)
684684
pwrseq_match_device);
685685
if (ret < 0)
686686
return ERR_PTR(ret);
687-
if (ret == 0)
687+
if (ret == PWRSEQ_NO_MATCH)
688688
/* No device matched. */
689689
return ERR_PTR(-EPROBE_DEFER);
690690

include/linux/pwrseq/provider.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ struct pwrseq_device;
1313
typedef int (*pwrseq_power_state_func)(struct pwrseq_device *);
1414
typedef int (*pwrseq_match_func)(struct pwrseq_device *, struct device *);
1515

16+
#define PWRSEQ_NO_MATCH 0
17+
#define PWRSEQ_MATCH_OK 1
18+
1619
/**
1720
* struct pwrseq_unit_data - Configuration of a single power sequencing
1821
* unit.

0 commit comments

Comments
 (0)