Commit 830fafce authored by Rob Herring's avatar Rob Herring Committed by Lee Jones
Browse files

mfd: Use device_get_match_data() in a bunch of drivers



Use preferred device_get_match_data() instead of of_match_device() to
get the driver match data. With this, adjust the includes to explicitly
include the correct headers.

Reviewed-by: default avatarChen-Yu Tsai <wens@csie.org>
Signed-off-by: default avatarRob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20231017203612.2701060-1-robh@kernel.org


Signed-off-by: default avatarLee Jones <lee@kernel.org>
parent 15d71e67
Loading
Loading
Loading
Loading
+3 −19
Original line number Diff line number Diff line
@@ -22,7 +22,8 @@
#include <linux/mfd/axp20x.h>
#include <linux/mfd/core.h>
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/of.h>
#include <linux/property.h>
#include <linux/reboot.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
@@ -1131,27 +1132,10 @@ static int axp20x_power_off(struct sys_off_data *data)
int axp20x_match_device(struct axp20x_dev *axp20x)
{
	struct device *dev = axp20x->dev;
	const struct acpi_device_id *acpi_id;
	const struct of_device_id *of_id;
	const struct mfd_cell *cells_no_irq = NULL;
	int nr_cells_no_irq = 0;

	if (dev->of_node) {
		of_id = of_match_device(dev->driver->of_match_table, dev);
		if (!of_id) {
			dev_err(dev, "Unable to match OF ID\n");
			return -ENODEV;
		}
		axp20x->variant = (long)of_id->data;
	} else {
		acpi_id = acpi_match_device(dev->driver->acpi_match_table, dev);
		if (!acpi_id || !acpi_id->driver_data) {
			dev_err(dev, "Unable to match ACPI ID and data\n");
			return -ENODEV;
		}
		axp20x->variant = (long)acpi_id->driver_data;
	}

	axp20x->variant = (long)device_get_match_data(dev);
	switch (axp20x->variant) {
	case AXP152_ID:
		axp20x->nr_cells = ARRAY_SIZE(axp152_cells);
+3 −6
Original line number Diff line number Diff line
@@ -15,8 +15,9 @@
#include <linux/mfd/core.h>
#include <linux/mfd/hi6421-pmic.h>
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/property.h>
#include <linux/regmap.h>

static const struct mfd_cell hi6421_devs[] = {
@@ -50,16 +51,12 @@ MODULE_DEVICE_TABLE(of, of_hi6421_pmic_match);
static int hi6421_pmic_probe(struct platform_device *pdev)
{
	struct hi6421_pmic *pmic;
	const struct of_device_id *id;
	const struct mfd_cell *subdevs;
	enum hi6421_type type;
	void __iomem *base;
	int n_subdevs, ret;

	id = of_match_device(of_hi6421_pmic_match, &pdev->dev);
	if (!id)
		return -EINVAL;
	type = (uintptr_t)id->data;
	type = (uintptr_t)device_get_match_data(&pdev->dev);

	pmic = devm_kzalloc(&pdev->dev, sizeof(*pmic), GFP_KERNEL);
	if (!pmic)
+2 −7
Original line number Diff line number Diff line
@@ -16,8 +16,8 @@
#include <linux/mfd/mxs-lradc.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/property.h>
#include <linux/slab.h>

#define ADC_CELL		0
@@ -125,7 +125,6 @@ MODULE_DEVICE_TABLE(of, mxs_lradc_dt_ids);

static int mxs_lradc_probe(struct platform_device *pdev)
{
	const struct of_device_id *of_id;
	struct device *dev = &pdev->dev;
	struct device_node *node = dev->of_node;
	struct mxs_lradc *lradc;
@@ -138,11 +137,7 @@ static int mxs_lradc_probe(struct platform_device *pdev)
	if (!lradc)
		return -ENOMEM;

	of_id = of_match_device(mxs_lradc_dt_ids, &pdev->dev);
	if (!of_id)
		return -EINVAL;

	lradc->soc = (uintptr_t)of_id->data;
	lradc->soc = (enum mxs_lradc_id)device_get_match_data(&pdev->dev);

	lradc->clk = devm_clk_get(&pdev->dev, NULL);
	if (IS_ERR(lradc->clk)) {
+4 −2
Original line number Diff line number Diff line
@@ -8,10 +8,12 @@
#include <linux/gfp.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/of_platform.h>
#include <linux/spmi.h>
#include <linux/types.h>
#include <linux/regmap.h>
#include <linux/of_platform.h>
#include <soc/qcom/qcom-spmi-pmic.h>

#define PMIC_REV2		0x101
@@ -264,7 +266,7 @@ static int pmic_spmi_probe(struct spmi_device *sdev)
	if (!ctx)
		return -ENOMEM;

	ctx->num_usids = (uintptr_t)of_device_get_match_data(&sdev->dev);
	ctx->num_usids = (uintptr_t)device_get_match_data(&sdev->dev);

	/* Only the first slave id for a PMIC contains this information */
	if (sdev->usid % ctx->num_usids == 0) {
+4 −4
Original line number Diff line number Diff line
@@ -7,6 +7,8 @@

#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/property.h>
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/io.h>
#include <linux/interrupt.h>
@@ -528,7 +530,6 @@ static irqreturn_t qcom_rpm_wakeup_interrupt(int irq, void *dev)

static int qcom_rpm_probe(struct platform_device *pdev)
{
	const struct of_device_id *match;
	struct device_node *syscon_np;
	struct qcom_rpm *rpm;
	u32 fw_version[3];
@@ -570,10 +571,9 @@ static int qcom_rpm_probe(struct platform_device *pdev)
	if (irq_wakeup < 0)
		return irq_wakeup;

	match = of_match_device(qcom_rpm_of_match, &pdev->dev);
	if (!match)
	rpm->data = device_get_match_data(&pdev->dev);
	if (!rpm->data)
		return -ENODEV;
	rpm->data = match->data;

	rpm->status_regs = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
	if (IS_ERR(rpm->status_regs))
Loading