From patchwork Tue Apr 9 07:43:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guanbing Huang X-Patchwork-Id: 787393 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8BF67C6CA; Tue, 9 Apr 2024 07:43:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712648637; cv=none; b=P4KbyTrL9i61eHKvM9CDvdf6tNnJjsARQeTFMJxmeoGoFhABNse1A3WsTpczlx6babi9evPrM7TfG96+rG+zT0O6t92gyxl1DxKGDENLf8q0KK1FwBZQqQuIuAtGtcItOj+4+dUj/Bb/sDe6BLLkLEwKxHtEy5v44mT0RO9uqbY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712648637; c=relaxed/simple; bh=w0Z0P84vxqSmx39NUsYXq/qGnGd2RcUjYIVp1R5MhG8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=CO/SCc79DcAR212XlkjWC5x2BgBR4c/P630Oj0hUWxOmRMn56um7h5VZ6Lxc3Kpl7Ztg2KYvTjWj/BDl/doDOpi2HrWEoBncD4Js41ohnWvTdV6950R5dNRb9V9Ec3FVQklkCUp6DPDebW45KKF6WZCYHYS3HzMt8wpSPUbl0/g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RqQ1LQUd; arc=none smtp.client-ip=209.85.214.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RqQ1LQUd" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-1e455b630acso8134485ad.1; Tue, 09 Apr 2024 00:43:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712648635; x=1713253435; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=ONFD4/Vc6YR7CCQ0n+d7jmlTotuvow43AhDgWdDDx6I=; b=RqQ1LQUdNT7P5q3OJbrmD8bWQEbVo1PEur7XHUSkaTNLHfmQjd6ONyxcxzq/zd0aZf cc2Cs0BpV4FCrhyLEV6VhH1eBLVz8NTw5uRmRTrwX/54KhtUryRCdGYOMp4Vr2VwH305 8NfoMFEBg5DTXqARk4xfEZoTKHf870UvaG00gr4QYDU0tJgsg78hq1/Qn7WBhRJZe35v GLYHxBpohfoos44fCJGbtF0m/dkGHhaG1ZiSh/yoKMWZPrgYjBzWBcwhUelru8DPDAzY mdqJ10krxyUtojUhTnSq9NCK8xb7E2h0kzMY35CwP7clzzff35qd73I8jcsVFUSa1OID t12w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712648635; x=1713253435; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ONFD4/Vc6YR7CCQ0n+d7jmlTotuvow43AhDgWdDDx6I=; b=t/OkaEBeAVfCGxvqLAe2t/3HKffIDch2ih7wnBiWideeCZdDmAka1vMlTmsTjJZ7sN n8SxGlRJeAW9yWyKCVUSm0I0/jbTrytTMeaLq5JpBTbHX8jnM3ia6aS4yk125hzqFWK/ KURRpgFVeEpxowUh08jx5uY4NarmhDa7AYRPx5euvi+LtPkQsnKFmegMx7jpbf4Iqgk4 SwT+dws0E40aOCTModkD6i8qk/ELH0NWUY3dVK5grG5aS1uu295upw12H6+zxpdW2+wa n5F2OEEYH5jlOsU6GMcqdTT+Ck5xnPpuMA4F/kEbNUnbDvRKybm7h43tyG2WWdHUb88E CwkA== X-Forwarded-Encrypted: i=1; AJvYcCXNAUDcexYJA9BDHgt+bZ6vc0LYEO0uvwKID3SnYrUhs21kxz1OWH0we1F+LJG+GcH6vMKpBHJoI9GSp+5Y95sRVkZo8VcBWGZn5OI3tknF9eNgdhI3jsVDYXttNdM81SMyvt1Dqu/MVcMl X-Gm-Message-State: AOJu0YwP/83KVhroWV6clvcQ/95hgJVvtZ881j8irDKnPfYGP/bYOOEx 64rbLZp6D7kLpIsO+zOG3w4jtxTQ2RzD/v+K/Gpz/y2yUjSWQxbl X-Google-Smtp-Source: AGHT+IG9f4mfZYnvm8ROpu5/UudNC3S46z1v8L7mwA165lyQ7y+oj0sj+xask7LQmgHgzOs+8CwZEA== X-Received: by 2002:a17:902:da81:b0:1e3:dc0c:1bb0 with SMTP id j1-20020a170902da8100b001e3dc0c1bb0mr7864871plx.1.1712648635342; Tue, 09 Apr 2024 00:43:55 -0700 (PDT) Received: from localhost.localdomain ([43.159.199.34]) by smtp.gmail.com with ESMTPSA id j5-20020a170902da8500b001e424ccf438sm3458975plx.97.2024.04.09.00.43.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 00:43:55 -0700 (PDT) From: Guanbing Huang To: gregkh@linuxfoundation.org, andriy.shevchenko@intel.com, rafael.j.wysocki@intel.com Cc: linux-acpi@vger.kernel.org, tony@atomide.com, john.ogness@linutronix.de, yangyicong@hisilicon.com, jirislaby@kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, lvjianmin@loongson.cn, albanhuang@tencent.com, tombinfan@tencent.com Subject: [PATCH v6 1/3] PNP: Add dev_is_pnp() macro Date: Tue, 9 Apr 2024 15:43:41 +0800 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: From: Guanbing Huang Add dev_is_pnp() macro to determine whether the device is a PNP device. Signed-off-by: Guanbing Huang Suggested-by: Andy Shevchenko Reviewed-by: Bing Fan Tested-by: Linheng Du --- v5 -> v6: fix the issue that the cover letter is not chained with the patch series v4 -> v5: change "pnp" in the commit message to uppercase include/linux/pnp.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/pnp.h b/include/linux/pnp.h index ddbe7c3ca4ce..792921c06594 100644 --- a/include/linux/pnp.h +++ b/include/linux/pnp.h @@ -502,6 +502,8 @@ static inline void pnp_unregister_driver(struct pnp_driver *drv) { } #endif /* CONFIG_PNP */ +#define dev_is_pnp(d) ((d)->bus == &pnp_bus_type) + /** * module_pnp_driver() - Helper macro for registering a PnP driver * @__pnp_driver: pnp_driver struct From patchwork Tue Apr 9 07:44:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guanbing Huang X-Patchwork-Id: 787894 Received: from mail-oi1-f172.google.com (mail-oi1-f172.google.com [209.85.167.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 861F47D07F; Tue, 9 Apr 2024 07:44:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712648658; cv=none; b=ZzFI8uRFc28/zuD3CzhqD0Q/UPi7PIDWnejg86a9ehC7d/AEsRD7t+NGOn1UqJ1XHBaZWDl1AOjTR5deIx/kbvjkGuP1M8N7/Q+2DGw+3Wto/kpRcXqMG/Bi6e+obnvHdFkP9pQ8v0nTV5RAFlMh0R0UByXZ9QxfBS9T9FaBCRY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712648658; c=relaxed/simple; bh=eMjsm+axSa9dba31ZbkHgkcUo0FWbw22zKllG4mNmB0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=I2gVwlvwZQ9+ycgbKJKOEuO0s34Q+wz6WbLsfxr4uJ71QlwhxYeLE9KiiRM0QVsJMaUb1RRsP6yOnUycaaJL9SuDE/PNzN1vyyOnJl0ZSPex1xYZS4j6nvC653pICMu9aSIZMQmdoM31U2q4THQ5OrByp+jBFO6yYH7k20Z75hE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Zvpv4AvA; arc=none smtp.client-ip=209.85.167.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Zvpv4AvA" Received: by mail-oi1-f172.google.com with SMTP id 5614622812f47-3c4f23d23d9so3219794b6e.3; Tue, 09 Apr 2024 00:44:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712648655; x=1713253455; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=4get4IE/kyR3VAiCznQKvRJLeYXGzh0Wcyxj/ZAznK8=; b=Zvpv4AvAl5EI0hcwPgR/Lf0KcIBOf8jjlRmjtsRUJKVdEdGhXfwb7pqty2GRN9hJXy jhpRxmbwUFry0UXI2myTlBJFpZQgvJxDVCVSAUFa/2sHFhfIIPnvuiVX76dwPr6icVtT H52a7SfsDbKtpxN7F8IJ3KpgnwDUarTVPwv4vD/AhgI5ogVHsenYk2eSNXruGD40OY+/ KaVwLhNCMRzDE9oRJzBAhJTEnKLNsRSHTm13Sd+Ri1tUDflsYTDmXL9jh5meqFKvtD9B iWcXo6NE8bKHzG2DSAm7jygdZrRs+UvvtcXX4oUWQM++eU7Ks4DUvKL4HoByHiUlZI0F GyOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712648655; x=1713253455; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=4get4IE/kyR3VAiCznQKvRJLeYXGzh0Wcyxj/ZAznK8=; b=eSdAhI1L80UXWl1c1A3ZSeyAttC+xoBjkhLOBHjFiIEdblskHxrXwUHW8MJe5Yrjlt asOTEqdrZTE2a3R9TlwtcY/0XnZ43X91UtqJbWSm3qWLs3kGEErBAJrRqt7ZpxWHjMLo SDmih9xeujJzwF6/J3Qb/2kz8DaGueX4qBvSxPMPD7oq9wA3ekkJu5txaWKPKk+qPPuH vc7lFhy3Qn3fXmgSdcvDYsjTrARrbSiWt0zMVgrf57jE3ba4Hjw+DV0ogdmebxJUXymb ks6IYESVTikoTqmv+rb2qIjCMMct2tZzHbh8fdRI6ii4z0Pfu5b/FcZaIHhD4X/+avZ9 wTMA== X-Forwarded-Encrypted: i=1; AJvYcCWRrOPdHxqD8jyowygXY97JBsFei9Jvrwu664CU1frZUn76FznXSXXbOznRYA0ct/O5E++9ySDxnolKqfpT+7h5Ml5yEe4dgWDi1b3Y6jrEo5DQcmabiUT1Z5OkoyQK1TbjhoNIZnS3Nl6r X-Gm-Message-State: AOJu0YxLJA9moQQl4BdwGjrIrXn81SNscUL55dZehFGwp2+1Z8nciBXx ObrrX30Zpt3nmodgnBfzZG9AjyS/O+XvAyj5w4z9G5OlX7OO92mC X-Google-Smtp-Source: AGHT+IHrjGyawYS5iBR5WVccVfDrwqzLQUgqXLkZthbBAde8zskxc5v6Ws1jPrpNVJwrvS+B4wlXuw== X-Received: by 2002:a05:6808:1790:b0:3c5:e901:e3ec with SMTP id bg16-20020a056808179000b003c5e901e3ecmr8690122oib.16.1712648655560; Tue, 09 Apr 2024 00:44:15 -0700 (PDT) Received: from localhost.localdomain ([43.159.199.34]) by smtp.gmail.com with ESMTPSA id ll24-20020a056a00729800b006ed97aa7975sm237818pfb.111.2024.04.09.00.44.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 00:44:15 -0700 (PDT) From: Guanbing Huang To: gregkh@linuxfoundation.org, andriy.shevchenko@intel.com, rafael.j.wysocki@intel.com Cc: linux-acpi@vger.kernel.org, tony@atomide.com, john.ogness@linutronix.de, yangyicong@hisilicon.com, jirislaby@kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, lvjianmin@loongson.cn, albanhuang@tencent.com, tombinfan@tencent.com Subject: [PATCH v6 2/3] serial: port: Add support of PNP IRQ to __uart_read_properties() Date: Tue, 9 Apr 2024 15:44:00 +0800 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: From: Guanbing Huang The function __uart_read_properties doesn't cover PNP devices, so add IRQ processing for PNP devices in the branch. Signed-off-by: Guanbing Huang Suggested-by: Andy Shevchenko Reviewed-by: Bing Fan Tested-by: Linheng Du --- v5 -> v6: fix the issue that the cover letter is not chained with the patch series v4 -> v5: change "pnp" and "irq" in the commit message to uppercase, modify the subject to start with "serial: port:", modify the location of the header file pnp.h drivers/tty/serial/serial_port.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/serial_port.c b/drivers/tty/serial/serial_port.c index 22b9eeb23e68..8504bae1d2c9 100644 --- a/drivers/tty/serial/serial_port.c +++ b/drivers/tty/serial/serial_port.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -221,7 +222,11 @@ static int __uart_read_properties(struct uart_port *port, bool use_defaults) if (dev_is_platform(dev)) ret = platform_get_irq(to_platform_device(dev), 0); - else + else if (dev_is_pnp(dev)) { + ret = pnp_irq(to_pnp_dev(dev), 0); + if (ret < 0) + ret = -ENXIO; + } else ret = fwnode_irq_get(dev_fwnode(dev), 0); if (ret == -EPROBE_DEFER) return ret; From patchwork Tue Apr 9 07:44:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guanbing Huang X-Patchwork-Id: 787392 Received: from mail-oa1-f54.google.com (mail-oa1-f54.google.com [209.85.160.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1BBD7CF37; Tue, 9 Apr 2024 07:44:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712648680; cv=none; b=GEZVLha1Rc4yQBoZxB5tLCSPodZu4rhj3cBewBbYxZzW0Kytdh/2FQJWjA5ddUFg4j69IusgPuf40DGAfykiHbChvY5KLX8GWuOKICeS215IpLqVgrruAc0phYY3NiiankgRX95bfko4OkavNxXH0bd5QvOA1tRdSQczvdHm/w8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712648680; c=relaxed/simple; bh=eN/Kbm8JIvI8VT1ekgbsIrtHERUOe+RG1vZ3KjwFC1Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=mUxx1jy3m7liEX1Xcn+X29Y+zxLyIeyEiYUY9Rt0HcfehOJEB09mRz2+2XKukVUHzs2WmKFySy8Zk5rqZXVxkrTfDjLVNBfJey8/4Ix0v4JEbvNYgGr4SCFD57QfHZgN4Bn80qlLQ03QoZVdGn8RqBYgFdvhxaWCSf7ymUIAfCs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=EWxf69rx; arc=none smtp.client-ip=209.85.160.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EWxf69rx" Received: by mail-oa1-f54.google.com with SMTP id 586e51a60fabf-22200c78d4fso3048180fac.1; Tue, 09 Apr 2024 00:44:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712648677; x=1713253477; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=glJ/raStn7JcLXqAKXJOlY+XSeBuKwLManaPf/wnEcA=; b=EWxf69rxCOCMFczHzSkVaFxG8HOerO1lV17k75QNHFib6HpPIUTwgnQKepHJt/bffc yLb6nXQCfifV0v0Y++pfGnx5QRMCppe/Ayq1Jpi6o8kTQwvEfZnA8H794UNk78I6ueFt JTtEG9uY1jjajznfe16Hri201KBmtlmMniKvzkbqo4Rc+2SHli/6vv8mDWZa+85LihjR 9kdto/IXdC8Rg+s2b4jaEgh05KSX2zyvGYCEc11fERPxH15YK+Ce1hrSzURLRthe8PFz N6QkztDQW6eNeJG6VuBGDk39wz1xtDFu3NQ3DggWV1KVFmJdIbyXXgKlj5nL/batXLYe 17zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712648677; x=1713253477; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=glJ/raStn7JcLXqAKXJOlY+XSeBuKwLManaPf/wnEcA=; b=R7gO6NEq10NYgMddBrYNxaHSvi7LBQbOfLkFH9YSVBBRWr8LpHQIb7P7uo04IoFhR3 jg7WwAqieyHcbVT8qJztQ0gJuuEu62qQot7DxTHEwmV5Yl7vEafCXG6pAKhmFeaBEJzh A6PLpnUckekrUSSLTM91H089m0gpv7Mzq/8vasLviq3BKiMYUuhP0JuKukPTze7rsrR6 0zHhC6voHXpGjR2WkDTljW9x8XXo9Szu2+ccA55zR+P4IvtmTBseUFUZOZ363dHTaaFC 9cOz1P4J4/whDqM6Arl5BdhwRH01Dp+xZ3KJhef+HhRzhlxrUFxkyRttRPZfMkdTzsD/ 7NMw== X-Forwarded-Encrypted: i=1; AJvYcCX5XUxK0z4x6+1oMJqEzq2g7DMFdYV8J+ul9siI7iHxWlnu9L075D4t/zg1CllggCs5RKHgeqUPZzrdHwf0u5Etn/J1ZtC8BHqoKSUNND0WkKLwKXx7lv+wUsHYKMYyPHBO0bc1bfoHsCe9 X-Gm-Message-State: AOJu0YzcVqKKUHKIS3CAP4Y76OO30RrMwhdnVNKeMvOOTBs/xTGSg0Kk u4tipymCXXSS/fwUghIYnOWVivili7NBSEMCReSeJeY2MZg5mJhKh/kl28e0ui4= X-Google-Smtp-Source: AGHT+IGhrVloGDWsURG4uDQX4JDIXqR4evFudZXRp9MphChgDw9agxSF7vVEk1ECPWIwoQcX1ZgS3w== X-Received: by 2002:a05:6870:65a5:b0:22a:6c9a:ece8 with SMTP id fp37-20020a05687065a500b0022a6c9aece8mr11297334oab.21.1712648677600; Tue, 09 Apr 2024 00:44:37 -0700 (PDT) Received: from localhost.localdomain ([43.159.199.34]) by smtp.gmail.com with ESMTPSA id r16-20020aa79890000000b006ed0f719a5fsm5809065pfl.81.2024.04.09.00.44.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 00:44:37 -0700 (PDT) From: Guanbing Huang To: gregkh@linuxfoundation.org, andriy.shevchenko@intel.com, rafael.j.wysocki@intel.com Cc: linux-acpi@vger.kernel.org, tony@atomide.com, john.ogness@linutronix.de, yangyicong@hisilicon.com, jirislaby@kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, lvjianmin@loongson.cn, albanhuang@tencent.com, tombinfan@tencent.com Subject: [PATCH v6 3/3] serial: 8250_pnp: Support configurable reg shift property Date: Tue, 9 Apr 2024 15:44:23 +0800 Message-Id: <3049b47a51fb403d6b1e97e63fcae70e1a810963.1712646750.git.albanhuang@tencent.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: From: Guanbing Huang The 16550a serial port based on the ACPI table requires obtaining the reg-shift attribute. In the ACPI scenario, If the reg-shift property is not configured like in DTS, the 16550a serial driver cannot read or write controller registers properly during initialization. Signed-off-by: Guanbing Huang Suggested-by: Andy Shevchenko Reviewed-by: Bing Fan Tested-by: Linheng Du --- v5 -> v6: fix the issue that the cover letter is not chained with the patch series v4 -> v5: modify to obtain the value of mapsize through the pnp_mem_len function, add annotations for the iotype variable, delete excess uart.port.flags operation v3 -> v4: dependent on two pre patches: "pnp: Add dev_is_pnp() macro" and "serial: 8250_port: Add support of pnp irq to __uart_read_properties()", the iotype is reserved, the mapsize is initialized, fix the UPF_SHARE_IRQ flag, check for IRQ being absent v2 -> v3: switch to use uart_read_port_properties(), change "Signed-off-by" to "Reviewed-by" and "Tested-by" v1 -> v2: change the names after "Signed off by" to the real names drivers/tty/serial/8250/8250_pnp.c | 40 +++++++++++++++++++----------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/drivers/tty/serial/8250/8250_pnp.c b/drivers/tty/serial/8250/8250_pnp.c index 1974bbadc975..8f72a7de1d1d 100644 --- a/drivers/tty/serial/8250/8250_pnp.c +++ b/drivers/tty/serial/8250/8250_pnp.c @@ -435,6 +435,7 @@ serial_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id) { struct uart_8250_port uart, *port; int ret, line, flags = dev_id->driver_data; + unsigned char iotype; if (flags & UNKNOWN_DEV) { ret = serial_pnp_guess_board(dev); @@ -443,37 +444,46 @@ serial_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id) } memset(&uart, 0, sizeof(uart)); - if (pnp_irq_valid(dev, 0)) - uart.port.irq = pnp_irq(dev, 0); if ((flags & CIR_PORT) && pnp_port_valid(dev, 2)) { uart.port.iobase = pnp_port_start(dev, 2); - uart.port.iotype = UPIO_PORT; + iotype = UPIO_PORT; } else if (pnp_port_valid(dev, 0)) { uart.port.iobase = pnp_port_start(dev, 0); - uart.port.iotype = UPIO_PORT; + iotype = UPIO_PORT; } else if (pnp_mem_valid(dev, 0)) { uart.port.mapbase = pnp_mem_start(dev, 0); - uart.port.iotype = UPIO_MEM; + uart.port.mapsize = pnp_mem_len(dev, 0); + iotype = UPIO_MEM; uart.port.flags = UPF_IOREMAP; } else return -ENODEV; - dev_dbg(&dev->dev, - "Setup PNP port: port %#lx, mem %#llx, irq %u, type %u\n", - uart.port.iobase, (unsigned long long)uart.port.mapbase, - uart.port.irq, uart.port.iotype); + uart.port.uartclk = 1843200; + uart.port.dev = &dev->dev; + uart.port.flags |= UPF_SKIP_TEST | UPF_BOOT_AUTOCONF; + + ret = uart_read_port_properties(&uart.port); + /* no interrupt -> fall back to polling */ + if (ret == -ENXIO) + ret = 0; + if (ret) + return ret; + + /* + * The previous call may not set iotype correctly when reg-io-width + * property is absent and it doesn't support IO port resource. + */ + uart.port.iotype = iotype; if (flags & CIR_PORT) { uart.port.flags |= UPF_FIXED_PORT | UPF_FIXED_TYPE; uart.port.type = PORT_8250_CIR; } - uart.port.flags |= UPF_SKIP_TEST | UPF_BOOT_AUTOCONF; - if (pnp_irq_flags(dev, 0) & IORESOURCE_IRQ_SHAREABLE) - uart.port.flags |= UPF_SHARE_IRQ; - uart.port.uartclk = 1843200; - device_property_read_u32(&dev->dev, "clock-frequency", &uart.port.uartclk); - uart.port.dev = &dev->dev; + dev_dbg(&dev->dev, + "Setup PNP port: port %#lx, mem %#llx, size %#llx, irq %u, type %u\n", + uart.port.iobase, (unsigned long long)uart.port.mapbase, + (unsigned long long)uart.port.mapsize, uart.port.irq, uart.port.iotype); line = serial8250_register_8250_port(&uart); if (line < 0 || (flags & CIR_PORT))