linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] i2c: ismt: Use dma_set_mask_and_coherent
@ 2020-12-03  1:01 Youling Tang
  2020-12-03  5:12 ` kernel test robot
  0 siblings, 1 reply; 2+ messages in thread
From: Youling Tang @ 2020-12-03  1:01 UTC (permalink / raw)
  To: Neil Horman, Seth Heasley; +Cc: Wolfram Sang, linux-i2c, linux-kernel

'pci_set_dma_mask()' + 'pci_set_consistent_dma_mask()' can be replaced by
an equivalent 'dma_set_mask_and_coherent()' which is much less verbose.

Signed-off-by: Youling Tang <tangyouling@loongson.cn>
---
 drivers/i2c/busses/i2c-ismt.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/i2c/busses/i2c-ismt.c b/drivers/i2c/busses/i2c-ismt.c
index a35a27c..5f49830 100644
--- a/drivers/i2c/busses/i2c-ismt.c
+++ b/drivers/i2c/busses/i2c-ismt.c
@@ -903,16 +903,12 @@ ismt_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 		return -ENODEV;
 	}
 
-	if ((pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) != 0) ||
-	    (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)) != 0)) {
-		if ((pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) != 0) ||
-		    (pci_set_consistent_dma_mask(pdev,
-						 DMA_BIT_MASK(32)) != 0)) {
+	if (dma_set_mask_and_coherent(pdev, DMA_BIT_MASK(64)) != 0)
+		if (dma_set_mask_and_coherent(pdev, DMA_BIT_MASK(32)) != 0) {
 			dev_err(&pdev->dev, "pci_set_dma_mask fail %p\n",
 				pdev);
 			return -ENODEV;
 		}
-	}
 
 	err = ismt_dev_init(priv);
 	if (err)
-- 
2.1.0


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

* Re: [PATCH v2] i2c: ismt: Use dma_set_mask_and_coherent
  2020-12-03  1:01 [PATCH v2] i2c: ismt: Use dma_set_mask_and_coherent Youling Tang
@ 2020-12-03  5:12 ` kernel test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2020-12-03  5:12 UTC (permalink / raw)
  To: Youling Tang, Neil Horman, Seth Heasley
  Cc: kbuild-all, clang-built-linux, Wolfram Sang, linux-i2c, linux-kernel

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

