All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Takashi Iwai <tiwai@suse.de>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: kbuild-all@lists.01.org, clang-built-linux@googlegroups.com,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] Input: elants_i2c - Fix NULL dereference at probing
Date: Fri, 28 May 2021 02:59:22 +0800	[thread overview]
Message-ID: <202105280215.fe5ohKNz-lkp@intel.com> (raw)
In-Reply-To: <20210527173153.16470-1-tiwai@suse.de>

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

Hi Takashi,

I love your patch! Perhaps something to improve:

[auto build test WARNING on input/next]
[also build test WARNING on hid/for-next linux/master linus/master v5.13-rc3 next-20210527]
[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/Takashi-Iwai/Input-elants_i2c-Fix-NULL-dereference-at-probing/20210528-013428
base:   https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
config: s390-randconfig-r023-20210526 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 6505c630407c5feec818f0bb1c284f9eeebf2071)
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 s390 cross compiling tool for clang build
        # apt-get install binutils-s390x-linux-gnu
        # https://github.com/0day-ci/linux/commit/8a6af622a33ab5301cea789e5ff6a9afd9b09828
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Takashi-Iwai/Input-elants_i2c-Fix-NULL-dereference-at-probing/20210528-013428
        git checkout 8a6af622a33ab5301cea789e5ff6a9afd9b09828
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=s390 

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

