Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp187436lqp; Tue, 11 Jun 2024 00:59:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWh4b6S+RGsdqTdoEVVDY0IM1ApbSy9leXwNQFHYE3WsyqRH3jDkRgstCawqE9+RH+o6LMMEb/MtPh9Jh0ZNHrAlMjVaftvK7zhZkZ3xA== X-Google-Smtp-Source: AGHT+IEugIN8w7Jyq/8ecPJ4461DTrJFojvX6Ct6HxE6anAfY3MUjJhNRLH40CnNDCngEB388M1x X-Received: by 2002:a05:6359:1a84:b0:19f:4150:9096 with SMTP id e5c5f4694b2df-19f415091ffmr698806155d.7.1718092748154; Tue, 11 Jun 2024 00:59:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718092748; cv=pass; d=google.com; s=arc-20160816; b=yaLGVaNvnXOg03Ku7zBpF7Y4qlXm6UBKsJ/HHrLuWev279vqZW1qfQy6I65SBDHmkB njQ8po+1o4JmYex+Jsoc343H+nhrqWRDReyv9VBmz1Ul6KWt62qYnoItSB0IB8sQ8tvt BL2DXOHb/mDL2YklF/nqrNjB4d9MtZL4hQ/QWa7gpXNTw6wODzORHp5vlVD34yx/IGvt 9qEkrgNyvNkQmdVq7QVY16+m2TNTfla2ahNNZAeI0JwL+ajHk9t3/UapJ00/CHRJ4jKn eqWSqKDb3gybELMPqkUOKCJ+RamUQPC0oa1OhQso6MWNHBuK7PsX1ZdPXzieJCIVDVqH i7JA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id; bh=d5Wm7OMeX6zk0x9ibqIrwPq0dr9kqWdXX7o1Kro22Zo=; fh=xOo8f4Ne5uR/vcFRlMmpEfET+TCrYTY2Q8RFj0hTRg0=; b=WIotbwxnaKAdXfNHfvyocX9JgzZmcMxBcbjAfgTGjRWb93eM8kkRqwCesHHvuX3VlR 8aosdfBeo92/qiesAJ8LGJhmO4VUNjkwFM8FIqIdF1mRlGQWFxLnpDP3N/myfNwExvWc 7dD/uaroGuTpXtp/X0R7Ayz/KOd3ntbNpxkASyP1oSQIP7igjteRkdF+6JwrQinqnQZC XTTeEIQOV+A/D2lfI0V5w7Xvv9tz+h0EjT7xgv21cTXPQdj6GkdT12E+9mc4pJ+40WM7 k4ikINBRqWPFn8CV2wgc8e/YpzzvC1IolcRcFXJHpFBa7WL/urJX8a3Db3oDHTs4CRJu 1Ssw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-209387-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209387-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6e599ea7367si6076323a12.839.2024.06.11.00.59.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 00:59:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-209387-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-209387-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209387-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id D5E1AB28BEA for ; Tue, 11 Jun 2024 07:39:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 639D3172BCA; Tue, 11 Jun 2024 07:39:39 +0000 (UTC) Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (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 321FB1E52F; Tue, 11 Jun 2024 07:39:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718091578; cv=none; b=e4sNaP3wB9fw/hji5wCk8peTYxVeLAs6On+2jK9b8vds9QVlCEI5obYwnIaRa5LTZnA3fAbGlBOVtAcw7oLRnCYb5QiWHf0P3DWLBYpfbaZqFANhlDp5ZFyH+70ZBk+n8Ziyq4fDSlo6KqVbRBi74W9kDQYWPkhXoYRsMo9vT78= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718091578; c=relaxed/simple; bh=637fUC182B/p/l0RQRC6xJXtXmBqhsWjWsCEztSAM6o=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=oGlGdE8bwd2KZ9knB8gkoMqb6ZIMD7stnxjF6lRU4+XavDwx5wkj7pKhrNfVECEESLbe3akST1gqzZQZanqoTPb8/LSm26vHUmrd5szM7DvJ7T9J54XFj8ax+mJT4j+h4gsOBn+MAXiox1pGdZ/dUUtjGNfGdUlxbXFdMbUKwmY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.208.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-57a1fe63947so949175a12.1; Tue, 11 Jun 2024 00:39:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718091575; x=1718696375; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=d5Wm7OMeX6zk0x9ibqIrwPq0dr9kqWdXX7o1Kro22Zo=; b=t7CAe/Tc+j9b0NfLMwCkEbQ3TAnuPLLVPUiwtAwZ4iakJH7daLPWAvCNtlw7RP2IQv MYfmY3y7bdhuPfQCITlAf35wXHNYwFUfCuLrmS9bPBvlIyzY0pFsIltxj6NbVtBUgdyC ugxjysRp6br2hpJ3CPE5pNo97gJPD3zUBS/kSEcaIvXVeU77lYE92Rcb04PYzcP3EjMW NZWRD7c8fZOAKvDEUWiIwKCRLUa7o2J1ZElkVrKRhOPa6S9eCtNZPP0em7+KTgguFvUp /2NrP0pECMwx565/nhJQ0GjRG6HQJdNL7oHxbuTeQuEgd4hlmLoJeMv0h90AxaU/S68q GdeQ== X-Forwarded-Encrypted: i=1; AJvYcCUc7dcx0NdnAwwz4RVfFy2rBeKeD6yz2NmU55TMB4WtMzw+3p6qOn+a8FLqA2YIBwAKRwYtJrNUSms/Y0C0RI1IhF5JSjQQhi1eSiqF X-Gm-Message-State: AOJu0Yx6jCP4qqW7yWby6MNZatvBhNM0hpIE65CZYMFV+1hXq3CHWkaH EPQNVjln/tmM0w/mHVcD/Nq27C+sDDAsP6yPn6trZkhJRFed3rzf X-Received: by 2002:a50:d681:0:b0:57c:673f:f262 with SMTP id 4fb4d7f45d1cf-57c673ff3a8mr6709485a12.30.1718091575316; Tue, 11 Jun 2024 00:39:35 -0700 (PDT) Received: from ?IPV6:2a0b:e7c0:0:107::aaaa:69? ([2a0b:e7c0:0:107::aaaa:69]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57c69d06729sm5958583a12.56.2024.06.11.00.39.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Jun 2024 00:39:34 -0700 (PDT) Message-ID: <4a748c05-c74c-4b4b-bacf-664b774a490e@kernel.org> Date: Tue, 11 Jun 2024 09:39:34 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/6] tty: serial: 8250: Fix the amount of ports doesn't match the device To: Crescent Hsieh , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org References: <20240607114336.4496-1-crescentcy.hsieh@moxa.com> <20240607114336.4496-2-crescentcy.hsieh@moxa.com> Content-Language: en-US From: Jiri Slaby Autocrypt: addr=jirislaby@kernel.org; keydata= xsFNBE6S54YBEACzzjLwDUbU5elY4GTg/NdotjA0jyyJtYI86wdKraekbNE0bC4zV+ryvH4j rrcDwGs6tFVrAHvdHeIdI07s1iIx5R/ndcHwt4fvI8CL5PzPmn5J+h0WERR5rFprRh6axhOk rSD5CwQl19fm4AJCS6A9GJtOoiLpWn2/IbogPc71jQVrupZYYx51rAaHZ0D2KYK/uhfc6neJ i0WqPlbtIlIrpvWxckucNu6ZwXjFY0f3qIRg3Vqh5QxPkojGsq9tXVFVLEkSVz6FoqCHrUTx wr+aw6qqQVgvT/McQtsI0S66uIkQjzPUrgAEtWUv76rM4ekqL9stHyvTGw0Fjsualwb0Gwdx ReTZzMgheAyoy/umIOKrSEpWouVoBt5FFSZUyjuDdlPPYyPav+h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3BFAVzRQ5nVrrLDAJZ8Y5ioWcm99JtSIIxXxt9FJaGc1Bgsi5K/+dyTKL wLMJgiBzbVx8G+fCJJ9YtlNOPWhbKPlrQ8+AY52Aagi9WNhe6XfJdh5g6ptiOILm330mkR4g W6nEgZVyIyTq3ekOuruftWL99qpP5zi+eNrMmLRQx9iecDNgFr342R9bTDlb1TLuRb+/tJ98 f/bIWIr0cqQmqQ33FgRhrG1+Xml6UXyJ2jExmlO8JljuOGeXYh6ZkIEyzqzffzBLXZCujlYQ DFXpyMNVJ2ZwPmX2mWEoYuaBU0JN7wM+/zWgOf2zRwhEuD3A2cO2PxoiIfyUEfB9SSmffaK/ S4xXoB6wvGENZ85Hg37C7WDNdaAt6Xh2uQIly5grkgvWppkNy4ZHxE+jeNsU7tg= In-Reply-To: <20240607114336.4496-2-crescentcy.hsieh@moxa.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 07. 06. 24, 13:43, Crescent Hsieh wrote: > Normally, the amount of ports is written at the third digit of device ID > of Moxa PCI boards, for example: `0x1121` indicates a 2 ports device. > > However, `CP116E_A_A` and `CP116E_A_B` are two exceptions, which has 8 > ports but the third digit of device ID is `6`. > > This patch fixes the issue above by adding checks. > > Signed-off-by: Crescent Hsieh > --- > drivers/tty/serial/8250/8250_pci.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c > index 40af74b55933..4e88ee07e548 100644 > --- a/drivers/tty/serial/8250/8250_pci.c > +++ b/drivers/tty/serial/8250/8250_pci.c > @@ -2041,6 +2041,10 @@ static int pci_moxa_init(struct pci_dev *dev) > unsigned int num_ports = (device & 0x00F0) >> 4, i; > u8 val, init_mode = MOXA_RS232; > > + if (device == PCI_DEVICE_ID_MOXA_CP116E_A_A || > + device == PCI_DEVICE_ID_MOXA_CP116E_A_B) > + num_ports = 8; Can you perhaps introduce a helper like: static unsigned short mxser_get_nports(struct pci_dev *pdev) { switch (pdev->device) { case ...CP116E_A_A: case ...CP116E_A_B: return 8; } return FIELD_GET(0x00F0, pdev->device); } ? > + > if (!(pci_moxa_supported_rs(dev) & MOXA_SUPP_RS232)) { > init_mode = MOXA_RS422; > } -- js suse labs