From patchwork Tue Apr 16 03:16:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guanbing Huang X-Patchwork-Id: 789381 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 1621E17984; Tue, 16 Apr 2024 03:16:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713237394; cv=none; b=t6Q+PkpcJRUE+d/Kogqyxi+j2RWEVG0Ei17RGOfpnkh/VnB/yFPI3JvC3ICXeB/DPKVI4izkkJUIey0Q5FJb6uVTDDt7hZINFaUyEpk/iTzzOgl2kxu/7/6/wrlTl5FiwSKewQvjg5okKrVMl6gznoC3+7S9+nPmDKRB/CoSVnY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713237394; c=relaxed/simple; bh=qshOwbkjhDK7IvO3CYwTpMh7IPQRdScQ9N0u1PaO7Qs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=OU/ium+e4R6CCYC8GAbRthY2nWaq3vjLKeobi3Kjn/FGIn7EkDBgSxFJOyR96KkFV+IPtmODfD3WLnDddmBkflgWgtDwvvSriKlPkrL+4aJMROENSPehoqDHX83AXFF1736xffiU1FAowGJWsqo3CCeHdZm0KdpjIMl3Dr5yL9g= 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=D3JbczBU; arc=none smtp.client-ip=209.85.214.175 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="D3JbczBU" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-1e424bd30fbso30459245ad.0; Mon, 15 Apr 2024 20:16:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713237392; x=1713842192; 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=x6//tEox5KRG/WsekWic2QlpMO9KpZmieUBGRrot0kE=; b=D3JbczBUtMbkeCmoo5Mw0CWMtPyy3RYANxRgSlMpW8pnfyW0gPyHkN6p5LkkZj6tBD 98p9vC0BFZ4QTUJ2b9cITGoCjf/hSfOT009HZuh4L/jvcF7cj0VEi5llBEJRYzHobaaU T5WHOKlqnxsqcUNwT2mx1rR3XFAdo85/tQ9m1cP8Wep+4gT1LQfElQC8M/nIo0TAVnTY jqdddVQCjFUpD+s1dOhwUDmHt1NVc2hNHEhFy3+Z3QMfn+8fF7LtrFS6V1OMeE+t37U/ I/V49MntPlPg0p4EHVUJwJ+O681aFU2rIAQhSGeReIlF9apks4oA7xsjQf+WBH/9i0o+ XOsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713237392; x=1713842192; 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=x6//tEox5KRG/WsekWic2QlpMO9KpZmieUBGRrot0kE=; b=Lb52T7TUgKOj+Ge85O5wWUg2C3C1OyB7JLtDb5l6lk9aciwDE/fNAH5sAUbIfJOzY2 0Vh9Iyw/5mFrTTT8mUZ9uBgDb6bLuo27GHMoST9TauGGEkeF/USvXAruirCTfrhDHRZa jWtV2jEFX0Bqg2NVaSwly2B8ecJPEyxHEfV0JTWjvO0agFzHCQMhzOgW/Dlaz9P1sVUT f1hA7mfMQlCJB2ufe2ZWKn5M97RQhUdqSFDu4VWrF7ucKL9UXlm7Gxtku29nv1p/sL8F E9cdsEZhKEcOnC5LnvdsFR58/YMOgA//4/lPSO6SI0Wrt2xWsaR8R2LCCDCwpF4Rz2YO BnLQ== X-Forwarded-Encrypted: i=1; AJvYcCUBOWk0BIw+MFqZWH4Nt1lmGkirFOR3s85FmUkevYGrKHz1ABEavQlBCiS4zr5Kl2zrVuUH1idTdGHYIpiAUbJTLTNe4rqazBvApJu+59JY3Fy7nq5NjT5fUsz9vhV4KrIrRmyiUWmeqFGL X-Gm-Message-State: AOJu0Yz+vgo9Cz/Yg6ypKSUIp5djzzE7PM3aB9aiMXxQOwU4BXoEDJJq hAA/m3kKJHNPYHhov9MOPbE0iu9lYrq6NJfA4sDtkSUuVw+Uqduv6bkiWQ== X-Google-Smtp-Source: AGHT+IErcQB2hTwDoy8nQxydHHDljvB6Ftuj4nATNE1n7p/H/4kJ1ZAm7u4TdkoxNjEgqEY39zTbSQ== X-Received: by 2002:a17:903:1c9:b0:1e4:55d8:e5f1 with SMTP id e9-20020a17090301c900b001e455d8e5f1mr15222562plh.5.1713237392350; Mon, 15 Apr 2024 20:16:32 -0700 (PDT) Received: from localhost.localdomain ([43.159.199.34]) by smtp.gmail.com with ESMTPSA id l8-20020a170903120800b001e78d217fd9sm2058496plh.16.2024.04.15.20.16.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 20:16:31 -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 v8 1/3] PNP: Add dev_is_pnp() macro Date: Tue, 16 Apr 2024 11:16:18 +0800 Message-Id: <4e68f5557ad53b671ca8103e572163eca52a8f29.1713234515.git.albanhuang@tencent.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-acpi@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 --- v7 -> v8: delete a "Reviewed-by" tag, delete a "Reported-by" tag v6 -> v7: add a "Reviewed-by" tag and a "Reported-by" tag, fix build errors when CONFIG_PNP is not enabled 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 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/pnp.h b/include/linux/pnp.h index ddbe7c3ca4ce..82561242cda4 100644 --- a/include/linux/pnp.h +++ b/include/linux/pnp.h @@ -469,6 +469,8 @@ int compare_pnp_id(struct pnp_id *pos, const char *id); int pnp_register_driver(struct pnp_driver *drv); void pnp_unregister_driver(struct pnp_driver *drv); +#define dev_is_pnp(d) ((d)->bus == &pnp_bus_type) + #else /* device management */ @@ -500,6 +502,8 @@ static inline int compare_pnp_id(struct pnp_id *pos, const char *id) { return -E static inline int pnp_register_driver(struct pnp_driver *drv) { return -ENODEV; } static inline void pnp_unregister_driver(struct pnp_driver *drv) { } +#define dev_is_pnp(d) false + #endif /* CONFIG_PNP */ /** From patchwork Tue Apr 16 03:16:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guanbing Huang X-Patchwork-Id: 789950 Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) (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 4AB471862C; Tue, 16 Apr 2024 03:16:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713237414; cv=none; b=WhC0HM92Cf2wRck4bRA+QlrurWt2pSLbgXaJVqABqN3SPuoUKXH6BHRAJx13R32iz1NLV2UrxvhqQy7u5srzOW4JNCImAW+obd3yU0R1j2crPRv9+D24cCg83Q7IpOX/sCOzjobodA/ozzV2m99HVzh/Jwc13RxtNr/sChR1MtM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713237414; c=relaxed/simple; bh=IP6VT8eDRdbw1bmE8R8GFrhgxSOo7uUT+zH5dbw9MG4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=bQcoNWIIioaLcZr8Jy4fv/2FEAV9W2LiwoEu/yT6T7zgCbfjtMrSHfFKmNLhXtNG7UCA7MR3BujtdPlqbMubOnRmKGraIZpZE3WEIFx2n5Vh/xbdGxL1cz3bCdLxgtp+yuVtGd1+Er46qmPnQyTxEgN805SDvHpEmQpoyTxEgl8= 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=PXoshhOp; arc=none smtp.client-ip=209.85.210.50 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="PXoshhOp" Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-6eb848b5a2eso764537a34.3; Mon, 15 Apr 2024 20:16:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713237412; x=1713842212; 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=OfAfxZQ2oOSLxgpuAwSaqkeow42p+JVYy0cCJMME+k4=; b=PXoshhOpAAL8w0aTWd2WxoyRHMfk0QytIEr3KfgpLI+zfmCB4Faez3sLZMtnZmV6Xm 3IHLQY/OxX5v4VuOfINlN2L/a5oIJSwAdgTJc1q3PuJ8FfFjgWHktHXnUsY+hbUzsQpi WHp52W78/n3hd8arOMi8a/ZSGCUkX7Z1SHdPcvnvEGGrrtb0y1SoXL44kNIlLd5YXT2x g4WzOH5nJmQevAXPEqPwwE4541HfzbuoRgTSrpXH+bmCNqU2h0tfi2evHhK2IZ9LPkip PlH2Zgwiu5pKX+CODZr0czSLWof8SC1GIqBNqL62pbZDXtRmKt2tLayhRZElnN04TRk0 DM6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713237412; x=1713842212; 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=OfAfxZQ2oOSLxgpuAwSaqkeow42p+JVYy0cCJMME+k4=; b=DixjYT41yTmhRRxbh4QNtoZJ7OIgR0wiwCmEaIamWFCNumqF4uWowP6deBzNL+wngd j7cYjWanB5NMYOy8TOcPW97xdks3kvTkZl23hgjW5xecyDqSKftf4SKhffCIaiDz1JKO uAt0GaYrp/UmfITajoxD7NrqPy83ic/mneaazSItU7QDGQ2CI58zeVvwTtzZouAFFID2 mvam/eElHTa6IBpzJNhTP129jfgA69HZTJ14pZxS7bobcamQzRhIVlq5wAMY6Jk/2XmO xlH7TMsx1kOpjLupJJ/ZT8TLaEwK2CAdLBnDavoiSgIaVOolmSw54iKhwWySSqPI4pFu 4rEg== X-Forwarded-Encrypted: i=1; AJvYcCWdnAiJWgQVwUEuR585zfMLNOEcbXCbPP58TKCsY5Gsb15S9b9y+b6J401soTIW6ojI8n/Tcs67mKxyJlEu5+i3ot8fAYf3m9FK9TMcGoX13sXRW6HYz8U6EYWpOWFid0AUb0zxCow1fKaw X-Gm-Message-State: AOJu0YzcjbK5JhHNcigViWeE0XapOiMiV2aNgju1JHCSKLnKXel9qhz0 oJU7x7VThlvGA8hsyUyG2yoKidnZkLXFMQLy1pxdN/v99zX96SOe X-Google-Smtp-Source: AGHT+IH/xrGHPv69fYUkZUs1gT+mx+8VcOP7E2bGDXaloBNA4L46xfkvc3RBGGnjAyO6cmul5NUsXA== X-Received: by 2002:a05:6808:8eb:b0:3c7:1054:b1b5 with SMTP id d11-20020a05680808eb00b003c71054b1b5mr5686580oic.55.1713237412333; Mon, 15 Apr 2024 20:16:52 -0700 (PDT) Received: from localhost.localdomain ([43.159.199.34]) by smtp.gmail.com with ESMTPSA id t8-20020aa78f88000000b006e7243bbd35sm8278832pfs.172.2024.04.15.20.16.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 20:16:51 -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 v8 2/3] serial: port: Add support of PNP IRQ to __uart_read_properties() Date: Tue, 16 Apr 2024 11:16:37 +0800 Message-Id: <7f4ca31ef1cab4c6ecad22fafd82117686b696be.1713234515.git.albanhuang@tencent.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-acpi@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: Andy Shevchenko Reviewed-by: Bing Fan Tested-by: Linheng Du --- v6 -> v7: add a "Reviewed-by" tag 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 16 03:16:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guanbing Huang X-Patchwork-Id: 789380 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (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 8963315AF6; Tue, 16 Apr 2024 03:17:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713237435; cv=none; b=Uzba+73RwhtTRIav/7Rpx9XIutMeIgnlIq0G+nR9gniS8tOJvnJMJY8gvmZHIg6yYXTfKEU/ky1gS7bu+P6/1nY/bofIzvPKEMEL58XSIdM5bpE8V2W0cB+9TEE+S6An8dBopd3ILyal3rkr/cMWrf2DfemsZQ4xymiSKgTmRmY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713237435; c=relaxed/simple; bh=9CKw6Ns0L5YcJd4x32/1S2dc5YX3XZimEZZwa+KRFmQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=I1zUh9bDQDbNDdsMHptuPjyMB2NnTOwDGOg5gkTYvb40sVEvSPoKoPQ0HHqX43RdgCPVqotdjkorySJTwcWyMJsv6/WdcLy0wJCmPkeyw1LX+dN/6GVPXVZIrOMJ7TrLCoE6DpXUaHJ2CWVaLlKNbaEROhl0Lz7H2gfonWQZ/jo= 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=kcR4q1ln; arc=none smtp.client-ip=209.85.210.169 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="kcR4q1ln" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-6ed32341906so3456160b3a.1; Mon, 15 Apr 2024 20:17:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713237434; x=1713842234; 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=KtroaYqcnyMYBjqOiDrOLUzCkiqYy/oQzAEHksV6GfE=; b=kcR4q1lnlfXuS4UMeH5f5vkE2Up1kCIW9DT8HeL8/NPdWL/HhkBMaLOO3NxLf7QNSU mWuJk+pUQT8YMhtF7laMzm+zlgs5vg2oSA6cMMpmEeYj4HR/wVj9dygxnYbsIpQG4kTZ IBljhm6tqgKcocwhjtvQTUmMGyxTXAd9VoUu3GcAM843TldtU6UbCLkqSP3xmEhYD1UL YiBUzU72BY8sI2vE6jfB+AHIlV2E9bVbrag23iziaMe4zbFbAyJ3flGSdAzCa7EMlKIE EOuPztqCni/0WY0ybFBLbBrhME+HdGIt+2sB4POKXXFC9PHzxAa1eWG8+l97W+kXSGgR N/YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713237434; x=1713842234; 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=KtroaYqcnyMYBjqOiDrOLUzCkiqYy/oQzAEHksV6GfE=; b=EE7XtO+RkhiXHeWPhPJGtQaw5ddK88Iw6cTi06Lzqtx7fjsn57eBrXT2lLai73RaDh khEOp/Riw5+hBAvo1cSh7rwA7K/adIvP+ZfFVcNmvBFNx/OzezVg5RdSVTgdNrf9Mq5I OLoriw8DopF4UMf1iRQpZQDkhTLarkatQxclY8uoi0XOVEguUhsqCODosah5kaMeOl7F +EFNsAQf6F+u8OkmUG8YOK0wmiw7xkG0QdcNPN3jjGfQSyQ6yzC71sviAYlDlCxLOU48 okTs9HeAcu1TGMH4SQYJfKlt6VDdCG8k20zOpohQ+zOQ7Vc0eqdebelv0S5eSepJcEv0 0vzg== X-Forwarded-Encrypted: i=1; AJvYcCWjQGzBtVPvMXl8UFK6pfLeTAOcivw1BCOfbhFKWBGi0aWJOy5VE7431KESQ/igSd71Ee9nf5gTIBuFJbD81N2EfU/bBsWAQPzN/lGrKw6jn2tFL74h/nY/c9KRpLDYWEKmJInFSv27sBo1 X-Gm-Message-State: AOJu0YyHmRPYc8ryEkIoROBW/rEs10S2/PKTLfg2IurIq3UP1GO2COEV 6Jc+VyMdo3CXQMaLfzlNMOJKxeJd35de5HofsNBsFQr6xrsNi1DI X-Google-Smtp-Source: AGHT+IGZ+pHtvHVAPYrf1SMPpr7pKM/v8Z0oeVFJ8UiC0oaGbmOZGtsexEtbO9Nc7cRX4xEeBcD7jQ== X-Received: by 2002:a05:6a20:3244:b0:1a7:59b5:4276 with SMTP id hm4-20020a056a20324400b001a759b54276mr8858620pzc.54.1713237433780; Mon, 15 Apr 2024 20:17:13 -0700 (PDT) Received: from localhost.localdomain ([43.159.199.34]) by smtp.gmail.com with ESMTPSA id n4-20020a17090a5a8400b002a5d684a6a7sm8658616pji.10.2024.04.15.20.17.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 20:17:13 -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 v8 3/3] serial: 8250_pnp: Support configurable reg shift property Date: Tue, 16 Apr 2024 11:16:59 +0800 Message-Id: <4726ecea8f7bfbfe42501b4f6ad9fe5b38994574.1713234515.git.albanhuang@tencent.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-acpi@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: Andy Shevchenko Reviewed-by: Bing Fan Tested-by: Linheng Du --- v6 -> v7: add a "Reviewed-by" tag 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))