Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: usb251xb: Use of_device_get_match_data()

Use the more modern API here instead of using of_match_device() and
avoid casting away const from the returned pointer by pushing the const
type through to the users. This nicely avoids referencing the match
table when it is undefined with configurations where CONFIG_OF=n and
avoids const issues.

Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Richard Leitner <richard.leitner@skidata.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: <linux-usb@vger.kernel.org>
Signed-off-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20210123034428.2841052-5-swboyd@chromium.org

authored by

Stephen Boyd and committed by
Rob Herring
9243eadc d825f0be

+5 -7
+5 -7
drivers/usb/misc/usb251xb.c
··· 396 396 } 397 397 398 398 static int usb251xb_get_ofdata(struct usb251xb *hub, 399 - struct usb251xb_data *data) 399 + const struct usb251xb_data *data) 400 400 { 401 401 struct device *dev = hub->dev; 402 402 struct device_node *np = dev->of_node; ··· 630 630 MODULE_DEVICE_TABLE(of, usb251xb_of_match); 631 631 #else /* CONFIG_OF */ 632 632 static int usb251xb_get_ofdata(struct usb251xb *hub, 633 - struct usb251xb_data *data) 633 + const struct usb251xb_data *data) 634 634 { 635 635 return 0; 636 636 } ··· 647 647 { 648 648 struct device *dev = hub->dev; 649 649 struct device_node *np = dev->of_node; 650 - const struct of_device_id *of_id = of_match_device(usb251xb_of_match, 651 - dev); 650 + const struct usb251xb_data *usb_data = of_device_get_match_data(dev); 652 651 int err; 653 652 654 - if (np && of_id) { 655 - err = usb251xb_get_ofdata(hub, 656 - (struct usb251xb_data *)of_id->data); 653 + if (np && usb_data) { 654 + err = usb251xb_get_ofdata(hub, usb_data); 657 655 if (err) { 658 656 dev_err(dev, "failed to get ofdata: %d\n", err); 659 657 return err;