From patchwork Sun Jan 12 13:47:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13936410 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 626C8E77188 for ; Sun, 12 Jan 2025 13:47:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DA2A110E30B; Sun, 12 Jan 2025 13:47:13 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="axFLEGq9"; dkim-atps=neutral Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by gabe.freedesktop.org (Postfix) with ESMTPS id A84C310E30B for ; Sun, 12 Jan 2025 13:47:13 +0000 (UTC) Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-5d3e5c225aaso703835a12.3 for ; Sun, 12 Jan 2025 05:47:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736689632; x=1737294432; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=RBnsV3mFkJmXnRbQqOXQC7xiyTGmF2RqY1RW5wKJo0U=; b=axFLEGq9CIIjS2GzhoJ9aSN9qXXQ1e78kme77IWTFGLgpQFuBIIXPsSiBEO1YwGLul SeF8Hmyhx3IiEQOXtg7PB93kDjDlnk7amFT4UPbowMkhebH79/tjqkpU4TfMEesuxx34 OreyYrJLrCtaguDEDwG25itWn/laLGURcKd6kLSVFRUrhxH0kp3igRSVtEPIXWpyY9Zc ze/fpkhxJBNftdWG/4cCXWGhWUKaiirpwUFgTGqtnQdvXYi+R0NJw1uu4y2k9lQ2qMYP ptsZqEhIC0EbNpGhSvf/n1MNTKVeNDhMp0m/FzmQzt5B5XO5JcUzr+CT1sWO/C5N655I Roxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736689632; x=1737294432; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=RBnsV3mFkJmXnRbQqOXQC7xiyTGmF2RqY1RW5wKJo0U=; b=b6GS13auFFHGWSgfhzSWnwyDKx1ky2WevH4Q8c1zEtaoBe1TJK+IoYuYbRJXR4LRTa kO5pAtu+OsC9EJfTiFBjVa15rSrsHLSCNSDLxSkjTwdu88I1NHW6dy+rxZvVIen3P03Y y4V7EQIW3qgMSCDK6XkPFce7qqDrKBobQOcrlsD8/WNSLndIeXzUOqFxnIVbEUDVTdyn 29ao/HpxymYfUj+mRFudk1VKBrSZHkum6nzwDk0TZoCAK2sdqMQP61E0sYcYtAmHDaWE ADIEBH8XrZAkQzFj0x/jJPH69J9geB9Bk+RNJHrSlqEHjY+as+TMQnDr/Sj9rUGug8KB k3Cg== X-Forwarded-Encrypted: i=1; AJvYcCV9crzIpvNxXORj4oU0ulH7NiXGosMuAE8K0TQverIKYePJFkZ92SslqU1KjeYag/LTPPShIV97GsA=@lists.freedesktop.org X-Gm-Message-State: AOJu0YwR3O/amoGypQiXVI14u3BYPLdlFvrqeO5GdP47Gy3VcmW258QB Ok863Gl1OUOfAp+dSKu+Xr/XMrO0LOM2taozwvODHQ11wS2eZ88bhd9X6z5xHIqcuV15+pKuR7x P X-Gm-Gg: ASbGnct/YBrmCI1kKbNqSFs4i2qtcqcs4Zalrvm5zhuPzmnWIsLgOKgF0/AKprgaJR5 RpqU7Tv99hFtIuWfGRtD1R056RrAlJQNzIu/17hNCT7BLy0lJIW11KFweCxlOZeCMU2MO1A+fWo ih8aHEg+RuwGl9iWEuBnT/itLxmT0+F7XzadQaJsfT4X5giB/Dj4seGFQogT8FNikHv9G/xG9Gy 3NT2+PGcpoxhqFpSuu9j+FPZqHt/Oc3TWo4+LauMWDVPDHdWlgByuCcmY7BMSM+O9L+TOs= X-Google-Smtp-Source: AGHT+IE5jjxbpuHLDjgHBaaKsQqbYx5oIutu5BOQFvdU7mITc2KX+nB9WMaHa1nRj5jMwrSpxOe8VQ== X-Received: by 2002:a17:906:c10f:b0:aa6:9631:9237 with SMTP id a640c23a62f3a-ab2ab6cd374mr674812366b.10.1736689631988; Sun, 12 Jan 2025 05:47:11 -0800 (PST) Received: from krzk-bin.. ([178.197.223.165]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab2c9060c00sm374899866b.41.2025.01.12.05.47.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jan 2025 05:47:11 -0800 (PST) From: Krzysztof Kozlowski To: Chun-Kuang Hu , Philipp Zabel , David Airlie , Simona Vetter , Matthias Brugger , AngeloGioacchino Del Regno , dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Krzysztof Kozlowski Subject: [PATCH 1/2] drm/mediatek/hdmi: Use syscon_regmap_lookup_by_phandle_args Date: Sun, 12 Jan 2025 14:47:07 +0100 Message-ID: <20250112134708.46100-1-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Use syscon_regmap_lookup_by_phandle_args() which is a wrapper over syscon_regmap_lookup_by_phandle() combined with getting the syscon argument. Except simpler code this annotates within one line that given phandle has arguments, so grepping for code would be easier. There is also no real benefit in printing errors on missing syscon argument, because this is done just too late: runtime check on static/build-time data. Dtschema and Devicetree bindings offer the static/build-time check for this already. Signed-off-by: Krzysztof Kozlowski --- drivers/gpu/drm/mediatek/mtk_hdmi.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c index ca82bc829cb9..4b0eb7dc25d8 100644 --- a/drivers/gpu/drm/mediatek/mtk_hdmi.c +++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c @@ -1458,15 +1458,11 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi, * MMSYS_CONFIG device and the register offset of the HDMI_SYS_CFG * registers it contains. */ - regmap = syscon_regmap_lookup_by_phandle(np, "mediatek,syscon-hdmi"); - ret = of_property_read_u32_index(np, "mediatek,syscon-hdmi", 1, - &hdmi->sys_offset); - if (IS_ERR(regmap)) - ret = PTR_ERR(regmap); - if (ret) { - dev_err(dev, - "Failed to get system configuration registers: %d\n", - ret); + regmap = syscon_regmap_lookup_by_phandle_args(np, "mediatek,syscon-hdmi", + 1, &hdmi->sys_offset); + if (IS_ERR(regmap)) { + ret = dev_err_probe(dev, PTR_ERR(regmap), + "Failed to get system configuration registers\n"); goto put_device; } hdmi->sys_regmap = regmap; From patchwork Sun Jan 12 13:47:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13936412 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BF556E77188 for ; Sun, 12 Jan 2025 13:48:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4E0BE10E3B5; Sun, 12 Jan 2025 13:48:15 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="lnYE9l1C"; dkim-atps=neutral Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 99EA610E321 for ; Sun, 12 Jan 2025 13:48:14 +0000 (UTC) Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-5d3e5c225aaso703841a12.3 for ; Sun, 12 Jan 2025 05:48:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736689633; x=1737294433; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0DoP8JyX0Rn+t869X/69C5AdIYY282FJMkh2+vYUqvg=; b=lnYE9l1CMZ4FRhfmH5KzoTeM+/RfqJ8f4IUWTGkSWAp6OzEBzWCp4T2+s6DWxVfiPf E5i3HzFcEXGob1WcY8KJSqvPlBnT5cSgGGGOIPWTkcz+F0N7dkPZwv1AC8apoJerkzh1 uZ8epByNpTl7GsVaYWaWP02Q6p4BH8MG6pKJM3u1EDRV+WlQjBKe44SA6KYq0GoOv1Wq /iklnQTVPjYia5kHEsii3AJf8erHC1nOtF35b/78xSgjNj/B8sCskGvNpVgssBsok4CA jkRHIoOS3FzdFMZLK5c1CSEEZCwD7L7yzY9n4sz8gZOrakLt9t90nm298RO4l5tLQcEG Pz5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736689633; x=1737294433; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0DoP8JyX0Rn+t869X/69C5AdIYY282FJMkh2+vYUqvg=; b=mo51KV2p2u7TopaZ+XuHJTVYKwDsOdWvVWdvJGsRojsgWBHBZHs0GO6bgSPFJZB+xe daVI0nVlRNEy9CygdAo3VanKX+yHH4+BpOjc2CYy/Q128CTjGQl49VHKP1uaGPBdcOZ9 5jX18xusMqsrl6RfA/0T8NbArLFeYCLGPxaHjoAyvPgBPgKpwOXtRMUoT+UM+vJ0QUdf V7qzm02CgitxF32wA48vdEgb6SY7WyIsXQ180yYE9ONzAj1bEWEjH83+VAkNV8dlTn79 sJBDAhwkPFCd1WqUnaio67qYR0zdEJj4FAwUjaVp8hGcr6LkBgD/mu5S2ayAe37PPcl2 ycaw== X-Forwarded-Encrypted: i=1; AJvYcCWA54MnaJsAAiQYf1oO/48yArzVuQEXEk1fZs83GxSpuJp5HZnZv8NWERxwIS+PorcFaS3necC2Zfs=@lists.freedesktop.org X-Gm-Message-State: AOJu0Yzo6eWcCFWq2wVuwrOYvAC9D+sSD7jJx6fX1bOAfCGEK/jd3XZx yI5G86vEr4UvfepErPctORRUd8xVf7MOUvbQU2OsOpXbmvrD0Dfqg7nKcRy34/CqUSYLbuCbEAQ o X-Gm-Gg: ASbGncvddMSKHRCyhFs9YxxWey6J4YtTOERkLXdnQH5dntQpymthKyGPy9a93HGzXDi rbdkLoBJzTnm25NLbpxFNpyEsqoI9dwBJwDvLt9Wc7j4O9tSc7+h0DLtKYfxYZVDKlenNQuI5qv bJ6v/eyt4P0M0/Ddm80BG8VQQZpa+zpFa6i7DXjgOezWbazqtgyVjv9sYGO4od+UpM3JJz6UgkK 3mME7U2AGU/tOpL6v9esIq26umtYgzlkbmCcnqXcPnsz8RiELGQqI7dxQh3V5VTdIPClAA= X-Google-Smtp-Source: AGHT+IEHAXrRzzhrt3gFm4JeAOOOtrjD1qbFZyqfcMZ+AbnWgJcTH3bD4AwNeCzDVpq7CMRHO0fkfA== X-Received: by 2002:a17:907:8689:b0:a9a:2afc:e4ef with SMTP id a640c23a62f3a-ab2ab60355cmr584894566b.7.1736689633230; Sun, 12 Jan 2025 05:47:13 -0800 (PST) Received: from krzk-bin.. ([178.197.223.165]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab2c9060c00sm374899866b.41.2025.01.12.05.47.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jan 2025 05:47:12 -0800 (PST) From: Krzysztof Kozlowski To: Chun-Kuang Hu , Philipp Zabel , David Airlie , Simona Vetter , Matthias Brugger , AngeloGioacchino Del Regno , dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Krzysztof Kozlowski Subject: [PATCH 2/2] drm/mediatek/hdmi: Simplify with dev_err_probe Date: Sun, 12 Jan 2025 14:47:08 +0100 Message-ID: <20250112134708.46100-2-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250112134708.46100-1-krzysztof.kozlowski@linaro.org> References: <20250112134708.46100-1-krzysztof.kozlowski@linaro.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Use dev_err_probe() to make error code and deferred probe handling simpler. Signed-off-by: Krzysztof Kozlowski --- drivers/gpu/drm/mediatek/mtk_hdmi.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c index 4b0eb7dc25d8..22935fdc5afe 100644 --- a/drivers/gpu/drm/mediatek/mtk_hdmi.c +++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c @@ -1429,19 +1429,13 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi, int ret; ret = mtk_hdmi_get_all_clk(hdmi, np); - if (ret) { - if (ret != -EPROBE_DEFER) - dev_err(dev, "Failed to get clocks: %d\n", ret); - - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "Failed to get clocks\n"); /* The CEC module handles HDMI hotplug detection */ cec_np = of_get_compatible_child(np->parent, "mediatek,mt8173-cec"); - if (!cec_np) { - dev_err(dev, "Failed to find CEC node\n"); - return -EINVAL; - } + if (!cec_np) + return dev_err_probe(dev, -EINVAL, "Failed to find CEC node\n"); cec_pdev = of_find_device_by_node(cec_np); if (!cec_pdev) { @@ -1492,10 +1486,9 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi, i2c_np = of_parse_phandle(remote, "ddc-i2c-bus", 0); if (!i2c_np) { - dev_err(dev, "Failed to find ddc-i2c-bus node in %pOF\n", - remote); + ret = dev_err_probe(dev, -EINVAL, "Failed to find ddc-i2c-bus node in %pOF\n", + remote); of_node_put(remote); - ret = -EINVAL; goto put_device; } of_node_put(remote); @@ -1503,8 +1496,7 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi, hdmi->ddc_adpt = of_find_i2c_adapter_by_node(i2c_np); of_node_put(i2c_np); if (!hdmi->ddc_adpt) { - dev_err(dev, "Failed to get ddc i2c adapter by node\n"); - ret = -EINVAL; + ret = dev_err_probe(dev, -EINVAL, "Failed to get ddc i2c adapter by node\n"); goto put_device; }