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

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

Merge "msm: BA: Save platform driver in device context"

parents e0660b24 e364bd42
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
/* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -145,6 +145,7 @@ struct msm_ba_input {
struct msm_ba_dev {
	struct mutex dev_cs;

	struct platform_device *pdev;
	enum ba_dev_state state;

	struct list_head inputs;
+37 −12
Original line number Diff line number Diff line
/*
 * Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
 * Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -15,6 +15,7 @@
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/debugfs.h>
#include <linux/io.h>
@@ -289,6 +290,11 @@ static const struct v4l2_file_operations msm_ba_v4l2_ba_fops = {
	.poll = msm_ba_v4l2_poll,
};

static const struct of_device_id msm_ba_dt_match[] = {
	{.compatible = "qcom,msm-ba"},
	{}
};

static int msm_ba_device_init(struct platform_device *pdev,
					struct msm_ba_dev **ret_dev_ctxt)
{
@@ -298,13 +304,27 @@ static int msm_ba_device_init(struct platform_device *pdev,

	dprintk(BA_INFO, "Enter %s", __func__);
	if ((NULL == ret_dev_ctxt) ||
			(NULL != *ret_dev_ctxt))
			(NULL != *ret_dev_ctxt) ||
			(NULL == pdev)) {
		dprintk(BA_ERR, "%s(%d) Invalid params %p %p %p",
			__func__, __LINE__,
			ret_dev_ctxt, *ret_dev_ctxt, pdev);
		return -EINVAL;
	}

	dev_ctxt = kzalloc(sizeof(struct msm_ba_dev), GFP_KERNEL);
	if (NULL == dev_ctxt)
		return -ENOMEM;

	dev_set_drvdata(&pdev->dev, dev_ctxt);
	dev_ctxt->pdev = pdev;
	if (!pdev->dev.of_node) {
		dprintk(BA_ERR, "%s(%d) pdev node is NULL",
			__func__, __LINE__);
		rc = -EINVAL;
		goto err_dev_init;
	}

	INIT_LIST_HEAD(&dev_ctxt->inputs);
	INIT_LIST_HEAD(&dev_ctxt->instances);
	INIT_LIST_HEAD(&dev_ctxt->sd_events);
@@ -362,6 +382,7 @@ static int msm_ba_device_init(struct platform_device *pdev,
		dprintk(BA_ERR, "Failed to register v4l2 device");
	}

err_dev_init:
	if (rc) {
		kfree(dev_ctxt);
		dev_ctxt = NULL;
@@ -371,12 +392,12 @@ static int msm_ba_device_init(struct platform_device *pdev,
	return rc;
}

static int msm_ba_probe(struct platform_device *pdev)
static int msm_ba_probe_ba_device(struct platform_device *pdev)
{
	struct ba_ctxt *ba_ctxt;
	int rc = 0;

	dprintk(BA_INFO, "Enter %s: pdev 0x%p device id = %d",
	dprintk(BA_INFO, "Enter %s: pdev %p device id = %d",
		__func__, pdev, pdev->id);
	ba_ctxt = msm_ba_get_ba_context();

@@ -397,6 +418,15 @@ static int msm_ba_probe(struct platform_device *pdev)
	return rc;
}

static int msm_ba_probe(struct platform_device *pdev)
{
	if (of_device_is_compatible(pdev->dev.of_node, "qcom,msm-ba"))
		return msm_ba_probe_ba_device(pdev);
	/* How did we end up here? */
	BUG();
	return -EINVAL;
}

static int msm_ba_remove(struct platform_device *pdev)
{
	struct msm_ba_dev *dev_ctxt;
@@ -490,11 +520,6 @@ int msm_ba_destroy(void)
	return rc;
}

static const struct of_device_id msm_ba_dt_match[] = {
	{.compatible = "qcom,msm-ba"},
	{}
};

MODULE_DEVICE_TABLE(of, msm_ba_dt_match);

static struct platform_driver msm_ba_driver = {