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 <angelogioacchino.delregno@collabora.com>
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Link: https://lore.kernel.org/r/20230222094253.23678-7-angelogioacchino.delregno@collabora.com
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
This commit is contained in:
AngeloGioacchino Del Regno 2023-02-22 10:42:50 +01:00 committed by Matthias Brugger
parent 00ee1db701
commit dc36768d05
1 changed files with 6 additions and 4 deletions

View File

@ -14,6 +14,8 @@
#include <linux/soc/mediatek/mtk-mutex.h> #include <linux/soc/mediatek/mtk-mutex.h>
#include <linux/soc/mediatek/mtk-cmdq.h> #include <linux/soc/mediatek/mtk-cmdq.h>
#define MTK_MUTEX_MAX_HANDLES 10
#define MT2701_MUTEX0_MOD0 0x2c #define MT2701_MUTEX0_MOD0 0x2c
#define MT2701_MUTEX0_SOF0 0x30 #define MT2701_MUTEX0_SOF0 0x30
#define MT8183_MUTEX0_MOD0 0x30 #define MT8183_MUTEX0_MOD0 0x30
@ -282,7 +284,7 @@
#define MT8195_MUTEX_EOF_DPI1 (MT8195_MUTEX_SOF_DPI1 << 7) #define MT8195_MUTEX_EOF_DPI1 (MT8195_MUTEX_SOF_DPI1 << 7)
struct mtk_mutex { struct mtk_mutex {
int id; u8 id;
bool claimed; bool claimed;
}; };
@ -312,7 +314,7 @@ struct mtk_mutex_ctx {
struct device *dev; struct device *dev;
struct clk *clk; struct clk *clk;
void __iomem *regs; void __iomem *regs;
struct mtk_mutex mutex[10]; struct mtk_mutex mutex[MTK_MUTEX_MAX_HANDLES];
const struct mtk_mutex_data *data; const struct mtk_mutex_data *data;
phys_addr_t addr; phys_addr_t addr;
struct cmdq_client_reg cmdq_reg; struct cmdq_client_reg cmdq_reg;
@ -717,7 +719,7 @@ struct mtk_mutex *mtk_mutex_get(struct device *dev)
struct mtk_mutex_ctx *mtx = dev_get_drvdata(dev); struct mtk_mutex_ctx *mtx = dev_get_drvdata(dev);
int i; int i;
for (i = 0; i < 10; i++) for (i = 0; i < MTK_MUTEX_MAX_HANDLES; i++)
if (!mtx->mutex[i].claimed) { if (!mtx->mutex[i].claimed) {
mtx->mutex[i].claimed = true; mtx->mutex[i].claimed = true;
return &mtx->mutex[i]; return &mtx->mutex[i];
@ -1007,7 +1009,7 @@ static int mtk_mutex_probe(struct platform_device *pdev)
if (!mtx) if (!mtx)
return -ENOMEM; return -ENOMEM;
for (i = 0; i < 10; i++) for (i = 0; i < MTK_MUTEX_MAX_HANDLES; i++)
mtx->mutex[i].id = i; mtx->mutex[i].id = i;
mtx->data = of_device_get_match_data(dev); mtx->data = of_device_get_match_data(dev);