From nobody Thu Nov 14 05:27:56 2024 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBBD7C04E69 for ; Tue, 8 Aug 2023 19:53:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234322AbjHHTxh (ORCPT ); Tue, 8 Aug 2023 15:53:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234181AbjHHTxV (ORCPT ); Tue, 8 Aug 2023 15:53:21 -0400 X-Greylist: delayed 64 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 08 Aug 2023 11:03:59 PDT Received: from exchange.fintech.ru (exchange.fintech.ru [195.54.195.159]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D27B1A58A6; Tue, 8 Aug 2023 11:03:59 -0700 (PDT) Received: from Ex16-01.fintech.ru (10.0.10.18) by exchange.fintech.ru (195.54.195.169) with Microsoft SMTP Server (TLS) id 14.3.498.0; Tue, 8 Aug 2023 21:02:52 +0300 Received: from localhost (10.0.253.138) by Ex16-01.fintech.ru (10.0.10.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Tue, 8 Aug 2023 21:02:51 +0300 From: Nikita Zhandarovich To: David Airlie , Daniel Vetter , Maarten Lankhorst , Matthias Brugger , Alex Deucher , "Alain Volmat" CC: Nikita Zhandarovich , Maxime Ripard , Thomas Zimmermann , Jani Nikula , Joonas Lahtinen , Chun-Kuang Hu , Philipp Zabel , =?UTF-8?q?Christian=20K=C3=B6nig?= , "Pan, Xinhui" , "Thierry Reding" , Mikko Perttunen , Jonathan Hunter , Emma Anholt , Helge Deller , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Ankit Nautiyal , , , , , , , , , Subject: [PATCH] video/hdmi: convert *_infoframe_init() functions to void Date: Tue, 8 Aug 2023 11:02:45 -0700 Message-ID: <20230808180245.7474-1-n.zhandarovich@fintech.ru> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.0.253.138] X-ClientProxiedBy: Ex16-02.fintech.ru (10.0.10.19) To Ex16-01.fintech.ru (10.0.10.18) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Four hdmi_*_infoframe_init() functions that initialize different types of hdmi infoframes only return the default 0 value, contrary to their descriptions. Yet these functions are still unnecessarily checked against possible errors in case of failure. Remove redundant error checks in calls to following functions: - hdmi_spd_infoframe_init - hdmi_audio_infoframe_init - hdmi_vendor_infoframe_init - hdmi_drm_infoframe_init Also, convert these functions to 'void' and fix their descriptions. Fixes: 2c676f378edb ("[media] hdmi: added unpack and logging functions for = InfoFrames") Signed-off-by: Nikita Zhandarovich --- drivers/gpu/drm/display/drm_hdmi_helper.c | 5 +--- drivers/gpu/drm/drm_edid.c | 5 +--- drivers/gpu/drm/i915/display/intel_hdmi.c | 7 ++--- drivers/gpu/drm/mediatek/mtk_hdmi.c | 14 ++-------- drivers/gpu/drm/radeon/r600_hdmi.c | 6 +--- drivers/gpu/drm/sti/sti_hdmi.c | 6 +--- drivers/gpu/drm/tegra/hdmi.c | 7 +---- drivers/gpu/drm/tegra/sor.c | 6 +--- drivers/gpu/drm/vc4/vc4_hdmi.c | 7 +---- drivers/video/hdmi.c | 46 ++++++---------------------= ---- include/linux/hdmi.h | 10 +++---- 11 files changed, 25 insertions(+), 94 deletions(-) diff --git a/drivers/gpu/drm/display/drm_hdmi_helper.c b/drivers/gpu/drm/di= splay/drm_hdmi_helper.c index faf5e9efa7d3..ce7038a3a183 100644 --- a/drivers/gpu/drm/display/drm_hdmi_helper.c +++ b/drivers/gpu/drm/display/drm_hdmi_helper.c @@ -27,7 +27,6 @@ int drm_hdmi_infoframe_set_hdr_metadata(struct hdmi_drm_i= nfoframe *frame, { struct drm_connector *connector; struct hdr_output_metadata *hdr_metadata; - int err; =20 if (!frame || !conn_state) return -EINVAL; @@ -47,9 +46,7 @@ int drm_hdmi_infoframe_set_hdr_metadata(struct hdmi_drm_i= nfoframe *frame, connector->hdr_sink_metadata.hdmi_type1.eotf)) DRM_DEBUG_KMS("Unknown EOTF %d\n", hdr_metadata->hdmi_metadata_type1.eot= f); =20 - err =3D hdmi_drm_infoframe_init(frame); - if (err < 0) - return err; + hdmi_drm_infoframe_init(frame); =20 frame->eotf =3D hdr_metadata->hdmi_metadata_type1.eotf; frame->metadata_type =3D hdr_metadata->hdmi_metadata_type1.metadata_type; diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index e0dbd9140726..d4933f215675 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -7235,7 +7235,6 @@ drm_hdmi_vendor_infoframe_from_display_mode(struct hd= mi_vendor_infoframe *frame, */ bool has_hdmi_infoframe =3D connector ? connector->display_info.has_hdmi_infoframe : false; - int err; =20 if (!frame || !mode) return -EINVAL; @@ -7243,9 +7242,7 @@ drm_hdmi_vendor_infoframe_from_display_mode(struct hd= mi_vendor_infoframe *frame, if (!has_hdmi_infoframe) return -EINVAL; =20 - err =3D hdmi_vendor_infoframe_init(frame); - if (err < 0) - return err; + hdmi_vendor_infoframe_init(frame); =20 /* * Even if it's not absolutely necessary to send the infoframe diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i9= 15/display/intel_hdmi.c index 7ac5e6c5e00d..8b58127bca37 100644 --- a/drivers/gpu/drm/i915/display/intel_hdmi.c +++ b/drivers/gpu/drm/i915/display/intel_hdmi.c @@ -763,12 +763,9 @@ intel_hdmi_compute_spd_infoframe(struct intel_encoder = *encoder, intel_hdmi_infoframe_enable(HDMI_INFOFRAME_TYPE_SPD); =20 if (IS_DGFX(i915)) - ret =3D hdmi_spd_infoframe_init(frame, "Intel", "Discrete gfx"); + hdmi_spd_infoframe_init(frame, "Intel", "Discrete gfx"); else - ret =3D hdmi_spd_infoframe_init(frame, "Intel", "Integrated gfx"); - - if (drm_WARN_ON(encoder->base.dev, ret)) - return false; + hdmi_spd_infoframe_init(frame, "Intel", "Integrated gfx"); =20 frame->sdi =3D HDMI_SPD_SDI_PC; =20 diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek= /mtk_hdmi.c index 0a8e0a13f516..75899e4a011f 100644 --- a/drivers/gpu/drm/mediatek/mtk_hdmi.c +++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c @@ -995,12 +995,7 @@ static int mtk_hdmi_setup_spd_infoframe(struct mtk_hdm= i *hdmi, u8 buffer[HDMI_INFOFRAME_HEADER_SIZE + HDMI_SPD_INFOFRAME_SIZE]; ssize_t err; =20 - err =3D hdmi_spd_infoframe_init(&frame, vendor, product); - if (err < 0) { - dev_err(hdmi->dev, "Failed to initialize SPD infoframe: %zd\n", - err); - return err; - } + hdmi_spd_infoframe_init(&frame, vendor, product); =20 err =3D hdmi_spd_infoframe_pack(&frame, buffer, sizeof(buffer)); if (err < 0) { @@ -1018,12 +1013,7 @@ static int mtk_hdmi_setup_audio_infoframe(struct mtk= _hdmi *hdmi) u8 buffer[HDMI_INFOFRAME_HEADER_SIZE + HDMI_AUDIO_INFOFRAME_SIZE]; ssize_t err; =20 - err =3D hdmi_audio_infoframe_init(&frame); - if (err < 0) { - dev_err(hdmi->dev, "Failed to setup audio infoframe: %zd\n", - err); - return err; - } + hdmi_audio_infoframe_init(&frame); =20 frame.coding_type =3D HDMI_AUDIO_CODING_TYPE_STREAM; frame.sample_frequency =3D HDMI_AUDIO_SAMPLE_FREQUENCY_STREAM; diff --git a/drivers/gpu/drm/radeon/r600_hdmi.c b/drivers/gpu/drm/radeon/r6= 00_hdmi.c index f3551ebaa2f0..b690254562e8 100644 --- a/drivers/gpu/drm/radeon/r600_hdmi.c +++ b/drivers/gpu/drm/radeon/r600_hdmi.c @@ -432,11 +432,7 @@ void r600_hdmi_update_audio_settings(struct drm_encode= r *encoder) DRM_DEBUG("0x%02X IEC60958 status bits and 0x%02X category code\n", (int)audio.status_bits, (int)audio.category_code); =20 - err =3D hdmi_audio_infoframe_init(&frame); - if (err < 0) { - DRM_ERROR("failed to setup audio infoframe\n"); - return; - } + hdmi_audio_infoframe_init(&frame); =20 frame.channels =3D audio.channels; =20 diff --git a/drivers/gpu/drm/sti/sti_hdmi.c b/drivers/gpu/drm/sti/sti_hdmi.c index dc1562f14ceb..6d3752329842 100644 --- a/drivers/gpu/drm/sti/sti_hdmi.c +++ b/drivers/gpu/drm/sti/sti_hdmi.c @@ -1322,11 +1322,7 @@ static int sti_hdmi_bind(struct device *dev, struct = device *master, void *data) } =20 /* Initialize audio infoframe */ - err =3D hdmi_audio_infoframe_init(&hdmi->audio.cea); - if (err) { - DRM_ERROR("Failed to init audio infoframe\n"); - goto err_sysfs; - } + hdmi_audio_infoframe_init(&hdmi->audio.cea); =20 cec_fill_conn_info_from_drm(&conn_info, drm_connector); hdmi->notifier =3D cec_notifier_conn_register(&hdmi->dev, NULL, diff --git a/drivers/gpu/drm/tegra/hdmi.c b/drivers/gpu/drm/tegra/hdmi.c index 6eac54ae1205..fa5a6f315377 100644 --- a/drivers/gpu/drm/tegra/hdmi.c +++ b/drivers/gpu/drm/tegra/hdmi.c @@ -747,12 +747,7 @@ static void tegra_hdmi_setup_audio_infoframe(struct te= gra_hdmi *hdmi) u8 buffer[14]; ssize_t err; =20 - err =3D hdmi_audio_infoframe_init(&frame); - if (err < 0) { - dev_err(hdmi->dev, "failed to setup audio infoframe: %zd\n", - err); - return; - } + hdmi_audio_infoframe_init(&frame); =20 frame.channels =3D hdmi->format.channels; =20 diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c index abd6e3b92293..1206959076f9 100644 --- a/drivers/gpu/drm/tegra/sor.c +++ b/drivers/gpu/drm/tegra/sor.c @@ -2022,11 +2022,7 @@ static int tegra_sor_hdmi_enable_audio_infoframe(str= uct tegra_sor *sor) u32 value; int err; =20 - err =3D hdmi_audio_infoframe_init(&frame); - if (err < 0) { - dev_err(sor->dev, "failed to setup audio infoframe: %d\n", err); - return err; - } + hdmi_audio_infoframe_init(&frame); =20 frame.channels =3D sor->format.channels; =20 diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index 5261526d286f..132381e66f39 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -929,13 +929,8 @@ static void vc4_hdmi_set_avi_infoframe(struct drm_enco= der *encoder) static void vc4_hdmi_set_spd_infoframe(struct drm_encoder *encoder) { union hdmi_infoframe frame; - int ret; =20 - ret =3D hdmi_spd_infoframe_init(&frame.spd, "Broadcom", "Videocore"); - if (ret < 0) { - DRM_ERROR("couldn't fill SPD infoframe\n"); - return; - } + hdmi_spd_infoframe_init(&frame.spd, "Broadcom", "Videocore"); =20 frame.spd.sdi =3D HDMI_SPD_SDI_PC; =20 diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c index 03c7f27dde49..974f32a5c442 100644 --- a/drivers/video/hdmi.c +++ b/drivers/video/hdmi.c @@ -216,11 +216,9 @@ EXPORT_SYMBOL(hdmi_avi_infoframe_pack); * @frame: HDMI SPD infoframe * @vendor: vendor string * @product: product string - * - * Returns 0 on success or a negative error code on failure. */ -int hdmi_spd_infoframe_init(struct hdmi_spd_infoframe *frame, - const char *vendor, const char *product) +void hdmi_spd_infoframe_init(struct hdmi_spd_infoframe *frame, + const char *vendor, const char *product) { size_t len; =20 @@ -234,8 +232,6 @@ int hdmi_spd_infoframe_init(struct hdmi_spd_infoframe *= frame, memcpy(frame->vendor, vendor, min(len, sizeof(frame->vendor))); len =3D strlen(product); memcpy(frame->product, product, min(len, sizeof(frame->product))); - - return 0; } EXPORT_SYMBOL(hdmi_spd_infoframe_init); =20 @@ -348,18 +344,14 @@ EXPORT_SYMBOL(hdmi_spd_infoframe_pack); /** * hdmi_audio_infoframe_init() - initialize an HDMI audio infoframe * @frame: HDMI audio infoframe - * - * Returns 0 on success or a negative error code on failure. */ -int hdmi_audio_infoframe_init(struct hdmi_audio_infoframe *frame) +void hdmi_audio_infoframe_init(struct hdmi_audio_infoframe *frame) { memset(frame, 0, sizeof(*frame)); =20 frame->type =3D HDMI_INFOFRAME_TYPE_AUDIO; frame->version =3D 1; frame->length =3D HDMI_AUDIO_INFOFRAME_SIZE; - - return 0; } EXPORT_SYMBOL(hdmi_audio_infoframe_init); =20 @@ -526,10 +518,8 @@ EXPORT_SYMBOL(hdmi_audio_infoframe_pack_for_dp); /** * hdmi_vendor_infoframe_init() - initialize an HDMI vendor infoframe * @frame: HDMI vendor infoframe - * - * Returns 0 on success or a negative error code on failure. */ -int hdmi_vendor_infoframe_init(struct hdmi_vendor_infoframe *frame) +void hdmi_vendor_infoframe_init(struct hdmi_vendor_infoframe *frame) { memset(frame, 0, sizeof(*frame)); =20 @@ -544,8 +534,6 @@ int hdmi_vendor_infoframe_init(struct hdmi_vendor_infof= rame *frame) */ frame->s3d_struct =3D HDMI_3D_STRUCTURE_INVALID; frame->length =3D HDMI_VENDOR_INFOFRAME_SIZE; - - return 0; } EXPORT_SYMBOL(hdmi_vendor_infoframe_init); =20 @@ -698,18 +686,14 @@ hdmi_vendor_any_infoframe_check_only(const union hdmi= _vendor_any_infoframe *fram * hdmi_drm_infoframe_init() - initialize an HDMI Dynaminc Range and * mastering infoframe * @frame: HDMI DRM infoframe - * - * Returns 0 on success or a negative error code on failure. */ -int hdmi_drm_infoframe_init(struct hdmi_drm_infoframe *frame) +void hdmi_drm_infoframe_init(struct hdmi_drm_infoframe *frame) { memset(frame, 0, sizeof(*frame)); =20 frame->type =3D HDMI_INFOFRAME_TYPE_DRM; frame->version =3D 1; frame->length =3D HDMI_DRM_INFOFRAME_SIZE; - - return 0; } EXPORT_SYMBOL(hdmi_drm_infoframe_init); =20 @@ -1661,7 +1645,6 @@ static int hdmi_spd_infoframe_unpack(struct hdmi_spd_= infoframe *frame, const void *buffer, size_t size) { const u8 *ptr =3D buffer; - int ret; =20 if (size < HDMI_INFOFRAME_SIZE(SPD)) return -EINVAL; @@ -1677,9 +1660,7 @@ static int hdmi_spd_infoframe_unpack(struct hdmi_spd_= infoframe *frame, =20 ptr +=3D HDMI_INFOFRAME_HEADER_SIZE; =20 - ret =3D hdmi_spd_infoframe_init(frame, ptr, ptr + 8); - if (ret) - return ret; + hdmi_spd_infoframe_init(frame, ptr, ptr + 8); =20 frame->sdi =3D ptr[24]; =20 @@ -1703,7 +1684,6 @@ static int hdmi_audio_infoframe_unpack(struct hdmi_au= dio_infoframe *frame, const void *buffer, size_t size) { const u8 *ptr =3D buffer; - int ret; =20 if (size < HDMI_INFOFRAME_SIZE(AUDIO)) return -EINVAL; @@ -1717,9 +1697,7 @@ static int hdmi_audio_infoframe_unpack(struct hdmi_au= dio_infoframe *frame, if (hdmi_infoframe_checksum(buffer, HDMI_INFOFRAME_SIZE(AUDIO)) !=3D 0) return -EINVAL; =20 - ret =3D hdmi_audio_infoframe_init(frame); - if (ret) - return ret; + hdmi_audio_infoframe_init(frame); =20 ptr +=3D HDMI_INFOFRAME_HEADER_SIZE; =20 @@ -1755,7 +1733,6 @@ hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_an= y_infoframe *frame, { const u8 *ptr =3D buffer; size_t length; - int ret; u8 hdmi_video_format; struct hdmi_vendor_infoframe *hvf =3D &frame->hdmi; =20 @@ -1789,9 +1766,7 @@ hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_an= y_infoframe *frame, if (hdmi_video_format > 0x2) return -EINVAL; =20 - ret =3D hdmi_vendor_infoframe_init(hvf); - if (ret) - return ret; + hdmi_vendor_infoframe_init(hvf); =20 hvf->length =3D length; =20 @@ -1837,15 +1812,12 @@ int hdmi_drm_infoframe_unpack_only(struct hdmi_drm_= infoframe *frame, const u8 *temp; u8 x_lsb, x_msb; u8 y_lsb, y_msb; - int ret; int i; =20 if (size < HDMI_DRM_INFOFRAME_SIZE) return -EINVAL; =20 - ret =3D hdmi_drm_infoframe_init(frame); - if (ret) - return ret; + hdmi_drm_infoframe_init(frame); =20 frame->eotf =3D ptr[0] & 0x7; frame->metadata_type =3D ptr[1] & 0x7; diff --git a/include/linux/hdmi.h b/include/linux/hdmi.h index 3bb87bf6bc65..4aaf294be756 100644 --- a/include/linux/hdmi.h +++ b/include/linux/hdmi.h @@ -214,7 +214,7 @@ ssize_t hdmi_avi_infoframe_pack(struct hdmi_avi_infofra= me *frame, void *buffer, ssize_t hdmi_avi_infoframe_pack_only(const struct hdmi_avi_infoframe *fram= e, void *buffer, size_t size); int hdmi_avi_infoframe_check(struct hdmi_avi_infoframe *frame); -int hdmi_drm_infoframe_init(struct hdmi_drm_infoframe *frame); +void hdmi_drm_infoframe_init(struct hdmi_drm_infoframe *frame); ssize_t hdmi_drm_infoframe_pack(struct hdmi_drm_infoframe *frame, void *bu= ffer, size_t size); ssize_t hdmi_drm_infoframe_pack_only(const struct hdmi_drm_infoframe *fram= e, @@ -249,8 +249,8 @@ struct hdmi_spd_infoframe { enum hdmi_spd_sdi sdi; }; =20 -int hdmi_spd_infoframe_init(struct hdmi_spd_infoframe *frame, - const char *vendor, const char *product); +void hdmi_spd_infoframe_init(struct hdmi_spd_infoframe *frame, + const char *vendor, const char *product); ssize_t hdmi_spd_infoframe_pack(struct hdmi_spd_infoframe *frame, void *bu= ffer, size_t size); ssize_t hdmi_spd_infoframe_pack_only(const struct hdmi_spd_infoframe *fram= e, @@ -331,7 +331,7 @@ struct hdmi_audio_infoframe { =20 }; =20 -int hdmi_audio_infoframe_init(struct hdmi_audio_infoframe *frame); +void hdmi_audio_infoframe_init(struct hdmi_audio_infoframe *frame); ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame, void *buffer, size_t size); ssize_t hdmi_audio_infoframe_pack_only(const struct hdmi_audio_infoframe *= frame, @@ -393,7 +393,7 @@ struct hdr_sink_metadata { }; }; =20 -int hdmi_vendor_infoframe_init(struct hdmi_vendor_infoframe *frame); +void hdmi_vendor_infoframe_init(struct hdmi_vendor_infoframe *frame); ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame, void *buffer, size_t size); ssize_t hdmi_vendor_infoframe_pack_only(const struct hdmi_vendor_infoframe= *frame,