All warnings (new ones prefixed by >>):

   In file included from drivers/input/touchscreen/elants_i2c.c:26:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/s390/include/asm/io.h:80:
   include/asm-generic/io.h:464:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __raw_readb(PCI_IOBASE + addr);
                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:477:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:36:59: note: expanded from macro '__le16_to_cpu'
   #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
                                                             ^
   include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16'
   #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
                                                        ^
   In file included from drivers/input/touchscreen/elants_i2c.c:26:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/s390/include/asm/io.h:80:
   include/asm-generic/io.h:490:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:34:59: note: expanded from macro '__le32_to_cpu'
   #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
                                                             ^
   include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
   #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
                                                        ^
   In file included from drivers/input/touchscreen/elants_i2c.c:26:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/s390/include/asm/io.h:80:
   include/asm-generic/io.h:501:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writeb(value, PCI_IOBASE + addr);
                               ~~~~~~~~~~ ^
   include/asm-generic/io.h:511:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:521:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:609:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsb(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:617:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsw(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:625:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsl(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:634:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesb(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
   include/asm-generic/io.h:643:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesw(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
   include/asm-generic/io.h:652:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesl(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
>> drivers/input/touchscreen/elants_i2c.c:1399:16: warning: cast to smaller integer type 'enum elants_chip_id' from 'const void *' [-Wvoid-pointer-to-enum-cast]
           ts->chip_id = (enum elants_chip_id)device_get_match_data(&client->dev);
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   13 warnings generated.


vim +1399 drivers/input/touchscreen/elants_i2c.c

  1371	
  1372	static int elants_i2c_probe(struct i2c_client *client,
  1373				    const struct i2c_device_id *id)
  1374	{
  1375		union i2c_smbus_data dummy;
  1376		struct elants_data *ts;
  1377		unsigned long irqflags;
  1378		int error;
  1379	
  1380		/* Don't bind to i2c-hid compatible devices, these are handled by the i2c-hid drv. */
  1381		if (elants_acpi_is_hid_device(&client->dev)) {
  1382			dev_warn(&client->dev, "This device appears to be an I2C-HID device, not binding\n");
  1383			return -ENODEV;
  1384		}
  1385	
  1386		if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
  1387			dev_err(&client->dev, "I2C check functionality error\n");
  1388			return -ENXIO;
  1389		}
  1390	
  1391		ts = devm_kzalloc(&client->dev, sizeof(struct elants_data), GFP_KERNEL);
  1392		if (!ts)
  1393			return -ENOMEM;
  1394	
  1395		mutex_init(&ts->sysfs_mutex);
  1396		init_completion(&ts->cmd_done);
  1397	
  1398		ts->client = client;
> 1399		ts->chip_id = (enum elants_chip_id)device_get_match_data(&client->dev);
  1400		i2c_set_clientdata(client, ts);
  1401	
  1402		ts->vcc33 = devm_regulator_get(&client->dev, "vcc33");
  1403		if (IS_ERR(ts->vcc33)) {
  1404			error = PTR_ERR(ts->vcc33);
  1405			if (error != -EPROBE_DEFER)
  1406				dev_err(&client->dev,
  1407					"Failed to get 'vcc33' regulator: %d\n",
  1408					error);
  1409			return error;
  1410		}
  1411	
  1412		ts->vccio = devm_regulator_get(&client->dev, "vccio");
  1413		if (IS_ERR(ts->vccio)) {
  1414			error = PTR_ERR(ts->vccio);
  1415			if (error != -EPROBE_DEFER)
  1416				dev_err(&client->dev,
  1417					"Failed to get 'vccio' regulator: %d\n",
  1418					error);
  1419			return error;
  1420		}
  1421	
  1422		ts->reset_gpio = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_LOW);
  1423		if (IS_ERR(ts->reset_gpio)) {
  1424			error = PTR_ERR(ts->reset_gpio);
  1425	
  1426			if (error == -EPROBE_DEFER)
  1427				return error;
  1428	
  1429			if (error != -ENOENT && error != -ENOSYS) {
  1430				dev_err(&client->dev,
  1431					"failed to get reset gpio: %d\n",
  1432					error);
  1433				return error;
  1434			}
  1435	
  1436			ts->keep_power_in_suspend = true;
  1437		}
  1438	
  1439		error = elants_i2c_power_on(ts);
  1440		if (error)
  1441			return error;
  1442	
  1443		error = devm_add_action(&client->dev, elants_i2c_power_off, ts);
  1444		if (error) {
  1445			dev_err(&client->dev,
  1446				"failed to install power off action: %d\n", error);
  1447			elants_i2c_power_off(ts);
  1448			return error;
  1449		}
  1450	
  1451		/* Make sure there is something at this address */
  1452		if (i2c_smbus_xfer(client->adapter, client->addr, 0,
  1453				   I2C_SMBUS_READ, 0, I2C_SMBUS_BYTE, &dummy) < 0) {
  1454			dev_err(&client->dev, "nothing at this address\n");
  1455			return -ENXIO;
  1456		}
  1457	
  1458		error = elants_i2c_initialize(ts);
  1459		if (error) {
  1460			dev_err(&client->dev, "failed to initialize: %d\n", error);
  1461			return error;
  1462		}
  1463	
  1464		ts->input = devm_input_allocate_device(&client->dev);
  1465		if (!ts->input) {
  1466			dev_err(&client->dev, "Failed to allocate input device\n");
  1467			return -ENOMEM;
  1468		}
  1469	
  1470		ts->input->name = "Elan Touchscreen";
  1471		ts->input->id.bustype = BUS_I2C;
  1472	
  1473		/* Multitouch input params setup */
  1474	
  1475		input_set_abs_params(ts->input, ABS_MT_POSITION_X, 0, ts->x_max, 0, 0);
  1476		input_set_abs_params(ts->input, ABS_MT_POSITION_Y, 0, ts->y_max, 0, 0);
  1477		input_set_abs_params(ts->input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
  1478		input_set_abs_params(ts->input, ABS_MT_PRESSURE, 0, 255, 0, 0);
  1479		input_set_abs_params(ts->input, ABS_MT_TOOL_TYPE,
  1480				     0, MT_TOOL_PALM, 0, 0);
  1481	
  1482		touchscreen_parse_properties(ts->input, true, &ts->prop);
  1483	
  1484		if (ts->chip_id == EKTF3624 && ts->phy_x && ts->phy_y) {
  1485			/* calculate resolution from size */
  1486			ts->x_res = DIV_ROUND_CLOSEST(ts->prop.max_x, ts->phy_x);
  1487			ts->y_res = DIV_ROUND_CLOSEST(ts->prop.max_y, ts->phy_y);
  1488		}
  1489	
  1490		input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->x_res);
  1491		input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->y_res);
  1492		input_abs_set_res(ts->input, ABS_MT_TOUCH_MAJOR, ts->major_res);
  1493	
  1494		error = input_mt_init_slots(ts->input, MAX_CONTACT_NUM,
  1495					    INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED);
  1496		if (error) {
  1497			dev_err(&client->dev,
  1498				"failed to initialize MT slots: %d\n", error);
  1499			return error;
  1500		}
  1501	
  1502		error = input_register_device(ts->input);
  1503		if (error) {
  1504			dev_err(&client->dev,
  1505				"unable to register input device: %d\n", error);
  1506			return error;
  1507		}
  1508	
  1509		/*
  1510		 * Platform code (ACPI, DTS) should normally set up interrupt
  1511		 * for us, but in case it did not let's fall back to using falling
  1512		 * edge to be compatible with older Chromebooks.
  1513		 */
  1514		irqflags = irq_get_trigger_type(client->irq);
  1515		if (!irqflags)
  1516			irqflags = IRQF_TRIGGER_FALLING;
  1517	
  1518		error = devm_request_threaded_irq(&client->dev, client->irq,
  1519						  NULL, elants_i2c_irq,
  1520						  irqflags | IRQF_ONESHOT,
  1521						  client->name, ts);
  1522		if (error) {
  1523			dev_err(&client->dev, "Failed to register interrupt\n");
  1524			return error;
  1525		}
  1526	
  1527		/*
  1528		 * Systems using device tree should set up wakeup via DTS,
  1529		 * the rest will configure device as wakeup source by default.
  1530		 */
  1531		if (!client->dev.of_node)
  1532			device_init_wakeup(&client->dev, true);
  1533	
  1534		error = devm_device_add_group(&client->dev, &elants_attribute_group);
  1535		if (error) {
  1536			dev_err(&client->dev, "failed to create sysfs attributes: %d\n",
  1537				error);
  1538			return error;
  1539		}
  1540	
  1541		return 0;
  1542	}
  1543	

---
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: 34365 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: kernel test robot <lkp@intel.com>
To: kbuild-all@lists.01.org
Subject: Re: [PATCH v2] Input: elants_i2c - Fix NULL dereference at probing
Date: Fri, 28 May 2021 02:59:22 +0800	[thread overview]
Message-ID: <202105280215.fe5ohKNz-lkp@intel.com> (raw)
In-Reply-To: <20210527173153.16470-1-tiwai@suse.de>

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

Hi Takashi,

I love your patch! Perhaps something to improve:

[auto build test WARNING on input/next]
[also build test WARNING on hid/for-next linux/master linus/master v5.13-rc3 next-20210527]
[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/Takashi-Iwai/Input-elants_i2c-Fix-NULL-dereference-at-probing/20210528-013428
base:   https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
config: s390-randconfig-r023-20210526 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 6505c630407c5feec818f0bb1c284f9eeebf2071)
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 s390 cross compiling tool for clang build
        # apt-get install binutils-s390x-linux-gnu
        # https://github.com/0day-ci/linux/commit/8a6af622a33ab5301cea789e5ff6a9afd9b09828
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Takashi-Iwai/Input-elants_i2c-Fix-NULL-dereference-at-probing/20210528-013428
        git checkout 8a6af622a33ab5301cea789e5ff6a9afd9b09828
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=s390 

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

All warnings (new ones prefixed by >>):

   In file included from drivers/input/touchscreen/elants_i2c.c:26:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/s390/include/asm/io.h:80:
   include/asm-generic/io.h:464:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __raw_readb(PCI_IOBASE + addr);
                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:477:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:36:59: note: expanded from macro '__le16_to_cpu'
   #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
                                                             ^
   include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16'
   #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
                                                        ^
   In file included from drivers/input/touchscreen/elants_i2c.c:26:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/s390/include/asm/io.h:80:
   include/asm-generic/io.h:490:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:34:59: note: expanded from macro '__le32_to_cpu'
   #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
                                                             ^
   include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
   #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
                                                        ^
   In file included from drivers/input/touchscreen/elants_i2c.c:26:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/s390/include/asm/io.h:80:
   include/asm-generic/io.h:501:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writeb(value, PCI_IOBASE + addr);
                               ~~~~~~~~~~ ^
   include/asm-generic/io.h:511:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:521:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:609:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsb(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:617:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsw(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:625:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsl(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:634:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesb(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
   include/asm-generic/io.h:643:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesw(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
   include/asm-generic/io.h:652:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesl(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
>> drivers/input/touchscreen/elants_i2c.c:1399:16: warning: cast to smaller integer type 'enum elants_chip_id' from 'const void *' [-Wvoid-pointer-to-enum-cast]
           ts->chip_id = (enum elants_chip_id)device_get_match_data(&client->dev);
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   13 warnings generated.


vim +1399 drivers/input/touchscreen/elants_i2c.c

  1371	
  1372	static int elants_i2c_probe(struct i2c_client *client,
  1373				    const struct i2c_device_id *id)
  1374	{
  1375		union i2c_smbus_data dummy;
  1376		struct elants_data *ts;
  1377		unsigned long irqflags;
  1378		int error;
  1379	
  1380		/* Don't bind to i2c-hid compatible devices, these are handled by the i2c-hid drv. */
  1381		if (elants_acpi_is_hid_device(&client->dev)) {
  1382			dev_warn(&client->dev, "This device appears to be an I2C-HID device, not binding\n");
  1383			return -ENODEV;
  1384		}
  1385	
  1386		if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
  1387			dev_err(&client->dev, "I2C check functionality error\n");
  1388			return -ENXIO;
  1389		}
  1390	
  1391		ts = devm_kzalloc(&client->dev, sizeof(struct elants_data), GFP_KERNEL);
  1392		if (!ts)
  1393			return -ENOMEM;
  1394	
  1395		mutex_init(&ts->sysfs_mutex);
  1396		init_completion(&ts->cmd_done);
  1397	
  1398		ts->client = client;
> 1399		ts->chip_id = (enum elants_chip_id)device_get_match_data(&client->dev);
  1400		i2c_set_clientdata(client, ts);
  1401	
  1402		ts->vcc33 = devm_regulator_get(&client->dev, "vcc33");
  1403		if (IS_ERR(ts->vcc33)) {
  1404			error = PTR_ERR(ts->vcc33);
  1405			if (error != -EPROBE_DEFER)
  1406				dev_err(&client->dev,
  1407					"Failed to get 'vcc33' regulator: %d\n",
  1408					error);
  1409			return error;
  1410		}
  1411	
  1412		ts->vccio = devm_regulator_get(&client->dev, "vccio");
  1413		if (IS_ERR(ts->vccio)) {
  1414			error = PTR_ERR(ts->vccio);
  1415			if (error != -EPROBE_DEFER)
  1416				dev_err(&client->dev,
  1417					"Failed to get 'vccio' regulator: %d\n",
  1418					error);
  1419			return error;
  1420		}
  1421	
  1422		ts->reset_gpio = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_LOW);
  1423		if (IS_ERR(ts->reset_gpio)) {
  1424			error = PTR_ERR(ts->reset_gpio);
  1425	
  1426			if (error == -EPROBE_DEFER)
  1427				return error;
  1428	
  1429			if (error != -ENOENT && error != -ENOSYS) {
  1430				dev_err(&client->dev,
  1431					"failed to get reset gpio: %d\n",
  1432					error);
  1433				return error;
  1434			}
  1435	
  1436			ts->keep_power_in_suspend = true;
  1437		}
  1438	
  1439		error = elants_i2c_power_on(ts);
  1440		if (error)
  1441			return error;
  1442	
  1443		error = devm_add_action(&client->dev, elants_i2c_power_off, ts);
  1444		if (error) {
  1445			dev_err(&client->dev,
  1446				"failed to install power off action: %d\n", error);
  1447			elants_i2c_power_off(ts);
  1448			return error;
  1449		}
  1450	
  1451		/* Make sure there is something at this address */
  1452		if (i2c_smbus_xfer(client->adapter, client->addr, 0,
  1453				   I2C_SMBUS_READ, 0, I2C_SMBUS_BYTE, &dummy) < 0) {
  1454			dev_err(&client->dev, "nothing at this address\n");
  1455			return -ENXIO;
  1456		}
  1457	
  1458		error = elants_i2c_initialize(ts);
  1459		if (error) {
  1460			dev_err(&client->dev, "failed to initialize: %d\n", error);
  1461			return error;
  1462		}
  1463	
  1464		ts->input = devm_input_allocate_device(&client->dev);
  1465		if (!ts->input) {
  1466			dev_err(&client->dev, "Failed to allocate input device\n");
  1467			return -ENOMEM;
  1468		}
  1469	
  1470		ts->input->name = "Elan Touchscreen";
  1471		ts->input->id.bustype = BUS_I2C;
  1472	
  1473		/* Multitouch input params setup */
  1474	
  1475		input_set_abs_params(ts->input, ABS_MT_POSITION_X, 0, ts->x_max, 0, 0);
  1476		input_set_abs_params(ts->input, ABS_MT_POSITION_Y, 0, ts->y_max, 0, 0);
  1477		input_set_abs_params(ts->input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
  1478		input_set_abs_params(ts->input, ABS_MT_PRESSURE, 0, 255, 0, 0);
  1479		input_set_abs_params(ts->input, ABS_MT_TOOL_TYPE,
  1480				     0, MT_TOOL_PALM, 0, 0);
  1481	
  1482		touchscreen_parse_properties(ts->input, true, &ts->prop);
  1483	
  1484		if (ts->chip_id == EKTF3624 && ts->phy_x && ts->phy_y) {
  1485			/* calculate resolution from size */
  1486			ts->x_res = DIV_ROUND_CLOSEST(ts->prop.max_x, ts->phy_x);
  1487			ts->y_res = DIV_ROUND_CLOSEST(ts->prop.max_y, ts->phy_y);
  1488		}
  1489	
  1490		input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->x_res);
  1491		input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->y_res);
  1492		input_abs_set_res(ts->input, ABS_MT_TOUCH_MAJOR, ts->major_res);
  1493	
  1494		error = input_mt_init_slots(ts->input, MAX_CONTACT_NUM,
  1495					    INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED);
  1496		if (error) {
  1497			dev_err(&client->dev,
  1498				"failed to initialize MT slots: %d\n", error);
  1499			return error;
  1500		}
  1501	
  1502		error = input_register_device(ts->input);
  1503		if (error) {
  1504			dev_err(&client->dev,
  1505				"unable to register input device: %d\n", error);
  1506			return error;
  1507		}
  1508	
  1509		/*
  1510		 * Platform code (ACPI, DTS) should normally set up interrupt
  1511		 * for us, but in case it did not let's fall back to using falling
  1512		 * edge to be compatible with older Chromebooks.
  1513		 */
  1514		irqflags = irq_get_trigger_type(client->irq);
  1515		if (!irqflags)
  1516			irqflags = IRQF_TRIGGER_FALLING;
  1517	
  1518		error = devm_request_threaded_irq(&client->dev, client->irq,
  1519						  NULL, elants_i2c_irq,
  1520						  irqflags | IRQF_ONESHOT,
  1521						  client->name, ts);
  1522		if (error) {
  1523			dev_err(&client->dev, "Failed to register interrupt\n");
  1524			return error;
  1525		}
  1526	
  1527		/*
  1528		 * Systems using device tree should set up wakeup via DTS,
  1529		 * the rest will configure device as wakeup source by default.
  1530		 */
  1531		if (!client->dev.of_node)
  1532			device_init_wakeup(&client->dev, true);
  1533	
  1534		error = devm_device_add_group(&client->dev, &elants_attribute_group);
  1535		if (error) {
  1536			dev_err(&client->dev, "failed to create sysfs attributes: %d\n",
  1537				error);
  1538			return error;
  1539		}
  1540	
  1541		return 0;
  1542	}
  1543	

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

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

  reply	other threads:[~2021-05-27 18:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-27 17:31 [PATCH v2] Input: elants_i2c - Fix NULL dereference at probing Takashi Iwai
2021-05-27 18:59 ` kernel test robot [this message]
2021-05-27 18:59   ` kernel test robot
2021-05-27 19:17 ` kernel test robot
2021-05-27 19:17   ` kernel test robot
2021-05-27 19:19 ` kernel test robot
2021-05-27 19:19   ` kernel test robot
2021-05-27 19:31 ` kernel test robot
2021-05-27 19:31   ` kernel test robot
2021-05-27 20:31 ` Takashi Iwai
2021-05-27 21:30 ` Dmitry Torokhov
2021-05-28  7:08   ` Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202105280215.fe5ohKNz-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=clang-built-linux@googlegroups.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=kbuild-all@lists.01.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.