All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/13] drivers: Introduce generic device lookup helpers
@ 2019-06-05 15:13 ` Suzuki K Poulose
  0 siblings, 0 replies; 39+ messages in thread
From: Suzuki K Poulose @ 2019-06-05 15:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andrew Lunn, Shyam Sundar S K, rafael, Will Deacon, Ulf Hansson,
	dri-devel, Pavel Machek, Stefan Schmidt, Wolfram Sang,
	linux-acpi, Doug Ledford, Jiri Slaby, Tomas Winkler, Dan Murphy,
	gregkh, linux-usb, Seung-Woo Kim, linux-spi, Joe Perches,
	linux-wpan, Alexandre Belloni, David Airlie, Rafael J . Wysocki ,
	Thierry Reding, Srinivas Kandagatla

We have device iterators to find a particular device matching a criteria
for a given bus/class/driver. i.e, {bus,class,driver}_find_device() APIs.
The matching criteria is a function pointer for the APIs. Often the lookup
is based on a generic property of a device (e.g, name, fwnode, of node pointer
or device type) rather than a driver specific information. However, each driver
writes up its own "match" function, spilling the similar match functions all
over the driver subsystems.

Additionally the prototype for the "match" functions accepted by the above APIs
have a minute difference which prevents us otherwise sharing the match functions.
i.e,
	int (*match)(struct device *dev, void *data) for {bus/driver}_find_device()
	  vs
	int (*match)(struct device *dev, const void *) for class_find_device()

If we promote the former to accept a "const void*" parameter, we could share one
single match function for all the helpers. This series achieves the following:

 1) Unify the prototype for "match" functions accepted by the device lookup APIs.
 2) Introduce generic match functions to match devices by the generic attributes
    of a device (e.g, name, fwnode, of_node and devt).

Also, in order to prevent creation of such match functions in the future,
we introduce wrapper functions for the look up APIs, which automatically
uses the appropriate match functions.

i.e,
	{bus/class/driver}_find_device_by_name
	{bus/class/driver}_find_device_by_of_node
	{bus/class/driver}_find_device_by_fwnode
	{bus/class/driver}_find_device_by_devt

Additionally, this series also adds wrapper for finding a device by matching
a device driver for platform bus devices - platform_find_device_by_driver() to
avoid a few drivers hard coding the platform bus specific details.

This is part 1 of revised version of the series posted here [0], to allow for better
management of the merging. Part 2 of the series, where these new helpers are consumed
by the individual driver subsystems will be posted once this is series is merged.
The entire tree with both the parts in is available at [1]

[0] https://marc.info/?i=1559577023-558-1-git-send-email-suzuki.poulose@arm.com
[1] git://linux-arm.org/linux-skp.git driver-cleanup/v1

Cc: Alan Tull <atull@kernel.org>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexander Aring <alex.aring@gmail.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Andreas Noever <andreas.noever@gmail.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Corey Minyard <minyard@acm.org>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Dan Murphy <dmurphy@ti.com>
Cc: David Airlie <airlied@linux.ie>
Cc: David Kershner <david.kershner@unisys.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Doug Ledford <dledford@redhat.com>
Cc: dri-devel@lists.freedesktop.org
Cc: Elie Morisse <syniurge@gmail.com>
Cc: Eric Anholt <eric@anholt.net>
Cc: Felipe Balbi <balbi@kernel.org>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: Grant Likely <grant.likely@arm.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Grygorii Strashko <grygorii.strashko@ti.com>
Cc: Harald Freudenberger <freude@linux.ibm.com>
Cc: Hartmut Knaack <knaack.h@gmx.de>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: "Heiko Stübner" <heiko@sntech.de>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Inki Dae <inki.dae@samsung.com>
Cc: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Joe Perches <joe@perches.com>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Len Brown <lenb@kernel.org
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Maxime Ripard <maxime.ripard@bootlin.com>
Cc: Michael Jamet <michael.jamet@intel.com>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Moritz Fischer <mdf@kernel.org>
Cc: Nehal Shah <nehal-bakulchandra.shah@amd.com>
Cc: Oliver Neukum <oneukum@suse.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
Cc: Peter Rosin <peda@axentia.se>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Sandy Huang <hjc@rock-chips.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Sebastian Ott <sebott@linux.ibm.com>
Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
Cc: Shyam Sundar S K <shyam-sundar.s-k@amd.com>
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Stefan Schmidt <stefan@datenfreihafen.org>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Thor Thayer <thor.thayer@linux.intel.com>
Cc: Tomas Winkler <tomas.winkler@intel.com>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: devicetree@vger.kernel.org
Cc: linux-acpi@vger.kernel.org
Cc: linux-fpga@vger.kernel.org
Cc: linux-i2c@vger.kernel.org
Cc: linux-leds@vger.kernel.org
Cc: linux-rockchip@lists.infradead.org
Cc: linux-rtc@vger.kernel.org
Cc: linux-spi@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: linux-wpan@vger.kernel.org

Suzuki K Poulose (13):
  acpi: utils: Cleanup acpi_dev_match_cb
  bus_find_device: Unify the match callback with class_find_device
  driver_find_device: Unify the match function with class_find_device()
  drivers: Add generic helper to match by of_node
  drivers: Add generic helper to match by fwnode
  drivers: Add generic helper to match by devt
  drivers: Add generic match helper by ACPI_COMPANION device
  drivers: Add generic helper to match by name
  drivers: Add generic helper to match any device
  drivers: Introduce variants of class_find_device()
  drivers: Introduce variants for bus_find_device()
  drivers: Introduce variants of driver_find_device()
  platform: Add platform_find_device_by_driver() helper

 arch/powerpc/platforms/pseries/ibmebus.c           |   4 +-
 drivers/acpi/acpi_lpss.c                           |   4 +-
 drivers/acpi/sleep.c                               |   2 +-
 drivers/acpi/utils.c                               |  11 +-
 drivers/amba/tegra-ahb.c                           |   4 +-
 drivers/base/bus.c                                 |  28 +--
 drivers/base/core.c                                |  36 ++++
 drivers/base/devcon.c                              |   2 +-
 drivers/base/driver.c                              |   4 +-
 drivers/base/platform.c                            |  14 ++
 drivers/char/ipmi/ipmi_msghandler.c                |   8 +-
 drivers/char/ipmi/ipmi_si_platform.c               |   2 +-
 drivers/firmware/efi/dev-path-parser.c             |   4 +-
 drivers/gpu/drm/drm_mipi_dsi.c                     |   2 +-
 drivers/gpu/drm/tegra/dc.c                         |   4 +-
 drivers/hwtracing/coresight/coresight.c            |   6 +-
 drivers/hwtracing/coresight/of_coresight.c         |   2 +-
 drivers/hwtracing/intel_th/core.c                  |   5 +-
 drivers/i2c/busses/i2c-amd-mp2-pci.c               |   2 +-
 drivers/i2c/i2c-core-acpi.c                        |   4 +-
 drivers/i2c/i2c-core-of.c                          |   4 +-
 drivers/iio/inkern.c                               |   2 +-
 drivers/infiniband/hw/hns/hns_roce_hw_v1.c         |   2 +-
 drivers/iommu/arm-smmu-v3.c                        |   2 +-
 drivers/iommu/arm-smmu.c                           |   2 +-
 drivers/mfd/altera-sysmgr.c                        |   4 +-
 drivers/mfd/syscon.c                               |   2 +-
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c |   2 +-
 drivers/net/ethernet/ti/cpsw-phy-sel.c             |   4 +-
 drivers/net/ethernet/ti/davinci_emac.c             |   2 +-
 drivers/net/ethernet/toshiba/tc35815.c             |   4 +-
 drivers/nvmem/core.c                               |   2 +-
 drivers/of/of_mdio.c                               |   2 +-
 drivers/of/platform.c                              |   2 +-
 drivers/pci/probe.c                                |   2 +-
 drivers/pci/search.c                               |   4 +-
 drivers/s390/cio/ccwgroup.c                        |   2 +-
 drivers/s390/cio/chsc_sch.c                        |   2 +-
 drivers/s390/cio/css.c                             |   4 +-
 drivers/s390/cio/device.c                          |   6 +-
 drivers/s390/cio/scm.c                             |   4 +-
 drivers/s390/crypto/ap_bus.c                       |   8 +-
 drivers/scsi/scsi_proc.c                           |   2 +-
 drivers/spi/spi.c                                  |   4 +-
 drivers/staging/most/core.c                        |   4 +-
 drivers/thunderbolt/switch.c                       |   4 +-
 drivers/usb/core/devio.c                           |   4 +-
 drivers/usb/core/usb.c                             |   4 +-
 drivers/usb/phy/phy-am335x-control.c               |   4 +-
 drivers/usb/phy/phy-isp1301.c                      |   4 +-
 drivers/visorbus/visorbus_main.c                   |   4 +-
 include/linux/device.h                             | 188 ++++++++++++++++++++-
 include/linux/platform_device.h                    |   3 +
 sound/soc/rockchip/rk3399_gru_sound.c              |   2 +-
 54 files changed, 320 insertions(+), 123 deletions(-)

-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 00/13] drivers: Introduce generic device lookup helpers
@ 2019-06-05 15:13 ` Suzuki K Poulose
  0 siblings, 0 replies; 39+ messages in thread
From: Suzuki K Poulose @ 2019-06-05 15:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andrew Lunn, Shyam Sundar S K, rafael, Will Deacon, Ulf Hansson,
	dri-devel, Pavel Machek, Stefan Schmidt, Wolfram Sang,
	linux-acpi, Doug Ledford, Jiri Slaby, Tomas Winkler, Dan Murphy,
	gregkh, linux-usb, Seung-Woo Kim, linux-spi, Joe Perches,
	linux-wpan, Alexandre Belloni, David Airlie, Rafael J . Wysocki ,
	Thierry Reding, Srinivas Kandagatla, linux-

We have device iterators to find a particular device matching a criteria
for a given bus/class/driver. i.e, {bus,class,driver}_find_device() APIs.
The matching criteria is a function pointer for the APIs. Often the lookup
is based on a generic property of a device (e.g, name, fwnode, of node pointer
or device type) rather than a driver specific information. However, each driver
writes up its own "match" function, spilling the similar match functions all
over the driver subsystems.

Additionally the prototype for the "match" functions accepted by the above APIs
have a minute difference which prevents us otherwise sharing the match functions.
i.e,
	int (*match)(struct device *dev, void *data) for {bus/driver}_find_device()
	  vs
	int (*match)(struct device *dev, const void *) for class_find_device()

If we promote the former to accept a "const void*" parameter, we could share one
single match function for all the helpers. This series achieves the following:

 1) Unify the prototype for "match" functions accepted by the device lookup APIs.
 2) Introduce generic match functions to match devices by the generic attributes
    of a device (e.g, name, fwnode, of_node and devt).

Also, in order to prevent creation of such match functions in the future,
we introduce wrapper functions for the look up APIs, which automatically
uses the appropriate match functions.

i.e,
	{bus/class/driver}_find_device_by_name
	{bus/class/driver}_find_device_by_of_node
	{bus/class/driver}_find_device_by_fwnode
	{bus/class/driver}_find_device_by_devt

Additionally, this series also adds wrapper for finding a device by matching
a device driver for platform bus devices - platform_find_device_by_driver() to
avoid a few drivers hard coding the platform bus specific details.

This is part 1 of revised version of the series posted here [0], to allow for better
management of the merging. Part 2 of the series, where these new helpers are consumed
by the individual driver subsystems will be posted once this is series is merged.
The entire tree with both the parts in is available at [1]

[0] https://marc.info/?i=1559577023-558-1-git-send-email-suzuki.poulose@arm.com
[1] git://linux-arm.org/linux-skp.git driver-cleanup/v1

Cc: Alan Tull <atull@kernel.org>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexander Aring <alex.aring@gmail.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Andreas Noever <andreas.noever@gmail.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Corey Minyard <minyard@acm.org>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Dan Murphy <dmurphy@ti.com>
Cc: David Airlie <airlied@linux.ie>
Cc: David Kershner <david.kershner@unisys.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Doug Ledford <dledford@redhat.com>
Cc: dri-devel@lists.freedesktop.org
Cc: Elie Morisse <syniurge@gmail.com>
Cc: Eric Anholt <eric@anholt.net>
Cc: Felipe Balbi <balbi@kernel.org>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: Grant Likely <grant.likely@arm.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Grygorii Strashko <grygorii.strashko@ti.com>
Cc: Harald Freudenberger <freude@linux.ibm.com>
Cc: Hartmut Knaack <knaack.h@gmx.de>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: "Heiko Stübner" <heiko@sntech.de>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Inki Dae <inki.dae@samsung.com>
Cc: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Joe Perches <joe@perches.com>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Len Brown <lenb@kernel.org
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Maxime Ripard <maxime.ripard@bootlin.com>
Cc: Michael Jamet <michael.jamet@intel.com>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Moritz Fischer <mdf@kernel.org>
Cc: Nehal Shah <nehal-bakulchandra.shah@amd.com>
Cc: Oliver Neukum <oneukum@suse.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
Cc: Peter Rosin <peda@axentia.se>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Sandy Huang <hjc@rock-chips.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Sebastian Ott <sebott@linux.ibm.com>
Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
Cc: Shyam Sundar S K <shyam-sundar.s-k@amd.com>
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Stefan Schmidt <stefan@datenfreihafen.org>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Thor Thayer <thor.thayer@linux.intel.com>
Cc: Tomas Winkler <tomas.winkler@intel.com>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: devicetree@vger.kernel.org
Cc: linux-acpi@vger.kernel.org
Cc: linux-fpga@vger.kernel.org
Cc: linux-i2c@vger.kernel.org
Cc: linux-leds@vger.kernel.org
Cc: linux-rockchip@lists.infradead.org
Cc: linux-rtc@vger.kernel.org
Cc: linux-spi@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: linux-wpan@vger.kernel.org

Suzuki K Poulose (13):
  acpi: utils: Cleanup acpi_dev_match_cb
  bus_find_device: Unify the match callback with class_find_device
  driver_find_device: Unify the match function with class_find_device()
  drivers: Add generic helper to match by of_node
  drivers: Add generic helper to match by fwnode
  drivers: Add generic helper to match by devt
  drivers: Add generic match helper by ACPI_COMPANION device
  drivers: Add generic helper to match by name
  drivers: Add generic helper to match any device
  drivers: Introduce variants of class_find_device()
  drivers: Introduce variants for bus_find_device()
  drivers: Introduce variants of driver_find_device()
  platform: Add platform_find_device_by_driver() helper

 arch/powerpc/platforms/pseries/ibmebus.c           |   4 +-
 drivers/acpi/acpi_lpss.c                           |   4 +-
 drivers/acpi/sleep.c                               |   2 +-
 drivers/acpi/utils.c                               |  11 +-
 drivers/amba/tegra-ahb.c                           |   4 +-
 drivers/base/bus.c                                 |  28 +--
 drivers/base/core.c                                |  36 ++++
 drivers/base/devcon.c                              |   2 +-
 drivers/base/driver.c                              |   4 +-
 drivers/base/platform.c                            |  14 ++
 drivers/char/ipmi/ipmi_msghandler.c                |   8 +-
 drivers/char/ipmi/ipmi_si_platform.c               |   2 +-
 drivers/firmware/efi/dev-path-parser.c             |   4 +-
 drivers/gpu/drm/drm_mipi_dsi.c                     |   2 +-
 drivers/gpu/drm/tegra/dc.c                         |   4 +-
 drivers/hwtracing/coresight/coresight.c            |   6 +-
 drivers/hwtracing/coresight/of_coresight.c         |   2 +-
 drivers/hwtracing/intel_th/core.c                  |   5 +-
 drivers/i2c/busses/i2c-amd-mp2-pci.c               |   2 +-
 drivers/i2c/i2c-core-acpi.c                        |   4 +-
 drivers/i2c/i2c-core-of.c                          |   4 +-
 drivers/iio/inkern.c                               |   2 +-
 drivers/infiniband/hw/hns/hns_roce_hw_v1.c         |   2 +-
 drivers/iommu/arm-smmu-v3.c                        |   2 +-
 drivers/iommu/arm-smmu.c                           |   2 +-
 drivers/mfd/altera-sysmgr.c                        |   4 +-
 drivers/mfd/syscon.c                               |   2 +-
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c |   2 +-
 drivers/net/ethernet/ti/cpsw-phy-sel.c             |   4 +-
 drivers/net/ethernet/ti/davinci_emac.c             |   2 +-
 drivers/net/ethernet/toshiba/tc35815.c             |   4 +-
 drivers/nvmem/core.c                               |   2 +-
 drivers/of/of_mdio.c                               |   2 +-
 drivers/of/platform.c                              |   2 +-
 drivers/pci/probe.c                                |   2 +-
 drivers/pci/search.c                               |   4 +-
 drivers/s390/cio/ccwgroup.c                        |   2 +-
 drivers/s390/cio/chsc_sch.c                        |   2 +-
 drivers/s390/cio/css.c                             |   4 +-
 drivers/s390/cio/device.c                          |   6 +-
 drivers/s390/cio/scm.c                             |   4 +-
 drivers/s390/crypto/ap_bus.c                       |   8 +-
 drivers/scsi/scsi_proc.c                           |   2 +-
 drivers/spi/spi.c                                  |   4 +-
 drivers/staging/most/core.c                        |   4 +-
 drivers/thunderbolt/switch.c                       |   4 +-
 drivers/usb/core/devio.c                           |   4 +-
 drivers/usb/core/usb.c                             |   4 +-
 drivers/usb/phy/phy-am335x-control.c               |   4 +-
 drivers/usb/phy/phy-isp1301.c                      |   4 +-
 drivers/visorbus/visorbus_main.c                   |   4 +-
 include/linux/device.h                             | 188 ++++++++++++++++++++-
 include/linux/platform_device.h                    |   3 +
 sound/soc/rockchip/rk3399_gru_sound.c              |   2 +-
 54 files changed, 320 insertions(+), 123 deletions(-)

-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 00/13] drivers: Introduce generic device lookup helpers
@ 2019-06-05 15:13 ` Suzuki K Poulose
  0 siblings, 0 replies; 39+ messages in thread
From: Suzuki K Poulose @ 2019-06-05 15:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Alan Tull, Alessandro Zummo,
	Alexander Aring, Alexander Shishkin, Alexandre Belloni,
	Andreas Noever, Andrew Lunn, Arnd Bergmann, Bjorn Helgaas,
	Corey Minyard, Daniel Vetter, Dan Murphy, David Airlie,
	David Kershner, David S. Miller, Doug Ledford, dri-devel,
	Elie Morisse, Eric Anholt, Felipe Balbi, Florian Fainelli,
	Frank Rowand, Grant Likely, Grygorii Strashko,
	Harald Freudenberger, Hartmut Knaack, Heikki Krogerus,
	Heiko Carstens, Heiko Stübner, Heiner Kallweit, Inki Dae,
	Jacek Anaszewski, James E.J. Bottomley, Jason Gunthorpe,
	Jiri Slaby, Joe Perches, Joerg Roedel, Jonathan Cameron,
	Jonathan Hunter, Lee Jones, Len Brown, Liam Girdwood,
	Maarten Lankhorst, Mark Brown, Martin K. Petersen,
	Mathieu Poirier, Maxime Coquelin, Maxime Ripard, Michael Jamet,
	Mika Westerberg, Moritz Fischer, Nehal Shah, Oliver Neukum,
	Pavel Machek, Peter Oberparleiter, Peter Rosin,
	Rafael J. Wysocki, Rafael J . Wysocki ,
	Rob Herring, Robin Murphy, Russell King, Sandy Huang,
	Sebastian Andrzej Siewior, Sebastian Ott, Seung-Woo Kim,
	Shyam Sundar S K, Srinivas Kandagatla, Stefan Schmidt,
	Takashi Iwai, Thierry Reding, Thor Thayer, Tomas Winkler,
	Ulf Hansson, Will Deacon, Wolfram Sang, devicetree, linux-acpi,
	linux-fpga, linux-i2c, linux-leds, linux-rockchip, linux-rtc,
	linux-spi, linux-usb, linux-wpan

We have device iterators to find a particular device matching a criteria
for a given bus/class/driver. i.e, {bus,class,driver}_find_device() APIs.
The matching criteria is a function pointer for the APIs. Often the lookup
is based on a generic property of a device (e.g, name, fwnode, of node pointer
or device type) rather than a driver specific information. However, each driver
writes up its own "match" function, spilling the similar match functions all
over the driver subsystems.

Additionally the prototype for the "match" functions accepted by the above APIs
have a minute difference which prevents us otherwise sharing the match functions.
i.e,
	int (*match)(struct device *dev, void *data) for {bus/driver}_find_device()
	  vs
	int (*match)(struct device *dev, const void *) for class_find_device()

If we promote the former to accept a "const void*" parameter, we could share one
single match function for all the helpers. This series achieves the following:

 1) Unify the prototype for "match" functions accepted by the device lookup APIs.
 2) Introduce generic match functions to match devices by the generic attributes
    of a device (e.g, name, fwnode, of_node and devt).

Also, in order to prevent creation of such match functions in the future,
we introduce wrapper functions for the look up APIs, which automatically
uses the appropriate match functions.

i.e,
	{bus/class/driver}_find_device_by_name
	{bus/class/driver}_find_device_by_of_node
	{bus/class/driver}_find_device_by_fwnode
	{bus/class/driver}_find_device_by_devt

Additionally, this series also adds wrapper for finding a device by matching
a device driver for platform bus devices - platform_find_device_by_driver() to
avoid a few drivers hard coding the platform bus specific details.

This is part 1 of revised version of the series posted here [0], to allow for better
management of the merging. Part 2 of the series, where these new helpers are consumed
by the individual driver subsystems will be posted once this is series is merged.
The entire tree with both the parts in is available at [1]

[0] https://marc.info/?i=1559577023-558-1-git-send-email-suzuki.poulose@arm.com
[1] git://linux-arm.org/linux-skp.git driver-cleanup/v1

Cc: Alan Tull <atull@kernel.org>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexander Aring <alex.aring@gmail.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Andreas Noever <andreas.noever@gmail.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Corey Minyard <minyard@acm.org>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Dan Murphy <dmurphy@ti.com>
Cc: David Airlie <airlied@linux.ie>
Cc: David Kershner <david.kershner@unisys.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Doug Ledford <dledford@redhat.com>
Cc: dri-devel@lists.freedesktop.org
Cc: Elie Morisse <syniurge@gmail.com>
Cc: Eric Anholt <eric@anholt.net>
Cc: Felipe Balbi <balbi@kernel.org>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: Grant Likely <grant.likely@arm.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Grygorii Strashko <grygorii.strashko@ti.com>
Cc: Harald Freudenberger <freude@linux.ibm.com>
Cc: Hartmut Knaack <knaack.h@gmx.de>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: "Heiko Stübner" <heiko@sntech.de>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Inki Dae <inki.dae@samsung.com>
Cc: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Joe Perches <joe@perches.com>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Len Brown <lenb@kernel.org
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Maxime Ripard <maxime.ripard@bootlin.com>
Cc: Michael Jamet <michael.jamet@intel.com>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Moritz Fischer <mdf@kernel.org>
Cc: Nehal Shah <nehal-bakulchandra.shah@amd.com>
Cc: Oliver Neukum <oneukum@suse.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
Cc: Peter Rosin <peda@axentia.se>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Sandy Huang <hjc@rock-chips.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Sebastian Ott <sebott@linux.ibm.com>
Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
Cc: Shyam Sundar S K <shyam-sundar.s-k@amd.com>
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Stefan Schmidt <stefan@datenfreihafen.org>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Thor Thayer <thor.thayer@linux.intel.com>
Cc: Tomas Winkler <tomas.winkler@intel.com>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: devicetree@vger.kernel.org
Cc: linux-acpi@vger.kernel.org
Cc: linux-fpga@vger.kernel.org
Cc: linux-i2c@vger.kernel.org
Cc: linux-leds@vger.kernel.org
Cc: linux-rockchip@lists.infradead.org
Cc: linux-rtc@vger.kernel.org
Cc: linux-spi@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: linux-wpan@vger.kernel.org

Suzuki K Poulose (13):
  acpi: utils: Cleanup acpi_dev_match_cb
  bus_find_device: Unify the match callback with class_find_device
  driver_find_device: Unify the match function with class_find_device()
  drivers: Add generic helper to match by of_node
  drivers: Add generic helper to match by fwnode
  drivers: Add generic helper to match by devt
  drivers: Add generic match helper by ACPI_COMPANION device
  drivers: Add generic helper to match by name
  drivers: Add generic helper to match any device
  drivers: Introduce variants of class_find_device()
  drivers: Introduce variants for bus_find_device()
  drivers: Introduce variants of driver_find_device()
  platform: Add platform_find_device_by_driver() helper

 arch/powerpc/platforms/pseries/ibmebus.c           |   4 +-
 drivers/acpi/acpi_lpss.c                           |   4 +-
 drivers/acpi/sleep.c                               |   2 +-
 drivers/acpi/utils.c                               |  11 +-
 drivers/amba/tegra-ahb.c                           |   4 +-
 drivers/base/bus.c                                 |  28 +--
 drivers/base/core.c                                |  36 ++++
 drivers/base/devcon.c                              |   2 +-
 drivers/base/driver.c                              |   4 +-
 drivers/base/platform.c                            |  14 ++
 drivers/char/ipmi/ipmi_msghandler.c                |   8 +-
 drivers/char/ipmi/ipmi_si_platform.c               |   2 +-
 drivers/firmware/efi/dev-path-parser.c             |   4 +-
 drivers/gpu/drm/drm_mipi_dsi.c                     |   2 +-
 drivers/gpu/drm/tegra/dc.c                         |   4 +-
 drivers/hwtracing/coresight/coresight.c            |   6 +-
 drivers/hwtracing/coresight/of_coresight.c         |   2 +-
 drivers/hwtracing/intel_th/core.c                  |   5 +-
 drivers/i2c/busses/i2c-amd-mp2-pci.c               |   2 +-
 drivers/i2c/i2c-core-acpi.c                        |   4 +-
 drivers/i2c/i2c-core-of.c                          |   4 +-
 drivers/iio/inkern.c                               |   2 +-
 drivers/infiniband/hw/hns/hns_roce_hw_v1.c         |   2 +-
 drivers/iommu/arm-smmu-v3.c                        |   2 +-
 drivers/iommu/arm-smmu.c                           |   2 +-
 drivers/mfd/altera-sysmgr.c                        |   4 +-
 drivers/mfd/syscon.c                               |   2 +-
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c |   2 +-
 drivers/net/ethernet/ti/cpsw-phy-sel.c             |   4 +-
 drivers/net/ethernet/ti/davinci_emac.c             |   2 +-
 drivers/net/ethernet/toshiba/tc35815.c             |   4 +-
 drivers/nvmem/core.c                               |   2 +-
 drivers/of/of_mdio.c                               |   2 +-
 drivers/of/platform.c                              |   2 +-
 drivers/pci/probe.c                                |   2 +-
 drivers/pci/search.c                               |   4 +-
 drivers/s390/cio/ccwgroup.c                        |   2 +-
 drivers/s390/cio/chsc_sch.c                        |   2 +-
 drivers/s390/cio/css.c                             |   4 +-
 drivers/s390/cio/device.c                          |   6 +-
 drivers/s390/cio/scm.c                             |   4 +-
 drivers/s390/crypto/ap_bus.c                       |   8 +-
 drivers/scsi/scsi_proc.c                           |   2 +-
 drivers/spi/spi.c                                  |   4 +-
 drivers/staging/most/core.c                        |   4 +-
 drivers/thunderbolt/switch.c                       |   4 +-
 drivers/usb/core/devio.c                           |   4 +-
 drivers/usb/core/usb.c                             |   4 +-
 drivers/usb/phy/phy-am335x-control.c               |   4 +-
 drivers/usb/phy/phy-isp1301.c                      |   4 +-
 drivers/visorbus/visorbus_main.c                   |   4 +-
 include/linux/device.h                             | 188 ++++++++++++++++++++-
 include/linux/platform_device.h                    |   3 +
 sound/soc/rockchip/rk3399_gru_sound.c              |   2 +-
 54 files changed, 320 insertions(+), 123 deletions(-)

-- 
2.7.4

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

* [PATCH 01/13] acpi: utils: Cleanup acpi_dev_match_cb
  2019-06-05 15:13 ` Suzuki K Poulose
  (?)
  (?)
@ 2019-06-05 15:13 ` Suzuki K Poulose
  2019-06-06  9:14   ` Rafael J. Wysocki
  -1 siblings, 1 reply; 39+ messages in thread
From: Suzuki K Poulose @ 2019-06-05 15:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Rafael J. Wysocki, Len Brown, linux-acpi

acpi_dev_match_cb match function modifies the "data" argument
to pass on a result which could be easily deduced from the result
of the bus_find_device() call at the caller site. Clean this
up in preparation to convert the "match" argument for bus_find_device
to accept a "const" data pointer, similar to class_find_device. This
would allow consolidating the match routines for these two APIs.

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Len Brown <lenb@kernel.org>
Cc: linux-acpi@vger.kernel.org
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/acpi/utils.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 7def63a..1391b63 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -725,8 +725,6 @@ bool acpi_dev_found(const char *hid)
 EXPORT_SYMBOL(acpi_dev_found);
 
 struct acpi_dev_match_info {
-	const char *dev_name;
-	struct acpi_device *adev;
 	struct acpi_device_id hid[2];
 	const char *uid;
 	s64 hrv;
@@ -746,9 +744,6 @@ static int acpi_dev_match_cb(struct device *dev, void *data)
 	    strcmp(adev->pnp.unique_id, match->uid)))
 		return 0;
 
-	match->dev_name = acpi_dev_name(adev);
-	match->adev = adev;
-
 	if (match->hrv == -1)
 		return 1;
 
@@ -818,7 +813,7 @@ acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv)
 	match.hrv = hrv;
 
 	dev = bus_find_device(&acpi_bus_type, NULL, &match, acpi_dev_match_cb);
-	return dev ? match.adev : NULL;
+	return dev ? to_acpi_device(dev) : NULL;
 }
 EXPORT_SYMBOL(acpi_dev_get_first_match_dev);
 
-- 
2.7.4


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

* [PATCH 02/13] bus_find_device: Unify the match callback with class_find_device
  2019-06-05 15:13 ` Suzuki K Poulose
                   ` (2 preceding siblings ...)
  (?)
@ 2019-06-05 15:13 ` Suzuki K Poulose
  2019-06-05 15:48   ` Corey Minyard
                     ` (4 more replies)
  -1 siblings, 5 replies; 39+ messages in thread
From: Suzuki K Poulose @ 2019-06-05 15:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Alexander Shishkin, Andrew Lunn,
	Andreas Noever, Arnd Bergmann, Bjorn Helgaas, Corey Minyard,
	Christian Borntraeger, David Kershner, David S. Miller,
	David Airlie, Felipe Balbi, Frank Rowand, Grygorii Strashko,
	Harald Freudenberger, Hartmut Knaack, Heiko Stuebner,
	Jason Gunthorpe, Jonathan Cameron, James E.J. Bottomley,
	Len Brown, Mark Brown, Michael Ellerman, Michael Jamet,
	Martin K. Petersen, Peter Oberparleiter, Rob Herring,
	Sebastian Ott, Srinivas Kandagatla, Yehezkel Bernat,
	Wolfram Sang

There is an arbitrary difference between the prototypes of
bus_find_device() and class_find_device() preventing their callers
from passing the same pair of data and match() arguments to both of
them, which is the const qualifier used in the prototype of
class_find_device().  If that qualifier is also used in the
bus_find_device() prototype, it will be possible to pass the same
match() callback function to both bus_find_device() and
class_find_device(), which will allow some optimizations to be made in
order to avoid code duplication going forward.  Also with that, constify
the "data" parameter as it is passed as a const to the match function.

For this reason, change the prototype of bus_find_device() to match
the prototype of class_find_device() and adjust its callers to use the
const qualifier in accordance with the new prototype of it.

Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Andreas Noever <andreas.noever@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Corey Minyard <minyard@acm.org>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: David Kershner <david.kershner@unisys.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: David Airlie <airlied@linux.ie>
Cc: Felipe Balbi <balbi@kernel.org>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: Grygorii Strashko <grygorii.strashko@ti.com>
Cc: Harald Freudenberger <freude@linux.ibm.com>
Cc: Hartmut Knaack <knaack.h@gmx.de>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: Len Brown <lenb@kernel.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Michael Jamet <michael.jamet@intel.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Sebastian Ott <sebott@linux.ibm.com>
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Yehezkel Bernat <YehezkelShB@gmail.com>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: rafael@kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 arch/powerpc/platforms/pseries/ibmebus.c           | 4 ++--
 drivers/acpi/acpi_lpss.c                           | 4 ++--
 drivers/acpi/sleep.c                               | 2 +-
 drivers/acpi/utils.c                               | 4 ++--
 drivers/base/bus.c                                 | 6 +++---
 drivers/base/devcon.c                              | 2 +-
 drivers/char/ipmi/ipmi_si_platform.c               | 2 +-
 drivers/firmware/efi/dev-path-parser.c             | 4 ++--
 drivers/gpu/drm/drm_mipi_dsi.c                     | 2 +-
 drivers/hwtracing/coresight/coresight.c            | 6 +++---
 drivers/hwtracing/coresight/of_coresight.c         | 2 +-
 drivers/hwtracing/intel_th/core.c                  | 5 ++---
 drivers/i2c/i2c-core-acpi.c                        | 4 ++--
 drivers/i2c/i2c-core-of.c                          | 4 ++--
 drivers/iio/inkern.c                               | 2 +-
 drivers/infiniband/hw/hns/hns_roce_hw_v1.c         | 2 +-
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c | 2 +-
 drivers/net/ethernet/ti/cpsw-phy-sel.c             | 4 ++--
 drivers/net/ethernet/ti/davinci_emac.c             | 2 +-
 drivers/net/ethernet/toshiba/tc35815.c             | 4 ++--
 drivers/nvmem/core.c                               | 2 +-
 drivers/of/of_mdio.c                               | 2 +-
 drivers/of/platform.c                              | 2 +-
 drivers/pci/probe.c                                | 2 +-
 drivers/pci/search.c                               | 4 ++--
 drivers/s390/cio/css.c                             | 4 ++--
 drivers/s390/cio/device.c                          | 4 ++--
 drivers/s390/cio/scm.c                             | 4 ++--
 drivers/s390/crypto/ap_bus.c                       | 8 ++++----
 drivers/scsi/scsi_proc.c                           | 2 +-
 drivers/spi/spi.c                                  | 4 ++--
 drivers/staging/most/core.c                        | 4 ++--
 drivers/thunderbolt/switch.c                       | 4 ++--
 drivers/usb/core/devio.c                           | 4 ++--
 drivers/usb/core/usb.c                             | 4 ++--
 drivers/usb/phy/phy-am335x-control.c               | 4 ++--
 drivers/usb/phy/phy-isp1301.c                      | 4 ++--
 drivers/visorbus/visorbus_main.c                   | 4 ++--
 include/linux/device.h                             | 4 ++--
 sound/soc/rockchip/rk3399_gru_sound.c              | 2 +-
 40 files changed, 69 insertions(+), 70 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/ibmebus.c b/arch/powerpc/platforms/pseries/ibmebus.c
index 84e8ec4..b91eb09 100644
--- a/arch/powerpc/platforms/pseries/ibmebus.c
+++ b/arch/powerpc/platforms/pseries/ibmebus.c
@@ -147,13 +147,13 @@ static const struct dma_map_ops ibmebus_dma_ops = {
 	.unmap_page         = ibmebus_unmap_page,
 };
 
-static int ibmebus_match_path(struct device *dev, void *data)
+static int ibmebus_match_path(struct device *dev, const void *data)
 {
 	struct device_node *dn = to_platform_device(dev)->dev.of_node;
 	return (of_find_node_by_path(data) == dn);
 }
 
-static int ibmebus_match_node(struct device *dev, void *data)
+static int ibmebus_match_node(struct device *dev, const void *data)
 {
 	return to_platform_device(dev)->dev.of_node == data;
 }
diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index cf76860..dc2ca78 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -511,10 +511,10 @@ struct hid_uid {
 	const char *uid;
 };
 
-static int match_hid_uid(struct device *dev, void *data)
+static int match_hid_uid(struct device *dev, const void *data)
 {
 	struct acpi_device *adev = ACPI_COMPANION(dev);
-	struct hid_uid *id = data;
+	const struct hid_uid *id = data;
 
 	if (!adev)
 		return 0;
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index a34decc..fcf4386 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -454,7 +454,7 @@ static int acpi_pm_prepare(void)
 	return error;
 }
 
-static int find_powerf_dev(struct device *dev, void *data)
+static int find_powerf_dev(struct device *dev, const void *data)
 {
 	struct acpi_device *device = to_acpi_device(dev);
 	const char *hid = acpi_device_hid(device);
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 1391b63..e3974a8 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -730,10 +730,10 @@ struct acpi_dev_match_info {
 	s64 hrv;
 };
 
-static int acpi_dev_match_cb(struct device *dev, void *data)
+static int acpi_dev_match_cb(struct device *dev, const void *data)
 {
 	struct acpi_device *adev = to_acpi_device(dev);
-	struct acpi_dev_match_info *match = data;
+	const struct acpi_dev_match_info *match = data;
 	unsigned long long hrv;
 	acpi_status status;
 
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 0a58e96..df3cac7 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -323,8 +323,8 @@ EXPORT_SYMBOL_GPL(bus_for_each_dev);
  * return to the caller and not iterate over any more devices.
  */
 struct device *bus_find_device(struct bus_type *bus,
-			       struct device *start, void *data,
-			       int (*match)(struct device *dev, void *data))
+			       struct device *start, const void *data,
+			       int (*match)(struct device *dev, const void *data))
 {
 	struct klist_iter i;
 	struct device *dev;
@@ -342,7 +342,7 @@ struct device *bus_find_device(struct bus_type *bus,
 }
 EXPORT_SYMBOL_GPL(bus_find_device);
 
-static int match_name(struct device *dev, void *data)
+static int match_name(struct device *dev, const void *data)
 {
 	const char *name = data;
 
diff --git a/drivers/base/devcon.c b/drivers/base/devcon.c
index 04db9ae..ac026d5 100644
--- a/drivers/base/devcon.c
+++ b/drivers/base/devcon.c
@@ -107,7 +107,7 @@ static struct bus_type *generic_match_buses[] = {
 	NULL,
 };
 
-static int device_fwnode_match(struct device *dev, void *fwnode)
+static int device_fwnode_match(struct device *dev, const void *fwnode)
 {
 	return dev_fwnode(dev) == fwnode;
 }
diff --git a/drivers/char/ipmi/ipmi_si_platform.c b/drivers/char/ipmi/ipmi_si_platform.c
index f2a91c4..fd94c42 100644
--- a/drivers/char/ipmi/ipmi_si_platform.c
+++ b/drivers/char/ipmi/ipmi_si_platform.c
@@ -426,7 +426,7 @@ static int ipmi_remove(struct platform_device *pdev)
 	return ipmi_si_remove_by_dev(&pdev->dev);
 }
 
-static int pdev_match_name(struct device *dev, void *data)
+static int pdev_match_name(struct device *dev, const void *data)
 {
 	struct platform_device *pdev = to_platform_device(dev);
 	const char *name = data;
diff --git a/drivers/firmware/efi/dev-path-parser.c b/drivers/firmware/efi/dev-path-parser.c
index 85ec99f..2012338 100644
--- a/drivers/firmware/efi/dev-path-parser.c
+++ b/drivers/firmware/efi/dev-path-parser.c
@@ -17,9 +17,9 @@ struct acpi_hid_uid {
 	char uid[11]; /* UINT_MAX + null byte */
 };
 
-static int __init match_acpi_dev(struct device *dev, void *data)
+static int __init match_acpi_dev(struct device *dev, const void *data)
 {
-	struct acpi_hid_uid hid_uid = *(struct acpi_hid_uid *)data;
+	struct acpi_hid_uid hid_uid = *(const struct acpi_hid_uid *)data;
 	struct acpi_device *adev = to_acpi_device(dev);
 
 	if (acpi_match_device_ids(adev, hid_uid.hid))
diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
index 80b7550..ad19df0 100644
--- a/drivers/gpu/drm/drm_mipi_dsi.c
+++ b/drivers/gpu/drm/drm_mipi_dsi.c
@@ -93,7 +93,7 @@ static struct bus_type mipi_dsi_bus_type = {
 	.pm = &mipi_dsi_device_pm_ops,
 };
 
-static int of_device_match(struct device *dev, void *data)
+static int of_device_match(struct device *dev, const void *data)
 {
 	return dev->of_node == data;
 }
diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c
index 4b13028..b67ab6a 100644
--- a/drivers/hwtracing/coresight/coresight.c
+++ b/drivers/hwtracing/coresight/coresight.c
@@ -498,9 +498,9 @@ struct coresight_device *coresight_get_sink(struct list_head *path)
 	return csdev;
 }
 
-static int coresight_enabled_sink(struct device *dev, void *data)
+static int coresight_enabled_sink(struct device *dev, const void *data)
 {
-	bool *reset = data;
+	const bool *reset = data;
 	struct coresight_device *csdev = to_coresight_device(dev);
 
 	if ((csdev->type == CORESIGHT_DEV_TYPE_SINK ||
@@ -544,7 +544,7 @@ struct coresight_device *coresight_get_enabled_sink(bool deactivate)
 	return dev ? to_coresight_device(dev) : NULL;
 }
 
-static int coresight_sink_by_id(struct device *dev, void *data)
+static int coresight_sink_by_id(struct device *dev, const void *data)
 {
 	struct coresight_device *csdev = to_coresight_device(dev);
 	unsigned long hash;
diff --git a/drivers/hwtracing/coresight/of_coresight.c b/drivers/hwtracing/coresight/of_coresight.c
index 7045930..3fc200e 100644
--- a/drivers/hwtracing/coresight/of_coresight.c
+++ b/drivers/hwtracing/coresight/of_coresight.c
@@ -18,7 +18,7 @@
 #include <asm/smp_plat.h>
 
 
-static int of_dev_node_match(struct device *dev, void *data)
+static int of_dev_node_match(struct device *dev, const void *data)
 {
 	return dev->of_node == data;
 }
diff --git a/drivers/hwtracing/intel_th/core.c b/drivers/hwtracing/intel_th/core.c
index 033dce5..5592289 100644
--- a/drivers/hwtracing/intel_th/core.c
+++ b/drivers/hwtracing/intel_th/core.c
@@ -789,10 +789,9 @@ static int intel_th_populate(struct intel_th *th)
 	return 0;
 }
 
-static int match_devt(struct device *dev, void *data)
+static int match_devt(struct device *dev, const void *data)
 {
-	dev_t devt = (dev_t)(unsigned long)data;
-
+	dev_t devt = (dev_t)(unsigned long)(void *)data;
 	return dev->devt == devt;
 }
 
diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
index d840955..8af35f11 100644
--- a/drivers/i2c/i2c-core-acpi.c
+++ b/drivers/i2c/i2c-core-acpi.c
@@ -318,7 +318,7 @@ u32 i2c_acpi_find_bus_speed(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(i2c_acpi_find_bus_speed);
 
-static int i2c_acpi_find_match_adapter(struct device *dev, void *data)
+static int i2c_acpi_find_match_adapter(struct device *dev, const void *data)
 {
 	struct i2c_adapter *adapter = i2c_verify_adapter(dev);
 
@@ -328,7 +328,7 @@ static int i2c_acpi_find_match_adapter(struct device *dev, void *data)
 	return ACPI_HANDLE(dev) == (acpi_handle)data;
 }
 
-static int i2c_acpi_find_match_device(struct device *dev, void *data)
+static int i2c_acpi_find_match_device(struct device *dev, const void *data)
 {
 	return ACPI_COMPANION(dev) == data;
 }
diff --git a/drivers/i2c/i2c-core-of.c b/drivers/i2c/i2c-core-of.c
index 406e5f6..2eb59a2 100644
--- a/drivers/i2c/i2c-core-of.c
+++ b/drivers/i2c/i2c-core-of.c
@@ -112,12 +112,12 @@ void of_i2c_register_devices(struct i2c_adapter *adap)
 	of_node_put(bus);
 }
 
-static int of_dev_node_match(struct device *dev, void *data)
+static int of_dev_node_match(struct device *dev, const void *data)
 {
 	return dev->of_node == data;
 }
 
-static int of_dev_or_parent_node_match(struct device *dev, void *data)
+static int of_dev_or_parent_node_match(struct device *dev, const void *data)
 {
 	if (dev->of_node == data)
 		return 1;
diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index 4a5eff3..c46fb59 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -93,7 +93,7 @@ static const struct iio_chan_spec
 
 #ifdef CONFIG_OF
 
-static int iio_dev_node_match(struct device *dev, void *data)
+static int iio_dev_node_match(struct device *dev, const void *data)
 {
 	return dev->of_node == data && dev->type == &iio_device_type;
 }
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
index 4c5d0f1..fd90b05 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
@@ -4497,7 +4497,7 @@ static const struct acpi_device_id hns_roce_acpi_match[] = {
 };
 MODULE_DEVICE_TABLE(acpi, hns_roce_acpi_match);
 
-static int hns_roce_node_match(struct device *dev, void *fwnode)
+static int hns_roce_node_match(struct device *dev, const void *fwnode)
 {
 	return dev->fwnode == fwnode;
 }
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c
index 09c16d8..bb6586d 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c
@@ -754,7 +754,7 @@ struct dsaf_misc_op *hns_misc_op_get(struct dsaf_device *dsaf_dev)
 	return (void *)misc_op;
 }
 
-static int hns_dsaf_dev_match(struct device *dev, void *fwnode)
+static int hns_dsaf_dev_match(struct device *dev, const void *fwnode)
 {
 	return dev->fwnode == fwnode;
 }
diff --git a/drivers/net/ethernet/ti/cpsw-phy-sel.c b/drivers/net/ethernet/ti/cpsw-phy-sel.c
index 48e0924..4e184ee 100644
--- a/drivers/net/ethernet/ti/cpsw-phy-sel.c
+++ b/drivers/net/ethernet/ti/cpsw-phy-sel.c
@@ -151,9 +151,9 @@ static void cpsw_gmii_sel_dra7xx(struct cpsw_phy_sel_priv *priv,
 }
 
 static struct platform_driver cpsw_phy_sel_driver;
-static int match(struct device *dev, void *data)
+static int match(struct device *dev, const void *data)
 {
-	struct device_node *node = (struct device_node *)data;
+	const struct device_node *node = (const struct device_node *)data;
 	return dev->of_node == node &&
 		dev->driver == &cpsw_phy_sel_driver.driver;
 }
diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
index 4bf65ca..57d131a 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -1371,7 +1371,7 @@ static int emac_devioctl(struct net_device *ndev, struct ifreq *ifrq, int cmd)
 		return -EOPNOTSUPP;
 }
 
-static int match_first_device(struct device *dev, void *data)
+static int match_first_device(struct device *dev, const void *data)
 {
 	if (dev->parent && dev->parent->of_node)
 		return of_device_is_compatible(dev->parent->of_node,
diff --git a/drivers/net/ethernet/toshiba/tc35815.c b/drivers/net/ethernet/toshiba/tc35815.c
index c50a977..8479a44 100644
--- a/drivers/net/ethernet/toshiba/tc35815.c
+++ b/drivers/net/ethernet/toshiba/tc35815.c
@@ -694,10 +694,10 @@ static int tc_mii_init(struct net_device *dev)
  * should provide a "tc35815-mac" device with a MAC address in its
  * platform_data.
  */
-static int tc35815_mac_match(struct device *dev, void *data)
+static int tc35815_mac_match(struct device *dev, const void *data)
 {
 	struct platform_device *plat_dev = to_platform_device(dev);
-	struct pci_dev *pci_dev = data;
+	const struct pci_dev *pci_dev = data;
 	unsigned int id = pci_dev->irq;
 	return !strcmp(plat_dev->name, "tc35815-mac") && plat_dev->id == id;
 }
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index c7892c3..ac5d945 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -76,7 +76,7 @@ static struct bus_type nvmem_bus_type = {
 	.name		= "nvmem",
 };
 
-static int of_nvmem_match(struct device *dev, void *nvmem_np)
+static int of_nvmem_match(struct device *dev, const void *nvmem_np)
 {
 	return dev->of_node == nvmem_np;
 }
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
index de61573..dfe1294 100644
--- a/drivers/of/of_mdio.c
+++ b/drivers/of/of_mdio.c
@@ -282,7 +282,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
 EXPORT_SYMBOL(of_mdiobus_register);
 
 /* Helper function for of_phy_find_device */
-static int of_phy_match(struct device *dev, void *phy_np)
+static int of_phy_match(struct device *dev, const void *phy_np)
 {
 	return dev->of_node == phy_np;
 }
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 04ad312..008d79e 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -37,7 +37,7 @@ static const struct of_device_id of_skipped_node_table[] = {
 	{} /* Empty terminated list */
 };
 
-static int of_dev_node_match(struct device *dev, void *data)
+static int of_dev_node_match(struct device *dev, const void *data)
 {
 	return dev->of_node == data;
 }
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 0e8e2c1..f9ef7ad 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -64,7 +64,7 @@ static struct resource *get_pci_domain_busn_res(int domain_nr)
 	return &r->res;
 }
 
-static int find_anything(struct device *dev, void *data)
+static int find_anything(struct device *dev, const void *data)
 {
 	return 1;
 }
diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index 5c79226..7f4e658 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -236,10 +236,10 @@ struct pci_dev *pci_get_domain_bus_and_slot(int domain, unsigned int bus,
 }
 EXPORT_SYMBOL(pci_get_domain_bus_and_slot);
 
-static int match_pci_dev_by_id(struct device *dev, void *data)
+static int match_pci_dev_by_id(struct device *dev, const void *data)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
-	struct pci_device_id *id = data;
+	const struct pci_device_id *id = data;
 
 	if (pci_match_one_device(id, pdev))
 		return 1;
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index aea5029..7b8488d 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -434,10 +434,10 @@ static int css_probe_device(struct subchannel_id schid, struct schib *schib)
 }
 
 static int
-check_subchannel(struct device * dev, void * data)
+check_subchannel(struct device *dev, const void *data)
 {
 	struct subchannel *sch;
-	struct subchannel_id *schid = data;
+	const struct subchannel_id *schid = data;
 
 	sch = to_subchannel(dev);
 	return schid_equal(&sch->schid, schid);
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index 1540229..6ca9a3a 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -642,10 +642,10 @@ static int ccw_device_add(struct ccw_device *cdev)
 	return device_add(dev);
 }
 
-static int match_dev_id(struct device *dev, void *data)
+static int match_dev_id(struct device *dev, const void *data)
 {
 	struct ccw_device *cdev = to_ccwdev(dev);
-	struct ccw_dev_id *dev_id = data;
+	const struct ccw_dev_id *dev_id = data;
 
 	return ccw_dev_id_is_equal(&cdev->private->dev_id, dev_id);
 }
diff --git a/drivers/s390/cio/scm.c b/drivers/s390/cio/scm.c
index 6bca1d5..9f26d43 100644
--- a/drivers/s390/cio/scm.c
+++ b/drivers/s390/cio/scm.c
@@ -174,10 +174,10 @@ static void scmdev_update(struct scm_device *scmdev, struct sale *sale)
 		kobject_uevent(&scmdev->dev.kobj, KOBJ_CHANGE);
 }
 
-static int check_address(struct device *dev, void *data)
+static int check_address(struct device *dev, const void *data)
 {
 	struct scm_device *scmdev = to_scm_dev(dev);
-	struct sale *sale = data;
+	const struct sale *sale = data;
 
 	return scmdev->address == sale->sa;
 }
diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c
index b9fc502..b7902b6 100644
--- a/drivers/s390/crypto/ap_bus.c
+++ b/drivers/s390/crypto/ap_bus.c
@@ -1356,16 +1356,16 @@ static int ap_get_compatible_type(ap_qid_t qid, int rawtype, unsigned int func)
  * Helper function to be used with bus_find_dev
  * matches for the card device with the given id
  */
-static int __match_card_device_with_id(struct device *dev, void *data)
+static int __match_card_device_with_id(struct device *dev, const void *data)
 {
-	return is_card_dev(dev) && to_ap_card(dev)->id == (int)(long) data;
+	return is_card_dev(dev) && to_ap_card(dev)->id == (int)(long)(void *) data;
 }
 
 /*
  * Helper function to be used with bus_find_dev
  * matches for the queue device with a given qid
  */
-static int __match_queue_device_with_qid(struct device *dev, void *data)
+static int __match_queue_device_with_qid(struct device *dev, const void *data)
 {
 	return is_queue_dev(dev) && to_ap_queue(dev)->qid == (int)(long) data;
 }
@@ -1374,7 +1374,7 @@ static int __match_queue_device_with_qid(struct device *dev, void *data)
  * Helper function to be used with bus_find_dev
  * matches any queue device with given queue id
  */
-static int __match_queue_device_with_queue_id(struct device *dev, void *data)
+static int __match_queue_device_with_queue_id(struct device *dev, const void *data)
 {
 	return is_queue_dev(dev)
 		&& AP_QID_QUEUE(to_ap_queue(dev)->qid) == (int)(long) data;
diff --git a/drivers/scsi/scsi_proc.c b/drivers/scsi/scsi_proc.c
index 7f0ceb6..c074631 100644
--- a/drivers/scsi/scsi_proc.c
+++ b/drivers/scsi/scsi_proc.c
@@ -372,7 +372,7 @@ static ssize_t proc_scsi_write(struct file *file, const char __user *buf,
 	return err;
 }
 
-static int always_match(struct device *dev, void *data)
+static int always_match(struct device *dev, const void *data)
 {
 	return 1;
 }
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 5e75944..3da1121 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -3538,7 +3538,7 @@ EXPORT_SYMBOL_GPL(spi_write_then_read);
 /*-------------------------------------------------------------------------*/
 
 #if IS_ENABLED(CONFIG_OF)
-static int __spi_of_device_match(struct device *dev, void *data)
+static int __spi_of_device_match(struct device *dev, const void *data)
 {
 	return dev->of_node == data;
 }
@@ -3639,7 +3639,7 @@ static int spi_acpi_controller_match(struct device *dev, const void *data)
 	return ACPI_COMPANION(dev->parent) == data;
 }
 
-static int spi_acpi_device_match(struct device *dev, void *data)
+static int spi_acpi_device_match(struct device *dev, const void *data)
 {
 	return ACPI_COMPANION(dev) == data;
 }
diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index 86a8545..3f8f340 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -561,9 +561,9 @@ static int split_string(char *buf, char **a, char **b, char **c, char **d)
 	return 0;
 }
 
-static int match_bus_dev(struct device *dev, void *data)
+static int match_bus_dev(struct device *dev, const void *data)
 {
-	char *mdev_name = data;
+	const char *mdev_name = data;
 
 	return !strcmp(dev_name(dev), mdev_name);
 }
diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
index c1b0165..c9a7e4a 100644
--- a/drivers/thunderbolt/switch.c
+++ b/drivers/thunderbolt/switch.c
@@ -1946,10 +1946,10 @@ struct tb_sw_lookup {
 	u64 route;
 };
 
-static int tb_switch_match(struct device *dev, void *data)
+static int tb_switch_match(struct device *dev, const void *data)
 {
 	struct tb_switch *sw = tb_to_switch(dev);
-	struct tb_sw_lookup *lookup = data;
+	const struct tb_sw_lookup *lookup = data;
 
 	if (!sw)
 		return 0;
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index fa783531..7bd7de7 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -947,9 +947,9 @@ static int parse_usbdevfs_streams(struct usb_dev_state *ps,
 	return ret;
 }
 
-static int match_devt(struct device *dev, void *data)
+static int match_devt(struct device *dev, const void *data)
 {
-	return dev->devt == (dev_t) (unsigned long) data;
+	return dev->devt == (dev_t)(unsigned long)(void *)data;
 }
 
 static struct usb_device *usbdev_lookup_by_devt(dev_t devt)
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 7fcb9f7..1678e30 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -325,9 +325,9 @@ struct find_interface_arg {
 	struct device_driver *drv;
 };
 
-static int __find_interface(struct device *dev, void *data)
+static int __find_interface(struct device *dev, const void *data)
 {
-	struct find_interface_arg *arg = data;
+	const struct find_interface_arg *arg = data;
 	struct usb_interface *intf;
 
 	if (!is_usb_interface(dev))
diff --git a/drivers/usb/phy/phy-am335x-control.c b/drivers/usb/phy/phy-am335x-control.c
index a3cb25c..d16dfc3 100644
--- a/drivers/usb/phy/phy-am335x-control.c
+++ b/drivers/usb/phy/phy-am335x-control.c
@@ -118,9 +118,9 @@ static const struct of_device_id omap_control_usb_id_table[] = {
 MODULE_DEVICE_TABLE(of, omap_control_usb_id_table);
 
 static struct platform_driver am335x_control_driver;
-static int match(struct device *dev, void *data)
+static int match(struct device *dev, const void *data)
 {
-	struct device_node *node = (struct device_node *)data;
+	const struct device_node *node = (const struct device_node *)data;
 	return dev->of_node == node &&
 		dev->driver == &am335x_control_driver.driver;
 }
diff --git a/drivers/usb/phy/phy-isp1301.c b/drivers/usb/phy/phy-isp1301.c
index 93b7d6a..6cf6fbd 100644
--- a/drivers/usb/phy/phy-isp1301.c
+++ b/drivers/usb/phy/phy-isp1301.c
@@ -142,9 +142,9 @@ static struct i2c_driver isp1301_driver = {
 
 module_i2c_driver(isp1301_driver);
 
-static int match(struct device *dev, void *data)
+static int match(struct device *dev, const void *data)
 {
-	struct device_node *node = (struct device_node *)data;
+	const struct device_node *node = (const struct device_node *)data;
 	return (dev->of_node == node) &&
 		(dev->driver == &isp1301_driver.driver);
 }
diff --git a/drivers/visorbus/visorbus_main.c b/drivers/visorbus/visorbus_main.c
index 0b2434c..152fd29 100644
--- a/drivers/visorbus/visorbus_main.c
+++ b/drivers/visorbus/visorbus_main.c
@@ -171,10 +171,10 @@ struct visor_busdev {
 	u32 dev_no;
 };
 
-static int match_visorbus_dev_by_id(struct device *dev, void *data)
+static int match_visorbus_dev_by_id(struct device *dev, const void *data)
 {
 	struct visor_device *vdev = to_visor_device(dev);
-	struct visor_busdev *id = data;
+	const struct visor_busdev *id = data;
 
 	if (vdev->chipset_bus_no == id->bus_no &&
 	    vdev->chipset_dev_no == id->dev_no)
diff --git a/include/linux/device.h b/include/linux/device.h
index e85264f..cbbdcadc 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -166,8 +166,8 @@ void subsys_dev_iter_exit(struct subsys_dev_iter *iter);
 int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
 		     int (*fn)(struct device *dev, void *data));
 struct device *bus_find_device(struct bus_type *bus, struct device *start,
-			       void *data,
-			       int (*match)(struct device *dev, void *data));
+			       const void *data,
+			       int (*match)(struct device *dev, const void *data));
 struct device *bus_find_device_by_name(struct bus_type *bus,
 				       struct device *start,
 				       const char *name);
diff --git a/sound/soc/rockchip/rk3399_gru_sound.c b/sound/soc/rockchip/rk3399_gru_sound.c
index 3d0cc6e..c04c9ed 100644
--- a/sound/soc/rockchip/rk3399_gru_sound.c
+++ b/sound/soc/rockchip/rk3399_gru_sound.c
@@ -405,7 +405,7 @@ static const struct dailink_match_data dailink_match[] = {
 	},
 };
 
-static int of_dev_node_match(struct device *dev, void *data)
+static int of_dev_node_match(struct device *dev, const void *data)
 {
 	return dev->of_node == data;
 }
-- 
2.7.4


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

* [PATCH 03/13] driver_find_device: Unify the match function with class_find_device()
  2019-06-05 15:13 ` Suzuki K Poulose
                   ` (3 preceding siblings ...)
  (?)
@ 2019-06-05 15:13 ` Suzuki K Poulose
  2019-06-12  9:32   ` Lee Jones
  -1 siblings, 1 reply; 39+ messages in thread
From: Suzuki K Poulose @ 2019-06-05 15:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Corey Minyard, Russell King,
	Thierry Reding, Will Deacon, Joerg Roedel, Peter Oberparleiter,
	Sebastian Ott, David Airlie, Daniel Vetter, Nehal Shah,
	Shyam Sundar S K, Lee Jones, Christian Borntraeger

The driver_find_device() accepts a match function pointer to
filter the devices for lookup, similar to bus/class_find_device().
However, there is a minor difference in the prototype for the
match parameter for driver_find_device() with the now unified
version accepted by {bus/class}_find_device(), where it doesn't
accept a "const" qualifier for the data argument. This prevents
us from reusing the generic match functions for driver_find_device().

For this reason, change the prototype of the driver_find_device() to
make the "match" parameter in line with {bus/class}_find_device()
and adjust its callers to use the const qualifier. Also, we could
now promote the "data" parameter to const as we pass it down
as a const parameter to the match functions.

Cc: Corey Minyard <minyard@acm.org>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
Cc: Sebastian Ott <sebott@linux.ibm.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Nehal Shah <nehal-bakulchandra.shah@amd.com>
Cc: Shyam Sundar S K <shyam-sundar.s-k@amd.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/amba/tegra-ahb.c             | 4 ++--
 drivers/base/driver.c                | 4 ++--
 drivers/char/ipmi/ipmi_msghandler.c  | 8 ++++----
 drivers/gpu/drm/tegra/dc.c           | 4 ++--
 drivers/i2c/busses/i2c-amd-mp2-pci.c | 2 +-
 drivers/iommu/arm-smmu-v3.c          | 2 +-
 drivers/iommu/arm-smmu.c             | 2 +-
 drivers/mfd/altera-sysmgr.c          | 4 ++--
 drivers/mfd/syscon.c                 | 2 +-
 drivers/s390/cio/ccwgroup.c          | 2 +-
 drivers/s390/cio/chsc_sch.c          | 2 +-
 drivers/s390/cio/device.c            | 2 +-
 include/linux/device.h               | 4 ++--
 13 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/amba/tegra-ahb.c b/drivers/amba/tegra-ahb.c
index 3751d81..42175a6 100644
--- a/drivers/amba/tegra-ahb.c
+++ b/drivers/amba/tegra-ahb.c
@@ -143,10 +143,10 @@ static inline void gizmo_writel(struct tegra_ahb *ahb, u32 value, u32 offset)
 }
 
 #ifdef CONFIG_TEGRA_IOMMU_SMMU
-static int tegra_ahb_match_by_smmu(struct device *dev, void *data)
+static int tegra_ahb_match_by_smmu(struct device *dev, const void *data)
 {
 	struct tegra_ahb *ahb = dev_get_drvdata(dev);
-	struct device_node *dn = data;
+	const struct device_node *dn = data;
 
 	return (ahb->dev->of_node == dn) ? 1 : 0;
 }
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 857c8f1..4e5ca63 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -73,8 +73,8 @@ EXPORT_SYMBOL_GPL(driver_for_each_device);
  * return to the caller and not iterate over any more devices.
  */
 struct device *driver_find_device(struct device_driver *drv,
-				  struct device *start, void *data,
-				  int (*match)(struct device *dev, void *data))
+				  struct device *start, const void *data,
+				  int (*match)(struct device *dev, const void *data))
 {
 	struct klist_iter i;
 	struct device *dev;
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 1dc1074..6707659 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -2819,9 +2819,9 @@ static const struct device_type bmc_device_type = {
 	.groups		= bmc_dev_attr_groups,
 };
 
-static int __find_bmc_guid(struct device *dev, void *data)
+static int __find_bmc_guid(struct device *dev, const void *data)
 {
-	guid_t *guid = data;
+	const guid_t *guid = data;
 	struct bmc_device *bmc;
 	int rv;
 
@@ -2857,9 +2857,9 @@ struct prod_dev_id {
 	unsigned char device_id;
 };
 
-static int __find_bmc_prod_dev_id(struct device *dev, void *data)
+static int __find_bmc_prod_dev_id(struct device *dev, const void *data)
 {
-	struct prod_dev_id *cid = data;
+	const struct prod_dev_id *cid = data;
 	struct bmc_device *bmc;
 	int rv;
 
diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index 607a6ea1..52109a6 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -2375,10 +2375,10 @@ static int tegra_dc_parse_dt(struct tegra_dc *dc)
 	return 0;
 }
 
-static int tegra_dc_match_by_pipe(struct device *dev, void *data)
+static int tegra_dc_match_by_pipe(struct device *dev, const void *data)
 {
 	struct tegra_dc *dc = dev_get_drvdata(dev);
-	unsigned int pipe = (unsigned long)data;
+	unsigned int pipe = (unsigned long)(void *)data;
 
 	return dc->pipe == pipe;
 }
diff --git a/drivers/i2c/busses/i2c-amd-mp2-pci.c b/drivers/i2c/busses/i2c-amd-mp2-pci.c
index 455e1f3..c7fe3b4 100644
--- a/drivers/i2c/busses/i2c-amd-mp2-pci.c
+++ b/drivers/i2c/busses/i2c-amd-mp2-pci.c
@@ -457,7 +457,7 @@ static struct pci_driver amd_mp2_pci_driver = {
 };
 module_pci_driver(amd_mp2_pci_driver);
 
-static int amd_mp2_device_match(struct device *dev, void *data)
+static int amd_mp2_device_match(struct device *dev, const void *data)
 {
 	return 1;
 }
diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
index 4d5a694..d787856 100644
--- a/drivers/iommu/arm-smmu-v3.c
+++ b/drivers/iommu/arm-smmu-v3.c
@@ -2023,7 +2023,7 @@ arm_smmu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova)
 
 static struct platform_driver arm_smmu_driver;
 
-static int arm_smmu_match_node(struct device *dev, void *data)
+static int arm_smmu_match_node(struct device *dev, const void *data)
 {
 	return dev->fwnode == data;
 }
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index 5e54cc0..4ce429b 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -1431,7 +1431,7 @@ static bool arm_smmu_capable(enum iommu_cap cap)
 	}
 }
 
-static int arm_smmu_match_node(struct device *dev, void *data)
+static int arm_smmu_match_node(struct device *dev, const void *data)
 {
 	return dev->fwnode == data;
 }
diff --git a/drivers/mfd/altera-sysmgr.c b/drivers/mfd/altera-sysmgr.c
index 8976f82..2ee14d8 100644
--- a/drivers/mfd/altera-sysmgr.c
+++ b/drivers/mfd/altera-sysmgr.c
@@ -92,9 +92,9 @@ static struct regmap_config altr_sysmgr_regmap_cfg = {
  * Matching function used by driver_find_device().
  * Return: True if match is found, otherwise false.
  */
-static int sysmgr_match_phandle(struct device *dev, void *data)
+static int sysmgr_match_phandle(struct device *dev, const void *data)
 {
-	return dev->of_node == (struct device_node *)data;
+	return dev->of_node == (const struct device_node *)data;
 }
 
 /**
diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index 8ce1e41..4f39ba5 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -190,7 +190,7 @@ struct regmap *syscon_regmap_lookup_by_compatible(const char *s)
 }
 EXPORT_SYMBOL_GPL(syscon_regmap_lookup_by_compatible);
 
-static int syscon_match_pdevname(struct device *dev, void *data)
+static int syscon_match_pdevname(struct device *dev, const void *data)
 {
 	return !strcmp(dev_name(dev), (const char *)data);
 }
diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c
index 4ebf6d4..7c27e53 100644
--- a/drivers/s390/cio/ccwgroup.c
+++ b/drivers/s390/cio/ccwgroup.c
@@ -608,7 +608,7 @@ void ccwgroup_driver_unregister(struct ccwgroup_driver *cdriver)
 }
 EXPORT_SYMBOL(ccwgroup_driver_unregister);
 
-static int __ccwgroupdev_check_busid(struct device *dev, void *id)
+static int __ccwgroupdev_check_busid(struct device *dev, const void *id)
 {
 	char *bus_id = id;
 
diff --git a/drivers/s390/cio/chsc_sch.c b/drivers/s390/cio/chsc_sch.c
index 8d9f366..8f080d3 100644
--- a/drivers/s390/cio/chsc_sch.c
+++ b/drivers/s390/cio/chsc_sch.c
@@ -203,7 +203,7 @@ static void chsc_cleanup_sch_driver(void)
 
 static DEFINE_SPINLOCK(chsc_lock);
 
-static int chsc_subchannel_match_next_free(struct device *dev, void *data)
+static int chsc_subchannel_match_next_free(struct device *dev, const void *data)
 {
 	struct subchannel *sch = to_subchannel(dev);
 
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index 6ca9a3a..a5c2765 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -1653,7 +1653,7 @@ EXPORT_SYMBOL_GPL(ccw_device_force_console);
  * get ccw_device matching the busid, but only if owned by cdrv
  */
 static int
-__ccwdev_check_busid(struct device *dev, void *id)
+__ccwdev_check_busid(struct device *dev, const void *id)
 {
 	char *bus_id;
 
diff --git a/include/linux/device.h b/include/linux/device.h
index cbbdcadc..4d7c881 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -336,8 +336,8 @@ extern int __must_check driver_for_each_device(struct device_driver *drv,
 					       int (*fn)(struct device *dev,
 							 void *));
 struct device *driver_find_device(struct device_driver *drv,
-				  struct device *start, void *data,
-				  int (*match)(struct device *dev, void *data));
+				  struct device *start, const void *data,
+				  int (*match)(struct device *dev, const void *data));
 
 void driver_deferred_probe_add(struct device *dev);
 int driver_deferred_probe_check_state(struct device *dev);
-- 
2.7.4


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

* [PATCH 04/13] drivers: Add generic helper to match by of_node
  2019-06-05 15:13 ` Suzuki K Poulose
  (?)
@ 2019-06-05 15:13   ` Suzuki K Poulose
  -1 siblings, 0 replies; 39+ messages in thread
From: Suzuki K Poulose @ 2019-06-05 15:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Alan Tull, Andrew Lunn,
	Daniel Vetter, David Airlie, David S. Miller, devicetree,
	dri-devel, Florian Fainelli, Frank Rowand, Heiner Kallweit,
	Jiri Slaby, Jonathan Hunter, Lee Jones, Liam Girdwood,
	linux-fpga, linux-i2c, linux-spi, Maarten Lankhorst, Mark Brown,
	Mathieu Poirier, Maxime Ripard, Moritz Fischer, Peter Rosin,
	Rob Herring, Srinivas Kandagatla, Thierry Reding, Thor Thayer,
	Wolfram Sang, Ulf Hansson, Joe Perches

Add a helper to match device by the of_node. This will be later used
to provide generic lookup functions by of_node.

Cc: Alan Tull <atull@kernel.org>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: David Airlie <airlied@linux.ie>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: devicetree@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: linux-fpga@vger.kernel.org
Cc: linux-i2c@vger.kernel.org
Cc: linux-spi@vger.kernel.org
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Maxime Ripard <maxime.ripard@bootlin.com>
Cc: Moritz Fischer <mdf@kernel.org>
Cc: Peter Rosin <peda@axentia.se>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Thor Thayer <thor.thayer@linux.intel.com>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/base/core.c    | 6 ++++++
 include/linux/device.h | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index fd7511e..9211908 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -3328,3 +3328,9 @@ void device_set_of_node_from_dev(struct device *dev, const struct device *dev2)
 	dev->of_node_reused = true;
 }
 EXPORT_SYMBOL_GPL(device_set_of_node_from_dev);
+
+int device_match_of_node(struct device *dev, const void *np)
+{
+	return dev->of_node == np;
+}
+EXPORT_SYMBOL_GPL(device_match_of_node);
diff --git a/include/linux/device.h b/include/linux/device.h
index 4d7c881..7093085 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -163,6 +163,8 @@ void subsys_dev_iter_init(struct subsys_dev_iter *iter,
 struct device *subsys_dev_iter_next(struct subsys_dev_iter *iter);
 void subsys_dev_iter_exit(struct subsys_dev_iter *iter);
 
+int device_match_of_node(struct device *dev, const void *np);
+
 int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
 		     int (*fn)(struct device *dev, void *data));
 struct device *bus_find_device(struct bus_type *bus, struct device *start,
-- 
2.7.4


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

* [PATCH 04/13] drivers: Add generic helper to match by of_node
@ 2019-06-05 15:13   ` Suzuki K Poulose
  0 siblings, 0 replies; 39+ messages in thread
From: Suzuki K Poulose @ 2019-06-05 15:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Alan Tull, Andrew Lunn,
	Daniel Vetter, David Airlie, David S. Miller, devicetree,
	dri-devel, Florian Fainelli, Frank Rowand, Heiner Kallweit,
	Jiri Slaby, Jonathan Hunter, Lee Jones, Liam Girdwood,
	linux-fpga, linux-i2c, linux-spi, Maarten Lankhorst, Mark Brown,
	Mathieu Poirier

Add a helper to match device by the of_node. This will be later used
to provide generic lookup functions by of_node.

Cc: Alan Tull <atull@kernel.org>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: David Airlie <airlied@linux.ie>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: devicetree@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: linux-fpga@vger.kernel.org
Cc: linux-i2c@vger.kernel.org
Cc: linux-spi@vger.kernel.org
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Maxime Ripard <maxime.ripard@bootlin.com>
Cc: Moritz Fischer <mdf@kernel.org>
Cc: Peter Rosin <peda@axentia.se>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Thor Thayer <thor.thayer@linux.intel.com>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/base/core.c    | 6 ++++++
 include/linux/device.h | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index fd7511e..9211908 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -3328,3 +3328,9 @@ void device_set_of_node_from_dev(struct device *dev, const struct device *dev2)
 	dev->of_node_reused = true;
 }
 EXPORT_SYMBOL_GPL(device_set_of_node_from_dev);
+
+int device_match_of_node(struct device *dev, const void *np)
+{
+	return dev->of_node == np;
+}
+EXPORT_SYMBOL_GPL(device_match_of_node);
diff --git a/include/linux/device.h b/include/linux/device.h
index 4d7c881..7093085 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -163,6 +163,8 @@ void subsys_dev_iter_init(struct subsys_dev_iter *iter,
 struct device *subsys_dev_iter_next(struct subsys_dev_iter *iter);
 void subsys_dev_iter_exit(struct subsys_dev_iter *iter);
 
+int device_match_of_node(struct device *dev, const void *np);
+
 int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
 		     int (*fn)(struct device *dev, void *data));
 struct device *bus_find_device(struct bus_type *bus, struct device *start,
-- 
2.7.4

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

* [PATCH 04/13] drivers: Add generic helper to match by of_node
@ 2019-06-05 15:13   ` Suzuki K Poulose
  0 siblings, 0 replies; 39+ messages in thread
From: Suzuki K Poulose @ 2019-06-05 15:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Alan Tull, Andrew Lunn,
	Daniel Vetter, David Airlie, David S. Miller, devicetree,
	dri-devel, Florian Fainelli, Frank Rowand, Heiner Kallweit,
	Jiri Slaby, Jonathan Hunter, Lee Jones, Liam Girdwood,
	linux-fpga, linux-i2c, linux-spi, Maarten Lankhorst, Mark Brown,
	Mathieu Poirier

Add a helper to match device by the of_node. This will be later used
to provide generic lookup functions by of_node.

Cc: Alan Tull <atull@kernel.org>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: David Airlie <airlied@linux.ie>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: devicetree@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: linux-fpga@vger.kernel.org
Cc: linux-i2c@vger.kernel.org
Cc: linux-spi@vger.kernel.org
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Maxime Ripard <maxime.ripard@bootlin.com>
Cc: Moritz Fischer <mdf@kernel.org>
Cc: Peter Rosin <peda@axentia.se>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Thor Thayer <thor.thayer@linux.intel.com>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/base/core.c    | 6 ++++++
 include/linux/device.h | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index fd7511e..9211908 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -3328,3 +3328,9 @@ void device_set_of_node_from_dev(struct device *dev, const struct device *dev2)
 	dev->of_node_reused = true;
 }
 EXPORT_SYMBOL_GPL(device_set_of_node_from_dev);
+
+int device_match_of_node(struct device *dev, const void *np)
+{
+	return dev->of_node == np;
+}
+EXPORT_SYMBOL_GPL(device_match_of_node);
diff --git a/include/linux/device.h b/include/linux/device.h
index 4d7c881..7093085 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -163,6 +163,8 @@ void subsys_dev_iter_init(struct subsys_dev_iter *iter,
 struct device *subsys_dev_iter_next(struct subsys_dev_iter *iter);
 void subsys_dev_iter_exit(struct subsys_dev_iter *iter);
 
+int device_match_of_node(struct device *dev, const void *np);
+
 int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
 		     int (*fn)(struct device *dev, void *data));
 struct device *bus_find_device(struct bus_type *bus, struct device *start,
-- 
2.7.4

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

* [PATCH 05/13] drivers: Add generic helper to match by fwnode
  2019-06-05 15:13 ` Suzuki K Poulose
                   ` (5 preceding siblings ...)
  (?)
@ 2019-06-05 15:13 ` Suzuki K Poulose
  -1 siblings, 0 replies; 39+ messages in thread
From: Suzuki K Poulose @ 2019-06-05 15:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, David S. Miller, Doug Ledford,
	Heikki Krogerus, Jason Gunthorpe, linux-usb, Ulf Hansson,
	Joe Perches

Add a helper to match the firmware node handle of a device. This
will be used later for generic look up by fwnode helpers.

Cc: "David S. Miller" <davem@davemloft.net>
Cc: Doug Ledford <dledford@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: linux-usb@vger.kernel.org
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/base/core.c    | 6 ++++++
 include/linux/device.h | 1 +
 2 files changed, 7 insertions(+)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 9211908..efcdb96 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -3334,3 +3334,9 @@ int device_match_of_node(struct device *dev, const void *np)
 	return dev->of_node == np;
 }
 EXPORT_SYMBOL_GPL(device_match_of_node);
+
+int device_match_fwnode(struct device *dev, const void *fwnode)
+{
+	return dev_fwnode(dev) == fwnode;
+}
+EXPORT_SYMBOL_GPL(device_match_fwnode);
diff --git a/include/linux/device.h b/include/linux/device.h
index 7093085..08aa087 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -164,6 +164,7 @@ struct device *subsys_dev_iter_next(struct subsys_dev_iter *iter);
 void subsys_dev_iter_exit(struct subsys_dev_iter *iter);
 
 int device_match_of_node(struct device *dev, const void *np);
+int device_match_fwnode(struct device *dev, const void *fwnode);
 
 int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
 		     int (*fn)(struct device *dev, void *data));
-- 
2.7.4


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

* [PATCH 06/13] drivers: Add generic helper to match by devt
  2019-06-05 15:13 ` Suzuki K Poulose
                   ` (6 preceding siblings ...)
  (?)
@ 2019-06-05 15:13 ` Suzuki K Poulose
  -1 siblings, 0 replies; 39+ messages in thread
From: Suzuki K Poulose @ 2019-06-05 15:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Alexander Shishkin,
	Arnd Bergmann, Harald Freudenberger, Heiko Carstens, linux-usb,
	Oliver Neukum, Sebastian Andrzej Siewior, Tomas Winkler,
	Ulf Hansson, Joe Perches

Add a helper to match the device type.

Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Harald Freudenberger <freude@linux.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux-usb@vger.kernel.org
Cc: Oliver Neukum <oneukum@suse.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Tomas Winkler <tomas.winkler@intel.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/base/core.c    | 6 ++++++
 include/linux/device.h | 1 +
 2 files changed, 7 insertions(+)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index efcdb96..b827ca1 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -3340,3 +3340,9 @@ int device_match_fwnode(struct device *dev, const void *fwnode)
 	return dev_fwnode(dev) == fwnode;
 }
 EXPORT_SYMBOL_GPL(device_match_fwnode);
+
+int device_match_devt(struct device *dev, const void *pdevt)
+{
+	return dev->devt == *(dev_t *)pdevt;
+}
+EXPORT_SYMBOL_GPL(device_match_devt);
diff --git a/include/linux/device.h b/include/linux/device.h
index 08aa087..f315692 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -165,6 +165,7 @@ void subsys_dev_iter_exit(struct subsys_dev_iter *iter);
 
 int device_match_of_node(struct device *dev, const void *np);
 int device_match_fwnode(struct device *dev, const void *fwnode);
+int device_match_devt(struct device *dev, const void *pdevt);
 
 int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
 		     int (*fn)(struct device *dev, void *data));
-- 
2.7.4


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

* [PATCH 07/13] drivers: Add generic match helper by ACPI_COMPANION device
  2019-06-05 15:13 ` Suzuki K Poulose
                   ` (7 preceding siblings ...)
  (?)
@ 2019-06-05 15:13 ` Suzuki K Poulose
  2019-06-06  9:17   ` Rafael J. Wysocki
  -1 siblings, 1 reply; 39+ messages in thread
From: Suzuki K Poulose @ 2019-06-05 15:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Len Brown, linux-acpi, linux-spi,
	Mark Brown

Add a generic helper to match a device by the acpi device.

Cc: Len Brown <lenb@kernel.org>
Cc: linux-acpi@vger.kernel.org
Cc: linux-spi@vger.kernel.org
Cc: Mark Brown <broonie@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/base/core.c    | 6 ++++++
 include/linux/device.h | 1 +
 2 files changed, 7 insertions(+)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index b827ca1..597095b 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -3346,3 +3346,9 @@ int device_match_devt(struct device *dev, const void *pdevt)
 	return dev->devt == *(dev_t *)pdevt;
 }
 EXPORT_SYMBOL_GPL(device_match_devt);
+
+int device_match_acpi_dev(struct device *dev, const void *adev)
+{
+	return ACPI_COMPANION(dev) == adev;
+}
+EXPORT_SYMBOL(device_match_acpi_dev);
diff --git a/include/linux/device.h b/include/linux/device.h
index f315692..a03b50d 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -166,6 +166,7 @@ void subsys_dev_iter_exit(struct subsys_dev_iter *iter);
 int device_match_of_node(struct device *dev, const void *np);
 int device_match_fwnode(struct device *dev, const void *fwnode);
 int device_match_devt(struct device *dev, const void *pdevt);
+int device_match_acpi_dev(struct device *dev, const void *adev);
 
 int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
 		     int (*fn)(struct device *dev, void *data));
-- 
2.7.4


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

* [PATCH 08/13] drivers: Add generic helper to match by name
  2019-06-05 15:13 ` Suzuki K Poulose
@ 2019-06-05 15:13   ` Suzuki K Poulose
  -1 siblings, 0 replies; 39+ messages in thread
From: Suzuki K Poulose @ 2019-06-05 15:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Alessandro Zummo,
	Alexander Aring, Alexander Shishkin, Alexandre Belloni,
	Arnd Bergmann, Dan Murphy, Harald Freudenberger, Heikki Krogerus,
	Heiko Carstens, Jacek Anaszewski, Lee Jones, linux-leds,
	linux-rtc, linux-usb, linux-wpan, Martin Schwidefsky,
	Maxime Coquelin, Pavel Machek

Add a helper to match the device name

Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexander Aring <alex.aring@gmail.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Dan Murphy <dmurphy@ti.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Harald Freudenberger <freude@linux.ibm.com>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: linux-leds@vger.kernel.org
Cc: linux-rtc@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: linux-wpan@vger.kernel.org
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Stefan Schmidt <stefan@datenfreihafen.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/base/core.c    | 6 ++++++
 include/linux/device.h | 1 +
 2 files changed, 7 insertions(+)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 597095b..5724f93 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -3352,3 +3352,9 @@ int device_match_acpi_dev(struct device *dev, const void *adev)
 	return ACPI_COMPANION(dev) == adev;
 }
 EXPORT_SYMBOL(device_match_acpi_dev);
+
+int device_match_name(struct device *dev, const void *name)
+{
+	return sysfs_streq(dev_name(dev), name);
+}
+EXPORT_SYMBOL_GPL(device_match_name);
diff --git a/include/linux/device.h b/include/linux/device.h
index a03b50d..74dd9c6 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -167,6 +167,7 @@ int device_match_of_node(struct device *dev, const void *np);
 int device_match_fwnode(struct device *dev, const void *fwnode);
 int device_match_devt(struct device *dev, const void *pdevt);
 int device_match_acpi_dev(struct device *dev, const void *adev);
+int device_match_name(struct device *dev, const void *name);
 
 int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
 		     int (*fn)(struct device *dev, void *data));
-- 
2.7.4

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

* [PATCH 08/13] drivers: Add generic helper to match by name
@ 2019-06-05 15:13   ` Suzuki K Poulose
  0 siblings, 0 replies; 39+ messages in thread
From: Suzuki K Poulose @ 2019-06-05 15:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Alessandro Zummo,
	Alexander Aring, Alexander Shishkin, Alexandre Belloni,
	Arnd Bergmann, Dan Murphy, Harald Freudenberger, Heikki Krogerus,
	Heiko Carstens, Jacek Anaszewski, Lee Jones, linux-leds,
	linux-rtc, linux-usb, linux-wpan, Martin Schwidefsky,
	Maxime Coquelin, Pavel Machek, Peter Oberparleiter,
	Stefan Schmidt, Rafael J. Wysocki

Add a helper to match the device name

Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexander Aring <alex.aring@gmail.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Dan Murphy <dmurphy@ti.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Harald Freudenberger <freude@linux.ibm.com>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: linux-leds@vger.kernel.org
Cc: linux-rtc@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: linux-wpan@vger.kernel.org
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Stefan Schmidt <stefan@datenfreihafen.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/base/core.c    | 6 ++++++
 include/linux/device.h | 1 +
 2 files changed, 7 insertions(+)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 597095b..5724f93 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -3352,3 +3352,9 @@ int device_match_acpi_dev(struct device *dev, const void *adev)
 	return ACPI_COMPANION(dev) == adev;
 }
 EXPORT_SYMBOL(device_match_acpi_dev);
+
+int device_match_name(struct device *dev, const void *name)
+{
+	return sysfs_streq(dev_name(dev), name);
+}
+EXPORT_SYMBOL_GPL(device_match_name);
diff --git a/include/linux/device.h b/include/linux/device.h
index a03b50d..74dd9c6 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -167,6 +167,7 @@ int device_match_of_node(struct device *dev, const void *np);
 int device_match_fwnode(struct device *dev, const void *fwnode);
 int device_match_devt(struct device *dev, const void *pdevt);
 int device_match_acpi_dev(struct device *dev, const void *adev);
+int device_match_name(struct device *dev, const void *name);
 
 int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
 		     int (*fn)(struct device *dev, void *data));
-- 
2.7.4


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

* [PATCH 09/13] drivers: Add generic helper to match any device
  2019-06-05 15:13 ` Suzuki K Poulose
                   ` (9 preceding siblings ...)
  (?)
@ 2019-06-05 15:13 ` Suzuki K Poulose
  -1 siblings, 0 replies; 39+ messages in thread
From: Suzuki K Poulose @ 2019-06-05 15:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Bjorn Helgaas, Elie Morisse,
	James E.J. Bottomley, Martin K. Petersen, Nehal Shah,
	Rafael J. Wysocki, Shyam Sundar S K

Add a generic helper to match any/all devices.

Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Elie Morisse <syniurge@gmail.com>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Nehal Shah <nehal-bakulchandra.shah@amd.com>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Cc: Shyam Sundar S K <shyam-sundar.s-k@amd.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/base/core.c    | 6 ++++++
 include/linux/device.h | 1 +
 2 files changed, 7 insertions(+)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 5724f93..053ee2e 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -3358,3 +3358,9 @@ int device_match_name(struct device *dev, const void *name)
 	return sysfs_streq(dev_name(dev), name);
 }
 EXPORT_SYMBOL_GPL(device_match_name);
+
+int device_match_any(struct device *dev, const void *unused)
+{
+	return 1;
+}
+EXPORT_SYMBOL_GPL(device_match_any);
diff --git a/include/linux/device.h b/include/linux/device.h
index 74dd9c6..8c8727b 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -168,6 +168,7 @@ int device_match_fwnode(struct device *dev, const void *fwnode);
 int device_match_devt(struct device *dev, const void *pdevt);
 int device_match_acpi_dev(struct device *dev, const void *adev);
 int device_match_name(struct device *dev, const void *name);
+int device_match_any(struct device *dev, const void *unused);
 
 int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
 		     int (*fn)(struct device *dev, void *data));
-- 
2.7.4


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

* [PATCH 10/13] drivers: Introduce variants of class_find_device()
  2019-06-05 15:13 ` Suzuki K Poulose
@ 2019-06-05 15:13   ` Suzuki K Poulose
  -1 siblings, 0 replies; 39+ messages in thread
From: Suzuki K Poulose @ 2019-06-05 15:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Alessandro Zummo,
	Alexander Aring, Alexander Shishkin, Alexandre Belloni,
	Andrew Lunn, Arnd Bergmann, Dan Murphy, David S. Miller,
	Florian Fainelli, Harald Freudenberger, Heikki Krogerus,
	Heiko Carstens, Heiner Kallweit, Jacek Anaszewski, Jiri Slaby,
	Liam Girdwood, linux-leds, linux-rtc

Now that we have generic helpers to match various generic
device attributes, provide wrappers to the class_find_device()
to lookup devices by individual properties. The new wrappers
except the lookup by devt, drops the "start" device pointer as
none of the existing users need it and the attributes are usually
unique. The idea is to stop the proliferation of custom match
functions to do generic attribute matching.

So now we have :

    class_find_device_by_name
    class_find_device_by_of_node
    class_find_device_by_fwnode
    class_find_device_by_devt

Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexander Aring <alex.aring@gmail.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Dan Murphy <dmurphy@ti.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Harald Freudenberger <freude@linux.ibm.com>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: linux-leds@vger.kernel.org
Cc: linux-rtc@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: linux-wpan@vger.kernel.org
Cc: Mark Brown <broonie@kernel.org>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Peter Rosin <peda@axentia.se>
Cc: Stefan Schmidt <stefan@datenfreihafen.org>
Cc: Tomas Winkler <tomas.winkler@intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 include/linux/device.h | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/include/linux/device.h b/include/linux/device.h
index 8c8727b..4396edc 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -474,6 +474,57 @@ extern struct device *class_find_device(struct class *class,
 					struct device *start, const void *data,
 					int (*match)(struct device *, const void *));
 
+/**
+ * class_find_device_by_name - device iterator for locating a particular device
+ * of a specific name.
+ * @class: class type
+ * @name: name of the device to match
+ */
+static inline struct device *class_find_device_by_name(struct class *class,
+						       const char *name)
+{
+	return class_find_device(class, NULL, name, device_match_name);
+}
+
+/**
+ * class_find_device_by_of_node : device iterator for locating a particular device
+ * matching the of_node.
+ * @class: class type
+ * @np: of_node of the device to match.
+ */
+static inline struct device *
+class_find_device_by_of_node(struct class *class, const struct device_node *np)
+{
+	return class_find_device(class, NULL, np, device_match_of_node);
+}
+
+/**
+ * class_find_device_by_fwnode : device iterator for locating a particular device
+ * matching the fwnode.
+ * @class: class type
+ * @fwnode: fwnode of the device to match.
+ */
+static inline struct device *
+class_find_device_by_fwnode(struct class *class,
+			    const struct fwnode_handle *fwnode)
+{
+	return class_find_device(class, NULL, fwnode, device_match_fwnode);
+}
+
+/**
+ * class_find_device_by_devt : device iterator for locating a particular device
+ * matching the device type.
+ * @class: class type
+ * @start: device to start search from
+ * @devt: device type of the device to match.
+ */
+static inline struct device *class_find_device_by_devt(struct class *class,
+						       struct device *start,
+						       dev_t devt)
+{
+	return class_find_device(class, start, &devt, device_match_devt);
+}
+
 struct class_attribute {
 	struct attribute attr;
 	ssize_t (*show)(struct class *class, struct class_attribute *attr,
-- 
2.7.4

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

* [PATCH 10/13] drivers: Introduce variants of class_find_device()
@ 2019-06-05 15:13   ` Suzuki K Poulose
  0 siblings, 0 replies; 39+ messages in thread
From: Suzuki K Poulose @ 2019-06-05 15:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Alessandro Zummo,
	Alexander Aring, Alexander Shishkin, Alexandre Belloni,
	Andrew Lunn, Arnd Bergmann, Dan Murphy, David S. Miller,
	Florian Fainelli, Harald Freudenberger, Heikki Krogerus,
	Heiko Carstens, Heiner Kallweit, Jacek Anaszewski, Jiri Slaby,
	Liam Girdwood, linux-leds, linux-rtc, linux-usb, linux-wpan,
	Mark Brown, Maxime Coquelin, Pavel Machek, Peter Rosin,
	Stefan Schmidt, Tomas Winkler, Rafael J. Wysocki

Now that we have generic helpers to match various generic
device attributes, provide wrappers to the class_find_device()
to lookup devices by individual properties. The new wrappers
except the lookup by devt, drops the "start" device pointer as
none of the existing users need it and the attributes are usually
unique. The idea is to stop the proliferation of custom match
functions to do generic attribute matching.

So now we have :

    class_find_device_by_name
    class_find_device_by_of_node
    class_find_device_by_fwnode
    class_find_device_by_devt

Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexander Aring <alex.aring@gmail.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Dan Murphy <dmurphy@ti.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Harald Freudenberger <freude@linux.ibm.com>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: linux-leds@vger.kernel.org
Cc: linux-rtc@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: linux-wpan@vger.kernel.org
Cc: Mark Brown <broonie@kernel.org>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Peter Rosin <peda@axentia.se>
Cc: Stefan Schmidt <stefan@datenfreihafen.org>
Cc: Tomas Winkler <tomas.winkler@intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 include/linux/device.h | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/include/linux/device.h b/include/linux/device.h
index 8c8727b..4396edc 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -474,6 +474,57 @@ extern struct device *class_find_device(struct class *class,
 					struct device *start, const void *data,
 					int (*match)(struct device *, const void *));
 
+/**
+ * class_find_device_by_name - device iterator for locating a particular device
+ * of a specific name.
+ * @class: class type
+ * @name: name of the device to match
+ */
+static inline struct device *class_find_device_by_name(struct class *class,
+						       const char *name)
+{
+	return class_find_device(class, NULL, name, device_match_name);
+}
+
+/**
+ * class_find_device_by_of_node : device iterator for locating a particular device
+ * matching the of_node.
+ * @class: class type
+ * @np: of_node of the device to match.
+ */
+static inline struct device *
+class_find_device_by_of_node(struct class *class, const struct device_node *np)
+{
+	return class_find_device(class, NULL, np, device_match_of_node);
+}
+
+/**
+ * class_find_device_by_fwnode : device iterator for locating a particular device
+ * matching the fwnode.
+ * @class: class type
+ * @fwnode: fwnode of the device to match.
+ */
+static inline struct device *
+class_find_device_by_fwnode(struct class *class,
+			    const struct fwnode_handle *fwnode)
+{
+	return class_find_device(class, NULL, fwnode, device_match_fwnode);
+}
+
+/**
+ * class_find_device_by_devt : device iterator for locating a particular device
+ * matching the device type.
+ * @class: class type
+ * @start: device to start search from
+ * @devt: device type of the device to match.
+ */
+static inline struct device *class_find_device_by_devt(struct class *class,
+						       struct device *start,
+						       dev_t devt)
+{
+	return class_find_device(class, start, &devt, device_match_devt);
+}
+
 struct class_attribute {
 	struct attribute attr;
 	ssize_t (*show)(struct class *class, struct class_attribute *attr,
-- 
2.7.4


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

* [PATCH 11/13] drivers: Introduce variants for bus_find_device()
  2019-06-05 15:13 ` Suzuki K Poulose
  (?)
@ 2019-06-05 15:13   ` Suzuki K Poulose
  -1 siblings, 0 replies; 39+ messages in thread
From: Suzuki K Poulose @ 2019-06-05 15:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Alexander Shishkin, Andrew Lunn,
	Daniel Vetter, David Airlie, David S. Miller, devicetree,
	Doug Ledford, dri-devel, Florian Fainelli, Frank Rowand,
	Heiko Stuebner, Jason Gunthorpe, Liam Girdwood, linux-i2c,
	linux-rockchip, linux-spi, linux-usb, Maarten Lankhorst,
	Mark Brown, Mathieu Poirier, Maxime Ripard, Oliver Neukum,
	Rob Herring, Sebastian Andrzej Siewior, Srinivas Kandagatla,
	Takashi Iwai, Wolfram Sang

Similar to the class_find_device_by_*() introduce the variants
for bus_find_device() to automatically search for device by
generic device properties.

Here is the list of new helpers :

	bus_find_device_by_of_node
	bus_find_device_by_fwnode
	bus_find_device_by_devt
	bus_find_next_device

While at it convert the bus_find_device_by_name to static inline
reusing the generic helper to match the name.

Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: David Airlie <airlied@linux.ie>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: devicetree@vger.kernel.org
Cc: Doug Ledford <dledford@redhat.com>
Cc: dri-devel@lists.freedesktop.org
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: linux-i2c@vger.kernel.org
Cc: linux-rockchip@lists.infradead.org
Cc: linux-spi@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Maxime Ripard <maxime.ripard@bootlin.com>
Cc: Oliver Neukum <oneukum@suse.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/base/bus.c     | 24 -------------------
 include/linux/device.h | 64 +++++++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 61 insertions(+), 27 deletions(-)

diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index df3cac7..a1d1e82 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -342,30 +342,6 @@ struct device *bus_find_device(struct bus_type *bus,
 }
 EXPORT_SYMBOL_GPL(bus_find_device);
 
-static int match_name(struct device *dev, const void *data)
-{
-	const char *name = data;
-
-	return sysfs_streq(name, dev_name(dev));
-}
-
-/**
- * bus_find_device_by_name - device iterator for locating a particular device of a specific name
- * @bus: bus type
- * @start: Device to begin with
- * @name: name of the device to match
- *
- * This is similar to the bus_find_device() function above, but it handles
- * searching by a name automatically, no need to write another strcmp matching
- * function.
- */
-struct device *bus_find_device_by_name(struct bus_type *bus,
-				       struct device *start, const char *name)
-{
-	return bus_find_device(bus, start, (void *)name, match_name);
-}
-EXPORT_SYMBOL_GPL(bus_find_device_by_name);
-
 /**
  * subsys_find_device_by_id - find a device with a specific enumeration number
  * @subsys: subsystem
diff --git a/include/linux/device.h b/include/linux/device.h
index 4396edc..10de79d 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -175,9 +175,67 @@ int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
 struct device *bus_find_device(struct bus_type *bus, struct device *start,
 			       const void *data,
 			       int (*match)(struct device *dev, const void *data));
-struct device *bus_find_device_by_name(struct bus_type *bus,
-				       struct device *start,
-				       const char *name);
+/**
+ * bus_find_device_by_name - device iterator for locating a particular device
+ * of a specific name.
+ * @bus: bus type
+ * @start: Device to begin with
+ * @name: name of the device to match
+ */
+static inline struct device *bus_find_device_by_name(struct bus_type *bus,
+						     struct device *start,
+						     const char *name)
+{
+	return bus_find_device(bus, start, name, device_match_name);
+}
+
+/**
+ * bus_find_device_by_of_node : device iterator for locating a particular device
+ * matching the of_node.
+ * @bus: bus type
+ * @np: of_node of the device to match.
+ */
+static inline struct device *
+bus_find_device_by_of_node(struct bus_type *bus, const struct device_node *np)
+{
+	return bus_find_device(bus, NULL, np, device_match_of_node);
+}
+
+/**
+ * bus_find_device_by_fwnode : device iterator for locating a particular device
+ * matching the fwnode.
+ * @bus: bus type
+ * @fwnode: fwnode of the device to match.
+ */
+static inline struct device *
+bus_find_device_by_fwnode(struct bus_type *bus, const struct fwnode_handle *fwnode)
+{
+	return bus_find_device(bus, NULL, fwnode, device_match_fwnode);
+}
+
+/**
+ * bus_find_device_by_devt : device iterator for locating a particular device
+ * matching the device type.
+ * @bus: bus type
+ * @start: device to start the search from
+ * @devt: device type of the device to match.
+ */
+static inline struct device *
+bus_find_device_by_devt(struct bus_type *bus, struct device *start, dev_t devt)
+{
+	return bus_find_device(bus, start, &devt, device_match_devt);
+}
+
+/**
+ * bus_find_next_device - Find the next device after a given device in a
+ * given bus.
+ */
+static inline struct device *
+bus_find_next_device(struct bus_type *bus,struct device *cur)
+{
+	return bus_find_device(bus, cur, NULL, device_match_any);
+}
+
 struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id,
 					struct device *hint);
 int bus_for_each_drv(struct bus_type *bus, struct device_driver *start,
-- 
2.7.4


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

* [PATCH 11/13] drivers: Introduce variants for bus_find_device()
@ 2019-06-05 15:13   ` Suzuki K Poulose
  0 siblings, 0 replies; 39+ messages in thread
From: Suzuki K Poulose @ 2019-06-05 15:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Alexander Shishkin, Andrew Lunn,
	Daniel Vetter, David Airlie, David S. Miller, devicetree,
	Doug Ledford, dri-devel, Florian Fainelli, Frank Rowand,
	Heiko Stuebner, Jason Gunthorpe, Liam Girdwood, linux-i2c,
	linux-rockchip, linux-spi, linux-usb, Maarten Lankhorst,
	Mark Brown, Mathieu

Similar to the class_find_device_by_*() introduce the variants
for bus_find_device() to automatically search for device by
generic device properties.

Here is the list of new helpers :

	bus_find_device_by_of_node
	bus_find_device_by_fwnode
	bus_find_device_by_devt
	bus_find_next_device

While at it convert the bus_find_device_by_name to static inline
reusing the generic helper to match the name.

Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: David Airlie <airlied@linux.ie>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: devicetree@vger.kernel.org
Cc: Doug Ledford <dledford@redhat.com>
Cc: dri-devel@lists.freedesktop.org
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: linux-i2c@vger.kernel.org
Cc: linux-rockchip@lists.infradead.org
Cc: linux-spi@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Maxime Ripard <maxime.ripard@bootlin.com>
Cc: Oliver Neukum <oneukum@suse.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/base/bus.c     | 24 -------------------
 include/linux/device.h | 64 +++++++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 61 insertions(+), 27 deletions(-)

diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index df3cac7..a1d1e82 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -342,30 +342,6 @@ struct device *bus_find_device(struct bus_type *bus,
 }
 EXPORT_SYMBOL_GPL(bus_find_device);
 
-static int match_name(struct device *dev, const void *data)
-{
-	const char *name = data;
-
-	return sysfs_streq(name, dev_name(dev));
-}
-
-/**
- * bus_find_device_by_name - device iterator for locating a particular device of a specific name
- * @bus: bus type
- * @start: Device to begin with
- * @name: name of the device to match
- *
- * This is similar to the bus_find_device() function above, but it handles
- * searching by a name automatically, no need to write another strcmp matching
- * function.
- */
-struct device *bus_find_device_by_name(struct bus_type *bus,
-				       struct device *start, const char *name)
-{
-	return bus_find_device(bus, start, (void *)name, match_name);
-}
-EXPORT_SYMBOL_GPL(bus_find_device_by_name);
-
 /**
  * subsys_find_device_by_id - find a device with a specific enumeration number
  * @subsys: subsystem
diff --git a/include/linux/device.h b/include/linux/device.h
index 4396edc..10de79d 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -175,9 +175,67 @@ int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
 struct device *bus_find_device(struct bus_type *bus, struct device *start,
 			       const void *data,
 			       int (*match)(struct device *dev, const void *data));
-struct device *bus_find_device_by_name(struct bus_type *bus,
-				       struct device *start,
-				       const char *name);
+/**
+ * bus_find_device_by_name - device iterator for locating a particular device
+ * of a specific name.
+ * @bus: bus type
+ * @start: Device to begin with
+ * @name: name of the device to match
+ */
+static inline struct device *bus_find_device_by_name(struct bus_type *bus,
+						     struct device *start,
+						     const char *name)
+{
+	return bus_find_device(bus, start, name, device_match_name);
+}
+
+/**
+ * bus_find_device_by_of_node : device iterator for locating a particular device
+ * matching the of_node.
+ * @bus: bus type
+ * @np: of_node of the device to match.
+ */
+static inline struct device *
+bus_find_device_by_of_node(struct bus_type *bus, const struct device_node *np)
+{
+	return bus_find_device(bus, NULL, np, device_match_of_node);
+}
+
+/**
+ * bus_find_device_by_fwnode : device iterator for locating a particular device
+ * matching the fwnode.
+ * @bus: bus type
+ * @fwnode: fwnode of the device to match.
+ */
+static inline struct device *
+bus_find_device_by_fwnode(struct bus_type *bus, const struct fwnode_handle *fwnode)
+{
+	return bus_find_device(bus, NULL, fwnode, device_match_fwnode);
+}
+
+/**
+ * bus_find_device_by_devt : device iterator for locating a particular device
+ * matching the device type.
+ * @bus: bus type
+ * @start: device to start the search from
+ * @devt: device type of the device to match.
+ */
+static inline struct device *
+bus_find_device_by_devt(struct bus_type *bus, struct device *start, dev_t devt)
+{
+	return bus_find_device(bus, start, &devt, device_match_devt);
+}
+
+/**
+ * bus_find_next_device - Find the next device after a given device in a
+ * given bus.
+ */
+static inline struct device *
+bus_find_next_device(struct bus_type *bus,struct device *cur)
+{
+	return bus_find_device(bus, cur, NULL, device_match_any);
+}
+
 struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id,
 					struct device *hint);
 int bus_for_each_drv(struct bus_type *bus, struct device_driver *start,
-- 
2.7.4

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

* [PATCH 11/13] drivers: Introduce variants for bus_find_device()
@ 2019-06-05 15:13   ` Suzuki K Poulose
  0 siblings, 0 replies; 39+ messages in thread
From: Suzuki K Poulose @ 2019-06-05 15:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Alexander Shishkin, Andrew Lunn,
	Daniel Vetter, David Airlie, David S. Miller, devicetree,
	Doug Ledford, dri-devel, Florian Fainelli, Frank Rowand,
	Heiko Stuebner, Jason Gunthorpe, Liam Girdwood, linux-i2c,
	linux-rockchip, linux-spi, linux-usb, Maarten Lankhorst,
	Mark Brown, Mathieu

Similar to the class_find_device_by_*() introduce the variants
for bus_find_device() to automatically search for device by
generic device properties.

Here is the list of new helpers :

	bus_find_device_by_of_node
	bus_find_device_by_fwnode
	bus_find_device_by_devt
	bus_find_next_device

While at it convert the bus_find_device_by_name to static inline
reusing the generic helper to match the name.

Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: David Airlie <airlied@linux.ie>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: devicetree@vger.kernel.org
Cc: Doug Ledford <dledford@redhat.com>
Cc: dri-devel@lists.freedesktop.org
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: linux-i2c@vger.kernel.org
Cc: linux-rockchip@lists.infradead.org
Cc: linux-spi@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Maxime Ripard <maxime.ripard@bootlin.com>
Cc: Oliver Neukum <oneukum@suse.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/base/bus.c     | 24 -------------------
 include/linux/device.h | 64 +++++++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 61 insertions(+), 27 deletions(-)

diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index df3cac7..a1d1e82 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -342,30 +342,6 @@ struct device *bus_find_device(struct bus_type *bus,
 }
 EXPORT_SYMBOL_GPL(bus_find_device);
 
-static int match_name(struct device *dev, const void *data)
-{
-	const char *name = data;
-
-	return sysfs_streq(name, dev_name(dev));
-}
-
-/**
- * bus_find_device_by_name - device iterator for locating a particular device of a specific name
- * @bus: bus type
- * @start: Device to begin with
- * @name: name of the device to match
- *
- * This is similar to the bus_find_device() function above, but it handles
- * searching by a name automatically, no need to write another strcmp matching
- * function.
- */
-struct device *bus_find_device_by_name(struct bus_type *bus,
-				       struct device *start, const char *name)
-{
-	return bus_find_device(bus, start, (void *)name, match_name);
-}
-EXPORT_SYMBOL_GPL(bus_find_device_by_name);
-
 /**
  * subsys_find_device_by_id - find a device with a specific enumeration number
  * @subsys: subsystem
diff --git a/include/linux/device.h b/include/linux/device.h
index 4396edc..10de79d 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -175,9 +175,67 @@ int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
 struct device *bus_find_device(struct bus_type *bus, struct device *start,
 			       const void *data,
 			       int (*match)(struct device *dev, const void *data));
-struct device *bus_find_device_by_name(struct bus_type *bus,
-				       struct device *start,
-				       const char *name);
+/**
+ * bus_find_device_by_name - device iterator for locating a particular device
+ * of a specific name.
+ * @bus: bus type
+ * @start: Device to begin with
+ * @name: name of the device to match
+ */
+static inline struct device *bus_find_device_by_name(struct bus_type *bus,
+						     struct device *start,
+						     const char *name)
+{
+	return bus_find_device(bus, start, name, device_match_name);
+}
+
+/**
+ * bus_find_device_by_of_node : device iterator for locating a particular device
+ * matching the of_node.
+ * @bus: bus type
+ * @np: of_node of the device to match.
+ */
+static inline struct device *
+bus_find_device_by_of_node(struct bus_type *bus, const struct device_node *np)
+{
+	return bus_find_device(bus, NULL, np, device_match_of_node);
+}
+
+/**
+ * bus_find_device_by_fwnode : device iterator for locating a particular device
+ * matching the fwnode.
+ * @bus: bus type
+ * @fwnode: fwnode of the device to match.
+ */
+static inline struct device *
+bus_find_device_by_fwnode(struct bus_type *bus, const struct fwnode_handle *fwnode)
+{
+	return bus_find_device(bus, NULL, fwnode, device_match_fwnode);
+}
+
+/**
+ * bus_find_device_by_devt : device iterator for locating a particular device
+ * matching the device type.
+ * @bus: bus type
+ * @start: device to start the search from
+ * @devt: device type of the device to match.
+ */
+static inline struct device *
+bus_find_device_by_devt(struct bus_type *bus, struct device *start, dev_t devt)
+{
+	return bus_find_device(bus, start, &devt, device_match_devt);
+}
+
+/**
+ * bus_find_next_device - Find the next device after a given device in a
+ * given bus.
+ */
+static inline struct device *
+bus_find_next_device(struct bus_type *bus,struct device *cur)
+{
+	return bus_find_device(bus, cur, NULL, device_match_any);
+}
+
 struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id,
 					struct device *hint);
 int bus_for_each_drv(struct bus_type *bus, struct device_driver *start,
-- 
2.7.4

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

* [PATCH 12/13] drivers: Introduce variants of driver_find_device()
  2019-06-05 15:13 ` Suzuki K Poulose
                   ` (12 preceding siblings ...)
  (?)
@ 2019-06-05 15:13 ` Suzuki K Poulose
  -1 siblings, 0 replies; 39+ messages in thread
From: Suzuki K Poulose @ 2019-06-05 15:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Arnd Bergmann, Joerg Roedel,
	Jonathan Hunter, Lee Jones, Robin Murphy, Thierry Reding,
	Thor Thayer, Will Deacon

Similar to the other device lookup helpers, introduce
variants of driver_find_device() to automatically lookup
devices by their generic properties to avoid proliferation
of custom match functions. We add :

	driver_find_device_by_name
	driver_find_device_by_of_node
	driver_find_device_by_fwnode
	driver_find_device_by_devt
	driver_find_next_device

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Thor Thayer <thor.thayer@linux.intel.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 include/linux/device.h | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/include/linux/device.h b/include/linux/device.h
index 10de79d..2c05e60 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -404,6 +404,64 @@ struct device *driver_find_device(struct device_driver *drv,
 				  struct device *start, const void *data,
 				  int (*match)(struct device *dev, const void *data));
 
+/**
+ * driver_find_device_by_name - device iterator for locating a particular device
+ * of a specific name.
+ * @driver: the driver we're iterating
+ * @name: name of the device to match
+ */
+static inline struct device *driver_find_device_by_name(struct device_driver *drv,
+							const char *name)
+{
+	return driver_find_device(drv, NULL, name, device_match_name);
+}
+
+/**
+ * driver_find_device_by_of_node- device iterator for locating a particular device
+ * by of_node pointer.
+ * @driver: the driver we're iterating
+ * @np: of_node pointer to match.
+ */
+static inline struct device *
+driver_find_device_by_of_node(struct device_driver *drv,
+			      const struct device_node *np)
+{
+	return driver_find_device(drv, NULL, np, device_match_of_node);
+}
+
+/**
+ * driver_find_device_by_fwnode- device iterator for locating a particular device
+ * by fwnode pointer.
+ * @driver: the driver we're iterating
+ * @fwnode: fwnode pointer to match.
+ */
+static inline struct device *
+driver_find_device_by_fwnode(struct device_driver *drv,
+			     const struct fwnode_handle *fwnode)
+{
+	return driver_find_device(drv, NULL, fwnode, device_match_fwnode);
+}
+
+/**
+ * driver_find_device_by_devt- device iterator for locating a particular device
+ * by devt.
+ * @driver: the driver we're iterating
+ * @start: device to start search from
+ * @devt: devt pointer to match.
+ */
+static inline struct device *driver_find_device_by_devt(struct device_driver *drv,
+							struct device *start,
+							dev_t devt)
+{
+	return driver_find_device(drv, start, &devt, device_match_devt);
+}
+
+static inline struct device *driver_find_next_device(struct device_driver *drv,
+						     struct device *start)
+{
+	return driver_find_device(drv, start, NULL, device_match_any);
+}
+
 void driver_deferred_probe_add(struct device *dev);
 int driver_deferred_probe_check_state(struct device *dev);
 
-- 
2.7.4


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

* [PATCH 13/13] platform: Add platform_find_device_by_driver() helper
  2019-06-05 15:13 ` Suzuki K Poulose
                   ` (13 preceding siblings ...)
  (?)
@ 2019-06-05 15:13 ` Suzuki K Poulose
  -1 siblings, 0 replies; 39+ messages in thread
From: Suzuki K Poulose @ 2019-06-05 15:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Eric Anholt, Heiko Stübner,
	Inki Dae, Sandy Huang, Seung-Woo Kim

Provide a helper to lookup platform devices by matching device
driver in order to avoid drivers trying to use platform bus
internals.

Cc: Eric Anholt <eric@anholt.net>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Heiko Stübner" <heiko@sntech.de>
Cc: Inki Dae <inki.dae@samsung.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Sandy Huang <hjc@rock-chips.com>
Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/base/platform.c         | 14 ++++++++++++++
 include/linux/platform_device.h |  3 +++
 2 files changed, 17 insertions(+)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 4d17298..158ac24 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -1197,6 +1197,20 @@ struct bus_type platform_bus_type = {
 };
 EXPORT_SYMBOL_GPL(platform_bus_type);
 
+/**
+ * platform_find_device_by_driver - Find a platform device with a given
+ * driver.
+ * @start: The device to start the search from.
+ * @drv: The device driver to look for.
+ */
+struct device *platform_find_device_by_driver(struct device *start,
+					      const struct device_driver *drv)
+{
+	return bus_find_device(&platform_bus_type, start, drv,
+			       (void *)platform_match);
+}
+EXPORT_SYMBOL_GPL(platform_find_device_by_driver);
+
 int __init platform_bus_init(void)
 {
 	int error;
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index cc46485..36aa775 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -52,6 +52,9 @@ extern struct device platform_bus;
 extern void arch_setup_pdev_archdata(struct platform_device *);
 extern struct resource *platform_get_resource(struct platform_device *,
 					      unsigned int, unsigned int);
+extern struct device *
+platform_find_device_by_driver(struct device * dev,
+			       const struct device_driver *drv);
 extern void __iomem *
 devm_platform_ioremap_resource(struct platform_device *pdev,
 			       unsigned int index);
-- 
2.7.4


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

* Re: [PATCH 02/13] bus_find_device: Unify the match callback with class_find_device
  2019-06-05 15:13 ` [PATCH 02/13] bus_find_device: Unify the match callback with class_find_device Suzuki K Poulose
@ 2019-06-05 15:48   ` Corey Minyard
  2019-06-05 15:51   ` Kershner, David A
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 39+ messages in thread
From: Corey Minyard @ 2019-06-05 15:48 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: linux-kernel, gregkh, rafael, Alexander Shishkin, Andrew Lunn,
	Andreas Noever, Arnd Bergmann, Bjorn Helgaas,
	Christian Borntraeger, David Kershner, David S. Miller,
	David Airlie, Felipe Balbi, Frank Rowand, Grygorii Strashko,
	Harald Freudenberger, Hartmut Knaack, Heiko Stuebner,
	Jason Gunthorpe, Jonathan Cameron, James E.J. Bottomley,
	Len Brown, Mark Brown, Michael Ellerman, Michael Jamet,
	Martin K. Petersen, Peter Oberparleiter, Rob Herring,
	Sebastian Ott, Srinivas Kandagatla, Yehezkel Bernat,
	Wolfram Sang

On Wed, Jun 05, 2019 at 04:13:39PM +0100, Suzuki K Poulose wrote:
> There is an arbitrary difference between the prototypes of
> bus_find_device() and class_find_device() preventing their callers
> from passing the same pair of data and match() arguments to both of
> them, which is the const qualifier used in the prototype of
> class_find_device().  If that qualifier is also used in the
> bus_find_device() prototype, it will be possible to pass the same
> match() callback function to both bus_find_device() and
> class_find_device(), which will allow some optimizations to be made in
> order to avoid code duplication going forward.  Also with that, constify
> the "data" parameter as it is passed as a const to the match function.
> 
> For this reason, change the prototype of bus_find_device() to match
> the prototype of class_find_device() and adjust its callers to use the
> const qualifier in accordance with the new prototype of it.

For the IPMI code, this (and the other change in ipmi_msghandler in
a later patch) is ok by me.  I cannot speak to the overall change,
though.

Acked-by: Corey Minyard <minyard@acm.org>

> 
> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Andreas Noever <andreas.noever@gmail.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Corey Minyard <minyard@acm.org>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> Cc: David Kershner <david.kershner@unisys.com>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: David Airlie <airlied@linux.ie>
> Cc: Felipe Balbi <balbi@kernel.org>
> Cc: Frank Rowand <frowand.list@gmail.com>
> Cc: Grygorii Strashko <grygorii.strashko@ti.com>
> Cc: Harald Freudenberger <freude@linux.ibm.com>
> Cc: Hartmut Knaack <knaack.h@gmx.de>
> Cc: Heiko Stuebner <heiko@sntech.de>
> Cc: Jason Gunthorpe <jgg@ziepe.ca>
> Cc: Jonathan Cameron <jic23@kernel.org>
> Cc: Jonathan Cameron <jic23@kernel.org>
> Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
> Cc: Len Brown <lenb@kernel.org>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Michael Jamet <michael.jamet@intel.com>
> Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
> Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Sebastian Ott <sebott@linux.ibm.com>
> Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> Cc: Yehezkel Bernat <YehezkelShB@gmail.com>
> Cc: Wolfram Sang <wsa@the-dreams.de>
> Cc: rafael@kernel.org
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> ---
>  arch/powerpc/platforms/pseries/ibmebus.c           | 4 ++--
>  drivers/acpi/acpi_lpss.c                           | 4 ++--
>  drivers/acpi/sleep.c                               | 2 +-
>  drivers/acpi/utils.c                               | 4 ++--
>  drivers/base/bus.c                                 | 6 +++---
>  drivers/base/devcon.c                              | 2 +-
>  drivers/char/ipmi/ipmi_si_platform.c               | 2 +-
>  drivers/firmware/efi/dev-path-parser.c             | 4 ++--
>  drivers/gpu/drm/drm_mipi_dsi.c                     | 2 +-
>  drivers/hwtracing/coresight/coresight.c            | 6 +++---
>  drivers/hwtracing/coresight/of_coresight.c         | 2 +-
>  drivers/hwtracing/intel_th/core.c                  | 5 ++---
>  drivers/i2c/i2c-core-acpi.c                        | 4 ++--
>  drivers/i2c/i2c-core-of.c                          | 4 ++--
>  drivers/iio/inkern.c                               | 2 +-
>  drivers/infiniband/hw/hns/hns_roce_hw_v1.c         | 2 +-
>  drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c | 2 +-
>  drivers/net/ethernet/ti/cpsw-phy-sel.c             | 4 ++--
>  drivers/net/ethernet/ti/davinci_emac.c             | 2 +-
>  drivers/net/ethernet/toshiba/tc35815.c             | 4 ++--
>  drivers/nvmem/core.c                               | 2 +-
>  drivers/of/of_mdio.c                               | 2 +-
>  drivers/of/platform.c                              | 2 +-
>  drivers/pci/probe.c                                | 2 +-
>  drivers/pci/search.c                               | 4 ++--
>  drivers/s390/cio/css.c                             | 4 ++--
>  drivers/s390/cio/device.c                          | 4 ++--
>  drivers/s390/cio/scm.c                             | 4 ++--
>  drivers/s390/crypto/ap_bus.c                       | 8 ++++----
>  drivers/scsi/scsi_proc.c                           | 2 +-
>  drivers/spi/spi.c                                  | 4 ++--
>  drivers/staging/most/core.c                        | 4 ++--
>  drivers/thunderbolt/switch.c                       | 4 ++--
>  drivers/usb/core/devio.c                           | 4 ++--
>  drivers/usb/core/usb.c                             | 4 ++--
>  drivers/usb/phy/phy-am335x-control.c               | 4 ++--
>  drivers/usb/phy/phy-isp1301.c                      | 4 ++--
>  drivers/visorbus/visorbus_main.c                   | 4 ++--
>  include/linux/device.h                             | 4 ++--
>  sound/soc/rockchip/rk3399_gru_sound.c              | 2 +-
>  40 files changed, 69 insertions(+), 70 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/pseries/ibmebus.c b/arch/powerpc/platforms/pseries/ibmebus.c
> index 84e8ec4..b91eb09 100644
> --- a/arch/powerpc/platforms/pseries/ibmebus.c
> +++ b/arch/powerpc/platforms/pseries/ibmebus.c
> @@ -147,13 +147,13 @@ static const struct dma_map_ops ibmebus_dma_ops = {
>  	.unmap_page         = ibmebus_unmap_page,
>  };
>  
> -static int ibmebus_match_path(struct device *dev, void *data)
> +static int ibmebus_match_path(struct device *dev, const void *data)
>  {
>  	struct device_node *dn = to_platform_device(dev)->dev.of_node;
>  	return (of_find_node_by_path(data) == dn);
>  }
>  
> -static int ibmebus_match_node(struct device *dev, void *data)
> +static int ibmebus_match_node(struct device *dev, const void *data)
>  {
>  	return to_platform_device(dev)->dev.of_node == data;
>  }
> diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
> index cf76860..dc2ca78 100644
> --- a/drivers/acpi/acpi_lpss.c
> +++ b/drivers/acpi/acpi_lpss.c
> @@ -511,10 +511,10 @@ struct hid_uid {
>  	const char *uid;
>  };
>  
> -static int match_hid_uid(struct device *dev, void *data)
> +static int match_hid_uid(struct device *dev, const void *data)
>  {
>  	struct acpi_device *adev = ACPI_COMPANION(dev);
> -	struct hid_uid *id = data;
> +	const struct hid_uid *id = data;
>  
>  	if (!adev)
>  		return 0;
> diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
> index a34decc..fcf4386 100644
> --- a/drivers/acpi/sleep.c
> +++ b/drivers/acpi/sleep.c
> @@ -454,7 +454,7 @@ static int acpi_pm_prepare(void)
>  	return error;
>  }
>  
> -static int find_powerf_dev(struct device *dev, void *data)
> +static int find_powerf_dev(struct device *dev, const void *data)
>  {
>  	struct acpi_device *device = to_acpi_device(dev);
>  	const char *hid = acpi_device_hid(device);
> diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
> index 1391b63..e3974a8 100644
> --- a/drivers/acpi/utils.c
> +++ b/drivers/acpi/utils.c
> @@ -730,10 +730,10 @@ struct acpi_dev_match_info {
>  	s64 hrv;
>  };
>  
> -static int acpi_dev_match_cb(struct device *dev, void *data)
> +static int acpi_dev_match_cb(struct device *dev, const void *data)
>  {
>  	struct acpi_device *adev = to_acpi_device(dev);
> -	struct acpi_dev_match_info *match = data;
> +	const struct acpi_dev_match_info *match = data;
>  	unsigned long long hrv;
>  	acpi_status status;
>  
> diff --git a/drivers/base/bus.c b/drivers/base/bus.c
> index 0a58e96..df3cac7 100644
> --- a/drivers/base/bus.c
> +++ b/drivers/base/bus.c
> @@ -323,8 +323,8 @@ EXPORT_SYMBOL_GPL(bus_for_each_dev);
>   * return to the caller and not iterate over any more devices.
>   */
>  struct device *bus_find_device(struct bus_type *bus,
> -			       struct device *start, void *data,
> -			       int (*match)(struct device *dev, void *data))
> +			       struct device *start, const void *data,
> +			       int (*match)(struct device *dev, const void *data))
>  {
>  	struct klist_iter i;
>  	struct device *dev;
> @@ -342,7 +342,7 @@ struct device *bus_find_device(struct bus_type *bus,
>  }
>  EXPORT_SYMBOL_GPL(bus_find_device);
>  
> -static int match_name(struct device *dev, void *data)
> +static int match_name(struct device *dev, const void *data)
>  {
>  	const char *name = data;
>  
> diff --git a/drivers/base/devcon.c b/drivers/base/devcon.c
> index 04db9ae..ac026d5 100644
> --- a/drivers/base/devcon.c
> +++ b/drivers/base/devcon.c
> @@ -107,7 +107,7 @@ static struct bus_type *generic_match_buses[] = {
>  	NULL,
>  };
>  
> -static int device_fwnode_match(struct device *dev, void *fwnode)
> +static int device_fwnode_match(struct device *dev, const void *fwnode)
>  {
>  	return dev_fwnode(dev) == fwnode;
>  }
> diff --git a/drivers/char/ipmi/ipmi_si_platform.c b/drivers/char/ipmi/ipmi_si_platform.c
> index f2a91c4..fd94c42 100644
> --- a/drivers/char/ipmi/ipmi_si_platform.c
> +++ b/drivers/char/ipmi/ipmi_si_platform.c
> @@ -426,7 +426,7 @@ static int ipmi_remove(struct platform_device *pdev)
>  	return ipmi_si_remove_by_dev(&pdev->dev);
>  }
>  
> -static int pdev_match_name(struct device *dev, void *data)
> +static int pdev_match_name(struct device *dev, const void *data)
>  {
>  	struct platform_device *pdev = to_platform_device(dev);
>  	const char *name = data;
> diff --git a/drivers/firmware/efi/dev-path-parser.c b/drivers/firmware/efi/dev-path-parser.c
> index 85ec99f..2012338 100644
> --- a/drivers/firmware/efi/dev-path-parser.c
> +++ b/drivers/firmware/efi/dev-path-parser.c
> @@ -17,9 +17,9 @@ struct acpi_hid_uid {
>  	char uid[11]; /* UINT_MAX + null byte */
>  };
>  
> -static int __init match_acpi_dev(struct device *dev, void *data)
> +static int __init match_acpi_dev(struct device *dev, const void *data)
>  {
> -	struct acpi_hid_uid hid_uid = *(struct acpi_hid_uid *)data;
> +	struct acpi_hid_uid hid_uid = *(const struct acpi_hid_uid *)data;
>  	struct acpi_device *adev = to_acpi_device(dev);
>  
>  	if (acpi_match_device_ids(adev, hid_uid.hid))
> diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
> index 80b7550..ad19df0 100644
> --- a/drivers/gpu/drm/drm_mipi_dsi.c
> +++ b/drivers/gpu/drm/drm_mipi_dsi.c
> @@ -93,7 +93,7 @@ static struct bus_type mipi_dsi_bus_type = {
>  	.pm = &mipi_dsi_device_pm_ops,
>  };
>  
> -static int of_device_match(struct device *dev, void *data)
> +static int of_device_match(struct device *dev, const void *data)
>  {
>  	return dev->of_node == data;
>  }
> diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c
> index 4b13028..b67ab6a 100644
> --- a/drivers/hwtracing/coresight/coresight.c
> +++ b/drivers/hwtracing/coresight/coresight.c
> @@ -498,9 +498,9 @@ struct coresight_device *coresight_get_sink(struct list_head *path)
>  	return csdev;
>  }
>  
> -static int coresight_enabled_sink(struct device *dev, void *data)
> +static int coresight_enabled_sink(struct device *dev, const void *data)
>  {
> -	bool *reset = data;
> +	const bool *reset = data;
>  	struct coresight_device *csdev = to_coresight_device(dev);
>  
>  	if ((csdev->type == CORESIGHT_DEV_TYPE_SINK ||
> @@ -544,7 +544,7 @@ struct coresight_device *coresight_get_enabled_sink(bool deactivate)
>  	return dev ? to_coresight_device(dev) : NULL;
>  }
>  
> -static int coresight_sink_by_id(struct device *dev, void *data)
> +static int coresight_sink_by_id(struct device *dev, const void *data)
>  {
>  	struct coresight_device *csdev = to_coresight_device(dev);
>  	unsigned long hash;
> diff --git a/drivers/hwtracing/coresight/of_coresight.c b/drivers/hwtracing/coresight/of_coresight.c
> index 7045930..3fc200e 100644
> --- a/drivers/hwtracing/coresight/of_coresight.c
> +++ b/drivers/hwtracing/coresight/of_coresight.c
> @@ -18,7 +18,7 @@
>  #include <asm/smp_plat.h>
>  
>  
> -static int of_dev_node_match(struct device *dev, void *data)
> +static int of_dev_node_match(struct device *dev, const void *data)
>  {
>  	return dev->of_node == data;
>  }
> diff --git a/drivers/hwtracing/intel_th/core.c b/drivers/hwtracing/intel_th/core.c
> index 033dce5..5592289 100644
> --- a/drivers/hwtracing/intel_th/core.c
> +++ b/drivers/hwtracing/intel_th/core.c
> @@ -789,10 +789,9 @@ static int intel_th_populate(struct intel_th *th)
>  	return 0;
>  }
>  
> -static int match_devt(struct device *dev, void *data)
> +static int match_devt(struct device *dev, const void *data)
>  {
> -	dev_t devt = (dev_t)(unsigned long)data;
> -
> +	dev_t devt = (dev_t)(unsigned long)(void *)data;
>  	return dev->devt == devt;
>  }
>  
> diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
> index d840955..8af35f11 100644
> --- a/drivers/i2c/i2c-core-acpi.c
> +++ b/drivers/i2c/i2c-core-acpi.c
> @@ -318,7 +318,7 @@ u32 i2c_acpi_find_bus_speed(struct device *dev)
>  }
>  EXPORT_SYMBOL_GPL(i2c_acpi_find_bus_speed);
>  
> -static int i2c_acpi_find_match_adapter(struct device *dev, void *data)
> +static int i2c_acpi_find_match_adapter(struct device *dev, const void *data)
>  {
>  	struct i2c_adapter *adapter = i2c_verify_adapter(dev);
>  
> @@ -328,7 +328,7 @@ static int i2c_acpi_find_match_adapter(struct device *dev, void *data)
>  	return ACPI_HANDLE(dev) == (acpi_handle)data;
>  }
>  
> -static int i2c_acpi_find_match_device(struct device *dev, void *data)
> +static int i2c_acpi_find_match_device(struct device *dev, const void *data)
>  {
>  	return ACPI_COMPANION(dev) == data;
>  }
> diff --git a/drivers/i2c/i2c-core-of.c b/drivers/i2c/i2c-core-of.c
> index 406e5f6..2eb59a2 100644
> --- a/drivers/i2c/i2c-core-of.c
> +++ b/drivers/i2c/i2c-core-of.c
> @@ -112,12 +112,12 @@ void of_i2c_register_devices(struct i2c_adapter *adap)
>  	of_node_put(bus);
>  }
>  
> -static int of_dev_node_match(struct device *dev, void *data)
> +static int of_dev_node_match(struct device *dev, const void *data)
>  {
>  	return dev->of_node == data;
>  }
>  
> -static int of_dev_or_parent_node_match(struct device *dev, void *data)
> +static int of_dev_or_parent_node_match(struct device *dev, const void *data)
>  {
>  	if (dev->of_node == data)
>  		return 1;
> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> index 4a5eff3..c46fb59 100644
> --- a/drivers/iio/inkern.c
> +++ b/drivers/iio/inkern.c
> @@ -93,7 +93,7 @@ static const struct iio_chan_spec
>  
>  #ifdef CONFIG_OF
>  
> -static int iio_dev_node_match(struct device *dev, void *data)
> +static int iio_dev_node_match(struct device *dev, const void *data)
>  {
>  	return dev->of_node == data && dev->type == &iio_device_type;
>  }
> diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
> index 4c5d0f1..fd90b05 100644
> --- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
> +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
> @@ -4497,7 +4497,7 @@ static const struct acpi_device_id hns_roce_acpi_match[] = {
>  };
>  MODULE_DEVICE_TABLE(acpi, hns_roce_acpi_match);
>  
> -static int hns_roce_node_match(struct device *dev, void *fwnode)
> +static int hns_roce_node_match(struct device *dev, const void *fwnode)
>  {
>  	return dev->fwnode == fwnode;
>  }
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c
> index 09c16d8..bb6586d 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c
> @@ -754,7 +754,7 @@ struct dsaf_misc_op *hns_misc_op_get(struct dsaf_device *dsaf_dev)
>  	return (void *)misc_op;
>  }
>  
> -static int hns_dsaf_dev_match(struct device *dev, void *fwnode)
> +static int hns_dsaf_dev_match(struct device *dev, const void *fwnode)
>  {
>  	return dev->fwnode == fwnode;
>  }
> diff --git a/drivers/net/ethernet/ti/cpsw-phy-sel.c b/drivers/net/ethernet/ti/cpsw-phy-sel.c
> index 48e0924..4e184ee 100644
> --- a/drivers/net/ethernet/ti/cpsw-phy-sel.c
> +++ b/drivers/net/ethernet/ti/cpsw-phy-sel.c
> @@ -151,9 +151,9 @@ static void cpsw_gmii_sel_dra7xx(struct cpsw_phy_sel_priv *priv,
>  }
>  
>  static struct platform_driver cpsw_phy_sel_driver;
> -static int match(struct device *dev, void *data)
> +static int match(struct device *dev, const void *data)
>  {
> -	struct device_node *node = (struct device_node *)data;
> +	const struct device_node *node = (const struct device_node *)data;
>  	return dev->of_node == node &&
>  		dev->driver == &cpsw_phy_sel_driver.driver;
>  }
> diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
> index 4bf65ca..57d131a 100644
> --- a/drivers/net/ethernet/ti/davinci_emac.c
> +++ b/drivers/net/ethernet/ti/davinci_emac.c
> @@ -1371,7 +1371,7 @@ static int emac_devioctl(struct net_device *ndev, struct ifreq *ifrq, int cmd)
>  		return -EOPNOTSUPP;
>  }
>  
> -static int match_first_device(struct device *dev, void *data)
> +static int match_first_device(struct device *dev, const void *data)
>  {
>  	if (dev->parent && dev->parent->of_node)
>  		return of_device_is_compatible(dev->parent->of_node,
> diff --git a/drivers/net/ethernet/toshiba/tc35815.c b/drivers/net/ethernet/toshiba/tc35815.c
> index c50a977..8479a44 100644
> --- a/drivers/net/ethernet/toshiba/tc35815.c
> +++ b/drivers/net/ethernet/toshiba/tc35815.c
> @@ -694,10 +694,10 @@ static int tc_mii_init(struct net_device *dev)
>   * should provide a "tc35815-mac" device with a MAC address in its
>   * platform_data.
>   */
> -static int tc35815_mac_match(struct device *dev, void *data)
> +static int tc35815_mac_match(struct device *dev, const void *data)
>  {
>  	struct platform_device *plat_dev = to_platform_device(dev);
> -	struct pci_dev *pci_dev = data;
> +	const struct pci_dev *pci_dev = data;
>  	unsigned int id = pci_dev->irq;
>  	return !strcmp(plat_dev->name, "tc35815-mac") && plat_dev->id == id;
>  }
> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> index c7892c3..ac5d945 100644
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
> @@ -76,7 +76,7 @@ static struct bus_type nvmem_bus_type = {
>  	.name		= "nvmem",
>  };
>  
> -static int of_nvmem_match(struct device *dev, void *nvmem_np)
> +static int of_nvmem_match(struct device *dev, const void *nvmem_np)
>  {
>  	return dev->of_node == nvmem_np;
>  }
> diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
> index de61573..dfe1294 100644
> --- a/drivers/of/of_mdio.c
> +++ b/drivers/of/of_mdio.c
> @@ -282,7 +282,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
>  EXPORT_SYMBOL(of_mdiobus_register);
>  
>  /* Helper function for of_phy_find_device */
> -static int of_phy_match(struct device *dev, void *phy_np)
> +static int of_phy_match(struct device *dev, const void *phy_np)
>  {
>  	return dev->of_node == phy_np;
>  }
> diff --git a/drivers/of/platform.c b/drivers/of/platform.c
> index 04ad312..008d79e 100644
> --- a/drivers/of/platform.c
> +++ b/drivers/of/platform.c
> @@ -37,7 +37,7 @@ static const struct of_device_id of_skipped_node_table[] = {
>  	{} /* Empty terminated list */
>  };
>  
> -static int of_dev_node_match(struct device *dev, void *data)
> +static int of_dev_node_match(struct device *dev, const void *data)
>  {
>  	return dev->of_node == data;
>  }
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 0e8e2c1..f9ef7ad 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -64,7 +64,7 @@ static struct resource *get_pci_domain_busn_res(int domain_nr)
>  	return &r->res;
>  }
>  
> -static int find_anything(struct device *dev, void *data)
> +static int find_anything(struct device *dev, const void *data)
>  {
>  	return 1;
>  }
> diff --git a/drivers/pci/search.c b/drivers/pci/search.c
> index 5c79226..7f4e658 100644
> --- a/drivers/pci/search.c
> +++ b/drivers/pci/search.c
> @@ -236,10 +236,10 @@ struct pci_dev *pci_get_domain_bus_and_slot(int domain, unsigned int bus,
>  }
>  EXPORT_SYMBOL(pci_get_domain_bus_and_slot);
>  
> -static int match_pci_dev_by_id(struct device *dev, void *data)
> +static int match_pci_dev_by_id(struct device *dev, const void *data)
>  {
>  	struct pci_dev *pdev = to_pci_dev(dev);
> -	struct pci_device_id *id = data;
> +	const struct pci_device_id *id = data;
>  
>  	if (pci_match_one_device(id, pdev))
>  		return 1;
> diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
> index aea5029..7b8488d 100644
> --- a/drivers/s390/cio/css.c
> +++ b/drivers/s390/cio/css.c
> @@ -434,10 +434,10 @@ static int css_probe_device(struct subchannel_id schid, struct schib *schib)
>  }
>  
>  static int
> -check_subchannel(struct device * dev, void * data)
> +check_subchannel(struct device *dev, const void *data)
>  {
>  	struct subchannel *sch;
> -	struct subchannel_id *schid = data;
> +	const struct subchannel_id *schid = data;
>  
>  	sch = to_subchannel(dev);
>  	return schid_equal(&sch->schid, schid);
> diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
> index 1540229..6ca9a3a 100644
> --- a/drivers/s390/cio/device.c
> +++ b/drivers/s390/cio/device.c
> @@ -642,10 +642,10 @@ static int ccw_device_add(struct ccw_device *cdev)
>  	return device_add(dev);
>  }
>  
> -static int match_dev_id(struct device *dev, void *data)
> +static int match_dev_id(struct device *dev, const void *data)
>  {
>  	struct ccw_device *cdev = to_ccwdev(dev);
> -	struct ccw_dev_id *dev_id = data;
> +	const struct ccw_dev_id *dev_id = data;
>  
>  	return ccw_dev_id_is_equal(&cdev->private->dev_id, dev_id);
>  }
> diff --git a/drivers/s390/cio/scm.c b/drivers/s390/cio/scm.c
> index 6bca1d5..9f26d43 100644
> --- a/drivers/s390/cio/scm.c
> +++ b/drivers/s390/cio/scm.c
> @@ -174,10 +174,10 @@ static void scmdev_update(struct scm_device *scmdev, struct sale *sale)
>  		kobject_uevent(&scmdev->dev.kobj, KOBJ_CHANGE);
>  }
>  
> -static int check_address(struct device *dev, void *data)
> +static int check_address(struct device *dev, const void *data)
>  {
>  	struct scm_device *scmdev = to_scm_dev(dev);
> -	struct sale *sale = data;
> +	const struct sale *sale = data;
>  
>  	return scmdev->address == sale->sa;
>  }
> diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c
> index b9fc502..b7902b6 100644
> --- a/drivers/s390/crypto/ap_bus.c
> +++ b/drivers/s390/crypto/ap_bus.c
> @@ -1356,16 +1356,16 @@ static int ap_get_compatible_type(ap_qid_t qid, int rawtype, unsigned int func)
>   * Helper function to be used with bus_find_dev
>   * matches for the card device with the given id
>   */
> -static int __match_card_device_with_id(struct device *dev, void *data)
> +static int __match_card_device_with_id(struct device *dev, const void *data)
>  {
> -	return is_card_dev(dev) && to_ap_card(dev)->id == (int)(long) data;
> +	return is_card_dev(dev) && to_ap_card(dev)->id == (int)(long)(void *) data;
>  }
>  
>  /*
>   * Helper function to be used with bus_find_dev
>   * matches for the queue device with a given qid
>   */
> -static int __match_queue_device_with_qid(struct device *dev, void *data)
> +static int __match_queue_device_with_qid(struct device *dev, const void *data)
>  {
>  	return is_queue_dev(dev) && to_ap_queue(dev)->qid == (int)(long) data;
>  }
> @@ -1374,7 +1374,7 @@ static int __match_queue_device_with_qid(struct device *dev, void *data)
>   * Helper function to be used with bus_find_dev
>   * matches any queue device with given queue id
>   */
> -static int __match_queue_device_with_queue_id(struct device *dev, void *data)
> +static int __match_queue_device_with_queue_id(struct device *dev, const void *data)
>  {
>  	return is_queue_dev(dev)
>  		&& AP_QID_QUEUE(to_ap_queue(dev)->qid) == (int)(long) data;
> diff --git a/drivers/scsi/scsi_proc.c b/drivers/scsi/scsi_proc.c
> index 7f0ceb6..c074631 100644
> --- a/drivers/scsi/scsi_proc.c
> +++ b/drivers/scsi/scsi_proc.c
> @@ -372,7 +372,7 @@ static ssize_t proc_scsi_write(struct file *file, const char __user *buf,
>  	return err;
>  }
>  
> -static int always_match(struct device *dev, void *data)
> +static int always_match(struct device *dev, const void *data)
>  {
>  	return 1;
>  }
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index 5e75944..3da1121 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -3538,7 +3538,7 @@ EXPORT_SYMBOL_GPL(spi_write_then_read);
>  /*-------------------------------------------------------------------------*/
>  
>  #if IS_ENABLED(CONFIG_OF)
> -static int __spi_of_device_match(struct device *dev, void *data)
> +static int __spi_of_device_match(struct device *dev, const void *data)
>  {
>  	return dev->of_node == data;
>  }
> @@ -3639,7 +3639,7 @@ static int spi_acpi_controller_match(struct device *dev, const void *data)
>  	return ACPI_COMPANION(dev->parent) == data;
>  }
>  
> -static int spi_acpi_device_match(struct device *dev, void *data)
> +static int spi_acpi_device_match(struct device *dev, const void *data)
>  {
>  	return ACPI_COMPANION(dev) == data;
>  }
> diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
> index 86a8545..3f8f340 100644
> --- a/drivers/staging/most/core.c
> +++ b/drivers/staging/most/core.c
> @@ -561,9 +561,9 @@ static int split_string(char *buf, char **a, char **b, char **c, char **d)
>  	return 0;
>  }
>  
> -static int match_bus_dev(struct device *dev, void *data)
> +static int match_bus_dev(struct device *dev, const void *data)
>  {
> -	char *mdev_name = data;
> +	const char *mdev_name = data;
>  
>  	return !strcmp(dev_name(dev), mdev_name);
>  }
> diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
> index c1b0165..c9a7e4a 100644
> --- a/drivers/thunderbolt/switch.c
> +++ b/drivers/thunderbolt/switch.c
> @@ -1946,10 +1946,10 @@ struct tb_sw_lookup {
>  	u64 route;
>  };
>  
> -static int tb_switch_match(struct device *dev, void *data)
> +static int tb_switch_match(struct device *dev, const void *data)
>  {
>  	struct tb_switch *sw = tb_to_switch(dev);
> -	struct tb_sw_lookup *lookup = data;
> +	const struct tb_sw_lookup *lookup = data;
>  
>  	if (!sw)
>  		return 0;
> diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
> index fa783531..7bd7de7 100644
> --- a/drivers/usb/core/devio.c
> +++ b/drivers/usb/core/devio.c
> @@ -947,9 +947,9 @@ static int parse_usbdevfs_streams(struct usb_dev_state *ps,
>  	return ret;
>  }
>  
> -static int match_devt(struct device *dev, void *data)
> +static int match_devt(struct device *dev, const void *data)
>  {
> -	return dev->devt == (dev_t) (unsigned long) data;
> +	return dev->devt == (dev_t)(unsigned long)(void *)data;
>  }
>  
>  static struct usb_device *usbdev_lookup_by_devt(dev_t devt)
> diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
> index 7fcb9f7..1678e30 100644
> --- a/drivers/usb/core/usb.c
> +++ b/drivers/usb/core/usb.c
> @@ -325,9 +325,9 @@ struct find_interface_arg {
>  	struct device_driver *drv;
>  };
>  
> -static int __find_interface(struct device *dev, void *data)
> +static int __find_interface(struct device *dev, const void *data)
>  {
> -	struct find_interface_arg *arg = data;
> +	const struct find_interface_arg *arg = data;
>  	struct usb_interface *intf;
>  
>  	if (!is_usb_interface(dev))
> diff --git a/drivers/usb/phy/phy-am335x-control.c b/drivers/usb/phy/phy-am335x-control.c
> index a3cb25c..d16dfc3 100644
> --- a/drivers/usb/phy/phy-am335x-control.c
> +++ b/drivers/usb/phy/phy-am335x-control.c
> @@ -118,9 +118,9 @@ static const struct of_device_id omap_control_usb_id_table[] = {
>  MODULE_DEVICE_TABLE(of, omap_control_usb_id_table);
>  
>  static struct platform_driver am335x_control_driver;
> -static int match(struct device *dev, void *data)
> +static int match(struct device *dev, const void *data)
>  {
> -	struct device_node *node = (struct device_node *)data;
> +	const struct device_node *node = (const struct device_node *)data;
>  	return dev->of_node == node &&
>  		dev->driver == &am335x_control_driver.driver;
>  }
> diff --git a/drivers/usb/phy/phy-isp1301.c b/drivers/usb/phy/phy-isp1301.c
> index 93b7d6a..6cf6fbd 100644
> --- a/drivers/usb/phy/phy-isp1301.c
> +++ b/drivers/usb/phy/phy-isp1301.c
> @@ -142,9 +142,9 @@ static struct i2c_driver isp1301_driver = {
>  
>  module_i2c_driver(isp1301_driver);
>  
> -static int match(struct device *dev, void *data)
> +static int match(struct device *dev, const void *data)
>  {
> -	struct device_node *node = (struct device_node *)data;
> +	const struct device_node *node = (const struct device_node *)data;
>  	return (dev->of_node == node) &&
>  		(dev->driver == &isp1301_driver.driver);
>  }
> diff --git a/drivers/visorbus/visorbus_main.c b/drivers/visorbus/visorbus_main.c
> index 0b2434c..152fd29 100644
> --- a/drivers/visorbus/visorbus_main.c
> +++ b/drivers/visorbus/visorbus_main.c
> @@ -171,10 +171,10 @@ struct visor_busdev {
>  	u32 dev_no;
>  };
>  
> -static int match_visorbus_dev_by_id(struct device *dev, void *data)
> +static int match_visorbus_dev_by_id(struct device *dev, const void *data)
>  {
>  	struct visor_device *vdev = to_visor_device(dev);
> -	struct visor_busdev *id = data;
> +	const struct visor_busdev *id = data;
>  
>  	if (vdev->chipset_bus_no == id->bus_no &&
>  	    vdev->chipset_dev_no == id->dev_no)
> diff --git a/include/linux/device.h b/include/linux/device.h
> index e85264f..cbbdcadc 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -166,8 +166,8 @@ void subsys_dev_iter_exit(struct subsys_dev_iter *iter);
>  int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
>  		     int (*fn)(struct device *dev, void *data));
>  struct device *bus_find_device(struct bus_type *bus, struct device *start,
> -			       void *data,
> -			       int (*match)(struct device *dev, void *data));
> +			       const void *data,
> +			       int (*match)(struct device *dev, const void *data));
>  struct device *bus_find_device_by_name(struct bus_type *bus,
>  				       struct device *start,
>  				       const char *name);
> diff --git a/sound/soc/rockchip/rk3399_gru_sound.c b/sound/soc/rockchip/rk3399_gru_sound.c
> index 3d0cc6e..c04c9ed 100644
> --- a/sound/soc/rockchip/rk3399_gru_sound.c
> +++ b/sound/soc/rockchip/rk3399_gru_sound.c
> @@ -405,7 +405,7 @@ static const struct dailink_match_data dailink_match[] = {
>  	},
>  };
>  
> -static int of_dev_node_match(struct device *dev, void *data)
> +static int of_dev_node_match(struct device *dev, const void *data)
>  {
>  	return dev->of_node == data;
>  }
> -- 
> 2.7.4
> 

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

* RE: [PATCH 02/13] bus_find_device: Unify the match callback with class_find_device
  2019-06-05 15:13 ` [PATCH 02/13] bus_find_device: Unify the match callback with class_find_device Suzuki K Poulose
  2019-06-05 15:48   ` Corey Minyard
@ 2019-06-05 15:51   ` Kershner, David A
  2019-06-05 18:18   ` Mark Brown
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 39+ messages in thread
From: Kershner, David A @ 2019-06-05 15:51 UTC (permalink / raw)
  To: Suzuki K Poulose, linux-kernel
  Cc: gregkh, rafael, Alexander Shishkin, Andrew Lunn, Andreas Noever,
	Arnd Bergmann, Bjorn Helgaas, Corey Minyard,
	Christian Borntraeger, David S. Miller, David Airlie,
	Felipe Balbi, Frank Rowand, Grygorii Strashko,
	Harald Freudenberger, Hartmut Knaack, Heiko Stuebner,
	Jason Gunthorpe, Jonathan Cameron, James E.J. Bottomley,
	Len Brown, Mark Brown, Michael Ellerman, Michael Jamet,
	Martin K. Petersen, Peter Oberparleiter, Rob Herring,
	Sebastian Ott, Srinivas Kandagatla, Yehezkel Bernat,
	Wolfram Sang

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

> -----Original Message-----
> From: Suzuki K Poulose [mailto:suzuki.poulose@arm.com]
> Subject: [PATCH 02/13] bus_find_device: Unify the match callback with
> class_find_device
> 
> There is an arbitrary difference between the prototypes of
> bus_find_device() and class_find_device() preventing their callers
> from passing the same pair of data and match() arguments to both of
> them, which is the const qualifier used in the prototype of
> class_find_device().  If that qualifier is also used in the
> bus_find_device() prototype, it will be possible to pass the same
> match() callback function to both bus_find_device() and
> class_find_device(), which will allow some optimizations to be made in
> order to avoid code duplication going forward.  Also with that, constify
> the "data" parameter as it is passed as a const to the match function.
> 
> For this reason, change the prototype of bus_find_device() to match
> the prototype of class_find_device() and adjust its callers to use the
> const qualifier in accordance with the new prototype of it.
> 

Visorbus portion looks ok.

Acked-by: David Kershner <david.kershner@unisys.com>

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 7882 bytes --]

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

* Re: [PATCH 10/13] drivers: Introduce variants of class_find_device()
  2019-06-05 15:13   ` Suzuki K Poulose
@ 2019-06-05 16:14     ` Greg KH
  -1 siblings, 0 replies; 39+ messages in thread
From: Greg KH @ 2019-06-05 16:14 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: linux-kernel, rafael, Alessandro Zummo, Alexander Aring,
	Alexander Shishkin, Alexandre Belloni, Andrew Lunn,
	Arnd Bergmann, Dan Murphy, David S. Miller, Florian Fainelli,
	Harald Freudenberger, Heikki Krogerus, Heiko Carstens,
	Heiner Kallweit, Jacek Anaszewski, Jiri Slaby, Liam Girdwood,
	linux-leds, linux-rtc

On Wed, Jun 05, 2019 at 04:13:47PM +0100, Suzuki K Poulose wrote:
> +/**
> + * class_find_device_by_devt : device iterator for locating a particular device
> + * matching the device type.
> + * @class: class type
> + * @start: device to start search from
> + * @devt: device type of the device to match.
> + */
> +static inline struct device *class_find_device_by_devt(struct class *class,
> +						       struct device *start,
> +						       dev_t devt)
> +{
> +	return class_find_device(class, start, &devt, device_match_devt);
> +}

Still has the start parameter, despite the changelog saying it would not
:(

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

* Re: [PATCH 10/13] drivers: Introduce variants of class_find_device()
@ 2019-06-05 16:14     ` Greg KH
  0 siblings, 0 replies; 39+ messages in thread
From: Greg KH @ 2019-06-05 16:14 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: linux-kernel, rafael, Alessandro Zummo, Alexander Aring,
	Alexander Shishkin, Alexandre Belloni, Andrew Lunn,
	Arnd Bergmann, Dan Murphy, David S. Miller, Florian Fainelli,
	Harald Freudenberger, Heikki Krogerus, Heiko Carstens,
	Heiner Kallweit, Jacek Anaszewski, Jiri Slaby, Liam Girdwood,
	linux-leds, linux-rtc, linux-usb, linux-wpan, Mark Brown,
	Maxime Coquelin, Pavel Machek, Peter Rosin, Stefan Schmidt,
	Tomas Winkler, Rafael J. Wysocki

On Wed, Jun 05, 2019 at 04:13:47PM +0100, Suzuki K Poulose wrote:
> +/**
> + * class_find_device_by_devt : device iterator for locating a particular device
> + * matching the device type.
> + * @class: class type
> + * @start: device to start search from
> + * @devt: device type of the device to match.
> + */
> +static inline struct device *class_find_device_by_devt(struct class *class,
> +						       struct device *start,
> +						       dev_t devt)
> +{
> +	return class_find_device(class, start, &devt, device_match_devt);
> +}

Still has the start parameter, despite the changelog saying it would not
:(


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

* Re: [PATCH 10/13] drivers: Introduce variants of class_find_device()
  2019-06-05 16:14     ` Greg KH
  (?)
@ 2019-06-05 18:13     ` Suzuki K Poulose
  -1 siblings, 0 replies; 39+ messages in thread
From: Suzuki K Poulose @ 2019-06-05 18:13 UTC (permalink / raw)
  To: gregkh
  Cc: linux-kernel, rafael, a.zummo, alex.aring, alexander.shishkin,
	alexandre.belloni, andrew, arnd, dmurphy, davem, f.fainelli,
	freude, heikki.krogerus, heiko.carstens, hkallweit1,
	jacek.anaszewski, jslaby, lgirdwood, linux-leds, linux-rtc,
	linux-usb, linux-wpan, broonie, mcoquelin.stm32, pavel, peda,
	stefan, tomas.winkler, rafael.j.wysocki

Hi Greg,

On 06/05/2019 05:14 PM, Greg KH wrote:
> On Wed, Jun 05, 2019 at 04:13:47PM +0100, Suzuki K Poulose wrote:
>> +/**
>> + * class_find_device_by_devt : device iterator for locating a particular device
>> + * matching the device type.
>> + * @class: class type
>> + * @start: device to start search from
>> + * @devt: device type of the device to match.
>> + */
>> +static inline struct device *class_find_device_by_devt(struct class *class,
>> +						       struct device *start,
>> +						       dev_t devt)
>> +{
>> +	return class_find_device(class, start, &devt, device_match_devt);
>> +}
> 
> Still has the start parameter, despite the changelog saying it would not
> :(
> 

Well, I kept the start parameter just for the _devt variants, as
mentioned in the changelog:

" The new wrappers except the lookup by devt, drops the "start" device 
pointer as none of the existing users need it and the attributes are 
usually unique. The idea is to stop the proliferation of custom match.."

Somehow I thought the dev_t may be duplicate for devices, which is why
I didn't change that alone. But that was silly of me to ignore the minor
number part. I will respin it fixing that.

Suzuki

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

* Re: [PATCH 02/13] bus_find_device: Unify the match callback with class_find_device
  2019-06-05 15:13 ` [PATCH 02/13] bus_find_device: Unify the match callback with class_find_device Suzuki K Poulose
  2019-06-05 15:48   ` Corey Minyard
  2019-06-05 15:51   ` Kershner, David A
@ 2019-06-05 18:18   ` Mark Brown
  2019-06-06  8:56   ` Rafael J. Wysocki
  2019-06-06  9:01   ` Srinivas Kandagatla
  4 siblings, 0 replies; 39+ messages in thread
From: Mark Brown @ 2019-06-05 18:18 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: linux-kernel, gregkh, rafael, Alexander Shishkin, Andrew Lunn,
	Andreas Noever, Arnd Bergmann, Bjorn Helgaas, Corey Minyard,
	Christian Borntraeger, David Kershner, David S. Miller,
	David Airlie, Felipe Balbi, Frank Rowand, Grygorii Strashko,
	Harald Freudenberger, Hartmut Knaack, Heiko Stuebner,
	Jason Gunthorpe, Jonathan Cameron, James E.J. Bottomley,
	Len Brown, Michael Ellerman, Michael Jamet, Martin K. Petersen,
	Peter Oberparleiter, Rob Herring, Sebastian Ott,
	Srinivas Kandagatla, Yehezkel Bernat, Wolfram Sang

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

On Wed, Jun 05, 2019 at 04:13:39PM +0100, Suzuki K Poulose wrote:
> There is an arbitrary difference between the prototypes of
> bus_find_device() and class_find_device() preventing their callers
> from passing the same pair of data and match() arguments to both of
> them, which is the const qualifier used in the prototype of

Acked-by: Mark Brown <broonie@kernel.org>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 02/13] bus_find_device: Unify the match callback with class_find_device
  2019-06-05 15:13 ` [PATCH 02/13] bus_find_device: Unify the match callback with class_find_device Suzuki K Poulose
                     ` (2 preceding siblings ...)
  2019-06-05 18:18   ` Mark Brown
@ 2019-06-06  8:56   ` Rafael J. Wysocki
  2019-06-06  9:01   ` Srinivas Kandagatla
  4 siblings, 0 replies; 39+ messages in thread
From: Rafael J. Wysocki @ 2019-06-06  8:56 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: Linux Kernel Mailing List, Greg Kroah-Hartman, Rafael J. Wysocki,
	Alexander Shishkin, Andrew Lunn, Andreas Noever, Arnd Bergmann,
	Bjorn Helgaas, Corey Minyard, Christian Borntraeger,
	David Kershner, David S. Miller, David Airlie, Felipe Balbi,
	Frank Rowand, Grygorii Strashko, Harald Freudenberger,
	Hartmut Knaack, Heiko Stuebner, Jason Gunthorpe,
	Jonathan Cameron, James E.J. Bottomley, Len Brown, Mark Brown,
	Michael Ellerman, Michael Jamet, Martin K. Petersen,
	Peter Oberparleiter, Rob Herring, Sebastian Ott,
	Srinivas Kandagatla, Yehezkel Bernat, Wolfram Sang

On Wed, Jun 5, 2019 at 5:14 PM Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
>
> There is an arbitrary difference between the prototypes of
> bus_find_device() and class_find_device() preventing their callers
> from passing the same pair of data and match() arguments to both of
> them, which is the const qualifier used in the prototype of
> class_find_device().  If that qualifier is also used in the
> bus_find_device() prototype, it will be possible to pass the same
> match() callback function to both bus_find_device() and
> class_find_device(), which will allow some optimizations to be made in
> order to avoid code duplication going forward.  Also with that, constify
> the "data" parameter as it is passed as a const to the match function.
>
> For this reason, change the prototype of bus_find_device() to match
> the prototype of class_find_device() and adjust its callers to use the
> const qualifier in accordance with the new prototype of it.
>
> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Andreas Noever <andreas.noever@gmail.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Corey Minyard <minyard@acm.org>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> Cc: David Kershner <david.kershner@unisys.com>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: David Airlie <airlied@linux.ie>
> Cc: Felipe Balbi <balbi@kernel.org>
> Cc: Frank Rowand <frowand.list@gmail.com>
> Cc: Grygorii Strashko <grygorii.strashko@ti.com>
> Cc: Harald Freudenberger <freude@linux.ibm.com>
> Cc: Hartmut Knaack <knaack.h@gmx.de>
> Cc: Heiko Stuebner <heiko@sntech.de>
> Cc: Jason Gunthorpe <jgg@ziepe.ca>
> Cc: Jonathan Cameron <jic23@kernel.org>
> Cc: Jonathan Cameron <jic23@kernel.org>
> Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
> Cc: Len Brown <lenb@kernel.org>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Michael Jamet <michael.jamet@intel.com>
> Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
> Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Sebastian Ott <sebott@linux.ibm.com>
> Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> Cc: Yehezkel Bernat <YehezkelShB@gmail.com>
> Cc: Wolfram Sang <wsa@the-dreams.de>
> Cc: rafael@kernel.org
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>

For the ACPI changes:

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

> ---
>  arch/powerpc/platforms/pseries/ibmebus.c           | 4 ++--
>  drivers/acpi/acpi_lpss.c                           | 4 ++--
>  drivers/acpi/sleep.c                               | 2 +-
>  drivers/acpi/utils.c                               | 4 ++--
>  drivers/base/bus.c                                 | 6 +++---
>  drivers/base/devcon.c                              | 2 +-
>  drivers/char/ipmi/ipmi_si_platform.c               | 2 +-
>  drivers/firmware/efi/dev-path-parser.c             | 4 ++--
>  drivers/gpu/drm/drm_mipi_dsi.c                     | 2 +-
>  drivers/hwtracing/coresight/coresight.c            | 6 +++---
>  drivers/hwtracing/coresight/of_coresight.c         | 2 +-
>  drivers/hwtracing/intel_th/core.c                  | 5 ++---
>  drivers/i2c/i2c-core-acpi.c                        | 4 ++--
>  drivers/i2c/i2c-core-of.c                          | 4 ++--
>  drivers/iio/inkern.c                               | 2 +-
>  drivers/infiniband/hw/hns/hns_roce_hw_v1.c         | 2 +-
>  drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c | 2 +-
>  drivers/net/ethernet/ti/cpsw-phy-sel.c             | 4 ++--
>  drivers/net/ethernet/ti/davinci_emac.c             | 2 +-
>  drivers/net/ethernet/toshiba/tc35815.c             | 4 ++--
>  drivers/nvmem/core.c                               | 2 +-
>  drivers/of/of_mdio.c                               | 2 +-
>  drivers/of/platform.c                              | 2 +-
>  drivers/pci/probe.c                                | 2 +-
>  drivers/pci/search.c                               | 4 ++--
>  drivers/s390/cio/css.c                             | 4 ++--
>  drivers/s390/cio/device.c                          | 4 ++--
>  drivers/s390/cio/scm.c                             | 4 ++--
>  drivers/s390/crypto/ap_bus.c                       | 8 ++++----
>  drivers/scsi/scsi_proc.c                           | 2 +-
>  drivers/spi/spi.c                                  | 4 ++--
>  drivers/staging/most/core.c                        | 4 ++--
>  drivers/thunderbolt/switch.c                       | 4 ++--
>  drivers/usb/core/devio.c                           | 4 ++--
>  drivers/usb/core/usb.c                             | 4 ++--
>  drivers/usb/phy/phy-am335x-control.c               | 4 ++--
>  drivers/usb/phy/phy-isp1301.c                      | 4 ++--
>  drivers/visorbus/visorbus_main.c                   | 4 ++--
>  include/linux/device.h                             | 4 ++--
>  sound/soc/rockchip/rk3399_gru_sound.c              | 2 +-
>  40 files changed, 69 insertions(+), 70 deletions(-)
>
> diff --git a/arch/powerpc/platforms/pseries/ibmebus.c b/arch/powerpc/platforms/pseries/ibmebus.c
> index 84e8ec4..b91eb09 100644
> --- a/arch/powerpc/platforms/pseries/ibmebus.c
> +++ b/arch/powerpc/platforms/pseries/ibmebus.c
> @@ -147,13 +147,13 @@ static const struct dma_map_ops ibmebus_dma_ops = {
>         .unmap_page         = ibmebus_unmap_page,
>  };
>
> -static int ibmebus_match_path(struct device *dev, void *data)
> +static int ibmebus_match_path(struct device *dev, const void *data)
>  {
>         struct device_node *dn = to_platform_device(dev)->dev.of_node;
>         return (of_find_node_by_path(data) == dn);
>  }
>
> -static int ibmebus_match_node(struct device *dev, void *data)
> +static int ibmebus_match_node(struct device *dev, const void *data)
>  {
>         return to_platform_device(dev)->dev.of_node == data;
>  }
> diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
> index cf76860..dc2ca78 100644
> --- a/drivers/acpi/acpi_lpss.c
> +++ b/drivers/acpi/acpi_lpss.c
> @@ -511,10 +511,10 @@ struct hid_uid {
>         const char *uid;
>  };
>
> -static int match_hid_uid(struct device *dev, void *data)
> +static int match_hid_uid(struct device *dev, const void *data)
>  {
>         struct acpi_device *adev = ACPI_COMPANION(dev);
> -       struct hid_uid *id = data;
> +       const struct hid_uid *id = data;
>
>         if (!adev)
>                 return 0;
> diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
> index a34decc..fcf4386 100644
> --- a/drivers/acpi/sleep.c
> +++ b/drivers/acpi/sleep.c
> @@ -454,7 +454,7 @@ static int acpi_pm_prepare(void)
>         return error;
>  }
>
> -static int find_powerf_dev(struct device *dev, void *data)
> +static int find_powerf_dev(struct device *dev, const void *data)
>  {
>         struct acpi_device *device = to_acpi_device(dev);
>         const char *hid = acpi_device_hid(device);
> diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
> index 1391b63..e3974a8 100644
> --- a/drivers/acpi/utils.c
> +++ b/drivers/acpi/utils.c
> @@ -730,10 +730,10 @@ struct acpi_dev_match_info {
>         s64 hrv;
>  };
>
> -static int acpi_dev_match_cb(struct device *dev, void *data)
> +static int acpi_dev_match_cb(struct device *dev, const void *data)
>  {
>         struct acpi_device *adev = to_acpi_device(dev);
> -       struct acpi_dev_match_info *match = data;
> +       const struct acpi_dev_match_info *match = data;
>         unsigned long long hrv;
>         acpi_status status;
>
> diff --git a/drivers/base/bus.c b/drivers/base/bus.c
> index 0a58e96..df3cac7 100644
> --- a/drivers/base/bus.c
> +++ b/drivers/base/bus.c
> @@ -323,8 +323,8 @@ EXPORT_SYMBOL_GPL(bus_for_each_dev);
>   * return to the caller and not iterate over any more devices.
>   */
>  struct device *bus_find_device(struct bus_type *bus,
> -                              struct device *start, void *data,
> -                              int (*match)(struct device *dev, void *data))
> +                              struct device *start, const void *data,
> +                              int (*match)(struct device *dev, const void *data))
>  {
>         struct klist_iter i;
>         struct device *dev;
> @@ -342,7 +342,7 @@ struct device *bus_find_device(struct bus_type *bus,
>  }
>  EXPORT_SYMBOL_GPL(bus_find_device);
>
> -static int match_name(struct device *dev, void *data)
> +static int match_name(struct device *dev, const void *data)
>  {
>         const char *name = data;
>
> diff --git a/drivers/base/devcon.c b/drivers/base/devcon.c
> index 04db9ae..ac026d5 100644
> --- a/drivers/base/devcon.c
> +++ b/drivers/base/devcon.c
> @@ -107,7 +107,7 @@ static struct bus_type *generic_match_buses[] = {
>         NULL,
>  };
>
> -static int device_fwnode_match(struct device *dev, void *fwnode)
> +static int device_fwnode_match(struct device *dev, const void *fwnode)
>  {
>         return dev_fwnode(dev) == fwnode;
>  }
> diff --git a/drivers/char/ipmi/ipmi_si_platform.c b/drivers/char/ipmi/ipmi_si_platform.c
> index f2a91c4..fd94c42 100644
> --- a/drivers/char/ipmi/ipmi_si_platform.c
> +++ b/drivers/char/ipmi/ipmi_si_platform.c
> @@ -426,7 +426,7 @@ static int ipmi_remove(struct platform_device *pdev)
>         return ipmi_si_remove_by_dev(&pdev->dev);
>  }
>
> -static int pdev_match_name(struct device *dev, void *data)
> +static int pdev_match_name(struct device *dev, const void *data)
>  {
>         struct platform_device *pdev = to_platform_device(dev);
>         const char *name = data;
> diff --git a/drivers/firmware/efi/dev-path-parser.c b/drivers/firmware/efi/dev-path-parser.c
> index 85ec99f..2012338 100644
> --- a/drivers/firmware/efi/dev-path-parser.c
> +++ b/drivers/firmware/efi/dev-path-parser.c
> @@ -17,9 +17,9 @@ struct acpi_hid_uid {
>         char uid[11]; /* UINT_MAX + null byte */
>  };
>
> -static int __init match_acpi_dev(struct device *dev, void *data)
> +static int __init match_acpi_dev(struct device *dev, const void *data)
>  {
> -       struct acpi_hid_uid hid_uid = *(struct acpi_hid_uid *)data;
> +       struct acpi_hid_uid hid_uid = *(const struct acpi_hid_uid *)data;
>         struct acpi_device *adev = to_acpi_device(dev);
>
>         if (acpi_match_device_ids(adev, hid_uid.hid))
> diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
> index 80b7550..ad19df0 100644
> --- a/drivers/gpu/drm/drm_mipi_dsi.c
> +++ b/drivers/gpu/drm/drm_mipi_dsi.c
> @@ -93,7 +93,7 @@ static struct bus_type mipi_dsi_bus_type = {
>         .pm = &mipi_dsi_device_pm_ops,
>  };
>
> -static int of_device_match(struct device *dev, void *data)
> +static int of_device_match(struct device *dev, const void *data)
>  {
>         return dev->of_node == data;
>  }
> diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c
> index 4b13028..b67ab6a 100644
> --- a/drivers/hwtracing/coresight/coresight.c
> +++ b/drivers/hwtracing/coresight/coresight.c
> @@ -498,9 +498,9 @@ struct coresight_device *coresight_get_sink(struct list_head *path)
>         return csdev;
>  }
>
> -static int coresight_enabled_sink(struct device *dev, void *data)
> +static int coresight_enabled_sink(struct device *dev, const void *data)
>  {
> -       bool *reset = data;
> +       const bool *reset = data;
>         struct coresight_device *csdev = to_coresight_device(dev);
>
>         if ((csdev->type == CORESIGHT_DEV_TYPE_SINK ||
> @@ -544,7 +544,7 @@ struct coresight_device *coresight_get_enabled_sink(bool deactivate)
>         return dev ? to_coresight_device(dev) : NULL;
>  }
>
> -static int coresight_sink_by_id(struct device *dev, void *data)
> +static int coresight_sink_by_id(struct device *dev, const void *data)
>  {
>         struct coresight_device *csdev = to_coresight_device(dev);
>         unsigned long hash;
> diff --git a/drivers/hwtracing/coresight/of_coresight.c b/drivers/hwtracing/coresight/of_coresight.c
> index 7045930..3fc200e 100644
> --- a/drivers/hwtracing/coresight/of_coresight.c
> +++ b/drivers/hwtracing/coresight/of_coresight.c
> @@ -18,7 +18,7 @@
>  #include <asm/smp_plat.h>
>
>
> -static int of_dev_node_match(struct device *dev, void *data)
> +static int of_dev_node_match(struct device *dev, const void *data)
>  {
>         return dev->of_node == data;
>  }
> diff --git a/drivers/hwtracing/intel_th/core.c b/drivers/hwtracing/intel_th/core.c
> index 033dce5..5592289 100644
> --- a/drivers/hwtracing/intel_th/core.c
> +++ b/drivers/hwtracing/intel_th/core.c
> @@ -789,10 +789,9 @@ static int intel_th_populate(struct intel_th *th)
>         return 0;
>  }
>
> -static int match_devt(struct device *dev, void *data)
> +static int match_devt(struct device *dev, const void *data)
>  {
> -       dev_t devt = (dev_t)(unsigned long)data;
> -
> +       dev_t devt = (dev_t)(unsigned long)(void *)data;
>         return dev->devt == devt;
>  }
>
> diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
> index d840955..8af35f11 100644
> --- a/drivers/i2c/i2c-core-acpi.c
> +++ b/drivers/i2c/i2c-core-acpi.c
> @@ -318,7 +318,7 @@ u32 i2c_acpi_find_bus_speed(struct device *dev)
>  }
>  EXPORT_SYMBOL_GPL(i2c_acpi_find_bus_speed);
>
> -static int i2c_acpi_find_match_adapter(struct device *dev, void *data)
> +static int i2c_acpi_find_match_adapter(struct device *dev, const void *data)
>  {
>         struct i2c_adapter *adapter = i2c_verify_adapter(dev);
>
> @@ -328,7 +328,7 @@ static int i2c_acpi_find_match_adapter(struct device *dev, void *data)
>         return ACPI_HANDLE(dev) == (acpi_handle)data;
>  }
>
> -static int i2c_acpi_find_match_device(struct device *dev, void *data)
> +static int i2c_acpi_find_match_device(struct device *dev, const void *data)
>  {
>         return ACPI_COMPANION(dev) == data;
>  }
> diff --git a/drivers/i2c/i2c-core-of.c b/drivers/i2c/i2c-core-of.c
> index 406e5f6..2eb59a2 100644
> --- a/drivers/i2c/i2c-core-of.c
> +++ b/drivers/i2c/i2c-core-of.c
> @@ -112,12 +112,12 @@ void of_i2c_register_devices(struct i2c_adapter *adap)
>         of_node_put(bus);
>  }
>
> -static int of_dev_node_match(struct device *dev, void *data)
> +static int of_dev_node_match(struct device *dev, const void *data)
>  {
>         return dev->of_node == data;
>  }
>
> -static int of_dev_or_parent_node_match(struct device *dev, void *data)
> +static int of_dev_or_parent_node_match(struct device *dev, const void *data)
>  {
>         if (dev->of_node == data)
>                 return 1;
> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> index 4a5eff3..c46fb59 100644
> --- a/drivers/iio/inkern.c
> +++ b/drivers/iio/inkern.c
> @@ -93,7 +93,7 @@ static const struct iio_chan_spec
>
>  #ifdef CONFIG_OF
>
> -static int iio_dev_node_match(struct device *dev, void *data)
> +static int iio_dev_node_match(struct device *dev, const void *data)
>  {
>         return dev->of_node == data && dev->type == &iio_device_type;
>  }
> diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
> index 4c5d0f1..fd90b05 100644
> --- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
> +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
> @@ -4497,7 +4497,7 @@ static const struct acpi_device_id hns_roce_acpi_match[] = {
>  };
>  MODULE_DEVICE_TABLE(acpi, hns_roce_acpi_match);
>
> -static int hns_roce_node_match(struct device *dev, void *fwnode)
> +static int hns_roce_node_match(struct device *dev, const void *fwnode)
>  {
>         return dev->fwnode == fwnode;
>  }
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c
> index 09c16d8..bb6586d 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c
> @@ -754,7 +754,7 @@ struct dsaf_misc_op *hns_misc_op_get(struct dsaf_device *dsaf_dev)
>         return (void *)misc_op;
>  }
>
> -static int hns_dsaf_dev_match(struct device *dev, void *fwnode)
> +static int hns_dsaf_dev_match(struct device *dev, const void *fwnode)
>  {
>         return dev->fwnode == fwnode;
>  }
> diff --git a/drivers/net/ethernet/ti/cpsw-phy-sel.c b/drivers/net/ethernet/ti/cpsw-phy-sel.c
> index 48e0924..4e184ee 100644
> --- a/drivers/net/ethernet/ti/cpsw-phy-sel.c
> +++ b/drivers/net/ethernet/ti/cpsw-phy-sel.c
> @@ -151,9 +151,9 @@ static void cpsw_gmii_sel_dra7xx(struct cpsw_phy_sel_priv *priv,
>  }
>
>  static struct platform_driver cpsw_phy_sel_driver;
> -static int match(struct device *dev, void *data)
> +static int match(struct device *dev, const void *data)
>  {
> -       struct device_node *node = (struct device_node *)data;
> +       const struct device_node *node = (const struct device_node *)data;
>         return dev->of_node == node &&
>                 dev->driver == &cpsw_phy_sel_driver.driver;
>  }
> diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
> index 4bf65ca..57d131a 100644
> --- a/drivers/net/ethernet/ti/davinci_emac.c
> +++ b/drivers/net/ethernet/ti/davinci_emac.c
> @@ -1371,7 +1371,7 @@ static int emac_devioctl(struct net_device *ndev, struct ifreq *ifrq, int cmd)
>                 return -EOPNOTSUPP;
>  }
>
> -static int match_first_device(struct device *dev, void *data)
> +static int match_first_device(struct device *dev, const void *data)
>  {
>         if (dev->parent && dev->parent->of_node)
>                 return of_device_is_compatible(dev->parent->of_node,
> diff --git a/drivers/net/ethernet/toshiba/tc35815.c b/drivers/net/ethernet/toshiba/tc35815.c
> index c50a977..8479a44 100644
> --- a/drivers/net/ethernet/toshiba/tc35815.c
> +++ b/drivers/net/ethernet/toshiba/tc35815.c
> @@ -694,10 +694,10 @@ static int tc_mii_init(struct net_device *dev)
>   * should provide a "tc35815-mac" device with a MAC address in its
>   * platform_data.
>   */
> -static int tc35815_mac_match(struct device *dev, void *data)
> +static int tc35815_mac_match(struct device *dev, const void *data)
>  {
>         struct platform_device *plat_dev = to_platform_device(dev);
> -       struct pci_dev *pci_dev = data;
> +       const struct pci_dev *pci_dev = data;
>         unsigned int id = pci_dev->irq;
>         return !strcmp(plat_dev->name, "tc35815-mac") && plat_dev->id == id;
>  }
> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> index c7892c3..ac5d945 100644
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
> @@ -76,7 +76,7 @@ static struct bus_type nvmem_bus_type = {
>         .name           = "nvmem",
>  };
>
> -static int of_nvmem_match(struct device *dev, void *nvmem_np)
> +static int of_nvmem_match(struct device *dev, const void *nvmem_np)
>  {
>         return dev->of_node == nvmem_np;
>  }
> diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
> index de61573..dfe1294 100644
> --- a/drivers/of/of_mdio.c
> +++ b/drivers/of/of_mdio.c
> @@ -282,7 +282,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
>  EXPORT_SYMBOL(of_mdiobus_register);
>
>  /* Helper function for of_phy_find_device */
> -static int of_phy_match(struct device *dev, void *phy_np)
> +static int of_phy_match(struct device *dev, const void *phy_np)
>  {
>         return dev->of_node == phy_np;
>  }
> diff --git a/drivers/of/platform.c b/drivers/of/platform.c
> index 04ad312..008d79e 100644
> --- a/drivers/of/platform.c
> +++ b/drivers/of/platform.c
> @@ -37,7 +37,7 @@ static const struct of_device_id of_skipped_node_table[] = {
>         {} /* Empty terminated list */
>  };
>
> -static int of_dev_node_match(struct device *dev, void *data)
> +static int of_dev_node_match(struct device *dev, const void *data)
>  {
>         return dev->of_node == data;
>  }
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 0e8e2c1..f9ef7ad 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -64,7 +64,7 @@ static struct resource *get_pci_domain_busn_res(int domain_nr)
>         return &r->res;
>  }
>
> -static int find_anything(struct device *dev, void *data)
> +static int find_anything(struct device *dev, const void *data)
>  {
>         return 1;
>  }
> diff --git a/drivers/pci/search.c b/drivers/pci/search.c
> index 5c79226..7f4e658 100644
> --- a/drivers/pci/search.c
> +++ b/drivers/pci/search.c
> @@ -236,10 +236,10 @@ struct pci_dev *pci_get_domain_bus_and_slot(int domain, unsigned int bus,
>  }
>  EXPORT_SYMBOL(pci_get_domain_bus_and_slot);
>
> -static int match_pci_dev_by_id(struct device *dev, void *data)
> +static int match_pci_dev_by_id(struct device *dev, const void *data)
>  {
>         struct pci_dev *pdev = to_pci_dev(dev);
> -       struct pci_device_id *id = data;
> +       const struct pci_device_id *id = data;
>
>         if (pci_match_one_device(id, pdev))
>                 return 1;
> diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
> index aea5029..7b8488d 100644
> --- a/drivers/s390/cio/css.c
> +++ b/drivers/s390/cio/css.c
> @@ -434,10 +434,10 @@ static int css_probe_device(struct subchannel_id schid, struct schib *schib)
>  }
>
>  static int
> -check_subchannel(struct device * dev, void * data)
> +check_subchannel(struct device *dev, const void *data)
>  {
>         struct subchannel *sch;
> -       struct subchannel_id *schid = data;
> +       const struct subchannel_id *schid = data;
>
>         sch = to_subchannel(dev);
>         return schid_equal(&sch->schid, schid);
> diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
> index 1540229..6ca9a3a 100644
> --- a/drivers/s390/cio/device.c
> +++ b/drivers/s390/cio/device.c
> @@ -642,10 +642,10 @@ static int ccw_device_add(struct ccw_device *cdev)
>         return device_add(dev);
>  }
>
> -static int match_dev_id(struct device *dev, void *data)
> +static int match_dev_id(struct device *dev, const void *data)
>  {
>         struct ccw_device *cdev = to_ccwdev(dev);
> -       struct ccw_dev_id *dev_id = data;
> +       const struct ccw_dev_id *dev_id = data;
>
>         return ccw_dev_id_is_equal(&cdev->private->dev_id, dev_id);
>  }
> diff --git a/drivers/s390/cio/scm.c b/drivers/s390/cio/scm.c
> index 6bca1d5..9f26d43 100644
> --- a/drivers/s390/cio/scm.c
> +++ b/drivers/s390/cio/scm.c
> @@ -174,10 +174,10 @@ static void scmdev_update(struct scm_device *scmdev, struct sale *sale)
>                 kobject_uevent(&scmdev->dev.kobj, KOBJ_CHANGE);
>  }
>
> -static int check_address(struct device *dev, void *data)
> +static int check_address(struct device *dev, const void *data)
>  {
>         struct scm_device *scmdev = to_scm_dev(dev);
> -       struct sale *sale = data;
> +       const struct sale *sale = data;
>
>         return scmdev->address == sale->sa;
>  }
> diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c
> index b9fc502..b7902b6 100644
> --- a/drivers/s390/crypto/ap_bus.c
> +++ b/drivers/s390/crypto/ap_bus.c
> @@ -1356,16 +1356,16 @@ static int ap_get_compatible_type(ap_qid_t qid, int rawtype, unsigned int func)
>   * Helper function to be used with bus_find_dev
>   * matches for the card device with the given id
>   */
> -static int __match_card_device_with_id(struct device *dev, void *data)
> +static int __match_card_device_with_id(struct device *dev, const void *data)
>  {
> -       return is_card_dev(dev) && to_ap_card(dev)->id == (int)(long) data;
> +       return is_card_dev(dev) && to_ap_card(dev)->id == (int)(long)(void *) data;
>  }
>
>  /*
>   * Helper function to be used with bus_find_dev
>   * matches for the queue device with a given qid
>   */
> -static int __match_queue_device_with_qid(struct device *dev, void *data)
> +static int __match_queue_device_with_qid(struct device *dev, const void *data)
>  {
>         return is_queue_dev(dev) && to_ap_queue(dev)->qid == (int)(long) data;
>  }
> @@ -1374,7 +1374,7 @@ static int __match_queue_device_with_qid(struct device *dev, void *data)
>   * Helper function to be used with bus_find_dev
>   * matches any queue device with given queue id
>   */
> -static int __match_queue_device_with_queue_id(struct device *dev, void *data)
> +static int __match_queue_device_with_queue_id(struct device *dev, const void *data)
>  {
>         return is_queue_dev(dev)
>                 && AP_QID_QUEUE(to_ap_queue(dev)->qid) == (int)(long) data;
> diff --git a/drivers/scsi/scsi_proc.c b/drivers/scsi/scsi_proc.c
> index 7f0ceb6..c074631 100644
> --- a/drivers/scsi/scsi_proc.c
> +++ b/drivers/scsi/scsi_proc.c
> @@ -372,7 +372,7 @@ static ssize_t proc_scsi_write(struct file *file, const char __user *buf,
>         return err;
>  }
>
> -static int always_match(struct device *dev, void *data)
> +static int always_match(struct device *dev, const void *data)
>  {
>         return 1;
>  }
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index 5e75944..3da1121 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -3538,7 +3538,7 @@ EXPORT_SYMBOL_GPL(spi_write_then_read);
>  /*-------------------------------------------------------------------------*/
>
>  #if IS_ENABLED(CONFIG_OF)
> -static int __spi_of_device_match(struct device *dev, void *data)
> +static int __spi_of_device_match(struct device *dev, const void *data)
>  {
>         return dev->of_node == data;
>  }
> @@ -3639,7 +3639,7 @@ static int spi_acpi_controller_match(struct device *dev, const void *data)
>         return ACPI_COMPANION(dev->parent) == data;
>  }
>
> -static int spi_acpi_device_match(struct device *dev, void *data)
> +static int spi_acpi_device_match(struct device *dev, const void *data)
>  {
>         return ACPI_COMPANION(dev) == data;
>  }
> diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
> index 86a8545..3f8f340 100644
> --- a/drivers/staging/most/core.c
> +++ b/drivers/staging/most/core.c
> @@ -561,9 +561,9 @@ static int split_string(char *buf, char **a, char **b, char **c, char **d)
>         return 0;
>  }
>
> -static int match_bus_dev(struct device *dev, void *data)
> +static int match_bus_dev(struct device *dev, const void *data)
>  {
> -       char *mdev_name = data;
> +       const char *mdev_name = data;
>
>         return !strcmp(dev_name(dev), mdev_name);
>  }
> diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
> index c1b0165..c9a7e4a 100644
> --- a/drivers/thunderbolt/switch.c
> +++ b/drivers/thunderbolt/switch.c
> @@ -1946,10 +1946,10 @@ struct tb_sw_lookup {
>         u64 route;
>  };
>
> -static int tb_switch_match(struct device *dev, void *data)
> +static int tb_switch_match(struct device *dev, const void *data)
>  {
>         struct tb_switch *sw = tb_to_switch(dev);
> -       struct tb_sw_lookup *lookup = data;
> +       const struct tb_sw_lookup *lookup = data;
>
>         if (!sw)
>                 return 0;
> diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
> index fa783531..7bd7de7 100644
> --- a/drivers/usb/core/devio.c
> +++ b/drivers/usb/core/devio.c
> @@ -947,9 +947,9 @@ static int parse_usbdevfs_streams(struct usb_dev_state *ps,
>         return ret;
>  }
>
> -static int match_devt(struct device *dev, void *data)
> +static int match_devt(struct device *dev, const void *data)
>  {
> -       return dev->devt == (dev_t) (unsigned long) data;
> +       return dev->devt == (dev_t)(unsigned long)(void *)data;
>  }
>
>  static struct usb_device *usbdev_lookup_by_devt(dev_t devt)
> diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
> index 7fcb9f7..1678e30 100644
> --- a/drivers/usb/core/usb.c
> +++ b/drivers/usb/core/usb.c
> @@ -325,9 +325,9 @@ struct find_interface_arg {
>         struct device_driver *drv;
>  };
>
> -static int __find_interface(struct device *dev, void *data)
> +static int __find_interface(struct device *dev, const void *data)
>  {
> -       struct find_interface_arg *arg = data;
> +       const struct find_interface_arg *arg = data;
>         struct usb_interface *intf;
>
>         if (!is_usb_interface(dev))
> diff --git a/drivers/usb/phy/phy-am335x-control.c b/drivers/usb/phy/phy-am335x-control.c
> index a3cb25c..d16dfc3 100644
> --- a/drivers/usb/phy/phy-am335x-control.c
> +++ b/drivers/usb/phy/phy-am335x-control.c
> @@ -118,9 +118,9 @@ static const struct of_device_id omap_control_usb_id_table[] = {
>  MODULE_DEVICE_TABLE(of, omap_control_usb_id_table);
>
>  static struct platform_driver am335x_control_driver;
> -static int match(struct device *dev, void *data)
> +static int match(struct device *dev, const void *data)
>  {
> -       struct device_node *node = (struct device_node *)data;
> +       const struct device_node *node = (const struct device_node *)data;
>         return dev->of_node == node &&
>                 dev->driver == &am335x_control_driver.driver;
>  }
> diff --git a/drivers/usb/phy/phy-isp1301.c b/drivers/usb/phy/phy-isp1301.c
> index 93b7d6a..6cf6fbd 100644
> --- a/drivers/usb/phy/phy-isp1301.c
> +++ b/drivers/usb/phy/phy-isp1301.c
> @@ -142,9 +142,9 @@ static struct i2c_driver isp1301_driver = {
>
>  module_i2c_driver(isp1301_driver);
>
> -static int match(struct device *dev, void *data)
> +static int match(struct device *dev, const void *data)
>  {
> -       struct device_node *node = (struct device_node *)data;
> +       const struct device_node *node = (const struct device_node *)data;
>         return (dev->of_node == node) &&
>                 (dev->driver == &isp1301_driver.driver);
>  }
> diff --git a/drivers/visorbus/visorbus_main.c b/drivers/visorbus/visorbus_main.c
> index 0b2434c..152fd29 100644
> --- a/drivers/visorbus/visorbus_main.c
> +++ b/drivers/visorbus/visorbus_main.c
> @@ -171,10 +171,10 @@ struct visor_busdev {
>         u32 dev_no;
>  };
>
> -static int match_visorbus_dev_by_id(struct device *dev, void *data)
> +static int match_visorbus_dev_by_id(struct device *dev, const void *data)
>  {
>         struct visor_device *vdev = to_visor_device(dev);
> -       struct visor_busdev *id = data;
> +       const struct visor_busdev *id = data;
>
>         if (vdev->chipset_bus_no == id->bus_no &&
>             vdev->chipset_dev_no == id->dev_no)
> diff --git a/include/linux/device.h b/include/linux/device.h
> index e85264f..cbbdcadc 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -166,8 +166,8 @@ void subsys_dev_iter_exit(struct subsys_dev_iter *iter);
>  int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
>                      int (*fn)(struct device *dev, void *data));
>  struct device *bus_find_device(struct bus_type *bus, struct device *start,
> -                              void *data,
> -                              int (*match)(struct device *dev, void *data));
> +                              const void *data,
> +                              int (*match)(struct device *dev, const void *data));
>  struct device *bus_find_device_by_name(struct bus_type *bus,
>                                        struct device *start,
>                                        const char *name);
> diff --git a/sound/soc/rockchip/rk3399_gru_sound.c b/sound/soc/rockchip/rk3399_gru_sound.c
> index 3d0cc6e..c04c9ed 100644
> --- a/sound/soc/rockchip/rk3399_gru_sound.c
> +++ b/sound/soc/rockchip/rk3399_gru_sound.c
> @@ -405,7 +405,7 @@ static const struct dailink_match_data dailink_match[] = {
>         },
>  };
>
> -static int of_dev_node_match(struct device *dev, void *data)
> +static int of_dev_node_match(struct device *dev, const void *data)
>  {
>         return dev->of_node == data;
>  }
> --
> 2.7.4
>

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

* Re: [PATCH 02/13] bus_find_device: Unify the match callback with class_find_device
  2019-06-05 15:13 ` [PATCH 02/13] bus_find_device: Unify the match callback with class_find_device Suzuki K Poulose
                     ` (3 preceding siblings ...)
  2019-06-06  8:56   ` Rafael J. Wysocki
@ 2019-06-06  9:01   ` Srinivas Kandagatla
  4 siblings, 0 replies; 39+ messages in thread
From: Srinivas Kandagatla @ 2019-06-06  9:01 UTC (permalink / raw)
  To: Suzuki K Poulose, linux-kernel
  Cc: gregkh, rafael, Alexander Shishkin, Andrew Lunn, Andreas Noever,
	Arnd Bergmann, Bjorn Helgaas, Corey Minyard,
	Christian Borntraeger, David Kershner, David S. Miller,
	David Airlie, Felipe Balbi, Frank Rowand, Grygorii Strashko,
	Harald Freudenberger, Hartmut Knaack, Heiko Stuebner,
	Jason Gunthorpe, Jonathan Cameron, James E.J. Bottomley,
	Len Brown, Mark Brown, Michael Ellerman, Michael Jamet,
	Martin K. Petersen, Peter Oberparleiter, Rob Herring,
	Sebastian Ott, Yehezkel Bernat, Wolfram Sang



On 05/06/2019 16:13, Suzuki K Poulose wrote:
> There is an arbitrary difference between the prototypes of
> bus_find_device() and class_find_device() preventing their callers
> from passing the same pair of data and match() arguments to both of
> them, which is the const qualifier used in the prototype of
> class_find_device().  If that qualifier is also used in the
> bus_find_device() prototype, it will be possible to pass the same
> match() callback function to both bus_find_device() and
> class_find_device(), which will allow some optimizations to be made in
> order to avoid code duplication going forward.  Also with that, constify
> the "data" parameter as it is passed as a const to the match function.
> 
> For this reason, change the prototype of bus_find_device() to match
> the prototype of class_find_device() and adjust its callers to use the
> const qualifier in accordance with the new prototype of it.
> 
> Cc: Alexander Shishkin<alexander.shishkin@linux.intel.com>
> Cc: Andrew Lunn<andrew@lunn.ch>
> Cc: Andreas Noever<andreas.noever@gmail.com>
> Cc: Arnd Bergmann<arnd@arndb.de>
> Cc: Bjorn Helgaas<bhelgaas@google.com>
> Cc: Corey Minyard<minyard@acm.org>
> Cc: Christian Borntraeger<borntraeger@de.ibm.com>
> Cc: David Kershner<david.kershner@unisys.com>
> Cc: "David S. Miller"<davem@davemloft.net>
> Cc: David Airlie<airlied@linux.ie>
> Cc: Felipe Balbi<balbi@kernel.org>
> Cc: Frank Rowand<frowand.list@gmail.com>
> Cc: Grygorii Strashko<grygorii.strashko@ti.com>
> Cc: Harald Freudenberger<freude@linux.ibm.com>
> Cc: Hartmut Knaack<knaack.h@gmx.de>
> Cc: Heiko Stuebner<heiko@sntech.de>
> Cc: Jason Gunthorpe<jgg@ziepe.ca>
> Cc: Jonathan Cameron<jic23@kernel.org>
> Cc: Jonathan Cameron<jic23@kernel.org>
> Cc: "James E.J. Bottomley"<jejb@linux.ibm.com>
> Cc: Len Brown<lenb@kernel.org>
> Cc: Mark Brown<broonie@kernel.org>
> Cc: Michael Ellerman<mpe@ellerman.id.au>
> Cc: Michael Jamet<michael.jamet@intel.com>
> Cc: "Martin K. Petersen"<martin.petersen@oracle.com>
> Cc: Peter Oberparleiter<oberpar@linux.ibm.com>
> Cc: Rob Herring<robh+dt@kernel.org>
> Cc: Sebastian Ott<sebott@linux.ibm.com>
> Cc: Srinivas Kandagatla<srinivas.kandagatla@linaro.org>
> Cc: Yehezkel Bernat<YehezkelShB@gmail.com>
> Cc: Wolfram Sang<wsa@the-dreams.de>
> Cc:rafael@kernel.org
> Cc: Greg Kroah-Hartman<gregkh@linuxfoundation.org>
> Signed-off-by: Suzuki K Poulose<suzuki.poulose@arm.com>
> ---
>   arch/powerpc/platforms/pseries/ibmebus.c           | 4 ++--
>   drivers/acpi/acpi_lpss.c                           | 4 ++--
>   drivers/acpi/sleep.c                               | 2 +-
>   drivers/acpi/utils.c                               | 4 ++--
>   drivers/base/bus.c                                 | 6 +++---
>   drivers/base/devcon.c                              | 2 +-
>   drivers/char/ipmi/ipmi_si_platform.c               | 2 +-
>   drivers/firmware/efi/dev-path-parser.c             | 4 ++--
>   drivers/gpu/drm/drm_mipi_dsi.c                     | 2 +-
>   drivers/hwtracing/coresight/coresight.c            | 6 +++---
>   drivers/hwtracing/coresight/of_coresight.c         | 2 +-
>   drivers/hwtracing/intel_th/core.c                  | 5 ++---
>   drivers/i2c/i2c-core-acpi.c                        | 4 ++--
>   drivers/i2c/i2c-core-of.c                          | 4 ++--
>   drivers/iio/inkern.c                               | 2 +-
>   drivers/infiniband/hw/hns/hns_roce_hw_v1.c         | 2 +-
>   drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c | 2 +-
>   drivers/net/ethernet/ti/cpsw-phy-sel.c             | 4 ++--
>   drivers/net/ethernet/ti/davinci_emac.c             | 2 +-
>   drivers/net/ethernet/toshiba/tc35815.c             | 4 ++--
>   drivers/nvmem/core.c                               | 2 +-


For NVMEM changes,

Acked-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>


--srini

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

* Re: [PATCH 01/13] acpi: utils: Cleanup acpi_dev_match_cb
  2019-06-05 15:13 ` [PATCH 01/13] acpi: utils: Cleanup acpi_dev_match_cb Suzuki K Poulose
@ 2019-06-06  9:14   ` Rafael J. Wysocki
  2019-06-06  9:21     ` Suzuki K Poulose
  0 siblings, 1 reply; 39+ messages in thread
From: Rafael J. Wysocki @ 2019-06-06  9:14 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: Linux Kernel Mailing List, Greg Kroah-Hartman, Rafael J. Wysocki,
	Rafael J. Wysocki, Len Brown, ACPI Devel Maling List

On Wed, Jun 5, 2019 at 5:14 PM Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
>
> acpi_dev_match_cb match function modifies the "data" argument
> to pass on a result which could be easily deduced from the result
> of the bus_find_device() call at the caller site. Clean this
> up in preparation to convert the "match" argument for bus_find_device
> to accept a "const" data pointer, similar to class_find_device. This
> would allow consolidating the match routines for these two APIs.

This changelog can be improved IMO.

In fact, the final goal here is to pass (const void *) as the second
argument to acpi_dev_match_cb() (which you could do right away in this
patch if I'm not mistaken) which is because you want to modify the
prototype of bus_find_device().

So why don't you write something like this in the changelog:

"The prototype of bus_find_device() will be unified with that of
class_find_device() subsequently, but for this purpose the callback
functions passed to it need to take (const void *) as the second
argument.  Consequently, they cannot modify the memory pointed to by
that argument which currently is not the case for acpi_dev_match_cb().
However, acpi_dev_match_cb() really need not modify the "match" object
passed to it, because acpi_dev_get_first_match_dev() which uses it via
bus_find_device() can easily convert the result of bus_find_device()
into the pointer to return.

For this reason, update acpi_dev_match_cb() to avoid the redundant
memory updates and change the type of its second argument to (const
void *)."

>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Len Brown <lenb@kernel.org>
> Cc: linux-acpi@vger.kernel.org
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> ---
>  drivers/acpi/utils.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
>
> diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
> index 7def63a..1391b63 100644
> --- a/drivers/acpi/utils.c
> +++ b/drivers/acpi/utils.c
> @@ -725,8 +725,6 @@ bool acpi_dev_found(const char *hid)
>  EXPORT_SYMBOL(acpi_dev_found);
>
>  struct acpi_dev_match_info {
> -       const char *dev_name;
> -       struct acpi_device *adev;
>         struct acpi_device_id hid[2];
>         const char *uid;
>         s64 hrv;
> @@ -746,9 +744,6 @@ static int acpi_dev_match_cb(struct device *dev, void *data)

And why not to change the type of the second arg to "const void *data" here?

>             strcmp(adev->pnp.unique_id, match->uid)))
>                 return 0;
>
> -       match->dev_name = acpi_dev_name(adev);
> -       match->adev = adev;
> -
>         if (match->hrv == -1)
>                 return 1;
>
> @@ -818,7 +813,7 @@ acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv)
>         match.hrv = hrv;
>
>         dev = bus_find_device(&acpi_bus_type, NULL, &match, acpi_dev_match_cb);
> -       return dev ? match.adev : NULL;
> +       return dev ? to_acpi_device(dev) : NULL;
>  }
>  EXPORT_SYMBOL(acpi_dev_get_first_match_dev);
>
> --

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

* Re: [PATCH 07/13] drivers: Add generic match helper by ACPI_COMPANION device
  2019-06-05 15:13 ` [PATCH 07/13] drivers: Add generic match helper by ACPI_COMPANION device Suzuki K Poulose
@ 2019-06-06  9:17   ` Rafael J. Wysocki
  2019-06-06  9:28     ` Suzuki K Poulose
  0 siblings, 1 reply; 39+ messages in thread
From: Rafael J. Wysocki @ 2019-06-06  9:17 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: Linux Kernel Mailing List, Greg Kroah-Hartman, Rafael J. Wysocki,
	Len Brown, ACPI Devel Maling List, linux-spi, Mark Brown

On Wed, Jun 5, 2019 at 5:14 PM Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
>
> Add a generic helper to match a device by the acpi device.

"by its ACPI companion device object", please.

Also, it would be good to combine this patch with the patch(es) that
cause device_match_acpi_dev() to be actually used.

Helpers without any users are arguably not useful.

>
> Cc: Len Brown <lenb@kernel.org>
> Cc: linux-acpi@vger.kernel.org
> Cc: linux-spi@vger.kernel.org
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> ---
>  drivers/base/core.c    | 6 ++++++
>  include/linux/device.h | 1 +
>  2 files changed, 7 insertions(+)
>
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index b827ca1..597095b 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -3346,3 +3346,9 @@ int device_match_devt(struct device *dev, const void *pdevt)
>         return dev->devt == *(dev_t *)pdevt;
>  }
>  EXPORT_SYMBOL_GPL(device_match_devt);
> +
> +int device_match_acpi_dev(struct device *dev, const void *adev)
> +{
> +       return ACPI_COMPANION(dev) == adev;
> +}
> +EXPORT_SYMBOL(device_match_acpi_dev);
> diff --git a/include/linux/device.h b/include/linux/device.h
> index f315692..a03b50d 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -166,6 +166,7 @@ void subsys_dev_iter_exit(struct subsys_dev_iter *iter);
>  int device_match_of_node(struct device *dev, const void *np);
>  int device_match_fwnode(struct device *dev, const void *fwnode);
>  int device_match_devt(struct device *dev, const void *pdevt);
> +int device_match_acpi_dev(struct device *dev, const void *adev);
>
>  int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
>                      int (*fn)(struct device *dev, void *data));
> --
> 2.7.4
>

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

* Re: [PATCH 01/13] acpi: utils: Cleanup acpi_dev_match_cb
  2019-06-06  9:14   ` Rafael J. Wysocki
@ 2019-06-06  9:21     ` Suzuki K Poulose
  0 siblings, 0 replies; 39+ messages in thread
From: Suzuki K Poulose @ 2019-06-06  9:21 UTC (permalink / raw)
  To: rafael; +Cc: linux-kernel, gregkh, rjw, lenb, linux-acpi

Hi Rafael,

On 06/06/2019 10:14, Rafael J. Wysocki wrote:
> On Wed, Jun 5, 2019 at 5:14 PM Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
>>
>> acpi_dev_match_cb match function modifies the "data" argument
>> to pass on a result which could be easily deduced from the result
>> of the bus_find_device() call at the caller site. Clean this
>> up in preparation to convert the "match" argument for bus_find_device
>> to accept a "const" data pointer, similar to class_find_device. This
>> would allow consolidating the match routines for these two APIs.
> 
> This changelog can be improved IMO.

I agree. Will update it.

> 
> In fact, the final goal here is to pass (const void *) as the second
> argument to acpi_dev_match_cb() (which you could do right away in this
> patch if I'm not mistaken) which is because you want to modify the
> prototype of bus_find_device().
> 
> So why don't you write something like this in the changelog:
> 
> "The prototype of bus_find_device() will be unified with that of
> class_find_device() subsequently, but for this purpose the callback
> functions passed to it need to take (const void *) as the second
> argument.  Consequently, they cannot modify the memory pointed to by
> that argument which currently is not the case for acpi_dev_match_cb().
> However, acpi_dev_match_cb() really need not modify the "match" object
> passed to it, because acpi_dev_get_first_match_dev() which uses it via
> bus_find_device() can easily convert the result of bus_find_device()
> into the pointer to return.

Sure.

> For this reason, update acpi_dev_match_cb() to avoid the redundant
> memory updates and change the type of its second argument to (const
> void *)."

We can't do that quite yet, until we unify the prototype of the
bus_find_device().

>>
>> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
>> Cc: Len Brown <lenb@kernel.org>
>> Cc: linux-acpi@vger.kernel.org
>> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
>> ---
>>   drivers/acpi/utils.c | 7 +------
>>   1 file changed, 1 insertion(+), 6 deletions(-)
>>
>> diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
>> index 7def63a..1391b63 100644
>> --- a/drivers/acpi/utils.c
>> +++ b/drivers/acpi/utils.c
>> @@ -725,8 +725,6 @@ bool acpi_dev_found(const char *hid)
>>   EXPORT_SYMBOL(acpi_dev_found);
>>
>>   struct acpi_dev_match_info {
>> -       const char *dev_name;
>> -       struct acpi_device *adev;
>>          struct acpi_device_id hid[2];
>>          const char *uid;
>>          s64 hrv;
>> @@ -746,9 +744,6 @@ static int acpi_dev_match_cb(struct device *dev, void *data)
> 
> And why not to change the type of the second arg to "const void *data" here?

Because, that would conflict with what bus_find_device() expects now. We make
the change only later. Since this change was a bit more intrusive than simply
changing the type of the parameter, I kept it as a preparatory patch.

Thanks for the review !

Suzuki

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

* Re: [PATCH 07/13] drivers: Add generic match helper by ACPI_COMPANION device
  2019-06-06  9:17   ` Rafael J. Wysocki
@ 2019-06-06  9:28     ` Suzuki K Poulose
  2019-06-06  9:57       ` Rafael J. Wysocki
  0 siblings, 1 reply; 39+ messages in thread
From: Suzuki K Poulose @ 2019-06-06  9:28 UTC (permalink / raw)
  To: rafael; +Cc: linux-kernel, gregkh, lenb, linux-acpi, linux-spi, broonie



On 06/06/2019 10:17, Rafael J. Wysocki wrote:
> On Wed, Jun 5, 2019 at 5:14 PM Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
>>
>> Add a generic helper to match a device by the acpi device.
> 
> "by its ACPI companion device object", please.

Sure.

> 
> Also, it would be good to combine this patch with the patch(es) that
> cause device_match_acpi_dev() to be actually used.
> 
> Helpers without any users are arguably not useful.

Sure, the helpers will be part of the part2 of the whole series,
which will actually have the individual subsystems consuming the
new helpers. For your reference, it is available here :

http://linux-arm.org/git?p=linux-skp.git;a=shortlog;h=refs/heads/driver-cleanup/v2

e.g: 
http://linux-arm.org/git?p=linux-skp.git;a=commit;h=59534e843e2f214f1f29659993f6e423bef16b28

I could simply pull those patches into this part, if you prefer that.
However, that would be true for the other patches in the part2.
I am open to suggestions, on how to split the series.

Cheers
Suzuki

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

* Re: [PATCH 07/13] drivers: Add generic match helper by ACPI_COMPANION device
  2019-06-06  9:28     ` Suzuki K Poulose
@ 2019-06-06  9:57       ` Rafael J. Wysocki
  2019-06-12  9:43         ` Suzuki K Poulose
  0 siblings, 1 reply; 39+ messages in thread
From: Rafael J. Wysocki @ 2019-06-06  9:57 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: Rafael J. Wysocki, Linux Kernel Mailing List, Greg Kroah-Hartman,
	Len Brown, ACPI Devel Maling List, linux-spi, Mark Brown

On Thu, Jun 6, 2019 at 11:28 AM Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
>
>
>
> On 06/06/2019 10:17, Rafael J. Wysocki wrote:
> > On Wed, Jun 5, 2019 at 5:14 PM Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
> >>
> >> Add a generic helper to match a device by the acpi device.
> >
> > "by its ACPI companion device object", please.
>
> Sure.
>
> >
> > Also, it would be good to combine this patch with the patch(es) that
> > cause device_match_acpi_dev() to be actually used.
> >
> > Helpers without any users are arguably not useful.
>
> Sure, the helpers will be part of the part2 of the whole series,
> which will actually have the individual subsystems consuming the
> new helpers. For your reference, it is available here :
>
> http://linux-arm.org/git?p=linux-skp.git;a=shortlog;h=refs/heads/driver-cleanup/v2
>
> e.g:
> http://linux-arm.org/git?p=linux-skp.git;a=commit;h=59534e843e2f214f1f29659993f6e423bef16b28
>
> I could simply pull those patches into this part, if you prefer that.

Not really.

I'd rather do it the other way around: push the introduction of the
helpers to part 2.

> However, that would be true for the other patches in the part2.
> I am open to suggestions, on how to split the series.

You can introduce each helper along with its users in one patch.

This way the total number of patches will be reduced and they will be
easier to review IMO.

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

* Re: [PATCH 03/13] driver_find_device: Unify the match function with class_find_device()
  2019-06-05 15:13 ` [PATCH 03/13] driver_find_device: Unify the match function with class_find_device() Suzuki K Poulose
@ 2019-06-12  9:32   ` Lee Jones
  2019-06-12  9:36     ` Suzuki K Poulose
  0 siblings, 1 reply; 39+ messages in thread
From: Lee Jones @ 2019-06-12  9:32 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: linux-kernel, gregkh, rafael, Corey Minyard, Russell King,
	Thierry Reding, Will Deacon, Joerg Roedel, Peter Oberparleiter,
	Sebastian Ott, David Airlie, Daniel Vetter, Nehal Shah,
	Shyam Sundar S K, Christian Borntraeger

On Wed, 05 Jun 2019, Suzuki K Poulose wrote:

> The driver_find_device() accepts a match function pointer to
> filter the devices for lookup, similar to bus/class_find_device().
> However, there is a minor difference in the prototype for the
> match parameter for driver_find_device() with the now unified
> version accepted by {bus/class}_find_device(), where it doesn't
> accept a "const" qualifier for the data argument. This prevents
> us from reusing the generic match functions for driver_find_device().
> 
> For this reason, change the prototype of the driver_find_device() to
> make the "match" parameter in line with {bus/class}_find_device()
> and adjust its callers to use the const qualifier. Also, we could
> now promote the "data" parameter to const as we pass it down
> as a const parameter to the match functions.
> 
> Cc: Corey Minyard <minyard@acm.org>
> Cc: Russell King <linux@armlinux.org.uk>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: Joerg Roedel <joro@8bytes.org>
> Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
> Cc: Sebastian Ott <sebott@linux.ibm.com>
> Cc: David Airlie <airlied@linux.ie>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: Nehal Shah <nehal-bakulchandra.shah@amd.com>
> Cc: Shyam Sundar S K <shyam-sundar.s-k@amd.com>
> Cc: Lee Jones <lee.jones@linaro.org>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> ---
>  drivers/amba/tegra-ahb.c             | 4 ++--
>  drivers/base/driver.c                | 4 ++--
>  drivers/char/ipmi/ipmi_msghandler.c  | 8 ++++----
>  drivers/gpu/drm/tegra/dc.c           | 4 ++--
>  drivers/i2c/busses/i2c-amd-mp2-pci.c | 2 +-
>  drivers/iommu/arm-smmu-v3.c          | 2 +-
>  drivers/iommu/arm-smmu.c             | 2 +-

>  drivers/mfd/altera-sysmgr.c          | 4 ++--
>  drivers/mfd/syscon.c                 | 2 +-

I'm okay with the changes.  How do you plan on managing the merge?

>  drivers/s390/cio/ccwgroup.c          | 2 +-
>  drivers/s390/cio/chsc_sch.c          | 2 +-
>  drivers/s390/cio/device.c            | 2 +-
>  include/linux/device.h               | 4 ++--
>  13 files changed, 21 insertions(+), 21 deletions(-)

[...]

> diff --git a/drivers/mfd/altera-sysmgr.c b/drivers/mfd/altera-sysmgr.c
> index 8976f82..2ee14d8 100644
> --- a/drivers/mfd/altera-sysmgr.c
> +++ b/drivers/mfd/altera-sysmgr.c
> @@ -92,9 +92,9 @@ static struct regmap_config altr_sysmgr_regmap_cfg = {
>   * Matching function used by driver_find_device().
>   * Return: True if match is found, otherwise false.
>   */
> -static int sysmgr_match_phandle(struct device *dev, void *data)
> +static int sysmgr_match_phandle(struct device *dev, const void *data)
>  {
> -	return dev->of_node == (struct device_node *)data;
> +	return dev->of_node == (const struct device_node *)data;
>  }
>  
>  /**
> diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
> index 8ce1e41..4f39ba5 100644
> --- a/drivers/mfd/syscon.c
> +++ b/drivers/mfd/syscon.c
> @@ -190,7 +190,7 @@ struct regmap *syscon_regmap_lookup_by_compatible(const char *s)
>  }
>  EXPORT_SYMBOL_GPL(syscon_regmap_lookup_by_compatible);
>  
> -static int syscon_match_pdevname(struct device *dev, void *data)
> +static int syscon_match_pdevname(struct device *dev, const void *data)
>  {
>  	return !strcmp(dev_name(dev), (const char *)data);
>  }

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH 03/13] driver_find_device: Unify the match function with class_find_device()
  2019-06-12  9:32   ` Lee Jones
@ 2019-06-12  9:36     ` Suzuki K Poulose
  0 siblings, 0 replies; 39+ messages in thread
From: Suzuki K Poulose @ 2019-06-12  9:36 UTC (permalink / raw)
  To: lee.jones
  Cc: linux-kernel, gregkh, rafael, minyard, linux, thierry.reding,
	will.deacon, joro, oberpar, sebott, airlied, daniel,
	nehal-bakulchandra.shah, shyam-sundar.s-k, borntraeger

Hi Lee,

On 12/06/2019 10:32, Lee Jones wrote:
> On Wed, 05 Jun 2019, Suzuki K Poulose wrote:
> 
>> The driver_find_device() accepts a match function pointer to
>> filter the devices for lookup, similar to bus/class_find_device().
>> However, there is a minor difference in the prototype for the
>> match parameter for driver_find_device() with the now unified
>> version accepted by {bus/class}_find_device(), where it doesn't
>> accept a "const" qualifier for the data argument. This prevents
>> us from reusing the generic match functions for driver_find_device().
>>
>> For this reason, change the prototype of the driver_find_device() to
>> make the "match" parameter in line with {bus/class}_find_device()
>> and adjust its callers to use the const qualifier. Also, we could
>> now promote the "data" parameter to const as we pass it down
>> as a const parameter to the match functions.
>>
>> Cc: Corey Minyard <minyard@acm.org>
>> Cc: Russell King <linux@armlinux.org.uk>
>> Cc: Thierry Reding <thierry.reding@gmail.com>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
>> Cc: Will Deacon <will.deacon@arm.com>
>> Cc: Joerg Roedel <joro@8bytes.org>
>> Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
>> Cc: Sebastian Ott <sebott@linux.ibm.com>
>> Cc: David Airlie <airlied@linux.ie>
>> Cc: Daniel Vetter <daniel@ffwll.ch>
>> Cc: Nehal Shah <nehal-bakulchandra.shah@amd.com>
>> Cc: Shyam Sundar S K <shyam-sundar.s-k@amd.com>
>> Cc: Lee Jones <lee.jones@linaro.org>
>> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
>> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>


>>   drivers/mfd/altera-sysmgr.c          | 4 ++--
>>   drivers/mfd/syscon.c                 | 2 +-
> 
> I'm okay with the changes.  How do you plan on managing the merge?

Thanks for looking the changes.

I assume, Greg can pull this once we have got the Acks.
Btw, would you mind providing the necessary tags here if you are OK with it ?


Cheers
Suzuki

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

* Re: [PATCH 07/13] drivers: Add generic match helper by ACPI_COMPANION device
  2019-06-06  9:57       ` Rafael J. Wysocki
@ 2019-06-12  9:43         ` Suzuki K Poulose
  2019-06-12 22:07           ` Rafael J. Wysocki
  0 siblings, 1 reply; 39+ messages in thread
From: Suzuki K Poulose @ 2019-06-12  9:43 UTC (permalink / raw)
  To: rafael; +Cc: linux-kernel, gregkh, lenb, linux-acpi, linux-spi, broonie

Hi Rafael,

On 06/06/2019 10:57, Rafael J. Wysocki wrote:
> On Thu, Jun 6, 2019 at 11:28 AM Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
>>
>>
>>
>> On 06/06/2019 10:17, Rafael J. Wysocki wrote:
>>> On Wed, Jun 5, 2019 at 5:14 PM Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
>>>>
>>>> Add a generic helper to match a device by the acpi device.
>>>
>>> "by its ACPI companion device object", please.
>>
>> Sure.
>>
>>>
>>> Also, it would be good to combine this patch with the patch(es) that
>>> cause device_match_acpi_dev() to be actually used.
>>>
>>> Helpers without any users are arguably not useful.
>>
>> Sure, the helpers will be part of the part2 of the whole series,
>> which will actually have the individual subsystems consuming the
>> new helpers. For your reference, it is available here :
>>
>> http://linux-arm.org/git?p=linux-skp.git;a=shortlog;h=refs/heads/driver-cleanup/v2
>>
>> e.g:
>> http://linux-arm.org/git?p=linux-skp.git;a=commit;h=59534e843e2f214f1f29659993f6e423bef16b28
>>
>> I could simply pull those patches into this part, if you prefer that.
> 
> Not really.
> 
> I'd rather do it the other way around: push the introduction of the
> helpers to part 2.

Sure, I will do that.

> 
>> However, that would be true for the other patches in the part2.
>> I am open to suggestions, on how to split the series.
> 
> You can introduce each helper along with its users in one patch.
> 
> This way the total number of patches will be reduced and they will be
> easier to review IMO.
> 

Wouldn't it make the merging complicated ? I am still not clear how we plan
to merge the part 2 ?

Cheers
Suzuki

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

* Re: [PATCH 07/13] drivers: Add generic match helper by ACPI_COMPANION device
  2019-06-12  9:43         ` Suzuki K Poulose
@ 2019-06-12 22:07           ` Rafael J. Wysocki
  0 siblings, 0 replies; 39+ messages in thread
From: Rafael J. Wysocki @ 2019-06-12 22:07 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: rafael, linux-kernel, gregkh, lenb, linux-acpi, linux-spi, broonie

On Wednesday, June 12, 2019 11:43:38 AM CEST Suzuki K Poulose wrote:
> Hi Rafael,
> 
> On 06/06/2019 10:57, Rafael J. Wysocki wrote:
> > On Thu, Jun 6, 2019 at 11:28 AM Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
> >>
> >>
> >>
> >> On 06/06/2019 10:17, Rafael J. Wysocki wrote:
> >>> On Wed, Jun 5, 2019 at 5:14 PM Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
> >>>>
> >>>> Add a generic helper to match a device by the acpi device.
> >>>
> >>> "by its ACPI companion device object", please.
> >>
> >> Sure.
> >>
> >>>
> >>> Also, it would be good to combine this patch with the patch(es) that
> >>> cause device_match_acpi_dev() to be actually used.
> >>>
> >>> Helpers without any users are arguably not useful.
> >>
> >> Sure, the helpers will be part of the part2 of the whole series,
> >> which will actually have the individual subsystems consuming the
> >> new helpers. For your reference, it is available here :
> >>
> >> http://linux-arm.org/git?p=linux-skp.git;a=shortlog;h=refs/heads/driver-cleanup/v2
> >>
> >> e.g:
> >> http://linux-arm.org/git?p=linux-skp.git;a=commit;h=59534e843e2f214f1f29659993f6e423bef16b28
> >>
> >> I could simply pull those patches into this part, if you prefer that.
> > 
> > Not really.
> > 
> > I'd rather do it the other way around: push the introduction of the
> > helpers to part 2.
> 
> Sure, I will do that.
> 
> > 
> >> However, that would be true for the other patches in the part2.
> >> I am open to suggestions, on how to split the series.
> > 
> > You can introduce each helper along with its users in one patch.
> > 
> > This way the total number of patches will be reduced and they will be
> > easier to review IMO.
> > 
> 
> Wouldn't it make the merging complicated ? I am still not clear how we plan
> to merge the part 2 ?

I wouldn't worry about it that much.  Without review, you have nothing to merge anyway.

Technically, every patch with a new helper and its users can go in via the Greg's tree
as long as it has been ACKed by the maintainers of the code touched by it.




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

end of thread, other threads:[~2019-06-13 17:12 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-05 15:13 [PATCH 00/13] drivers: Introduce generic device lookup helpers Suzuki K Poulose
2019-06-05 15:13 ` Suzuki K Poulose
2019-06-05 15:13 ` Suzuki K Poulose
2019-06-05 15:13 ` [PATCH 01/13] acpi: utils: Cleanup acpi_dev_match_cb Suzuki K Poulose
2019-06-06  9:14   ` Rafael J. Wysocki
2019-06-06  9:21     ` Suzuki K Poulose
2019-06-05 15:13 ` [PATCH 02/13] bus_find_device: Unify the match callback with class_find_device Suzuki K Poulose
2019-06-05 15:48   ` Corey Minyard
2019-06-05 15:51   ` Kershner, David A
2019-06-05 18:18   ` Mark Brown
2019-06-06  8:56   ` Rafael J. Wysocki
2019-06-06  9:01   ` Srinivas Kandagatla
2019-06-05 15:13 ` [PATCH 03/13] driver_find_device: Unify the match function with class_find_device() Suzuki K Poulose
2019-06-12  9:32   ` Lee Jones
2019-06-12  9:36     ` Suzuki K Poulose
2019-06-05 15:13 ` [PATCH 04/13] drivers: Add generic helper to match by of_node Suzuki K Poulose
2019-06-05 15:13   ` Suzuki K Poulose
2019-06-05 15:13   ` Suzuki K Poulose
2019-06-05 15:13 ` [PATCH 05/13] drivers: Add generic helper to match by fwnode Suzuki K Poulose
2019-06-05 15:13 ` [PATCH 06/13] drivers: Add generic helper to match by devt Suzuki K Poulose
2019-06-05 15:13 ` [PATCH 07/13] drivers: Add generic match helper by ACPI_COMPANION device Suzuki K Poulose
2019-06-06  9:17   ` Rafael J. Wysocki
2019-06-06  9:28     ` Suzuki K Poulose
2019-06-06  9:57       ` Rafael J. Wysocki
2019-06-12  9:43         ` Suzuki K Poulose
2019-06-12 22:07           ` Rafael J. Wysocki
2019-06-05 15:13 ` [PATCH 08/13] drivers: Add generic helper to match by name Suzuki K Poulose
2019-06-05 15:13   ` Suzuki K Poulose
2019-06-05 15:13 ` [PATCH 09/13] drivers: Add generic helper to match any device Suzuki K Poulose
2019-06-05 15:13 ` [PATCH 10/13] drivers: Introduce variants of class_find_device() Suzuki K Poulose
2019-06-05 15:13   ` Suzuki K Poulose
2019-06-05 16:14   ` Greg KH
2019-06-05 16:14     ` Greg KH
2019-06-05 18:13     ` Suzuki K Poulose
2019-06-05 15:13 ` [PATCH 11/13] drivers: Introduce variants for bus_find_device() Suzuki K Poulose
2019-06-05 15:13   ` Suzuki K Poulose
2019-06-05 15:13   ` Suzuki K Poulose
2019-06-05 15:13 ` [PATCH 12/13] drivers: Introduce variants of driver_find_device() Suzuki K Poulose
2019-06-05 15:13 ` [PATCH 13/13] platform: Add platform_find_device_by_driver() helper Suzuki K Poulose

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.