Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1496611ybj; Tue, 5 May 2020 22:54:10 -0700 (PDT) X-Google-Smtp-Source: APiQypKgSN6HBrHJ5va02G74dbmdZ1v1CgvReKBXBer/PRh42Nk7y0bpy5hGcrVF1T48tAU7VfKE X-Received: by 2002:a17:906:a857:: with SMTP id dx23mr6119184ejb.52.1588744450475; Tue, 05 May 2020 22:54:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588744450; cv=none; d=google.com; s=arc-20160816; b=zowdIwy2pScRLUHlgE9leGJuH7zFFLGei9SNSjRcBi36kFwxD167CskFsaMgIiBGZa M91h/IcWgxOMiX7FGqt+MUuX0ImnKLTQBo+Jm1JiFrWyV5kVxrRZoF60xrQ7tZRTiyBE YAiqVf7I9aGf+j9qrXL5DD6Wn9zyK4sPAPBomH7+3e41/ohvhe7GUR/FwszasuyAY1TS VB0HzgUIc8FZ2VnoOgmtoNyhqT4tiLUzlPwEc1cxBfPuCyStfKmssJsXNjMpTjSMJBgV yMXMsWLCXpDB5V0kCdalPYM7gurzYj7HIoEUPME+cTnRfKxCOBK3OQgBn2tj89vVYmKm 9F9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PM4gOtd4M5rNomz6Zqy7hM5rWWUrGbMfSwGqTPRg+r8=; b=Z08YGRVZkG96sLH+GDWwEI4fEQ9jvRmSBcX7eVpT8ppS8waAWGakVE7CoPXQBKusIa OTblYe+8wLdnBgqjAPfx9e9c4lvMvzeYTG5tzN5N2/Gz6CRF5mD64ZqxRuUnBE+LJQPj w/xTJQCVdBklk+VRzPhamNDqHUWJq4h4jdm8LdCWjJ7MYf71R9kv+nXpjFEJZ9tcl083 kRU+UtG4fJ2k8MgK1SotpBR5lNZJr16talJrUPMl6QTnEear9eMPksUs+za+LWdaKS8d O1sLCuuybl2PKI8F7YJL0TgLjLYSDVDV9Fwoxk8+6VZKJiXFdydgTeXKYlo995FVzwFz LAaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="Nuse4U//"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y24si570106ejr.132.2020.05.05.22.53.43; Tue, 05 May 2020 22:54:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="Nuse4U//"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727831AbgEFFun (ORCPT + 99 others); Wed, 6 May 2020 01:50:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727824AbgEFFum (ORCPT ); Wed, 6 May 2020 01:50:42 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A523FC061A10 for ; Tue, 5 May 2020 22:50:42 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id a7so336722pju.2 for ; Tue, 05 May 2020 22:50:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PM4gOtd4M5rNomz6Zqy7hM5rWWUrGbMfSwGqTPRg+r8=; b=Nuse4U//1dIw0hvi5grcLxpOnLlYQvg45dm/2J1rPsqcpfRdWq+WukMyMaVSOzpPzO 5Oy0ft/YP77n8K8IYNoF/uJl44Nyfabz3jfSjJiykUGXFXesQ8MUkwpgvKetO4iEgCfG /w+3C8uEbBjR1RW44mv4rXNm5eXHp+fwU2Pak= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PM4gOtd4M5rNomz6Zqy7hM5rWWUrGbMfSwGqTPRg+r8=; b=TMUzjNBoooNF8iqbz0tqXCXT3H/8UbZcaPiJptZ55YgbnwEgWkdYZsloR/rROsS654 gX8vua/M9fH9EejY410hBmyqjiqlhoS5SaMzmSTg/l8B2yOlZKbWx+32MKd+BuqODdyO VmUDhZ+HWxzcafT8Q302iuzRoSZIF43FKqA9r1r0+j+bn8DiqpuUEsIwWxj/Dxg0ImwN RVzpTY4Sche5f7SGF3dnSXu3kvncqWyQc8XCUR8MOXQHzTPakaVpmFStgktRD6pYmfXL 73sAm/1IWyYFz6cgmarK4NPoAhQzH89vsTVD5AfPZE9LQ54BauROwG0jMpTiQGVS8g3Q ADcA== X-Gm-Message-State: AGi0PuYQ1mnvaQ4ugVaqaU8z56E6qaJ/LWyK2aCXq+eFOQuB+Cpk43Bd Gtlx1ZTaGfLG8Hs3cPME/aSteu15c6k= X-Received: by 2002:a17:902:a706:: with SMTP id w6mr6196148plq.173.1588744241767; Tue, 05 May 2020 22:50:41 -0700 (PDT) Received: from localhost ([2401:fa00:9:14:a92f:c47d:76a8:b09e]) by smtp.gmail.com with ESMTPSA id u5sm622227pfu.198.2020.05.05.22.50.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 May 2020 22:50:41 -0700 (PDT) From: Eizan Miyamoto To: LKML Cc: Eizan Miyamoto , Andrew-CT Chen , Houlong Wei , Matthias Brugger , Mauro Carvalho Chehab , Minghsiu Tsai , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH v2 5/5] [media] mtk-mdp: Remove mtk_mdp_comp.id and supporting functionality Date: Wed, 6 May 2020 15:49:20 +1000 Message-Id: <20200506154832.v2.5.I1c85bddc262913b8572d892dd6bf9bc03fbe0ec7@changeid> X-Mailer: git-send-email 2.26.2.526.g744177e7f7-goog In-Reply-To: <20200506054920.109738-1-eizan@chromium.org> References: <20200506054920.109738-1-eizan@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since components are registered in a list, the numeric component id that specified a location in an array is not necessary. Signed-off-by: eizan@chromium.org Signed-off-by: Eizan Miyamoto --- Changes in v1: - rebase onto linux-next/master to pick up 757570f11fa4b0ce5472a6583de6f06e996a8527 drivers/media/platform/mtk-mdp/mtk_mdp_comp.c | 60 +++---------------- drivers/media/platform/mtk-mdp/mtk_mdp_comp.h | 19 +----- drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 10 +--- 3 files changed, 11 insertions(+), 78 deletions(-) diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c index da2bdad7a8d1..362fff924aef 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c @@ -14,46 +14,6 @@ #include "mtk_mdp_comp.h" -static const char * const mtk_mdp_comp_stem[MTK_MDP_COMP_TYPE_MAX] = { - "mdp-rdma", - "mdp-rsz", - "mdp-wdma", - "mdp-wrot", -}; - -struct mtk_mdp_comp_match { - enum mtk_mdp_comp_type type; - int alias_id; -}; - -static const struct mtk_mdp_comp_match mtk_mdp_matches[MTK_MDP_COMP_ID_MAX] = { - { MTK_MDP_RDMA, 0 }, - { MTK_MDP_RDMA, 1 }, - { MTK_MDP_RSZ, 0 }, - { MTK_MDP_RSZ, 1 }, - { MTK_MDP_RSZ, 2 }, - { MTK_MDP_WDMA, 0 }, - { MTK_MDP_WROT, 0 }, - { MTK_MDP_WROT, 1 }, -}; - -int mtk_mdp_comp_get_id(struct device *dev, struct device_node *node, - enum mtk_mdp_comp_type comp_type) -{ - int id = of_alias_get_id(node, mtk_mdp_comp_stem[comp_type]); - int i; - - for (i = 0; i < ARRAY_SIZE(mtk_mdp_matches); i++) { - if (comp_type == mtk_mdp_matches[i].type && - id == mtk_mdp_matches[i].alias_id) - return i; - } - - dev_err(dev, "Failed to get id. type: %d, id: %d\n", comp_type, id); - - return -EINVAL; -} - void mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp) { int i, err; @@ -62,8 +22,8 @@ void mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp) err = mtk_smi_larb_get(comp->larb_dev); if (err) dev_err(dev, - "failed to get larb, err %d. type:%d id:%d\n", - err, comp->type, comp->id); + "failed to get larb, err %d. type:%d\n", + err, comp->type); } for (i = 0; i < ARRAY_SIZE(comp->clk); i++) { @@ -72,8 +32,8 @@ void mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp) err = clk_prepare_enable(comp->clk[i]); if (err) dev_err(dev, - "failed to enable clock, err %d. type:%d id:%d i:%d\n", - err, comp->type, comp->id, i); + "failed to enable clock, err %d. type:%d i:%d\n", + err, comp->type, i); } } @@ -92,21 +52,15 @@ void mtk_mdp_comp_clock_off(struct device *dev, struct mtk_mdp_comp *comp) } int mtk_mdp_comp_init(struct device *dev, struct device_node *node, - struct mtk_mdp_comp *comp, enum mtk_mdp_comp_id comp_id) + struct mtk_mdp_comp *comp, + enum mtk_mdp_comp_type comp_type) { struct device_node *larb_node; struct platform_device *larb_pdev; int i; - if (comp_id < 0 || comp_id >= MTK_MDP_COMP_ID_MAX) { - dev_err(dev, "Invalid comp_id %d\n", comp_id); - return -EINVAL; - } - - INIT_LIST_HEAD(&comp->node); comp->dev_node = of_node_get(node); - comp->id = comp_id; - comp->type = mtk_mdp_matches[comp_id].type; + comp->type = comp_type; for (i = 0; i < ARRAY_SIZE(comp->clk); i++) { comp->clk[i] = of_clk_get(node, i); diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h index 1f745891c6c3..1bf0242cce46 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h @@ -22,18 +22,6 @@ enum mtk_mdp_comp_type { MTK_MDP_COMP_TYPE_MAX, }; -enum mtk_mdp_comp_id { - MTK_MDP_COMP_RDMA0, - MTK_MDP_COMP_RDMA1, - MTK_MDP_COMP_RSZ0, - MTK_MDP_COMP_RSZ1, - MTK_MDP_COMP_RSZ2, - MTK_MDP_COMP_WDMA, - MTK_MDP_COMP_WROT0, - MTK_MDP_COMP_WROT1, - MTK_MDP_COMP_ID_MAX, -}; - /** * struct mtk_mdp_comp - the MDP's function component data * @node: list node to track sibing MDP components @@ -41,7 +29,6 @@ enum mtk_mdp_comp_id { * @clk: clocks required for component * @larb_dev: SMI device required for component * @type: component type - * @id: component ID */ struct mtk_mdp_comp { struct list_head node; @@ -49,14 +36,12 @@ struct mtk_mdp_comp { struct clk *clk[2]; struct device *larb_dev; enum mtk_mdp_comp_type type; - enum mtk_mdp_comp_id id; }; int mtk_mdp_comp_init(struct device *dev, struct device_node *node, - struct mtk_mdp_comp *comp, enum mtk_mdp_comp_id comp_id); + struct mtk_mdp_comp *comp, + enum mtk_mdp_comp_type comp_type); void mtk_mdp_comp_deinit(struct device *dev, struct mtk_mdp_comp *comp); -int mtk_mdp_comp_get_id(struct device *dev, struct device_node *node, - enum mtk_mdp_comp_type comp_type); void mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp); void mtk_mdp_comp_clock_off(struct device *dev, struct mtk_mdp_comp *comp); diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c index 40b9fda8b03b..acbc5a01ae4c 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c @@ -137,7 +137,6 @@ static int mtk_mdp_probe(struct platform_device *pdev) for_each_child_of_node(parent, node) { const struct of_device_id *of_id; enum mtk_mdp_comp_type comp_type; - int comp_id; of_id = of_match_node(mtk_mdp_comp_dt_ids, node); if (!of_id) @@ -150,12 +149,7 @@ static int mtk_mdp_probe(struct platform_device *pdev) } comp_type = (enum mtk_mdp_comp_type)of_id->data; - comp_id = mtk_mdp_comp_get_id(dev, node, comp_type); - if (comp_id < 0) { - dev_warn(dev, "Skipping unknown component %pOF\n", - node); - continue; - } + comp = devm_kzalloc(dev, sizeof(*comp), GFP_KERNEL); if (!comp) { @@ -164,7 +158,7 @@ static int mtk_mdp_probe(struct platform_device *pdev) goto err_comp; } - ret = mtk_mdp_comp_init(dev, node, comp, comp_id); + ret = mtk_mdp_comp_init(dev, node, comp, comp_type); if (ret) { of_node_put(node); goto err_comp; -- 2.26.2.526.g744177e7f7-goog