From patchwork Fri Apr 12 03:24:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guanbing Huang X-Patchwork-Id: 788837 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.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 1D2F8182C3; Fri, 12 Apr 2024 03:24:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712892268; cv=none; b=XMQf4+Pqv9wfsvCcGQ8mqd6mUgV+LUCNk+iauH0tRUcjLgaoRzY/h6HPvFyPTMmcTuQs6qZhTys1S+/rcfItaFFcp8aP39+edm46avD4BD3YRYmnCCpoM8gARQpkYFVQEKx32abexMnq5aLGiEgDs2l9AGLAv7eYjejk6RpgwgY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712892268; c=relaxed/simple; bh=yZw4Jjq2AN5aMLxXNpw7l65AU8UStiEiNBekBWTKNnM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=BtYNRgEUlOY4RWgN4SCPQkn4T/N3J2lAmgo5OwN0I0K806Sn3ggGeLz+hn2jIzRLT44IUjgldGeUQCHyDzmp90nzuA8RO+ZrHdhGDc5A5Dk8sYo5L3SQgMt+mXtEYFZsnDEnCXPacoiHvTi+Qx4zU+JFbqUCOH9jUiZ4W5OWMfs= 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=ku7wpXi4; arc=none smtp.client-ip=209.85.216.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="ku7wpXi4" Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-2a53a4a283eso364235a91.0; Thu, 11 Apr 2024 20:24:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712892266; x=1713497066; 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=SvnG0oBIU6cI316sayoppBSPEOQpaDRnhL9Ex14LSPQ=; b=ku7wpXi458pC4dNh8aUdp4n9mhPh06h8A+EN3p/hrDjaprisW/dCbMoMpAeXb2wiEL ra/EMf6Kj0DvJmiw7M/0jZVHUeDmBac1zLyPe98Gf7qoAiaO92iDoCWLklDWxl21T7l9 EwzD/skV3yCN1TjD7//1B6t1+nSH5ZQt63Zih4vu3HHF8qCzXYYXpVepKQlzJPIkuOZb aWgSgBHKWLQlEdWqopRIqAgqX31q9AhIXsVKMnCZ50VGCwCtA+BkUjwKFoOuFYenKEka i9ATUQ2H+IA+GH8SYNMazRgi8OI7pKYgrUkKpTvTQx+pZDGUMIBUbhAW8EVcdQ7XoGOn VIFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712892266; x=1713497066; 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=SvnG0oBIU6cI316sayoppBSPEOQpaDRnhL9Ex14LSPQ=; b=T1hWoIAS6abe1AtLnHhzDI2AhUti8Rm5mmPHFq3JgYzOEZcvcx/sgO2r/YTvov8rSj 0kjlyzGgyaMRtVC9FV/H+mYmnUxQ2sSImXrwmDN99F9Pi+nEWE8H3YsLGxxICvWgyyMK VXwCJ1GmxDLZROYHHrkYCswHuGiBoTL1RWW2L5ng+T2V1cpJJhIT7YAsJ/nV+tqSTd8V ueJotBBnkH0ZikHFuYhNNFOyXAUuWR0OYfU9wgaAPgvGPcbPLr2b3RWdrX7lwygrsXxM Y01X8V9d6qZudsuuYfxDAleCSb8AyjtIBFfNby2ZDon+eyPcMJOGulhMUSF3M53nLbhY WuXw== X-Forwarded-Encrypted: i=1; AJvYcCXFAwYg6hDeVGnNZnHBKQhkyTXVzmTr7EhqP5kx6zlZMy6HS0hRfuEwh9kOdusKodHg5dYvfs8fSS4aqmCwp2fs193y3/d8ZRcDVG+upGdXUzr9ntrwsZ+O31spzawMFsfBhjQGKNZJnSIM X-Gm-Message-State: AOJu0YxsEZd68AhBeVVMGoYrO2Y4cFUewgdGiS7zn0lNuiXjg5CLRRGC inKPGlkwdg0cb0ZapA/tFCI7A5RrOaZ3Pznl3zXF3rF1ML0SwpcP X-Google-Smtp-Source: AGHT+IHCtEPhlaKAqj5m6cf/8AGbOFoG7qLEIifTkstc9gu8pZVor5qAw3TSDH4UndgKuwIzGjtP4g== X-Received: by 2002:a17:90b:1bcc:b0:2a6:a760:79f1 with SMTP id oa12-20020a17090b1bcc00b002a6a76079f1mr1379889pjb.4.1712892266394; Thu, 11 Apr 2024 20:24:26 -0700 (PDT) Received: from localhost.localdomain ([43.159.199.34]) by smtp.gmail.com with ESMTPSA id v19-20020a17090a459300b002a2a845868asm1813035pjg.57.2024.04.11.20.24.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 20:24:25 -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 v7 1/3] PNP: Add dev_is_pnp() macro Date: Fri, 12 Apr 2024 11:24:12 +0800 Message-Id: <41d35ec4ff287ad6ab4fe7360fc80fb604a12958.1712890897.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: Andy Shevchenko Reviewed-by: Bing Fan Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202404100523.b06UvPSB-lkp@intel.com/ Tested-by: Linheng Du --- 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 Fri Apr 12 03:24:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guanbing Huang X-Patchwork-Id: 788348 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (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 195E218AF9; Fri, 12 Apr 2024 03:24:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712892292; cv=none; b=e3pw5AxmU/bFBgMmGLn4aCfAo619u929hq/PYynFbHgHgHy4AGEeiCrhR1FYVktAQANEk9o+IvNIGsyEqW4ameDRW/OZrM8ZouKpE169hcHOLcxScNDaHUj5JuB63eeMVCGqPulwu9N17AZ8Gv08cjeNMaY0MnSSXdvvuUodYdc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712892292; c=relaxed/simple; bh=IP6VT8eDRdbw1bmE8R8GFrhgxSOo7uUT+zH5dbw9MG4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=EBljar6iawJEX9ayJN6A7oXccenUrp2clqbBO+pJ1uEOEZtfMkId+4kEEkr5Ft9xs7Fz3wfCIWYf+uPetCKvhnupXmttdhzWGzRYvnrOo51zte9Jdnxq92s3n53T3fh1ZwEHGcCk0uwt3TTj6qitIeig7Wpxi2Csdn/FynloIVI= 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=LU6AVIHK; arc=none smtp.client-ip=209.85.216.47 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="LU6AVIHK" Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-2a53eda3272so304613a91.2; Thu, 11 Apr 2024 20:24:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712892290; x=1713497090; 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=LU6AVIHK1ln7phY3euqrUntX6kKydNmgQ4k663kvozjNR1lsmXIPvBo2d+c3IUwL5C nC7wZIYt507bVXj29v5Fgw9IqTSyo+oGAj1qXtBf04d2ccZL0SfQyedCMTBcVwzWj9uJ zmDmV9DILSlqD41h2cvBWGOfPnMJ0sFYrKyRceO6eKdNcY5L+xcO7De1i2ucV4x7lg2q lAivmCO4isEV18IW1Jya2TsqloGY+u7y0J5G7Yp8yHGkdnFvpdeP9rUuA+TsRLBo8PTa irYQz4GTWwqh1O8ju2E3bWjGJYGQLeNyoevfk3SWW+/M7o/Vzo/LTc+p1BBiyegMpjpF nvnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712892290; x=1713497090; 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=qBwRNVK8BwEp8CzUrEkStyUXbLnoxqIVkDVC0u7alktq14fSpMS2/rdFwj9gyYBX24 PkkApclICy58DYjwIsDBUc2R2BRCZOXScyZTVBazABRtB1RHqJKYCWs0lG5CQs+agTPO /bVxot4lbQcW2bIgy/hIRBUKhYFkMeKuXTwLxcm+vJ8od0jFNPaaFgUnBVlcHfVxEA2e g4o8JUmbmnchwKdoNUiNGp1w3vIH1gkDg7CvjBi566n8v2ShD90EdOBzib01gBwfP+AO hGoktXcF9nQS9Gqc1m47wmn0UOC9QP7bX9wALoWeiFIGgdmMap4YMLRyFafIsapQqL0Z jeQw== X-Forwarded-Encrypted: i=1; AJvYcCUmLISf1louDv3aA00SoK5UbecwcSjg8lzwTiNyJlJ5fGJbRMZsqTCrkYpoE3MsR9WLVngQ5u/BaU8O8Tmloxy3/NcCzqQMnhve0BCRt5bZ9M8y1Xf2/2WClLX2ZxBdi4Kzrmnm4tzySULY X-Gm-Message-State: AOJu0Yyi+PTdA8E+8Qwj/oAMT4wfp5DAT9n3YFkw9wRl8aF3VKJ1ZqSR CsznTES0BUnVOak80DG4xBp+9ERkF0M7DphoaArpS3P4vJfPyVYd X-Google-Smtp-Source: AGHT+IFBF4TQo9lpQg97wiRjqzlRudbtZGx4sY2yXC9yCRKikKLnSmD3iC2AwsTThUk7aCZYStTTdg== X-Received: by 2002:a17:90a:ca8e:b0:2a2:9843:927c with SMTP id y14-20020a17090aca8e00b002a29843927cmr1271826pjt.27.1712892290294; Thu, 11 Apr 2024 20:24:50 -0700 (PDT) Received: from localhost.localdomain ([43.159.199.34]) by smtp.gmail.com with ESMTPSA id n18-20020a6563d2000000b005dccf9e3b74sm1512070pgv.92.2024.04.11.20.24.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 20:24:49 -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 v7 2/3] serial: port: Add support of PNP IRQ to __uart_read_properties() Date: Fri, 12 Apr 2024 11:24:35 +0800 Message-Id: <814c5890d8613bfd890ba330c394e8d685c495b5.1712890897.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 Fri Apr 12 03:24:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guanbing Huang X-Patchwork-Id: 788836 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 C324C1B81F; Fri, 12 Apr 2024 03:25:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712892315; cv=none; b=OAdqam3s6OKO+gvdEKY2FiZKtV0vEbq1R1OABu7XzUvh9zo3PCRojbaKlp/KMh+JVrTpybQLJMydomau4sl8ANWIHdRAvrHB508mpd2N/l4jQaX5VDkA7+YVhq+p5/ydtJcmDmCrlHtDRjF65KDaXTCLFhLAu3AfNhkFMf8zJPI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712892315; c=relaxed/simple; bh=9CKw6Ns0L5YcJd4x32/1S2dc5YX3XZimEZZwa+KRFmQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=Pyh/ftPjBDDjaWBWRXeIcJjNdgEzvl2bdvUSCxh1IE4xD4vVFA/6SJLywJ6S82gSzq8KFi/gUnvfiXkA7i2x9Ei1Cn5NDEGM5gtJtz8dnMNuRq9AdmCrjE2VneWwdQGofRLrHqDDctdW+LJR/7qZNZmBJA4rKfojOpFio01f2KU= 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=i/8zladS; arc=none smtp.client-ip=209.85.214.173 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="i/8zladS" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1e5aa82d1f6so779335ad.0; Thu, 11 Apr 2024 20:25:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712892313; x=1713497113; 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=i/8zladSzdgTy++lKKjKSaAgQU0Xigqp8hqPz8yHxmpZsw1QdSPmTGB0ynt9eihr7e HfFVqN8XeiEkCzgpj/fe2VffnCKHhkXeviGEOmINBTxl0nJT5tl24OOCOdBMWTUQ2cK+ M+Wo0gURf8bUqTqRXJtkUjQiRQhbCGR4XL3kiK6fZhg2suEyBGCZpeIl8MnxfjmWYKJh tjkUi1jUEPdJEIFU10rc/YWtAz+jm9Xl6AoxDTjCbaFjaC7clhbRKzayQf7A03bs6k86 EO8BaY+rOWyLpWJn6G2zTOYsbo2SKxlDYM5ejCrQYguUi0Sb9fFV6fYhAWlzfjTCzm0W la5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712892313; x=1713497113; 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=nUmWp6jpa2QuFoz6Bnqe0rVSk2sT5S4eTjYNxAkh47UL6NrOIjiJtz6/L2swMTuFKo 2cDwNRaHewSlRKRUCi4xQw5RrY0JSOuHGGI0tAfwLRlamFH9G4/tKJpD7pveUMPSdHKa zxvzVtVlZJJ6xO+dBOwZzK7sFgWLWpTxG3jGbk4QrVrUsiwXibfz8IZHM7eb+RzpCnHw iCaxzmKeEuGh8/eiOqVBAZWOGe95mhVpWCAV+NrvqnRuOV6IRNN+0IKk3ftavLjrWhRa mKSQ6n7ByADonaXlQqrHzAwX8okdCkDmOXX1z47CmdY9ZGduT/e7Iiv28+d+eTDQBWzT HUFQ== X-Forwarded-Encrypted: i=1; AJvYcCXjMBdsXyU7a7dJLLC/2rfbDBxyQi3DGYuvBuEc6tRwC0zG2zqIT3+1VbcwoiEpwC+jcHv5Kc8iIvm0CL6b9vfEsOiVBUUlmkhrDT/B1VKInUgRJXCU47fX17tcFoUVXic3++xhjNh6HnhG X-Gm-Message-State: AOJu0YynY/t7H8kso7L4fdz2d8AnP+rfzyaQltMAo1XOTzV48dZ1QT06 j8U97aNelO23+5D/70UW594/PNW1gaFJe7eLpxT8zsM5J0kN06ya X-Google-Smtp-Source: AGHT+IEMY4KXDDxPHpKKS/lhFPTqrezbvbayAaJrcKofTls9PlHc7z5waKT5mT0P09D+6Cxaw9fIlg== X-Received: by 2002:a17:902:ce8d:b0:1e4:3909:47e9 with SMTP id f13-20020a170902ce8d00b001e4390947e9mr6194342plg.11.1712892313048; Thu, 11 Apr 2024 20:25:13 -0700 (PDT) Received: from localhost.localdomain ([43.159.199.34]) by smtp.gmail.com with ESMTPSA id q7-20020a170902a3c700b001e2b36d0c8esm1972448plb.7.2024.04.11.20.25.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 20:25:12 -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 v7 3/3] serial: 8250_pnp: Support configurable reg shift property Date: Fri, 12 Apr 2024 11:24:58 +0800 Message-Id: <8c4bdae45363f4beb885fa5c88682b630a35f9af.1712890897.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))