Skip to content

Commit dc36768

Browse files
AngeloGioacchino Del Regnombgg
authored andcommitted
soc: mediatek: mtk-mutex: Replace max handles number with definition
Replace the magic number "10", defining the maximum number of supported handles with a MTK_MUTEX_MAX_HANDLES definition. While at it, also change the type for `id` from a signed integer to a unsigned 8 bits integer to save some (small) memory footprint, as this number is never higher than 10. This cleanup brings no functional changes. Signed-off-by: AngeloGioacchino Del Regno <[email protected]> Reviewed-by: Chen-Yu Tsai <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Matthias Brugger <[email protected]>
1 parent 00ee1db commit dc36768

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/soc/mediatek/mtk-mutex.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <linux/soc/mediatek/mtk-mutex.h>
1515
#include <linux/soc/mediatek/mtk-cmdq.h>
1616

17+
#define MTK_MUTEX_MAX_HANDLES 10
18+
1719
#define MT2701_MUTEX0_MOD0 0x2c
1820
#define MT2701_MUTEX0_SOF0 0x30
1921
#define MT8183_MUTEX0_MOD0 0x30
@@ -282,7 +284,7 @@
282284
#define MT8195_MUTEX_EOF_DPI1 (MT8195_MUTEX_SOF_DPI1 << 7)
283285

284286
struct mtk_mutex {
285-
int id;
287+
u8 id;
286288
bool claimed;
287289
};
288290

@@ -312,7 +314,7 @@ struct mtk_mutex_ctx {
312314
struct device *dev;
313315
struct clk *clk;
314316
void __iomem *regs;
315-
struct mtk_mutex mutex[10];
317+
struct mtk_mutex mutex[MTK_MUTEX_MAX_HANDLES];
316318
const struct mtk_mutex_data *data;
317319
phys_addr_t addr;
318320
struct cmdq_client_reg cmdq_reg;
@@ -717,7 +719,7 @@ struct mtk_mutex *mtk_mutex_get(struct device *dev)
717719
struct mtk_mutex_ctx *mtx = dev_get_drvdata(dev);
718720
int i;
719721

720-
for (i = 0; i < 10; i++)
722+
for (i = 0; i < MTK_MUTEX_MAX_HANDLES; i++)
721723
if (!mtx->mutex[i].claimed) {
722724
mtx->mutex[i].claimed = true;
723725
return &mtx->mutex[i];
@@ -1007,7 +1009,7 @@ static int mtk_mutex_probe(struct platform_device *pdev)
10071009
if (!mtx)
10081010
return -ENOMEM;
10091011

1010-
for (i = 0; i < 10; i++)
1012+
for (i = 0; i < MTK_MUTEX_MAX_HANDLES; i++)
10111013
mtx->mutex[i].id = i;
10121014

10131015
mtx->data = of_device_get_match_data(dev);

0 commit comments

Comments
 (0)