[PATCH 5/7] i3c: mipi-i3c-hci-pci: Define default driver data

Adrian Hunter adrian.hunter at intel.com
Wed Dec 10 00:27:05 PST 2025


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 at 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 at lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-i3c




More information about the linux-i3c mailing list