All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/2] i2c: designware-pci: Group AMD NAVI quirk parts together
@ 2022-09-28 16:21 Andy Shevchenko
  2022-09-28 16:21 ` [PATCH v1 2/2] i2c: designware-pci: Use standard pattern for memory allocation Andy Shevchenko
  2022-09-29  5:52 ` [PATCH v1 1/2] i2c: designware-pci: Group AMD NAVI quirk parts together Jarkko Nikula
  0 siblings, 2 replies; 5+ messages in thread
From: Andy Shevchenko @ 2022-09-28 16:21 UTC (permalink / raw)
  To: Wolfram Sang, Andy Shevchenko, linux-i2c, linux-kernel
  Cc: Jarkko Nikula, Mika Westerberg, Jan Dabros

The code is ogranazed in a way that all related parts to
the certain platform quirk go toghether. This is not the
case for AMD NAVI. Shuffle code to make it happen.

While at it, drop the frequency definition and use
hard coded value as it's done for other platforms and
add a comment to the PCI ID list.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/busses/i2c-designware-pcidrv.c | 30 +++++++++++-----------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
index c001719209be..6e8a9d26563a 100644
--- a/drivers/i2c/busses/i2c-designware-pcidrv.c
+++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
@@ -27,7 +27,6 @@
 #include "i2c-ccgx-ucsi.h"
 
 #define DRIVER_NAME "i2c-designware-pci"
-#define AMD_CLK_RATE_HZ	100000
 
 enum dw_pci_ctl_id_t {
 	medfield,
@@ -100,11 +99,6 @@ static u32 mfld_get_clk_rate_khz(struct dw_i2c_dev *dev)
 	return 25000;
 }
 
-static u32 navi_amd_get_clk_rate_khz(struct dw_i2c_dev *dev)
-{
-	return AMD_CLK_RATE_HZ;
-}
-
 static int mfld_setup(struct pci_dev *pdev, struct dw_pci_controller *c)
 {
 	struct dw_i2c_dev *dev = dev_get_drvdata(&pdev->dev);
@@ -126,15 +120,6 @@ static int mfld_setup(struct pci_dev *pdev, struct dw_pci_controller *c)
 	return -ENODEV;
 }
 
