diff options
| author | Yi-wei Zhao <gbjc64@motorola.com> | 2014-03-31 19:28:35 -0500 |
|---|---|---|
| committer | Mister Oyster <oysterized@gmail.com> | 2017-05-20 21:09:02 +0200 |
| commit | 132b594a8555216dfd7fe52824aae394eab4c231 (patch) | |
| tree | 33fa4318b8682ba084d142627319a06164fe5696 | |
| parent | 5ced4c41cdf4e845211737cc2a77c7f77189a4ee (diff) | |
fs:pstore:ramoops: config mem from dt
configure the start & size of ramoops memory using device tree.
the "dummy" device is no harm as long as initial mem_size is zero.
Conflicts:
fs/pstore/ram.c
Cherry-picked from: bc4df1ea67057fa2117aa6f5b5a967d2ca2cc846
Change-Id: I756e933bea072399cb80ffd78dc79a42b448fed9
Signed-off-by: Yi-wei Zhao <gbjc64@motorola.com>
Reviewed-by: Jeffrey Carlyle <jeff.carlyle@motorola.com>
Signed-off-by: Patrick Tjin <pattjin@google.com>
| -rw-r--r-- | fs/pstore/ram.c | 63 |
1 files changed, 62 insertions, 1 deletions
diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index 8e9309101..e5cc1094b 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -34,6 +34,7 @@ #include <linux/slab.h> #include <linux/compiler.h> #include <linux/pstore_ram.h> +#include <linux/of.h> #define RAMOOPS_KERNMSG_HDR "====" #define MIN_MEM_SIZE 4096UL @@ -419,15 +420,74 @@ void notrace ramoops_console_write_buf(const char *buf, size_t size) persistent_ram_write(cxt->cprz, buf, size); } +#ifdef CONFIG_OF +static struct of_device_id ramoops_of_match[] = { + { .compatible = "ramoops", }, + { }, +}; + +MODULE_DEVICE_TABLE(of, ramoops_of_match); +static void ramoops_of_init(struct platform_device *pdev) +{ + const struct device *dev = &pdev->dev; + struct ramoops_platform_data *pdata; + struct device_node *np = pdev->dev.of_node; + u32 start, size, console; + int ret; + + pdata = dev_get_drvdata(dev); + if (!pdata) { + pr_err("private data is empty!\n"); + return; + } + ret = of_property_read_u32(np, "android,ramoops-buffer-start", + &start); + if (ret) + return; + + ret = of_property_read_u32(np, "android,ramoops-buffer-size", + &size); + if (ret) + return; + + ret = of_property_read_u32(np, "android,ramoops-console-size", + &console); + if (ret) + return; + + pdata->mem_address = start; + pdata->mem_size = size; + pdata->console_size = console; +} +#else +static inline void ramoops_of_init(struct platform_device *pdev) +{ + return; +} +#endif + static int ramoops_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct ramoops_platform_data *pdata = pdev->dev.platform_data; + struct ramoops_platform_data *pdata; struct ramoops_context *cxt = &oops_cxt; size_t dump_mem_sz; phys_addr_t paddr; int err = -EINVAL; + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) { + pr_err("could not allocate ramoops_platform_data\n"); + return -ENOMEM; + } + + err = dev_set_drvdata(dev, pdata); + if (err) + goto fail_out; + + if (pdev->dev.of_node) + ramoops_of_init(pdev); + /* Only a single ramoops area allowed at a time, so fail extra * probes. */ @@ -566,6 +626,7 @@ static struct platform_driver ramoops_driver = { .remove = __exit_p(ramoops_remove), .driver = { .name = "ramoops", + .of_match_table = of_match_ptr(ramoops_of_match), .owner = THIS_MODULE, }, }; |
