Received: by 2002:a05:7208:3003:b0:81:def:69cd with SMTP id f3csp4221694rba; Tue, 2 Apr 2024 10:33:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWMEvAqJaFmiEQGzz5driwzuOcN/sSdT1dMqEg8qKNRg65wpIQOFYz4y8x3bhRsjfM13c0NmjW14TIsigpFYviYETQUKKLjfCc1SL2bVg== X-Google-Smtp-Source: AGHT+IGJOCKgTo+d5AIRJ2VXR7dezHcpR5tMmesZpub8fTBGJB18v7KpoC+x8pluT56CHkGYbX96 X-Received: by 2002:a05:6358:8008:b0:183:4d1d:f6b9 with SMTP id g8-20020a056358800800b001834d1df6b9mr15803871rwn.22.1712079198169; Tue, 02 Apr 2024 10:33:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712079198; cv=pass; d=google.com; s=arc-20160816; b=pTJgiQO2ZcCiJpBlcE0acS8LcM52gGxn5G+DpboHtkwgsL/5mXpPzspgxv369ogb5x mlQWCr56PJgvZVUwvtcgb8iUXRxbMRZ1+EBBquS/NoujKPdBz7jDvLaBgh5zN+R2JrAa Lgg0Eds4f6fX3YZgIyIJhGt2aCv6UYoRFpXtE5X974IGjtzRxqmeIcqSirThk66qpNcA UzADXtfSnc6BpMNUjZZW3knIm9Mb7uOqhhqaRk2Yav8MoM2aJmWwilt5wHpeUDq8X6JR M+1g5DQuV2Rj19IVRpvTVT1po41n6c8tRma417Je4hCesY08j5ClqDxkH8X7QGNhSaLV kpIw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=subject:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :cc:to:from:date:dkim-signature; bh=tlmcDV4tJG/vmyJxl8o94HzuPvhHeWXr40QJIGScueA=; fh=H65RVQV9wfAvwu8WF2ICti459M+/Qy0jzAn6HhdH+C4=; b=AS9A3zRKvj/H4OeqEir89i5xOEut4RbWuNbbqWOYAQHW5de8vQrQjNOxGO4g3uET0J VoDDA4a9ZYlBDECJFJFN1gj1j1YFUP3z1zX2b0/APpA/IAep4tA9BaEUFwwRzcsnO5dS zPvNaowuV107kjZ6R2zWcRjP4h9HFZA9zhK7ucDOAw0zdYUM5bZq+AXNid9aXYUYXYd5 0GauFsYbkQvy4WuZq+uSk17hi2sznfJNPJ598ufTkh+Sh3Q75fInEOdAsKe2WIQIUHDr 7wMPR+cRgDC9YYQ3q6HCLmmVud82pLVCXjNfXuStDF8yiVD4JykIM8WOSGufzq+0S/tC 1nyQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=GFtHOR8O; arc=pass (i=1 spf=pass spfdomain=hugovil.com dkim=pass dkdomain=hugovil.com); spf=pass (google.com: domain of linux-kernel+bounces-128429-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-128429-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 38-20020a631166000000b005dc4ec6cd2esi11454972pgr.767.2024.04.02.10.33.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 10:33:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-128429-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=GFtHOR8O; arc=pass (i=1 spf=pass spfdomain=hugovil.com dkim=pass dkdomain=hugovil.com); spf=pass (google.com: domain of linux-kernel+bounces-128429-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-128429-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D8BCC28981E for ; Tue, 2 Apr 2024 17:32:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4E17515A4AF; Tue, 2 Apr 2024 17:32:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=hugovil.com header.i=@hugovil.com header.b="GFtHOR8O" Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA505159912; Tue, 2 Apr 2024 17:32:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=162.243.120.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712079135; cv=none; b=ilrLw8/ULZ4k9uv03dCUpNGFSw0EVOAP8+dKQD92wQ7NA/1ELeA3eZgbNlprJdx76oEMzQdLNvG1L2CxrAK/kFVlK86cuarvyTL24cbA82WBc4WaQ811pe8NWojw1KTRcZXV5a2PI4zDyDGo7rd9PzmdgiONAa+GCeaU5Fq4/Uw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712079135; c=relaxed/simple; bh=mV53t1podiDxtR/XNgQXyFOr0aY8dlvQ8zbvCHm7YHg=; h=Date:From:To:Cc:Message-Id:In-Reply-To:References:Mime-Version: Content-Type:Subject; b=VBU/VjIPeYE9yeU2ICvJ0y2xv3TtIqcZm0UWDIEeeg3mamREY/SFLb22ush596ngY2r1hY2XM11t8DrYb9pR7mU7rAK0mk98rjc/v3zIZKIzZlT9PBrSgquPrh2snZ9DLUkjmtmydyILQHq8V8ymm9Pa6W9ZnHIDCFGAyWK8l6k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hugovil.com; spf=pass smtp.mailfrom=hugovil.com; dkim=pass (1024-bit key) header.d=hugovil.com header.i=@hugovil.com header.b=GFtHOR8O; arc=none smtp.client-ip=162.243.120.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hugovil.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hugovil.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=hugovil.com ; s=x; h=Subject:Content-Transfer-Encoding:Mime-Version:Message-Id:Cc:To:From :Date:subject:date:message-id:reply-to; bh=tlmcDV4tJG/vmyJxl8o94HzuPvhHeWXr40QJIGScueA=; b=GFtHOR8O1pJ0LYmvPijVG1uhh1 xgSBiJpYlrTQLZesk0EmnnStmucyt1up9p5krXbQN+Qhnxf7FNiBBq1OsuLQE07cA466hLn1DwVEK YqmAqAePLxLtfrrXf+BizPJNVfozPSvY6dMCCx3ayEV3KIT+wv8LNlUarWQ1/S8vLJSw=; Received: from modemcable168.174-80-70.mc.videotron.ca ([70.80.174.168]:41686 helo=pettiford) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1rrhzW-00082d-BF; Tue, 02 Apr 2024 13:32:11 -0400 Date: Tue, 2 Apr 2024 13:32:09 -0400 From: Hugo Villeneuve To: Andy Shevchenko Cc: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Jiri Slaby Message-Id: <20240402133209.910f63378eb40fa27363f3ed@hugovil.com> In-Reply-To: <20240402154219.3583679-14-andriy.shevchenko@linux.intel.com> References: <20240402154219.3583679-1-andriy.shevchenko@linux.intel.com> <20240402154219.3583679-14-andriy.shevchenko@linux.intel.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 70.80.174.168 X-SA-Exim-Mail-From: hugo@hugovil.com X-Spam-Level: X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * -0.4 NICE_REPLY_A Looks like a legit reply (A) Subject: Re: [PATCH v1 13/16] serial: max3100: Extract to_max3100_port() helper macro X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.hugovil.com) On Tue, 2 Apr 2024 18:38:19 +0300 Andy Shevchenko wrote: > Instead of using container_of() explicitly, introduce a heler macro. heler -> helper Reviewed-by: Hugo Villeneuve > This saves a lot of lines of code. > > Signed-off-by: Andy Shevchenko > --- > drivers/tty/serial/max3100.c | 67 ++++++++++-------------------------- > 1 file changed, 19 insertions(+), 48 deletions(-) > > diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c > index 585bf6c898b2..19b05992a9ac 100644 > --- a/drivers/tty/serial/max3100.c > +++ b/drivers/tty/serial/max3100.c > @@ -16,6 +16,7 @@ > /* 4 MAX3100s should be enough for everyone */ > #define MAX_MAX3100 4 > > +#include > #include > #include > #include > @@ -110,6 +111,8 @@ struct max3100_port { > struct timer_list timer; > }; > > +#define to_max3100_port(port) container_of(port, struct max3100_port, port) > + > static struct max3100_port *max3100s[MAX_MAX3100]; /* the chips */ > static DEFINE_MUTEX(max3100s_lock); /* race on probe */ > > @@ -322,9 +325,7 @@ static irqreturn_t max3100_irq(int irqno, void *dev_id) > > static void max3100_enable_ms(struct uart_port *port) > { > - struct max3100_port *s = container_of(port, > - struct max3100_port, > - port); > + struct max3100_port *s = to_max3100_port(port); > > mod_timer(&s->timer, jiffies); > dev_dbg(&s->spi->dev, "%s\n", __func__); > @@ -332,9 +333,7 @@ static void max3100_enable_ms(struct uart_port *port) > > static void max3100_start_tx(struct uart_port *port) > { > - struct max3100_port *s = container_of(port, > - struct max3100_port, > - port); > + struct max3100_port *s = to_max3100_port(port); > > dev_dbg(&s->spi->dev, "%s\n", __func__); > > @@ -343,9 +342,7 @@ static void max3100_start_tx(struct uart_port *port) > > static void max3100_stop_rx(struct uart_port *port) > { > - struct max3100_port *s = container_of(port, > - struct max3100_port, > - port); > + struct max3100_port *s = to_max3100_port(port); > > dev_dbg(&s->spi->dev, "%s\n", __func__); > > @@ -359,9 +356,7 @@ static void max3100_stop_rx(struct uart_port *port) > > static unsigned int max3100_tx_empty(struct uart_port *port) > { > - struct max3100_port *s = container_of(port, > - struct max3100_port, > - port); > + struct max3100_port *s = to_max3100_port(port); > > dev_dbg(&s->spi->dev, "%s\n", __func__); > > @@ -372,9 +367,7 @@ static unsigned int max3100_tx_empty(struct uart_port *port) > > static unsigned int max3100_get_mctrl(struct uart_port *port) > { > - struct max3100_port *s = container_of(port, > - struct max3100_port, > - port); > + struct max3100_port *s = to_max3100_port(port); > > dev_dbg(&s->spi->dev, "%s\n", __func__); > > @@ -386,9 +379,7 @@ static unsigned int max3100_get_mctrl(struct uart_port *port) > > static void max3100_set_mctrl(struct uart_port *port, unsigned int mctrl) > { > - struct max3100_port *s = container_of(port, > - struct max3100_port, > - port); > + struct max3100_port *s = to_max3100_port(port); > int loopback, rts; > > dev_dbg(&s->spi->dev, "%s\n", __func__); > @@ -414,9 +405,7 @@ static void > max3100_set_termios(struct uart_port *port, struct ktermios *termios, > const struct ktermios *old) > { > - struct max3100_port *s = container_of(port, > - struct max3100_port, > - port); > + struct max3100_port *s = to_max3100_port(port); > unsigned int baud = port->uartclk / 16; > unsigned int baud230400 = (baud == 230400) ? 1 : 0; > unsigned cflag; > @@ -532,9 +521,7 @@ max3100_set_termios(struct uart_port *port, struct ktermios *termios, > > static void max3100_shutdown(struct uart_port *port) > { > - struct max3100_port *s = container_of(port, > - struct max3100_port, > - port); > + struct max3100_port *s = to_max3100_port(port); > u16 rx; > > dev_dbg(&s->spi->dev, "%s\n", __func__); > @@ -559,9 +546,7 @@ static void max3100_shutdown(struct uart_port *port) > > static int max3100_startup(struct uart_port *port) > { > - struct max3100_port *s = container_of(port, > - struct max3100_port, > - port); > + struct max3100_port *s = to_max3100_port(port); > char b[12]; > int ret; > > @@ -607,9 +592,7 @@ static int max3100_startup(struct uart_port *port) > > static const char *max3100_type(struct uart_port *port) > { > - struct max3100_port *s = container_of(port, > - struct max3100_port, > - port); > + struct max3100_port *s = to_max3100_port(port); > > dev_dbg(&s->spi->dev, "%s\n", __func__); > > @@ -618,18 +601,14 @@ static const char *max3100_type(struct uart_port *port) > > static void max3100_release_port(struct uart_port *port) > { > - struct max3100_port *s = container_of(port, > - struct max3100_port, > - port); > + struct max3100_port *s = to_max3100_port(port); > > dev_dbg(&s->spi->dev, "%s\n", __func__); > } > > static void max3100_config_port(struct uart_port *port, int flags) > { > - struct max3100_port *s = container_of(port, > - struct max3100_port, > - port); > + struct max3100_port *s = to_max3100_port(port); > > dev_dbg(&s->spi->dev, "%s\n", __func__); > > @@ -640,9 +619,7 @@ static void max3100_config_port(struct uart_port *port, int flags) > static int max3100_verify_port(struct uart_port *port, > struct serial_struct *ser) > { > - struct max3100_port *s = container_of(port, > - struct max3100_port, > - port); > + struct max3100_port *s = to_max3100_port(port); > int ret = -EINVAL; > > dev_dbg(&s->spi->dev, "%s\n", __func__); > @@ -654,18 +631,14 @@ static int max3100_verify_port(struct uart_port *port, > > static void max3100_stop_tx(struct uart_port *port) > { > - struct max3100_port *s = container_of(port, > - struct max3100_port, > - port); > + struct max3100_port *s = to_max3100_port(port); > > dev_dbg(&s->spi->dev, "%s\n", __func__); > } > > static int max3100_request_port(struct uart_port *port) > { > - struct max3100_port *s = container_of(port, > - struct max3100_port, > - port); > + struct max3100_port *s = to_max3100_port(port); > > dev_dbg(&s->spi->dev, "%s\n", __func__); > return 0; > @@ -673,9 +646,7 @@ static int max3100_request_port(struct uart_port *port) > > static void max3100_break_ctl(struct uart_port *port, int break_state) > { > - struct max3100_port *s = container_of(port, > - struct max3100_port, > - port); > + struct max3100_port *s = to_max3100_port(port); > > dev_dbg(&s->spi->dev, "%s\n", __func__); > } > -- > 2.43.0.rc1.1.gbec44491f096 > > -- Hugo Villeneuve