mbox series

[v2,0/3] Fix build issue when CONFIG_MODULES is not set

Message ID 20250603214611.3039787-1-pratap.nirujogi@amd.com
Headers show
Series Fix build issue when CONFIG_MODULES is not set | expand

Message

Pratap Nirujogi June 3, 2025, 9:40 p.m. UTC
When CONFIG_MODULES is not defined, 'adap->owner->name' used in amd_isp4 platform
driver will not be valid and is resulting in build failures.

../drivers/platform/x86/amd/amd_isp4.c: In function 'is_isp_i2c_adapter':
../drivers/platform/x86/amd/amd_isp4.c:154:35: error: invalid use of undefined type 'struct module'
  154 |         return !strcmp(adap->owner->name, "i2c_designware_amdisp");
      |                                   ^~

To fix this issue, need to make changes both in platform and i2c driver modules.

* In the amd_isp4 x86/platform driver, replace 'adap->owner->name' with 'adap->name', this removes
the hard dependency on 'struct module'.
* In i2c amdisp driver, initialize unique name to i2c adapter and also make a change in
i2c-designware-common to avoid overwriting with generic name when adap->name[] is already set.

---

Changes v1 -> v2:

* Replace snprintf with scnprintf
* Add new isp4 specific misc header file to include the adapter name
* Remove 'Fixes' and 'Link' tags from i2c patches

---

Pratap Nirujogi (3):
  i2c: designware: Initialize adapter name only when not set
  i2c: amd-isp: Initialize unique adpater name
  platform/x86: Use i2c adapter name to fix build errors

 drivers/i2c/busses/i2c-designware-amdisp.c |  2 ++
 drivers/i2c/busses/i2c-designware-master.c |  5 +++--
 drivers/platform/x86/amd/amd_isp4.c        |  3 ++-
 include/linux/soc/amd/isp4_misc.h          | 12 ++++++++++++
 4 files changed, 19 insertions(+), 3 deletions(-)
 create mode 100644 include/linux/soc/amd/isp4_misc.h

Comments

Nirujogi, Pratap June 4, 2025, 2:25 a.m. UTC | #1
On 6/3/2025 6:48 PM, Randy Dunlap wrote:
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
> 
> 
> On 6/3/25 2:40 PM, Pratap Nirujogi wrote:
>> Initialize unique name for amdisp i2c adapter, which is used
>> in the platform driver to detect the matching adapter for
>> i2c_client creation.
>>
>> Add definition of amdisp i2c adapter name in a new header file
>> (include/linux/soc/amd/isp4_misc.h) as it is referred in different
>> driver modules.
>>
>> Signed-off-by: Pratap Nirujogi <pratap.nirujogi@amd.com>
> 
> Tested-by: Randy Dunlap <rdunlap@infradead.org>
> 
Thanks Randy!

> Thanks.
> 
>> ---
>>   drivers/i2c/busses/i2c-designware-amdisp.c |  2 ++
>>   include/linux/soc/amd/isp4_misc.h          | 12 ++++++++++++
>>   2 files changed, 14 insertions(+)
>>   create mode 100644 include/linux/soc/amd/isp4_misc.h
>>
>> diff --git a/drivers/i2c/busses/i2c-designware-amdisp.c b/drivers/i2c/busses/i2c-designware-amdisp.c
>> index ad6f08338124..450793d5f839 100644
>> --- a/drivers/i2c/busses/i2c-designware-amdisp.c
>> +++ b/drivers/i2c/busses/i2c-designware-amdisp.c
>> @@ -8,6 +8,7 @@
>>   #include <linux/module.h>
>>   #include <linux/platform_device.h>
>>   #include <linux/pm_runtime.h>
>> +#include <linux/soc/amd/isp4_misc.h>
>>
>>   #include "i2c-designware-core.h"
>>
>> @@ -62,6 +63,7 @@ static int amd_isp_dw_i2c_plat_probe(struct platform_device *pdev)
>>
>>        adap = &isp_i2c_dev->adapter;
>>        adap->owner = THIS_MODULE;
>> +     scnprintf(adap->name, sizeof(adap->name), AMDISP_I2C_ADAP_NAME);
>>        ACPI_COMPANION_SET(&adap->dev, ACPI_COMPANION(&pdev->dev));
>>        adap->dev.of_node = pdev->dev.of_node;
>>        /* use dynamically allocated adapter id */
>> diff --git a/include/linux/soc/amd/isp4_misc.h b/include/linux/soc/amd/isp4_misc.h
>> new file mode 100644
>> index 000000000000..6738796986a7
>> --- /dev/null
>> +++ b/include/linux/soc/amd/isp4_misc.h
>> @@ -0,0 +1,12 @@
>> +// SPDX-License-Identifier: GPL-2.0+
>> +
>> +/*
>> + * Copyright (C) 2025 Advanced Micro Devices, Inc.
>> + */
>> +
>> +#ifndef __SOC_ISP4_MISC_H
>> +#define __SOC_ISP4_MISC_H
>> +
>> +#define AMDISP_I2C_ADAP_NAME "AMDISP DesignWare I2C adapter"
>> +
>> +#endif
> 
> --
> ~Randy