Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp697915pxk; Sun, 30 Aug 2020 20:24:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzurKIqCif2678hVopgwBZNN4Gb0vT/6i1i8i9gLvY25a7C3vai2dE0IIIvVg14660MJvUB X-Received: by 2002:aa7:db89:: with SMTP id u9mr9178671edt.267.1598844298020; Sun, 30 Aug 2020 20:24:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598844298; cv=none; d=google.com; s=arc-20160816; b=AoUgI/H60BrFHZ0AtE/8NcL7PzgfCf5z5VhfhzJTAyEiAL2irhNWKH6cTmiXib/Ppx wuNoFzgYLmh0Y3OSjAj77qjFWa+iCmEKyQ0RAwBes8BnOdUBPOhpDD0/YkiQe9Ub6rzh jckqZ3PJP9c5jnss9whJdmp+6S3861XQ7bjfrtjPt3lVH4c5y4osx20pfIESTAfVD3De 8QlA72LISIqW96Ii76rQsAc/4BeNTwT2HMwnFgucQCXmFKz8gccrLNi66OJWyoJKIPTo AMfJ3S/hh+jTeVYMwgIbhMID58pVTzgwcWRSTF4bM5Elfa6ybWoWTcwma47ByN0D0gCA Vbpg== 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=XJu8Fr05mizISWB56Hlb10M0sf/dfg8bVJEiVB791u371odj8iB8AiBH50af1K0cBz QIYtZeZ4i6+j8nPgOc3mK96tEfvg7grH37cNc5lh412U+DydXUpjEpS1yIZcngSpSMRm /glrMiQye/YPSROABIkRac+KuNmZ8rU9yKh5AhHgloirPUsmRYbl62J5HY9GJxEibn9q jQt8+WsMFQIZfuNFZkmj0Ro+YSgNDKVKmHMetsWKebfUQ4oXWuo9Y0qxBKUkdOe7jgJ9 AoAY0dgA8/29lvDy078zw97A1ylyrFjT53GD7MW0oIVNWtc9sw0OqhnKjNoRkXqIbPEE RcEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QBcYBryk; 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 u28si4151537edi.531.2020.08.30.20.24.35; Sun, 30 Aug 2020 20:24:58 -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=QBcYBryk; 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 S1727883AbgHaDV4 (ORCPT + 99 others); Sun, 30 Aug 2020 23:21:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726838AbgHaDVs (ORCPT ); Sun, 30 Aug 2020 23:21:48 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CB0CC061573; Sun, 30 Aug 2020 20:21:47 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id mw10so2259730pjb.2; Sun, 30 Aug 2020 20:21:47 -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=QBcYBrykVgceqsMHplHHmauMcT+hfCWitLlosKJrBTnrq8+AMbi2I1V2j25ewurtoU 1AARVptcvo99ojPg1+dIvNZPHttlrt6nNDc8XevUvar9kWGwCXwbmhfUYXlYeR9kSrGL OD4bUzL5cOSWL72Nnt5VKhl62/fY4Z/jdc96iZ/b10kT/CyRZu+qp/7kfQghgGV+2xCa d6WjYWufWqV3Qef+5K2uOHTxh3sHaXFtMvY+e0UObojO3l80x0+hqHwRpFfnb5ope9ZK lS/+GXLtt1LZValWKUwIwDxguQWp6JPz+pVEwclYMgXRg0uOiDEVCN4VKZOWlRSytqmw S+Fw== 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=rpaRkuWekzFFDqZLyrVupE0MDB+Dyt7AV2qwT+PsJ1sDe0VEZTPykC3kOQ30gEfV0H Eld4mTVEducBxpgueDFgbWO7Ws8gtC9aIEfR0r21134f0H5ckTBqE4t/ejAUnMjZw/Qa d6u7B899U3Htd10bfISuOljDkHl3bH1mmL+vUAq+6Srk10Htc+WDblIw5pw1Gr3XEUNy 11EBnzdahJn5wL2skzALM3WGu+Coc8byg0kswVLeyXoxe38OA2NOxmyYCaNvfa/geMry DwBq4QoGBqnPy8kJrhdKq33KPuqQzcx4l6vqGZCJq9WCpWW7VNw1fwrd10Fuul+Lgxhc Y6bw== X-Gm-Message-State: AOAM531Ptm5fAluPefK25osCiG/V5V7ThJ7OPS1hMWR6fDxn8ElUU5CS MBl4Fu5U3OtoK1cD4AcUlcTaALKVHNs= X-Received: by 2002:a17:90a:7f8a:: with SMTP id m10mr9357767pjl.47.1598844106799; Sun, 30 Aug 2020 20:21:46 -0700 (PDT) Received: from sol.lan (106-69-184-100.dyn.iinet.net.au. [106.69.184.100]) by smtp.gmail.com with ESMTPSA id z17sm6095733pfq.38.2020.08.30.20.21.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Aug 2020 20:21:45 -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 v6 03/20] gpio: uapi: define GPIO_MAX_NAME_SIZE for array sizes Date: Mon, 31 Aug 2020 11:19:49 +0800 Message-Id: <20200831032006.1019978-4-warthog618@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200831032006.1019978-1-warthog618@gmail.com> References: <20200831032006.1019978-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