From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) (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 334FE14E2C2 for ; Fri, 7 Feb 2025 16:29:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738945759; cv=none; b=RI7u1UZ6FnbP17EeEjhnKeiZFdSiRA7PJi0zsxQInxXvURQEP+m3ks744xjD5MksNDBMttv1i6xBJHht2u9rFm6N9xijBoonJ55iqMKKaZhHLdf3+mAvdRFqbUdEGajs69mM4Jx97OQ7OMXRA2CCN8eQ9EL8cCiyJ6xvqpbAbwU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738945759; c=relaxed/simple; bh=57uHeJssUhSTwboeRjLbjHP/8gebXbxQ08iLQ68S9QU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=BSJp/p6Tt01lvSQyP7bgQsY8JTMHj6jcWSoxNwF73k8wZUWxVxJChM+3Qujj/M+n9ppbRKoVxvQ37S9v3fAzNUxlzg6CceHfSr/4QOJPEEEUT5r0CG5A3cPxU5HfmRbqyfxMouUeS260s69ZKqUiCM2qcmZtm36sLOeraavXe+o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=mtEJ1Sr2; arc=none smtp.client-ip=209.85.167.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="mtEJ1Sr2" Received: by mail-oi1-f175.google.com with SMTP id 5614622812f47-3eba0f09c3aso703443b6e.1 for ; Fri, 07 Feb 2025 08:29:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1738945755; x=1739550555; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=k5z98lSfe6WwRG+wC0Tg6PRqMgic/o2qF3h3J+ulLEk=; b=mtEJ1Sr2l7/lIK8nvmtXf2sOSfDvQGnL/msUKLZ4fK99Rd4clSOcYOIj0eFfGaLOdX PhbPZ29bbmJC0xUP5e0yRlFjkXShnUq/dnZ/WcJcZ9M7t7eYficY5G1lTOMk0+/DyFz7 e7suiMpue9zPF6ivH9gxewbO9CUN2xj5AcJLrNAWv/c297UzMkAI7UiZLl1csBec2nzX TKEh6k+Px2lri8jnJt3ooEj+r4MH63cF5+lZ0wLdUaKwV8lZvZ4i9cjd0QcxPZu2haAn qI9z/jykdLqcHLrqXuxBKAy1uKVNi2IOwAJY0Rl1NN0AWeZ68C+NE4/maNTj/grV7fSA H/KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738945755; x=1739550555; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=k5z98lSfe6WwRG+wC0Tg6PRqMgic/o2qF3h3J+ulLEk=; b=NRyZLZk6GyAVanmA4r4+eYQLgFxeCxA/Ba2XiV1ntFvAHLT1ITZIsUyI04acVWfprw tYSivFeFVM6M0WSHE03wgfAwA8wDspfL82ByYzK25CLe4QZK6EPon1ySwfUJgxPgmWdl LkosKZXMxKuJ8t4WuNVsOFhM75aOjMjzeLmGNU10lRwiCkpuyOuiTbJm+ZwTO3T6tSBZ NDv/UuOLJxAJmcFrGWVu8eG0bh3o8iEZHBil4xGTlHiLA4G3wlAJSk+kiP6AGzOd1VO8 7gXwdjVm4VmGOklMo1zqCA/VXXqBc37tCND44r3MG999LF4Lh/jcAAXXk+HDe9b2ZA9d f0oQ== X-Forwarded-Encrypted: i=1; AJvYcCWBEJaJ6Xq24CvrnfrL1WxNUZtXWCI9JHczQcNeGfHYBZIP9HkPz2rpvwmI+HzwpLarG7nIX4SmULutlbk=@vger.kernel.org X-Gm-Message-State: AOJu0Yzp0mJS3hZy6NuPyfxSEzwPjgNtVFRDEa7rAeeMt8ZUf5pt0CF0 8KG6PxgzLmtspx14luXbuCCbOtdlQ64lAIp96Ic/8/foExQWRzKlbQNZuYTFnJU= X-Gm-Gg: ASbGncvy+xG1lDKBLnyAIM4NLRITFjRU3SLjm2t9y/QaiFhOQLXjCJgOY7ja+8hJtx8 tpP99FQ/0hasciKG26F+diH/Ahk1BvNKjBK3fPhJ4zQ82EkVor/gPYOJ4mY08hdP28MCid6iTU1 uE/Xj9rdZNKtB810IHeN/d7T6XMODzjourcgQQC6/vWn8EYsQSASak7cV3Xvogt/vIkrQHHqLo3 HbzOISzBVVfjOACwv1YX//WVfoEI7dtBUp29xLBdyzjtG3HU6pSAygXo38StbA248sASTnF5AX1 GLxLfvEbarG/jTV5Oe3hvi5kKbE3FzhQm8uawZr3kId8/CzeNiUg X-Google-Smtp-Source: AGHT+IG7StedQ5Vnf2T8W9EtvcPrRVDItpyl7T3DBHEMIV0RzDgNrv3XTiomaadolzmBwJACvP6VXg== X-Received: by 2002:a05:6808:30a3:b0:3e3:bd1c:d584 with SMTP id 5614622812f47-3f3922d9a38mr2709674b6e.9.1738945755147; Fri, 07 Feb 2025 08:29:15 -0800 (PST) Received: from [192.168.0.142] (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3f389ed6220sm756084b6e.15.2025.02.07.08.29.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 07 Feb 2025 08:29:13 -0800 (PST) Message-ID: <74ec33db-6721-4b86-86a6-e18b0a01fc47@baylibre.com> Date: Fri, 7 Feb 2025 10:29:11 -0600 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 v2 01/13] gpiolib: add gpiod_multi_set_value_cansleep() To: Geert Uytterhoeven Cc: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Ulf Hansson , Peter Rosin , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vinod Koul , Kishon Vijay Abraham I , =?UTF-8?Q?Nuno_S=C3=A1?= , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-mmc@vger.kernel.org, netdev@vger.kernel.org, linux-phy@lists.infradead.org, linux-sound@vger.kernel.org References: <20250206-gpio-set-array-helper-v2-0-1c5f048f79c3@baylibre.com> <20250206-gpio-set-array-helper-v2-1-1c5f048f79c3@baylibre.com> From: David Lechner Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2/7/25 3:10 AM, Geert Uytterhoeven wrote: > Hi David, > > On Thu, 6 Feb 2025 at 23:48, David Lechner wrote: >> Add a new gpiod_multi_set_value_cansleep() helper function with fewer >> parameters than gpiod_set_array_value_cansleep(). >> >> Calling gpiod_set_array_value_cansleep() can get quite verbose. In many >> cases, the first arguments all come from the same struct gpio_descs, so >> having a separate function where we can just pass that cuts down on the >> boilerplate. >> >> Reviewed-by: Linus Walleij >> Signed-off-by: David Lechner > > Thanks for your patch! > >> --- a/include/linux/gpio/consumer.h >> +++ b/include/linux/gpio/consumer.h >> @@ -655,4 +655,11 @@ static inline void gpiod_unexport(struct gpio_desc *desc) >> >> #endif /* CONFIG_GPIOLIB && CONFIG_GPIO_SYSFS */ >> >> +static inline int gpiod_multi_set_value_cansleep(struct gpio_descs *descs, >> + unsigned long *value_bitmap) >> +{ >> + return gpiod_set_array_value_cansleep(descs->ndescs, descs->desc, >> + descs->info, value_bitmap); > > I am wondering whether this needs a check for !IS_ERR_OR_NULL(descs), > to handle the !CONFIG_GPIOLIB and gpiod_get_array_optional() cases? I don't think it is strictly needed, but could be convenient for future use cases. If we add it, should it be: if (IS_ERR_OR_NULL(descs)) return PTR_ERR(descs); or: if (!descs) return -EINVAL; if (IS_ERR(descs)) return PTR_ERR(descs); ? For comparison, gpiod_set_array_value_cansleep() will return -EINVAL if the first argument is NULL. > > Slightly related: shouldn't gpiod_put_array() (both the implementation > and the !CONFIG_GPIOLIB dummy) allow the caller to pass NULL, to > streamline the gpiod_get_array_optional() case? > >> +} >> + >> #endif > > Gr{oetje,eeting}s, > > Geert >