From patchwork Tue Dec 7 19:21:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 522361 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20E22C433EF for ; Tue, 7 Dec 2021 19:22:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233740AbhLGTZg (ORCPT ); Tue, 7 Dec 2021 14:25:36 -0500 Received: from mga11.intel.com ([192.55.52.93]:47756 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233172AbhLGTZe (ORCPT ); Tue, 7 Dec 2021 14:25:34 -0500 X-IronPort-AV: E=McAfee;i="6200,9189,10190"; a="235180031" X-IronPort-AV: E=Sophos;i="5.87,295,1631602800"; d="scan'208";a="235180031" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Dec 2021 11:22:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,295,1631602800"; d="scan'208";a="515767191" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 07 Dec 2021 11:22:01 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 8B07B14F; Tue, 7 Dec 2021 21:22:07 +0200 (EET) From: Andy Shevchenko To: Wolfram Sang , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org Cc: Jarkko Nikula , Mika Westerberg , Ajay Gupta Subject: [PATCH v1 01/11] i2c: Introduce common module to instantiate CCGx UCSI Date: Tue, 7 Dec 2021 21:21:49 +0200 Message-Id: <20211207192159.41383-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Introduce a common module to provide an API to instantiate UCSI device for Cypress CCGx Type-C controller. Individual bus drivers need to select this one on demand. Signed-off-by: Andy Shevchenko --- drivers/i2c/busses/Kconfig | 7 +++++++ drivers/i2c/busses/Makefile | 3 +++ drivers/i2c/busses/i2c-ccgx-ucsi.c | 27 +++++++++++++++++++++++++++ drivers/i2c/busses/i2c-ccgx-ucsi.h | 11 +++++++++++ 4 files changed, 48 insertions(+) create mode 100644 drivers/i2c/busses/i2c-ccgx-ucsi.c create mode 100644 drivers/i2c/busses/i2c-ccgx-ucsi.h diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index df89cb809330..0fb2caf7498c 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -9,6 +9,13 @@ menu "I2C Hardware Bus support" comment "PC SMBus host controller drivers" depends on PCI +config I2C_CCGX_UCSI + tristate + help + A common module to provide an API to instantiate UCSI device + for Cypress CCGx Type-C controller. Individual bus drivers + need to select this one on demand. + config I2C_ALI1535 tristate "ALI 1535" depends on PCI diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile index 1d00dce77098..79405cb5d600 100644 --- a/drivers/i2c/busses/Makefile +++ b/drivers/i2c/busses/Makefile @@ -6,6 +6,9 @@ # ACPI drivers obj-$(CONFIG_I2C_SCMI) += i2c-scmi.o +# Auxiliary I2C/SMBus modules +obj-$(CONFIG_I2C_CCGX_UCSI) += i2c-ccgx-ucsi.o + # PC SMBus host controller drivers obj-$(CONFIG_I2C_ALI1535) += i2c-ali1535.o obj-$(CONFIG_I2C_ALI1563) += i2c-ali1563.o diff --git a/drivers/i2c/busses/i2c-ccgx-ucsi.c b/drivers/i2c/busses/i2c-ccgx-ucsi.c new file mode 100644 index 000000000000..141c3d1ef752 --- /dev/null +++ b/drivers/i2c/busses/i2c-ccgx-ucsi.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Instantiate UCSI device for Cypress CCGx Type-C controller. + * Derived from i2c-designware-pcidrv.c and i2c-nvidia-gpu.c. + */ + +#include +#include +#include + +#include "i2c-ccgx-ucsi.h" + +struct software_node; + +struct i2c_client *i2c_new_ccgx_ucsi(struct i2c_adapter *adapter, int irq, + const struct software_node *swnode) +{ + struct i2c_board_info info = {}; + + strscpy(info.type, "ccgx-ucsi", sizeof(info.type)); + info.addr = 0x08; + info.irq = irq; + info.swnode = swnode; + + return i2c_new_client_device(adapter, &info); +} +EXPORT_SYMBOL_GPL(i2c_new_ccgx_ucsi); diff --git a/drivers/i2c/busses/i2c-ccgx-ucsi.h b/drivers/i2c/busses/i2c-ccgx-ucsi.h new file mode 100644 index 000000000000..739ac7a4b117 --- /dev/null +++ b/drivers/i2c/busses/i2c-ccgx-ucsi.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef __I2C_CCGX_UCSI_H_ +#define __I2C_CCGX_UCSI_H_ + +struct i2c_adapter; +struct i2c_client; +struct software_node; + +struct i2c_client *i2c_new_ccgx_ucsi(struct i2c_adapter *adapter, int irq, + const struct software_node *swnode); +#endif /* __I2C_CCGX_UCSI_H_ */ From patchwork Tue Dec 7 19:21:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 521753 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3A08C433FE for ; Tue, 7 Dec 2021 19:22:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240952AbhLGTZl (ORCPT ); Tue, 7 Dec 2021 14:25:41 -0500 Received: from mga09.intel.com ([134.134.136.24]:2078 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240957AbhLGTZk (ORCPT ); Tue, 7 Dec 2021 14:25:40 -0500 X-IronPort-AV: E=McAfee;i="6200,9189,10190"; a="237474909" X-IronPort-AV: E=Sophos;i="5.87,295,1631602800"; d="scan'208";a="237474909" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Dec 2021 11:22:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,295,1631602800"; d="scan'208";a="600287752" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 07 Dec 2021 11:22:01 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 9B0FB109; Tue, 7 Dec 2021 21:22:07 +0200 (EET) From: Andy Shevchenko To: Wolfram Sang , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org Cc: Jarkko Nikula , Mika Westerberg , Ajay Gupta Subject: [PATCH v1 02/11] i2c: designware-pci: Switch to use i2c_new_ccgx_ucsi() Date: Tue, 7 Dec 2021 21:21:50 +0200 Message-Id: <20211207192159.41383-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211207192159.41383-1-andriy.shevchenko@linux.intel.com> References: <20211207192159.41383-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Instead of open coded variant switch to use i2c_new_ccgx_ucsi(). Signed-off-by: Andy Shevchenko --- drivers/i2c/busses/Kconfig | 1 + drivers/i2c/busses/i2c-designware-pcidrv.c | 30 ++++------------------ 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 0fb2caf7498c..451ddec12dba 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -577,6 +577,7 @@ config I2C_DESIGNWARE_PCI tristate "Synopsys DesignWare PCI" depends on PCI select I2C_DESIGNWARE_CORE + select I2C_CCGX_UCSI help If you say yes to this option, support will be included for the Synopsys DesignWare I2C adapter. Only master mode is supported. diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c index 0f409a4c2da0..2952eca87b86 100644 --- a/drivers/i2c/busses/i2c-designware-pcidrv.c +++ b/drivers/i2c/busses/i2c-designware-pcidrv.c @@ -24,6 +24,7 @@ #include #include "i2c-designware-core.h" +#include "i2c-ccgx-ucsi.h" #define DRIVER_NAME "i2c-designware-pci" #define AMD_CLK_RATE_HZ 100000 @@ -118,26 +119,6 @@ static int mfld_setup(struct pci_dev *pdev, struct dw_pci_controller *c) return -ENODEV; } - /* - * TODO find a better way how to deduplicate instantiation - * of USB PD slave device from nVidia GPU driver. - */ -static int navi_amd_register_client(struct dw_i2c_dev *dev) -{ - struct i2c_board_info info; - - memset(&info, 0, sizeof(struct i2c_board_info)); - strscpy(info.type, "ccgx-ucsi", I2C_NAME_SIZE); - info.addr = 0x08; - info.irq = dev->irq; - - dev->slave = i2c_new_client_device(&dev->adapter, &info); - if (IS_ERR(dev->slave)) - return PTR_ERR(dev->slave); - - return 0; -} - static int navi_amd_setup(struct pci_dev *pdev, struct dw_pci_controller *c) { struct dw_i2c_dev *dev = dev_get_drvdata(&pdev->dev); @@ -324,11 +305,10 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev, } if ((dev->flags & MODEL_MASK) == MODEL_AMD_NAVI_GPU) { - r = navi_amd_register_client(dev); - if (r) { - dev_err(dev->dev, "register client failed with %d\n", r); - return r; - } + dev->slave = i2c_new_ccgx_ucsi(&dev->adapter, dev->irq, NULL); + if (IS_ERR(dev->slave)) + return dev_err_probe(&pdev->dev, PTR_ERR(dev->slave), + "register UCSI failed\n"); } pm_runtime_set_autosuspend_delay(&pdev->dev, 1000); From patchwork Tue Dec 7 19:21:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 521756 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F5ADC433F5 for ; Tue, 7 Dec 2021 19:22:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233635AbhLGTZf (ORCPT ); Tue, 7 Dec 2021 14:25:35 -0500 Received: from mga11.intel.com ([192.55.52.93]:47766 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233257AbhLGTZe (ORCPT ); Tue, 7 Dec 2021 14:25:34 -0500 X-IronPort-AV: E=McAfee;i="6200,9189,10190"; a="235180032" X-IronPort-AV: E=Sophos;i="5.87,295,1631602800"; d="scan'208";a="235180032" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Dec 2021 11:22:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,295,1631602800"; d="scan'208";a="611799724" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga004.jf.intel.com with ESMTP; 07 Dec 2021 11:22:01 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id A52E91C5; Tue, 7 Dec 2021 21:22:07 +0200 (EET) From: Andy Shevchenko To: Wolfram Sang , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org Cc: Jarkko Nikula , Mika Westerberg , Ajay Gupta Subject: [PATCH v1 03/11] i2c: designware-pci: Use temporary variable for struct device Date: Tue, 7 Dec 2021 21:21:51 +0200 Message-Id: <20211207192159.41383-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211207192159.41383-1-andriy.shevchenko@linux.intel.com> References: <20211207192159.41383-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Use temporary variable for struct device to make code neater. While at it, rename variable of struct dw_i2c_dev pointer to i_dev. Signed-off-by: Andy Shevchenko --- drivers/i2c/busses/i2c-designware-pcidrv.c | 99 +++++++++++----------- 1 file changed, 50 insertions(+), 49 deletions(-) diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c index 2952eca87b86..f91b352f448a 100644 --- a/drivers/i2c/busses/i2c-designware-pcidrv.c +++ b/drivers/i2c/busses/i2c-designware-pcidrv.c @@ -52,7 +52,7 @@ struct dw_pci_controller { u32 flags; struct dw_scl_sda_cfg *scl_sda_cfg; int (*setup)(struct pci_dev *pdev, struct dw_pci_controller *c); - u32 (*get_clk_rate_khz)(struct dw_i2c_dev *dev); + u32 (*get_clk_rate_khz)(struct dw_i2c_dev *i_dev); }; /* Merrifield HCNT/LCNT/SDA hold time */ @@ -88,23 +88,23 @@ static struct dw_scl_sda_cfg navi_amd_config = { .sda_hold = 0x9, }; -static u32 mfld_get_clk_rate_khz(struct dw_i2c_dev *dev) +static u32 mfld_get_clk_rate_khz(struct dw_i2c_dev *i_dev) { return 25000; } -static u32 navi_amd_get_clk_rate_khz(struct dw_i2c_dev *dev) +static u32 navi_amd_get_clk_rate_khz(struct dw_i2c_dev *i_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); + struct dw_i2c_dev *i_dev = dev_get_drvdata(&pdev->dev); switch (pdev->device) { case 0x0817: - dev->timings.bus_freq_hz = I2C_MAX_STANDARD_MODE_FREQ; + i_dev->timings.bus_freq_hz = I2C_MAX_STANDARD_MODE_FREQ; fallthrough; case 0x0818: case 0x0819: @@ -121,10 +121,10 @@ static int mfld_setup(struct pci_dev *pdev, struct dw_pci_controller *c) static int navi_amd_setup(struct pci_dev *pdev, struct dw_pci_controller *c) { - struct dw_i2c_dev *dev = dev_get_drvdata(&pdev->dev); + struct dw_i2c_dev *i_dev = dev_get_drvdata(&pdev->dev); - dev->flags |= MODEL_AMD_NAVI_GPU; - dev->timings.bus_freq_hz = I2C_MAX_STANDARD_MODE_FREQ; + i_dev->flags |= MODEL_AMD_NAVI_GPU; + i_dev->timings.bus_freq_hz = I2C_MAX_STANDARD_MODE_FREQ; return 0; } @@ -216,14 +216,15 @@ static UNIVERSAL_DEV_PM_OPS(i2c_dw_pm_ops, i2c_dw_pci_suspend, static int i2c_dw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) { - struct dw_i2c_dev *dev; + struct device *dev = &pdev->dev; struct i2c_adapter *adap; int r; struct dw_pci_controller *controller; struct dw_scl_sda_cfg *cfg; + struct dw_i2c_dev *i_dev; if (id->driver_data >= ARRAY_SIZE(dw_pci_controllers)) { - dev_err(&pdev->dev, "%s: invalid driver data %ld\n", __func__, + dev_err(dev, "%s: invalid driver data %ld\n", __func__, id->driver_data); return -EINVAL; } @@ -232,7 +233,7 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev, r = pcim_enable_device(pdev); if (r) { - dev_err(&pdev->dev, "Failed to enable I2C PCI device (%d)\n", + dev_err(dev, "Failed to enable I2C PCI device (%d)\n", r); return r; } @@ -241,26 +242,26 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev, r = pcim_iomap_regions(pdev, 1 << 0, pci_name(pdev)); if (r) { - dev_err(&pdev->dev, "I/O memory remapping failed\n"); + dev_err(dev, "I/O memory remapping failed\n"); return r; } - dev = devm_kzalloc(&pdev->dev, sizeof(struct dw_i2c_dev), GFP_KERNEL); - if (!dev) + i_dev = devm_kzalloc(dev, sizeof(*i_dev), GFP_KERNEL); + if (!i_dev) return -ENOMEM; r = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES); if (r < 0) return r; - dev->get_clk_rate_khz = controller->get_clk_rate_khz; - dev->timings.bus_freq_hz = I2C_MAX_FAST_MODE_FREQ; - dev->base = pcim_iomap_table(pdev)[0]; - dev->dev = &pdev->dev; - dev->irq = pci_irq_vector(pdev, 0); - dev->flags |= controller->flags; + i_dev->get_clk_rate_khz = controller->get_clk_rate_khz; + i_dev->timings.bus_freq_hz = I2C_MAX_FAST_MODE_FREQ; + i_dev->base = pcim_iomap_table(pdev)[0]; + i_dev->dev = dev; + i_dev->irq = pci_irq_vector(pdev, 0); + i_dev->flags |= controller->flags; - pci_set_drvdata(pdev, dev); + pci_set_drvdata(pdev, i_dev); if (controller->setup) { r = controller->setup(pdev, controller); @@ -270,65 +271,65 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev, } } - i2c_dw_adjust_bus_speed(dev); + i2c_dw_adjust_bus_speed(i_dev); - if (has_acpi_companion(&pdev->dev)) - i2c_dw_acpi_configure(&pdev->dev); + if (has_acpi_companion(dev)) + i2c_dw_acpi_configure(dev); - r = i2c_dw_validate_speed(dev); + r = i2c_dw_validate_speed(i_dev); if (r) { pci_free_irq_vectors(pdev); return r; } - i2c_dw_configure(dev); + i2c_dw_configure(i_dev); if (controller->scl_sda_cfg) { cfg = controller->scl_sda_cfg; - dev->ss_hcnt = cfg->ss_hcnt; - dev->fs_hcnt = cfg->fs_hcnt; - dev->ss_lcnt = cfg->ss_lcnt; - dev->fs_lcnt = cfg->fs_lcnt; - dev->sda_hold_time = cfg->sda_hold; + i_dev->ss_hcnt = cfg->ss_hcnt; + i_dev->fs_hcnt = cfg->fs_hcnt; + i_dev->ss_lcnt = cfg->ss_lcnt; + i_dev->fs_lcnt = cfg->fs_lcnt; + i_dev->sda_hold_time = cfg->sda_hold; } - adap = &dev->adapter; + adap = &i_dev->adapter; adap->owner = THIS_MODULE; adap->class = 0; - ACPI_COMPANION_SET(&adap->dev, ACPI_COMPANION(&pdev->dev)); + ACPI_COMPANION_SET(&adap->dev, ACPI_COMPANION(dev)); adap->nr = controller->bus_num; - r = i2c_dw_probe(dev); + r = i2c_dw_probe(i_dev); if (r) { pci_free_irq_vectors(pdev); return r; } - if ((dev->flags & MODEL_MASK) == MODEL_AMD_NAVI_GPU) { - dev->slave = i2c_new_ccgx_ucsi(&dev->adapter, dev->irq, NULL); - if (IS_ERR(dev->slave)) - return dev_err_probe(&pdev->dev, PTR_ERR(dev->slave), - "register UCSI failed\n"); + if ((i_dev->flags & MODEL_MASK) == MODEL_AMD_NAVI_GPU) { + i_dev->slave = i2c_new_ccgx_ucsi(&i_dev->adapter, i_dev->irq, NULL); + if (IS_ERR(i_dev->slave)) + return dev_err_probe(dev, PTR_ERR(i_dev->slave), "register UCSI failed\n"); } - pm_runtime_set_autosuspend_delay(&pdev->dev, 1000); - pm_runtime_use_autosuspend(&pdev->dev); - pm_runtime_put_autosuspend(&pdev->dev); - pm_runtime_allow(&pdev->dev); + pm_runtime_set_autosuspend_delay(dev, 1000); + pm_runtime_use_autosuspend(dev); + pm_runtime_put_autosuspend(dev); + pm_runtime_allow(dev); return 0; } static void i2c_dw_pci_remove(struct pci_dev *pdev) { - struct dw_i2c_dev *dev = pci_get_drvdata(pdev); + struct dw_i2c_dev *i_dev = pci_get_drvdata(pdev); + struct device *dev = &pdev->dev; - dev->disable(dev); - pm_runtime_forbid(&pdev->dev); - pm_runtime_get_noresume(&pdev->dev); + i_dev->disable(i_dev); + pm_runtime_forbid(dev); + pm_runtime_get_noresume(dev); - i2c_del_adapter(&dev->adapter); - devm_free_irq(&pdev->dev, dev->irq, dev); + i2c_del_adapter(&i_dev->adapter); + devm_free_irq(dev, i_dev->irq, i_dev); pci_free_irq_vectors(pdev); } From patchwork Tue Dec 7 19:21:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 521755 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FE4AC433FE for ; Tue, 7 Dec 2021 19:22:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236438AbhLGTZg (ORCPT ); Tue, 7 Dec 2021 14:25:36 -0500 Received: from mga11.intel.com ([192.55.52.93]:47756 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233151AbhLGTZe (ORCPT ); Tue, 7 Dec 2021 14:25:34 -0500 X-IronPort-AV: E=McAfee;i="6200,9189,10190"; a="235180034" X-IronPort-AV: E=Sophos;i="5.87,295,1631602800"; d="scan'208";a="235180034" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Dec 2021 11:22:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,295,1631602800"; d="scan'208";a="502727148" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 07 Dec 2021 11:22:01 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id B3712206; Tue, 7 Dec 2021 21:22:07 +0200 (EET) From: Andy Shevchenko To: Wolfram Sang , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org Cc: Jarkko Nikula , Mika Westerberg , Ajay Gupta Subject: [PATCH v1 04/11] i2c: designware-pci: Convert to use dev_err_probe() Date: Tue, 7 Dec 2021 21:21:52 +0200 Message-Id: <20211207192159.41383-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211207192159.41383-1-andriy.shevchenko@linux.intel.com> References: <20211207192159.41383-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org It's fine to call dev_err_probe() in ->probe() when error code is known. Convert the driver to use dev_err_probe(). Signed-off-by: Andy Shevchenko --- drivers/i2c/busses/i2c-designware-pcidrv.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c index f91b352f448a..e6b4b1a468da 100644 --- a/drivers/i2c/busses/i2c-designware-pcidrv.c +++ b/drivers/i2c/busses/i2c-designware-pcidrv.c @@ -223,28 +223,20 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev, struct dw_scl_sda_cfg *cfg; struct dw_i2c_dev *i_dev; - if (id->driver_data >= ARRAY_SIZE(dw_pci_controllers)) { - dev_err(dev, "%s: invalid driver data %ld\n", __func__, - id->driver_data); - return -EINVAL; - } + if (id->driver_data >= ARRAY_SIZE(dw_pci_controllers)) + return dev_err_probe(dev, -EINVAL, "invalid driver data %ld\n", id->driver_data); controller = &dw_pci_controllers[id->driver_data]; r = pcim_enable_device(pdev); - if (r) { - dev_err(dev, "Failed to enable I2C PCI device (%d)\n", - r); - return r; - } + if (r) + return dev_err_probe(dev, r, "Failed to enable I2C PCI device\n"); pci_set_master(pdev); r = pcim_iomap_regions(pdev, 1 << 0, pci_name(pdev)); - if (r) { - dev_err(dev, "I/O memory remapping failed\n"); - return r; - } + if (r) + return dev_err_probe(dev, r, "I/O memory remapping failed\n"); i_dev = devm_kzalloc(dev, sizeof(*i_dev), GFP_KERNEL); if (!i_dev) From patchwork Tue Dec 7 19:21:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 522358 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66F65C433EF for ; Tue, 7 Dec 2021 19:22:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240978AbhLGTZm (ORCPT ); Tue, 7 Dec 2021 14:25:42 -0500 Received: from mga09.intel.com ([134.134.136.24]:2078 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240934AbhLGTZj (ORCPT ); Tue, 7 Dec 2021 14:25:39 -0500 X-IronPort-AV: E=McAfee;i="6200,9189,10190"; a="237474911" X-IronPort-AV: E=Sophos;i="5.87,295,1631602800"; d="scan'208";a="237474911" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Dec 2021 11:22:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,295,1631602800"; d="scan'208";a="679570102" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga005.jf.intel.com with ESMTP; 07 Dec 2021 11:22:01 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id BD2601CB; Tue, 7 Dec 2021 21:22:07 +0200 (EET) From: Andy Shevchenko To: Wolfram Sang , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org Cc: Jarkko Nikula , Mika Westerberg , Ajay Gupta Subject: [PATCH v1 05/11] i2c: designware-pci: use __maybe_unused for PM functions Date: Tue, 7 Dec 2021 21:21:53 +0200 Message-Id: <20211207192159.41383-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211207192159.41383-1-andriy.shevchenko@linux.intel.com> References: <20211207192159.41383-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Use __maybe_unused for PM functions instead of ifdeffery. Signed-off-by: Andy Shevchenko --- drivers/i2c/busses/i2c-designware-pcidrv.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c index e6b4b1a468da..66dc765b6834 100644 --- a/drivers/i2c/busses/i2c-designware-pcidrv.c +++ b/drivers/i2c/busses/i2c-designware-pcidrv.c @@ -187,8 +187,7 @@ static struct dw_pci_controller dw_pci_controllers[] = { }, }; -#ifdef CONFIG_PM -static int i2c_dw_pci_suspend(struct device *dev) +static int __maybe_unused i2c_dw_pci_suspend(struct device *dev) { struct dw_i2c_dev *i_dev = dev_get_drvdata(dev); @@ -198,7 +197,7 @@ static int i2c_dw_pci_suspend(struct device *dev) return 0; } -static int i2c_dw_pci_resume(struct device *dev) +static int __maybe_unused i2c_dw_pci_resume(struct device *dev) { struct dw_i2c_dev *i_dev = dev_get_drvdata(dev); int ret; @@ -208,7 +207,6 @@ static int i2c_dw_pci_resume(struct device *dev) return ret; } -#endif static UNIVERSAL_DEV_PM_OPS(i2c_dw_pm_ops, i2c_dw_pci_suspend, i2c_dw_pci_resume, NULL); From patchwork Tue Dec 7 19:21:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 521752 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 206FDC433F5 for ; Tue, 7 Dec 2021 19:22:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241001AbhLGTZp (ORCPT ); Tue, 7 Dec 2021 14:25:45 -0500 Received: from mga05.intel.com ([192.55.52.43]:43246 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233479AbhLGTZh (ORCPT ); Tue, 7 Dec 2021 14:25:37 -0500 X-IronPort-AV: E=McAfee;i="6200,9189,10190"; a="323921799" X-IronPort-AV: E=Sophos;i="5.87,295,1631602800"; d="scan'208";a="323921799" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Dec 2021 11:22:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,295,1631602800"; d="scan'208";a="600287775" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 07 Dec 2021 11:22:04 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id D1AB82A0; Tue, 7 Dec 2021 21:22:07 +0200 (EET) From: Andy Shevchenko To: Wolfram Sang , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org Cc: Jarkko Nikula , Mika Westerberg , Ajay Gupta , Lakshmi Sowjanya D Subject: [PATCH v1 06/11] i2c: designware-pci: Fix to change data types of hcnt and lcnt parameters Date: Tue, 7 Dec 2021 21:21:54 +0200 Message-Id: <20211207192159.41383-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211207192159.41383-1-andriy.shevchenko@linux.intel.com> References: <20211207192159.41383-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org From: Lakshmi Sowjanya D The data type of hcnt and lcnt in the struct dw_i2c_dev is of type u16. It's better to have same data type in struct dw_scl_sda_cfg as well. Signed-off-by: Lakshmi Sowjanya D Signed-off-by: Andy Shevchenko Acked-by: Jarkko Nikula --- drivers/i2c/busses/i2c-designware-pcidrv.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c index 66dc765b6834..a0ea71e71886 100644 --- a/drivers/i2c/busses/i2c-designware-pcidrv.c +++ b/drivers/i2c/busses/i2c-designware-pcidrv.c @@ -40,10 +40,10 @@ enum dw_pci_ctl_id_t { }; struct dw_scl_sda_cfg { - u32 ss_hcnt; - u32 fs_hcnt; - u32 ss_lcnt; - u32 fs_lcnt; + u16 ss_hcnt; + u16 fs_hcnt; + u16 ss_lcnt; + u16 fs_lcnt; u32 sda_hold; }; From patchwork Tue Dec 7 19:21:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 522357 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12241C433FE for ; Tue, 7 Dec 2021 19:22:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235447AbhLGTZx (ORCPT ); Tue, 7 Dec 2021 14:25:53 -0500 Received: from mga03.intel.com ([134.134.136.65]:16927 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233960AbhLGTZk (ORCPT ); Tue, 7 Dec 2021 14:25:40 -0500 X-IronPort-AV: E=McAfee;i="6200,9189,10190"; a="237610082" X-IronPort-AV: E=Sophos;i="5.87,295,1631602800"; d="scan'208";a="237610082" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Dec 2021 11:22:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,295,1631602800"; d="scan'208";a="542925266" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 07 Dec 2021 11:22:04 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id DD349315; Tue, 7 Dec 2021 21:22:07 +0200 (EET) From: Andy Shevchenko To: Wolfram Sang , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org Cc: Jarkko Nikula , Mika Westerberg , Ajay Gupta Subject: [PATCH v1 07/11] i2c: designware-pci: Group MODULE_*() macros Date: Tue, 7 Dec 2021 21:21:55 +0200 Message-Id: <20211207192159.41383-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211207192159.41383-1-andriy.shevchenko@linux.intel.com> References: <20211207192159.41383-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org For better maintenance group MODULE_*() macros together. Signed-off-by: Andy Shevchenko Acked-by: Jarkko Nikula --- drivers/i2c/busses/i2c-designware-pcidrv.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c index a0ea71e71886..87bdf7acb612 100644 --- a/drivers/i2c/busses/i2c-designware-pcidrv.c +++ b/drivers/i2c/busses/i2c-designware-pcidrv.c @@ -323,9 +323,6 @@ static void i2c_dw_pci_remove(struct pci_dev *pdev) pci_free_irq_vectors(pdev); } -/* work with hotplug and coldplug */ -MODULE_ALIAS("i2c_designware-pci"); - static const struct pci_device_id i2_designware_pci_ids[] = { /* Medfield */ { PCI_VDEVICE(INTEL, 0x0817), medfield }, @@ -382,9 +379,11 @@ static struct pci_driver dw_i2c_driver = { .pm = &i2c_dw_pm_ops, }, }; - module_pci_driver(dw_i2c_driver); +/* work with hotplug and coldplug */ +MODULE_ALIAS("i2c_designware-pci"); + MODULE_AUTHOR("Baruch Siach "); MODULE_DESCRIPTION("Synopsys DesignWare PCI I2C bus adapter"); MODULE_LICENSE("GPL"); From patchwork Tue Dec 7 19:21:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 521751 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47A65C433EF for ; Tue, 7 Dec 2021 19:22:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234746AbhLGTZx (ORCPT ); Tue, 7 Dec 2021 14:25:53 -0500 Received: from mga09.intel.com ([134.134.136.24]:2083 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234089AbhLGTZk (ORCPT ); Tue, 7 Dec 2021 14:25:40 -0500 X-IronPort-AV: E=McAfee;i="6200,9189,10190"; a="237474912" X-IronPort-AV: E=Sophos;i="5.87,295,1631602800"; d="scan'208";a="237474912" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Dec 2021 11:22:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,295,1631602800"; d="scan'208";a="600287768" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 07 Dec 2021 11:22:04 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id E8AD1325; Tue, 7 Dec 2021 21:22:07 +0200 (EET) From: Andy Shevchenko To: Wolfram Sang , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org Cc: Jarkko Nikula , Mika Westerberg , Ajay Gupta Subject: [PATCH v1 08/11] i2c: designware-pci: Add a note about struct dw_scl_sda_cfg usage Date: Tue, 7 Dec 2021 21:21:56 +0200 Message-Id: <20211207192159.41383-8-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211207192159.41383-1-andriy.shevchenko@linux.intel.com> References: <20211207192159.41383-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Add a note about struct dw_scl_sda_cfg usage to discourage people of using this structure on new platforms. Instead they should try hard to put the needed information into firmware descriptions. Signed-off-by: Andy Shevchenko Acked-by: Jarkko Nikula --- drivers/i2c/busses/i2c-designware-pcidrv.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c index 87bdf7acb612..c1b57895e8ab 100644 --- a/drivers/i2c/busses/i2c-designware-pcidrv.c +++ b/drivers/i2c/busses/i2c-designware-pcidrv.c @@ -39,6 +39,13 @@ enum dw_pci_ctl_id_t { navi_amd, }; +/* + * This is a legacy structure to describe the hardware counters + * to configure signal timings on the bus. For Device Tree platforms + * one should use the respective properties and for ACPI there is + * a set of ACPI methods that provide these counters. No new + * platform should use this structure. + */ struct dw_scl_sda_cfg { u16 ss_hcnt; u16 fs_hcnt; From patchwork Tue Dec 7 19:21:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 522359 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F331C433EF for ; Tue, 7 Dec 2021 19:22:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240959AbhLGTZj (ORCPT ); Tue, 7 Dec 2021 14:25:39 -0500 Received: from mga06.intel.com ([134.134.136.31]:64804 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236233AbhLGTZh (ORCPT ); Tue, 7 Dec 2021 14:25:37 -0500 X-IronPort-AV: E=McAfee;i="6200,9189,10190"; a="298462339" X-IronPort-AV: E=Sophos;i="5.87,295,1631602800"; d="scan'208";a="298462339" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Dec 2021 11:22:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,295,1631602800"; d="scan'208";a="751423313" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 07 Dec 2021 11:22:04 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id F3CB4361; Tue, 7 Dec 2021 21:22:07 +0200 (EET) From: Andy Shevchenko To: Wolfram Sang , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org Cc: Jarkko Nikula , Mika Westerberg , Ajay Gupta Subject: [PATCH v1 09/11] i2c: nvidia-gpu: Switch to use i2c_new_ccgx_ucsi() Date: Tue, 7 Dec 2021 21:21:57 +0200 Message-Id: <20211207192159.41383-9-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211207192159.41383-1-andriy.shevchenko@linux.intel.com> References: <20211207192159.41383-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Instead of open coded variant switch to use i2c_new_ccgx_ucsi(). Signed-off-by: Andy Shevchenko --- drivers/i2c/busses/Kconfig | 1 + drivers/i2c/busses/i2c-nvidia-gpu.c | 26 ++++++-------------------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 451ddec12dba..c2d29d7cdff3 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -252,6 +252,7 @@ config I2C_NFORCE2_S4985 config I2C_NVIDIA_GPU tristate "NVIDIA GPU I2C controller" depends on PCI + select I2C_CCGX_UCSI help If you say yes to this option, support will be included for the NVIDIA GPU I2C controller which is used to communicate with the GPU's diff --git a/drivers/i2c/busses/i2c-nvidia-gpu.c b/drivers/i2c/busses/i2c-nvidia-gpu.c index b5055a3cbd93..8117c3674209 100644 --- a/drivers/i2c/busses/i2c-nvidia-gpu.c +++ b/drivers/i2c/busses/i2c-nvidia-gpu.c @@ -17,6 +17,8 @@ #include +#include "i2c-ccgx-ucsi.h" + /* I2C definitions */ #define I2C_MST_CNTL 0x00 #define I2C_MST_CNTL_GEN_START BIT(0) @@ -266,23 +268,6 @@ static const struct software_node ccgx_node = { .properties = ccgx_props, }; -static int gpu_populate_client(struct gpu_i2c_dev *i2cd, int irq) -{ - i2cd->gpu_ccgx_ucsi = devm_kzalloc(i2cd->dev, - sizeof(*i2cd->gpu_ccgx_ucsi), - GFP_KERNEL); - if (!i2cd->gpu_ccgx_ucsi) - return -ENOMEM; - - strlcpy(i2cd->gpu_ccgx_ucsi->type, "ccgx-ucsi", - sizeof(i2cd->gpu_ccgx_ucsi->type)); - i2cd->gpu_ccgx_ucsi->addr = 0x8; - i2cd->gpu_ccgx_ucsi->irq = irq; - i2cd->gpu_ccgx_ucsi->swnode = &ccgx_node; - i2cd->ccgx_client = i2c_new_client_device(&i2cd->adapter, i2cd->gpu_ccgx_ucsi); - return PTR_ERR_OR_ZERO(i2cd->ccgx_client); -} - static int gpu_i2c_probe(struct pci_dev *pdev, const struct pci_device_id *id) { struct gpu_i2c_dev *i2cd; @@ -328,9 +313,10 @@ static int gpu_i2c_probe(struct pci_dev *pdev, const struct pci_device_id *id) if (status < 0) goto free_irq_vectors; - status = gpu_populate_client(i2cd, pdev->irq); - if (status < 0) { - dev_err(&pdev->dev, "gpu_populate_client failed %d\n", status); + i2cd->ccgx_client = i2c_new_ccgx_ucsi(&i2cd->adapter, pdev->irq, &ccgx_node); + if (IS_ERR(i2cd->ccgx_client)) { + status = dev_err_probe(&pdev->dev, PTR_ERR(i2cd->ccgx_client), + "register UCSI failed\n"); goto del_adapter; } From patchwork Tue Dec 7 19:21:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 522360 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD8AAC433F5 for ; Tue, 7 Dec 2021 19:22:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240948AbhLGTZi (ORCPT ); Tue, 7 Dec 2021 14:25:38 -0500 Received: from mga04.intel.com ([192.55.52.120]:23086 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236178AbhLGTZh (ORCPT ); Tue, 7 Dec 2021 14:25:37 -0500 X-IronPort-AV: E=McAfee;i="6200,9189,10190"; a="236405021" X-IronPort-AV: E=Sophos;i="5.87,295,1631602800"; d="scan'208";a="236405021" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Dec 2021 11:22:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,295,1631602800"; d="scan'208";a="580136677" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga004.fm.intel.com with ESMTP; 07 Dec 2021 11:22:04 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 0A9ED378; Tue, 7 Dec 2021 21:22:08 +0200 (EET) From: Andy Shevchenko To: Wolfram Sang , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org Cc: Jarkko Nikula , Mika Westerberg , Ajay Gupta Subject: [PATCH v1 10/11] i2c: nvidia-gpu: Use temporary variable for struct device Date: Tue, 7 Dec 2021 21:21:58 +0200 Message-Id: <20211207192159.41383-10-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211207192159.41383-1-andriy.shevchenko@linux.intel.com> References: <20211207192159.41383-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Use temporary variable for struct device to make code neater. Signed-off-by: Andy Shevchenko --- drivers/i2c/busses/i2c-nvidia-gpu.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/i2c/busses/i2c-nvidia-gpu.c b/drivers/i2c/busses/i2c-nvidia-gpu.c index 8117c3674209..a82be377146e 100644 --- a/drivers/i2c/busses/i2c-nvidia-gpu.c +++ b/drivers/i2c/busses/i2c-nvidia-gpu.c @@ -270,19 +270,20 @@ static const struct software_node ccgx_node = { static int gpu_i2c_probe(struct pci_dev *pdev, const struct pci_device_id *id) { + struct device *dev = &pdev->dev; struct gpu_i2c_dev *i2cd; int status; - i2cd = devm_kzalloc(&pdev->dev, sizeof(*i2cd), GFP_KERNEL); + i2cd = devm_kzalloc(dev, sizeof(*i2cd), GFP_KERNEL); if (!i2cd) return -ENOMEM; - i2cd->dev = &pdev->dev; - dev_set_drvdata(&pdev->dev, i2cd); + i2cd->dev = dev; + dev_set_drvdata(dev, i2cd); status = pcim_enable_device(pdev); if (status < 0) { - dev_err(&pdev->dev, "pcim_enable_device failed %d\n", status); + dev_err(dev, "pcim_enable_device failed %d\n", status); return status; } @@ -290,13 +291,13 @@ static int gpu_i2c_probe(struct pci_dev *pdev, const struct pci_device_id *id) i2cd->regs = pcim_iomap(pdev, 0, 0); if (!i2cd->regs) { - dev_err(&pdev->dev, "pcim_iomap failed\n"); + dev_err(dev, "pcim_iomap failed\n"); return -ENOMEM; } status = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSI); if (status < 0) { - dev_err(&pdev->dev, "pci_alloc_irq_vectors err %d\n", status); + dev_err(dev, "pci_alloc_irq_vectors err %d\n", status); return status; } @@ -308,22 +309,21 @@ static int gpu_i2c_probe(struct pci_dev *pdev, const struct pci_device_id *id) sizeof(i2cd->adapter.name)); i2cd->adapter.algo = &gpu_i2c_algorithm; i2cd->adapter.quirks = &gpu_i2c_quirks; - i2cd->adapter.dev.parent = &pdev->dev; + i2cd->adapter.dev.parent = dev; status = i2c_add_adapter(&i2cd->adapter); if (status < 0) goto free_irq_vectors; i2cd->ccgx_client = i2c_new_ccgx_ucsi(&i2cd->adapter, pdev->irq, &ccgx_node); if (IS_ERR(i2cd->ccgx_client)) { - status = dev_err_probe(&pdev->dev, PTR_ERR(i2cd->ccgx_client), - "register UCSI failed\n"); + status = dev_err_probe(dev, PTR_ERR(i2cd->ccgx_client), "register UCSI failed\n"); goto del_adapter; } - pm_runtime_set_autosuspend_delay(&pdev->dev, 3000); - pm_runtime_use_autosuspend(&pdev->dev); - pm_runtime_put_autosuspend(&pdev->dev); - pm_runtime_allow(&pdev->dev); + pm_runtime_set_autosuspend_delay(dev, 3000); + pm_runtime_use_autosuspend(dev); + pm_runtime_put_autosuspend(dev); + pm_runtime_allow(dev); return 0; @@ -336,7 +336,7 @@ static int gpu_i2c_probe(struct pci_dev *pdev, const struct pci_device_id *id) static void gpu_i2c_remove(struct pci_dev *pdev) { - struct gpu_i2c_dev *i2cd = dev_get_drvdata(&pdev->dev); + struct gpu_i2c_dev *i2cd = pci_get_drvdata(pdev); pm_runtime_get_noresume(i2cd->dev); i2c_del_adapter(&i2cd->adapter); From patchwork Tue Dec 7 19:21:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 521754 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05144C43217 for ; Tue, 7 Dec 2021 19:22:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240936AbhLGTZj (ORCPT ); Tue, 7 Dec 2021 14:25:39 -0500 Received: from mga02.intel.com ([134.134.136.20]:22343 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240933AbhLGTZh (ORCPT ); Tue, 7 Dec 2021 14:25:37 -0500 X-IronPort-AV: E=McAfee;i="6200,9189,10190"; a="224923751" X-IronPort-AV: E=Sophos;i="5.87,295,1631602800"; d="scan'208";a="224923751" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Dec 2021 11:22:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,295,1631602800"; d="scan'208";a="462437374" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga006.jf.intel.com with ESMTP; 07 Dec 2021 11:22:04 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 15950400; Tue, 7 Dec 2021 21:22:08 +0200 (EET) From: Andy Shevchenko To: Wolfram Sang , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org Cc: Jarkko Nikula , Mika Westerberg , Ajay Gupta Subject: [PATCH v1 11/11] i2c: nvidia-gpu: Convert to use dev_err_probe() Date: Tue, 7 Dec 2021 21:21:59 +0200 Message-Id: <20211207192159.41383-11-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211207192159.41383-1-andriy.shevchenko@linux.intel.com> References: <20211207192159.41383-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org It's fine to call dev_err_probe() in ->probe() when error code is known. Convert the driver to use dev_err_probe(). Signed-off-by: Andy Shevchenko --- drivers/i2c/busses/i2c-nvidia-gpu.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/i2c/busses/i2c-nvidia-gpu.c b/drivers/i2c/busses/i2c-nvidia-gpu.c index a82be377146e..6920c1b9a126 100644 --- a/drivers/i2c/busses/i2c-nvidia-gpu.c +++ b/drivers/i2c/busses/i2c-nvidia-gpu.c @@ -282,24 +282,18 @@ static int gpu_i2c_probe(struct pci_dev *pdev, const struct pci_device_id *id) dev_set_drvdata(dev, i2cd); status = pcim_enable_device(pdev); - if (status < 0) { - dev_err(dev, "pcim_enable_device failed %d\n", status); - return status; - } + if (status < 0) + return dev_err_probe(dev, status, "pcim_enable_device failed\n"); pci_set_master(pdev); i2cd->regs = pcim_iomap(pdev, 0, 0); - if (!i2cd->regs) { - dev_err(dev, "pcim_iomap failed\n"); - return -ENOMEM; - } + if (!i2cd->regs) + return dev_err_probe(dev, -ENOMEM, "pcim_iomap failed\n"); status = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSI); - if (status < 0) { - dev_err(dev, "pci_alloc_irq_vectors err %d\n", status); - return status; - } + if (status < 0) + return dev_err_probe(dev, status, "pci_alloc_irq_vectors err\n"); gpu_enable_i2c_bus(i2cd);