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

Commit 3fb78b35 authored by Xiaozhe Shi's avatar Xiaozhe Shi Committed by Abhijeet Dharmapurikar
Browse files

power: pmic-voter: add debug logs for votes



Add a name for each pmic votable registered, and add some debug logs
when votes are cast and when the final value is changed.

Change-Id: I0cce9c6140162d8409af4060ebc6247b18ddfa3a
Signed-off-by: default avatarXiaozhe Shi <xiaozhes@codeaurora.org>
Signed-off-by: default avatarAbhijeet Dharmapurikar <adharmap@codeaurora.org>
parent f795a613
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ struct client_vote {
struct votable {
	struct client_vote	votes[NUM_MAX_CLIENTS];
	struct device		*dev;
	const char		*name;
	int			num_clients;
	int			type;
	int			effective_client_id;
@@ -149,6 +150,9 @@ int vote(struct votable *votable, int client_id, int state, int val)
	votable->votes[client_id].state = state;
	votable->votes[client_id].value = val;

	pr_debug("%s: %d voting for %d - %s\n",
			votable->name,
			client_id, val, state ? "on" : "off");
	switch (votable->type) {
	case VOTE_MIN:
		effective_id = vote_min(votable);
@@ -177,6 +181,8 @@ int vote(struct votable *votable, int client_id, int state, int val)
	if (effective_result != votable->effective_result) {
		votable->effective_client_id = effective_id;
		votable->effective_result = effective_result;
		pr_debug("%s: effective vote is now %d voted by %d",
				votable->name, effective_result, effective_id);
		rc = votable->callback(votable->dev, effective_result,
					effective_id, val, client_id);
	}
@@ -189,7 +195,8 @@ out:
	return rc;
}

struct votable *create_votable(struct device *dev, int votable_type,
struct votable *create_votable(struct device *dev, const char *name,
					int votable_type,
					int num_clients,
					int (*callback)(struct device *dev,
							int effective_result,
@@ -220,6 +227,7 @@ struct votable *create_votable(struct device *dev, int votable_type,
	}

	votable->dev = dev;
	votable->name = name;
	votable->num_clients = num_clients;
	votable->callback = callback;
	votable->type = votable_type;
+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ int get_effective_result_locked(struct votable *votable);
int get_effective_client_id(struct votable *votable);
int get_effective_client_id_locked(struct votable *votable);
int vote(struct votable *votable, int client_id, int state, int val);
struct votable *create_votable(struct device *dev,
struct votable *create_votable(struct device *dev, const char *name,
					int votable_type, int num_clients,
					int (*callback)(struct device *dev,
							int effective_result,
+18 −6
Original line number Diff line number Diff line
@@ -7212,32 +7212,44 @@ static int smbchg_probe(struct spmi_device *spmi)
		return -ENOMEM;
	}

	chip->fcc_votable = create_votable(&spmi->dev, VOTE_MIN,
	chip->fcc_votable = create_votable(&spmi->dev,
			"SMBCHG: fcc",
			VOTE_MIN,
			NUM_FCC_VOTER, set_fastchg_current_vote_cb);
	if (IS_ERR(chip->fcc_votable))
		return PTR_ERR(chip->fcc_votable);

	chip->usb_icl_votable = create_votable(&spmi->dev, VOTE_MIN,
	chip->usb_icl_votable = create_votable(&spmi->dev,
			"SMBCHG: usb_icl",
			VOTE_MIN,
			NUM_ICL_VOTER, set_usb_current_limit_vote_cb);
	if (IS_ERR(chip->usb_icl_votable))
		return PTR_ERR(chip->usb_icl_votable);

	chip->dc_icl_votable = create_votable(&spmi->dev, VOTE_MIN,
	chip->dc_icl_votable = create_votable(&spmi->dev,
			"SMBCHG: dcl_icl",
			VOTE_MIN,
			NUM_ICL_VOTER, set_dc_current_limit_vote_cb);
	if (IS_ERR(chip->dc_icl_votable))
		return PTR_ERR(chip->dc_icl_votable);

	chip->usb_suspend_votable = create_votable(&spmi->dev, VOTE_SET_ANY,
	chip->usb_suspend_votable = create_votable(&spmi->dev,
					"SMBCHG: usb_suspend",
					VOTE_SET_ANY,
					NUM_EN_VOTERS, usb_suspend_vote_cb);
	if (IS_ERR(chip->usb_suspend_votable))
		return PTR_ERR(chip->usb_suspend_votable);

	chip->dc_suspend_votable = create_votable(&spmi->dev, VOTE_SET_ANY,
	chip->dc_suspend_votable = create_votable(&spmi->dev,
					"SMBCHG: dc_suspend",
					VOTE_SET_ANY,
					NUM_EN_VOTERS, dc_suspend_vote_cb);
	if (IS_ERR(chip->dc_suspend_votable))
		return PTR_ERR(chip->dc_suspend_votable);

	chip->battchg_suspend_votable = create_votable(&spmi->dev, VOTE_SET_ANY,
	chip->battchg_suspend_votable = create_votable(&spmi->dev,
					"SMBCHG: battchg_en",
					VOTE_SET_ANY,
					NUM_BATTCHG_EN_VOTERS,
					charging_suspend_vote_cb);
	if (IS_ERR(chip->dc_suspend_votable))