From mboxrd@z Thu Jan 1 00:00:00 1970 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=-7.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS 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 BAFF5C433E0 for ; Mon, 8 Jun 2020 06:41:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 976A02076A for ; Mon, 8 Jun 2020 06:41:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591598474; bh=BQCBgwFsMXSNTIHxvc5pCdzZe+VJ7aLilK0Z+i0lOhU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=TM79co/isxo0v8LQloKDSKbbPTde8K4No49PkaelHRJ3naVzUVZcQLhA6J7WnYFfj hfQ7i1Cp3viushclIbPB+moKSczaEEUua87rvRypsFrODsqhVtyEmBESQahixR+wS0 9XZv5u8vnbLVvxRk885oE8KOFmY1nFS6rEZ5J00o= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726929AbgFHGlO (ORCPT ); Mon, 8 Jun 2020 02:41:14 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:45992 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728906AbgFHGlN (ORCPT ); Mon, 8 Jun 2020 02:41:13 -0400 Received: by mail-lj1-f194.google.com with SMTP id i27so8049651ljb.12; Sun, 07 Jun 2020 23:41:12 -0700 (PDT) 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; bh=Z4UQh0Us0hQtEs1TDFqY5o6aN1qVDkFutQCZsE8JqaU=; b=csQWcLndzxeF1KrldccUUCgN7uzZmNEptynzFIjfAjykqXPq0K25A1eJPkrBtnq2Xo 8LuQ5cvNIrTsEFXj8mfV0PVlbYL8PM0bX/oQTKgDZfq7YgnyRmZjKQvNH0Qcl1iQyhrl XzifwteGq2Ukke6BV+PaPrECf+x9h0S+AVVGr0Wj3f1dfAzVqJ5dkhyN0it2VAsnLpM2 sMhwrM/q3algyoJEwqmltogYOxkgy7EOLwe8SNhNYizjmtu0qRoth1lpV7c0HbKs3GRp YsZHRI5TyIAkr0Q1LRiZV0csdWn20+YZu0fsjXovAWb4T/oox0+6763EQdrQfxBtIOea lTmg== X-Gm-Message-State: AOAM532DGYSVhK83OR1UL9HwTJ0z6cjd+60ljzawBnNMObWxCPswL3Aj ugDYlW/uAEhxT5DumuOit34= X-Google-Smtp-Source: ABdhPJw7i0D0egd72cvg61t4dDEMZ5Zoy6Geiu+vS8eBA4Z7uYi/XVCKJRKsmx3xMFnlXhqh8YnFKw== X-Received: by 2002:a2e:8e27:: with SMTP id r7mr10196151ljk.382.1591598471669; Sun, 07 Jun 2020 23:41:11 -0700 (PDT) Received: from xi.terra (c-beaee455.07-184-6d6c6d4.bbcust.telenor.se. [85.228.174.190]) by smtp.gmail.com with ESMTPSA id t26sm4169562lfk.61.2020.06.07.23.41.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jun 2020 23:41:11 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.93.0.4) (envelope-from ) id 1jiBSz-0003mQ-EB; Mon, 08 Jun 2020 08:41:05 +0200 Date: Mon, 8 Jun 2020 08:41:05 +0200 From: Johan Hovold To: Christophe Leroy Cc: Greg Kroah-Hartman , Jiri Slaby , Linus Walleij , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-serial@vger.kernel.org Subject: Re: [PATCH] tty: serial: cpm_uart: Fix behaviour for non existing GPIOs Message-ID: <20200608064105.GL19480@localhost> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org On Sat, Jun 06, 2020 at 07:30:21AM +0000, Christophe Leroy wrote: > devm_gpiod_get_index() doesn't return NULL but -ENOENT when the > requested GPIO doesn't exist, leading to the following messages: > > [ 2.742468] gpiod_direction_input: invalid GPIO (errorpointer) > [ 2.748147] can't set direction for gpio #2: -2 > [ 2.753081] gpiod_direction_input: invalid GPIO (errorpointer) > [ 2.758724] can't set direction for gpio #3: -2 > [ 2.763666] gpiod_direction_output: invalid GPIO (errorpointer) > [ 2.769394] can't set direction for gpio #4: -2 > [ 2.774341] gpiod_direction_input: invalid GPIO (errorpointer) > [ 2.779981] can't set direction for gpio #5: -2 > [ 2.784545] ff000a20.serial: ttyCPM1 at MMIO 0xfff00a20 (irq = 39, base_baud = 8250000) is a CPM UART > > Use IS_ERR_OR_NULL() to properly check gpiod validity. Why check for NULL at all? > Fixes: 97cbaf2c829b ("tty: serial: cpm_uart: Convert to use GPIO descriptors") > Cc: stable@vger.kernel.org > Cc: Linus Walleij > Signed-off-by: Christophe Leroy > --- > drivers/tty/serial/cpm_uart/cpm_uart_core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c > index a04f74d2e854..3cbe24802296 100644 > --- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c > +++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c > @@ -1217,7 +1217,7 @@ static int cpm_uart_init_port(struct device_node *np, > > gpiod = devm_gpiod_get_index(dev, NULL, i, GPIOD_ASIS); > > - if (gpiod) { > + if (!IS_ERR_OR_NULL(gpiod)) { > if (i == GPIO_RTS || i == GPIO_DTR) > ret = gpiod_direction_output(gpiod, 0); > else Johan From mboxrd@z Thu Jan 1 00:00:00 1970 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=-7.0 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS 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 D568EC433E1 for ; Mon, 8 Jun 2020 06:42:45 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8B17A2076A for ; Mon, 8 Jun 2020 06:42:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8B17A2076A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 49gNwg4rWwzDqV9 for ; Mon, 8 Jun 2020 16:42:43 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=209.85.208.196; helo=mail-lj1-f196.google.com; envelope-from=jhovold@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=fail (p=none dis=none) header.from=kernel.org Received: from mail-lj1-f196.google.com (mail-lj1-f196.google.com [209.85.208.196]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 49gNv21qJQzDqT8 for ; Mon, 8 Jun 2020 16:41:16 +1000 (AEST) Received: by mail-lj1-f196.google.com with SMTP id y11so17345023ljm.9 for ; Sun, 07 Jun 2020 23:41:15 -0700 (PDT) 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; bh=Z4UQh0Us0hQtEs1TDFqY5o6aN1qVDkFutQCZsE8JqaU=; b=eBfTgDhCmtIOpOGwb9DuaD0i7V7Pb0lEvWSiArRzyyRO3B5kcoTYkcEUkza0C9Cd6M emHGgdJl1GDTAVnm1saOeWgXJ2vebs7xIiuofET3xCftRWEoK8KPYa5WJDlb3XhqvDFn 0coZzI+DnlTTM68hUyif+sea3KDSudWmsJgJjCkx3mrcrICLHNFMk8t7I1u1FzW0ipuJ gVw+MQhnBPLwOGaNMUE9jL/e3+2CSFtbQ5Posm9jU5eeCBjRbmtWiyKPIwdSTilc7Ga6 isrXJlYrorkVy1VgClaqYvBjbdxIBHCGERwit7xAKTEnpBX99Z0gxB7Jw5qyO0olHZMJ jSRQ== X-Gm-Message-State: AOAM530T7Hc3A9ADUO4DbgBWrozX4xdh1yj4HSC56aUSlw9tkJ4xIJyI tZJarim2GXX4cfUaI3s2WSE= X-Google-Smtp-Source: ABdhPJw7i0D0egd72cvg61t4dDEMZ5Zoy6Geiu+vS8eBA4Z7uYi/XVCKJRKsmx3xMFnlXhqh8YnFKw== X-Received: by 2002:a2e:8e27:: with SMTP id r7mr10196151ljk.382.1591598471669; Sun, 07 Jun 2020 23:41:11 -0700 (PDT) Received: from xi.terra (c-beaee455.07-184-6d6c6d4.bbcust.telenor.se. [85.228.174.190]) by smtp.gmail.com with ESMTPSA id t26sm4169562lfk.61.2020.06.07.23.41.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jun 2020 23:41:11 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.93.0.4) (envelope-from ) id 1jiBSz-0003mQ-EB; Mon, 08 Jun 2020 08:41:05 +0200 Date: Mon, 8 Jun 2020 08:41:05 +0200 From: Johan Hovold To: Christophe Leroy Subject: Re: [PATCH] tty: serial: cpm_uart: Fix behaviour for non existing GPIOs Message-ID: <20200608064105.GL19480@localhost> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kroah-Hartman , Linus Walleij , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Jiri Slaby , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Sat, Jun 06, 2020 at 07:30:21AM +0000, Christophe Leroy wrote: > devm_gpiod_get_index() doesn't return NULL but -ENOENT when the > requested GPIO doesn't exist, leading to the following messages: > > [ 2.742468] gpiod_direction_input: invalid GPIO (errorpointer) > [ 2.748147] can't set direction for gpio #2: -2 > [ 2.753081] gpiod_direction_input: invalid GPIO (errorpointer) > [ 2.758724] can't set direction for gpio #3: -2 > [ 2.763666] gpiod_direction_output: invalid GPIO (errorpointer) > [ 2.769394] can't set direction for gpio #4: -2 > [ 2.774341] gpiod_direction_input: invalid GPIO (errorpointer) > [ 2.779981] can't set direction for gpio #5: -2 > [ 2.784545] ff000a20.serial: ttyCPM1 at MMIO 0xfff00a20 (irq = 39, base_baud = 8250000) is a CPM UART > > Use IS_ERR_OR_NULL() to properly check gpiod validity. Why check for NULL at all? > Fixes: 97cbaf2c829b ("tty: serial: cpm_uart: Convert to use GPIO descriptors") > Cc: stable@vger.kernel.org > Cc: Linus Walleij > Signed-off-by: Christophe Leroy > --- > drivers/tty/serial/cpm_uart/cpm_uart_core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c > index a04f74d2e854..3cbe24802296 100644 > --- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c > +++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c > @@ -1217,7 +1217,7 @@ static int cpm_uart_init_port(struct device_node *np, > > gpiod = devm_gpiod_get_index(dev, NULL, i, GPIOD_ASIS); > > - if (gpiod) { > + if (!IS_ERR_OR_NULL(gpiod)) { > if (i == GPIO_RTS || i == GPIO_DTR) > ret = gpiod_direction_output(gpiod, 0); > else Johan