public inbox for linux-next@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/3] Fix build issue when CONFIG_MODULES is not set
@ 2025-06-06 21:31 Pratap Nirujogi
  2025-06-06 21:31 ` [PATCH v3 1/3] i2c: designware: Initialize adapter name only when " Pratap Nirujogi
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Pratap Nirujogi @ 2025-06-06 21:31 UTC (permalink / raw)
  To: andi.shyti, rdunlap, hdegoede, ilpo.jarvinen, sfr, linux-next
  Cc: linux-i2c, platform-driver-x86, linux-kernel, benjamin.chan,
	bin.du, gjorgji.rosikopulos, king.li, dantony, Pratap Nirujogi

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 v2 -> v3:

* Update commit text for patch 1/3


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

-- 
2.43.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v3 1/3] i2c: designware: Initialize adapter name only when not set
  2025-06-06 21:31 [PATCH v3 0/3] Fix build issue when CONFIG_MODULES is not set Pratap Nirujogi
@ 2025-06-06 21:31 ` Pratap Nirujogi
  2025-06-06 21:31 ` [PATCH v3 2/3] i2c: amd-isp: Initialize unique adpater name Pratap Nirujogi
  2025-06-06 21:31 ` [PATCH v3 3/3] platform/x86: Use i2c adapter name to fix build errors Pratap Nirujogi
  2 siblings, 0 replies; 7+ messages in thread
From: Pratap Nirujogi @ 2025-06-06 21:31 UTC (permalink / raw)
  To: andi.shyti, rdunlap, hdegoede, ilpo.jarvinen, sfr, linux-next
  Cc: linux-i2c, platform-driver-x86, linux-kernel, benjamin.chan,
	bin.du, gjorgji.rosikopulos, king.li, dantony, Pratap Nirujogi

Check if the adapter name is already set in the driver prior to
initializing with generic name in i2c_dw_probe_master(). This
check allows to retain the unique adapter name driver has
initialized, which platform driver can use to distinguish it
from other i2c designware adapters.

Tested-by: Randy Dunlap <rdunlap@infradead.org
Signed-off-by: Pratap Nirujogi <pratap.nirujogi@amd.com>
---
 drivers/i2c/busses/i2c-designware-master.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busses/i2c-designware-master.c
index c5394229b77f..9d7d9e47564a 100644
--- a/drivers/i2c/busses/i2c-designware-master.c
+++ b/drivers/i2c/busses/i2c-designware-master.c
@@ -1042,8 +1042,9 @@ int i2c_dw_probe_master(struct dw_i2c_dev *dev)
 	if (ret)
 		return ret;
 
-	snprintf(adap->name, sizeof(adap->name),
-		 "Synopsys DesignWare I2C adapter");
+	if (!adap->name[0])
+		scnprintf(adap->name, sizeof(adap->name),
+			  "Synopsys DesignWare I2C adapter");
 	adap->retries = 3;
 	adap->algo = &i2c_dw_algo;
 	adap->quirks = &i2c_dw_quirks;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v3 2/3] i2c: amd-isp: Initialize unique adpater name
  2025-06-06 21:31 [PATCH v3 0/3] Fix build issue when CONFIG_MODULES is not set Pratap Nirujogi
  2025-06-06 21:31 ` [PATCH v3 1/3] i2c: designware: Initialize adapter name only when " Pratap Nirujogi
@ 2025-06-06 21:31 ` Pratap Nirujogi
  2025-06-09  8:36   ` Ilpo Järvinen
  2025-06-06 21:31 ` [PATCH v3 3/3] platform/x86: Use i2c adapter name to fix build errors Pratap Nirujogi
  2 siblings, 1 reply; 7+ messages in thread
From: Pratap Nirujogi @ 2025-06-06 21:31 UTC (permalink / raw)
  To: andi.shyti, rdunlap, hdegoede, ilpo.jarvinen, sfr, linux-next
  Cc: linux-i2c, platform-driver-x86, linux-kernel, benjamin.chan,
	bin.du, gjorgji.rosikopulos, king.li, dantony, Pratap Nirujogi

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.

