From patchwork Tue Apr 2 19:50:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 785358 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 AF54E15CD52; Tue, 2 Apr 2024 19:53:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712087597; cv=none; b=oKVX4PYqRZEF2UE/HlqVPrH1TrRSDiddmCIXT+Gl8mje5N1O4yXouCvXUL8+ZRLMmo36/UtRstviXNTFTrC0uvJcgkq4xmUqi1Z2EaeJZBikVY/T78JoFtY6hBoCXxGS7r2q/0abID+sZOr6K0JA/hLaYzODMbN/gobH+fKPCig= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712087597; c=relaxed/simple; bh=+of8nXv2yYLVGjFEgKMdTt0MbiPEXZvBXfKBOaicXQI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nhxTI7w/M9Uo4fKJg1gAblQT9reTO9UHO6hRsOEi32UjOcLqaPuCl0qmtW+5us5YMCrEsv3yayRMjSYSZESuVFj046Nv4DD2lqTZAHkrKhEeLPLj1MARhfEqWKaElBw/g+Bb+WGal+G/9XHzIrZFPzFiksMZlwc1Q+5mWSfa444= 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=hUbH33rz; arc=none smtp.client-ip=192.198.163.17 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="hUbH33rz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712087596; x=1743623596; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+of8nXv2yYLVGjFEgKMdTt0MbiPEXZvBXfKBOaicXQI=; b=hUbH33rzfuJ2h3Ohx5ci3UqwW5HR1QoO8bwzQTUPQthM54hro2TgXOXo WCQ6q9vN9WkfnBVPd1c3QCjgjYqZZuyfsoLUrFtiJPCZT59agvzBsyfPH x/q10IllAtq/6MJ54+P5GC+hMldBdFj+dzVnCi1Wr7GloR5GSR9PNJyaT hv2VIvJypvaBQRfN2rziP5DK/X1zs5gFU2M42Emm6R5Sv2K1AE1WCWc4U GfAlIOtJIsgXAcVbt4oowRz4oO9NMVOTAcVivROYiaeWymWFKc/PngmaB IasfwHN+BajN1QOO/KHX/GItJuDJlx1IcwQmzwfSU22nFFjO0HwYcmn63 A==; X-CSE-ConnectionGUID: 5hki2DydQuygUCvQJfyRlA== X-CSE-MsgGUID: lE3iizYUR8irxiv6wO32yQ== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="7150992" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="7150992" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 12:53:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="937083784" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="937083784" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Apr 2024 12:53:10 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id B5A32133; Tue, 2 Apr 2024 22:53:09 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Jiri Slaby , Hugo Villeneuve Subject: [PATCH v2 01/16] serial: max3100: Lock port->lock when calling uart_handle_cts_change() Date: Tue, 2 Apr 2024 22:50:28 +0300 Message-ID: <20240402195306.269276-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240402195306.269276-1-andriy.shevchenko@linux.intel.com> References: <20240402195306.269276-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 uart_handle_cts_change() has to be called with port lock taken, Since we run it in a separate work, the lock may not be taken at the time of running. Make sure that it's taken by explicitly doing that. Without it we got a splat: WARNING: CPU: 0 PID: 10 at drivers/tty/serial/serial_core.c:3491 uart_handle_cts_change+0xa6/0xb0 ... Workqueue: max3100-0 max3100_work [max3100] RIP: 0010:uart_handle_cts_change+0xa6/0xb0 ... max3100_handlerx+0xc5/0x110 [max3100] max3100_work+0x12a/0x340 [max3100] Fixes: 7831d56b0a35 ("tty: MAX3100") Signed-off-by: Andy Shevchenko --- drivers/tty/serial/max3100.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c index 5efb2b593be3..45022f2909f0 100644 --- a/drivers/tty/serial/max3100.c +++ b/drivers/tty/serial/max3100.c @@ -213,7 +213,7 @@ static int max3100_sr(struct max3100_port *s, u16 tx, u16 *rx) return 0; } -static int max3100_handlerx(struct max3100_port *s, u16 rx) +static int max3100_handlerx_unlocked(struct max3100_port *s, u16 rx) { unsigned int status = 0; int ret = 0, cts; @@ -254,6 +254,17 @@ static int max3100_handlerx(struct max3100_port *s, u16 rx) return ret; } +static int max3100_handlerx(struct max3100_port *s, u16 rx) +{ + unsigned long flags; + int ret; + + uart_port_lock_irqsave(&s->port, &flags); + ret = max3100_handlerx_unlocked(s, rx); + uart_port_unlock_irqrestore(&s->port, flags); + return ret; +} + static void max3100_work(struct work_struct *w) { struct max3100_port *s = container_of(w, struct max3100_port, work); From patchwork Tue Apr 2 19:50:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 785744 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 F33BF15CD54; Tue, 2 Apr 2024 19:53:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712087597; cv=none; b=gT1kBnCn807V7N7bHzCl7WhpUNZvpFPxytxeKNF8aWqSSP2yWzIMNyM5M0IefSwJRyVePQmCgoI+Fzq6yscuTG8Dir0qzgHI9VoQYaeMaPlow7AL3I+derxJa7B551/7GoN+wcI7zB7FMTkNhUyDPti+9/4GPzVYl96V3EokT1o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712087597; c=relaxed/simple; bh=xJUqvEi+qmStZVvR5xGTQUGRPj6WLU9SeicD1FyZC5Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LhWp+XtPKeVeJkEoBKbDzNm8R4Q0FchXvBadK7yBp6LOxe9FrO/QoiWVUtkBloWMvNSHFOIy8r2tAxu2FGVIbmQHfB3XQe0MHx3tgbA0ZpeRSyOmJnBXQSZHYuLxi+uStGNf1L3v7JleUI7TWf6pYC85VYjEmkQmUhCvG15tH3M= 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=Jdlv6+1C; arc=none smtp.client-ip=192.198.163.17 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="Jdlv6+1C" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712087596; x=1743623596; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xJUqvEi+qmStZVvR5xGTQUGRPj6WLU9SeicD1FyZC5Q=; b=Jdlv6+1C0esL8GwQnw+VoLUOTb+qnojQoFt4zsG7o+acVkOKhwLBdS98 0jnOSCVXi8lR2fWGhKGcnMvQEfXXBE9JTYVbk0Z8lU3MgVRFwaH/6ZWV3 39G5yiK02T/TO8xxGSqQET7lKmzDMCWLg0ShaAplaGZkKLaFPZUEb4icH h9TGePZVu8bI4WEbe3xSbIdSkKaSXjE79ZbGrAaPEq2aMkVkpxuZr1MQd ojmKa2R6TuK8+p/w/95kS79U+qDc1ayiPQqNIJYN/BEwD5dzhduVfOlaN /3te1HrsKwcXncbEJ6kOb9DcmWsItgR9Oo9wnmU9hDzqIiXLzc+tLdl8H w==; X-CSE-ConnectionGUID: etxwTR86Qzyk4JW/0/dZ2w== X-CSE-MsgGUID: lDMYPVjMSA6BFrTkCFnLJw== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="7150984" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="7150984" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 12:53:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="937083783" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="937083783" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Apr 2024 12:53:10 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id C02BD506; Tue, 2 Apr 2024 22:53:09 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Jiri Slaby , Hugo Villeneuve Subject: [PATCH v2 02/16] serial: max3100: Update uart_driver_registered on driver removal Date: Tue, 2 Apr 2024 22:50:29 +0300 Message-ID: <20240402195306.269276-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240402195306.269276-1-andriy.shevchenko@linux.intel.com> References: <20240402195306.269276-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 removal of the last MAX3100 device triggers the removal of the driver. However, code doesn't update the respective global variable and after insmod — rmmod — insmod cycle the kernel oopses: max3100 spi-PRP0001:01: max3100_probe: adding port 0 BUG: kernel NULL pointer dereference, address: 0000000000000408 ... RIP: 0010:serial_core_register_port+0xa0/0x840 ... max3100_probe+0x1b6/0x280 [max3100] spi_probe+0x8d/0xb0 Update the actual state so next time UART driver will be registered again. Hugo also noticed, that the error path in the probe also affected by having the variable set, and not cleared. Instead of clearing it move the assignment after the successfull uart_register_driver() call. Fixes: 7831d56b0a35 ("tty: MAX3100") Signed-off-by: Andy Shevchenko --- drivers/tty/serial/max3100.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c index 45022f2909f0..b3e63b6a402e 100644 --- a/drivers/tty/serial/max3100.c +++ b/drivers/tty/serial/max3100.c @@ -749,13 +749,14 @@ static int max3100_probe(struct spi_device *spi) mutex_lock(&max3100s_lock); if (!uart_driver_registered) { - uart_driver_registered = 1; 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; } + + uart_driver_registered = 1; } for (i = 0; i < MAX_MAX3100; i++) @@ -841,6 +842,7 @@ static void max3100_remove(struct spi_device *spi) } pr_debug("removing max3100 driver\n"); uart_unregister_driver(&max3100_uart_driver); + uart_driver_registered = 0; mutex_unlock(&max3100s_lock); } From patchwork Tue Apr 2 19:50:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 785743 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 A834F15D5AF; Tue, 2 Apr 2024 19:53:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712087599; cv=none; b=JjLDapFSD2WzG4MuAHEo1e24Hu9SltZU2j+fqQkWMO5sRn14ocTjnNIUGmgHqa3Fcr2iKrI2Yz37dv5qOTJLJmAxA6Nq8Qn0TYoVWOQKMvogxmljmJIhtoo+dW7YM1ahPaz8hQzSuTgji1FgSgwKoqz+FQwDO/PxGqHITA9bMF8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712087599; c=relaxed/simple; bh=n8VkQDEUtV5+Oh39C+hut59NEcsvenhzLvwxnXGx6ZY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=M5DS2osCOykdeJfTWtzxUVroEwy5ERmrtUXqgAWlkMltXiPlKc9Behn3InF/LoL1r+5SWoZL21+k/dRjlLScw9fIEXEuROorRxvyMnNZw816EO4ZOgiUAJfnZmW4K0kV93UqmBKfHGHM7DMYUgCsGhJgusktmihjPCTuKp936SA= 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=VeIFZCVa; arc=none smtp.client-ip=192.198.163.17 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="VeIFZCVa" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712087598; x=1743623598; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=n8VkQDEUtV5+Oh39C+hut59NEcsvenhzLvwxnXGx6ZY=; b=VeIFZCVaaPw4i+uMJxXMy/NKhAagTL/YhH4dLftb/OA5qzzOTZNggjcI Eu6Al7vBZshR2gD3AKCNjvCXyxz92Cue/FdMp/H2Q2hcrvsiDOLcnkZWJ WT3FyuWdH3rNsChArY5rWOXO5Qi99hiTu5+NUHQCjcKWrbJrWpHcbzzk5 E8w5DyPS+fNeObwgHg64nd1/eBj60o/q7KtRVUZo9SR5WE6bFGIbNyw5t JX+OhcbtzSg/zJ+CVe01abCqxCK6Zynn0tmf+h2nMnNI//mrpV+qxNGKM MyOWcqDAmPdQwhf1LNns3U1JxJa/ivk1x9aPpcgo4F/HwO8Tw3fQZuSKo g==; X-CSE-ConnectionGUID: mpQQmDFPTRKFl2Wh5FvQNA== X-CSE-MsgGUID: Wi1SlnYvSweQLduk+kR8zQ== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="7151001" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="7151001" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 12:53:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="937083786" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="937083786" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Apr 2024 12:53:10 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id CC9D8525; Tue, 2 Apr 2024 22:53:09 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Jiri Slaby , Hugo Villeneuve Subject: [PATCH v2 03/16] serial: max3100: Fix bitwise types Date: Tue, 2 Apr 2024 22:50:30 +0300 Message-ID: <20240402195306.269276-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240402195306.269276-1-andriy.shevchenko@linux.intel.com> References: <20240402195306.269276-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 Sparse is not happy about misuse of bitwise types: .../max3100.c:194:13: warning: incorrect type in assignment (different base types) .../max3100.c:194:13: expected unsigned short [addressable] [usertype] etx .../max3100.c:194:13: got restricted __be16 [usertype] .../max3100.c:202:15: warning: cast to restricted __be16 Fix this by choosing proper types for the respective variables. Fixes: 7831d56b0a35 ("tty: MAX3100") Signed-off-by: Andy Shevchenko --- drivers/tty/serial/max3100.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c index b3e63b6a402e..3d2b83d6ab51 100644 --- a/drivers/tty/serial/max3100.c +++ b/drivers/tty/serial/max3100.c @@ -45,6 +45,9 @@ #include #include #include +#include + +#include #include @@ -191,7 +194,7 @@ static void max3100_timeout(struct timer_list *t) static int max3100_sr(struct max3100_port *s, u16 tx, u16 *rx) { struct spi_message message; - u16 etx, erx; + __be16 etx, erx; int status; struct spi_transfer tran = { .tx_buf = &etx, From patchwork Tue Apr 2 19:50:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 785745 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 6C56715B96A; Tue, 2 Apr 2024 19:53:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712087595; cv=none; b=PPlsb+OS1Bz6ibCO38R5/8vwf5a+G4Q1mmU5zZ8pF6gJa+qc9RLNoCauIYQriYsCAkE2lMHVJoZB4fNpQZ8l+k/mASmuZeOl3EAy69lfKtM+Pe7miJoIEtVxsWehHemlkBwO5D6uysJAEwMdPe4eZYKdtT/WqaGt9po15smDWdo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712087595; c=relaxed/simple; bh=1UzMmpdJ3SyH/zn8EcKQjxnq5OJVXRSw4sEYO55O31c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FLHjTKxehULA3+5L9nmfwWHkXDBzySPDhJWRW3Ten9uWvoUTHDZmmUub13Wdla7+/fOfuK1DRU/9P+9kQOTcZGea8bg6D95KJqkNlYnh/EKb0DU/vJnmJ+LPJZIshLoUuuqwj53mNOvnh6nck3YqU4MrYcLOHBes+86Tf0LdWeQ= 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=NxigBuYs; arc=none smtp.client-ip=192.198.163.17 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="NxigBuYs" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712087594; x=1743623594; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1UzMmpdJ3SyH/zn8EcKQjxnq5OJVXRSw4sEYO55O31c=; b=NxigBuYs/KhhLDd99ZK1ij3qrZp3GxRQthng8XKsGclOwa2AWHrH6NwH LY4LcNpUIvNVls/5LfFhLFlBpIlWB/8V8qos3zEBYMcaFPCL1y1Nv+oh7 iGjpdgQVZuMEHbbJ614zYTKM8LI9x6GPSPqny8zOlAlYDm/ZEJq3qORnR +uNzsCJqDbvtko+UEIrwX4IV6jZewIoZcLdhQzSFd9vKpd7CNQZZzPI7d bTGyiZQV2u5qPtx4prY7aALaAwiqjQt+xCUGQFyhGelEefUr3zaVfbeTD qZVsBbBHGmin2YxI0ltgsQX6FwdOBgmLgwAPcxAZ7+O92nHJcUPBs06A5 A==; X-CSE-ConnectionGUID: qA3a4RotSDORZNgf9VvLpw== X-CSE-MsgGUID: dSTH3/2ASRK6DUSxNkWeDA== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="7150988" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="7150988" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 12:53:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="937083782" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="937083782" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Apr 2024 12:53:10 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id D746957D; Tue, 2 Apr 2024 22:53:09 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Jiri Slaby , Hugo Villeneuve Subject: [PATCH v2 04/16] serial: max3100: Make struct plat_max3100 local Date: Tue, 2 Apr 2024 22:50:31 +0300 Message-ID: <20240402195306.269276-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240402195306.269276-1-andriy.shevchenko@linux.intel.com> References: <20240402195306.269276-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 There is no user of the struct plat_max3100 outside the driver. Inline its contents into the driver. While at it, drop outdated example in the comment. Signed-off-by: Andy Shevchenko --- drivers/tty/serial/max3100.c | 38 +++++++++++++-------------- include/linux/serial_max3100.h | 48 ---------------------------------- 2 files changed, 18 insertions(+), 68 deletions(-) delete mode 100644 include/linux/serial_max3100.h diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c index 3d2b83d6ab51..031803a5da58 100644 --- a/drivers/tty/serial/max3100.c +++ b/drivers/tty/serial/max3100.c @@ -1,6 +1,5 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * * Copyright (C) 2008 Christian Pellegrin * * Notes: the MAX3100 doesn't provide an interrupt on CTS so we have @@ -8,24 +7,6 @@ * writing conf clears FIFO buffer and we cannot have this interrupt * always asking us for attention. * - * Example platform data: - - static struct plat_max3100 max3100_plat_data = { - .loopback = 0, - .crystal = 0, - .poll_time = 100, - }; - - static struct spi_board_info spi_board_info[] = { - { - .modalias = "max3100", - .platform_data = &max3100_plat_data, - .irq = IRQ_EINT12, - .max_speed_hz = 5*1000*1000, - .chip_select = 0, - }, - }; - * The initial minor number is 209 in the low-density serial port: * mknod /dev/ttyMAX0 c 204 209 */ @@ -49,7 +30,24 @@ #include -#include +/** + * struct plat_max3100 - MAX3100 SPI UART platform data + * @loopback: force MAX3100 in loopback + * @crystal: 1 for 3.6864 Mhz, 0 for 1.8432 + * @max3100_hw_suspend: MAX3100 has a shutdown pin. This is a hook + * called on suspend and resume to activate it. + * @poll_time: poll time for CTS signal in ms, 0 disables (so no hw + * flow ctrl is possible but you have less CPU usage) + * + * You should use this structure in your machine description to specify + * how the MAX3100 is connected. + */ +struct plat_max3100 { + int loopback; + int crystal; + void (*max3100_hw_suspend) (int suspend); + int poll_time; +}; #define MAX3100_C (1<<14) #define MAX3100_D (0<<14) diff --git a/include/linux/serial_max3100.h b/include/linux/serial_max3100.h deleted file mode 100644 index befd55c08a7c..000000000000 --- a/include/linux/serial_max3100.h +++ /dev/null @@ -1,48 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* - * - * Copyright (C) 2007 Christian Pellegrin - */ - - -#ifndef _LINUX_SERIAL_MAX3100_H -#define _LINUX_SERIAL_MAX3100_H 1 - - -/** - * struct plat_max3100 - MAX3100 SPI UART platform data - * @loopback: force MAX3100 in loopback - * @crystal: 1 for 3.6864 Mhz, 0 for 1.8432 - * @max3100_hw_suspend: MAX3100 has a shutdown pin. This is a hook - * called on suspend and resume to activate it. - * @poll_time: poll time for CTS signal in ms, 0 disables (so no hw - * flow ctrl is possible but you have less CPU usage) - * - * You should use this structure in your machine description to specify - * how the MAX3100 is connected. Example: - * - * static struct plat_max3100 max3100_plat_data = { - * .loopback = 0, - * .crystal = 0, - * .poll_time = 100, - * }; - * - * static struct spi_board_info spi_board_info[] = { - * { - * .modalias = "max3100", - * .platform_data = &max3100_plat_data, - * .irq = IRQ_EINT12, - * .max_speed_hz = 5*1000*1000, - * .chip_select = 0, - * }, - * }; - * - **/ -struct plat_max3100 { - int loopback; - int crystal; - void (*max3100_hw_suspend) (int suspend); - int poll_time; -}; - -#endif From patchwork Tue Apr 2 19:50:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 785356 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 E002A15D5B8; Tue, 2 Apr 2024 19:53:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712087599; cv=none; b=mQBHouv6b1U6jjMgnL0RaAxt1YjrJEl+GmLivVYoKWYW3PjPWOrg/PAyLOiRNAZOw4fAz/QmYUcenQc6sTDiTaeKFKZFF9jBG4UD4VtkcXcru+TdFHAcVnJ7+49BGUMRwUZ/BCdU00gs2gsP14vOPYAwxLMEtyT2mZCECZv4Bkg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712087599; c=relaxed/simple; bh=hwX0VzHlci8kWHYHJbr2yCODKUvNYIYEx+UfyWdrKX8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Kq7kxxNm+EIFJQ9Hlg7MV9P752adNqo0EdUqBxCnL2O/zaccMGwQRfRyNsf7WSbFR7QR52cpQJrIXKRiHgJrBnxszmiIizsCMkaYBTefJho2b0CbemiUiQ4m4fajPs/m+rDGQmmwTFd6rlkr02G2KeRukfFtWD42i9wEtqi0wuA= 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=BNJr2Bbh; arc=none smtp.client-ip=192.198.163.17 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="BNJr2Bbh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712087598; x=1743623598; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hwX0VzHlci8kWHYHJbr2yCODKUvNYIYEx+UfyWdrKX8=; b=BNJr2Bbh18ucT38TSxHMn+eIeqiNZ2BuVAhTTujb6lizETRqkCoCEzF9 JWz+EAxVq6VoEkbvOLADYEHt5KWwcpEWxoUqb8cHD6ilolBzBKbRG/qQE XJOfsKYrESeMCqMyMtHPDnmn2YES7fdyrCc3VsCspKi+prKnQntYJ2h1T EjJ6gqTaYkg9LHhcrY+6uniiShifZYKxEqPCsJ8Oiz8SMBEFzh3lcNfza SPwwQlu1zNgwcfnq1QHoSccS8LM9rp0IWIYI2gRGCA0fDLvgsoS5UXulu A6gKvnIsA/qEEbs3T/Ipe471M/AnNnAYmQP4MTqJFmKWAKS8yBa9J8LZU g==; X-CSE-ConnectionGUID: 0RX3wz2/TDy8VJ/4Oca2Yg== X-CSE-MsgGUID: RfqLUULlTWC6Tia9unzrXg== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="7151003" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="7151003" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 12:53:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="937083787" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="937083787" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Apr 2024 12:53:13 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id DD04128A; Tue, 2 Apr 2024 22:53:09 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Jiri Slaby , Hugo Villeneuve Subject: [PATCH v2 05/16] serial: max3100: Remove custom HW shutdown support Date: Tue, 2 Apr 2024 22:50:32 +0300 Message-ID: <20240402195306.269276-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240402195306.269276-1-andriy.shevchenko@linux.intel.com> References: <20240402195306.269276-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 While there is no user of this callback in the kernel, it also breaks the relationship in the driver model. The correct implementation should be done via GPIO or regulator framework. Remove custom HW shutdown support for good and, if needed, we will implement it correctly later on. Signed-off-by: Andy Shevchenko --- drivers/tty/serial/max3100.c | 42 ++++++------------------------------ 1 file changed, 7 insertions(+), 35 deletions(-) diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c index 031803a5da58..c31e4a96cc72 100644 --- a/drivers/tty/serial/max3100.c +++ b/drivers/tty/serial/max3100.c @@ -34,8 +34,6 @@ * struct plat_max3100 - MAX3100 SPI UART platform data * @loopback: force MAX3100 in loopback * @crystal: 1 for 3.6864 Mhz, 0 for 1.8432 - * @max3100_hw_suspend: MAX3100 has a shutdown pin. This is a hook - * called on suspend and resume to activate it. * @poll_time: poll time for CTS signal in ms, 0 disables (so no hw * flow ctrl is possible but you have less CPU usage) * @@ -45,7 +43,6 @@ struct plat_max3100 { int loopback; int crystal; - void (*max3100_hw_suspend) (int suspend); int poll_time; }; @@ -125,9 +122,6 @@ struct max3100_port { /* need to know we are suspending to avoid deadlock on workqueue */ int suspending; - /* hook for suspending MAX3100 via dedicated pin */ - void (*max3100_hw_suspend) (int suspend); - /* poll time (in ms) for ctrl lines */ int poll_time; /* and its timer */ @@ -553,6 +547,7 @@ static void max3100_shutdown(struct uart_port *port) struct max3100_port *s = container_of(port, struct max3100_port, port); + u16 rx; dev_dbg(&s->spi->dev, "%s\n", __func__); @@ -572,14 +567,7 @@ static void max3100_shutdown(struct uart_port *port) free_irq(s->irq, s); /* set shutdown mode to save power */ - if (s->max3100_hw_suspend) - s->max3100_hw_suspend(1); - else { - u16 tx, rx; - - tx = MAX3100_WC | MAX3100_SHDN; - max3100_sr(s, tx, &rx); - } + max3100_sr(s, MAX3100_WC | MAX3100_SHDN, &rx); } static int max3100_startup(struct uart_port *port) @@ -625,8 +613,6 @@ static int max3100_startup(struct uart_port *port) max3100_sr(s, tx, &rx); } - if (s->max3100_hw_suspend) - s->max3100_hw_suspend(0); s->conf_commit = 1; max3100_dowork(s); /* wait for clock to settle */ @@ -745,7 +731,7 @@ static int max3100_probe(struct spi_device *spi) { int i, retval; struct plat_max3100 *pdata; - u16 tx, rx; + u16 rx; mutex_lock(&max3100s_lock); @@ -786,7 +772,6 @@ static int max3100_probe(struct spi_device *spi) max3100s[i]->poll_time = msecs_to_jiffies(pdata->poll_time); if (pdata->poll_time > 0 && max3100s[i]->poll_time == 0) max3100s[i]->poll_time = 1; - max3100s[i]->max3100_hw_suspend = pdata->max3100_hw_suspend; max3100s[i]->minor = i; timer_setup(&max3100s[i]->timer, max3100_timeout, 0); @@ -806,12 +791,7 @@ static int max3100_probe(struct spi_device *spi) i, retval); /* set shutdown mode to save power. Will be woken-up on open */ - if (max3100s[i]->max3100_hw_suspend) - max3100s[i]->max3100_hw_suspend(1); - else { - tx = MAX3100_WC | MAX3100_SHDN; - max3100_sr(max3100s[i], tx, &rx); - } + max3100_sr(max3100s[i], MAX3100_WC | MAX3100_SHDN, &rx); mutex_unlock(&max3100s_lock); return 0; } @@ -853,6 +833,7 @@ static void max3100_remove(struct spi_device *spi) static int max3100_suspend(struct device *dev) { struct max3100_port *s = dev_get_drvdata(dev); + u16 rx; dev_dbg(&s->spi->dev, "%s\n", __func__); @@ -861,15 +842,8 @@ static int max3100_suspend(struct device *dev) s->suspending = 1; uart_suspend_port(&max3100_uart_driver, &s->port); - if (s->max3100_hw_suspend) - s->max3100_hw_suspend(1); - else { - /* no HW suspend, so do SW one */ - u16 tx, rx; - - tx = MAX3100_WC | MAX3100_SHDN; - max3100_sr(s, tx, &rx); - } + /* no HW suspend, so do SW one */ + max3100_sr(s, MAX3100_WC | MAX3100_SHDN, &rx); return 0; } @@ -879,8 +853,6 @@ static int max3100_resume(struct device *dev) dev_dbg(&s->spi->dev, "%s\n", __func__); - if (s->max3100_hw_suspend) - s->max3100_hw_suspend(0); uart_resume_port(&max3100_uart_driver, &s->port); s->suspending = 0; From patchwork Tue Apr 2 19:50:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 785739 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 BB89715E7FA; Tue, 2 Apr 2024 19:53:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712087604; cv=none; b=HvxswKZl7syH6m98fETL5BaobYREKcXKeAdTbRAODN0NTOq3yyUU+Ky0eT1R5m1F4WQfXOAhBOx41U9ZAA3gMV1aEJL6sZHeAXLLDc9jBe90K6vOOalcICr9DRZ1TlZ/53qOWCN1OAquN7SOwipXVJL6KLc/qUicF0qApW3RepU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712087604; c=relaxed/simple; bh=+tCR8Q6qrQLWWhfMOEUZuihnpFyj0j83V98VFK52xIc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R1jQwJWeluN9UR9VynzSKifHc2+maZwyeNIlcZ6oo9yK62aJpTHLQ8IKpX8waNKv2pKAfO4bVjNKmES4yOaUaLisASC/7y555OVn1bdXrt3c/7AqmJ6NNkwM3PPMDo2tG59dLtYUqtAxzswm3dqVwJS8ZrBaf3+CKKaIfkz4np0= 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=OcjN0hj+; arc=none smtp.client-ip=192.198.163.17 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="OcjN0hj+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712087603; x=1743623603; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+tCR8Q6qrQLWWhfMOEUZuihnpFyj0j83V98VFK52xIc=; b=OcjN0hj+PLRTIE0XhZ7xk5zF6zJtL9KNDgUUGt97tHtQlhazepzRkE3c uVzqm3486CpBkpdxgbHvlCOdYrg1I0hHATIQupKJzM3IR5cAFFeS7xx2s cwM8kNNcEm/cOxkMG8xRPcVmiqeIA3534/wuw4ca3JSjenLHD6RwO+caS 3mWx5DV6jzB/DIj4R/kxCKoFXeygg1eqv15Dmni0yQHrJay/6QQ6TeUKc xdzuPxoXWmghh9jLvFMXiMIzlITavvVKJukoWj/UZib8RnrsmDlrRUeJk RPYE7FMRC1aXWWOoPTE3a6TaxewbQauPgIoTPwlIhJYYzmz0nsVjP+FjJ Q==; X-CSE-ConnectionGUID: Ak2GAdJtTZe7XxNZs25lVA== X-CSE-MsgGUID: qPbBct4jTqmIsp6j/qBzFg== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="7151041" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="7151041" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 12:53:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="937083789" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="937083789" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Apr 2024 12:53:13 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id E6E9C6CB; Tue, 2 Apr 2024 22:53:09 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Jiri Slaby , Hugo Villeneuve Subject: [PATCH v2 06/16] serial: max3100: Replace custom polling timeout with standard one Date: Tue, 2 Apr 2024 22:50:33 +0300 Message-ID: <20240402195306.269276-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240402195306.269276-1-andriy.shevchenko@linux.intel.com> References: <20240402195306.269276-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 Serial core provides a standard timeout for polling modem state. Use it instead of a custom approach. Signed-off-by: Andy Shevchenko --- drivers/tty/serial/max3100.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c index c31e4a96cc72..6dc20e4ec078 100644 --- a/drivers/tty/serial/max3100.c +++ b/drivers/tty/serial/max3100.c @@ -34,8 +34,6 @@ * struct plat_max3100 - MAX3100 SPI UART platform data * @loopback: force MAX3100 in loopback * @crystal: 1 for 3.6864 Mhz, 0 for 1.8432 - * @poll_time: poll time for CTS signal in ms, 0 disables (so no hw - * flow ctrl is possible but you have less CPU usage) * * You should use this structure in your machine description to specify * how the MAX3100 is connected. @@ -43,7 +41,6 @@ struct plat_max3100 { int loopback; int crystal; - int poll_time; }; #define MAX3100_C (1<<14) @@ -122,9 +119,6 @@ struct max3100_port { /* need to know we are suspending to avoid deadlock on workqueue */ int suspending; - /* poll time (in ms) for ctrl lines */ - int poll_time; - /* and its timer */ struct timer_list timer; }; @@ -177,10 +171,8 @@ static void max3100_timeout(struct timer_list *t) { struct max3100_port *s = from_timer(s, t, timer); - if (s->port.state) { - max3100_dowork(s); - mod_timer(&s->timer, jiffies + s->poll_time); - } + max3100_dowork(s); + mod_timer(&s->timer, jiffies + uart_poll_timeout(&s->port)); } static int max3100_sr(struct max3100_port *s, u16 tx, u16 *rx) @@ -342,8 +334,7 @@ static void max3100_enable_ms(struct uart_port *port) struct max3100_port, port); - if (s->poll_time > 0) - mod_timer(&s->timer, jiffies); + mod_timer(&s->timer, jiffies); dev_dbg(&s->spi->dev, "%s\n", __func__); } @@ -526,9 +517,7 @@ max3100_set_termios(struct uart_port *port, struct ktermios *termios, MAX3100_STATUS_PE | MAX3100_STATUS_FE | MAX3100_STATUS_OE; - if (s->poll_time > 0) - del_timer_sync(&s->timer); - + del_timer_sync(&s->timer); uart_update_timeout(port, termios->c_cflag, baud); spin_lock(&s->conf_lock); @@ -556,8 +545,7 @@ static void max3100_shutdown(struct uart_port *port) s->force_end_work = 1; - if (s->poll_time > 0) - del_timer_sync(&s->timer); + del_timer_sync(&s->timer); if (s->workqueue) { destroy_workqueue(s->workqueue); @@ -769,9 +757,6 @@ static int max3100_probe(struct spi_device *spi) pdata = dev_get_platdata(&spi->dev); max3100s[i]->crystal = pdata->crystal; max3100s[i]->loopback = pdata->loopback; - max3100s[i]->poll_time = msecs_to_jiffies(pdata->poll_time); - if (pdata->poll_time > 0 && max3100s[i]->poll_time == 0) - max3100s[i]->poll_time = 1; max3100s[i]->minor = i; timer_setup(&max3100s[i]->timer, max3100_timeout, 0); From patchwork Tue Apr 2 19:50:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 785740 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 EBF0115E21E; Tue, 2 Apr 2024 19:53:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712087602; cv=none; b=kQO7DMZJT5PgdErRKZOwjtR8D0gUqmnxLE1bwm+sZoXcVq1IVyLH7LqttNm6a1qLr9jP7zO1P++4AYfLLB5yqRNsz3Pyv1FkW4IfrAdQIr0L6wZF5u2PCVRtuv3GX+2Bq9RbSnzKLd/wNxUQcJVvIrIGrDK5uW1IGGwtv8GvxV0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712087602; c=relaxed/simple; bh=lkYByveoDNXTS+TGzqxE2FjXqVLC6IlZzHAyfGxhKyg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OFN78n6nAWxp4XTxI2gTAGOW0xDOgwcBeNocLdwdPLKuN6hlKifDALJ3b4Gl8OGBzGiRf2vD2ZdoN6Dp4nPV6Jwjod64+p1k8f0tQGPOoy6hPQbes8464ItWjglS4aDpW0efUvd4vRAVjlBUJJGLmYAe43egn2EE1FBXfLFKM/E= 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=ibvTmlQs; arc=none smtp.client-ip=192.198.163.17 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="ibvTmlQs" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712087601; x=1743623601; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lkYByveoDNXTS+TGzqxE2FjXqVLC6IlZzHAyfGxhKyg=; b=ibvTmlQstoQuvbNuVOXuSa1+7+7P4nTYwcWG7BiG30EIVbllsVplWT4u u3c2kmIvk3Sl4G/r1aqFoxXH2kd58UJdGncgD8SQb9/A3+j9rLsHLgkuT m6sbXiutPWCGJPmxvInrbRkJFIUgmmfuxqhe+/KhjoSeprfSTU7S78NzT uza+2Sf+hn8BLNSBq0baDCaqQcWBh3/ME63E00LFPkpJs3gRx5O8sHUYo Mgm967Q8p7LJ+e1hT6qaErHwwX4Z1SxRZVJeG3MsrtHJcqrtwJ5Ie4f04 MCw3LL424ia7ljxWMrbp190rdH3X2NJoWL5IToVkegvQF54L+ak6H/oxE A==; X-CSE-ConnectionGUID: AdyT2GhKSCKot8WOkNkd/A== X-CSE-MsgGUID: FifmvPHiRwaKX9rEp6OyfA== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="7151021" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="7151021" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 12:53:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="937083788" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="937083788" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Apr 2024 12:53:13 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 022FA812; Tue, 2 Apr 2024 22:53:09 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Jiri Slaby , Hugo Villeneuve Subject: [PATCH v2 07/16] serial: max3100: Enable TIOCM_LOOP Date: Tue, 2 Apr 2024 22:50:34 +0300 Message-ID: <20240402195306.269276-8-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240402195306.269276-1-andriy.shevchenko@linux.intel.com> References: <20240402195306.269276-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 6dc20e4ec078..cd6a80e97868 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 */ @@ -257,7 +256,7 @@ static void max3100_work(struct work_struct *w) struct max3100_port *s = container_of(w, struct max3100_port, work); int rxchars; u16 tx, rx; - int conf, cconf, crts; + int conf, cconf, cloopback, crts; struct circ_buf *xmit = &s->port.state->xmit; dev_dbg(&s->spi->dev, "%s\n", __func__); @@ -268,11 +267,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); @@ -397,18 +400,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); } @@ -595,12 +604,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 */ @@ -756,7 +759,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 2 19:50:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 785742 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 1A31F15D5D8; Tue, 2 Apr 2024 19:53:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712087600; cv=none; b=H7sbrIloJGSBAgOEFlJ6ysc73IadaCV4LHolRt7FPIJpnB2GrgfZhuk7JYrv/uPVpkvGUSk2mQQzhJury+OJZr6S5cgEMyEA0vTeKaoGTNc7csX3FmgL69SmwqDtTSaFJxX990xETt+8XM2GVFRsR1rJoBP8eXbOz2tDaOVyaDI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712087600; c=relaxed/simple; bh=Pi6Iu7dutwBs4bW3dBS5h5JXTELjV2UWlLMb4UNtt4M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EDpSJFpTtbZjGzgHI537vuA+X5Uq+SPTW0WH8bP/4fKa54bFIeg74ZZV5b9GFTx9JLExkEy2sSpt3UMbnFx6pJE9OdUHwGGIGOdqV7H9vNi9alXSTy+kXGTUeIq+7igvx4kNv0luy6cEaaUole2RaHBeb2EjVZhB5o3D1iRoKLw= 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=BuceOWkb; arc=none smtp.client-ip=192.198.163.17 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="BuceOWkb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712087599; x=1743623599; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Pi6Iu7dutwBs4bW3dBS5h5JXTELjV2UWlLMb4UNtt4M=; b=BuceOWkb3PhI+6hddI32OSi9ULiUIwXZjAKNK9+exRLg6aq4dmCQGOn4 duZWDjOyN5TmipXd4xnhnJzufUmCPgKhSVex+4V73YNf6QwD6fx+3j+l3 zUGzRLGulOCO/mt0sHYQdvdQ1QYBW3tS70+jExlrtsduVt/4ChNKJCDif 9SmcS0BY2Dbk8jnuvKXRTkr/U9EY6zsiO66Nnlq4CLcbBBCiyF/mWlPAG xWZq9d6KDAWyi0Rg1K8Hd/KzW9xcPIGtGGFI/mg1yozz6TAuhNrgzyZn/ R1eUuebcGMmLBRcPn7VVBnsC5DTKE1GlEZ/gLiq4Yzt7j+vMZaXKc5SPL A==; X-CSE-ConnectionGUID: 3e1e1UbGTeiI6hV9phm8rA== X-CSE-MsgGUID: enoX+2j8SVqhIsC2clYuSg== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="7151007" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="7151007" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 12:53:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="937083790" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="937083790" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Apr 2024 12:53:13 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 0C3799B0; Tue, 2 Apr 2024 22:53:10 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Jiri Slaby , Hugo Villeneuve Subject: [PATCH v2 08/16] serial: max3100: Get crystal frequency via device property Date: Tue, 2 Apr 2024 22:50:35 +0300 Message-ID: <20240402195306.269276-9-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240402195306.269276-1-andriy.shevchenko@linux.intel.com> References: <20240402195306.269276-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 cd6a80e97868..bd3f281969e3 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 */ @@ -428,7 +417,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; @@ -441,40 +431,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; @@ -577,7 +567,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) @@ -720,8 +710,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); @@ -757,20 +747,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 2 19:50:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 785741 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 BABEA15DBD8; Tue, 2 Apr 2024 19:53:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712087601; cv=none; b=d2YI3xUd6hR7W5EjRFmCjIhPB5jFeUYp0b4QimKiY++BqOjttPC2fChCMQ3460Sepklev98aaKJ9AgG64HnzX4V1+gxKOhqqeJlHxZx8N8nzSka9we5nUi9h+IGgLgPch0P7qoak9zTraIdqThrL9mXq2Ezh/+H30UIlwVNa3fc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712087601; c=relaxed/simple; bh=mra41kMuk7qyT6e9ANIRzG0FF/EgvI0Upn/qCusbz8c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fMZ26EsMYCwQERYxoUXrjxK2TKrBLxq+BadMg6I7FGwabYS6T2MF9xqY1JweP6qKHOyj4EujSHh/S4T34F75R11QqN/jtouS1KzqRP3s3Hrg977eAWyZ4I5fUZgfWfMVUyY0nyTzd5AnHPUwqCF/8/xUpR0wtRH9Bt775fUD4ow= 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=T24ua1GC; arc=none smtp.client-ip=192.198.163.17 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="T24ua1GC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712087600; x=1743623600; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mra41kMuk7qyT6e9ANIRzG0FF/EgvI0Upn/qCusbz8c=; b=T24ua1GC9H2L/T+WS+XEl0uZMqTzGpsfszxnv+6kJdm29NnvI9uuO9C0 ppKnEtqDCYM7oo3s3B/ZWQux8x3Skrj21A4kIFJVrVCj4T5oiemfaAQMk 78wpqKV783q4gDRhWMd+e9znv8wdr+0Jw9j+Gyjni5aLO+hFKPqQmuGEY jymKvWVVZ8oGPnuzmcE9GjwNeS5V56eZfzUVGlLU5f7+1vyY04CGojxMR Dr8UCe3zx6XDMHN+Z68t7+JdWzBak/5e3pCMvac1XXHMKXiXUi9u9dhwl pe28ysbaT134HZaFLKqzBWuZ5itr4W/zXYSVaEmBZZGJiKM2MFz6deGf1 Q==; X-CSE-ConnectionGUID: 8H6AbVopRSS/x/Vi53UiIg== X-CSE-MsgGUID: 5l6uttkbQBGRBzDDpmf53A== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="7151026" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="7151026" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 12:53:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="937083791" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="937083791" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Apr 2024 12:53:13 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 163426F5; Tue, 2 Apr 2024 22:53:10 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Jiri Slaby , Hugo Villeneuve Subject: [PATCH v2 09/16] serial: max3100: Remove duplicating irq field Date: Tue, 2 Apr 2024 22:50:36 +0300 Message-ID: <20240402195306.269276-10-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240402195306.269276-1-andriy.shevchenko@linux.intel.com> References: <20240402195306.269276-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 bd3f281969e3..85899ef010e9 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 */ @@ -550,8 +548,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); @@ -563,6 +561,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__); @@ -585,10 +584,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; @@ -744,14 +743,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; @@ -815,7 +813,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); @@ -834,7 +832,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 2 19:50:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 785353 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 67F4F15E5B1; Tue, 2 Apr 2024 19:53:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712087603; cv=none; b=V6gwID2fPKvR/EaYlA31l5CSeuRWDefBQTp0LcPU1Ivw4uxrZfyq/m9AeHP2j+D+vn9gZX8z9GhjLoLYPhUlRVCih5bon2WCcTnq8TUTNqhJA9NDF0HjdmUwUHnQyO3Juampit+Yo0jdP0gMMG0rvEyTivooTi8Gk2TIl9hn93A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712087603; c=relaxed/simple; bh=SwTcUDBjZbj3VUyVgmN94kgSUzBs3VieG+KuXT7YGZg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UL4Jr2Hpvc/mx6Z2fxYOnremVX/IW457cmSDvmomKrL4pLYOqSADKBt6G76dMBYJDSb9FelE2pQPv6TqcKCkuqBvq5YDaYAKTrtc8XssWVLRZTrtAdjwHEQK/2Y7ezvPoOn9K8vW5dO1s5Omgh8i3u5MODFyLu7dEUIxAN/jjiw= 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=Yfk5EQ2Y; arc=none smtp.client-ip=192.198.163.17 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="Yfk5EQ2Y" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712087602; x=1743623602; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SwTcUDBjZbj3VUyVgmN94kgSUzBs3VieG+KuXT7YGZg=; b=Yfk5EQ2YT5iAC+eaMoPsqmiwxLL7EgRetHlqEIBwVu8NvzFTKAv2hXeP VMajvZe8hSnT4R/qzRhEw9Z0dCQocoZj2pG7VmZJWDFZbnF5pdjjBcFOB CxojfE3K7qhSiQsy6dB6SBO73KtOMX8SE9eJGJ9QO24XuS8nxQz08nSui nrOK0X6Ac18rzFjk8a5qg7qPwAo0DDdvokbuMG87bMuXs6VSJQxVzQdTw U/CQ8jXHHnPRZgvyO3l7cRO2U/JOpc3ZO4sPKN1uDveBd+XVVFCBBDphB rtTutn5dR07+36nUlcQa/h698JAf8RhnPsziAR4POFZiyN2BwCO51fuct w==; X-CSE-ConnectionGUID: NY6zp3b+TDCwM1wzKmhblQ== X-CSE-MsgGUID: HSYltHnJS965pAZvY8Xkkg== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="7151030" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="7151030" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 12:53:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="937083796" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="937083796" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Apr 2024 12:53:13 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 1B581C74; Tue, 2 Apr 2024 22:53:10 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Jiri Slaby , Hugo Villeneuve Subject: [PATCH v2 10/16] serial: max3100: Switch to use dev_err_probe() Date: Tue, 2 Apr 2024 22:50:37 +0300 Message-ID: <20240402195306.269276-11-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240402195306.269276-1-andriy.shevchenko@linux.intel.com> References: <20240402195306.269276-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 85899ef010e9..d287fb377523 100644 --- a/drivers/tty/serial/max3100.c +++ b/drivers/tty/serial/max3100.c @@ -718,9 +718,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; @@ -730,15 +729,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; } @@ -762,9 +758,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 2 19:50:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 785354 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 C871C15E210; Tue, 2 Apr 2024 19:53:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712087602; cv=none; b=V16Ic0gCcevljtM7Z6HoELImx21Wu5WP9mJ9cEjkoHJDENkotWova2fN/KD9TiYaRxU9YE8Z+cHc1tALYVbkVBDE49LSqGNrcZm3hEA7hW3m+fMwhqyB6Fqg9FPd4OYnBlwk+0nXz4vbu2Fwy5n1jmNW4oKC1vhAUeMfQwRoTGk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712087602; c=relaxed/simple; bh=FRoH8PTNS0jkAV8BXxBX4MyiYJGH6z8PP4TdQp9eq98=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n7cSaXHENfVAT76l+xHj7RL+M6mO0uVSYth4oLDtHhgwcrWaEzkkbOXkMKXIXHPhETXc2ItU/NwpgI6GPLXzTawAn1BysqpjMwCLYJWXt0U2TcQg5mBafsUEDaopXl06TNY25gGCfXhElCAdiunSkQR7aofMm3m/ZCEw5fqW37A= 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=AL625d/P; arc=none smtp.client-ip=192.198.163.17 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="AL625d/P" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712087601; x=1743623601; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FRoH8PTNS0jkAV8BXxBX4MyiYJGH6z8PP4TdQp9eq98=; b=AL625d/Puf00EMryrPJ90ec9I6THgBWyL8lbzLtnqejuflZxTrQccv5p sfazKW2U+TsrHEnDKXXZ5/D3OWEBDFFQfBjmEu/7Jo8DxL2gsgShgiHzs mtO4pbl32W7nKqd2SeGPova7JuSMiv9dQ0VQdmhf1Q0oz+yR/6XIm2nN7 ocixye9Nf7rOk6upauRVdTQB2UzqKu4vIp+g/kSdeLOaVmiacRsO8Rwpz xmPNTx8lHjqwpAexzydL5EA3jA7HdlcRylGy8pEsYxt+7bx8koJ7T7Er9 f+g21n3qq2zVOW+vH9gmVicBS0vQdehA1KNbalBDMYOMNEZ9G5ktnSlb6 A==; X-CSE-ConnectionGUID: rBCBXVpVSAGc/pGleVxvXQ== X-CSE-MsgGUID: cUO1b6gGTkOP01OA51vEeA== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="7151034" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="7151034" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 12:53:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="937083794" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="937083794" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Apr 2024 12:53:13 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 3192F1567; Tue, 2 Apr 2024 22:53:10 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Jiri Slaby , Hugo Villeneuve Subject: [PATCH v2 11/16] serial: max3100: Replace MODULE_ALIAS() with respective ID tables Date: Tue, 2 Apr 2024 22:50:38 +0300 Message-ID: <20240402195306.269276-12-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240402195306.269276-1-andriy.shevchenko@linux.intel.com> References: <20240402195306.269276-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 d287fb377523..7cbb8c096b47 100644 --- a/drivers/tty/serial/max3100.c +++ b/drivers/tty/serial/max3100.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -842,13 +843,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); @@ -856,4 +871,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 2 19:50:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 785352 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 4FF2F15E816; Tue, 2 Apr 2024 19:53:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712087605; cv=none; b=fx/K5f9vEzlt610bAILOQ4IpUPrlPCWaTR7RBIVgpKKZQZMI/ToEoax9BJz2BuNkie7efw7zU0skfToMSx0oT/kJnA3N6lVP/D7BruY/EOphgPuiT3UL2oH+5UK2GYF6BnxZl5VkEBAIylfCt/mdD3BckSQB3QTVCgA9IJkoifI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712087605; c=relaxed/simple; bh=b14aVJkpvb1M/whvnXz3j759fvoxBOvYl/RFmgCkmkU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FdtPHABalyuDSe6UGzyPlHARJcZUAaVXPYy9tNZSbjHKe6/7FnGqX6tIw+bv6Eu9zy4AhpsnAh6XYsjH5cEo/KEayqx0WIAQiBvj5B2ClviXRPNn3RBwLs0Wmu7BR7PgZ/bUw3CVaDkxjLmE0vjunRhl2ZfAFjo9n1vlQzWlJso= 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=d9NnickI; arc=none smtp.client-ip=192.198.163.17 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="d9NnickI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712087603; x=1743623603; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=b14aVJkpvb1M/whvnXz3j759fvoxBOvYl/RFmgCkmkU=; b=d9NnickIoRvIRDe4QeT0OdW1U3JsnaM53TO4cPdIpVxyN9E0cOw4qAOK Ms0J/R2r/aEA+772q7i8noEPcGpL+vWwizh2AaTqUl5NAXAMShE+fGWdN Ulvs8Mna/3sOPf9vSh0evNor8VP773ir8SlCL68ciNsTXvVeZIS2jKuod AWXqEycpstoCXC/gCECAlTyGpcyDZFd62m0O4oj8v108kEhJdfPxHb681 /mp237YavzJlyTk+KwSIqBNpncrvvfZ4wn7qDmN0n/uF6KyzEtcn3/flg +UUIGRm10u3VEdOj+ScAnF+6vP7sIWPA/pZfl1qltixZVmQSX/70Z5Lro A==; X-CSE-ConnectionGUID: qODqmkJoT4KJi1QkUXU4Bw== X-CSE-MsgGUID: Jf7H67+2QHeMXMfYQ6u1kg== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="7151018" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="7151018" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 12:53:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="937083793" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="937083793" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Apr 2024 12:53:13 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 378531506; Tue, 2 Apr 2024 22:53:10 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Jiri Slaby , Hugo Villeneuve Subject: [PATCH v2 12/16] serial: max3100: Switch to DEFINE_SIMPLE_DEV_PM_OPS() Date: Tue, 2 Apr 2024 22:50:39 +0300 Message-ID: <20240402195306.269276-13-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240402195306.269276-1-andriy.shevchenko@linux.intel.com> References: <20240402195306.269276-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 7cbb8c096b47..55f0421515a8 100644 --- a/drivers/tty/serial/max3100.c +++ b/drivers/tty/serial/max3100.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -799,8 +800,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); @@ -836,12 +835,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" }, @@ -859,7 +853,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 2 19:50:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 785738 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 91D7315E7F1; Tue, 2 Apr 2024 19:53:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712087605; cv=none; b=LLNRtl1RNcMoAk1UDqZlZYABdmo4wMingXzF/Zct9NigyyMm00Z5fV9ZIFinWaeskwVb0c3vuUAubJStILAxYsTcPM7sRtWH+2gUCals8LsA4Ms4DqwBoAHKebeh+/i6J+44ZQ0Dn1qED/Fb3vM8yYkU/gdRfKi24N++9LqPsjQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712087605; c=relaxed/simple; bh=UttHAm7kWJDBQbIbN+5DgAfqZ8GVuR4A1O6eAxQAjBk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LUOhuirbpHclcN98mAdQrvCYNNqJZuAVG93MQj8VfSV8DWwqZGfDg+b3Rnx94iNCwv6lMyxZkzwIJSGoZWKjLyaPdUukYYNbniZ3cGKW6Vfob9BpmPV15uh6B91Nsj6ZjBGP8IaoYZ+zf1yKRS83bNgI/VZ+VqoON9w2EThP7l4= 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=QO92byj2; arc=none smtp.client-ip=192.198.163.17 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="QO92byj2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712087603; x=1743623603; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UttHAm7kWJDBQbIbN+5DgAfqZ8GVuR4A1O6eAxQAjBk=; b=QO92byj2qgFkJfKJy3gPp1CibF3RdZQc1jjUUN0YjQXTJn1s6fmtal/X SSGb5P6u5w5QxmqxIOzFUbSq8/zHqANKxhTj4Z0MPXGbfDOhlGhmvFpbn gEDKnudfH71/XJqHGYnWw7ujp3dQdXOiHgjUAwvx1uk9H+Vf2K887pvkc 9y4dlIUxko/WQvAzG2H4j1K/IlDJRr218O9Yguq+3VIJg7XlGAEUf/tbX wkn5sDETGCKGi8DUhvtxZ/21Qnn8jZMyI+/LfWykbSICvbafovQJdIuQE adjvZ1MEUDtJ6AaBacYOq8EcWPeGajW3IGpbtdndnQWDjzCo12HO9QEFf w==; X-CSE-ConnectionGUID: HW/lzEAeS1S/AmWmqrpghA== X-CSE-MsgGUID: +q5wFLDoRCy/xOTmy/h5Kg== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="7151042" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="7151042" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 12:53:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="937083795" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="937083795" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Apr 2024 12:53:13 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 4336515BC; Tue, 2 Apr 2024 22:53:10 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Jiri Slaby , Hugo Villeneuve , Hugo Villeneuve Subject: [PATCH v2 13/16] serial: max3100: Extract to_max3100_port() helper macro Date: Tue, 2 Apr 2024 22:50:40 +0300 Message-ID: <20240402195306.269276-14-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240402195306.269276-1-andriy.shevchenko@linux.intel.com> References: <20240402195306.269276-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 55f0421515a8..b068175ef9c3 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__); } From patchwork Tue Apr 2 19:50:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 785355 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 4D09715DBB7; Tue, 2 Apr 2024 19:53:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712087600; cv=none; b=Q7LfTgSfuhgoZw+v7DKUgjRruQ0zV+6ZdAenBf93iswJgw7PsTvM+D/ROfXykJP6/DImwqvxZiEusFGaOoaDDU8XcnrlsGx6EL0qA1nrgjoXZH6+gHOCLDRSwi2f74te5jpTmLt8zvEtTOZonDA40Fhdh+YKpzobPbuSdxyYCjc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712087600; c=relaxed/simple; bh=7uF+Ni2y2wMkDzn7LDrpsM+dIWXMZVCj7KGProB4/7U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mfXpe6AGmAn6cdlYGvhK5IvHSUXaP6mOJP/lsOEAzWqMEOmm4EkR0rpl6Nqw49S+0dbZ5LTzKJGH3oRmt6gnuDF0uFEI/tUn+a2v7qoPZsb4Mfj9YucKCdCWVP1cqwCpTKDv7jwAK6w1FLAcaps7+jenPlc9yxg35sRURDq4Yo8= 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=a/10wS2Y; arc=none smtp.client-ip=192.198.163.17 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="a/10wS2Y" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712087599; x=1743623599; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7uF+Ni2y2wMkDzn7LDrpsM+dIWXMZVCj7KGProB4/7U=; b=a/10wS2Ysnn2QwnJzXKi7euUh9maBiUhRmfRmTynxG2gNOOB1lzrIet/ KBBpS0pwkhcOVP8FwZIpXBkwwDS/rJrTFdeRRhJSZXKJ01aPOXVBDyz1L aNzuI0Ji5Nqt/SpZzXSs81MfXinczpJO7dItPYooVY2xXP9Bo18lphT/n FTtziBoIrr1vRzo08Nj0/UyZ0XcrDJOWbiGOwn+sdxVS4vFwaYgI93HMa 6eH8K9pXS2hc0NZrTmRoN9S11nAfACGCvY8/2jjr3MJtcyTFFlMjUiC0+ g2L+99hlpPUJtaNBI8VCDIy+76HuPJJJ7t6UZDqdaP7FSXAE3L8BaXsp+ g==; X-CSE-ConnectionGUID: ZWslMqamT4iYaWrjBCnzgg== X-CSE-MsgGUID: /zNIbKQ4SIy6Fk52gcyUzA== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="7151013" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="7151013" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 12:53:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="937083792" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="937083792" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Apr 2024 12:53:13 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 5159C16A1; Tue, 2 Apr 2024 22:53:10 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Jiri Slaby , Hugo Villeneuve Subject: [PATCH v2 14/16] serial: max3100: Remove unneeded forward declaration Date: Tue, 2 Apr 2024 22:50:41 +0300 Message-ID: <20240402195306.269276-15-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240402195306.269276-1-andriy.shevchenko@linux.intel.com> References: <20240402195306.269276-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 There is no code using max3100_work() before the definition of it. Remove unneeded forward declaration. While at it, move max3100_dowork() and max3100_timeout() down in the code to be after actual max3100_work() implementation. Signed-off-by: Andy Shevchenko --- drivers/tty/serial/max3100.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c index b068175ef9c3..5a28df2564b2 100644 --- a/drivers/tty/serial/max3100.c +++ b/drivers/tty/serial/max3100.c @@ -150,22 +150,6 @@ static void max3100_calc_parity(struct max3100_port *s, u16 *c) *c |= max3100_do_parity(s, *c) << 8; } -static void max3100_work(struct work_struct *w); - -static void max3100_dowork(struct max3100_port *s) -{ - if (!s->force_end_work && !freezing(current) && !s->suspending) - queue_work(s->workqueue, &s->work); -} - -static void max3100_timeout(struct timer_list *t) -{ - struct max3100_port *s = from_timer(s, t, timer); - - max3100_dowork(s); - mod_timer(&s->timer, jiffies + uart_poll_timeout(&s->port)); -} - static int max3100_sr(struct max3100_port *s, u16 tx, u16 *rx) { struct spi_message message; @@ -313,6 +297,20 @@ static void max3100_work(struct work_struct *w) tty_flip_buffer_push(&s->port.state->port); } +static void max3100_dowork(struct max3100_port *s) +{ + if (!s->force_end_work && !freezing(current) && !s->suspending) + queue_work(s->workqueue, &s->work); +} + +static void max3100_timeout(struct timer_list *t) +{ + struct max3100_port *s = from_timer(s, t, timer); + + max3100_dowork(s); + mod_timer(&s->timer, jiffies + uart_poll_timeout(&s->port)); +} + static irqreturn_t max3100_irq(int irqno, void *dev_id) { struct max3100_port *s = dev_id; From patchwork Tue Apr 2 19:50:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 785737 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 28E4B15EFAE; Tue, 2 Apr 2024 19:53:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712087606; cv=none; b=fCmMOL5+jofotdfwc6+ZFrQ52t+pxgybObrs9RWRyXjBCF0/Eku6Y5mnWGWi0Uf5Y1NzdFSr31IgBFZ3EY/PJ95K44JMCaEOVbyi1rGaPQTWvA/+NK5FaK8tUDwEZiGK0Q1CaSR7il1mHX9KadI6Do4EHti1Gc+ajEu/JgLw4Js= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712087606; c=relaxed/simple; bh=NprQ14Gp15g2wulXjCok7Aa/pMesYfi0qsUoZ4gNAXQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qnCHqVlFW6WiIC6o6m7/dnzWSeAuNfPERaMoARZYl6XeUlRuj8OsQ4Vyo14bAvUSIOURvX31NTuyUE40YNWNH7nL0O7EPlVyqzEuJ8RJFIM5SgguY/T850lYlB///GQsoZZfJH6ooLhnb3zGPeKmJt3pOeNKnd+2J6o4b8ODgpQ= 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=RrNpkTe9; arc=none smtp.client-ip=192.198.163.17 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="RrNpkTe9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712087605; x=1743623605; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NprQ14Gp15g2wulXjCok7Aa/pMesYfi0qsUoZ4gNAXQ=; b=RrNpkTe9rPSIwr5Dm9naCovOaXLG7k5svdWeh5sCOlSS/JQL7zGRrGub tAowPx11kLm6FCLe/1i5goODEgnpfU3ccWlKohlSkqut4cniQFnp7l7Ht CpZLTigV1ywkge7Epb5DXFdZljB+RC5dJcd7Bgvx3frGYodnZgXN1yc2s 76VUNnzrXstY/PjOvDrRimExOnswBXQB5cbj2T+bW0byXRKBw06nOJa9S koRM86YtZUKwqJhARMl4Ixi2nIx0Ob+UzeKx8L9uMR27/HoSZOu/rb4ez 94hQSqMbv4eOeNPp44xU4bMtbQfDZVTLW4KbKJGQ5Kq6ukopYhbZwRWtc Q==; X-CSE-ConnectionGUID: Q2Rw5ScASzWmHMTDhkZyiw== X-CSE-MsgGUID: Lty19qGlRtSMZvpuL4mEhg== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="7151049" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="7151049" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 12:53:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="937083798" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="937083798" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Apr 2024 12:53:15 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 5FD0316E8; Tue, 2 Apr 2024 22:53:10 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Jiri Slaby , Hugo Villeneuve Subject: [PATCH v2 15/16] serial: max3100: Sort headers Date: Tue, 2 Apr 2024 22:50:42 +0300 Message-ID: <20240402195306.269276-16-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240402195306.269276-1-andriy.shevchenko@linux.intel.com> References: <20240402195306.269276-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 5a28df2564b2..004c0a9a6d61 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 From patchwork Tue Apr 2 19:50:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 785351 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 8072915ECF0; Tue, 2 Apr 2024 19:53:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712087606; cv=none; b=RcfDSnTmkP7LL2COXRjvc/KwMEbAUxsXTElTRGVSl0O2PY518BcrS+n84pKO16KMGpZOWyoGftrVk4sKKbvbB9YZJa7z5iKQ0Oug6fKRyE73tb6UncL2p2i9Kt4Wm6/Ah4qCQXo5SOsMFfyxPO4SJM1eCjYXpawO2T6JTuHrRhU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712087606; c=relaxed/simple; bh=Pzd4zF55D0Q5tN3ZT/f+vvK1+li7w9jn5Gn98hnh/Tk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aD2SP7AdmQ9GLlA/aUVbVNZYFkO/Jv10PfjeqP8mdXvYcjn9YstqWC5wNcKzrVtaPIezrgKgb1HQ+2QKwVx/Ca56+W9GpoRh/NofQ/KE76CAJUR4DSh692xxwbyAHbAloWGszMY/t5X9eq8YWG3+ycMOdvWLmP5z1eH3iMt2va4= 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=dkGRiSv7; arc=none smtp.client-ip=192.198.163.17 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="dkGRiSv7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712087605; x=1743623605; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Pzd4zF55D0Q5tN3ZT/f+vvK1+li7w9jn5Gn98hnh/Tk=; b=dkGRiSv7oQID/W21fQbfH/kvluZ7jugMH8rqK2Z9/z2OsxxfRzXdq8zs hNqMqRHjZr1fKlC3qubMZ21ag09Hf1ryz8SMIoR/Fi6KWGui7HVrcLiff XlMR5ESPt8XfdQ/cCGL/DfgmeW0aqot5GFfrUb+olwLlfijY1D1hEJA34 LR5dTAq3JbXcNK2ISnCAj3IGciDQb/8C5wYE6dthRaxxiB5c7J/7HrZmC sndNo0/6IZBl9sAmZ5f9OdAtZL49XuKb5TQvqzDbCqSylFp0S5+7Ar1yJ bzF+kzG7NV6vItaan2wpXAq92YfT6jsyVdVH3SK1r+BXez18DK5+TPRl0 Q==; X-CSE-ConnectionGUID: oGWDkvn8SuW1I3eAhr+9pA== X-CSE-MsgGUID: BdTq/U9fSRSAXDRyWd3HqQ== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="7151044" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="7151044" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 12:53:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="937083797" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="937083797" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Apr 2024 12:53:15 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 64E9016A6; Tue, 2 Apr 2024 22:53:10 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Jiri Slaby , Hugo Villeneuve Subject: [PATCH v2 16/16] serial: max3100: Update Kconfig entry Date: Tue, 2 Apr 2024 22:50:43 +0300 Message-ID: <20240402195306.269276-17-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240402195306.269276-1-andriy.shevchenko@linux.intel.com> References: <20240402195306.269276-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 driver actually supports more than one chip. Update Kconfig entry to list the supported chips. Signed-off-by: Andy Shevchenko --- drivers/tty/serial/Kconfig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index e636a51eb7b6..dcb67c40bf92 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -307,11 +307,14 @@ config SERIAL_TEGRA_TCU_CONSOLE If unsure, say Y. config SERIAL_MAX3100 - tristate "MAX3100 support" + tristate "MAX3100/3110/3111/3222 support" depends on SPI select SERIAL_CORE help - MAX3100 chip support + This selects support for an advanced UART from Maxim. + Supported ICs are MAX3100, MAX3110, MAX3111, MAX3222. + + Say Y here if you want to support these ICs. config SERIAL_MAX310X tristate "MAX310X support"