Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp73951pxa; Thu, 13 Aug 2020 20:05:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrzF6E5XdkDb5bSh9gBHeA0XoRiiheb6X6oxfIx+A9r49VBc6WmaQdOx+Cn/9Cdz14giFC X-Received: by 2002:a05:6402:1a23:: with SMTP id be3mr398972edb.138.1597374313544; Thu, 13 Aug 2020 20:05:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597374313; cv=none; d=google.com; s=arc-20160816; b=LrEbl/6MKIWxQzXiiUTBW/v5cfvb/zx2cH7gG9mbbaT1ynMcV7242IWpNIW3aq76Ql 4Vzst+MGz1i/gkiax8ucy7gLoAskj7hydzuH8+sexYowkvUs3fO8zb/2Zg8Fm1MScsYX hRIbLKs3fjOKuboCI0wi75lc968dLpMf1lQZnELsdHQijQeQ+wUjiylQ3PcuPVDQug9H v8EeJJ4elLs9kPgym8g7gTIw7P4NFabJtIjTd1+uSZ0FiaamL4T0/C8+sTz2+9O1AiZr u83vjG8ZBVOwKpqieQM7MV0TdDTz7MWIfaIPhPWZWs/q++cld6OnD8hE0wD5x/dhT5Bp otkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=s4z3c80rW1f77SHZ1DJfS7Y59f6hWqfux6WtIWEmMvU=; b=rmzJ0qaSR12t2t6sSdZ+R1oPg4moQeFfLmXaGVTqteTZ+OnNPJboaBGHwtMhH3fgfo GDOn99U9YJHRud6GT0WR8rYo8chsH0r8hdjgqK0YfOKyra0o8PSz6Eg6xXSMWXkPqjOu DzK9VskcxyJ6svBEpnsybbOeQM+tNpppRSRVVIlGQezVevVHW0mfSKY4MU3m06+ipSFC 8fZQMwOzOCEkFV6ViGTPAuU5/M8LoLmzcWSU8k1dBBg+Pi0X2/vzB1GR5ebJOKFm6A/A a2cdPJXUW+i9nZCbAavx0WP66nvtEZNy1ZaRjMWeQSXm7Pxe6iQZDHNDJk34IbYSLEK9 GVPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="jE56/qNS"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f16si4304079ejx.464.2020.08.13.20.04.50; Thu, 13 Aug 2020 20:05:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="jE56/qNS"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726735AbgHNDDl (ORCPT + 99 others); Thu, 13 Aug 2020 23:03:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726564AbgHNDDk (ORCPT ); Thu, 13 Aug 2020 23:03:40 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BFF3C061757; Thu, 13 Aug 2020 20:03:40 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id v5so1381219plo.4; Thu, 13 Aug 2020 20:03:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=s4z3c80rW1f77SHZ1DJfS7Y59f6hWqfux6WtIWEmMvU=; b=jE56/qNS2bR2eU/znoGV6CpLP/o/OxHAV7hxz27u+pQJgrjwR0rrwTLvEKS/buhcNp 0TYpM+FeHKK3knW1+S+DcLD7UcvslV2WSB8A6zrYREsGr5R8uyASKqg5i7Vm+D6cp55F KUxt+BVIYKnPqpN90JwU60FDmEpUdEfVSEZkYFame9ShRYi991AmZ7s4OaoG/OjivJHd Ph5lxUv/MhYDOp/zElspaZl7ROy1q2H5DM6MHkoBECCwdzAtnBV9rbkygk9K3xx9yQf0 1O+6xWcugPAoIl6FdjNw3bjCteX/JW3SWYRNEH7OqvHuHHSaTZ8HsWfl38xoL/81lzGz yHbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s4z3c80rW1f77SHZ1DJfS7Y59f6hWqfux6WtIWEmMvU=; b=Y1AgtAkXe8PwQXkB92Nt9c5OcCHks4VuBTNJdZ1eUol0x9JbUMIDHFZ7/pDUh1Adgu LZ0twysFM0Daqz7MA0QCrVSchWFil1Q8Ry2kr/KyZvkH0Uc176heqMyUVkUqpgC3uVhp mQ1X3xt3czDzZfLmk9ovw1Sub75rU4ajxVxM4etp4cuVXm+nqKNwKkX1euAYdOB4qVCV 0s/ZE7OEsORCP6KL8FU7oQLOJz68ZEdCdVEFyNiTlmu74komJ9gqSfrvhW8n3ngC9hiA SnLZlRRFZALYkpTbEhnwOguAS+YiVnd725qxEE3UPgFQq/3BUTy3xf48ot+utJSZUgsO LFEw== X-Gm-Message-State: AOAM533HOV/f0yil/rOVNjSUkhzNlxNKERe0juWUm2tCa6Rs/aZ+ulOS oKWHtBWzcJegqvvn8/CAJgrhGY1j X-Received: by 2002:a17:90a:e50d:: with SMTP id t13mr571289pjy.33.1597374219770; Thu, 13 Aug 2020 20:03:39 -0700 (PDT) Received: from sol.lan (106-69-161-64.dyn.iinet.net.au. [106.69.161.64]) by smtp.gmail.com with ESMTPSA id z3sm6522231pgk.49.2020.08.13.20.03.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Aug 2020 20:03:39 -0700 (PDT) From: Kent Gibson To: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, bgolaszewski@baylibre.com, linus.walleij@linaro.org Cc: Kent Gibson Subject: [PATCH v4 03/20] gpio: uapi: define GPIO_MAX_NAME_SIZE for array sizes Date: Fri, 14 Aug 2020 11:02:40 +0800 Message-Id: <20200814030257.135463-4-warthog618@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200814030257.135463-1-warthog618@gmail.com> References: <20200814030257.135463-1-warthog618@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace constant array sizes with a macro constant to clarify the source of array sizes, provide a place to document any constraints on the size, and to simplify array sizing in userspace if constructing structs from their composite fields. Signed-off-by: Kent Gibson --- include/uapi/linux/gpio.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/include/uapi/linux/gpio.h b/include/uapi/linux/gpio.h index 9c27cecf406f..285cc10355b2 100644 --- a/include/uapi/linux/gpio.h +++ b/include/uapi/linux/gpio.h @@ -14,6 +14,11 @@ #include #include +/* + * The maximum size of name and label arrays. + */ +#define GPIO_MAX_NAME_SIZE 32 + /** * struct gpiochip_info - Information about a certain GPIO chip * @name: the Linux kernel name of this GPIO chip @@ -22,8 +27,8 @@ * @lines: number of GPIO lines on this chip */ struct gpiochip_info { - char name[32]; - char label[32]; + char name[GPIO_MAX_NAME_SIZE]; + char label[GPIO_MAX_NAME_SIZE]; __u32 lines; }; @@ -52,8 +57,8 @@ struct gpiochip_info { struct gpioline_info { __u32 line_offset; __u32 flags; - char name[32]; - char consumer[32]; + char name[GPIO_MAX_NAME_SIZE]; + char consumer[GPIO_MAX_NAME_SIZE]; }; /* Maximum number of requested handles */ @@ -123,7 +128,7 @@ struct gpiohandle_request { __u32 lineoffsets[GPIOHANDLES_MAX]; __u32 flags; __u8 default_values[GPIOHANDLES_MAX]; - char consumer_label[32]; + char consumer_label[GPIO_MAX_NAME_SIZE]; __u32 lines; int fd; }; @@ -182,7 +187,7 @@ struct gpioevent_request { __u32 lineoffset; __u32 handleflags; __u32 eventflags; - char consumer_label[32]; + char consumer_label[GPIO_MAX_NAME_SIZE]; int fd; }; -- 2.28.0