From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from polaris.svanheule.net (polaris.svanheule.net [84.16.241.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9DF834E743 for ; Fri, 20 Feb 2026 16:00:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=84.16.241.116 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771603203; cv=none; b=u2CSVM+ftQiDVXeoouOWYJunNdBPiswHRwqG/hHk3hIc3kA3MoBLs+5zaHEjn6SGNh3zonLiODTQo90VQloxBQXpe93FmevtKFFq8ScVP1TyV8wlzw7833WK6Qun28YXWiPnfntfFl4Ex0KuzydO07SlL+d2HPjzcESyOPmAHNQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771603203; c=relaxed/simple; bh=bdS3G0OD4AJbwhBldExGHOYNqxXjdIxqaGQUDIP0M6Y=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=gBD2FN5JK2jhlVbGcZqu2DKTx1qBGD9w29iNWdW14tWAStFkxSthiwNhoTUyj40DJaxu0JmmC+gDjMv9X6YGpECf1NIHAQ8fgCIvBQ68x+0Eje67AQcWUfzppoC+l6TsyItS0fcsn9cp95NrhDTEmfHNBZI17zcpGISLPPhrJkE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=svanheule.net; spf=pass smtp.mailfrom=svanheule.net; dkim=pass (2048-bit key) header.d=svanheule.net header.i=@svanheule.net header.b=wQ/1VGOZ; arc=none smtp.client-ip=84.16.241.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=svanheule.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=svanheule.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=svanheule.net header.i=@svanheule.net header.b="wQ/1VGOZ" Received: from [IPv6:2a02:1812:162c:8f00:1e2d:b404:3319:eba8] (2a02-1812-162c-8f00-1e2d-b404-3319-eba8.ip6.access.telenet.be [IPv6:2a02:1812:162c:8f00:1e2d:b404:3319:eba8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: sander@svanheule.net) by polaris.svanheule.net (Postfix) with ESMTPSA id 18FA66E8682; Fri, 20 Feb 2026 17:00:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svanheule.net; s=mail1707; t=1771603200; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bdS3G0OD4AJbwhBldExGHOYNqxXjdIxqaGQUDIP0M6Y=; b=wQ/1VGOZu/PzOsOH2pIlMEO59hr9C0l1V1SkEl+mENV8VghriDlUY1dMLTmQGeFqq2z35S gsr+eHy+rRRZM7c+tEmVUI9D4MbpkEE2Zy+KDT2M7anBXuXpKykCtykq35Y9zED73VRc37 nQJdawWUP8nTd1U9Ug/ypzbdfaVzxE5QwsIS9pCJA76yFHkQQS3tX89RiG8lf3AZ59ef+3 snUs7CNJEWMqLupLT/JnbZp+93wlbUnt3NQxhzHXgMYoVra30Rm0btnF0OKOctliD3yC7I H9Vuqbw22dwKcv6h+kAOjAnBbeCABQT4hqGOWGzQKg0qS6PCTEfn6TN+WhBI9g== Message-ID: <7698648ffb4515b7d6b3b5e3d6c62042e8d8dcc8.camel@svanheule.net> Subject: Re: [PATCH] regmap: define cleanup helper for regmap_field From: Sander Vanheule To: Mark Brown Cc: linux-kernel@vger.kernel.org Date: Fri, 20 Feb 2026 16:59:59 +0100 In-Reply-To: <4ddbaa4d-7dc5-4fbe-aadd-d903b3e99778@sirena.org.uk> References: <20260220153646.494683-1-sander@svanheule.net> <4ddbaa4d-7dc5-4fbe-aadd-d903b3e99778@sirena.org.uk> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.3 (3.58.3-1.fc43) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Fri, 2026-02-20 at 15:43 +0000, Mark Brown wrote: > On Fri, Feb 20, 2026 at 04:36:46PM +0100, Sander Vanheule wrote: >=20 > > =C2=A0=C2=A0=C2=A0 struct regmap_field *field =3D regmap_field_alloc(..= .); > > =C2=A0=C2=A0=C2=A0 if (!field) > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return -ENOMEM; > >=20 > > =C2=A0=C2=A0=C2=A0 int err =3D regmap_field_write(...); > >=20 > > =C2=A0=C2=A0=C2=A0 regmap_field_free(field); > >=20 > > =C2=A0=C2=A0=C2=A0 return err; >=20 > That seems like a bit of an odd pattern, I'd expect the fields to live > for the lifetime of the driver rather than a function.=C2=A0 OTOH if peop= le > are doing that then sure. That is usually the case yes. I did find myself using devm_regmap_field_all= oc() in a proposed driver [1] to avoid goto's in less trivial logic. I'll update= the example in v2 to show the benefit a bit more. [1] https://lore.kernel.org/all/20251215175115.135294-5-sander@svanheule.ne= t/ Best, Sander