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

Commit b7a0869a authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "regulator: cpr-regulator: Add panic handler to dump voltage information"

parents e38c12aa 0a652478
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
@@ -404,6 +404,8 @@ struct cpr_regulator {
	bool		skip_voltage_change_during_suspend;

	struct cpr_aging_info	*aging_info;

	struct notifier_block	panic_notifier;
};

#define CPR_DEBUG_MASK_IRQ	BIT(0)
@@ -6022,6 +6024,35 @@ static void cpr_debugfs_base_remove(void)

#endif

/**
 * cpr_panic_callback() - panic notification callback function. This function
 *		is invoked when a kernel panic occurs.
 * @nfb:	Notifier block pointer of CPR regulator
 * @event:	Value passed unmodified to notifier function
 * @data:	Pointer passed unmodified to notifier function
 *
 * Return: NOTIFY_OK
 */
static int cpr_panic_callback(struct notifier_block *nfb,
			unsigned long event, void *data)
{
	struct cpr_regulator *cpr_vreg = container_of(nfb,
				struct cpr_regulator, panic_notifier);
	int corner, fuse_corner, volt;

	corner = cpr_vreg->corner;
	fuse_corner = cpr_vreg->corner_map[corner];
	if (cpr_is_allowed(cpr_vreg))
		volt = cpr_vreg->last_volt[corner];
	else
		volt = cpr_vreg->open_loop_volt[corner];

	cpr_err(cpr_vreg, "[corner:%d, fuse_corner:%d] = %d uV\n",
		corner, fuse_corner, volt);

	return NOTIFY_OK;
}

static int cpr_regulator_probe(struct platform_device *pdev)
{
	struct regulator_config reg_config = {};
@@ -6227,6 +6258,11 @@ static int cpr_regulator_probe(struct platform_device *pdev)
		}
	}

	/* Register panic notification call back */
	cpr_vreg->panic_notifier.notifier_call = cpr_panic_callback;
	atomic_notifier_chain_register(&panic_notifier_list,
			&cpr_vreg->panic_notifier);

	mutex_lock(&cpr_regulator_list_mutex);
	list_add(&cpr_vreg->list, &cpr_regulator_list);
	mutex_unlock(&cpr_regulator_list_mutex);
@@ -6261,6 +6297,9 @@ static int cpr_regulator_remove(struct platform_device *pdev)
			sensor_mgr_remove_threshold(
				&cpr_vreg->tsens_threshold_config);

		atomic_notifier_chain_unregister(&panic_notifier_list,
			&cpr_vreg->panic_notifier);

		cpr_apc_exit(cpr_vreg);
		cpr_debugfs_remove(cpr_vreg);
		regulator_unregister(cpr_vreg->rdev);