Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp429482rdb; Thu, 22 Feb 2024 08:03:24 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVoYI74x666kLFOCZ6uFPo7fOYfKqm/p0BAGVrDveOA4hzA27SC5FasrHqElls5jIsHieRjW4fKTd2Ol9WzL40sjj3nctY3WaQcAw4B2Q== X-Google-Smtp-Source: AGHT+IExp+SDs1FoTFsDuD2F0OgKAGE632iBnq2BGTRBs98praOuHS/ZgapGwKUXOFvsI5uhxdgS X-Received: by 2002:a17:906:7c92:b0:a3f:357b:d995 with SMTP id w18-20020a1709067c9200b00a3f357bd995mr3796724ejo.1.1708617804180; Thu, 22 Feb 2024 08:03:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708617804; cv=pass; d=google.com; s=arc-20160816; b=ShrXgdBn/F5nJ2ztJlU5EzFHVDN2srZfV5JAu1542Uyczqc8OTTl3n9YgMa8F91QBb pi1rMFqcFKM4uuqQM+Flti54HDYphbFSLApZUDRF8IVx0Wjdg9pkxpfUV22dQOIeAM/p i+y3qz4UPEqx2vkhPQMh85PZ1b7NG+diC4D6WckTk0jX62inVZuVBBKDKAvNNVc9fnt6 lfbNkh/XQ/Q6slqe/E9TqGDUwkbU9xvokqNgQh6FRi7wmzcwZz/MPPHzUHAKPVaF3MBM NpvIXfmu69RPQDJ1DJrRNzxuhfX2ZazEh/kWDzeWcY5mX+OZc2yJaaTceBMa2nqbfqdE 6QxA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :sender:dkim-signature; bh=zmfGugikQMjXAKoK91kY7BKBKEQ6iIZOd74HOBnKvEw=; fh=L6ZwY/45XD9xhy5/ED9UKsj2LYdTclZco0GaP+YgiyM=; b=O0IY5z8RDiABgHgj71ktqL8oWRVBVUX2uRLK5iIWC2Wk94f6A/pLAyK6LOXpE5mTMI ZhVEcsJHyksN2aWt7Nx4xrPzbhET8vCQcFLLOLRTmc5tEX6X2+nbEneCH4196TUhP6fT wkzZLRDG/1Jjf60dPyBlSdxS2nSuSioYyeYXpqSQzuu1whbbJaYZDoBptBc4LBArZNsm RygSdLZPUCQCFawiqmHd9Cg04grczy5IyYhd5a38s8Cm/ahC6uM/5CCPt3b+9t+epVVX iq7KNh3btrWuTaPm7H8gwGAtlktgZ8LAJHyL7gUEPEyYyOhjvfpDTRN+qbOdpJHEbf6x m3hg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=UOED4nwm; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-76842-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76842-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id f10-20020a170906084a00b00a3e7636f513si4153457ejd.167.2024.02.22.08.03.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 08:03:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76842-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=UOED4nwm; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-76842-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76842-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 781971F24CF0 for ; Thu, 22 Feb 2024 16:03:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 30E2814E2C9; Thu, 22 Feb 2024 16:03:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UOED4nwm" Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (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 7EBEC14E2CB; Thu, 22 Feb 2024 16:03:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708617795; cv=none; b=QFDx97U2sn+soUZWvg7s/z6m+g57G7AFefrA2+GAL5nrcNNUO5Wn7nMT+MhRKQg9WcOMfp0dSepOawZb/7JzEQBBtpsGpmRxC1ujageocRd+WS3pLKXqFTzGADQ879hQ7JWIcjLsqs5glKvlWWKNkLL3oD2hMdXAgLyFIQB5rTM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708617795; c=relaxed/simple; bh=ZzTjmOQds9KovKFGXLCTE8JT9BXUhegvI7WlqiNBr30=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=YszcMuhOV1BMODcAPrXxdsyhLabjKeaR1zEA6QgDvsDSGaNnbzdGHdc8W44afF0hS0BK/CKgCpfExKUkdPgV8RhFD4suBhmPDCTjA+dlv85dbn2feLNCUkm9NTTSNe8EJEype6kF2Sz71IeCIRNEgqCSjQKKJapYltsMMvKfdes= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UOED4nwm; arc=none smtp.client-ip=209.85.210.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-6e471f5f1a5so2767975b3a.1; Thu, 22 Feb 2024 08:03:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708617793; x=1709222593; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:sender:from:to:cc:subject:date:message-id:reply-to; bh=zmfGugikQMjXAKoK91kY7BKBKEQ6iIZOd74HOBnKvEw=; b=UOED4nwmnSxNGD45iov/m/UeUsRjJoJNX5/xuJnM+bnD09dRQqkedrVzmNYFFbiIQ+ PIM0/BmWrjbB84GJwh/g7rTi8aXOz/gRKaCxvHs7s4aNnUw5avnGoxkxzJqMVVibVgb5 WTPXOJ5XHxgoVwipj+Pqmwnf9u1GkfiRsPEWgeWNW73JSEbsy0dZfxYdiKohQjoKLIJ+ 6IafMdcNwaQ7KDkOesvukFf/PnbQMhpy+sROXKM7rW87rEzaow+vnaDxH43eEYEUINEK dJ8sPRRgr+J3Opa/3ce1IYIrR41WgZHzTTet8nERCZql3FWtyWMrnexngQTr2Xjc8YV4 Wp8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708617793; x=1709222593; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=zmfGugikQMjXAKoK91kY7BKBKEQ6iIZOd74HOBnKvEw=; b=UfTtQUyfmv3kXQwI5e114u7iev29wIWKxmjt52b9LCB0K8OT7LQ8WQaw5yCGviRaE/ Z86Sb6k1GXCByN+oXnyK4fSEochjm5SRfKy+G78HhWdVQA6786Cd7eR1F6k6akBE3V4e 3xZy6biNhgGE/nHImi09enI7xl6kDFNX6PMFYTJaBBpBAfbo/Wp08ffEGIPQr307WEdw ZaWleF+kLkfNp/Vjmr66qgYcHLegemlmMtxFNEEhL/PYscM8w+H4b8BChRDRd7lQoNGc Ihc1UAVm+sQwwOJbBaWyP2PFCkjvTi+V0m/H2NHELVBP5dwVhNGrrsqUv155WfLpJr0E +k3A== X-Forwarded-Encrypted: i=1; AJvYcCXxBhVwTZSFZo8ZqY1UUAZvmK29Y+MFXQMoHFdzrAwBPMJERb7w6XJ+tnXBnsU5JwEqVvUiVJ9xE5VpMbWRqKxHtuboixh/k7a8yCymiKaT6+wdI5E344xdCa5QP1D8xj0/ZuYvUQgOyLOR795W0QOWeJhocEvYY7WcgGo1n6Lbs+FwozZ8Er7lhWPlFLE4eiV+2xeWog0naFKfv7IIsgGNHVDIIf7t19wCT3+C+23uUhCKkGEUvWUgAvJ5 X-Gm-Message-State: AOJu0Ywkm3a7PZdtjHutEs1+AViH/uYaJ8+MKa0c5odiB3fTuCihmO6H 7OcMsgV8JuM0ZSk6sR3dh0d2j1yqfA7TS+Fq0kjRkWLmuAEf/V67 X-Received: by 2002:a05:6a20:6f96:b0:1a0:7f19:b2b1 with SMTP id gv22-20020a056a206f9600b001a07f19b2b1mr20747791pzb.26.1708617792716; Thu, 22 Feb 2024 08:03:12 -0800 (PST) Received: from ?IPV6:2600:1700:e321:62f0:329c:23ff:fee3:9d7c? ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id e20-20020a633714000000b005c1ce3c960bsm10802514pga.50.2024.02.22.08.03.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Feb 2024 08:03:11 -0800 (PST) Sender: Guenter Roeck Message-ID: Date: Thu, 22 Feb 2024 08:03:09 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/2] devm-helpers: Add resource managed version of mutex init Content-Language: en-US From: Guenter Roeck To: =?UTF-8?Q?Marek_Beh=C3=BAn?= , linux-kernel@vger.kernel.org, Hans de Goede , Matti Vaittinen Cc: Linus Walleij , Bartosz Golaszewski , Lucas De Marchi , Oded Gabbay , =?UTF-8?Q?Thomas_Hellstr=C3=B6m?= , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Aleksandr Mezin , Jean Delvare , Pavel Machek , Lee Jones , Sebastian Reichel , Matthias Brugger , AngeloGioacchino Del Regno , linux-gpio@vger.kernel.org, intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-hwmon@vger.kernel.org, linux-leds@vger.kernel.org, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org References: <20240222145838.12916-1-kabel@kernel.org> <4a545c16-7518-49d2-b158-7fcabe3508c5@roeck-us.net> Autocrypt: addr=linux@roeck-us.net; keydata= xsFNBE6H1WcBEACu6jIcw5kZ5dGeJ7E7B2uweQR/4FGxH10/H1O1+ApmcQ9i87XdZQiB9cpN RYHA7RCEK2dh6dDccykQk3bC90xXMPg+O3R+C/SkwcnUak1UZaeK/SwQbq/t0tkMzYDRxfJ7 nyFiKxUehbNF3r9qlJgPqONwX5vJy4/GvDHdddSCxV41P/ejsZ8PykxyJs98UWhF54tGRWFl 7i1xvaDB9lN5WTLRKSO7wICuLiSz5WZHXMkyF4d+/O5ll7yz/o/JxK5vO/sduYDIlFTvBZDh gzaEtNf5tQ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kjqtcbw41SjkjrcTG wF52zFO4bOWyovVAPncvV9eGA/vtnd3xEZXQiSt91kBSqK28yjxAqK/c3G6i7IX2rg6pzgqh hiH3/1qM2M/LSuqAv0Rwrt/k+pZXE+B4Ud42hwmMr0TfhNxG+X7YKvjKC+SjPjqp0CaztQ0H nsDLSLElVROxCd9m8CAUuHplgmR3seYCOrT4jriMFBtKNPtj2EE4DNV4s7k0Zy+6iRQ8G8ng QjsSqYJx8iAR8JRB7Gm2rQOMv8lSRdjva++GT0VLXtHULdlzg8VjDnFZ3lfz5PWEOeIMk7Rj trjv82EZtrhLuLjHRCaG50OOm0hwPSk1J64R8O3HjSLdertmw7eyAYOo4RuWJguYMg5DRnBk WkRwrSuCn7UG+qVWZeKEsFKFOkynOs3pVbcbq1pxbhk3TRWCGRU5JolI4ohy/7JV1TVbjiDI HP/aVnm6NC8of26P40Pg8EdAhajZnHHjA7FrJXsy3cyIGqvg9os4rNkUWmrCfLLsZDHD8FnU mDW4+i+XlNFUPUYMrIKi9joBhu18ssf5i5Q= In-Reply-To: <4a545c16-7518-49d2-b158-7fcabe3508c5@roeck-us.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Oops, sorry for the noise. Shortened reply below. On 2/22/24 07:24, Guenter Roeck wrote: > On 2/22/24 06:58, Marek Behún wrote: >> A few drivers are doing resource-managed mutex initialization by >> implementing ad-hoc one-liner mutex dropping functions and using them >> with devm_add_action_or_reset(). Help drivers avoid these repeated >> one-liners by adding managed version of mutex initialization. >> [ ... ] >> +static inline int devm_mutex_init(struct device *dev, struct mutex *lock) >> +{ >> +    mutex_init(lock); >> + >> +    /* >> +     * mutex_destroy() is an empty function if CONFIG_DEBUG_MUTEXES is >> +     * disabled. No need to allocate an action in that case. >> +     */ >> +    if (IS_ENABLED(CONFIG_DEBUG_MUTEXES)) >> +        return devm_add_action_or_reset(dev, devm_mutex_drop, lock); >> +    else > > else after return is unnecessary. > >> +        return 0; >> +} >> + >>   #endif > >