From nobody Mon Sep 15 19:44:15 2025 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 2BAE1C46467 for ; Wed, 11 Jan 2023 11:32:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237591AbjAKLcJ (ORCPT ); Wed, 11 Jan 2023 06:32:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232716AbjAKLbN (ORCPT ); Wed, 11 Jan 2023 06:31:13 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F11BB4A6 for ; Wed, 11 Jan 2023 03:31:11 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id CC2FEB819EF for ; Wed, 11 Jan 2023 11:31:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E7CFC433F1; Wed, 11 Jan 2023 11:31:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1673436668; bh=1vqW6DznMRgbPw/+04VEBpy62SL5hHVRbzL2+kYgjlg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0bHQTNZWATOTIKhHpxas2zGuwKFhEEtdCziVt7Dha9I/cPf90pkHFa1KfaFUXQpIG p0WKno6PX/SjuLGYbtxZIfbdJofh0ffuoHNvcdP9VyNBji/Y7bLCBZXOB0zcwpBFse KAalUDkWGTr4hVEX3Zq4/7io5AODAYNnwDup5+fI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Stefan Richter , linux1394-devel@lists.sourceforge.net Subject: [PATCH v2 04/16] firewire: move fw_device() and fw_unit() to use container_of_const() Date: Wed, 11 Jan 2023 12:30:06 +0100 Message-Id: <20230111113018.459199-5-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230111113018.459199-1-gregkh@linuxfoundation.org> References: <20230111113018.459199-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1932; i=gregkh@linuxfoundation.org; h=from:subject; bh=1vqW6DznMRgbPw/+04VEBpy62SL5hHVRbzL2+kYgjlg=; b=owGbwMvMwCRo6H6F97bub03G02pJDMn75h6/+DvosLuUcdHFB+uc9q9K+mzoksivbP/s24YNW3dF 71/U0xHLwiDIxCArpsjyZRvP0f0VhxS9DG1Pw8xhZQIZwsDFKQATiVBlmGehUVxx6dnKjVutlk7Uvz Q9XrvP7yfDXKlIxQqlYB6ut5z9Z3dorK6ysC90BwA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The driver core is changing to pass some pointers as const, so move fw_device() and fw_unit() functions to use container_of_const() to handle this change. fw_device() and fw_unit() now properly keeps the const-ness of the pointer passed into it, while as before it could be lost. This also required turning fw_parent_device() into a macro to preserve the const-ness of the pointer passed into it if necessary. Cc: Stefan Richter Cc: linux1394-devel@lists.sourceforge.net Signed-off-by: Greg Kroah-Hartman --- include/linux/firewire.h | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/include/linux/firewire.h b/include/linux/firewire.h index 980019053e54..03ac31ada5e6 100644 --- a/include/linux/firewire.h +++ b/include/linux/firewire.h @@ -208,10 +208,7 @@ struct fw_device { struct fw_attribute_group attribute_group; }; =20 -static inline struct fw_device *fw_device(struct device *dev) -{ - return container_of(dev, struct fw_device, device); -} +#define fw_device(dev) container_of_const(dev, struct fw_device, device) =20 static inline int fw_device_is_shutdown(struct fw_device *device) { @@ -229,10 +226,7 @@ struct fw_unit { struct fw_attribute_group attribute_group; }; =20 -static inline struct fw_unit *fw_unit(struct device *dev) -{ - return container_of(dev, struct fw_unit, device); -} +#define fw_unit(dev) container_of_const(dev, struct fw_unit, device) =20 static inline struct fw_unit *fw_unit_get(struct fw_unit *unit) { @@ -246,10 +240,7 @@ static inline void fw_unit_put(struct fw_unit *unit) put_device(&unit->device); } =20 -static inline struct fw_device *fw_parent_device(struct fw_unit *unit) -{ - return fw_device(unit->device.parent); -} +#define fw_parent_device(unit) fw_device(unit->device.parent) =20 struct ieee1394_device_id; =20 --=20 2.39.0