forked from mirrors/linux
		
	usb: Use device_get_match_data()
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. Signed-off-by: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20231009211356.3242037-16-robh@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
		
							parent
							
								
									c19473d282
								
							
						
					
					
						commit
						14485de431
					
				
					 4 changed files with 15 additions and 34 deletions
				
			
		| 
						 | 
					@ -9,9 +9,9 @@
 | 
				
			||||||
#include <linux/dma-mapping.h>
 | 
					#include <linux/dma-mapping.h>
 | 
				
			||||||
#include <linux/module.h>
 | 
					#include <linux/module.h>
 | 
				
			||||||
#include <linux/of.h>
 | 
					#include <linux/of.h>
 | 
				
			||||||
#include <linux/of_platform.h>
 | 
					 | 
				
			||||||
#include <linux/phy/phy.h>
 | 
					#include <linux/phy/phy.h>
 | 
				
			||||||
#include <linux/platform_device.h>
 | 
					#include <linux/platform_device.h>
 | 
				
			||||||
 | 
					#include <linux/property.h>
 | 
				
			||||||
#include <linux/usb/chipidea.h>
 | 
					#include <linux/usb/chipidea.h>
 | 
				
			||||||
#include <linux/usb/hcd.h>
 | 
					#include <linux/usb/hcd.h>
 | 
				
			||||||
#include <linux/usb/ulpi.h>
 | 
					#include <linux/usb/ulpi.h>
 | 
				
			||||||
