From patchwork Fri Nov 20 18:43:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Syed Nayyar Waris X-Patchwork-Id: 11921911 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70B80C6379D for ; Fri, 20 Nov 2020 18:43:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2DDA522470 for ; Fri, 20 Nov 2020 18:43:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ArT35zTA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731503AbgKTSnW (ORCPT ); Fri, 20 Nov 2020 13:43:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731383AbgKTSnW (ORCPT ); Fri, 20 Nov 2020 13:43:22 -0500 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 EACC0C0613CF; Fri, 20 Nov 2020 10:43:21 -0800 (PST) Received: by mail-pl1-x644.google.com with SMTP id t18so5326692plo.0; Fri, 20 Nov 2020 10:43:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=WXCokNcFtmUFZk8OkEAohOIZoUd84BUeBegjeYFXaK0=; b=ArT35zTApfxrR1D++Yl4zdVcqMbNXWKgsa0paeogv6PsVQMX08hAhXuEAm5XltrVWc uZe7e7D6Wh40OS7WDxbltcmSugAp0AaEPsobXvyuFAX2K77ZisSUsaDjy7XaXa+H6pBy EtGUG/Og/DE0Uq5zQnMh1aat6V6ektoPy6gdfoYdKJo7Z3V9Yb54w1Q4EYmn8rIX6NYA gg7AQ3SyOFoUv3GbH/RlX0Hs2LdAijINN/hfenjEZvDP5+rp/8Dbt1q3insU0jt9KufL OyTutRqH2qjpuuJPYMyu1PxUd8ZQz6J0FOXX0vhHSmRf2Ewu5cMRJSlpMkRGp5QwGi+D jbeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=WXCokNcFtmUFZk8OkEAohOIZoUd84BUeBegjeYFXaK0=; b=chHuOeIDvKczJdBeXUZ1u6kYIcjiQm9Yb5rohiIedMfvyy7FxVNFcNwJ0KdZaRsjvG 3o2nUpwIKdmbhLM39sSGaVIJXIyOx9qvECyVKxcjimRI9RFuIiZEV8/+EtgvEXERJPD9 8+D9049GHWNMCsKK63zdTkA+Sh0fdRQcQo3SN5+ndGNqdo8S/tja13e8y5lGpzlFtsyZ r2nbDENx5BP++dBx8wTLhsrD2Gku0TLBEjlOLtzf7FqmjrhLhrmlGEDsxzYwytQYsRFl lzVUkpm+9FQomfikX6Ijg8+TzSUXvfllDNytsQ5ThhviXZ0MQQAwkN7R3cV6KKMR+tLy jUdA== X-Gm-Message-State: AOAM531bdBDL57x5xrbBDWJpVZj878Iw0qZGVDGkZ1mYp/xNjt9Y2Xp3 0XvnpID72NYjwS5CBW6SRDlMS3HakaQ= X-Google-Smtp-Source: ABdhPJzohs3MmB+IkhzVGQX6moCZPPkrpU7OcKdu237FnWfI5fZuik401VUybcFI/uigj/eyV0ODXw== X-Received: by 2002:a17:902:bc46:b029:d6:d98a:1a68 with SMTP id t6-20020a170902bc46b02900d6d98a1a68mr14200054plz.63.1605897801482; Fri, 20 Nov 2020 10:43:21 -0800 (PST) Received: from syed ([223.225.2.215]) by smtp.gmail.com with ESMTPSA id p15sm5191603pjg.21.2020.11.20.10.43.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Nov 2020 10:43:20 -0800 (PST) Date: Sat, 21 Nov 2020 00:13:02 +0530 From: Syed Nayyar Waris To: akpm@linux-foundation.org Cc: andriy.shevchenko@linux.intel.com, vilhelm.gray@gmail.com, michal.simek@xilinx.com, arnd@arndb.de, rrichter@marvell.com, linus.walleij@linaro.org, bgolaszewski@baylibre.com, yamada.masahiro@socionext.com, rui.zhang@intel.com, daniel.lezcano@linaro.org, amit.kucheria@verdurent.com, linux-arch@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org Subject: [RESEND PATCH 1/4] bitmap: Modify bitmap_set_value() to check bitmap length Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add explicit check to see if the value being written into the bitmap does not fall outside the bitmap. The situation that it is falling outside would never be possible in the code because the boundaries are required to be correct before the function is called. The responsibility is on the caller for ensuring the boundaries are correct. The code change is simply to silence the GCC warning messages because GCC is not aware that the boundaries have already been checked. As such, we're better off using __builtin_unreachable() here because we can avoid the latency of the conditional check entirely. Cc: Arnd Bergmann Signed-off-by: Syed Nayyar Waris Acked-by: William Breathitt Gray --- include/linux/bitmap.h | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index 386d08777342..efb6199ea1e7 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h @@ -78,8 +78,9 @@ * bitmap_get_value(map, start, nbits) Get bit value of size * 'nbits' from map at start * bitmap_set_value8(map, value, start) Set 8bit value to map at start - * bitmap_set_value(map, value, start, nbits) Set bit value of size 'nbits' - * of map at start + * bitmap_set_value(map, nbits, value, value_width, start) + * Set bit value of size value_width + * to map at start * * Note, bitmap_zero() and bitmap_fill() operate over the region of * unsigned longs, that is, bits behind bitmap till the unsigned long @@ -610,30 +611,36 @@ static inline void bitmap_set_value8(unsigned long *map, unsigned long value, } /** - * bitmap_set_value - set n-bit value within a memory region + * bitmap_set_value - set value within a memory region * @map: address to the bitmap memory region - * @value: value of nbits - * @start: bit offset of the n-bit value - * @nbits: size of value in bits (must be between 1 and BITS_PER_LONG inclusive). + * @nbits: size of map in bits + * @value: value of clump + * @value_width: size of value in bits (must be between 1 and BITS_PER_LONG inclusive) + * @start: bit offset of the value */ -static inline void bitmap_set_value(unsigned long *map, - unsigned long value, - unsigned long start, unsigned long nbits) +static inline void bitmap_set_value(unsigned long *map, unsigned long nbits, + unsigned long value, unsigned long value_width, + unsigned long start) { - const size_t index = BIT_WORD(start); + const unsigned long index = BIT_WORD(start); + const unsigned long length = BIT_WORD(nbits); const unsigned long offset = start % BITS_PER_LONG; const unsigned long ceiling = round_up(start + 1, BITS_PER_LONG); const unsigned long space = ceiling - start; - value &= GENMASK(nbits - 1, 0); + value &= GENMASK(value_width - 1, 0); - if (space >= nbits) { - map[index] &= ~(GENMASK(nbits - 1, 0) << offset); + if (space >= value_width) { + map[index] &= ~(GENMASK(value_width - 1, 0) << offset); map[index] |= value << offset; } else { map[index + 0] &= ~BITMAP_FIRST_WORD_MASK(start); map[index + 0] |= value << offset; - map[index + 1] &= ~BITMAP_LAST_WORD_MASK(start + nbits); + + if (index + 1 >= length) + __builtin_unreachable(); + + map[index + 1] &= ~BITMAP_LAST_WORD_MASK(start + value_width); map[index + 1] |= value >> space; } } From patchwork Fri Nov 20 18:44:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Syed Nayyar Waris X-Patchwork-Id: 11921913 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 439D7C56201 for ; Fri, 20 Nov 2020 18:44:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DA31922464 for ; Fri, 20 Nov 2020 18:44:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JDmUnio1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731460AbgKTSo1 (ORCPT ); Fri, 20 Nov 2020 13:44:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731457AbgKTSo0 (ORCPT ); Fri, 20 Nov 2020 13:44:26 -0500 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 84439C0613CF; Fri, 20 Nov 2020 10:44:25 -0800 (PST) Received: by mail-pl1-x644.google.com with SMTP id s2so5298990plr.9; Fri, 20 Nov 2020 10:44:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=cK5F4d0qMv8rWJ7QrP6ojZzILBcMD6l3/NGR5/zHn7g=; b=JDmUnio1aSGCqFrCLxgQawip7qmMCTVk/WxT1wywIs4ubhldWhE81sZ8HL1BspCcwU ZpXoOLh3nCOau9q+oL5oYYEGs5uhiuybwEUGN9OAEaENpAUNux57VoeF6h5n+9PsMQ+b QsQK08JsbIq94vZ2aE47GM5BtKOGOp99nCI5PXeQogU3Hbb1Y9fxQxHDf8nH/0F+a+zf 0mMAjPimAH6SC4apd3jbLAlpXpPttDSNZrbvcf/YR+zI1Rn3UoKvs36bIhpW2T70FMxn 4RBwnlgYg4jrjFhgHjWtOKXBgHx0+MGYyjNrd+SyLGK9sfbjpHbKruTMeZSM5VnNI/tm 1qMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=cK5F4d0qMv8rWJ7QrP6ojZzILBcMD6l3/NGR5/zHn7g=; b=NpodfHcm35Khl0pIHR0+YgAK2h5AzRIFSz+1zod5mafyAKUvdRbcBsNRlU1f1BNVAd 9p7MtIAqt2y0KDjHCFUhD/I21gYZEn47s65EIpRTIx75kajs0Kt3VW/1EYgP+6eEqlYv 5jkmDkE4F8SLPeYRSu8Z1txgyQPZIG6iLmZ58RC7ja30KVGQnFSr2YaJCnIJ3BblpbVQ GUZPTYpmX2w453Apoxx1bR6jpBUwd2d1UjQVqEZWaHrhRHUZR7cZ9w6LSc70vq7uMe/u ElUMOEctW7tlwctY40jx736WvIhv7oCY8gMpMaswEBER1VKDztbPqFwV7xmRSCzjdkya 93pg== X-Gm-Message-State: AOAM532lmecvf9x/yU0kDEQVVLqb6vVc78kod9hbhv7OjGLgDMJQm6Xq kW79thPrqArkUBYEgRGrJjU= X-Google-Smtp-Source: ABdhPJz4LuKXhDhCCts6c4qxBuonU2yyA62xYcyZVA/6Ht5a1UW44vjUMzTXOBHxjTCPcprZwATb3Q== X-Received: by 2002:a17:902:8609:b029:d8:fc3c:b01a with SMTP id f9-20020a1709028609b02900d8fc3cb01amr14765755plo.36.1605897865137; Fri, 20 Nov 2020 10:44:25 -0800 (PST) Received: from syed ([223.225.2.215]) by smtp.gmail.com with ESMTPSA id n10sm3988016pgb.45.2020.11.20.10.44.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Nov 2020 10:44:24 -0800 (PST) Date: Sat, 21 Nov 2020 00:14:04 +0530 From: Syed Nayyar Waris To: akpm@linux-foundation.org Cc: andriy.shevchenko@linux.intel.com, vilhelm.gray@gmail.com, michal.simek@xilinx.com, arnd@arndb.de, rrichter@marvell.com, linus.walleij@linaro.org, bgolaszewski@baylibre.com, yamada.masahiro@socionext.com, rui.zhang@intel.com, daniel.lezcano@linaro.org, amit.kucheria@verdurent.com, linux-arch@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org Subject: [RESEND PATCH 2/4] lib/test_bitmap.c: Modify for_each_set_clump test Message-ID: <27dfda9e32e6f7d0ba9399209c70e5c3c73d0113.1605893642.git.syednwaris@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Modify the test where bitmap_set_value() is called. bitmap_set_value() now takes an extra bitmap-width as second argument and the width of value is now present as the fourth argument. Signed-off-by: Syed Nayyar Waris --- lib/test_bitmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c index 1c5791ff02cb..7fafe6a0bc08 100644 --- a/lib/test_bitmap.c +++ b/lib/test_bitmap.c @@ -656,8 +656,8 @@ static void __init prepare_test_data(unsigned int index) unsigned long width = 0; for (i = 0; i < clump_test_data[index].count; i++) { - bitmap_set_value(clump_test_data[index].data, - clump_bitmap_data[(clump_test_data[index].offset)++], width, 32); + bitmap_set_value(clump_test_data[index].data, 256, + clump_bitmap_data[(clump_test_data[index].offset)++], 32, width); width += 32; } } From patchwork Fri Nov 20 18:45:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Syed Nayyar Waris X-Patchwork-Id: 11921915 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0EACCC56201 for ; Fri, 20 Nov 2020 18:46:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BB2842245F for ; Fri, 20 Nov 2020 18:46:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="U9H+SThK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729245AbgKTSqC (ORCPT ); Fri, 20 Nov 2020 13:46:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727862AbgKTSqB (ORCPT ); Fri, 20 Nov 2020 13:46:01 -0500 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFDF5C0613CF; Fri, 20 Nov 2020 10:46:01 -0800 (PST) Received: by mail-pg1-x541.google.com with SMTP id t21so8051326pgl.3; Fri, 20 Nov 2020 10:46:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=uRfbcvxICboodQKlXinezNDbNPHvNn9T8ybYNIuKq0c=; b=U9H+SThKzcEXd9tLGPr811jW2dYlCQuUZfL61AUO7ajIgdPvGvKGXBWcN7Ra8DTx9j 0IJbTG2lt8H/Y4tot+GSwwCHrSeXYDJaZ77HbBh4iTv0Z7PzuCPMANeH1TiRTxNi9j6I g8JhYvlJPpERfX/sZtajXIakUE/v8dZ5xrGUI/wyEO3BqYogh98HU+VvSYVZ6UKnt+XX Qx1nKnHDgCT/c/uorufeMkl3ppRNTP8mSvhB5MLNO9p/nOtvRe0UbZg4XOaGp0yhzRSy xK9ohdt74h/xzeY1bp9d9A7AK1F9u2v2uM4SGKlqiE2dP2FWsQOQ0aaLO3MOsvvltgYD chGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=uRfbcvxICboodQKlXinezNDbNPHvNn9T8ybYNIuKq0c=; b=DKwNJeIF2/JeaWnIHJUcQuQCBAOeOSGytW9d5Y6NV8V7yqkK5dhsauvHuVL9O7CZHv RKfBQ+INVjYWc3oYAp9hNdDbxpttZXYq8rSrQn8oEnOsVgNW+aS77cixDq4iQnH/mkXl HCDFHxBLAcZKd6Fd9kFeCyHiQexyYFxksE3LnsLR91JPe5lGf2BI+fRakJz7VqQ1FAWN ZfLxUQs6aZQjZOMZYRKFMCzS0E8aZjMsicTAnnYEGMuj/ocejvkvzKzWH7CePtVzKjvJ xULVj0LmFL1krgCu2RAUz05Li5LMjhH3Vc+EAxR41lK/6cLkYnJLTGvOSaVLEsA0aOog /Ozg== X-Gm-Message-State: AOAM530mdU/1uFQh1JJ/CBuiuQ2XqG9Zue1xI+UqYKhjoARcjgvEj9WC +yAy6VzA+CwCo6P3D/oPClg= X-Google-Smtp-Source: ABdhPJyWXZsEhH6jt/PDfBCjCATNuUdMTae2dGTKO861W53YNzTXD212XNGggD+wyA3731udHYZC4A== X-Received: by 2002:a17:90a:4816:: with SMTP id a22mr12202439pjh.228.1605897961351; Fri, 20 Nov 2020 10:46:01 -0800 (PST) Received: from syed ([223.225.2.215]) by smtp.gmail.com with ESMTPSA id h16sm4397847pfo.185.2020.11.20.10.45.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Nov 2020 10:46:00 -0800 (PST) Date: Sat, 21 Nov 2020 00:15:41 +0530 From: Syed Nayyar Waris To: akpm@linux-foundation.org Cc: andriy.shevchenko@linux.intel.com, vilhelm.gray@gmail.com, michal.simek@xilinx.com, arnd@arndb.de, rrichter@marvell.com, linus.walleij@linaro.org, bgolaszewski@baylibre.com, yamada.masahiro@socionext.com, rui.zhang@intel.com, daniel.lezcano@linaro.org, amit.kucheria@verdurent.com, linux-arch@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org Subject: [RESEND PATCH 3/4] gpio: xilinx: Modify bitmap_set_value() calls Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Modify the bitmap_set_value() calls. bitmap_set_value() now takes an extra bitmap width as second argument and the width of value is now present as the fourth argument. Cc: Michal Simek Signed-off-by: Syed Nayyar Waris --- drivers/gpio/gpio-xilinx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c index ad4ee4145db4..05dae086c4d0 100644 --- a/drivers/gpio/gpio-xilinx.c +++ b/drivers/gpio/gpio-xilinx.c @@ -151,16 +151,16 @@ static void xgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask, spin_lock_irqsave(&chip->gpio_lock[0], flags); spin_lock(&chip->gpio_lock[1]); - bitmap_set_value(old, state[0], 0, width[0]); - bitmap_set_value(old, state[1], width[0], width[1]); + bitmap_set_value(old, 64, state[0], width[0], 0); + bitmap_set_value(old, 64, state[1], width[1], width[0]); bitmap_replace(new, old, bits, mask, gc->ngpio); - bitmap_set_value(old, state[0], 0, 32); - bitmap_set_value(old, state[1], 32, 32); + bitmap_set_value(old, 64, state[0], 32, 0); + bitmap_set_value(old, 64, state[1], 32, 32); state[0] = bitmap_get_value(new, 0, width[0]); state[1] = bitmap_get_value(new, width[0], width[1]); - bitmap_set_value(new, state[0], 0, 32); - bitmap_set_value(new, state[1], 32, 32); + bitmap_set_value(new, 64, state[0], 32, 0); + bitmap_set_value(new, 64, state[1], 32, 32); bitmap_xor(changed, old, new, 64); if (((u32 *)changed)[0]) From patchwork Fri Nov 20 18:46:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Syed Nayyar Waris X-Patchwork-Id: 11921929 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 428E2C63777 for ; Fri, 20 Nov 2020 18:46:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E7B0B24073 for ; Fri, 20 Nov 2020 18:46:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ujvfeniS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731526AbgKTSqz (ORCPT ); Fri, 20 Nov 2020 13:46:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727862AbgKTSqy (ORCPT ); Fri, 20 Nov 2020 13:46:54 -0500 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B83E8C0613CF; Fri, 20 Nov 2020 10:46:54 -0800 (PST) Received: by mail-pg1-x542.google.com with SMTP id q34so8019702pgb.11; Fri, 20 Nov 2020 10:46:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Yy8mAP2XRxcUpsdCsTm+KdTXMmpuQJot11SefIetIN0=; b=ujvfeniSWlxcgqZRespio3sYte4Z6dmDMzdy7bcj6Ktnrv/AjG740aaFTs+OaM0yjg qlQEpc+tl+oeyTPEWfA+zKBs6kCTfikyvOzwGQxxF5t4lF1tByVQZcR2LrkyMIZ9F6L1 l1R5lprWjmotlbC+Lk4ZNLDUcqx0WsEe9TZdk6khc4Xnwp0FuuMFpVvwfwkxlSU2gv6k Kkgy3z2bFWjOH4uZ1RGGtwaBSuETHsHaBVrWuied6lj0RBCsUh/FlY8cdsnc2IBdKEmj +qlq+EeiPekrq3A+CItfdJ198nhbuj/zi3kpNtnjcBwsPkSLuWqrqBduO1n8z2FVygDQ XbFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Yy8mAP2XRxcUpsdCsTm+KdTXMmpuQJot11SefIetIN0=; b=PPDpuHh7igIVqRQ62PGf+DkFGk5V1dIrI8kB/7EhwJ7CtLxh0LbkYf2y9v5ixT92Ro npNrw0FkrBbZUkdvP2ike8r3H1vqiyAZbkv9pFeOP9vMtSwdwiGya5yX2Edxz0iq9u33 mxFIKGGyDhiv2ycupkZ4L/5dvWojWR/tDqRJm6dQ/qn9s2s4B5vTtJTjCBLGl+vDG9Z/ h/unSgRPahGaYZPZezbn3Zhv0vUmc2ySWB7vpTjdDiiDUztNKvDVGMTt2aYSDWYCQCtv hb2fySPHCgHhVHuBlroddQvG0N+MlK0VXTgusRbu/FEMbfOJycz7mBzclfoiF/GHmfjY hzlQ== X-Gm-Message-State: AOAM5306Z01PQFU23uh3MOxnUR0UN+PZYB7imnE8BGhBjJpU7Y7av4hU n3IcGR06VHcYkYndj3W0TKs= X-Google-Smtp-Source: ABdhPJw68hakH3pf9zGUb/sx7gPTEd3v2MhxOVO81lDAR6CmRc++87rAP18uKr94XDKv67IXSwoTbA== X-Received: by 2002:a63:ef4d:: with SMTP id c13mr17996932pgk.147.1605898014325; Fri, 20 Nov 2020 10:46:54 -0800 (PST) Received: from syed ([223.225.2.215]) by smtp.gmail.com with ESMTPSA id e8sm4667303pjr.30.2020.11.20.10.46.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Nov 2020 10:46:53 -0800 (PST) Date: Sat, 21 Nov 2020 00:16:35 +0530 From: Syed Nayyar Waris To: akpm@linux-foundation.org Cc: andriy.shevchenko@linux.intel.com, vilhelm.gray@gmail.com, michal.simek@xilinx.com, arnd@arndb.de, rrichter@marvell.com, linus.walleij@linaro.org, bgolaszewski@baylibre.com, yamada.masahiro@socionext.com, rui.zhang@intel.com, daniel.lezcano@linaro.org, amit.kucheria@verdurent.com, linux-arch@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org Subject: [RESEND PATCH 4/4] gpio: xilinx: Add extra check if sum of widths exceed 64 Message-ID: <5581771d86df1abaf33545ccd60caf4db7ad3c5e.1605893643.git.syednwaris@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add extra check to see if sum of widths does not exceed 64. If it exceeds then return -EINVAL alongwith appropriate error message. Cc: Michal Simek Signed-off-by: Syed Nayyar Waris --- drivers/gpio/gpio-xilinx.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c index 05dae086c4d0..a2e92a1cf50b 100644 --- a/drivers/gpio/gpio-xilinx.c +++ b/drivers/gpio/gpio-xilinx.c @@ -340,6 +340,12 @@ static int xgpio_probe(struct platform_device *pdev) chip->gc.base = -1; chip->gc.ngpio = chip->gpio_width[0] + chip->gpio_width[1]; + + if (chip->gc.ngpio > 64) { + dev_err(&pdev->dev, "invalid configuration: number of GPIO is greater than 64"); + return -EINVAL; + } + chip->gc.parent = &pdev->dev; chip->gc.direction_input = xgpio_dir_in; chip->gc.direction_output = xgpio_dir_out;