From patchwork Tue Apr 2 15:38:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 785370 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (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 17CAB1332B8; Tue, 2 Apr 2024 15:42:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072548; cv=none; b=tqBcOYmpD6UAxyhqQw5GeTvgnhqXKwgEOWbBXuJlB1Z4jGSuQoPfTWmzGkWcel5KZk77EdKlLDLijY25U73iL1JHrBWRaeYj+j/bazLWWsmqpf29GxF848bflNRY0sunzGMIth8IzeYYTcS2GjgZj3vOOUhrFvR/64nv1mUHL/Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072548; c=relaxed/simple; bh=iiqZkjQzkOKvdMO7xpjs8WUDJFSjOVUqV0uwKR1JZaU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uCflpYMSyTB6uOgTu9aIgA4n0uUbZKrjjYYVNfdTbXyXCMPKLAcFiePFq8M0/lzt34saXMHICn+ovv4zq1br82EXp8q1eyeNTw+3waDfQkx5LGkMs/Ga0yjyDGGeePyNkb7MdzYr7Lv0VwQ4+RrDrh3r/VCxIJ6TQ/ynHuEd4S0= 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=PKdtPB2s; arc=none smtp.client-ip=192.198.163.11 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="PKdtPB2s" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712072547; x=1743608547; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iiqZkjQzkOKvdMO7xpjs8WUDJFSjOVUqV0uwKR1JZaU=; b=PKdtPB2snKA7rhJw/MLRRPiuxcU4e+iUH0xjPBS6X6H5BzY5MICew+iX ftYafeQJhfSRdZXLIDPDKHTfn2ZPeLBYJA7opj/TAhFIU7T22dPrIgFUb m6zRPgaVRbM1XtEZwLfCaIcODFzDw/938JgjXVhv9gnI3r7vabJOQRMCp YkHS7FUHRv6EgPGYqM36oaG6HJyt3Rh4ZiqwfHw/Ujc2becsaErmK0m6C ahtJk+h1kspTX3s7dAXNVW4D8v7xRrZRusoo2fXlrL2jgYh7Ad2vInHRj gNpEblR6PMogrn5zkhrFcAGWJ5vhw/32Jk91lUlDJ4u/+Hvc6WTkKP0xN g==; X-CSE-ConnectionGUID: CnCeqm47RNuRcEUm4YoUaw== X-CSE-MsgGUID: CwFwFDwQTLOFNqt0/e0TzQ== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="17870057" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="17870057" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 08:42:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="937083638" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="937083638" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Apr 2024 08:42:21 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 2AFE1133; Tue, 2 Apr 2024 18:42:20 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Jiri Slaby Subject: [PATCH v1 01/16] serial: max3100: Lock port->lock when calling uart_handle_cts_change() Date: Tue, 2 Apr 2024 18:38:07 +0300 Message-ID: <20240402154219.3583679-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240402154219.3583679-1-andriy.shevchenko@linux.intel.com> References: <20240402154219.3583679-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 lcok maybe not 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 15:38:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 785757 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (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 8F00C132C39; Tue, 2 Apr 2024 15:42:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072548; cv=none; b=WfAqcP8osRyOZPaR+UacYwkXBwB6fJxooLzj8Sx9B5LdxWOQ40KJMtYkwrYnXbo9qgAEeEkFK+bSnNqd9iKZkoRV3B99vV2+frvjYniI3KltNIZPiAd3iNabHT0DcdQrmhLOGAKPCKlKiMGtUEbtd9v0W9fx/KVayaZJ26ukyRI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072548; c=relaxed/simple; bh=o78Fa752/ZOPs6iLperlSbDq86UPzIkFataSRBoiH5o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZjRj0BqSLS3ibp7ePEWLhmUNgNlQUCR8E51n7RtdMqPw/r5/32JZDAZDrAiQxIMfl4LbYlwdyFT9lYI7AO7WyloRDvt86VOjIFiVtMbPnW9mYHzb95AdnhTPusPFbGty2uJ4Ja9zZ4upGyyr8C5vzeGcSFIConENiJMeZO/shRs= 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=JhRRKeZg; arc=none smtp.client-ip=192.198.163.11 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="JhRRKeZg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712072546; x=1743608546; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=o78Fa752/ZOPs6iLperlSbDq86UPzIkFataSRBoiH5o=; b=JhRRKeZgk4TdfSlc/i8PRARSiAPC7EdrZF4A98iOdkLp7nedM49aAicx 8BcCXCVQE0+DubNWlAldgI58xpIxFaBUSDLsbhUWw/NcabvPDd0f4/q+r +uGYI65LqCrrspLa5uf7aT8yDUqqdoAUqCk4JfXn2lZ2LVHoiEHERzVHK upVhcrn5sDpHekJMOsWF8qVslZ2NBZw4VNwVeglDxRWOKWR1+SEOdZ7R6 2HxtXuy/UUV7hZlF9QqLHmDFvrbsNBJxIWVhXVL9FVmA9XvkQ2JMPIvnq VrixDaXGlDMU66mM1R6boHMJs8rwjFY1RwB5+xqHnptK0kaR3AZqOM4gQ A==; X-CSE-ConnectionGUID: PV/v7GXrQkS+8xUl3pUVMg== X-CSE-MsgGUID: cprVtvEMTNC684Nd5tUTtA== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="17870055" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="17870055" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 08:42:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="937083636" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="937083636" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Apr 2024 08:42:21 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 3506D506; Tue, 2 Apr 2024 18:42:20 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Jiri Slaby Subject: [PATCH v1 02/16] serial: max3100: Update uart_driver_registered on driver removal Date: Tue, 2 Apr 2024 18:38:08 +0300 Message-ID: <20240402154219.3583679-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240402154219.3583679-1-andriy.shevchenko@linux.intel.com> References: <20240402154219.3583679-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. Fixes: 7831d56b0a35 ("tty: MAX3100") Signed-off-by: Andy Shevchenko --- drivers/tty/serial/max3100.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c index 45022f2909f0..efe26f6d5ebf 100644 --- a/drivers/tty/serial/max3100.c +++ b/drivers/tty/serial/max3100.c @@ -841,6 +841,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 15:38:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 785758 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (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 5EDD584FCD; Tue, 2 Apr 2024 15:42:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072545; cv=none; b=OAbBVgl+SaRfsWGuNZmNMgDZGZ3h5dGWt+W+HMum1u/QjIER6Neu4cAceyoavD6eh9ZSrQTwSkbCzIZB3kec94wVF3wMPWEkuavfMrVu5qYA0IZlmqsxsaedXpQ8IN6gPtDXuu5j1srwDMr/vqXQjcmxjBoK1cW6uW80OS2uO9U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072545; c=relaxed/simple; bh=3qKFLfNKckxhtzTrYwg8CiyP780i0A8n/fZ4lxrWml4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E2L2MG5T70DiLp2MgS3bNepYaJif+qOABy8TpZaNk4KfFSdKKzevXFvdADKPpgAVeiARGgsW5xrYZm+1Cx9E1vlq1QEVYMQV+ZXnxwniEGYDoP5MufywgdBorTSdA5KtyvESUMD8WANc6uOO4YKDn0GopMq31AJvFhi33oy7NUY= 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=T9Xpanjj; arc=none smtp.client-ip=192.198.163.11 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="T9Xpanjj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712072543; x=1743608543; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3qKFLfNKckxhtzTrYwg8CiyP780i0A8n/fZ4lxrWml4=; b=T9XpanjjKU5XHedST3pGoTz/xHuWoH98IyhrTNjY+XEZA4kH9fWRbu+g Md+uLA7Tftc37cDlvdyH6M5cRe/k+RHIG2TGumws+V91MYdDkJpZmXnJw MNKP0tXWTOF/68WPgjBWApf62JWNg1huoCprMsLiGVKpd1ScGPEikwybc 1VQMJN9hq+GHe9in+wMDzxzVlk9LGeqlSTpcErvrvmI7bIlklKK1hmLbt Hgie6eWUGV0Bz2yp4Gt5rseSgumnsYvBEO/Kw9O0mMlWBnm0PHR/0ybiF 8bStW7tCzNWXApoHPgOpA0dRTVXG5omv9UqMpJ3NXQRsmBvg/Sr/eCciT A==; X-CSE-ConnectionGUID: 0TQIAYzaS9Guf6r60b1nZw== X-CSE-MsgGUID: VCFQkQNuS5qoeZga4L2L+A== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="17870048" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="17870048" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 08:42:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="937083635" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="937083635" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Apr 2024 08:42:21 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 3E38328A; Tue, 2 Apr 2024 18:42:20 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Jiri Slaby Subject: [PATCH v1 03/16] serial: max3100: Fix bitwise types Date: Tue, 2 Apr 2024 18:38:09 +0300 Message-ID: <20240402154219.3583679-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240402154219.3583679-1-andriy.shevchenko@linux.intel.com> References: <20240402154219.3583679-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 efe26f6d5ebf..3c68b8e1a226 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 15:38:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 785756 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (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 A2C0B13342C; Tue, 2 Apr 2024 15:42:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072549; cv=none; b=ATQQuVJaZLKC1es2MsX/sIVKUD3pR+0NvZW9c5GFhVnsnZaRb2ckx9PqDa0lFDpxg0SAkyVVMGH/pt71WF+RlQw1FCvp2UxHBG7lNKzJqhVhpXK1w65aYp8z6tfbkXPi3JVIjHMYkUC+uw4MQCnOjcJ6sxsu7tmHLGr3E9imCHE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072549; c=relaxed/simple; bh=zZMOnIzQZrnHgzBuQ7c9CjMUprZPaXtN+6HEIt6BE4I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EuYf1RuqVnoC9g8J9Oikh57tAzYhqDfbJskHZbCO8T2pqMlPlkbVzhD4ZPxNtXPd+1GGkBNV+JtujVBKlbXiXraOUNfbetHHj0bff4MbDENSrYKKpSGgu/MhXub+UanDznttuQN9zwaFdbOjeFZZY5WU2YaNtEcryAuM3tm9/yM= 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=E8dGIuV/; arc=none smtp.client-ip=192.198.163.11 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="E8dGIuV/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712072547; x=1743608547; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zZMOnIzQZrnHgzBuQ7c9CjMUprZPaXtN+6HEIt6BE4I=; b=E8dGIuV/9jofqMGmcRo3NGIWzb84QvbcjUo+Y2REbupUQMqC+4kW3232 jC8qgalj5oBJ5LxV2Y0rHnW1BVLrthixXXVEtt/UftvMwvVUqqy0BEIjA j8ijLoDvH00ltKifqCvr1QyBJye9YVPM+2Ob8RfktwUh5hvIwEP+FgBE2 G/f2w+WtjEGwPUtcGFXsiSw1gXhqgyrXnXgRTFrjr2XalGxawP0wryfNo kKepPDYMga9w1jC2jDj/3pGdAPdWX3WQm3l53vCsznUZQti2nPBOwJ0cd VC8SbPd7SmYwUOM8ztn+ZNeVAYSq5+Xwvh/mQj7eFjSlvNruvbzOpX8ah w==; X-CSE-ConnectionGUID: gbSlrTjuSjqRmi5ar21O/A== X-CSE-MsgGUID: vpcGwvtYRCW+krWR5TrSJA== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="17870061" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="17870061" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 08:42:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="937083639" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="937083639" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Apr 2024 08:42:21 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 5600357D; Tue, 2 Apr 2024 18:42:20 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Jiri Slaby Subject: [PATCH v1 04/16] serial: max3100: Make struct plat_max3100 local Date: Tue, 2 Apr 2024 18:38:10 +0300 Message-ID: <20240402154219.3583679-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240402154219.3583679-1-andriy.shevchenko@linux.intel.com> References: <20240402154219.3583679-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 3c68b8e1a226..f30050248130 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 15:38:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 785365 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (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 97E061369A8; Tue, 2 Apr 2024 15:42:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072555; cv=none; b=mJXFmcjpMMXwwrILUIDYslrP/8txWW+GF6vcASXMQIjOLaa1pFYsu5CZQgwK8IpFgt+ITd++rr4sypGDQB8dRlCda/Y8yTb4rJryrwXORkv6JQyDGFVMjpukgOHvZtho8K9yj4dK3g6T1EtlO7kzv+YW9LVaGE8SXAhxYrampJU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072555; c=relaxed/simple; bh=vGrq3AnF8SD13aIPLv3DIPaAzu1EFpaug7iIxyUVZEI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RXL6UlHXbQH8qLuDYRRuVP9iZ3jem7xvpdEZdVWW/hpTPG864t6CKLdMwKNuYnFzqlgpC/PBD3S4uHKzpbrzUTD7GcherTRWR3visQxFiMUZFCmbqV/h3Swh3gmHy1v/aU4yCZ4qH+HY5PnI2Pi1KQP0iYgRX5VOlRIU5jCJyho= 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=MkGJC1eU; arc=none smtp.client-ip=192.198.163.11 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="MkGJC1eU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712072553; x=1743608553; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vGrq3AnF8SD13aIPLv3DIPaAzu1EFpaug7iIxyUVZEI=; b=MkGJC1eUNif1IoA9+UHxEu8YOv97v0aY8yarQT9IyR7yxzZtFT1baXJR 5XdBwCp1coJ6WOfRDxdz5Fxr7EmRh9TxmTgb1a7jPTQNN/bej9yvVQ1HY /unlPfH79ztY472r42Sqbp5uNqO279uJzGHxbgV4odUIf14Ul0Q6lstTW OP1p4q0kMsfnYUeWatQhEzVDf8c5SD7hEfbAfc6WAL2UteuvwjlWVIAy9 Rw22Vc4h/hC7zUG5OUb+fHcyI007dUybTiuoTSPfdRWU57ut/EMJp1ZeQ PCm/LJdFv83w8N1xRBinSHMBYPIj3XBI/F9zOluAZSwJ4EVXbcWfz+GoL Q==; X-CSE-ConnectionGUID: ecPjsbkoQSaoXi9THRjJnw== X-CSE-MsgGUID: qarwQKVWQt+Fp8Dc1zchvQ== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="17870094" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="17870094" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 08:42:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="937083645" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="937083645" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Apr 2024 08:42:23 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 64A6C6CB; Tue, 2 Apr 2024 18:42:20 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Jiri Slaby Subject: [PATCH v1 05/16] serial: max3100: Remove custom HW shutdown support Date: Tue, 2 Apr 2024 18:38:11 +0300 Message-ID: <20240402154219.3583679-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240402154219.3583679-1-andriy.shevchenko@linux.intel.com> References: <20240402154219.3583679-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 f30050248130..0931d7be9c62 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); @@ -785,7 +771,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); @@ -805,12 +790,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; } @@ -852,6 +832,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__); @@ -860,15 +841,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; } @@ -878,8 +852,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 15:38:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 785369 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (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 5BF01134403; Tue, 2 Apr 2024 15:42:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072549; cv=none; b=ahc0AehTt7ahvJYu3BUdM2R9q6ZT4ze64JunxKTpJ0svkssL80FCTWJ0Z9X/lQhO6tqeGcqNbOlUiPtxUNwamfqNlDbounwx7pko9Sww9lhY0XWamfnCfs1q1qBzzwn9CtEhGiXD53ow2Na/+SLM37lP/oU0EFLW8pXP9uxUVvU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072549; c=relaxed/simple; bh=y43cM1loEB/xdiC5XlfYWF8K/xbUbOlgMRJmmCex1Yc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eop3Pb4yBAEfuFMMvsap4NrF5MtR2U9alYIx0Fy6vJ363itpbhEEp1rZzfAPbSow7avZmuGBql0RhpS+du1TrZ/HL5e680BqLSS/3s8+Nzz4+X/R2PX9Rqk7+zd8MjY6qssGWh+VOBylxkSTJO0j+jtGCyfPd2YZIOVCe+lo7Bg= 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=WiJg5Kp8; arc=none smtp.client-ip=192.198.163.11 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="WiJg5Kp8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712072548; x=1743608548; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=y43cM1loEB/xdiC5XlfYWF8K/xbUbOlgMRJmmCex1Yc=; b=WiJg5Kp8+pMN4zwvQ6iQqzQjYtDq4SNlG02RGUCLdzpbKNCkEf9NTRZY xJ6Fqx1upEsCdgk2ShTq6l0Kaqu2oFwluZauJU5ZBffhzKqffAmjaom9J dzpC8lp5bgsjmyHBtheA1ojXlbwoihiiZE4Dkdw5C51sTKMrf1Hzos5fH DxD0dCXzz8nXj03ydSeY3NwP94wp5i2njok+0XUktNvh7mIwwwfgl6grN WSWAAprIGL/ZnAAI0TtTMpiFtb8MABsYxSaqK0oasdOHsL6hIvdcgZ3RV su6opBvXyscbu9rp811KALTeBLMueI84qUanJDM/l3mWrZ0PDnIp4xIu1 A==; X-CSE-ConnectionGUID: 6mPP2k/7TyeP3TEZnTcXjA== X-CSE-MsgGUID: 4LrL9gv6QTuNZCCojaH1Xg== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="17870065" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="17870065" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 08:42:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="937083640" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="937083640" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Apr 2024 08:42:23 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 6FECB6F5; Tue, 2 Apr 2024 18:42:20 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Jiri Slaby Subject: [PATCH v1 06/16] serial: max3100: Replace custom polling timeout with standard one Date: Tue, 2 Apr 2024 18:38:12 +0300 Message-ID: <20240402154219.3583679-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240402154219.3583679-1-andriy.shevchenko@linux.intel.com> References: <20240402154219.3583679-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 0931d7be9c62..d4f0ea97a698 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); @@ -768,9 +756,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 15:38:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 785755 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (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 C1030134421; Tue, 2 Apr 2024 15:42:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072550; cv=none; b=TLyTZAGzsG99nwX7EPX9LuRdF8bGfbJ7iknjve9i4rBLZAF354eZ0k1K6mK79YnMgOY3P8NLEG/wKzYvK5XYGcoNizlsTgmc613FXNW4IBHQHaIb5jwqrcaMB73pRT/6RxYoLabmb8jrkPKZ7MNWNkSHw7CdH4MLELjHmxO/t9s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072550; c=relaxed/simple; bh=yfyKGhwMZ96ANs3HOcPXcTSdNrv8h/x14jOKdaWhcCc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d1r8KEQ+ZFWRYKzEOwCCqbPnjYvRx2kB+lVC4xWa7TvrKP5GrSqIA1RO9zb+Iat1b07JlZrprbrRB895/iazcvzvMEHzoMFkgxrpjeLcasU/TeWLckgV+Wd3Ou08bclI8M2xJIUzdGi3bn5M1n+/n78vkcfXDBxM9n8kJkQS3DQ= 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=FaRUjAAq; arc=none smtp.client-ip=192.198.163.11 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="FaRUjAAq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712072548; x=1743608548; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yfyKGhwMZ96ANs3HOcPXcTSdNrv8h/x14jOKdaWhcCc=; b=FaRUjAAqRUspSLfrBbjeP8wGzW5ejvPQzorGc5C2Hx3patRJ/QxbzsOm ZTWMRkLw9PBieu0GaMTkkgtwUKbTSL+h5/XExTBCsHdj+ws20yk/MjVfZ Bxi4sPTlK3Cg3p4m/nHsC2pn4rt4Mk/5r12yXkouo/vyw5g3pVSmatvca idVXs9spAls6nk7drzHXXqtynhbwliV9A5YAHFQNEbitdRN58lvcG3ghK hY31fI3WNfE6P7RvOcMbeR3RfJ8eVmkMHerijchWyLG0l1XO526SRlIxI ig7dDO5UeH4SswUHxJ3yPceYD/Qkg67YTMHwzbQJYK/jESDrz3WzzjRE0 w==; X-CSE-ConnectionGUID: u/GvBhXyQq2xxoOb30mnMw== X-CSE-MsgGUID: DjtjuN+nQFeRCE2pUtQHiA== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="17870070" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="17870070" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 08:42:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="937083641" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="937083641" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Apr 2024 08:42:23 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7A6E5525; Tue, 2 Apr 2024 18:42:20 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Jiri Slaby Subject: [PATCH v1 07/16] serial: max3100: Enable TIOCM_LOOP Date: Tue, 2 Apr 2024 18:38:13 +0300 Message-ID: <20240402154219.3583679-8-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240402154219.3583679-1-andriy.shevchenko@linux.intel.com> References: <20240402154219.3583679-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 d4f0ea97a698..dd98f8037b60 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 */ @@ -755,7 +758,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 15:38:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 785752 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (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 1BF6C135406; Tue, 2 Apr 2024 15:42:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072554; cv=none; b=T210B8ki3nklntNG6ZL9CvNaWDiUVj20W9Ck8Zkis1wOa7i0/OHxOX75CvoG4hpE3/hj9FLvhoM/lQXPWCKAqdiQ14n6kPTDeIg21muxUNf3sULQLYHRG1QjpF2HHGxcX2YxYtMVgEzgpeb6kh7hvPbb63o6jRkX3I6C4Nn2Fww= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072554; c=relaxed/simple; bh=jSxcGvPq4d8XaI19VUL8FP1V3nzthfNF3EeNJoxxUqQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qx+dcFgUfKInK9W+PbQ70T9lsCExgWp3tmOlhAbZemV7EgYOyAuUOnWack1+6QdVZSnfeU0tTwnenxlk/rDVvTiSnC1dNb0HJPPjLa963WVMkGdKVhrvy/s/Xssun83/JDL9g4meiDo5bnL0b9wxZPOq9hQYk98aJtHBNFcYeNk= 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=Yss7eEDS; arc=none smtp.client-ip=192.198.163.11 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="Yss7eEDS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712072551; x=1743608551; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jSxcGvPq4d8XaI19VUL8FP1V3nzthfNF3EeNJoxxUqQ=; b=Yss7eEDSuGXxnJ51C2l3YI3SbJa91XaF6U8Cxd+YX8K9MP4cscXLOGUt uM8/0aj+lYOAhNxaZSkMAOU0X71v23fYDYb1zQxaXSYNsaRnzl8ikTHZo zG24uu9KlJAkqleRWQf+eFTGNJ/S9chxOZB6BCXddLhTFvjRotLa/w0ym tecscNvPC1u4fgIs/MEjNuttBeY/u5zmVNbJntRNZ2SCGMZQYF4Dj1IPT IOsji24iS3RYstxdaqLiQ/etzwF7b7oc0VklMYXfp7/SIhkC5vGxFu9ZL 6BIdweqeCe7AVY5LsGbeu9AK4b9wt5EQS2/SIKnKU2+rKxandvc35dVZr g==; X-CSE-ConnectionGUID: lRzAHgKRQmuo3t2CecB39w== X-CSE-MsgGUID: n85bZMTzRTiqgDesNhIKJQ== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="17870079" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="17870079" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 08:42:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="937083642" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="937083642" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Apr 2024 08:42:23 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 8B9D39B0; Tue, 2 Apr 2024 18:42:20 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Jiri Slaby Subject: [PATCH v1 08/16] serial: max3100: Get crystal frequency via device property Date: Tue, 2 Apr 2024 18:38:14 +0300 Message-ID: <20240402154219.3583679-9-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240402154219.3583679-1-andriy.shevchenko@linux.intel.com> References: <20240402154219.3583679-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 dd98f8037b60..e5a1a9171047 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); @@ -756,20 +746,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 15:38:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 785754 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (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 0CBB7131751; Tue, 2 Apr 2024 15:42:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072551; cv=none; b=BlxG7RyMBMqafxi/CkHXxMZQWmzWNMn1FgELfDXEy+rrOoSlt4sGgsBs356PaeZi87QHzL82fgJPTPMsN/uGcwCI5kVXk9eE8XiOFLv9b5qrhE9zEUFq5MqaZk/sQBxyNzl+mJqMYtR/ksq5KdiHjWlF6gbfduXz2kwR+GEGAdo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072551; c=relaxed/simple; bh=gZ3z+6SQpyMoP20wO/5WkHibYBkOqQM1QKvat7X5mw8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YMP3kMj7GCvkt1FhcwCBgquTZRd23LSA8tebMUfP71zsvYbn6qfjPb62OysmCrgcKq9i0QcanhaFuWFEj/cT5+7G907Vx08nSXOdsCX1M113YmoJ2IjP3bcLYPeYi0jIqsU9xrqbmuvtJJ1aGUQOhaIYN46XGyJcxAtl55GStp0= 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=UeRUa8P4; arc=none smtp.client-ip=192.198.163.11 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="UeRUa8P4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712072550; x=1743608550; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gZ3z+6SQpyMoP20wO/5WkHibYBkOqQM1QKvat7X5mw8=; b=UeRUa8P4UkEpvQY7odQfZfeujORDmEyOaZ2C3YxBmobeoq4pEwyuoLvM iD9vGYG5YwFm5o0/sAHT7NGUzGXIEXI7DDTkdhIVnc/ytbGd5J5GpjFmN euX7mWtQdTMMBrJ6BTY1N4s+OFTO5r3jPckr/tP3oh2HoU3Ni0YgKUqc6 b6huvMPqU28FGHaAUh6JamaWSuy1lYLelbtqj19TkVUUGI1ir250pICpw S8FRGl8vLJ9/nNqYLQ83VTpOisceiQa+74ZEURaa9wMSlKxcEvPieZ7fn 2h+oHpHdrT0zE5fmSZoFF1XG2YDhGLph1XaAZuKrnN+cQdgn3kBuTAHIW g==; X-CSE-ConnectionGUID: qSzzTXDuQ7iDEYwjUv3n0A== X-CSE-MsgGUID: nRQOhCvLSOG6LQjpP171EA== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="17870076" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="17870076" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 08:42:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="937083643" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="937083643" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Apr 2024 08:42:23 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 97A93C74; Tue, 2 Apr 2024 18:42:20 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Jiri Slaby Subject: [PATCH v1 09/16] serial: max3100: Remove duplicating irq field Date: Tue, 2 Apr 2024 18:38:15 +0300 Message-ID: <20240402154219.3583679-10-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240402154219.3583679-1-andriy.shevchenko@linux.intel.com> References: <20240402154219.3583679-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 e5a1a9171047..e7963382bbb6 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; @@ -743,14 +742,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; @@ -814,7 +812,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); @@ -833,7 +831,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 15:38:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 785368 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (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 6820D134730; Tue, 2 Apr 2024 15:42:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072550; cv=none; b=bMm7MpWU1HLeH/iLk1yelBtc6d0Ok7YhE2SV7T3fbIBi7Eyn6wAfn+UpZOBhlx8sfpN4HCFzSrzau8ddbZDnKnWgrn0Ps8ZinubrJA8kFzpsZEWP5TGlXOQMykrWT3EwSsPet3nTdC9uZS86yAveN9MmKDDPIMD5AeZpzXEF9Js= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072550; c=relaxed/simple; bh=LcqZFh6/V3ILmvm1KWfU5KvKxMmRC9e8E1vyzCpbkO0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hXD/uN09h88CWjJ0Cx+fT9azkKlieOZ857d3T4+7JD6RCdwnfo5pdm7upSJJWaTBBkmFWzpXNJCFJE7L6rOK2uAd7aZLEWdv+mU9tJ4UP+jmzFl5QpldZejc8CdR57oe9pjf4rbvEKbt3X1N/P17aA16TJc9ofHeLni9FMzVpiI= 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=IlDQGPkT; arc=none smtp.client-ip=192.198.163.11 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="IlDQGPkT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712072549; x=1743608549; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LcqZFh6/V3ILmvm1KWfU5KvKxMmRC9e8E1vyzCpbkO0=; b=IlDQGPkTnFbN7FS3YRRXNOGsjVhdUVACNa7R9UAVeoTWeFQh0yTx5vN5 f5+ej/h3uIvzMEHUEeD2Le8tt93mjkd7s7IeWoHdtZf5w1WoDDKg43L39 R8f06Vuz3pqZKCQ9CXTWlenOcxOpMJu7iKReMv270VcKb+yCvKGQCwQ6I OXj1OnhIicAVBGWqCwfjH7o49ZjzHCoDpWpgjqDeFfAixL+gl0A35aLm2 JTS/SSDIkowtxzUVYYi+Db1p77BcvBpStWsJABVeez9yamYeWSxS1ZV3N qiFlu/Bg9Zf3VcbLifo8d0aJPJI6pd3EJL5FaS9T4TLAaybvP/OmrhuC4 w==; X-CSE-ConnectionGUID: 2TuxaaalQnek3TFHY3LrrA== X-CSE-MsgGUID: pjcKM7UrSoudoVEyiC0k2A== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="17870072" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="17870072" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 08:42:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="937083644" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="937083644" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Apr 2024 08:42:23 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id A367B1506; Tue, 2 Apr 2024 18:42:20 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Jiri Slaby Subject: [PATCH v1 10/16] serial: max3100: Switch to use dev_err_probe() Date: Tue, 2 Apr 2024 18:38:16 +0300 Message-ID: <20240402154219.3583679-11-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240402154219.3583679-1-andriy.shevchenko@linux.intel.com> References: <20240402154219.3583679-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 e7963382bbb6..c4e4dc5f0858 100644 --- a/drivers/tty/serial/max3100.c +++ b/drivers/tty/serial/max3100.c @@ -719,9 +719,8 @@ static int max3100_probe(struct spi_device *spi) 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; + return dev_err_probe(dev, retval, "Couldn't register max3100 uart driver\n"); } } @@ -729,15 +728,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; } @@ -761,9 +757,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 15:38:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 785751 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (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 29195137770; Tue, 2 Apr 2024 15:42:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072555; cv=none; b=rdg5k3erQ6Py559tGd6Rh+wUyX2Vd0QhGmy5h+YxGfPDNtNOCdMd66NVd7t8/alH8bnOpEsXw3e3cpTCXho9pamhc3kK3Y0IOMSOg0eP4ngbpFdNRkKgzb5mIntOD5QMFN1UznleH2KGGPDmxr8PePJuKtZ4BbZMI/ULKuRB1S8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072555; c=relaxed/simple; bh=OVHNlIP+AOoymkMOBF5BGMRhdK9G0XAGm3jDVh5hzgs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V0AOg5g0wC3bq5kUEn29Uch3Nm5DFY3o4ab6Cd9ekVOzXKKK/yUpwCvOpoj4bUFTtGW55ONzOvk1PJicdlosLPZ5U5FqtF9YAk6Tc1M7pVVUlAxL4irfqQadAqLmNvuQXUXUXSlN+wm2nNVzjJ1ZHEx8X0QVkBZZoSC9E6nzTjU= 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=Ern3zW7G; arc=none smtp.client-ip=192.198.163.11 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="Ern3zW7G" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712072554; x=1743608554; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OVHNlIP+AOoymkMOBF5BGMRhdK9G0XAGm3jDVh5hzgs=; b=Ern3zW7GHq19188pS7Dz3evoNGdHZnUP/byUZ4+nR6P9jG4ylvMe497W In0Jb7iW/c6stMaVMTr7wSW2ZwDNQ5L3Qcy0gRYo4heZd+oxNQB4Vdir6 GV6PNUKjmPz5RA+MkG1fgtpmOcxFg/uRgM4VU3LnebZV64yEqZyFoIK5g o1Obn9ICiOmT3uSaah0kq49yYcOxnOlcEnopiEk8r4nvjVX7iPPp4LjKj 0UKXgiYfsR0COl/CaZ9wfmZ0wNWFH19OIECB6o7uE01E7qEcv7zINsOCa 1Rl5bQDm40gFv3YcD2A33ZeMClc9rzm8VEt1UvQjo53M1I9SwSvHNUzmJ w==; X-CSE-ConnectionGUID: UlMApRsfTaG2SLQ3jplajQ== X-CSE-MsgGUID: Uo57ieySRpyFRU69S8OH3Q== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="17870085" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="17870085" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 08:42:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="937083646" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="937083646" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Apr 2024 08:42:23 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id AA91B812; Tue, 2 Apr 2024 18:42:20 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Jiri Slaby Subject: [PATCH v1 11/16] serial: max3100: Replace MODULE_ALIAS() with respective ID tables Date: Tue, 2 Apr 2024 18:38:17 +0300 Message-ID: <20240402154219.3583679-12-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240402154219.3583679-1-andriy.shevchenko@linux.intel.com> References: <20240402154219.3583679-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 c4e4dc5f0858..599665770b6e 100644 --- a/drivers/tty/serial/max3100.c +++ b/drivers/tty/serial/max3100.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -841,13 +842,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); @@ -855,4 +870,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 15:38:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 785366 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (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 6D5EE136652; Tue, 2 Apr 2024 15:42:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072554; cv=none; b=UeBtu8RRiHkAVehuj4WCdOWe6XfkchBfN9lsHSE0FGq9HMCYj3B3DYktsNuobX9p8oqW/9ROcXacGAbcYPdEgcu8X/0qTzYw0vzwhDPXZu42NCnsfsKvaQoA4tACVn9MI0Al1cyow+xpgdp0LEOXrt2pVeWopxI+QvlNxCa4Yj4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072554; c=relaxed/simple; bh=AIh3l1Gbu1W+nR8Zu3dJLegwaJOkwuUiD3LVeSrwOEc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WQDsWy1D2mtjaC1w2vMBgtpnHATr0RyVlwO2RzsjX1lYdkh7+AbHubxal3kmWYDX19Cn7wY7uO9uPHi0/SIt4knnsiqHm7x4AtqM65mnSI2gN6NWxNZsWC6KRYjwVpayiztd+0Iq9gZ1vDWdLqnJE5gXhicmNZWXHNdhRfOQ52o= 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=Y2oiYWTR; arc=none smtp.client-ip=192.198.163.11 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="Y2oiYWTR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712072552; x=1743608552; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AIh3l1Gbu1W+nR8Zu3dJLegwaJOkwuUiD3LVeSrwOEc=; b=Y2oiYWTRSHkl809masdF/vazRHN1YArCs5JzD7gm1+C7O4jRQzEGwrKU tC2/dL246al1FM00w1kOTI+SbzZ2rtQ19quXrmWF50jA6jTzytqL6WGE4 YjJAG6h+nIkM/CxBi95o/qui0bQ8bLdo+WjqqceAbm9ZznSqKSAYp4p2d hYiwyPk4jXEVlnmsJjnfdFtXAWO2J+gV6RHHCHswH43VilLVD3zXq86HX row9FaTOgx3mVu1EOf6bOckzottxew7MF1twzyuh8JwEiutANhUEzUv40 6Diq2G79SMm7qeYVhbGEBrxQBBoCLDWb2Qw4Yyx00O6MfaRccu2pkQPk7 Q==; X-CSE-ConnectionGUID: BUWewOyrQxW7/QL2/w5RUg== X-CSE-MsgGUID: LH6XPWdUTSWOJRwvSwZYsw== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="17870092" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="17870092" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 08:42:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="937083649" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="937083649" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Apr 2024 08:42:23 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id B297F15BC; Tue, 2 Apr 2024 18:42:20 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Jiri Slaby Subject: [PATCH v1 12/16] serial: max3100: Switch to DEFINE_SIMPLE_DEV_PM_OPS() Date: Tue, 2 Apr 2024 18:38:18 +0300 Message-ID: <20240402154219.3583679-13-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240402154219.3583679-1-andriy.shevchenko@linux.intel.com> References: <20240402154219.3583679-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 599665770b6e..585bf6c898b2 100644 --- a/drivers/tty/serial/max3100.c +++ b/drivers/tty/serial/max3100.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -798,8 +799,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); @@ -835,12 +834,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" }, @@ -858,7 +852,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 15:38:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 785367 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (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 70BE2131756; Tue, 2 Apr 2024 15:42:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072552; cv=none; b=JuU0/Uyxre8VP8leCTSgizljAhfRK8dLDd9BW36Htn6EgWc5/j0HQHI0xuGblhfyixY+AktImsA2vZ1a9+hr8HNyyhnYjAD2lq0604O1IaqsLGLfL2xmmaZhgY8zO81YctiYY+pddmrkZ/21mLsUMmias2ySK3ClmykPYFWvTk8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072552; c=relaxed/simple; bh=qaNxJRzKNFJEciBWzATAEKh3thS3c0nNiekRNQvqy8Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TLWH7GrVsUSW4IdeSJfw28KXoML6HlCZWquEaSw7d1fWObgfnGPC9hjnrz7huvst7qpqg+fPop5Z9NYN2l/DcE/jSjbxA9/P4Eu1wFn51OjeVBWcHY0mbqC9ENHmYctgMEBGyim0t9YOYtswHJ/UteTx4toGcgUUC1EjahBHcpU= 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=V9ATCE5q; arc=none smtp.client-ip=192.198.163.11 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="V9ATCE5q" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712072550; x=1743608550; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qaNxJRzKNFJEciBWzATAEKh3thS3c0nNiekRNQvqy8Y=; b=V9ATCE5q2/0dMMbQf/nbqk7dfya2Ia+wdV89uq0E/SWqeXr236TfxauA +ZxmJD6PUSY2bUJW7E3S09H8mPWwuUChxbKcb0MIJxmTf+vxPrZ2dFqVb GAMwFas69ptIi16H57BuNxWRJ0k+Nf71V78N5bCPLiUMQc+gA8yus+XYu NT6rrp46kNbZUBfasFImvy7C3ELhZObe9i3v4Ljy9EsUgbzgJrxo5tq3o N6GWVU9Qth49N+qygEex42IdTaN7fMSpKT7R7nRvhdeBy5fT80r5BWKt1 IPjfEoRQTZVfyJC6rwVKjhQ8gNUumlLYwC6B6X3l21QyTws0e2T7HQhrC g==; X-CSE-ConnectionGUID: 8wrW/6g2TU2TACh2B5l6Vw== X-CSE-MsgGUID: IZjweAUaQe21XgHpl9bHcg== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="17870082" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="17870082" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 08:42:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="937083647" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="937083647" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Apr 2024 08:42:23 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id BFE1816A1; Tue, 2 Apr 2024 18:42:20 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Jiri Slaby Subject: [PATCH v1 13/16] serial: max3100: Extract to_max3100_port() helper macro Date: Tue, 2 Apr 2024 18:38:19 +0300 Message-ID: <20240402154219.3583679-14-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240402154219.3583679-1-andriy.shevchenko@linux.intel.com> References: <20240402154219.3583679-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 heler 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 585bf6c898b2..19b05992a9ac 100644 --- a/drivers/tty/serial/max3100.c +++ b/drivers/tty/serial/max3100.c @@ -16,6 +16,7 @@ /* 4 MAX3100s should be enough for everyone */ #define MAX_MAX3100 4 +#include #include #include #include @@ -110,6 +111,8 @@ struct max3100_port { struct timer_list timer; }; +#define to_max3100_port(port) container_of(port, struct max3100_port, port) + static struct max3100_port *max3100s[MAX_MAX3100]; /* the chips */ static DEFINE_MUTEX(max3100s_lock); /* race on probe */ @@ -322,9 +325,7 @@ static irqreturn_t max3100_irq(int irqno, void *dev_id) static void max3100_enable_ms(struct uart_port *port) { - struct max3100_port *s = container_of(port, - struct max3100_port, - port); + struct max3100_port *s = to_max3100_port(port); mod_timer(&s->timer, jiffies); dev_dbg(&s->spi->dev, "%s\n", __func__); @@ -332,9 +333,7 @@ static void max3100_enable_ms(struct uart_port *port) static void max3100_start_tx(struct uart_port *port) { - struct max3100_port *s = container_of(port, - struct max3100_port, - port); + struct max3100_port *s = to_max3100_port(port); dev_dbg(&s->spi->dev, "%s\n", __func__); @@ -343,9 +342,7 @@ static void max3100_start_tx(struct uart_port *port) static void max3100_stop_rx(struct uart_port *port) { - struct max3100_port *s = container_of(port, - struct max3100_port, - port); + struct max3100_port *s = to_max3100_port(port); dev_dbg(&s->spi->dev, "%s\n", __func__); @@ -359,9 +356,7 @@ static void max3100_stop_rx(struct uart_port *port) static unsigned int max3100_tx_empty(struct uart_port *port) { - struct max3100_port *s = container_of(port, - struct max3100_port, - port); + struct max3100_port *s = to_max3100_port(port); dev_dbg(&s->spi->dev, "%s\n", __func__); @@ -372,9 +367,7 @@ static unsigned int max3100_tx_empty(struct uart_port *port) static unsigned int max3100_get_mctrl(struct uart_port *port) { - struct max3100_port *s = container_of(port, - struct max3100_port, - port); + struct max3100_port *s = to_max3100_port(port); dev_dbg(&s->spi->dev, "%s\n", __func__); @@ -386,9 +379,7 @@ static unsigned int max3100_get_mctrl(struct uart_port *port) static void max3100_set_mctrl(struct uart_port *port, unsigned int mctrl) { - struct max3100_port *s = container_of(port, - struct max3100_port, - port); + struct max3100_port *s = to_max3100_port(port); int loopback, rts; dev_dbg(&s->spi->dev, "%s\n", __func__); @@ -414,9 +405,7 @@ static void max3100_set_termios(struct uart_port *port, struct ktermios *termios, const struct ktermios *old) { - struct max3100_port *s = container_of(port, - struct max3100_port, - port); + struct max3100_port *s = to_max3100_port(port); unsigned int baud = port->uartclk / 16; unsigned int baud230400 = (baud == 230400) ? 1 : 0; unsigned cflag; @@ -532,9 +521,7 @@ max3100_set_termios(struct uart_port *port, struct ktermios *termios, static void max3100_shutdown(struct uart_port *port) { - struct max3100_port *s = container_of(port, - struct max3100_port, - port); + struct max3100_port *s = to_max3100_port(port); u16 rx; dev_dbg(&s->spi->dev, "%s\n", __func__); @@ -559,9 +546,7 @@ static void max3100_shutdown(struct uart_port *port) static int max3100_startup(struct uart_port *port) { - struct max3100_port *s = container_of(port, - struct max3100_port, - port); + struct max3100_port *s = to_max3100_port(port); char b[12]; int ret; @@ -607,9 +592,7 @@ static int max3100_startup(struct uart_port *port) static const char *max3100_type(struct uart_port *port) { - struct max3100_port *s = container_of(port, - struct max3100_port, - port); + struct max3100_port *s = to_max3100_port(port); dev_dbg(&s->spi->dev, "%s\n", __func__); @@ -618,18 +601,14 @@ static const char *max3100_type(struct uart_port *port) static void max3100_release_port(struct uart_port *port) { - struct max3100_port *s = container_of(port, - struct max3100_port, - port); + struct max3100_port *s = to_max3100_port(port); dev_dbg(&s->spi->dev, "%s\n", __func__); } static void max3100_config_port(struct uart_port *port, int flags) { - struct max3100_port *s = container_of(port, - struct max3100_port, - port); + struct max3100_port *s = to_max3100_port(port); dev_dbg(&s->spi->dev, "%s\n", __func__); @@ -640,9 +619,7 @@ static void max3100_config_port(struct uart_port *port, int flags) static int max3100_verify_port(struct uart_port *port, struct serial_struct *ser) { - struct max3100_port *s = container_of(port, - struct max3100_port, - port); + struct max3100_port *s = to_max3100_port(port); int ret = -EINVAL; dev_dbg(&s->spi->dev, "%s\n", __func__); @@ -654,18 +631,14 @@ static int max3100_verify_port(struct uart_port *port, static void max3100_stop_tx(struct uart_port *port) { - struct max3100_port *s = container_of(port, - struct max3100_port, - port); + struct max3100_port *s = to_max3100_port(port); dev_dbg(&s->spi->dev, "%s\n", __func__); } static int max3100_request_port(struct uart_port *port) { - struct max3100_port *s = container_of(port, - struct max3100_port, - port); + struct max3100_port *s = to_max3100_port(port); dev_dbg(&s->spi->dev, "%s\n", __func__); return 0; @@ -673,9 +646,7 @@ static int max3100_request_port(struct uart_port *port) static void max3100_break_ctl(struct uart_port *port, int break_state) { - struct max3100_port *s = container_of(port, - struct max3100_port, - port); + struct max3100_port *s = to_max3100_port(port); dev_dbg(&s->spi->dev, "%s\n", __func__); } From patchwork Tue Apr 2 15:38:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 785753 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (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 C2178135A5F; Tue, 2 Apr 2024 15:42:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072553; cv=none; b=Y4nDYodjeak1CP5l5EcijGDejX4AW0arD+pZjRaPnWcYLm5gQNB9aYmw89bJhdj/MfJjN+3wGC4D93k/dJxvBcfiK5GLFX7JIlEvZDc3oeXagu5rxKJPp7UmXDIgSkYbq05n3pDeQn5MGfoy/Hrdin0FA5yzBwQznsQyab1ihAw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072553; c=relaxed/simple; bh=nPKJLyGWUAo20JnttXNN/dLtu3GQiMS1v2MSYR4PCTE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aQpbJm+Ha4znPlem90KV4UwTj9g+413U3ifV3M/jq+HTjUnrsgMX3cYRsYJzvTIPNVvK4HJV8K1tejV34GVBkFpdn6X9SkvD2ZXVGT7vBt5h6VYg0Ns6N/opjkKFxyl9nSO3qPcI9pBHj470xdWVtgKMlw+oFoXwPzR1TttelKI= 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=OKapIKiQ; arc=none smtp.client-ip=192.198.163.11 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="OKapIKiQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712072551; x=1743608551; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nPKJLyGWUAo20JnttXNN/dLtu3GQiMS1v2MSYR4PCTE=; b=OKapIKiQnpaAzPbdKpkNg23I+AwZWYh0aiEeTU34pkTkzFZNNzFLrVxF fCI2ys43UeC8gHkwSNZpPxP0UcScsvK953ZgSGz0cqZA7fkQGXFM7NxiE +QHTQ0WsMpq/ihWbze+pZxsfe7Cl3/372kvA3j/e3civzyJASKJj6zm4J xyfmcFVwDz8K6l3B0qUOGMApeYv2+mFYy3/7qpsm/vP8DINrtZhizBG25 /uQDMQs1XAhMGgTvsv2D9BwymP3KAwWdYTIWr3SNbxuTrMeMm+uVzqT+V I7RHIe8Byn6gxChvVGvPF+xDHLybGDa2VdQEcQ5Nsqx27FqReoxo/iHQ1 Q==; X-CSE-ConnectionGUID: t/I/g15RQIyG/oH2ePlKPg== X-CSE-MsgGUID: eGlWa7aJS4mL1ofe6KwveQ== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="17870089" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="17870089" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 08:42:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="937083648" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="937083648" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Apr 2024 08:42:23 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id C8ED716A6; Tue, 2 Apr 2024 18:42:20 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Jiri Slaby Subject: [PATCH v1 14/16] serial: max3100: Remove unneeded forward declaration Date: Tue, 2 Apr 2024 18:38:20 +0300 Message-ID: <20240402154219.3583679-15-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240402154219.3583679-1-andriy.shevchenko@linux.intel.com> References: <20240402154219.3583679-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 19b05992a9ac..e63ac027b4f3 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 15:38:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 785364 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (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 7EF1D137C33; Tue, 2 Apr 2024 15:42:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072556; cv=none; b=DIUpyRUE3RCjgRNiJ6JfCbIutqp5ZmRpavlxlQEw6dlMlHhylEAybTrHcdi7GUAyYywfTgYUgvtm1mnvMqk366MebPFBD3ZTJdPH4bLnl86YsuynK3XHJtE7PxTm63ePtdu4myknfI20UU4Grb2Y8xhcqIRQI97cTeamsGS8XRs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072556; c=relaxed/simple; bh=9PMPvNt/graUgF5IwGBIHwem/5+4HBKF7gr4a0TYsBo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XdS86H73z4HibsoIC2NM+XFgo3nVrLZrYBpS7ZVi9TBhkfX1eITI4YgMx03Umk0DEuJOwt3vCrtnsBm/0UOEmhmnQMCDavGxcLk8UbfWVts81hhMqsBoVTOHKq8dQHPsXeaxb/GFbKV9TOALZieW7lvvMO8z8EnrpnEZUjbHZb8= 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=c7L/XuPj; arc=none smtp.client-ip=192.198.163.11 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="c7L/XuPj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712072554; x=1743608554; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9PMPvNt/graUgF5IwGBIHwem/5+4HBKF7gr4a0TYsBo=; b=c7L/XuPjLYRBCNK0LQybxQ8B33EK91N2YnnZlXojtoiqchWV6scFX8js CgAHZdqoqH7mgtzmJ+Qu+dujxEREdZW6QQl/SCAp5uRavUsR82B40oZPo Y4x8Q9DH/Fw15EEcFffnGYo1gsuaYss8Pn59ilfHuP0zujzgL3utGMhYk YXKGbGlg71lSAhP7KtW8kBc3XqVUpt7Odd7EKhiys+LLyx3XN4zNA0BKq QHleoMor2lPziBnJ04fgcMcoIDZc5OfhTKWuqf7s9zBlaR2NoEvh5va/O /mBRZlaRl2EI7VSAul2rzAUgi4xeZStpp2NbvB9ZhzfePIoyZ+KcLxC+4 Q==; X-CSE-ConnectionGUID: CzSgz+PTRxCV0c+FPHdNXg== X-CSE-MsgGUID: yNa272ObQkaiEjEX4VnwFg== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="17870097" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="17870097" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 08:42:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="937083650" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="937083650" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Apr 2024 08:42:25 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id D07D51567; Tue, 2 Apr 2024 18:42:20 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Jiri Slaby Subject: [PATCH v1 15/16] serial: max3100: Sort headers Date: Tue, 2 Apr 2024 18:38:21 +0300 Message-ID: <20240402154219.3583679-16-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240402154219.3583679-1-andriy.shevchenko@linux.intel.com> References: <20240402154219.3583679-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 e63ac027b4f3..d7c0e274e00c 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 15:38:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 785750 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (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 8D86613A890; Tue, 2 Apr 2024 15:42:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072557; cv=none; b=Jj7TRjb0xJEeHmwqC1B2+G8Ow+u8rA7LMzGRpqD2DCiSRCNmHw8DTcQsIpsnmSnQDtnHVVSI6vr2T/ZRb8oxHhR87kftO0R0th93qWj+2Bti/FSvIPdpSd0pYCGKr7EjLER22AAViQnLYGc+XxxdjCysuDnEdZe3vXZljmyYLC0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072557; c=relaxed/simple; bh=Pzd4zF55D0Q5tN3ZT/f+vvK1+li7w9jn5Gn98hnh/Tk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ICHBmyuohMRZlodt1DOr5/7a7jmUTTbNAMiYImMDDRxGs6Jq46hFIx1Le2FmEjo2m5MQFUQyxXKvRcsTGlulFeeQyt8G9yeGPwhxPvd6rLCc4gff+pHe3hbs1fnp2bT/pm0W4gouq7XonrAfHcJeQ8yDqBhnLBRJ+E7Ib36YIMA= 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=nBP7VhyT; arc=none smtp.client-ip=192.198.163.11 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="nBP7VhyT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712072555; x=1743608555; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Pzd4zF55D0Q5tN3ZT/f+vvK1+li7w9jn5Gn98hnh/Tk=; b=nBP7VhyTTRyoCcONpmr8jmQ6qOIWoW42Q4Lzz2huPYZKgAk/PiPgGsTs kzAX5wB7bQrR3mz74qEB0BcbCmDiGA8G7M5l8C6SZKv4LUHvd+b8ycNUO oI5VQWQj0W5M+BLcbZZskLqNXEbG+xssUMX9TwVuzuYqaJ7eKQkah1M5+ OjudtXhbHPDixLKasnbYJRwTjutPzoCHkZDoGQGNyXJlWQsIuwfNdCj/l 1tIIlU3U7IzwSlrldSgvj+hCPXc017x/TY8Ub78iMHS29bHXpGZvmnMjv CPK1v4cpZxurdibIoxBlUVBgC8sa2r5AM0hE3Vu6TM0TBOe66xnZBzJq7 A==; X-CSE-ConnectionGUID: kSOzQfISRcWO2NZSh8cLCg== X-CSE-MsgGUID: CHzj9OOQRYiAGGoK6ahx1w== X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="17870099" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="17870099" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 08:42:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11032"; a="937083651" X-IronPort-AV: E=Sophos;i="6.07,175,1708416000"; d="scan'208";a="937083651" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 02 Apr 2024 08:42:25 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id E0BC016EF; Tue, 2 Apr 2024 18:42:20 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Jiri Slaby Subject: [PATCH v1 16/16] serial: max3100: Update Kconfig entry Date: Tue, 2 Apr 2024 18:38:22 +0300 Message-ID: <20240402154219.3583679-17-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240402154219.3583679-1-andriy.shevchenko@linux.intel.com> References: <20240402154219.3583679-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"