Tested-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Pratap Nirujogi <pratap.nirujogi@amd.com>
---
 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
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v3 3/3] platform/x86: Use i2c adapter name to fix build errors
  2025-06-06 21:31 [PATCH v3 0/3] Fix build issue when CONFIG_MODULES is not set Pratap Nirujogi
  2025-06-06 21:31 ` [PATCH v3 1/3] i2c: designware: Initialize adapter name only when " Pratap Nirujogi
  2025-06-06 21:31 ` [PATCH v3 2/3] i2c: amd-isp: Initialize unique adpater name Pratap Nirujogi
@ 2025-06-06 21:31 ` Pratap Nirujogi
  2 siblings, 0 replies; 7+ messages in thread
From: Pratap Nirujogi @ 2025-06-06 21:31 UTC (permalink / raw)
  To: andi.shyti, rdunlap, hdegoede, ilpo.jarvinen, sfr, linux-next
  Cc: linux-i2c, platform-driver-x86, linux-kernel, benjamin.chan,
	bin.du, gjorgji.rosikopulos, king.li, dantony, Pratap Nirujogi

Use adapater->name inplace of adapter->owner->name to fix
build issues when CONFIG_MODULES is not defined.

Fixes: 90b85567e457 ("platform/x86: Add AMD ISP platform config for OV05C10")
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Link: https://lore.kernel.org/all/04577a46-9add-420c-b181-29bad582026d@infradead.org
Tested-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Pratap Nirujogi <pratap.nirujogi@amd.com>
---
 drivers/platform/x86/amd/amd_isp4.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/amd/amd_isp4.c b/drivers/platform/x86/amd/amd_isp4.c
index 0cc01441bcbb..9f291aeb35f1 100644
--- a/drivers/platform/x86/amd/amd_isp4.c
+++ b/drivers/platform/x86/amd/amd_isp4.c
@@ -11,6 +11,7 @@
 #include <linux/mutex.h>
 #include <linux/platform_device.h>
 #include <linux/property.h>
+#include <linux/soc/amd/isp4_misc.h>
 #include <linux/string.h>
 #include <linux/types.h>
 #include <linux/units.h>
@@ -151,7 +152,7 @@ MODULE_DEVICE_TABLE(acpi, amdisp_sensor_ids);
 
 static inline bool is_isp_i2c_adapter(struct i2c_adapter *adap)
 {
-	return !strcmp(adap->owner->name, "i2c_designware_amdisp");
+	return !strcmp(adap->name, AMDISP_I2C_ADAP_NAME);
 }
 
 static void instantiate_isp_i2c_client(struct amdisp_platform *isp4_platform,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 2/3] i2c: amd-isp: Initialize unique adpater name
  2025-06-06 21:31 ` [PATCH v3 2/3] i2c: amd-isp: Initialize unique adpater name Pratap Nirujogi
@ 2025-06-09  8:36   ` Ilpo Järvinen
  2025-06-09  9:38     ` Ilpo Järvinen
  0 siblings, 1 reply; 7+ messages in thread
From: Ilpo Järvinen @ 2025-06-09  8:36 UTC (permalink / raw)
  To: Pratap Nirujogi
  Cc: andi.shyti, rdunlap, Hans de Goede, sfr, linux-next, linux-i2c,
	platform-driver-x86, LKML, benjamin.chan, bin.du,
	gjorgji.rosikopulos, king.li, dantony

On Fri, 6 Jun 2025, 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.
> 
> Tested-by: Randy Dunlap <rdunlap@infradead.org>
> Signed-off-by: Pratap Nirujogi <pratap.nirujogi@amd.com>
> ---
>  drivers/i2c/busses/i2c-designware-amdisp.c |  2 ++
>  include/linux/soc/amd/isp4_misc.h          | 12 ++++++++++++

You forgot to add this new file into MAINTAINERS file.

