/* 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 #include #include #include #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");