mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
2f289a8cf3
Update the driver to support backward compatibility for devices relying on board files for platform data. CRs-Fixed: 592586 Bug: 12784954 Change-Id: I04d4195a7fd4b926e52b0cbb2bb33cfcc054689f Signed-off-by: Pratibhasagar V <pratibha@codeaurora.org> Signed-off-by: Mekala Natarajan <mekalan@codeaurora.org>
82 lines
2.1 KiB
C
82 lines
2.1 KiB
C
/* Copyright (c) 2013, 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
|
|
* only version 2 as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*/
|
|
|
|
#define pr_fmt(fmt) "%s: " fmt, __func__
|
|
|
|
#include <linux/uio_driver.h>
|
|
#include <linux/module.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/err.h>
|
|
|
|
#define DRIVER_NAME "msm_sharedmem"
|
|
|
|
static int msm_sharedmem_probe(struct platform_device *pdev)
|
|
{
|
|
int ret = 0;
|
|
struct uio_info *info = NULL;
|
|
struct resource *clnt_res = NULL;
|
|
|
|
/* Get the addresses from platform-data */
|
|
clnt_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
if (!clnt_res) {
|
|
pr_err("resource not found\n");
|
|
return -ENODEV;
|
|
}
|
|
|
|
info = devm_kzalloc(&pdev->dev, sizeof(struct uio_info), GFP_KERNEL);
|
|
if (!info)
|
|
return -ENOMEM;
|
|
|
|
info->name = clnt_res->name;
|
|
info->version = "1.0";
|
|
info->mem[0].addr = clnt_res->start;
|
|
info->mem[0].size = resource_size(clnt_res);
|
|
info->mem[0].memtype = UIO_MEM_PHYS;
|
|
|
|
/* Setup device */
|
|
ret = uio_register_device(&pdev->dev, info);
|
|
if (ret)
|
|
goto out;
|
|
|
|
dev_set_drvdata(&pdev->dev, info);
|
|
pr_debug("Device created for client '%s'\n", clnt_res->name);
|
|
out:
|
|
return ret;
|
|
}
|
|
|
|
static int msm_sharedmem_remove(struct platform_device *pdev)
|
|
{
|
|
struct uio_info *info = dev_get_drvdata(&pdev->dev);
|
|
|
|
uio_unregister_device(info);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static struct of_device_id msm_sharedmem_of_match[] = {
|
|
{.compatible = "qcom,sharedmem-uio",},
|
|
{},
|
|
};
|
|
MODULE_DEVICE_TABLE(of, msm_sharedmem_of_match);
|
|
|
|
static struct platform_driver msm_sharedmem_driver = {
|
|
.probe = msm_sharedmem_probe,
|
|
.remove = msm_sharedmem_remove,
|
|
.driver = {
|
|
.name = DRIVER_NAME,
|
|
.owner = THIS_MODULE,
|
|
.of_match_table = msm_sharedmem_of_match,
|
|
},
|
|
};
|
|
|
|
module_platform_driver(msm_sharedmem_driver);
|
|
MODULE_LICENSE("GPL v2");
|