Hi Youling,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on wsa/i2c/for-next]
[also build test ERROR on v5.10-rc6 next-20201201]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Youling-Tang/i2c-ismt-Use-dma_set_mask_and_coherent/20201203-090418
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
config: x86_64-randconfig-r031-20201203 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 32c501dd88b62787d3a5ffda7aabcf4650dbe3cd)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # https://github.com/0day-ci/linux/commit/70c09af3590c87f78b3fb025c692195d97696f28
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Youling-Tang/i2c-ismt-Use-dma_set_mask_and_coherent/20201203-090418
        git checkout 70c09af3590c87f78b3fb025c692195d97696f28
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/i2c/busses/i2c-ismt.c:906:32: error: incompatible pointer types passing 'struct pci_dev *' to parameter of type 'struct device *' [-Werror,-Wincompatible-pointer-types]
           if (dma_set_mask_and_coherent(pdev, DMA_BIT_MASK(64)) != 0)
                                         ^~~~
   include/linux/dma-mapping.h:420:60: note: passing argument to parameter 'dev' here
   static inline int dma_set_mask_and_coherent(struct device *dev, u64 mask)
                                                              ^
   drivers/i2c/busses/i2c-ismt.c:907:33: error: incompatible pointer types passing 'struct pci_dev *' to parameter of type 'struct device *' [-Werror,-Wincompatible-pointer-types]
                   if (dma_set_mask_and_coherent(pdev, DMA_BIT_MASK(32)) != 0) {
                                                 ^~~~
   include/linux/dma-mapping.h:420:60: note: passing argument to parameter 'dev' here
   static inline int dma_set_mask_and_coherent(struct device *dev, u64 mask)
                                                              ^
   2 errors generated.

vim +906 drivers/i2c/busses/i2c-ismt.c

   832	
   833	/**
   834	 * ismt_probe() - probe for iSMT devices
   835	 * @pdev: PCI-Express device
   836	 * @id: PCI-Express device ID
   837	 */
   838	static int
   839	ismt_probe(struct pci_dev *pdev, const struct pci_device_id *id)
   840	{
   841		int err;
   842		struct ismt_priv *priv;
   843		unsigned long start, len;
   844	
   845		priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
   846		if (!priv)
   847			return -ENOMEM;
   848	
   849		pci_set_drvdata(pdev, priv);
   850	
   851		i2c_set_adapdata(&priv->adapter, priv);
   852		priv->adapter.owner = THIS_MODULE;
   853		priv->adapter.class = I2C_CLASS_HWMON;
   854		priv->adapter.algo = &smbus_algorithm;
   855		priv->adapter.dev.parent = &pdev->dev;
   856		ACPI_COMPANION_SET(&priv->adapter.dev, ACPI_COMPANION(&pdev->dev));
   857		priv->adapter.retries = ISMT_MAX_RETRIES;
   858	
   859		priv->pci_dev = pdev;
   860	
   861		err = pcim_enable_device(pdev);
   862		if (err) {
   863			dev_err(&pdev->dev, "Failed to enable SMBus PCI device (%d)\n",
   864				err);
   865			return err;
   866		}
   867	
   868		/* enable bus mastering */
   869		pci_set_master(pdev);
   870	
   871		/* Determine the address of the SMBus area */
   872		start = pci_resource_start(pdev, SMBBAR);
   873		len = pci_resource_len(pdev, SMBBAR);
   874		if (!start || !len) {
   875			dev_err(&pdev->dev,
   876				"SMBus base address uninitialized, upgrade BIOS\n");
   877			return -ENODEV;
   878		}
   879	
   880		snprintf(priv->adapter.name, sizeof(priv->adapter.name),
   881			 "SMBus iSMT adapter at %lx", start);
   882	
   883		dev_dbg(&priv->pci_dev->dev, " start=0x%lX\n", start);
   884		dev_dbg(&priv->pci_dev->dev, " len=0x%lX\n", len);
   885	
   886		err = acpi_check_resource_conflict(&pdev->resource[SMBBAR]);
   887		if (err) {
   888			dev_err(&pdev->dev, "ACPI resource conflict!\n");
   889			return err;
   890		}
   891	
   892		err = pci_request_region(pdev, SMBBAR, ismt_driver.name);
   893		if (err) {
   894			dev_err(&pdev->dev,
   895				"Failed to request SMBus region 0x%lx-0x%lx\n",
   896				start, start + len);
   897			return err;
   898		}
   899	
   900		priv->smba = pcim_iomap(pdev, SMBBAR, len);
   901		if (!priv->smba) {
   902			dev_err(&pdev->dev, "Unable to ioremap SMBus BAR\n");
   903			return -ENODEV;
   904		}
   905	
 > 906		if (dma_set_mask_and_coherent(pdev, DMA_BIT_MASK(64)) != 0)
   907			if (dma_set_mask_and_coherent(pdev, DMA_BIT_MASK(32)) != 0) {
   908				dev_err(&pdev->dev, "pci_set_dma_mask fail %p\n",
   909					pdev);
   910				return -ENODEV;
   911			}
   912	
   913		err = ismt_dev_init(priv);
   914		if (err)
   915			return err;
   916	
   917		ismt_hw_init(priv);
   918	
   919		err = ismt_int_init(priv);
   920		if (err)
   921			return err;
   922	
   923		err = i2c_add_adapter(&priv->adapter);
   924		if (err)
   925			return -ENODEV;
   926		return 0;
   927	}
   928	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 38801 bytes --]

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

end of thread, other threads:[~2020-12-03  5:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-03  1:01 [PATCH v2] i2c: ismt: Use dma_set_mask_and_coherent Youling Tang
2020-12-03  5:12 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).