From nobody Tue Nov 26 00:28:05 2024 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED9CF205AD5 for ; Wed, 23 Oct 2024 16:50:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729702256; cv=none; b=UjBwKK0vVd/kXmrBe73C3+1Kwfq+ZuRXbMRjVcbx11rDI+PRE0P9dwrZyMAoeuKqAntxBeUBOJjYkYH4SZ3buYz+J+wk0GVIZjfiGwu4WJdqP4atJ/+pxREPwra4Awa5OHJ9c5g3yP91oVnGP7n2m5K+8EuR/PceLezKRWvSm4c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729702256; c=relaxed/simple; bh=h60g8ThwYT/UJQE4G2CP6rUIno0KoMdhzemrzgI+AYI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dtoZ3eKC+LgX1J3CodCy1/AUzJQzEkCoswA03dYGvxUi5I9BR7I6ofMvJmtTNPi+CTUK54IqDAb32oqOoGu/WgsA+TzwYm6VibafF7Eqx/Qf3yO/zj9iXHPp/BGmXB3awDhJd/UJtWDSOqC1Lq/56yymuyJ3nmAp9N8jwL7MJ3U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=raspberrypi.com; spf=pass smtp.mailfrom=raspberrypi.com; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b=bL2DrpR/; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="bL2DrpR/" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-42f6bec84b5so77557895e9.1 for ; Wed, 23 Oct 2024 09:50:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1729702253; x=1730307053; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=L9MiZUhuAcE+DC6JkjBsIZrkLkLAyStuyfWQoaNqfXQ=; b=bL2DrpR/FWJvjVHisJX0luDsjeVwtalgpvJdWsZ+637rtRRezTKHRugwXfdQ5bf/+y uiqlIT3FA0kmVYEA7kMVrRN6QnUPNoFuTfEQvSKB4QeY1EaMmOP14jpQ1sCjLjp6XG9j O8EPae4nTBvCJTUxZTiHeI1ndfQxE3+hcyWQH4QRa92YrkJz9ZxX2NTo4hfeUjuNBKlv UPfQlQpYrJp7KaxsDXY49plKI9POTVha/1Cv0HMY6xFqTl/Qnpyid/8wYQnXRKoKyl2z y+s4TBiCEi4qkFmmQkNJpubQvFxgKMRb2gxTpIZ5yLv8VqQqYBO7Q/0AdpdJ2V2Yedr+ f3dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729702253; x=1730307053; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L9MiZUhuAcE+DC6JkjBsIZrkLkLAyStuyfWQoaNqfXQ=; b=ltIUvMdbL62MZNexLgt87BgFZDcQvTFFRtmTkuO1Kh/n/RxM4vkOzGmC2HG3O7GZHT QdeFoLX4wUVwTboRhKgRREl9fKfpU+wVazmkHThQCA9MBFLVJEd5DJ88+P10xfSzS303 mrV19KR5Hfi0zkOd/Y/qb+5P8fv94dnL7go5/BPQBprJX7IpsHVBbbSHLiaLVkqqncha LxP2AM9SlXjl5bGL0fWbpwJoeLxKwgZhDVSHy3VMCsh8CBhM15sfCltn2zXol3TjXhe1 s8dMy43hmJ6EKqQdaU2cIipAot+YLQ6vPtZV+SDj7DJIjpe+18IMf4zY15laEvh7n25+ 7jCw== X-Forwarded-Encrypted: i=1; AJvYcCVoHMOcXWX3pxARtkDtnIhFCrfYdcRRtmhIUyn0ZapfHhgTYszkBkk0iVrZHIWhu5kP+DyjxNwHCGf1mf8=@vger.kernel.org X-Gm-Message-State: AOJu0YwUMYgSEbZIWZDribNRMtLfVIN5eHglLvygIF1VdpGJAJTV3WMa IOAI40Gc0Ughe4vV2Wh1vqqV6oxnLzay6HoYYpHJXqTkTw9YxA4y9QcZV/wvAMg= X-Google-Smtp-Source: AGHT+IH3dVyDZOxIVjZAcfUl+JwKCM4Z59KdfEHOCGa0hmLNiw7CjeLKq/QM+g/Vjy8Ji+yxUeCFow== X-Received: by 2002:a05:600c:45cb:b0:431:44aa:ee2e with SMTP id 5b1f17b1804b1-4318413209emr25331625e9.4.1729702253413; Wed, 23 Oct 2024 09:50:53 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-43186c50445sm21642035e9.39.2024.10.23.09.50.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2024 09:50:53 -0700 (PDT) From: Dave Stevenson Date: Wed, 23 Oct 2024 17:50:30 +0100 Subject: [PATCH 33/37] clk: bcm: rpi: Create helper to retrieve private data Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241023-drm-vc4-2712-support-v1-33-1cc2d5594907@raspberrypi.com> References: <20241023-drm-vc4-2712-support-v1-0-1cc2d5594907@raspberrypi.com> In-Reply-To: <20241023-drm-vc4-2712-support-v1-0-1cc2d5594907@raspberrypi.com> To: Maxime Ripard , =?utf-8?q?Ma=C3=ADra_Canal?= , Raspberry Pi Kernel Maintenance , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Simona Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Michael Turquette , Stephen Boyd , Javier Martinez Canillas , Catalin Marinas , Will Deacon Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, Dave Stevenson X-Mailer: b4 0.14.1 From: Maxime Ripard The RaspberryPi firmware clocks driver uses in several instances a container_of to retrieve the struct raspberrypi_clk_data from a pointer to struct clk_hw. Let's create a small function to avoid duplicating it all over the place. Signed-off-by: Maxime Ripard Signed-off-by: Dave Stevenson Acked-by: Stephen Boyd --- drivers/clk/bcm/clk-raspberrypi.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/clk/bcm/clk-raspberrypi.c b/drivers/clk/bcm/clk-raspbe= rrypi.c index fd7ae0efcf07..89e2c0241ff6 100644 --- a/drivers/clk/bcm/clk-raspberrypi.c +++ b/drivers/clk/bcm/clk-raspberrypi.c @@ -56,6 +56,12 @@ struct raspberrypi_clk_data { struct raspberrypi_clk *rpi; }; =20 +static inline +const struct raspberrypi_clk_data *clk_hw_to_data(const struct clk_hw *hw) +{ + return container_of(hw, struct raspberrypi_clk_data, hw); +} + struct raspberrypi_clk_variant { bool export; char *clkdev; @@ -177,8 +183,7 @@ static int raspberrypi_clock_property(struct rpi_firmwa= re *firmware, =20 static int raspberrypi_fw_is_prepared(struct clk_hw *hw) { - struct raspberrypi_clk_data *data =3D - container_of(hw, struct raspberrypi_clk_data, hw); + const struct raspberrypi_clk_data *data =3D clk_hw_to_data(hw); struct raspberrypi_clk *rpi =3D data->rpi; u32 val =3D 0; int ret; @@ -195,8 +200,7 @@ static int raspberrypi_fw_is_prepared(struct clk_hw *hw) static unsigned long raspberrypi_fw_get_rate(struct clk_hw *hw, unsigned long parent_rate) { - struct raspberrypi_clk_data *data =3D - container_of(hw, struct raspberrypi_clk_data, hw); + const struct raspberrypi_clk_data *data =3D clk_hw_to_data(hw); struct raspberrypi_clk *rpi =3D data->rpi; u32 val =3D 0; int ret; @@ -212,8 +216,7 @@ static unsigned long raspberrypi_fw_get_rate(struct clk= _hw *hw, static int raspberrypi_fw_set_rate(struct clk_hw *hw, unsigned long rate, unsigned long parent_rate) { - struct raspberrypi_clk_data *data =3D - container_of(hw, struct raspberrypi_clk_data, hw); + const struct raspberrypi_clk_data *data =3D clk_hw_to_data(hw); struct raspberrypi_clk *rpi =3D data->rpi; u32 _rate =3D rate; int ret; @@ -230,8 +233,7 @@ static int raspberrypi_fw_set_rate(struct clk_hw *hw, u= nsigned long rate, static int raspberrypi_fw_dumb_determine_rate(struct clk_hw *hw, struct clk_rate_request *req) { - struct raspberrypi_clk_data *data =3D - container_of(hw, struct raspberrypi_clk_data, hw); + const struct raspberrypi_clk_data *data =3D clk_hw_to_data(hw); struct raspberrypi_clk_variant *variant =3D data->variant; =20 /* --=20 2.34.1