From patchwork Tue Apr 9 14:45:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 787391 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 5372B50275; Tue, 9 Apr 2024 14:47:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712674052; cv=none; b=nvthsNzTdBcnMSBA511/Z55VeF4uZYVWeoOt0xf8ZR405iy+sRhLBQWDHrkhR0I5E++rfSWj78VfvNNtOfFZ+tYlt/zWnaJEI4M43CAxDyZoN318MYu1w0qtvmBNMOZlA0zcSRrZeIr7SqSsOeQx/yMQtF5FskXVcVDCB5ZLjfM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712674052; c=relaxed/simple; bh=kg9KDXJNIRys96XzkRzlSzAvAHPk0RvpRk5pjnWlqpo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dLTSfSm6pE3PpUDPxMW8uJOx7dI33MHxXaUhuttQgTDNpv4VuPG7HyLvCFdHPNs5Nx7/RKzMvWEPSV8zuvFuTwkvNQCPJFZM1xr4xBuqeyVEY/0zWezTFSEac11clwvusgi2vRBgDP7OFzQ5VahJpEFmw+ounpo8K59jd39Xido= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=S5QbEyWC; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="S5QbEyWC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712674050; x=1744210050; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kg9KDXJNIRys96XzkRzlSzAvAHPk0RvpRk5pjnWlqpo=; b=S5QbEyWCSV1p4Ba62giqlUCbktU64I/l2Ab+2uHG8DLxDiewMYM/vz2c DzKs2neRmBU4trtsKRSQYCPYuM/Bl5wEuc9hCGjlnIhVvg+r+S5b4s3xm HMaYff5ol1jdjq0Z5AawGjyocVHhxK6AskRfUQx77992NVFUg19+fNb97 R30jgXQ098qjjCgWK+5ElNVgr+pLgMPu5PjR79x59FRX9fqF+3MnhZiJR HyU2rQ39F44WujShIFJfTU45mEGoi7kpfXg8FFLfYdD+TvyPzbTrl0KUJ Uc0EtVUIOBdCggAnpakR/aWsvJXYbzETgxI/+Cg1077DhZq7o1k5hiR2G A==; X-CSE-ConnectionGUID: 1yXCl1FtQW2IoVrEPp4kNA== X-CSE-MsgGUID: 5J9w3LhBTl2kH3k+CIbXKQ== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="7905517" X-IronPort-AV: E=Sophos;i="6.07,189,1708416000"; d="scan'208";a="7905517" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2024 07:47:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="937093482" X-IronPort-AV: E=Sophos;i="6.07,189,1708416000"; d="scan'208";a="937093482" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 09 Apr 2024 07:47:28 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 2848D193; Tue, 9 Apr 2024 17:47:27 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Greg Kroah-Hartman , Jiri Slaby Subject: [PATCH v3 1/8] serial: max3100: Enable TIOCM_LOOP Date: Tue, 9 Apr 2024 17:45:48 +0300 Message-ID: <20240409144721.638326-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240409144721.638326-1-andriy.shevchenko@linux.intel.com> References: <20240409144721.638326-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Enable or disable loopback at run-time. Signed-off-by: Andy Shevchenko --- drivers/tty/serial/max3100.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c index 75e96ff74571..4a4343e7b1fa 100644 --- a/drivers/tty/serial/max3100.c +++ b/drivers/tty/serial/max3100.c @@ -32,14 +32,12 @@ /** * struct plat_max3100 - MAX3100 SPI UART platform data - * @loopback: force MAX3100 in loopback * @crystal: 1 for 3.6864 Mhz, 0 for 1.8432 * * You should use this structure in your machine description to specify * how the MAX3100 is connected. */ struct plat_max3100 { - int loopback; int crystal; }; @@ -109,6 +107,7 @@ struct max3100_port { int minor; /* minor number */ int crystal; /* 1 if 3.6864Mhz crystal 0 for 1.8432 */ + int loopback_commit; /* need to change loopback */ int loopback; /* 1 if we are in loopback mode */ /* for handling irqs: need workqueue since we do spi_sync */ @@ -241,9 +240,9 @@ static void max3100_work(struct work_struct *w) struct max3100_port *s = container_of(w, struct max3100_port, work); struct tty_port *tport = &s->port.state->port; unsigned char ch; + int conf, cconf, cloopback, crts; int rxchars; u16 tx, rx; - int conf, cconf, crts; dev_dbg(&s->spi->dev, "%s\n", __func__); @@ -253,11 +252,15 @@ static void max3100_work(struct work_struct *w) conf = s->conf; cconf = s->conf_commit; s->conf_commit = 0; + cloopback = s->loopback_commit; + s->loopback_commit = 0; crts = s->rts_commit; s->rts_commit = 0; spin_unlock(&s->conf_lock); if (cconf) max3100_sr(s, MAX3100_WC | conf, &rx); + if (cloopback) + max3100_sr(s, 0x4001, &rx); if (crts) { max3100_sr(s, MAX3100_WD | MAX3100_TE | (s->rts ? MAX3100_RTS : 0), &rx); @@ -395,18 +398,24 @@ static void max3100_set_mctrl(struct uart_port *port, unsigned int mctrl) struct max3100_port *s = container_of(port, struct max3100_port, port); - int rts; + int loopback, rts; dev_dbg(&s->spi->dev, "%s\n", __func__); + loopback = (mctrl & TIOCM_LOOP) > 0; rts = (mctrl & TIOCM_RTS) > 0; spin_lock(&s->conf_lock); + if (s->loopback != loopback) { + s->loopback = loopback; + s->loopback_commit = 1; + } if (s->rts != rts) { s->rts = rts; s->rts_commit = 1; - max3100_dowork(s); } + if (s->loopback_commit || s->rts_commit) + max3100_dowork(s); spin_unlock(&s->conf_lock); } @@ -593,12 +602,6 @@ static int max3100_startup(struct uart_port *port) return -EBUSY; } - if (s->loopback) { - u16 tx, rx; - tx = 0x4001; - max3100_sr(s, tx, &rx); - } - s->conf_commit = 1; max3100_dowork(s); /* wait for clock to settle */ @@ -754,7 +757,6 @@ static int max3100_probe(struct spi_device *spi) spi_set_drvdata(spi, max3100s[i]); pdata = dev_get_platdata(&spi->dev); max3100s[i]->crystal = pdata->crystal; - max3100s[i]->loopback = pdata->loopback; max3100s[i]->minor = i; timer_setup(&max3100s[i]->timer, max3100_timeout, 0); From patchwork Tue Apr 9 14:45:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 787893 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 267647C6D4; Tue, 9 Apr 2024 14:47:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712674053; cv=none; b=nEJwueU9hvmYOxi7S3J8zjWtyqx1C6YssL9owoQ1/CzhqE0Kf1fVl22PJpDaSAIvMxdkV0inLRbnaiwJZfIy67RBa4A6CgwNFx5WTILnFth+7pgAA9iHFT1z3sjJn3HnHAaQffaQ65NAM/jzNq14pw0M+8WpIuLdWgKBIROnk+M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712674053; c=relaxed/simple; bh=1gZpJYWGAf2cNtFpFnKr3hMZPoI1cEmqbZW998DA/PU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=amBYEcRmMgbD5FriB/safp3HA5eb20afyV1pcVDm3z99SYUMOqpgAFeAus95U2JYehyHcHtDs533gfyPAOsKlbgmpnIOLBJJ59m7iDrk11aRxOPVUPArhBYiFkcDlj7oZ3iB6vtK1fb5c4o8VFW6Q+mH1LnogyZfxdIVtFm005c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=OsCxTUuw; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="OsCxTUuw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712674052; x=1744210052; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1gZpJYWGAf2cNtFpFnKr3hMZPoI1cEmqbZW998DA/PU=; b=OsCxTUuw98RjfIrNAHkj43NnXl3s1CMAgiPW7wtEtyrTV7hkCZYU1vCT DqZ3uapI8RU59IY4Yv9BTRdBtzgrvvFocgu3NHZgsjC33ze5joNwxtonu MWt+wLXgDbmsvgTvfbObTkrpC0+gEG0otK4SR1udSIBLhnrs7o2Es8UYo z90a0Mi3tpvX8C5SFMqBzgHUbF8zFEUYnoEZVdvwAWMtd4ZeC6PIAw2eK gqwlZd0xav2N/BtgGhMf9B0Z/1Y5yfC3WtyY4WoMp2hXPiJX1O36nP4HF ajTojOhvrZPTOUYAahWdz2CW6S+I+d1XF+yIFOaunxZDtEhjfvkUjIyIQ A==; X-CSE-ConnectionGUID: 2swGCIxXSjS7dbI7ECpf2A== X-CSE-MsgGUID: 29XtUxI3RpaO4OfDJN2yug== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="7905520" X-IronPort-AV: E=Sophos;i="6.07,189,1708416000"; d="scan'208";a="7905520" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2024 07:47:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="937093484" X-IronPort-AV: E=Sophos;i="6.07,189,1708416000"; d="scan'208";a="937093484" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 09 Apr 2024 07:47:28 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 2FC93357; Tue, 9 Apr 2024 17:47:27 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Greg Kroah-Hartman , Jiri Slaby Subject: [PATCH v3 2/8] serial: max3100: Get crystal frequency via device property Date: Tue, 9 Apr 2024 17:45:49 +0300 Message-ID: <20240409144721.638326-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240409144721.638326-1-andriy.shevchenko@linux.intel.com> References: <20240409144721.638326-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Get crystal frequency via device property instead of using a platform data. Signed-off-by: Andy Shevchenko --- drivers/tty/serial/max3100.c | 49 +++++++++++++++--------------------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c index 4a4343e7b1fa..446bc78061e3 100644 --- a/drivers/tty/serial/max3100.c +++ b/drivers/tty/serial/max3100.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -30,17 +31,6 @@ #include -/** - * struct plat_max3100 - MAX3100 SPI UART platform data - * @crystal: 1 for 3.6864 Mhz, 0 for 1.8432 - * - * You should use this structure in your machine description to specify - * how the MAX3100 is connected. - */ -struct plat_max3100 { - int crystal; -}; - #define MAX3100_C (1<<14) #define MAX3100_D (0<<14) #define MAX3100_W (1<<15) @@ -106,7 +96,6 @@ struct max3100_port { int irq; /* irq assigned to the max3100 */ int minor; /* minor number */ - int crystal; /* 1 if 3.6864Mhz crystal 0 for 1.8432 */ int loopback_commit; /* need to change loopback */ int loopback; /* 1 if we are in loopback mode */ @@ -426,7 +415,8 @@ max3100_set_termios(struct uart_port *port, struct ktermios *termios, struct max3100_port *s = container_of(port, struct max3100_port, port); - int baud = 0; + unsigned int baud = port->uartclk / 16; + unsigned int baud230400 = (baud == 230400) ? 1 : 0; unsigned cflag; u32 param_new, param_mask, parity = 0; @@ -439,40 +429,40 @@ max3100_set_termios(struct uart_port *port, struct ktermios *termios, param_new = s->conf & MAX3100_BAUD; switch (baud) { case 300: - if (s->crystal) + if (baud230400) baud = s->baud; else param_new = 15; break; case 600: - param_new = 14 + s->crystal; + param_new = 14 + baud230400; break; case 1200: - param_new = 13 + s->crystal; + param_new = 13 + baud230400; break; case 2400: - param_new = 12 + s->crystal; + param_new = 12 + baud230400; break; case 4800: - param_new = 11 + s->crystal; + param_new = 11 + baud230400; break; case 9600: - param_new = 10 + s->crystal; + param_new = 10 + baud230400; break; case 19200: - param_new = 9 + s->crystal; + param_new = 9 + baud230400; break; case 38400: - param_new = 8 + s->crystal; + param_new = 8 + baud230400; break; case 57600: - param_new = 1 + s->crystal; + param_new = 1 + baud230400; break; case 115200: - param_new = 0 + s->crystal; + param_new = 0 + baud230400; break; case 230400: - if (s->crystal) + if (baud230400) param_new = 0; else baud = s->baud; @@ -575,7 +565,7 @@ static int max3100_startup(struct uart_port *port) dev_dbg(&s->spi->dev, "%s\n", __func__); s->conf = MAX3100_RM; - s->baud = s->crystal ? 230400 : 115200; + s->baud = port->uartclk / 16; s->rx_enabled = 1; if (s->suspending) @@ -718,8 +708,8 @@ static int uart_driver_registered; static int max3100_probe(struct spi_device *spi) { + struct device *dev = &spi->dev; int i, retval; - struct plat_max3100 *pdata; u16 rx; mutex_lock(&max3100s_lock); @@ -755,20 +745,21 @@ static int max3100_probe(struct spi_device *spi) max3100s[i]->irq = spi->irq; spin_lock_init(&max3100s[i]->conf_lock); spi_set_drvdata(spi, max3100s[i]); - pdata = dev_get_platdata(&spi->dev); - max3100s[i]->crystal = pdata->crystal; max3100s[i]->minor = i; timer_setup(&max3100s[i]->timer, max3100_timeout, 0); dev_dbg(&spi->dev, "%s: adding port %d\n", __func__, i); max3100s[i]->port.irq = max3100s[i]->irq; - max3100s[i]->port.uartclk = max3100s[i]->crystal ? 3686400 : 1843200; max3100s[i]->port.fifosize = 16; max3100s[i]->port.ops = &max3100_ops; max3100s[i]->port.flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF; max3100s[i]->port.line = i; max3100s[i]->port.type = PORT_MAX3100; max3100s[i]->port.dev = &spi->dev; + + /* Read clock frequency from a property, uart_add_one_port() will fail if it's not set */ + device_property_read_u32(dev, "clock-frequency", &max3100s[i]->port.uartclk); + retval = uart_add_one_port(&max3100_uart_driver, &max3100s[i]->port); if (retval < 0) dev_warn(&spi->dev, From patchwork Tue Apr 9 14:45:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 787390 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 89E9C12FF63; Tue, 9 Apr 2024 14:47:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712674054; cv=none; b=ZT9nVURcl9sYY2NEsFIqSuhMWDusetVsUREpW+/INZGHjts6KFyHXg5oxXS3axlr3UtkhJevPDvcYGH3WtxvHlEIKc7gkypSaqkfWD/mzyOh6KpCiWLUSpYze33VLLW87ZlBcsdkE+MOYswT3FeYTyvFhAVd1TwMDlU9lmH05B4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712674054; c=relaxed/simple; bh=AzV7ojVPO5a7N5jBs+1WvcuO+35uQD5o8KQy7ckJN8Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CyTg8Ts2DgTAYObIpwrG661ZfWZwBvX9FrA/FCaPVzsm3VVejLicrRcz6TTdGBnTO3SERbE2X4uMNvY3HXa050wSCdpYUNC+1ZFCC2ghDTDVCZHKUA8dS0nxEUVHfJfDQEbdrtqAfGk7D4G5ITa6fdqPKPXK/mV2IvhqpuH/FJY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=EjfjMqe9; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="EjfjMqe9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712674053; x=1744210053; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AzV7ojVPO5a7N5jBs+1WvcuO+35uQD5o8KQy7ckJN8Q=; b=EjfjMqe9ZHUpfSjXdAuHcHGv+res3ucLj6BWF5wLFMA7Skm2zWG/ayOS 99oN4PVLDLboa+0iBVfOkXH+h0Sd3yc+HhroPJgaYyB1yrCMwWzJ2YQKW Z8mdnQXPyEK+S7DefVY/DnJKPDfsRkaEiX9nBHZeySlYXv8NWwPoVRGS9 q5GDrUbVetpUS37+ffelOwq1/2ro8COutJp05rBO6ewqgtrihNPk4oJ3E 2CN/8gC9OS0VDhbWXGA0T2LuhzJOoMu/QkiNO89Kw2dYbPh03BLu3JZUH LmIjoa0BHoEY81WhPgaRmqHnTGUpCqsgl1u94Kq8jHJZssBWuoffdBgI8 A==; X-CSE-ConnectionGUID: GYXIRWJ7TA+OHU/J24+uUw== X-CSE-MsgGUID: 7x8F93giTtWq3qElGoNzHw== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="7905524" X-IronPort-AV: E=Sophos;i="6.07,189,1708416000"; d="scan'208";a="7905524" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2024 07:47:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="937093483" X-IronPort-AV: E=Sophos;i="6.07,189,1708416000"; d="scan'208";a="937093483" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 09 Apr 2024 07:47:28 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 3E14A8C9; Tue, 9 Apr 2024 17:47:27 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Greg Kroah-Hartman , Jiri Slaby Subject: [PATCH v3 3/8] serial: max3100: Remove duplicating irq field Date: Tue, 9 Apr 2024 17:45:50 +0300 Message-ID: <20240409144721.638326-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240409144721.638326-1-andriy.shevchenko@linux.intel.com> References: <20240409144721.638326-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The struct uart_port has a copy of the IRQ that is also stored in the private data structure. Remove the duplication in the latter one. Signed-off-by: Andy Shevchenko --- drivers/tty/serial/max3100.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c index 446bc78061e3..e3104ea7a3ca 100644 --- a/drivers/tty/serial/max3100.c +++ b/drivers/tty/serial/max3100.c @@ -93,8 +93,6 @@ struct max3100_port { #define MAX3100_7BIT 4 int rx_enabled; /* if we should rx chars */ - int irq; /* irq assigned to the max3100 */ - int minor; /* minor number */ int loopback_commit; /* need to change loopback */ int loopback; /* 1 if we are in loopback mode */ @@ -548,8 +546,8 @@ static void max3100_shutdown(struct uart_port *port) destroy_workqueue(s->workqueue); s->workqueue = NULL; } - if (s->irq) - free_irq(s->irq, s); + if (port->irq) + free_irq(port->irq, s); /* set shutdown mode to save power */ max3100_sr(s, MAX3100_WC | MAX3100_SHDN, &rx); @@ -561,6 +559,7 @@ static int max3100_startup(struct uart_port *port) struct max3100_port, port); char b[12]; + int ret; dev_dbg(&s->spi->dev, "%s\n", __func__); @@ -583,10 +582,10 @@ static int max3100_startup(struct uart_port *port) } INIT_WORK(&s->work, max3100_work); - if (request_irq(s->irq, max3100_irq, - IRQF_TRIGGER_FALLING, "max3100", s) < 0) { - dev_warn(&s->spi->dev, "cannot allocate irq %d\n", s->irq); - s->irq = 0; + ret = request_irq(port->irq, max3100_irq, IRQF_TRIGGER_FALLING, "max3100", s); + if (ret < 0) { + dev_warn(&s->spi->dev, "cannot allocate irq %d\n", port->irq); + port->irq = 0; destroy_workqueue(s->workqueue); s->workqueue = NULL; return -EBUSY; @@ -742,14 +741,13 @@ static int max3100_probe(struct spi_device *spi) return -ENOMEM; } max3100s[i]->spi = spi; - max3100s[i]->irq = spi->irq; spin_lock_init(&max3100s[i]->conf_lock); spi_set_drvdata(spi, max3100s[i]); max3100s[i]->minor = i; timer_setup(&max3100s[i]->timer, max3100_timeout, 0); dev_dbg(&spi->dev, "%s: adding port %d\n", __func__, i); - max3100s[i]->port.irq = max3100s[i]->irq; + max3100s[i]->port.irq = spi->irq; max3100s[i]->port.fifosize = 16; max3100s[i]->port.ops = &max3100_ops; max3100s[i]->port.flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF; @@ -813,7 +811,7 @@ static int max3100_suspend(struct device *dev) dev_dbg(&s->spi->dev, "%s\n", __func__); - disable_irq(s->irq); + disable_irq(s->port.irq); s->suspending = 1; uart_suspend_port(&max3100_uart_driver, &s->port); @@ -832,7 +830,7 @@ static int max3100_resume(struct device *dev) uart_resume_port(&max3100_uart_driver, &s->port); s->suspending = 0; - enable_irq(s->irq); + enable_irq(s->port.irq); s->conf_commit = 1; if (s->workqueue) From patchwork Tue Apr 9 14:45:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 787389 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 E8B1412FF99; Tue, 9 Apr 2024 14:47:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712674055; cv=none; b=sXbX28byw7Uc9alCfZmgYA6pzzIVlBn6TGpHxDfVTjWWi+o6uCm9w5AdM7FQbv6Lqab8pg9U6/1BF8gkcfG/aVVuZFCBKI1LZY9J4sYc/8U7FjlByfN2TXfrwvcU69fQBMC8/f48mOBEnqXvJFV46pLIiKoZpEyiGVmvCig+q40= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712674055; c=relaxed/simple; bh=vDMhltrK3RzG/4Ns3P4TzOAT9HMZ4adbMF+JSVYXVvY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cTHl5WZQLVur+piHIYZPaknE8pjCO5TNyKhaQZP2J9kGg/46YPldwMRDRmFppyc4MOP2hfFyFY/FMsmmPw4rO6dbXDSO0TZ86Iwo1SBYfi3W5WZfLlI1+ohg3qKVms8wN/MOv210Ski5/KAFfD+HoYqhJ8xl4zhW0uTsaDQG6Ew= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=diKYhpeC; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="diKYhpeC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712674054; x=1744210054; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vDMhltrK3RzG/4Ns3P4TzOAT9HMZ4adbMF+JSVYXVvY=; b=diKYhpeCBIiSqcboK74DIISz1L8OiqaD/yGke0Dba9zxtQsbQTYP+KqO RXJc1EmtUzxmcUDwbUBpVy6HD/zOrv9FbmAOhcpp6NBhxj6b+5aH4CbeH b1hvV09RtuphYjON1o9C2PoKx2teqoEGyBXvY62N8KHIHseZfYm08ftyC n6wp05xt5gfCzJGIBoJzL/XdJFkuEGWQ89FEy1Rp33crpzhaWkftInVig AVPzmJ6y/xSadmL+4eCnVXuDD7K5Su5D8SNkX4VSV1a8E+Db6m1pPsK9J lPYrDlGZ9e8mm6wXt1DHtfCIWMmnrmB/sdQrjlBX89sIl7qNxWtDUgje/ g==; X-CSE-ConnectionGUID: z7v0a5tiQ+aRqcv3R8Xh5Q== X-CSE-MsgGUID: ljw+jizdQL6wRrL75wNMHg== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="7905528" X-IronPort-AV: E=Sophos;i="6.07,189,1708416000"; d="scan'208";a="7905528" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2024 07:47:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="937093485" X-IronPort-AV: E=Sophos;i="6.07,189,1708416000"; d="scan'208";a="937093485" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 09 Apr 2024 07:47:28 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 43EED2E9; Tue, 9 Apr 2024 17:47:27 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Greg Kroah-Hartman , Jiri Slaby Subject: [PATCH v3 4/8] serial: max3100: Switch to use dev_err_probe() Date: Tue, 9 Apr 2024 17:45:51 +0300 Message-ID: <20240409144721.638326-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240409144721.638326-1-andriy.shevchenko@linux.intel.com> References: <20240409144721.638326-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Switch to use dev_err_probe() to simplify the error path and unify a message template. Signed-off-by: Andy Shevchenko --- drivers/tty/serial/max3100.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c index e3104ea7a3ca..09ec2ca06989 100644 --- a/drivers/tty/serial/max3100.c +++ b/drivers/tty/serial/max3100.c @@ -716,9 +716,8 @@ static int max3100_probe(struct spi_device *spi) if (!uart_driver_registered) { retval = uart_register_driver(&max3100_uart_driver); if (retval) { - printk(KERN_ERR "Couldn't register max3100 uart driver\n"); mutex_unlock(&max3100s_lock); - return retval; + return dev_err_probe(dev, retval, "Couldn't register max3100 uart driver\n"); } uart_driver_registered = 1; @@ -728,15 +727,12 @@ static int max3100_probe(struct spi_device *spi) if (!max3100s[i]) break; if (i == MAX_MAX3100) { - dev_warn(&spi->dev, "too many MAX3100 chips\n"); mutex_unlock(&max3100s_lock); - return -ENOMEM; + return dev_err_probe(dev, -ENOMEM, "too many MAX3100 chips\n"); } max3100s[i] = kzalloc(sizeof(struct max3100_port), GFP_KERNEL); if (!max3100s[i]) { - dev_warn(&spi->dev, - "kmalloc for max3100 structure %d failed!\n", i); mutex_unlock(&max3100s_lock); return -ENOMEM; } @@ -760,9 +756,7 @@ static int max3100_probe(struct spi_device *spi) retval = uart_add_one_port(&max3100_uart_driver, &max3100s[i]->port); if (retval < 0) - dev_warn(&spi->dev, - "uart_add_one_port failed for line %d with error %d\n", - i, retval); + dev_err_probe(dev, retval, "uart_add_one_port failed for line %d\n", i); /* set shutdown mode to save power. Will be woken-up on open */ max3100_sr(max3100s[i], MAX3100_WC | MAX3100_SHDN, &rx); From patchwork Tue Apr 9 14:45:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 787387 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 4E546131BA1; Tue, 9 Apr 2024 14:47:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712674057; cv=none; b=U/MG+b9+oXNNPatJkUrJbADKpo4DFsWx8czy59ev+mUrM4PTHlZD543bQN61OpWtveRwci6+CBIDbYaDaO1BdD/H4saUMty6ctuFK/rdjqebip8XEd8dBFBUALJFzDY/VN5n5HDQJeXowyILSoHxAj87vGqTGDpGpGw1QZ99+Lk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712674057; c=relaxed/simple; bh=xF8oRrOuA8we7IwhVd+8C+jZeZJzI3rGBO1o6MB+O0M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hj8rXdqJftKK+CeHoAS0/geKoYnHRKf95UNLDxPOp1Cugs/GcgWjn/GfiGKfwZ1ZhZe66KiH2ZpjrT33Xj+PpuAyGVS8QzVm1OFM8v1eUj13dil/xnVrvzu1sC0GKNYTux1g5EstFaeVJ54Wj+pyt5aP69sasKC/9d0EJWf9A4w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=YeC2MF+1; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="YeC2MF+1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712674056; x=1744210056; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xF8oRrOuA8we7IwhVd+8C+jZeZJzI3rGBO1o6MB+O0M=; b=YeC2MF+1N6O/AUabLz0WJCqkOmcYIOGI2aJH8KgL1FUVcBcDbPzDTz4K db6hCXp4ZcaFecWDwW1IDFKppxnXACviB7lPrkclP+AwMyNh934xGGIxI AL83rUkbv5FUCpxduaeO2a8l3BQ1uePqoUO02Fd1AphIhkXlQaEy5w4mF 0AocxRCHxt80Bd+Oiu09nRJ4lUZxIsPFUFWzom5l9vuwmumed/hvjyr4F oc5UbnYBWSI6zs5FIhW6F/1tG9Wwr0RSWJGUhJJnGiOeDz7EF1cPWc8h5 baVNL7zU0CYoWyN53Z3f9lCx/ooDgPgfK8DqCezdifJhBf6TiZg3RzjTq w==; X-CSE-ConnectionGUID: IdekcKAiTtGUcmq1BvwH/A== X-CSE-MsgGUID: aOdwVwQ0SemhDj0P2NPT7g== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="7905543" X-IronPort-AV: E=Sophos;i="6.07,189,1708416000"; d="scan'208";a="7905543" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2024 07:47:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="937093488" X-IronPort-AV: E=Sophos;i="6.07,189,1708416000"; d="scan'208";a="937093488" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 09 Apr 2024 07:47:30 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 587F58D1; Tue, 9 Apr 2024 17:47:27 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Greg Kroah-Hartman , Jiri Slaby Subject: [PATCH v3 5/8] serial: max3100: Replace MODULE_ALIAS() with respective ID tables Date: Tue, 9 Apr 2024 17:45:52 +0300 Message-ID: <20240409144721.638326-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240409144721.638326-1-andriy.shevchenko@linux.intel.com> References: <20240409144721.638326-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 MODULE_ALIAS() in most cases is a pure hack to avoid placing ID tables. Replace it with the respective ID tables. Signed-off-by: Andy Shevchenko --- drivers/tty/serial/max3100.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c index 09ec2ca06989..3004a95e573f 100644 --- a/drivers/tty/serial/max3100.c +++ b/drivers/tty/serial/max3100.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -840,13 +841,27 @@ static SIMPLE_DEV_PM_OPS(max3100_pm_ops, max3100_suspend, max3100_resume); #define MAX3100_PM_OPS NULL #endif +static const struct spi_device_id max3100_spi_id[] = { + { "max3100" }, + { } +}; +MODULE_DEVICE_TABLE(spi, max3100_spi_id); + +static const struct of_device_id max3100_of_match[] = { + { .compatible = "maxim,max3100" }, + { } +}; +MODULE_DEVICE_TABLE(of, max3100_of_match); + static struct spi_driver max3100_driver = { .driver = { .name = "max3100", + .of_match_table = max3100_of_match, .pm = MAX3100_PM_OPS, }, .probe = max3100_probe, .remove = max3100_remove, + .id_table = max3100_spi_id, }; module_spi_driver(max3100_driver); @@ -854,4 +869,3 @@ module_spi_driver(max3100_driver); MODULE_DESCRIPTION("MAX3100 driver"); MODULE_AUTHOR("Christian Pellegrin "); MODULE_LICENSE("GPL"); -MODULE_ALIAS("spi:max3100"); From patchwork Tue Apr 9 14:45:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 787388 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 BEEEB1311AC; Tue, 9 Apr 2024 14:47:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712674057; cv=none; b=kGrFkUc7NwJWKd2k47gbap4M5JGjqMUKmJvyYGJ5XHd8785O0lwhCyvOANtPhDYWhUtfOq2dAT6zE6bAgkIGIhxh5kYuKNN2fRGSibkP+2As+eDtDxrSKk6FR7LOcPB+a5lsUdzeBEYesvALA7GNE2YQS3566HE1yTZK+MYRWlA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712674057; c=relaxed/simple; bh=8f9F0d1TbdbG/VHMAuiUiInQd9MAfWKByxYOamMxypM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XKhyv4CdVOU0LGBgP/Rcn71WXQMGkhR099A8BSCUuSc5+cXlX0BJe3bHRagRsTV5VN+lcnlV518EaOjZDyGAhRIv2yhbggG7no5WZiDqil/ZlIBKBEUeVAZoDa9aOEviUFi3SP0hO5DkQ7qWazGKIio0nnsjasiXI59URHDMQlg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=hQz0GJQ0; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="hQz0GJQ0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712674056; x=1744210056; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8f9F0d1TbdbG/VHMAuiUiInQd9MAfWKByxYOamMxypM=; b=hQz0GJQ0QukIjG73ZQSyvHQl5MX3oxX5NNG0AZx5PrhiM6N5o6biAZbw AibGRJn4nrxZLQHCE9zLy1Qa3ENHgD2utTLyQny3Rp4HzqBrj2c5Nygo4 1d4qBA0Fsg8LzO0zZzzEXC3DowwO5U6TKcLQ7e8/+3x/oTpz3RGjcPDUV Z/r1yw6MK9qBQ4WxasCAYrTZTkFjWDtWHNqMmBtj/UV0q4ty3fBNMpVsM tN8740DHD/8UbI+BPKBcFDGvxY5WrS1KWslse7TPk+UQACP0zf92l1d8N kiIgAkiLdyUS17OM7TPoFus8WdPCNgDOn3bJ8zsiCnLfbju2brd5dV7Mn A==; X-CSE-ConnectionGUID: efaG8WJ+QxK2/dgOYIFTbw== X-CSE-MsgGUID: YL6PAa0/Tw+2PH9du4RaeQ== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="7905539" X-IronPort-AV: E=Sophos;i="6.07,189,1708416000"; d="scan'208";a="7905539" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2024 07:47:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="937093487" X-IronPort-AV: E=Sophos;i="6.07,189,1708416000"; d="scan'208";a="937093487" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 09 Apr 2024 07:47:30 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 624D18CA; Tue, 9 Apr 2024 17:47:27 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Greg Kroah-Hartman , Jiri Slaby Subject: [PATCH v3 6/8] serial: max3100: Switch to DEFINE_SIMPLE_DEV_PM_OPS() Date: Tue, 9 Apr 2024 17:45:53 +0300 Message-ID: <20240409144721.638326-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240409144721.638326-1-andriy.shevchenko@linux.intel.com> References: <20240409144721.638326-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The SIMPLE_DEV_PM_OPS() is deprecated, replace it with the DEFINE_SIMPLE_DEV_PM_OPS() and use pm_sleep_ptr() for setting the driver's PM routines. Signed-off-by: Andy Shevchenko --- drivers/tty/serial/max3100.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c index 3004a95e573f..db543eaa39c8 100644 --- a/drivers/tty/serial/max3100.c +++ b/drivers/tty/serial/max3100.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -797,8 +798,6 @@ static void max3100_remove(struct spi_device *spi) mutex_unlock(&max3100s_lock); } -#ifdef CONFIG_PM_SLEEP - static int max3100_suspend(struct device *dev) { struct max3100_port *s = dev_get_drvdata(dev); @@ -834,12 +833,7 @@ static int max3100_resume(struct device *dev) return 0; } -static SIMPLE_DEV_PM_OPS(max3100_pm_ops, max3100_suspend, max3100_resume); -#define MAX3100_PM_OPS (&max3100_pm_ops) - -#else -#define MAX3100_PM_OPS NULL -#endif +static DEFINE_SIMPLE_DEV_PM_OPS(max3100_pm_ops, max3100_suspend, max3100_resume); static const struct spi_device_id max3100_spi_id[] = { { "max3100" }, @@ -857,7 +851,7 @@ static struct spi_driver max3100_driver = { .driver = { .name = "max3100", .of_match_table = max3100_of_match, - .pm = MAX3100_PM_OPS, + .pm = pm_sleep_ptr(&max3100_pm_ops), }, .probe = max3100_probe, .remove = max3100_remove, From patchwork Tue Apr 9 14:45:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 787890 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 CE3E11311BB; Tue, 9 Apr 2024 14:47:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712674057; cv=none; b=m8Xi29A4tQFkMu58i/JhGDCjHQxxg8trd4p8jwzlDt3zEIVSaqGBEG0aO/KfPZis1om3x51O+byzkhkDELl5BSlg6Pml7sbd0CDTGsB/5eWl67rPLpqg/niRFqWeR7wbuTah8bUgAttIEXobqdJh8QiLs1XRb1yvhuavPplGfLc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712674057; c=relaxed/simple; bh=g0TObzXZAJf9fT1d6X4ImoYo9aLCppDtNsERfaj9vNs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BpbuTLRbs+he6Ff8DXtx8wMZSXAVWGW4v2C7evkTYdSe8p6tl5rcqOeh/b1TB/enJ2IFt1hsnwLYhxC9rZhUMSBpPHM2SMVGti/E8zHoYANslrhLPVimUk71BJN9+/UbnsFzTBJxeFYCU6NTVF1CbdzVm8ShpVC74HYuhaqujdM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=dpYKW9jC; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="dpYKW9jC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712674056; x=1744210056; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=g0TObzXZAJf9fT1d6X4ImoYo9aLCppDtNsERfaj9vNs=; b=dpYKW9jCsBOv/YYxVLrvvPY7LFL0utEFHcz+nvcdbWVrPvqmoLuPm5ne Skej2/syzDhfs8oQPZaFsJiGI0yHEz+IB0FlpY0pgZg8MLNBTrjwpJ1Au Qwd5psCo68wWBcorLgfUQnxZNi4qet38GVcJDB/SAwWEIWWgEj7GWmSyI P86X1zys+aV1v61pkt4y/N4OIM6kHYS8/VUWMZYzdqMQYdUOmcydzg/J0 nBAOXv/Wp3mJAAm4Rw/b676dtXLo3f30j2EU3seSkhzND/XUZXvTUz+wK Vpj8qhTp3EpDj7Evp49mkohEPn+RmTEPaKhj2FPUeZBVkl0r+MaCxxt4Y A==; X-CSE-ConnectionGUID: ehiOM+FAQFiery9ZLUSQOw== X-CSE-MsgGUID: pja6vvTlTEO67Gj9YSMgsQ== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="7905545" X-IronPort-AV: E=Sophos;i="6.07,189,1708416000"; d="scan'208";a="7905545" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2024 07:47:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="937093490" X-IronPort-AV: E=Sophos;i="6.07,189,1708416000"; d="scan'208";a="937093490" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 09 Apr 2024 07:47:30 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 72413A70; Tue, 9 Apr 2024 17:47:27 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Greg Kroah-Hartman , Jiri Slaby , Hugo Villeneuve Subject: [PATCH v3 7/8] serial: max3100: Extract to_max3100_port() helper macro Date: Tue, 9 Apr 2024 17:45:54 +0300 Message-ID: <20240409144721.638326-8-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240409144721.638326-1-andriy.shevchenko@linux.intel.com> References: <20240409144721.638326-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Instead of using container_of() explicitly, introduce a helper macro. This saves a lot of lines of code. Signed-off-by: Andy Shevchenko Reviewed-by: Hugo Villeneuve --- 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 db543eaa39c8..4e7cd037cfc2 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 */ @@ -320,9 +323,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__); @@ -330,9 +331,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__); @@ -341,9 +340,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__); @@ -357,9 +354,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__); @@ -370,9 +365,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__); @@ -384,9 +377,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__); @@ -412,9 +403,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; @@ -530,9 +519,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__); @@ -557,9 +544,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; @@ -605,9 +590,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__); @@ -616,18 +599,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__); @@ -638,9 +617,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__); @@ -652,18 +629,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; @@ -671,9 +644,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__); } From patchwork Tue Apr 9 14:45:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 787892 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 22C0D130A43; Tue, 9 Apr 2024 14:47:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712674055; cv=none; b=BforQ+Z77Pigbg5Uh0bu3nsQ6bSdo+C6sZvkwuqmts0Y/elipYtCKUEeqBDWr4K8yvUC7lGYq+8NO0d8QOov+SdDiQOwjoT0ZcrDwbC5USf2DpDXVI4ebn551dk6ZBoiltbsjyzDF2SyFt3XeoRtFNaFtfHNfZduCJrpobK0SkE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712674055; c=relaxed/simple; bh=pt7kSYebcjw0FdTN5T5ylrZPelzqHThOoid4ebBFqqQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AVTXGcvRCTwBBk4XKDETwyeN5RQLwIR5tTk2k/oyek8NXoyGFgqqqgNY6t2T1qiiDcxWPfNA40ipSA9yK2rr5hgnZmb8T4kd7rD/Q0cbkp8dT6tgfMKntGD38bj3jJ6dEiSYRiKZnv0pDLj1F97njSq7nhdZD/tC+4KcNxnzcQg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=egp86RJg; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="egp86RJg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712674054; x=1744210054; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pt7kSYebcjw0FdTN5T5ylrZPelzqHThOoid4ebBFqqQ=; b=egp86RJgQ//caVyOkD0lX/rhejNQ+yE0cOltBT4N2XboeL1LTpY7fFCC RiiWBp50LlCy7CQm7B2qVTwjdmbsJe919KV/LvUnLI2clg2Aus3Tb5qQ8 r1NZ78g4HoXQ0O7jupjZlg1o9ZFAZg9WjEJwVlA0JuSpg5UQoH8z/Glij Cx/xo0nlihZoH26rAk/rY14+LB5mwU8WNjxo6v+AsS81RIZexkO5KO+5C royCb7NqkID2o+xxuVs5yJSUNgwFv/N1815YEDClZtA5l9cJgeemzW2jB iEwP8OV7deYCsyQQuRBW9t2aGFXN2e0NfHWaXBTkuvmYasuEZFiXeEZ2b A==; X-CSE-ConnectionGUID: AQWbVTuvT2aaS4lbX4+yLw== X-CSE-MsgGUID: uqUXtoG3T3K2KszIiCrywg== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="7905535" X-IronPort-AV: E=Sophos;i="6.07,189,1708416000"; d="scan'208";a="7905535" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2024 07:47:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="937093489" X-IronPort-AV: E=Sophos;i="6.07,189,1708416000"; d="scan'208";a="937093489" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 09 Apr 2024 07:47:30 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7C852BC4; Tue, 9 Apr 2024 17:47:27 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Greg Kroah-Hartman , Jiri Slaby Subject: [PATCH v3 8/8] serial: max3100: Sort headers Date: Tue, 9 Apr 2024 17:45:55 +0300 Message-ID: <20240409144721.638326-9-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240409144721.638326-1-andriy.shevchenko@linux.intel.com> References: <20240409144721.638326-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sort the headers in alphabetic order in order to ease the maintenance for this part. Signed-off-by: Andy Shevchenko --- drivers/tty/serial/max3100.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c index 4e7cd037cfc2..ce24588150bf 100644 --- a/drivers/tty/serial/max3100.c +++ b/drivers/tty/serial/max3100.c @@ -18,18 +18,18 @@ #include #include -#include #include +#include #include #include #include #include #include #include +#include #include -#include -#include #include +#include #include #include