public inbox for linux-i3c@lists.infradead.org
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Frank Li <Frank.li@nxp.com>
Cc: <alexandre.belloni@bootlin.com>, <linux-i3c@lists.infradead.org>
Subject: Re: [PATCH 5/7] i3c: mipi-i3c-hci-pci: Define default driver data
Date: Wed, 10 Dec 2025 10:27:05 +0200	[thread overview]
Message-ID: <d727d3ba-be23-4ac4-b693-68f7a0cfea88@intel.com> (raw)
In-Reply-To: <aThQHLHCxp/SU92N@lizhi-Precision-Tower-5810>

On 09/12/2025 18:36, Frank Li wrote:
> On Tue, Dec 09, 2025 at 01:51:02PM +0200, Adrian Hunter wrote:
>> Define default driver data, to save having to repeatedly check for NULL.
>>
>> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
>> ---
>>  drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c | 11 +++++++----
>>  1 file changed, 7 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c b/drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c
>> index dc8ede0f8ad8..ccaec5d3d248 100644
>> --- a/drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c
>> +++ b/drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c
>> @@ -184,6 +184,9 @@ static const struct mipi_i3c_hci_pci_info intel_info = {
>>  	.exit = intel_i3c_exit,
>>  };
>>
>> +static const struct mipi_i3c_hci_pci_info dflt_info = {
>> +};
>> +
>>  static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
>>  				  const struct pci_device_id *id)
>>  {
>> @@ -228,8 +231,8 @@ static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
>>  	if (ret)
>>  		goto err;
>>
>> -	hci->info = (const struct mipi_i3c_hci_pci_info *)id->driver_data;
> 
> I see all devices have driver_data in mipi_i3c_hci_pci_devices()

Seems safer not to assume that.  Alternative is to return an error.

> 
> "
> static const struct pci_device_id mipi_i3c_hci_pci_devices[] = {
>         /* Wildcat Lake-U */
>         { PCI_VDEVICE(INTEL, 0x4d7c), (kernel_ulong_t)&intel_info},
>         { PCI_VDEVICE(INTEL, 0x4d6f), (kernel_ulong_t)&intel_info},
>         /* Panther Lake-H */
>         { PCI_VDEVICE(INTEL, 0xe37c), (kernel_ulong_t)&intel_info},
>         { PCI_VDEVICE(INTEL, 0xe36f), (kernel_ulong_t)&intel_info},
>         /* Panther Lake-P */
>         { PCI_VDEVICE(INTEL, 0xe47c), (kernel_ulong_t)&intel_info},
>         { PCI_VDEVICE(INTEL, 0xe46f), (kernel_ulong_t)&intel_info},
>         /* Nova Lake-S */
>         { PCI_VDEVICE(INTEL, 0x6e2c), (kernel_ulong_t)&intel_info},
>         { PCI_VDEVICE(INTEL, 0x6e2d), (kernel_ulong_t)&intel_info},
>         { },
> };
> "
> 
> Frank
> 
> 
>> -	if (hci->info && hci->info->init) {
>> +	hci->info = (const struct mipi_i3c_hci_pci_info *)id->driver_data ?: &dflt_info;
>> +	if (hci->info->init) {
>>  		ret = hci->info->init(hci);
>>  		if (ret)
>>  			goto err;
>> @@ -244,7 +247,7 @@ static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
>>  	return 0;
>>
>>  err_exit:
>> -	if (hci->info && hci->info->exit)
>> +	if (hci->info->exit)
>>  		hci->info->exit(hci);
>>  err:
>>  	platform_device_put(hci->pdev);
>> @@ -258,7 +261,7 @@ static void mipi_i3c_hci_pci_remove(struct pci_dev *pci)
>>  	struct platform_device *pdev = hci->pdev;
>>  	int dev_id = pdev->id;
>>
>> -	if (hci->info && hci->info->exit)
>> +	if (hci->info->exit)
>>  		hci->info->exit(hci);
>>
>>  	platform_device_unregister(pdev);
>> --
>> 2.51.0
>>
>>
>> --
>> linux-i3c mailing list
>> linux-i3c@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-i3c


-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

  reply	other threads:[~2025-12-10  8:27 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-09 11:50 [PATCH 0/7] i3c: mipi-i3c-hci-pci: Define Multi-Bus Instances for Intel controllers Adrian Hunter
2025-12-09 11:50 ` [PATCH 1/7] i3c: mipi-i3c-hci: Remove duplicate blank lines Adrian Hunter
2025-12-09 16:21   ` Frank Li
2025-12-09 11:50 ` [PATCH 2/7] i3c: mipi-i3c-hci: Stop reading Extended Capabilities if capability ID is 0 Adrian Hunter
2025-12-09 16:22   ` Frank Li
2025-12-09 11:51 ` [PATCH 3/7] i3c: mipi-i3c-hci: Quieten initialization messages Adrian Hunter
2025-12-09 16:25   ` Frank Li
2025-12-09 11:51 ` [PATCH 4/7] i3c: mipi-i3c-hci: Allow for Multi-Bus Instances Adrian Hunter
2025-12-09 11:51 ` [PATCH 5/7] i3c: mipi-i3c-hci-pci: Define default driver data Adrian Hunter
2025-12-09 16:36   ` Frank Li
2025-12-10  8:27     ` Adrian Hunter [this message]
2025-12-10 15:14       ` Frank Li
2025-12-09 11:51 ` [PATCH 6/7] i3c: mipi-i3c-hci-pci: Add support for Multi-Bus Instances Adrian Hunter
2025-12-09 17:10   ` Frank Li
2025-12-10  9:17     ` Adrian Hunter
2025-12-10 15:13       ` Frank Li
2025-12-10  6:01   ` Krzysztof Kozlowski
2025-12-09 11:51 ` [PATCH 7/7] i3c: mipi-i3c-hci-pci: Define Multi-Bus Instances for Intel controllers Adrian Hunter

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=d727d3ba-be23-4ac4-b693-68f7a0cfea88@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=Frank.li@nxp.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=linux-i3c@lists.infradead.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