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

Commit 71644d76 authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "sensors: ssc: Add restart interface for SLPI"

parents 8174ea9d 267a8637
Loading
Loading
Loading
Loading
+47 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@

#define IMAGE_LOAD_CMD 1
#define IMAGE_UNLOAD_CMD 0
#define SSR_RESET_CMD 1
#define CLASS_NAME	"ssc"
#define DRV_NAME	"sensors"
#define DRV_VERSION	"2.00"
@@ -53,6 +54,10 @@ static ssize_t slpi_boot_store(struct kobject *kobj,
	struct kobj_attribute *attr,
	const char *buf, size_t count);

static ssize_t slpi_ssr_store(struct kobject *kobj,
	struct kobj_attribute *attr,
	const char *buf, size_t count);

struct slpi_loader_private {
	void *pil_h;
	struct kobject *boot_slpi_obj;
@@ -62,8 +67,12 @@ struct slpi_loader_private {
static struct kobj_attribute slpi_boot_attribute =
	__ATTR(boot, 0220, NULL, slpi_boot_store);

static struct kobj_attribute slpi_ssr_attribute =
	__ATTR(ssr, 0220, NULL, slpi_ssr_store);

static struct attribute *attrs[] = {
	&slpi_boot_attribute.attr,
	&slpi_ssr_attribute.attr,
	NULL,
};

@@ -138,6 +147,44 @@ static void slpi_loader_unload(struct platform_device *pdev)
	}
}

static ssize_t slpi_ssr_store(struct kobject *kobj,
	struct kobj_attribute *attr,
	const char *buf,
	size_t count)
{
	int ssr_cmd = 0;
	struct subsys_device *sns_dev = NULL;
	struct platform_device *pdev = slpi_private;
	struct slpi_loader_private *priv = NULL;

	pr_debug("%s: going to call slpi_ssr\n", __func__);

	if (kstrtoint(buf, 10, &ssr_cmd) < 0)
		return -EINVAL;

	if (ssr_cmd != SSR_RESET_CMD)
		return -EINVAL;

	priv = platform_get_drvdata(pdev);
	if (!priv)
		return -EINVAL;

	sns_dev = (struct subsys_device *)priv->pil_h;
	if (!sns_dev)
		return -EINVAL;

	dev_err(&pdev->dev, "Something went wrong with SLPI, restarting\n");

	/* subsystem_restart_dev has worker queue to handle */
	if (subsystem_restart_dev(sns_dev) != 0) {
		dev_err(&pdev->dev, "subsystem_restart_dev failed\n");
		return -EINVAL;
	}

	dev_dbg(&pdev->dev, "SLPI restarted\n");
	return count;
}

static ssize_t slpi_boot_store(struct kobject *kobj,
	struct kobj_attribute *attr,
	const char *buf,