From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com [209.85.210.46]) (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 EB8CB371CE2 for ; Tue, 2 Jun 2026 16:39:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780418391; cv=none; b=QcXkIFo3IhYXadQPy+2tcNDeA/z4qbVsskKqvVwafR9oc2G0pUkHmTMMcWp9JMkKnCw6bWNo1EiNJqJzDOyvxBmTj80OjagTVBB5GwwG26WO7Os0lSdyTYKlr2+eTZPwVulapBgJeKSjet1pgaTTA2ygrQn+6f94qNBzRnyv4/o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780418391; c=relaxed/simple; bh=QBYsbN6b20Pt0eNUxfygT+eCgDSEpTa0lXXtqr0FKh8=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VqKUKhyfR1nw+gTF7xUmLBNO6gXuLAk3XuSz0ZK/AJ/4o1T/J2eHnbFihy6sBMC/WA7hrUt5nnYwvQ1jBjyYVNWSSKCI3YSi1gLDJcVGbooilonTY4bVkEJIw6tqAf0gErvq1JuOEEhZvvppOD893veNFcJWNVHngeVAhP/083I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=p1Ii12ry; arc=none smtp.client-ip=209.85.210.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="p1Ii12ry" Received: by mail-ot1-f46.google.com with SMTP id 46e09a7af769-7e6d991991dso706144a34.3 for ; Tue, 02 Jun 2026 09:39:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780418389; x=1781023189; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=tZyhA/HoFpbaorFoLTKRTegpBte1NUgV963dUdPXjN8=; b=p1Ii12rynOdr9qa7/Z4mt+gUGvJaSdhoGVpWcEbbrAG6YJjTXHYbMq3wq2Jou6Rc96 Y0+SyowA9qmMupK3G4uMazVY0F2s+1MkAKcufyujk3XjOwuBrKA0Hl1IdCLmWOu5hWRL Y0gb1XII3LMbYdBdBfbDi2KjAsrORbRSb2suNfqX4lvUTQcN5uDBf/9ybwgUIgyL8W/p pWQYz514br1bhTwgeQbWjFrzZZ+klCVAa6S2PEdswDocBPlSB1xTg5fLJIQfL3rgNrZy mF7+SdwoYRbHn4PwZ45zh7a7eT5KXiE68B/34hOSuFbXXGLHKpzGurC8nJsiaaFswDkS +WCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780418389; x=1781023189; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=tZyhA/HoFpbaorFoLTKRTegpBte1NUgV963dUdPXjN8=; b=P2LfmQtcuQqDzw7gpih1/q3SvpEc4LLYC1dw2rhyXpJpEQqZRoRJQ0BJpDlF2Jn4f8 LhA+BV4vWtWlY/c0e6LxgRrHntu4/N+NDcwFLwkOlZpF5JzcAcbbxwywnOlZdB05TroJ +ATtu58MPJwRkagIf+CmhOCvd04CpyGYXzTzYXvgPDiQL8mvuSrIFA8Bn18a6p4mo02n h2UmO9A+ok956EfRpwSpFV7bc0KeFsR7WZpEtUvRXJHb/RAk8MEyGCzbQtrHDppuh8Jo O+FUloj+gvLbiDWArlilmP2uynlelm21a8aAbCuWw87m3Aac3BQ6w1LX+gfjmROFF7lg FbJQ== X-Gm-Message-State: AOJu0YwmktF3eSbyaWlqddLTPRhz38A9ifSZkZ9zGw2f9pqEIIh7M2qm jamQZiKBtbhGbF/96mxy2HTgs5JwsL+EWh/4iIEPxnV3Xx/HD1EwxwjqjmCCofYBsQo= X-Gm-Gg: Acq92OFUzlY8jtuVWEFSqjlT4QCiOsm58JbSOYV0TE9A1p9OtVHcL8kevNOY4YL8L1N CQA3d90tcHv5BLn9B++sQXjegSlt4n/Vs6y0y+cUj8nzJqf3zJw8jB2ZZd5Gc3XiP3QAHnyHJPG svW+AaABdZnlt3wmLhQ7IQHz47xpZLIR26IJ9NoK459Tr1G8iZc9fRxfEoz7N/9AkSHAV3AM32p i+9VZ9lO3ziSQyVsY+IIwxIO9MvnwNQIpKf5ygC46GzIxp96M7AmoHWu0c94Wpe5CccPmtTIFH8 vP3W3tFALorQIlYpI55lotu7pvZOjo8HBt7zBdMYhdIbZ08G7otD1KDCf+ketY8jZBnoPkkiBCM nWZKbpCj1utfbOGkgH0QXnBunpblmULpjtSiyRbGq1P1uK7B1o1mKEusT3S23Z3DZ1boShnDtyI 2FhVYLp4bcVHL6DgjoSSsNsGTQvnaJ7uswwn1eP3vki+xvA+wId5GWoyZttsCJUow= X-Received: by 2002:a4a:d24f:0:b0:69d:82e6:69d8 with SMTP id 006d021491bc7-69e46acd1b8mr186164eaf.52.1780418388873; Tue, 02 Jun 2026 09:39:48 -0700 (PDT) Received: from linuxescape (23-88-128-2.fttp.usinternet.com. [23.88.128.2]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-440d8297395sm63065fac.11.2026.06.02.09.39.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 09:39:48 -0700 (PDT) Date: Tue, 2 Jun 2026 11:39:45 -0500 From: Maxwell Doose To: peda@lysator.liu.se Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] mux: core: Replace manual put_device() with __free(put_device) Message-ID: <20260602113945.6713960e@linuxescape> In-Reply-To: <20260602162833.339562-1-m32285159@gmail.com> References: <20260602162833.339562-1-m32285159@gmail.com> X-Mailer: Claws Mail 4.4.0 (GTK 3.24.52; x86_64-pc-linux-gnu) 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=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 2 Jun 2026 11:28:33 -0500 Maxwell Doose wrote: > The current code for returning on failure in mux_get() uses manual > put_device() calls. Refactor and replace them with a new variable for > the pointer to the underlying device and __free(put_device). > > Signed-off-by: Maxwell Doose > --- > drivers/mux/core.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > v2: > - Add explicit cleanup.h header. > - Add no_free_ptr() at the end of the happy path to prevent > accidentially calling put_device() where it shouldn't. > > diff --git a/drivers/mux/core.c b/drivers/mux/core.c > index 23538de2c91b..7c9180dfaff6 100644 > --- a/drivers/mux/core.c > +++ b/drivers/mux/core.c > @@ -9,6 +9,7 @@ > > #define pr_fmt(fmt) "mux-core: " fmt > > +#include > #include > #include > #include > @@ -586,13 +587,13 @@ static struct mux_control *mux_get(struct device *dev, const char *mux_name, > if (!mux_chip) > return ERR_PTR(-EPROBE_DEFER); > > + struct device *mux_dev __free(put_device) = &mux_chip->dev; > controller = 0; > if (state) { > if (args.args_count > 2 || args.args_count == 0 || > (args.args_count < 2 && mux_chip->controllers > 1)) { > dev_err(dev, "%pOF: wrong #mux-state-cells for %pOF\n", > np, args.np); > - put_device(&mux_chip->dev); > return ERR_PTR(-EINVAL); > } > > @@ -608,7 +609,6 @@ static struct mux_control *mux_get(struct device *dev, const char *mux_name, > (!args.args_count && mux_chip->controllers > 1)) { > dev_err(dev, "%pOF: wrong #mux-control-cells for %pOF\n", > np, args.np); > - put_device(&mux_chip->dev); > return ERR_PTR(-EINVAL); > } > > @@ -619,10 +619,11 @@ static struct mux_control *mux_get(struct device *dev, const char *mux_name, > if (controller >= mux_chip->controllers) { > dev_err(dev, "%pOF: bad mux controller %u specified in %pOF\n", > np, controller, args.np); > - put_device(&mux_chip->dev); > return ERR_PTR(-EINVAL); > } > > + no_free_ptr(mux_dev); > + > return &mux_chip->mux[controller]; > } > Disregard, I accidentally forgot to build and now GCC is screaming at me with "ignoring return value of..." errors. -- best regards, max