From patchwork Thu Mar 10 10:15:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: mrpace2@gmail.com X-Patchwork-Id: 595675 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id C053414030F for ; Thu, 10 Mar 2016 21:15:11 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754641AbcCJKPK (ORCPT ); Thu, 10 Mar 2016 05:15:10 -0500 Received: from mo4-p05-ob.smtp.rzone.de ([81.169.146.180]:39171 "EHLO mo4-p05-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753612AbcCJKPJ convert rfc822-to-8bit (ORCPT ); Thu, 10 Mar 2016 05:15:09 -0500 X-RZG-AUTH: :Kn4Fe0uIaqrBzWqJxdlaAF2yWZVBD3LY6nZshHN1BI6bDP7FeTZ21BrTcfQAIw== X-RZG-CLASS-ID: mo05 Received: from mail.q5net.de (p4FF1C47E.dip0.t-ipconnect.de [79.241.196.126]) by smtp.strato.de (RZmta 37.21 DYNA|AUTH) with ESMTPSA id k02e5ds2AAF6zPM (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate) for ; Thu, 10 Mar 2016 11:15:06 +0100 (CET) From: mrpace2@gmail.com To: linux-gpio@vger.kernel.org Subject: [PATCH v2] gpio: gpio-pca953x: no interrupts with 4-bit devices Date: Thu, 10 Mar 2016 10:15:05 +0000 Message-Id: In-Reply-To: <2550700.ucYhgAiWGF@ws-stein> Reply-To: mrpace2@gmail.com User-Agent: eM_Client/6.0.24928.0 Mime-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org The NBANK macro can be extended in order to avoid the underflow: #define NBANK(chip) (chip->gpio_chip.ngpio == 0 ? 0 : \ ((chip->gpio_chip.ngpio + (BANK_SZ - 1)) / BANK_SZ)) Resending a modified patch. Signed-off-by: Frank Edelhaeuser gmail.com> --- -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff -Nur a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c --- a/drivers/gpio/gpio-pca953x.c 2016-03-10 02:34:56.012345678 +0000 +++ b/drivers/gpio/gpio-pca953x.c 2016-03-10 02:34:56.012345678 +0000 @@ -86,7 +86,8 @@ #define MAX_BANK 5 #define BANK_SZ 8 -#define NBANK(chip) (chip->gpio_chip.ngpio / BANK_SZ) +#define NBANK(chip) (chip->gpio_chip.ngpio == 0 ? 0 : \ + ((chip->gpio_chip.ngpio + (BANK_SZ - 1)) / BANK_SZ)) struct pca953x_chip { unsigned gpio_start;