Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2667625pxk; Sun, 27 Sep 2020 17:31:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzw4bBRUBVwUxTCYSAs9zoQtrgIUkbEgGHxdSd6WAedC0/ICiWY2MRb8oWifPt1JcK9YRNU X-Received: by 2002:a50:9355:: with SMTP id n21mr12781118eda.237.1601253062031; Sun, 27 Sep 2020 17:31:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601253062; cv=none; d=google.com; s=arc-20160816; b=i1oahzsGlgLhqWizhQbpl/RIp6Ni8D8ZHqHJPDd+xamTbJFtKTg5cXcwZr4N+CxqlC nK6dWUaf0OdaWCDsqZW5KrPlhi28gg0ZskiCzLOCS21EqxbSOX1uxzkHxipdhVgtFV4n A+EngEEulPlSJSF0ucQTlhGCjPo6i39P7dE7+a68wc+PPaFm5N8ZuZm1vevbeiOFjh1c BfOBj97nvH5nRsiDFmMaJfj8vQhW51WLtdy8Xu/2rozmaE4dBaHbdRpg0nfxv4nTCBbY th3SCUSDlURIfTWxbFimqf8YehyeY0nBPFJQStH6tOVy/EhEdoUZzFHp90I2l/2GwP0F K92g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7Xmm15LbmubgcaoAcN8p4xddZgeXjh2diqDOrXM5Y2w=; b=Y5ogYs6j9OJNPgFro/tiN5/BAADixI0iNZCoUoyX23y5cGe9PmuUlUMn09wI4pRTbw XU76co7t99LkV0FYyBJJLd8qOoJ9t+6y9a3D/wpddlI6Q8aQkZ+tbjd7+rhuN+TZOKOl NqDT93f66TTlxQkQPpPAbiZJm8UGllcAOQUzH/iKA8A9/jNFlaM+YNL3jHFUPyD2XH1a pmbcesvXEDWXwgrHYOOQzknn32ZRvsuwLz66H933xpQwyJRLcqz6aev7HMJHjGuwfiuC VK92QB6AK/ZDpwBRrerFzpUPJ0T+JpqZppsaN7p/tV/fnKRCVmWr47myG1S4SPefQOl5 J37Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FnTt14dj; 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 s9si6134796eja.318.2020.09.27.17.30.39; Sun, 27 Sep 2020 17:31:02 -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=FnTt14dj; 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 S1726595AbgI1A3O (ORCPT + 99 others); Sun, 27 Sep 2020 20:29:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726393AbgI1A3O (ORCPT ); Sun, 27 Sep 2020 20:29:14 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AEFAC0613CE; Sun, 27 Sep 2020 17:29:14 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id n14so7749682pff.6; Sun, 27 Sep 2020 17:29:14 -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=7Xmm15LbmubgcaoAcN8p4xddZgeXjh2diqDOrXM5Y2w=; b=FnTt14djxHJAdf7yF1iDMqsEgp8UOZGjwgHBgjTFK2uhnrgOdPipcs1c3xLY7uoeau /k+IQq6tukbuuXf5uXk8rX+W47nMH+rSx695kbBGgcp6Q+UCUAZoDKnG1KDLZR8Lzo3q EZspUjDxBrQxll+H9Q+LbKobab57/J8OLEziwpr8YuN6syiEmk+Jjc4bo0peI5A/4WUt s0oLaNtR9KDtgR+ZJCaKQpuGCsFmZaCetPg5xPCg9jeDMLJxaVUlGdS8DqSPkMjjzN+5 yHlo3THul0K9jHbsk+l9apL8AsCTGIFSJ3heumR8GASbdXO+Q6PGDvckny+yNaq1kIso gJbw== 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=7Xmm15LbmubgcaoAcN8p4xddZgeXjh2diqDOrXM5Y2w=; b=owbTQEXjkFLW0/qSV03HPGRpQvhgz6nXo8SPyDUFwzjlBq+Vvtg3Dx5haOOzruwAK4 zGEz3xtXwu5hsylpk8h1fklhjVovlDJW6oXrTK0TPu0bEZIIfLxgqFBocEGFPx/svRNT 0Zshebs1EyLKEbaeIK0QUd1dZetoX0Zfbdstrk3t4HgiBSsNCO3pVpdiP1mLTKXOxtCD CFg/wOS4x5ysyXJSsf6UFmcAA1QaIEktwrXNrJ37YrhOKtKghwiHkQhW6bbuXgfbWzOr BO8TVyOthFwFYRTAzL9WRWwSH7El8Hm2vmi/1RPbUw+WQU+zbOaMI3xxfeK6+fqY8McP vfDw== X-Gm-Message-State: AOAM532h0kB4wnYjAbTBcFVbo/rcJ8kiCR0KudHpHiKJteONxT18RhoR C0sZ30W50njuvEELZrWzS/+kHaKrYFAYHg== X-Received: by 2002:aa7:96f1:0:b029:142:2501:39ed with SMTP id i17-20020aa796f10000b0290142250139edmr7893101pfq.60.1601252953289; Sun, 27 Sep 2020 17:29:13 -0700 (PDT) Received: from sol.lan (106-69-171-132.dyn.iinet.net.au. [106.69.171.132]) by smtp.gmail.com with ESMTPSA id o20sm8443783pgh.63.2020.09.27.17.29.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 17:29:12 -0700 (PDT) From: Kent Gibson To: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, bgolaszewski@baylibre.com, linus.walleij@linaro.org, andy.shevchenko@gmail.com, arnd@arndb.de Cc: Kent Gibson Subject: [PATCH v10 03/20] gpio: uapi: define GPIO_MAX_NAME_SIZE for array sizes Date: Mon, 28 Sep 2020 08:27:50 +0800 Message-Id: <20200928002807.12146-4-warthog618@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928002807.12146-1-warthog618@gmail.com> References: <20200928002807.12146-1-warthog618@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Andy Shevchenko --- 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