From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 7310AC531C9 for ; Sun, 26 Jul 2026 12:56:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To: Content-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=7gH91vs1XUmyWPNxOvMm5JbdkkX4kBzPrXZaO8GwcXc=; b=UI8T3Wuv3gdr/MZCaAXaCYt5am aFRCEYfrs/65o/ebYwwh03U8o0AaSv4m9N6xh/lpww1QK6Za9emwXYM/NjXhGBuFYEjemHCJxhhuI ebodbI9xpgsGb3Yk+nbAtquj9x3/ngY03XYs4TUv20bWQgr0g7GwTTovHZ4jkNhndnerdMZbXCjAe AXBvvJCy5uEqTjpDRovBkk6fhOZOe2pQF2QQyFJKpjM2CdOmC9fSqdFSNBAn+lTc9oune47mTqu4W OQimGjsb7gYJ6n63owJpxZHTcby9kQf61L6AdDLuOGUvH2JzxJkvQWxRLpnaVDdgCgQirlcR114eK kM8KBAgw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wnyP7-00000001B2S-1Hwg; Sun, 26 Jul 2026 12:56:29 +0000 Received: from [2a01:e0a:1040:9780:49:5ff:fe41:d261] (helo=luna.linkmauve.fr) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wnyP4-00000001B1v-27qE; Sun, 26 Jul 2026 12:56:28 +0000 Received: by luna.linkmauve.fr (Postfix, from userid 1000) id 046A5F40DDF; Sun, 26 Jul 2026 14:56:17 +0200 (CEST) Date: Sun, 26 Jul 2026 14:56:16 +0200 From: Link Mauve To: Andy Shevchenko Cc: Link Mauve , Srinivas Kandagatla , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Sven Peter , Janne Grunau , Neal Gompa , Frank Li , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Vladimir Zapolskiy , =?iso-8859-1?Q?Andr=E9?= Draszik , Orson Zhai , Baolin Wang , Chunyan Zhang , Maxime Coquelin , Alexandre Torgue , Kalyani Akula , Michal Simek , Miguel Ojeda , Boqun Feng , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Daniel Almeida , Tamir Duberstein , Alexandre Courbot , Onur =?iso-8859-1?Q?=D6zkan?= , Johan Hovold , Ronald Claveau , Daniel Lezcano , linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, imx@lists.linux.dev, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, rust-for-linux@vger.kernel.org Subject: Re: [PATCH v3 3/4] nvmem: apple-spmi: improve calling safety with wrapper functions Message-ID: References: <20260716142415.28718-1-linkmauve@linkmauve.fr> <20260716142415.28718-4-linkmauve@linkmauve.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Jabber-ID: linkmauve@linkmauve.fr X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260726_055626_713320_6F18F254 X-CRM114-Status: GOOD ( 19.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Ah, someone independently sent the same patch as this one in 7089170e1df160f5f8fb395bc5aa2e2697b4e896, so I’ll drop it from v4. Sorry it took that long! On Thu, Jul 16, 2026 at 09:07:13PM +0300, Andy Shevchenko wrote: > On Thu, Jul 16, 2026 at 04:24:10PM +0200, Link Mauve wrote: > > This driver used to cast the regmap_bulk_*() functions to void *, > > bypassing any compiler safety around incompatible function pointers. > > > > With two small wrappers, which just convert the void * priv parameter > > into the wanted struct regmap *, we can remove the void * cast > > altogether. > > Reported-by: ? > > > Signed-off-by: Link Mauve > > ... > > > +static int apple_spmi_nvmem_read(void *priv, unsigned int offset, > > + void *val, size_t bytes) > > +{ > > > + struct regmap *regmap = priv; > > No need :-) > > > + return regmap_bulk_read(regmap, offset, val, bytes); > > +} > > static int apple_spmi_nvmem_read(void *map, unsigned int offset, > void *val, size_t bytes) > { > return regmap_bulk_read(map, offset, val, bytes); > } > > ... > > > +static int apple_spmi_nvmem_write(void *priv, unsigned int offset, > > + const void *val, size_t bytes) > > +{ > > + struct regmap *regmap = priv; > > + return regmap_bulk_write(regmap, offset, val, bytes); > > +} > > In the similar way as above. > > ... > > > - .reg_read = (void *)regmap_bulk_read, > > - .reg_write_const = (void *)regmap_bulk_write, > > + .reg_read = apple_spmi_nvmem_read, > > + .reg_write_const = apple_spmi_nvmem_write, > > I think the proper ordering is to address this first (before your main change) > and update later with const argument. Yes, it will be a bit more changes, but > it will be cleaner. > > -- > With Best Regards, > Andy Shevchenko > > -- Link Mauve