From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-f170.google.com (mail-oi1-f170.google.com [209.85.167.170]) (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 3E63418DF89 for ; Fri, 7 Feb 2025 16:29:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738945759; cv=none; b=qTIgxkfu0VxGUatE2rFF4nIP0+0mu8rgtZlkvbGxHYGK1R/GIOp8DaV0TcuK7GmHH00VEZfvLE0CcNmU/Leyr1jCuk6bQLA5C+gy3tpbvufX6jQ+oZriG0wAzUWJNKSDAIaoJUuM8zX0AORR3xtrNuqXObwS+V9n61pTaET5klE= 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.170 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-f170.google.com with SMTP id 5614622812f47-3f34101f68eso471400b6e.0 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=m9HoMqm/qhN1mYPraIe3G2d7uS3fwGn+18QnQr9PMLcQvM6QJ/K3RBLmO0xfyzQZW7 bkq68fdBnWQBPmQxln34a3J6CUS6mWoJiOO0eWFBaH+igstijcQycC8vUitBye53xl4R bWuDgx2q+8SnmhXkxnSslyYd4CqX+HFu1gcvxVlj1usX4Bdvf8XZmcvB8rNgf12QXBoo 381o+KrnQScz1iLCO0ECMDvh8JTF7lb/ItmLbWtbR4uHQ1fLk/gsbr6l2T6Rp3QMU78Y cTblrWBLyEF8a6tTv9ELqta3FHp3W97cxsR/YvJHhV74g9NaV4PdueNN2yMhLSyCDTRw z1xw== X-Forwarded-Encrypted: i=1; AJvYcCXTRwSXynASsv4TWLA2s1RLn067pZt4AM/mjitaIUlKtXeDymHdoBe6azC09WGcz6gOzp6JAZk=@vger.kernel.org X-Gm-Message-State: AOJu0YysjMTAOJ9dKO0VaiPKI0aUzyjVrpgWScNDNpGrAABKWW19lBCC n8IIIo+cQqiCUREgYpr3pj1VcoXfZC6R/0/5exCP2TFmrEA6nMPyhVC5CbKpJMU= X-Gm-Gg: ASbGncsG3olQG2i6c/7Bp3qCBK7n9W+NmKWwhatf/LbB0H8oVIiJsPPbyMdI9YfGHih g8YkoUlfL/Yb1zBhFqSGWILPx3KhhlHmqkimJ7usRdNmvuoFtEEM0W9lH5V098CNZWBGDgcDJab JYG03m1717fjHLCjuyo+KtoWrqzJ6bpyEowPYw/pX8kbOngQVOVx7Q+Uii+hhIec1RI5Tto7POy FZlSKfkRGEA4o8R0Qm63xlXnLIsym1PtfAcn0ypvj/OF9vdlag9sA7EezQ+KvBOjmPKKy+YhLp4 TJR+L+SkpvOcsyUcQejn7q8EFFUZL6S2JlRI/frkQw/Ck/kwhu6W 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: netdev@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 >