Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4521272ybi; Tue, 11 Jun 2019 08:02:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqzDJuHhMNyT0r1DHq/FDM3qhFM8k4+vnvcj1j1ZeXk9KsJdFt4HDYA3npiGZHzXKGecfoz8 X-Received: by 2002:a63:de0e:: with SMTP id f14mr1521857pgg.348.1560265322989; Tue, 11 Jun 2019 08:02:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560265322; cv=none; d=google.com; s=arc-20160816; b=VELWvSJvbPApegDec8L9gFDoAGu5OzEuzuF/AcGVHsX66HuvD8c+/yH4dDA185wxxd xKexXvO0iPI4j1HrptxjxMKCxMOsUd+1AkFnR4RwGaEi9khF7NXtPCrN2U9WkIB+xjcA fpdl7TFrUDc/HUhYslbxT/5z7hR/mWuxjWtOvVIYDYvGuFEz9KUg1Al2MjKEoZFXYgAE Ep4JgZXy7y96d58R+X8b+14fVN9nDKzNOc4qgIy865i0lefZFZiEcKXOTuooNUB35852 +Q3HrbwB1+dF8RLrg/ohhApCHTGNENKdjla/kIImMOQL0TfZkry8NLfJ9n+fiGgY489A IUKQ== 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=+kR6PnkHEBhwZsv9e25t31NZ4U6/fqLCQGzRh/dMGI4=; b=XGsHX1UHrYrpQami+Ijrw8sbP59OT7ChUEwqG9eyJnVlGmr3skhJKLpFZVyIB63E43 nMphLHWlxqZO9h6ddB/asw/AB49nqy05+0payFfsUHrUs9TATn7jj+nzhxPM2t9ditrF 6f5Hc9GfeobbH5TPL6WGAkwjBBW8J4jxwtVExknRYlDXUaAxeRWQ7bIUlMYjh8I7+1FW Urxbg+8BOUe3+MYCpYHk3krv0uL6wUBQxwvw4N0hy49n7DvbJ6ciMvqcA7PndNazmQ6Z 7wsarVPKxtKaPasP/0eLZofpoTKaENiUDr52mzkb8uF8yna585vYLBr0qazNbOGL+I7v ljFQ== 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 e6si13375670pfe.111.2019.06.11.08.01.33; Tue, 11 Jun 2019 08:02:02 -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 S2391410AbfFKOsc (ORCPT + 99 others); Tue, 11 Jun 2019 10:48:32 -0400 Received: from mga18.intel.com ([134.134.136.126]:14951 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389454AbfFKOsc (ORCPT ); Tue, 11 Jun 2019 10:48:32 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jun 2019 07:48:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,579,1557212400"; d="scan'208";a="183821262" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.145]) by fmsmga002.fm.intel.com with ESMTP; 11 Jun 2019 07:48:29 -0700 Received: from andy by smile with local (Exim 4.92) (envelope-from ) id 1hai4a-00065P-Ol; Tue, 11 Jun 2019 17:48:28 +0300 Date: Tue, 11 Jun 2019 17:48:28 +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: <20190611144828.GX9224@smile.fi.intel.com> References: <20190611105603.4435-1-sr@denx.de> <20190611105603.4435-2-sr@denx.de> <20190611124415.GT9224@smile.fi.intel.com> <85f0d39c-e5d8-320b-e611-d956630a629f@denx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <85f0d39c-e5d8-320b-e611-d956630a629f@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 04:02:54PM +0200, Stefan Roese wrote: > On 11.06.19 14:44, Andy Shevchenko wrote: > > On Tue, Jun 11, 2019 at 12:56:03PM +0200, Stefan Roese wrote: > > > 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? > > Sorry, I don't see, which bits you are referring to? Could you please be > a bit more specific with the variable / macro meant (example)? I meant that we double write values in the out() which might have some consequences, though I hope nothing wrong with it happens. In the in() we read the all bits in the register. As now I look at the implementation of mctrl_gpio_get_outputs(), I think we rather get helpers for conversion between TIOCM and UART_MCR values, so, they can be used in get_mctrl() / set_mctrl() and above. The logic now is understandable to me (I was confused by the conversions here and there). -- With Best Regards, Andy Shevchenko