>  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
> 

-- 
 i.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 2/3] i2c: amd-isp: Initialize unique adpater name
  2025-06-09  8:36   ` Ilpo Järvinen
@ 2025-06-09  9:38     ` Ilpo Järvinen
  2025-06-09 15:24       ` Nirujogi, Pratap
  0 siblings, 1 reply; 7+ messages in thread
From: Ilpo Järvinen @ 2025-06-09  9:38 UTC (permalink / raw)
  To: Pratap Nirujogi
  Cc: andi.shyti, rdunlap, Hans de Goede, sfr, linux-next, linux-i2c,
	platform-driver-x86, LKML, benjamin.chan, bin.du,
	gjorgji.rosikopulos, king.li, dantony

[-- Attachment #1: Type: text/plain, Size: 2342 bytes --]

On Mon, 9 Jun 2025, Ilpo Järvinen wrote:

> On Fri, 6 Jun 2025, Pratap Nirujogi wrote:

You also have a typo in the subject, adpater -> adapter.

> > 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.
> > 
> > Tested-by: Randy Dunlap <rdunlap@infradead.org>
> > Signed-off-by: Pratap Nirujogi <pratap.nirujogi@amd.com>
> > ---
> >  drivers/i2c/busses/i2c-designware-amdisp.c |  2 ++
> >  include/linux/soc/amd/isp4_misc.h          | 12 ++++++++++++
> 
> You forgot to add this new file into MAINTAINERS file.
> 
> >  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
> > 
> 
> 

-- 
 i.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 2/3] i2c: amd-isp: Initialize unique adpater name
  2025-06-09  9:38     ` Ilpo Järvinen
@ 2025-06-09 15:24       ` Nirujogi, Pratap
  0 siblings, 0 replies; 7+ messages in thread
From: Nirujogi, Pratap @ 2025-06-09 15:24 UTC (permalink / raw)
  To: Ilpo Järvinen, Pratap Nirujogi
  Cc: andi.shyti, rdunlap, Hans de Goede, sfr, linux-next, linux-i2c,
	platform-driver-x86, LKML, benjamin.chan, bin.du,
	gjorgji.rosikopulos, king.li, dantony

Hi Ilpo,

On 6/9/2025 5:38 AM, Ilpo Järvinen wrote:
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
> 
> 
> On Mon, 9 Jun 2025, Ilpo Järvinen wrote:
> 
>> On Fri, 6 Jun 2025, Pratap Nirujogi wrote:
> 
> You also have a typo in the subject, adpater -> adapter.
> 
Thanks for catching this typo, will fix it in the next patch.

>>> 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.
>>>
>>> Tested-by: Randy Dunlap <rdunlap@infradead.org>
>>> Signed-off-by: Pratap Nirujogi <pratap.nirujogi@amd.com>
>>> ---
>>>   drivers/i2c/busses/i2c-designware-amdisp.c |  2 ++
>>>   include/linux/soc/amd/isp4_misc.h          | 12 ++++++++++++
>>
>> You forgot to add this new file into MAINTAINERS file.
>>
Thanks, will take care of this too in the next v4 patch.

Thanks,
Pratap

>>>   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
>>>
>>
>>
> 
> --
>   i.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-06-09 15:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-06 21:31 [PATCH v3 0/3] Fix build issue when CONFIG_MODULES is not set Pratap Nirujogi
2025-06-06 21:31 ` [PATCH v3 1/3] i2c: designware: Initialize adapter name only when " Pratap Nirujogi
2025-06-06 21:31 ` [PATCH v3 2/3] i2c: amd-isp: Initialize unique adpater name Pratap Nirujogi
2025-06-09  8:36   ` Ilpo Järvinen
2025-06-09  9:38     ` Ilpo Järvinen
2025-06-09 15:24       ` Nirujogi, Pratap
2025-06-06 21:31 ` [PATCH v3 3/3] platform/x86: Use i2c adapter name to fix build errors Pratap Nirujogi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox