Re: [PATCH] spidev: Introduce "linux,spidev-name" property for device tree of spidev.

From: kernel test robot
Date: Sun May 19 2024 - 17:18:21 EST


Hi,

kernel test robot noticed the following build errors:

[auto build test ERROR on broonie-spi/for-next]
[also build test ERROR on linus/master v6.9 next-20240517]
[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#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/egyszeregy-freemail-hu/spidev-Introduce-linux-spidev-name-property-for-device-tree-of-spidev/20240520-021957
base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
patch link: https://lore.kernel.org/r/20240519181039.23147-1-egyszeregy%40freemail.hu
patch subject: [PATCH] spidev: Introduce "linux,spidev-name" property for device tree of spidev.
config: arm64-defconfig (https://download.01.org/0day-ci/archive/20240520/202405200442.ydsaBrDZ-lkp@xxxxxxxxx/config)
compiler: aarch64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240520/202405200442.ydsaBrDZ-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202405200442.ydsaBrDZ-lkp@xxxxxxxxx/

All errors (new ones prefixed by >>):

drivers/spi/spidev.c: In function 'spidev_probe':
>> drivers/spi/spidev.c:812:45: error: incompatible type for argument 1 of 'device_create'
812 | dev = device_create(spidev_class, &spi->dev, spidev->devt,
| ^~~~~~~~~~~~
| |
| struct class
In file included from drivers/spi/spidev.c:13:
include/linux/device.h:1175:35: note: expected 'const struct class *' but argument is of type 'struct class'
1175 | device_create(const struct class *cls, struct device *parent, dev_t devt,
| ~~~~~~~~~~~~~~~~~~~~^~~
drivers/spi/spidev.c:816:45: error: incompatible type for argument 1 of 'device_create'
816 | dev = device_create(spidev_class, &spi->dev, spidev->devt,
| ^~~~~~~~~~~~
| |
| struct class
include/linux/device.h:1175:35: note: expected 'const struct class *' but argument is of type 'struct class'
1175 | device_create(const struct class *cls, struct device *parent, dev_t devt,
| ~~~~~~~~~~~~~~~~~~~~^~~


vim +/device_create +812 drivers/spi/spidev.c

767
768 static int spidev_probe(struct spi_device *spi)
769 {
770 int ret;
771 const char *name;
772 int (*match)(struct device *dev);
773 struct spidev_data *spidev;
774 int status;
775 unsigned long minor;
776
777 match = device_get_match_data(&spi->dev);
778 if (match) {
779 status = match(&spi->dev);
780 if (status)
781 return status;
782 }
783
784 /* Allocate driver data */
785 spidev = kzalloc(sizeof(*spidev), GFP_KERNEL);
786 if (!spidev)
787 return -ENOMEM;
788
789 /* Initialize the driver data */
790 spidev->spi = spi;
791 mutex_init(&spidev->spi_lock);
792 mutex_init(&spidev->buf_lock);
793
794 INIT_LIST_HEAD(&spidev->device_entry);
795
796 /* If we can allocate a minor number, hook up this device.
797 * Reusing minors is fine so long as udev or mdev is working.
798 */
799 mutex_lock(&device_list_lock);
800 minor = find_first_zero_bit(minors, N_SPI_MINORS);
801 if (minor < N_SPI_MINORS) {
802 struct device *dev;
803
804 spidev->devt = MKDEV(SPIDEV_MAJOR, minor);
805
806 /*
807 * If "linux,spidev-name" is specified in device tree, use /dev/spidev-<name>
808 * in Linux userspace, otherwise use /dev/spidev<bus_num>.<cs_num>.
809 */
810 ret = device_property_read_string(&spi->dev, "linux,spidev-name", &name);
811 if (ret < 0)
> 812 dev = device_create(spidev_class, &spi->dev, spidev->devt,
813 spidev, "spidev%d.%d",
814 spi->controller->bus_num, spi_get_chipselect(spi, 0));
815 else
816 dev = device_create(spidev_class, &spi->dev, spidev->devt,
817 spidev, "spidev-%s", name);
818
819 status = PTR_ERR_OR_ZERO(dev);
820 } else {
821 dev_dbg(&spi->dev, "no minor number available!\n");
822 status = -ENODEV;
823 }
824 if (status == 0) {
825 set_bit(minor, minors);
826 list_add(&spidev->device_entry, &device_list);
827 }
828 mutex_unlock(&device_list_lock);
829
830 spidev->speed_hz = spi->max_speed_hz;
831
832 if (status == 0)
833 spi_set_drvdata(spi, spidev);
834 else
835 kfree(spidev);
836
837 return status;
838 }
839

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki