linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
To: Damien Le Moal <dlemoal@kernel.org>
Cc: lpieralisi@kernel.org, kw@linux.com, kishon@kernel.org,
	bhelgaas@google.com, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH v5 3/9] PCI: endpoint: Pass EPF device ID to the probe function
Date: Fri, 2 Jun 2023 08:49:40 +0530	[thread overview]
Message-ID: <20230602031940.GA5341@thinkpad> (raw)
In-Reply-To: <65ed4b9f-a153-7c7b-6462-a5c11024a1f6@kernel.org>

On Fri, Jun 02, 2023 at 08:16:45AM +0900, Damien Le Moal wrote:
> On 6/1/23 23:57, Manivannan Sadhasivam wrote:
> > Currently, the EPF probe function doesn't get the device ID argument needed
> > to correctly identify the device table ID of the EPF device.
> > 
> > When multiple entries are added to the "struct pci_epf_device_id" table,
> > the probe function needs to identify the correct one. This is achieved by
> > modifying the pci_epf_match_id() function to return the match ID pointer
> > and passing it to the driver's probe function.
> > 
> > pci_epf_device_match() function can return bool based on the return value
> > of pci_epf_match_id().
> > 
> > Reviewed-by: Kishon Vijay Abraham I <kishon@kernel.org>
> > Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> 
> [...]
> 
> >  static int pci_epf_device_match(struct device *dev, struct device_driver *drv)
> > @@ -510,8 +510,12 @@ static int pci_epf_device_match(struct device *dev, struct device_driver *drv)
> >  	struct pci_epf *epf = to_pci_epf(dev);
> >  	struct pci_epf_driver *driver = to_pci_epf_driver(drv);
> >  
> > -	if (driver->id_table)
> > -		return pci_epf_match_id(driver->id_table, epf);
> > +	if (driver->id_table) {
> > +		if (pci_epf_match_id(driver->id_table, epf))
> > +			return true;
> > +		else
> > +			return false;
> 
> 		return pci_epf_match_id(driver->id_table, epf) != NULL;
> 
> is simpler. If you do not like this, at least drop the "else" as it is not
> necessary at all.
> 

I settle for simplicity :) Also, there is a theoretical possibility of passing
NULL as the id->name, so doesn't want to rule out that.

> > +	}
> >  
> >  	return !strcmp(epf->name, drv->name);
> >  }
> > @@ -520,13 +524,15 @@ static int pci_epf_device_probe(struct device *dev)
> >  {
> >  	struct pci_epf *epf = to_pci_epf(dev);
> >  	struct pci_epf_driver *driver = to_pci_epf_driver(dev->driver);
> > +	const struct pci_epf_device_id *id;
> >  
> >  	if (!driver->probe)
> >  		return -ENODEV;
> >  
> >  	epf->driver = driver;
> > +	id = pci_epf_match_id(driver->id_table, epf);
> 
> Not sure that the id variable is that useful.
> 

Thought it makes the code clear but looking again, it doesn't hurt to call match
directly in probe. Will change it in next iteration.

- Mani

> >  
> > -	return driver->probe(epf);
> > +	return driver->probe(epf, id);
> >  }
> 
> -- 
> Damien Le Moal
> Western Digital Research
> 

-- 
மணிவண்ணன் சதாசிவம்

  reply	other threads:[~2023-06-02  3:19 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-01 14:57 [PATCH v5 0/9] Add support for MHI Endpoint function driver Manivannan Sadhasivam
2023-06-01 14:57 ` [PATCH v5 1/9] MAINTAINERS: Add entry for MHI networking drivers under MHI bus Manivannan Sadhasivam
2023-06-01 14:57 ` [PATCH v5 2/9] PCI: endpoint: Add missing documentation about the MSI/MSI-X range Manivannan Sadhasivam
2023-06-01 23:12   ` Damien Le Moal
2023-06-01 14:57 ` [PATCH v5 3/9] PCI: endpoint: Pass EPF device ID to the probe function Manivannan Sadhasivam
2023-06-01 23:16   ` Damien Le Moal
2023-06-02  3:19     ` Manivannan Sadhasivam [this message]
2023-06-01 14:57 ` [PATCH v5 4/9] PCI: endpoint: Warn and return if EPC is started/stopped multiple times Manivannan Sadhasivam
2023-06-01 23:18   ` Damien Le Moal
2023-06-02  3:27     ` Manivannan Sadhasivam
2023-06-01 14:57 ` [PATCH v5 5/9] PCI: endpoint: Add linkdown notifier support Manivannan Sadhasivam
2023-06-01 23:20   ` Damien Le Moal
2023-06-01 14:57 ` [PATCH v5 6/9] PCI: endpoint: Add BME " Manivannan Sadhasivam
2023-06-01 23:21   ` Damien Le Moal
2023-06-01 14:57 ` [PATCH v5 7/9] PCI: qcom-ep: Add support for Link down notification Manivannan Sadhasivam
2023-06-01 23:22   ` Damien Le Moal
2023-06-01 14:57 ` [PATCH v5 8/9] PCI: qcom-ep: Add support for BME notification Manivannan Sadhasivam
2023-06-01 23:22   ` Damien Le Moal
2023-06-01 14:57 ` [PATCH v5 9/9] PCI: endpoint: Add PCI Endpoint function driver for MHI bus Manivannan Sadhasivam
2023-06-01 23:31   ` Damien Le Moal
2023-06-02 11:38     ` Manivannan Sadhasivam
2023-06-02  5:17   ` kernel test robot

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=20230602031940.GA5341@thinkpad \
    --to=manivannan.sadhasivam@linaro.org \
    --cc=bhelgaas@google.com \
    --cc=dlemoal@kernel.org \
    --cc=kishon@kernel.org \
    --cc=kw@linux.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).