| 
						 | 
					@ -51,8 +51,8 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev)
 | 
				
			||||||
	struct device *dev = &pdev->dev;
 | 
						struct device *dev = &pdev->dev;
 | 
				
			||||||
	struct ci_hdrc_usb2_priv *priv;
 | 
						struct ci_hdrc_usb2_priv *priv;
 | 
				
			||||||
	struct ci_hdrc_platform_data *ci_pdata = dev_get_platdata(dev);
 | 
						struct ci_hdrc_platform_data *ci_pdata = dev_get_platdata(dev);
 | 
				
			||||||
 | 
						const struct ci_hdrc_platform_data *data;
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
	const struct of_device_id *match;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!ci_pdata) {
 | 
						if (!ci_pdata) {
 | 
				
			||||||
		ci_pdata = devm_kmalloc(dev, sizeof(*ci_pdata), GFP_KERNEL);
 | 
							ci_pdata = devm_kmalloc(dev, sizeof(*ci_pdata), GFP_KERNEL);
 | 
				
			||||||
| 
						 | 
					@ -61,11 +61,10 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev)
 | 
				
			||||||
		*ci_pdata = ci_default_pdata;	/* struct copy */
 | 
							*ci_pdata = ci_default_pdata;	/* struct copy */
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	match = of_match_device(ci_hdrc_usb2_of_match, &pdev->dev);
 | 
						data = device_get_match_data(&pdev->dev);
 | 
				
			||||||
	if (match && match->data) {
 | 
						if (data)
 | 
				
			||||||
		/* struct copy */
 | 
							/* struct copy */
 | 
				
			||||||
		*ci_pdata = *(struct ci_hdrc_platform_data *)match->data;
 | 
							*ci_pdata = *data;
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 | 
						priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 | 
				
			||||||
	if (!priv)
 | 
						if (!priv)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,7 +5,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <linux/kernel.h>
 | 
					#include <linux/kernel.h>
 | 
				
			||||||
#include <linux/module.h>
 | 
					#include <linux/module.h>
 | 
				
			||||||
#include <linux/of_device.h>
 | 
					#include <linux/of.h>
 | 
				
			||||||
#include <linux/usb/of.h>
 | 
					#include <linux/usb/of.h>
 | 
				
			||||||
#include <linux/pci_ids.h>
 | 
					#include <linux/pci_ids.h>
 | 
				
			||||||
#include <linux/pci.h>
 | 
					#include <linux/pci.h>
 | 
				
			||||||
| 
						 | 
					@ -968,26 +968,17 @@ typedef void (*set_params_cb)(struct dwc2_hsotg *data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int dwc2_init_params(struct dwc2_hsotg *hsotg)
 | 
					int dwc2_init_params(struct dwc2_hsotg *hsotg)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	const struct of_device_id *match;
 | 
					 | 
				
			||||||
	set_params_cb set_params;
 | 
						set_params_cb set_params;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	dwc2_set_default_params(hsotg);
 | 
						dwc2_set_default_params(hsotg);
 | 
				
			||||||
	dwc2_get_device_properties(hsotg);
 | 
						dwc2_get_device_properties(hsotg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	match = of_match_device(dwc2_of_match_table, hsotg->dev);
 | 
						set_params = device_get_match_data(hsotg->dev);
 | 
				
			||||||
	if (match && match->data) {
 | 
						if (set_params) {
 | 
				
			||||||
		set_params = match->data;
 | 
					 | 
				
			||||||
		set_params(hsotg);
 | 
							set_params(hsotg);
 | 
				
			||||||
	} else if (!match) {
 | 
						} else {
 | 
				
			||||||
		const struct acpi_device_id *amatch;
 | 
							const struct pci_device_id *pmatch =
 | 
				
			||||||
		const struct pci_device_id *pmatch = NULL;
 | 
								pci_match_id(dwc2_pci_ids, to_pci_dev(hsotg->dev->parent));
 | 
				
			||||||
 | 
					 | 
				
			||||||
		amatch = acpi_match_device(dwc2_acpi_match, hsotg->dev);
 | 
					 | 
				
			||||||
		if (amatch && amatch->driver_data) {
 | 
					 | 
				
			||||||
			set_params = (set_params_cb)amatch->driver_data;
 | 
					 | 
				
			||||||
			set_params(hsotg);
 | 
					 | 
				
			||||||
		} else if (!amatch)
 | 
					 | 
				
			||||||
			pmatch = pci_match_id(dwc2_pci_ids, to_pci_dev(hsotg->dev->parent));
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (pmatch && pmatch->driver_data) {
 | 
							if (pmatch && pmatch->driver_data) {
 | 
				
			||||||
			set_params = (set_params_cb)pmatch->driver_data;
 | 
								set_params = (set_params_cb)pmatch->driver_data;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -27,9 +27,10 @@
 | 
				
			||||||
#include <linux/interrupt.h>
 | 
					#include <linux/interrupt.h>
 | 
				
			||||||
#include <linux/io.h>
 | 
					#include <linux/io.h>
 | 
				
			||||||
#include <linux/moduleparam.h>
 | 
					#include <linux/moduleparam.h>
 | 
				
			||||||
 | 
					#include <linux/of.h>
 | 
				
			||||||
#include <linux/of_address.h>
 | 
					#include <linux/of_address.h>
 | 
				
			||||||
#include <linux/of_irq.h>
 | 
					#include <linux/of_irq.h>
 | 
				
			||||||
#include <linux/of_platform.h>
 | 
					#include <linux/platform_device.h>
 | 
				
			||||||
#include <linux/dma-mapping.h>
 | 
					#include <linux/dma-mapping.h>
 | 
				
			||||||
#include <linux/usb/ch9.h>
 | 
					#include <linux/usb/ch9.h>
 | 
				
			||||||
#include <linux/usb/gadget.h>
 | 
					#include <linux/usb/gadget.h>
 | 
				
			||||||
| 
						 | 
					@ -2471,17 +2472,12 @@ static const struct of_device_id qe_udc_match[];
 | 
				
			||||||
static int qe_udc_probe(struct platform_device *ofdev)
 | 
					static int qe_udc_probe(struct platform_device *ofdev)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct qe_udc *udc;
 | 
						struct qe_udc *udc;
 | 
				
			||||||
	const struct of_device_id *match;
 | 
					 | 
				
			||||||
	struct device_node *np = ofdev->dev.of_node;
 | 
						struct device_node *np = ofdev->dev.of_node;
 | 
				
			||||||
	struct qe_ep *ep;
 | 
						struct qe_ep *ep;
 | 
				
			||||||
	unsigned int ret = 0;
 | 
						unsigned int ret = 0;
 | 
				
			||||||
	unsigned int i;
 | 
						unsigned int i;
 | 
				
			||||||
	const void *prop;
 | 
						const void *prop;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	match = of_match_device(qe_udc_match, &ofdev->dev);
 | 
					 | 
				
			||||||
	if (!match)
 | 
					 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	prop = of_get_property(np, "mode", NULL);
 | 
						prop = of_get_property(np, "mode", NULL);
 | 
				
			||||||
	if (!prop || strcmp(prop, "peripheral"))
 | 
						if (!prop || strcmp(prop, "peripheral"))
 | 
				
			||||||
		return -ENODEV;
 | 
							return -ENODEV;
 | 
				
			||||||
| 
						 | 
					@ -2493,7 +2489,7 @@ static int qe_udc_probe(struct platform_device *ofdev)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	udc->soc_type = (unsigned long)match->data;
 | 
						udc->soc_type = (unsigned long)device_get_match_data(&ofdev->dev);
 | 
				
			||||||
	udc->usb_regs = of_iomap(np, 0);
 | 
						udc->usb_regs = of_iomap(np, 0);
 | 
				
			||||||
	if (!udc->usb_regs) {
 | 
						if (!udc->usb_regs) {
 | 
				
			||||||
		ret = -ENOMEM;
 | 
							ret = -ENOMEM;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -240,7 +240,6 @@ static void onboard_hub_attach_usb_driver(struct work_struct *work)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int onboard_hub_probe(struct platform_device *pdev)
 | 
					static int onboard_hub_probe(struct platform_device *pdev)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	const struct of_device_id *of_id;
 | 
					 | 
				
			||||||
	struct device *dev = &pdev->dev;
 | 
						struct device *dev = &pdev->dev;
 | 
				
			||||||
	struct onboard_hub *hub;
 | 
						struct onboard_hub *hub;
 | 
				
			||||||
	unsigned int i;
 | 
						unsigned int i;
 | 
				
			||||||
| 
						 | 
					@ -250,11 +249,7 @@ static int onboard_hub_probe(struct platform_device *pdev)
 | 
				
			||||||
	if (!hub)
 | 
						if (!hub)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	of_id = of_match_device(onboard_hub_match, &pdev->dev);
 | 
						hub->pdata = device_get_match_data(&pdev->dev);
 | 
				
			||||||
	if (!of_id)
 | 
					 | 
				
			||||||
		return -ENODEV;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	hub->pdata = of_id->data;
 | 
					 | 
				
			||||||
	if (!hub->pdata)
 | 
						if (!hub->pdata)
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue