public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sergey Shtylyov <s.shtylyov@omp.ru>
To: Philipp Stanner <pstanner@redhat.com>,
	Damien Le Moal <dlemoal@kernel.org>,
	Niklas Cassel <cassel@kernel.org>,
	Mikael Pettersson <mikpelinux@gmail.com>
Cc: <linux-ide@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [RFC PATCH 3/3] libata-sff: Simplify request of PCI resources
Date: Thu, 12 Dec 2024 22:26:43 +0300	[thread overview]
Message-ID: <3976ee84-5403-4ece-b341-b265e31e78d9@omp.ru> (raw)
In-Reply-To: <20241204171033.86804-5-pstanner@redhat.com>

On 12/4/24 8:10 PM, Philipp Stanner wrote:

> pcim_iomap_regions() has been deprecated by the PCI subsystem.
> 
> Unfortunately, libata-sff uses quite complicated bit mask magic to
> obtain its PCI resources.
> 
> Restructure and simplify the PCI resource request code.
> 
> Replace pcim_iomap_regions() with pcim_iomap_region().
> 
> Signed-off-by: Philipp Stanner <pstanner@redhat.com>
[...]

> diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
> index 67f277e1c3bf..1d2273c0f447 100644
> --- a/drivers/ata/libata-sff.c
> +++ b/drivers/ata/libata-sff.c
> @@ -2127,6 +2127,73 @@ static bool ata_resources_present(struct pci_dev *pdev, int port)
>  	return true;
>  }
>  
> +static void ata_pci_sff_set_ap_data(struct ata_port *ap, struct ata_host *host,

   Maybe ata_pci_sff_set_port_data()?

> +		struct pci_dev *pdev, unsigned short base)

   Using just 2 tabs here seems to go against the coding style used in libata-sff.c
but no biggie... :-)

> +{
> +	void __iomem *ctl_addr;
> +
> +	ctl_addr = host->iomap[base + 1];
> +	ctl_addr = (void __iomem *)((unsigned long)ctl_addr | ATA_PCI_CTL_OFS);
> +
> +	ap->ioaddr.cmd_addr = host->iomap[base];
> +	ap->ioaddr.altstatus_addr = ctl_addr;
> +	ap->ioaddr.ctl_addr = ctl_addr;
> +
> +	ata_sff_std_ports(&ap->ioaddr);
> +
> +	ata_port_desc(ap, "cmd 0x%llx ctl 0x%llx",
> +		(unsigned long long)pci_resource_start(pdev, base),
> +		(unsigned long long)pci_resource_start(pdev, base + 1));
> +}
> +
> +/*

   Please use /** here -- the comment seems to otherwise match the kernel-doc
format...

> + * ata_pci_sff_obtain_bars - obtain the PCI BARs associated with an ATA port
> + * @pdev: the PCI device
> + * @host: the ATA host
> + * @ap: the ATA port
> + * @port: @ap's port index in @host
> + *
> + * Returns: Number of successfully ioremaped BARs, a negative code on failure
> + */
> +static int ata_pci_sff_obtain_bars(struct pci_dev *pdev, struct ata_host *host,
> +		struct ata_port *ap, unsigned short port)
> +{
> +	int ret = 0, bars_mapped = 0;
> +	unsigned short i, base;
> +	void __iomem *io_tmp;

   Maybe call it iomem instead?

> +	const char *name = dev_driver_string(&pdev->dev);
> +
> +	/*
> +	 * Port can be 0 or 1.
> +	 * Port 0 corresponds to PCI BARs 0 and 1, port 1 to BARs 2 and 3.
> +	 */
> +	base = port * 2;
> +
> +       /*

   Don't indent with spaces please.

> +	* Discard disabled ports. Some controllers show their unused channels
> +	* this way. Disabled ports are made dummy.
> +	*/

   These 3 lines lack a space before *.

[...]
> +	for (i = 0; i < 2; i++) {
> +		io_tmp = pcim_iomap_region(pdev, base + i, name);
> +		ret = PTR_ERR_OR_ZERO(io_tmp);
> +		if (ret != 0)

   != 0 unnecessary.

[...]
> @@ -2148,59 +2215,31 @@ static bool ata_resources_present(struct pci_dev *pdev, int port)
[...]> -	if (!mask) {
> -		dev_err(gdev, "no available native port\n");
> +	if (operational_ports == 0)

   Perhaps:

	if (!operational_ports)

[...]

MBR, Sergey


  reply	other threads:[~2024-12-12 19:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-04 17:10 [RFC PATCH 0/3] ATA: Replace deprecated PCI functions Philipp Stanner
2024-12-04 17:10 ` [RFC PATCH 1/3] ata: Allocate PCI iomap table statically Philipp Stanner
2024-12-04 17:10 ` [RFC PATCH 2/3] ata: Replace deprecated PCI functions Philipp Stanner
2024-12-12 18:20   ` Sergey Shtylyov
2024-12-04 17:10 ` [RFC PATCH 3/3] libata-sff: Simplify request of PCI resources Philipp Stanner
2024-12-12 19:26   ` Sergey Shtylyov [this message]
2024-12-09  1:14 ` [RFC PATCH 0/3] ATA: Replace deprecated PCI functions Damien Le Moal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3976ee84-5403-4ece-b341-b265e31e78d9@omp.ru \
    --to=s.shtylyov@omp.ru \
    --cc=cassel@kernel.org \
    --cc=dlemoal@kernel.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mikpelinux@gmail.com \
    --cc=pstanner@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox