From patchwork Thu Feb 24 12:57:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 545712 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 E0D60C433EF for ; Thu, 24 Feb 2022 12:58:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234065AbiBXM6e (ORCPT ); Thu, 24 Feb 2022 07:58:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231355AbiBXM6d (ORCPT ); Thu, 24 Feb 2022 07:58:33 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24E6E1CF093 for ; Thu, 24 Feb 2022 04:58:03 -0800 (PST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DA00BDD; Thu, 24 Feb 2022 13:58:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1645707482; bh=dMP785DF8PqK1dVBIJgx0U+EpcvcKm79rwfwAsZXZB0=; h=From:To:Cc:Subject:Date:From; b=K//7MBI67uDZTTNAg1cES40kCXohayIJtJI948KbI+77Wpv20n+FxRllzXJwMzqpV RoYskzCrUogmeU18O+En5bMt9wVQA10wIUBZFYXeJHC6xoGh9QCkEy0x2b7ZE79gmj esyWM+5xaT3KYbUjQK/E7DEh20Ol0I98JZU8Wv04= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Sakari Ailus , Laurent Pinchart Subject: [PATCH] media: media-entity: Clarify media_entity_cleanup() usage Date: Thu, 24 Feb 2022 14:57:47 +0200 Message-Id: <20220224125747.2099-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart Being able to call cleanup functions on objects that haven't been initialized but whose memory has been zeroed simplifies error handling. The media_entity_cleanup() function documentation doesn't tell whether this is allowed or not, and inspection of its implementation doesn't provide any clue as the function is currently empty. Update the documentation to explicitly allow this usage pattern. Signed-off-by: Laurent Pinchart --- include/media/media-entity.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 1419a327c78d..95499d0f458b 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -671,6 +671,10 @@ int media_entity_pads_init(struct media_entity *entity, u16 num_pads, * * This function must be called during the cleanup phase after unregistering * the entity (currently, it does nothing). + * + * Calling media_entity_cleanup() on a media_entity whose memory has been + * zeroed but that has not been initialized with media_entity_pad_init() is + * valid and is a no-op. */ #if IS_ENABLED(CONFIG_MEDIA_CONTROLLER) static inline void media_entity_cleanup(struct media_entity *entity) {}