|
12 | 12 | #include <linux/ctype.h>
|
13 | 13 | #include <linux/debugfs.h>
|
14 | 14 | #include <linux/delay.h>
|
| 15 | +#include <linux/minmax.h> |
15 | 16 | #include <linux/module.h>
|
16 | 17 | #include <linux/moduleparam.h>
|
17 | 18 | #include <linux/seq_file.h>
|
@@ -1470,7 +1471,6 @@ static int cs_dsp_load(struct cs_dsp *dsp, const struct firmware *firmware,
|
1470 | 1471 | const struct wmfw_region *region;
|
1471 | 1472 | const struct cs_dsp_region *mem;
|
1472 | 1473 | const char *region_name;
|
1473 |
| - char *text = NULL; |
1474 | 1474 | struct cs_dsp_buf *buf;
|
1475 | 1475 | unsigned int reg;
|
1476 | 1476 | int regions = 0;
|
@@ -1542,27 +1542,22 @@ static int cs_dsp_load(struct cs_dsp *dsp, const struct firmware *firmware,
|
1542 | 1542 |
|
1543 | 1543 | region_name = "Unknown";
|
1544 | 1544 | reg = 0;
|
1545 |
| - text = NULL; |
1546 | 1545 | offset = le32_to_cpu(region->offset) & 0xffffff;
|
1547 | 1546 | type = be32_to_cpu(region->type) & 0xff;
|
1548 | 1547 |
|
1549 | 1548 | switch (type) {
|
| 1549 | + case WMFW_INFO_TEXT: |
1550 | 1550 | case WMFW_NAME_TEXT:
|
1551 |
| - region_name = "Firmware name"; |
1552 |
| - text = kzalloc(le32_to_cpu(region->len) + 1, |
1553 |
| - GFP_KERNEL); |
| 1551 | + region_name = "Info/Name"; |
| 1552 | + cs_dsp_info(dsp, "%s: %.*s\n", file, |
| 1553 | + min(le32_to_cpu(region->len), 100), region->data); |
1554 | 1554 | break;
|
1555 | 1555 | case WMFW_ALGORITHM_DATA:
|
1556 | 1556 | region_name = "Algorithm";
|
1557 | 1557 | ret = cs_dsp_parse_coeff(dsp, region);
|
1558 | 1558 | if (ret != 0)
|
1559 | 1559 | goto out_fw;
|
1560 | 1560 | break;
|
1561 |
| - case WMFW_INFO_TEXT: |
1562 |
| - region_name = "Information"; |
1563 |
| - text = kzalloc(le32_to_cpu(region->len) + 1, |
1564 |
| - GFP_KERNEL); |
1565 |
| - break; |
1566 | 1561 | case WMFW_ABSOLUTE:
|
1567 | 1562 | region_name = "Absolute";
|
1568 | 1563 | reg = offset;
|
@@ -1596,13 +1591,6 @@ static int cs_dsp_load(struct cs_dsp *dsp, const struct firmware *firmware,
|
1596 | 1591 | regions, le32_to_cpu(region->len), offset,
|
1597 | 1592 | region_name);
|
1598 | 1593 |
|
1599 |
| - if (text) { |
1600 |
| - memcpy(text, region->data, le32_to_cpu(region->len)); |
1601 |
| - cs_dsp_info(dsp, "%s: %s\n", file, text); |
1602 |
| - kfree(text); |
1603 |
| - text = NULL; |
1604 |
| - } |
1605 |
| - |
1606 | 1594 | if (reg) {
|
1607 | 1595 | buf = cs_dsp_buf_alloc(region->data,
|
1608 | 1596 | le32_to_cpu(region->len),
|
@@ -1644,7 +1632,6 @@ static int cs_dsp_load(struct cs_dsp *dsp, const struct firmware *firmware,
|
1644 | 1632 | out_fw:
|
1645 | 1633 | regmap_async_complete(regmap);
|
1646 | 1634 | cs_dsp_buf_free(&buf_list);
|
1647 |
| - kfree(text); |
1648 | 1635 |
|
1649 | 1636 | if (ret == -EOVERFLOW)
|
1650 | 1637 | cs_dsp_err(dsp, "%s: file content overflows file data\n", file);
|
@@ -2177,7 +2164,6 @@ static int cs_dsp_load_coeff(struct cs_dsp *dsp, const struct firmware *firmware
|
2177 | 2164 | struct cs_dsp_alg_region *alg_region;
|
2178 | 2165 | const char *region_name;
|
2179 | 2166 | int ret, pos, blocks, type, offset, reg, version;
|
2180 |
| - char *text = NULL; |
2181 | 2167 | struct cs_dsp_buf *buf;
|
2182 | 2168 |
|
2183 | 2169 | if (!firmware)
|
@@ -2246,7 +2232,8 @@ static int cs_dsp_load_coeff(struct cs_dsp *dsp, const struct firmware *firmware
|
2246 | 2232 | region_name = "Unknown";
|
2247 | 2233 | switch (type) {
|
2248 | 2234 | case (WMFW_NAME_TEXT << 8):
|
2249 |
| - text = kzalloc(le32_to_cpu(blk->len) + 1, GFP_KERNEL); |
| 2235 | + cs_dsp_info(dsp, "%s: %.*s\n", dsp->fw_name, |
| 2236 | + min(le32_to_cpu(blk->len), 100), blk->data); |
2250 | 2237 | break;
|
2251 | 2238 | case (WMFW_INFO_TEXT << 8):
|
2252 | 2239 | case (WMFW_METADATA << 8):
|
@@ -2318,13 +2305,6 @@ static int cs_dsp_load_coeff(struct cs_dsp *dsp, const struct firmware *firmware
|
2318 | 2305 | break;
|
2319 | 2306 | }
|
2320 | 2307 |
|
2321 |
| - if (text) { |
2322 |
| - memcpy(text, blk->data, le32_to_cpu(blk->len)); |
2323 |
| - cs_dsp_info(dsp, "%s: %s\n", dsp->fw_name, text); |
2324 |
| - kfree(text); |
2325 |
| - text = NULL; |
2326 |
| - } |
2327 |
| - |
2328 | 2308 | if (reg) {
|
2329 | 2309 | buf = cs_dsp_buf_alloc(blk->data,
|
2330 | 2310 | le32_to_cpu(blk->len),
|
@@ -2364,7 +2344,6 @@ static int cs_dsp_load_coeff(struct cs_dsp *dsp, const struct firmware *firmware
|
2364 | 2344 | out_fw:
|
2365 | 2345 | regmap_async_complete(regmap);
|
2366 | 2346 | cs_dsp_buf_free(&buf_list);
|
2367 |
| - kfree(text); |
2368 | 2347 |
|
2369 | 2348 | if (ret == -EOVERFLOW)
|
2370 | 2349 | cs_dsp_err(dsp, "%s: file content overflows file data\n", file);
|
|
0 commit comments