diff options
author | David Kershner <david.kershner@unisys.com> | 2016-09-19 17:09:22 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-09-20 07:27:28 -0400 |
commit | 612b81c9315c60f3ab921cf87e1740e087a103de (patch) | |
tree | b59580ecec826176622e3069a2533068d9ff1e5e /drivers/staging | |
parent | 1b1d463d08be0785b48ad8b23446ac13f726a60b (diff) |
staging: unisys: visorbus: move parser_init_byte_stream
The function parser_init_byte_stream needs to be moved lower in the file to
avoid extraneous function prototypes.
Reported-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: David Kershner <david.kershner@unisys.com>
Reviewed-by: Tim Sell <Timothy.Sell@unisys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/unisys/visorbus/visorchipset.c | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 8081160720a4..47504a6a889a 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c | |||
@@ -334,64 +334,6 @@ static void controlvm_respond_physdev_changestate( | |||
334 | 334 | ||
335 | static void parser_done(struct parser_context *ctx); | 335 | static void parser_done(struct parser_context *ctx); |
336 | 336 | ||
337 | static struct parser_context * | ||
338 | parser_init_byte_stream(u64 addr, u32 bytes, bool local, bool *retry) | ||
339 | { | ||
340 | int allocbytes = sizeof(struct parser_context) + bytes; | ||
341 | struct parser_context *ctx; | ||
342 | |||
343 | if (retry) | ||
344 | *retry = false; | ||
345 | |||
346 | /* | ||
347 | * alloc an 0 extra byte to ensure payload is | ||
348 | * '\0'-terminated | ||
349 | */ | ||
350 | allocbytes++; | ||
351 | if ((controlvm_payload_bytes_buffered + bytes) | ||
352 | > MAX_CONTROLVM_PAYLOAD_BYTES) { | ||
353 | if (retry) | ||
354 | *retry = true; | ||
355 | return NULL; | ||
356 | } | ||
357 | ctx = kzalloc(allocbytes, GFP_KERNEL | __GFP_NORETRY); | ||
358 | if (!ctx) { | ||
359 | if (retry) | ||
360 | *retry = true; | ||
361 | return NULL; | ||
362 | } | ||
363 | |||
364 | ctx->allocbytes = allocbytes; | ||
365 | ctx->param_bytes = bytes; | ||
366 | ctx->curr = NULL; | ||
367 | ctx->bytes_remaining = 0; | ||
368 | ctx->byte_stream = false; | ||
369 | if (local) { | ||
370 | void *p; | ||
371 | |||
372 | if (addr > virt_to_phys(high_memory - 1)) | ||
373 | goto err_finish_ctx; | ||
374 | p = __va((unsigned long)(addr)); | ||
375 | memcpy(ctx->data, p, bytes); | ||
376 | } else { | ||
377 | void *mapping = memremap(addr, bytes, MEMREMAP_WB); | ||
378 | |||
379 | if (!mapping) | ||
380 | goto err_finish_ctx; | ||
381 | memcpy(ctx->data, mapping, bytes); | ||
382 | memunmap(mapping); | ||
383 | } | ||
384 | |||
385 | ctx->byte_stream = true; | ||
386 | controlvm_payload_bytes_buffered += ctx->param_bytes; | ||
387 | |||
388 | return ctx; | ||
389 | |||
390 | err_finish_ctx: | ||
391 | parser_done(ctx); | ||
392 | return NULL; | ||
393 | } | ||
394 | |||
395 | static uuid_le | 337 | static uuid_le |
396 | parser_id_get(struct parser_context *ctx) | 338 | parser_id_get(struct parser_context *ctx) |
397 | { | 339 | { |
@@ -1906,6 +1848,64 @@ visorchipset_file_cleanup(dev_t major_dev) | |||
1906 | unregister_chrdev_region(major_dev, 1); | 1848 | unregister_chrdev_region(major_dev, 1); |
1907 | } | 1849 | } |
1908 | 1850 | ||
1851 | static struct parser_context * | ||
1852 | parser_init_byte_stream(u64 addr, u32 bytes, bool local, bool *retry) | ||
1853 | { | ||
1854 | int allocbytes = sizeof(struct parser_context) + bytes; | ||
1855 | struct parser_context *ctx; | ||
1856 | |||
1857 | if (retry) | ||
1858 | *retry = false; | ||
1859 | |||
1860 | /* | ||
1861 | * alloc an 0 extra byte to ensure payload is | ||
1862 | * '\0'-terminated | ||
1863 | */ | ||
1864 | allocbytes++; | ||
1865 | if ((controlvm_payload_bytes_buffered + bytes) | ||
1866 | > MAX_CONTROLVM_PAYLOAD_BYTES) { | ||
1867 | if (retry) | ||
1868 | *retry = true; | ||
1869 | return NULL; | ||
1870 | } | ||
1871 | ctx = kzalloc(allocbytes, GFP_KERNEL | __GFP_NORETRY); | ||
1872 | if (!ctx) { | ||
1873 | if (retry) | ||
1874 | *retry = true; | ||
1875 | return NULL; | ||
1876 | } | ||
1877 | |||
1878 | ctx->allocbytes = allocbytes; | ||
1879 | ctx->param_bytes = bytes; | ||
1880 | ctx->curr = NULL; | ||
1881 | ctx->bytes_remaining = 0; | ||
1882 | ctx->byte_stream = false; | ||
1883 | if (local) { | ||
1884 | void *p; | ||
1885 | |||
1886 | if (addr > virt_to_phys(high_memory - 1)) | ||
1887 | goto err_finish_ctx; | ||
1888 | p = __va((unsigned long)(addr)); | ||
1889 | memcpy(ctx->data, p, bytes); | ||
1890 | } else { | ||
1891 | void *mapping = memremap(addr, bytes, MEMREMAP_WB); | ||
1892 | |||
1893 | if (!mapping) | ||
1894 | goto err_finish_ctx; | ||
1895 | memcpy(ctx->data, mapping, bytes); | ||
1896 | memunmap(mapping); | ||
1897 | } | ||
1898 | |||
1899 | ctx->byte_stream = true; | ||
1900 | controlvm_payload_bytes_buffered += ctx->param_bytes; | ||
1901 | |||
1902 | return ctx; | ||
1903 | |||
1904 | err_finish_ctx: | ||
1905 | parser_done(ctx); | ||
1906 | return NULL; | ||
1907 | } | ||
1908 | |||
1909 | /** | 1909 | /** |
1910 | * handle_command() - process a controlvm message | 1910 | * handle_command() - process a controlvm message |
1911 | * @inmsg: the message to process | 1911 | * @inmsg: the message to process |