Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 47aaacc8 authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy
Browse files

power: batterydata-lib: Define is_between() as a macro



Currently is_between() is defined as a function only based on
some CONFIG options whereas it can be really useful in other
places too. Remove the function definitions for is_between()
in batterydata-lib files and define it as a macro so that it
can be used just with including batterydata-lib.h.

Change-Id: Iafe8f867b97e5d6e2e8d75ad14c13bf4d4e7f7fb
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent 4fe162d7
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -25,15 +25,6 @@ int linear_interpolate(int y0, int x0, int y1, int x1, int x)
	return y0 + ((y1 - y0) * (x - x0) / (x1 - x0));
}

int is_between(int left, int right, int value)
{
	if (left >= right && left >= value && value >= right)
		return 1;
	if (left <= right && left <= value && value <= right)
		return 1;
	return 0;
}

static int interpolate_single_lut_scaled(struct single_row_lut *lut,
						int x, int scale)
{
+6 −5
Original line number Diff line number Diff line
@@ -140,6 +140,12 @@ struct bms_battery_data {
	const char		*battery_type;
};

#define is_between(left, right, value) \
		(((left) >= (right) && (left) >= (value) \
			&& (value) >= (right)) \
		|| ((left) <= (right) && (left) <= (value) \
			&& (value) <= (right)))

#if defined(CONFIG_PM8921_BMS) || \
	defined(CONFIG_PM8921_BMS_MODULE) || \
	defined(CONFIG_QPNP_BMS) || \
@@ -163,7 +169,6 @@ int interpolate_slope(struct pc_temp_ocv_lut *pc_temp_ocv,
int interpolate_acc(struct ibat_temp_acc_lut *ibat_acc_lut,
					int batt_temp, int ibat);
int linear_interpolate(int y0, int x0, int y1, int x1, int x);
int is_between(int left, int right, int value);
#else
static inline int interpolate_fcc(struct single_row_lut *fcc_temp_lut,
			int batt_temp)
@@ -199,10 +204,6 @@ static inline int linear_interpolate(int y0, int x0, int y1, int x1, int x)
{
	return -EINVAL;
}
static inline int is_between(int left, int right, int value)
{
	return -EINVAL;
}
static inline int interpolate_acc(struct ibat_temp_acc_lut *ibat_acc_lut,
						int batt_temp, int ibat)
{