Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4374511ybi; Tue, 11 Jun 2019 05:44:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqwnfiRrxLcNpSFZkksP7HTGWpXmoB69R3B60w3k33JOQO1rqeMGU/JdN3V7mpxoNY+DrRDN X-Received: by 2002:a62:1b85:: with SMTP id b127mr80686310pfb.165.1560257087546; Tue, 11 Jun 2019 05:44:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560257087; cv=none; d=google.com; s=arc-20160816; b=X41UskcIijCFq/GPO+9cEQDCFZiGeZzveuKXPxRC/+bIFOwH+jixz7vkkuLONiCXP/ RKATPIqTBbQMq0anReiDA8vuP9v5NX5IF1Dn2Byr9wfN8UqSrhmQwkwJyp0sHOaFWCuz yRvAthX3KSgOiQe8Kl5o/bg7aaJYBN9NPU1Ji/dH3IWi6OQg6hV+TtXOaIZbq4WABEAQ JT1epOMfy3Kqkxb+cdYjEDBsF3kU7W6t5KkfUVosglzT6jVBv/q/L1a+hUQT1eBgR6XC wU6kzRgNWhjinBUeEIHEtPnZDNL4Ef8yMeFS5Qr42J9couYNjxPEghRh51wTTRHpVg/h jZ7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=J7tmqDGUKbvvsSubnlxX0yAVtwkS52/D2jgGULypYUg=; b=Y3s7NWyGTyiNqepHWUordddoikCWiLKOQMPbHNBp2Q3pTyraOAxSgSY4mFFEeU0v1p c6KpG6I6JTnIo8LiK8s9zoGhHdes/gRwKXWudQpOwP3LCLlyIys6U54RAb7QpmXv6u1k SDFaM3wFv+gAq+k18iyUzglIZeKUhXT0qwkrDlydBO+d/K49abSoiFoxlmmeKolXIv7g hEylpK+rgTiTCaV9sUj/ehAWGqY3/McZBRVd3v7j2eBkpbBoHLUj9EcSDXCBajc24YuJ pSdczGIunMybj37mVszoX7dZ+Eo0LuRzoXuZjf58ee2OYn0aPF3/5TFtFWR+F+fz7TyM M8LA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b132si13852350pfb.267.2019.06.11.05.44.32; Tue, 11 Jun 2019 05:44:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388429AbfFKMoS (ORCPT + 99 others); Tue, 11 Jun 2019 08:44:18 -0400 Received: from mga14.intel.com ([192.55.52.115]:38430 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727733AbfFKMoS (ORCPT ); Tue, 11 Jun 2019 08:44:18 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jun 2019 05:44:18 -0700 X-ExtLoop1: 1 Received: from smile.fi.intel.com (HELO smile) ([10.237.68.145]) by orsmga002.jf.intel.com with ESMTP; 11 Jun 2019 05:44:15 -0700 Received: from andy by smile with local (Exim 4.92) (envelope-from ) id 1hag8N-00059q-0l; Tue, 11 Jun 2019 15:44:15 +0300 Date: Tue, 11 Jun 2019 15:44:15 +0300 From: Andy Shevchenko To: Stefan Roese Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Yegor Yefremov , Mika Westerberg , Giulio Benetti , Greg Kroah-Hartman Subject: Re: [PATCH 2/2 v5] tty/serial/8250: use mctrl_gpio helpers Message-ID: <20190611124415.GT9224@smile.fi.intel.com> References: <20190611105603.4435-1-sr@denx.de> <20190611105603.4435-2-sr@denx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190611105603.4435-2-sr@denx.de> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 11, 2019 at 12:56:03PM +0200, Stefan Roese wrote: > From: Yegor Yefremov > > This patch permits the usage for GPIOs to control > the CTS/RTS/DTR/DSR/DCD/RI signals. > static inline void serial8250_out_MCR(struct uart_8250_port *up, int value) > { > serial_out(up, UART_MCR, value); > + > + if (up->gpios) { > + int mctrl_gpio = 0; > + > + if (value & UART_MCR_RTS) > + mctrl_gpio |= TIOCM_RTS; > + if (value & UART_MCR_DTR) > + mctrl_gpio |= TIOCM_DTR; > + > + mctrl_gpio_set(up->gpios, mctrl_gpio); > + } > } > > static inline int serial8250_in_MCR(struct uart_8250_port *up) > { > - return serial_in(up, UART_MCR); > + int mctrl; > + > + mctrl = serial_in(up, UART_MCR); > + > + if (up->gpios) { > + int mctrl_gpio = 0; > + > + /* save current MCR values */ > + if (mctrl & UART_MCR_RTS) > + mctrl_gpio |= TIOCM_RTS; > + if (mctrl & UART_MCR_DTR) > + mctrl_gpio |= TIOCM_DTR; > + > + mctrl_gpio = mctrl_gpio_get_outputs(up->gpios, &mctrl_gpio); > + if (mctrl_gpio & TIOCM_RTS) > + mctrl |= UART_MCR_RTS; > + else > + mctrl &= ~UART_MCR_RTS; > + > + if (mctrl_gpio & TIOCM_DTR) > + mctrl |= UART_MCR_DTR; > + else > + mctrl &= ~UART_MCR_DTR; > + } > + > + return mctrl; > } These are using OR logic with potentially volatile data. Shouldn't we mask unused bits in UART_MCR in case of up->gpios != NULL? > + if (up->gpios == 0) This is type inconsistency with this check as far as I understand. I guess you have to do either (up->gpios == NULL), or (!up->gpios). > ret = 0; + Blank line. > + if (up->gpios) > + return mctrl_gpio_get(up->gpios, &ret); -- With Best Regards, Andy Shevchenko