-static int navi_amd_setup(struct pci_dev *pdev, struct dw_pci_controller *c)
-{
-	struct dw_i2c_dev *dev = dev_get_drvdata(&pdev->dev);
-
-	dev->flags |= MODEL_AMD_NAVI_GPU;
-	dev->timings.bus_freq_hz = I2C_MAX_STANDARD_MODE_FREQ;
-	return 0;
-}
-
 static int mrfld_setup(struct pci_dev *pdev, struct dw_pci_controller *c)
 {
 	/*
@@ -159,6 +144,20 @@ static u32 ehl_get_clk_rate_khz(struct dw_i2c_dev *dev)
 	return 100000;
 }
 
+static u32 navi_amd_get_clk_rate_khz(struct dw_i2c_dev *dev)
+{
+	return 100000;
+}
+
+static int navi_amd_setup(struct pci_dev *pdev, struct dw_pci_controller *c)
+{
+	struct dw_i2c_dev *dev = dev_get_drvdata(&pdev->dev);
+
+	dev->flags |= MODEL_AMD_NAVI_GPU;
+	dev->timings.bus_freq_hz = I2C_MAX_STANDARD_MODE_FREQ;
+	return 0;
+}
+
 static struct dw_pci_controller dw_pci_controllers[] = {
 	[medfield] = {
 		.bus_num = -1,
@@ -392,6 +391,7 @@ static const struct pci_device_id i2_designware_pci_ids[] = {
 	{ PCI_VDEVICE(INTEL, 0x4bbe), elkhartlake },
 	{ PCI_VDEVICE(INTEL, 0x4bbf), elkhartlake },
 	{ PCI_VDEVICE(INTEL, 0x4bc0), elkhartlake },
+	/* AMD NAVI */
 	{ PCI_VDEVICE(ATI,  0x7314), navi_amd },
 	{ PCI_VDEVICE(ATI,  0x73a4), navi_amd },
 	{ PCI_VDEVICE(ATI,  0x73e4), navi_amd },
-- 
2.35.1


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

* [PATCH v1 2/2] i2c: designware-pci: Use standard pattern for memory allocation
  2022-09-28 16:21 [PATCH v1 1/2] i2c: designware-pci: Group AMD NAVI quirk parts together Andy Shevchenko
@ 2022-09-28 16:21 ` Andy Shevchenko
  2022-09-29  5:52   ` Jarkko Nikula
  2022-09-29  5:52 ` [PATCH v1 1/2] i2c: designware-pci: Group AMD NAVI quirk parts together Jarkko Nikula
  1 sibling, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2022-09-28 16:21 UTC (permalink / raw)
  To: Wolfram Sang, Andy Shevchenko, linux-i2c, linux-kernel
  Cc: Jarkko Nikula, Mika Westerberg, Jan Dabros

The pattern
	foo = kmalloc(sizeof(*foo), GFP_KERNEL);
has an advantage when foo type is changed. Since we are planning a such,
better to be prepared by using standard pattern for memory allocation.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/busses/i2c-designware-pcidrv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
index 6e8a9d26563a..e499f96506c5 100644
--- a/drivers/i2c/busses/i2c-designware-pcidrv.c
+++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
@@ -263,7 +263,7 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
 		return dev_err_probe(&pdev->dev, r,
 				     "I/O memory remapping failed\n");
 
-	dev = devm_kzalloc(&pdev->dev, sizeof(struct dw_i2c_dev), GFP_KERNEL);
+	dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
 	if (!dev)
 		return -ENOMEM;
 
-- 
2.35.1


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

* Re: [PATCH v1 1/2] i2c: designware-pci: Group AMD NAVI quirk parts together
  2022-09-28 16:21 [PATCH v1 1/2] i2c: designware-pci: Group AMD NAVI quirk parts together Andy Shevchenko
  2022-09-28 16:21 ` [PATCH v1 2/2] i2c: designware-pci: Use standard pattern for memory allocation Andy Shevchenko
@ 2022-09-29  5:52 ` Jarkko Nikula
  2022-09-29  9:42   ` Andy Shevchenko
  1 sibling, 1 reply; 5+ messages in thread
From: Jarkko Nikula @ 2022-09-29  5:52 UTC (permalink / raw)
  To: Andy Shevchenko, Wolfram Sang, linux-i2c, linux-kernel
  Cc: Mika Westerberg, Jan Dabros

On 9/28/22 19:21, Andy Shevchenko wrote:
> The code is ogranazed in a way that all related parts to
> the certain platform quirk go toghether. This is not the
> case for AMD NAVI. Shuffle code to make it happen.
> 
Perhaps you want to change ogranazed and toghether?

> While at it, drop the frequency definition and use
> hard coded value as it's done for other platforms and
> add a comment to the PCI ID list.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>   drivers/i2c/busses/i2c-designware-pcidrv.c | 30 +++++++++++-----------
>   1 file changed, 15 insertions(+), 15 deletions(-)
> 
You may add:
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>

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

* Re: [PATCH v1 2/2] i2c: designware-pci: Use standard pattern for memory allocation
  2022-09-28 16:21 ` [PATCH v1 2/2] i2c: designware-pci: Use standard pattern for memory allocation Andy Shevchenko
@ 2022-09-29  5:52   ` Jarkko Nikula
  0 siblings, 0 replies; 5+ messages in thread
From: Jarkko Nikula @ 2022-09-29  5:52 UTC (permalink / raw)
  To: Andy Shevchenko, Wolfram Sang, linux-i2c, linux-kernel
  Cc: Mika Westerberg, Jan Dabros

On 9/28/22 19:21, Andy Shevchenko wrote:
> The pattern
> 	foo = kmalloc(sizeof(*foo), GFP_KERNEL);
> has an advantage when foo type is changed. Since we are planning a such,
> better to be prepared by using standard pattern for memory allocation.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>   drivers/i2c/busses/i2c-designware-pcidrv.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>

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

* Re: [PATCH v1 1/2] i2c: designware-pci: Group AMD NAVI quirk parts together
  2022-09-29  5:52 ` [PATCH v1 1/2] i2c: designware-pci: Group AMD NAVI quirk parts together Jarkko Nikula
@ 2022-09-29  9:42   ` Andy Shevchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2022-09-29  9:42 UTC (permalink / raw)
  To: Jarkko Nikula
  Cc: Wolfram Sang, linux-i2c, linux-kernel, Mika Westerberg, Jan Dabros

On Thu, Sep 29, 2022 at 08:52:15AM +0300, Jarkko Nikula wrote:
> On 9/28/22 19:21, Andy Shevchenko wrote:
> > The code is ogranazed in a way that all related parts to
> > the certain platform quirk go toghether. This is not the
> > case for AMD NAVI. Shuffle code to make it happen.
> > 
> Perhaps you want to change ogranazed and toghether?

Done in v2, thanks!

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2022-09-29  9:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-28 16:21 [PATCH v1 1/2] i2c: designware-pci: Group AMD NAVI quirk parts together Andy Shevchenko
2022-09-28 16:21 ` [PATCH v1 2/2] i2c: designware-pci: Use standard pattern for memory allocation Andy Shevchenko
2022-09-29  5:52   ` Jarkko Nikula
2022-09-29  5:52 ` [PATCH v1 1/2] i2c: designware-pci: Group AMD NAVI quirk parts together Jarkko Nikula
2022-09-29  9:42   ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.