diff mbox series

[3/6] usb: dwc3: haps: Constify the software node

Message ID 20210202125032.64982-4-heikki.krogerus@linux.intel.com (mailing list archive)
State Superseded
Headers show
Series usb: Handle device properties with software node API | expand

Commit Message

Heikki Krogerus Feb. 2, 2021, 12:50 p.m. UTC
What platform_device_add_properties() does is it allocates
dynamically a software node that will contain the device
properties supplied to it, and then couples that node with
the device. Since that node is always created, it might as
well be constant.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
 drivers/usb/dwc3/dwc3-haps.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

kernel test robot Feb. 2, 2021, 4:45 p.m. UTC | #1
Hi Heikki,

I love your patch! Yet something to improve:

[auto build test ERROR on usb/usb-testing]
[also build test ERROR on next-20210125]
[cannot apply to balbi-usb/testing/next char-misc/char-misc-testing v5.11-rc6]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Heikki-Krogerus/usb-Handle-device-properties-with-software-node-API/20210202-205900
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: x86_64-randconfig-a006-20210202 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 275c6af7d7f1ed63a03d05b4484413e447133269)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # https://github.com/0day-ci/linux/commit/399031fcde9483395785bd0eec474c584bd1e9fd
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Heikki-Krogerus/usb-Handle-device-properties-with-software-node-API/20210202-205900
        git checkout 399031fcde9483395785bd0eec474c584bd1e9fd
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/usb/dwc3/dwc3-haps.c:84:50: error: passing 'const struct software_node' to parameter of incompatible type 'const struct software_node *'; take the address with &
           ret = device_add_software_node(&dwc->dwc3->dev, dwc3_haps_swnode);
                                                           ^~~~~~~~~~~~~~~~
                                                           &
   include/linux/property.h:491:78: note: passing argument to parameter 'swnode' here
   int device_add_software_node(struct device *dev, const struct software_node *swnode);
                                                                                ^
   1 error generated.


vim +84 drivers/usb/dwc3/dwc3-haps.c

    39	
    40	static int dwc3_haps_probe(struct pci_dev *pci,
    41				   const struct pci_device_id *id)
    42	{
    43		struct dwc3_haps	*dwc;
    44		struct device		*dev = &pci->dev;
    45		struct resource		res[2];
    46		int			ret;
    47	
    48		ret = pcim_enable_device(pci);
    49		if (ret) {
    50			dev_err(dev, "failed to enable pci device\n");
    51			return -ENODEV;
    52		}
    53	
    54		pci_set_master(pci);
    55	
    56		dwc = devm_kzalloc(dev, sizeof(*dwc), GFP_KERNEL);
    57		if (!dwc)
    58			return -ENOMEM;
    59	
    60		dwc->dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO);
    61		if (!dwc->dwc3)
    62			return -ENOMEM;
    63	
    64		memset(res, 0x00, sizeof(struct resource) * ARRAY_SIZE(res));
    65	
    66		res[0].start	= pci_resource_start(pci, 0);
    67		res[0].end	= pci_resource_end(pci, 0);
    68		res[0].name	= "dwc_usb3";
    69		res[0].flags	= IORESOURCE_MEM;
    70	
    71		res[1].start	= pci->irq;
    72		res[1].name	= "dwc_usb3";
    73		res[1].flags	= IORESOURCE_IRQ;
    74	
    75		ret = platform_device_add_resources(dwc->dwc3, res, ARRAY_SIZE(res));
    76		if (ret) {
    77			dev_err(dev, "couldn't add resources to dwc3 device\n");
    78			goto err;
    79		}
    80	
    81		dwc->pci = pci;
    82		dwc->dwc3->dev.parent = dev;
    83	
  > 84		ret = device_add_software_node(&dwc->dwc3->dev, dwc3_haps_swnode);
    85		if (ret)
    86			goto err;
    87	
    88		ret = platform_device_add(dwc->dwc3);
    89		if (ret) {
    90			dev_err(dev, "failed to register dwc3 device\n");
    91			goto err;
    92		}
    93	
    94		pci_set_drvdata(pci, dwc);
    95	
    96		return 0;
    97	err:
    98		device_remove_software_node(&dwc->dwc3->dev);
    99		platform_device_put(dwc->dwc3);
   100		return ret;
   101	}
   102	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
kernel test robot Feb. 2, 2021, 7:27 p.m. UTC | #2
Hi Heikki,

I love your patch! Yet something to improve:

[auto build test ERROR on usb/usb-testing]
[also build test ERROR on next-20210125]
[cannot apply to balbi-usb/testing/next char-misc/char-misc-testing v5.11-rc6]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Heikki-Krogerus/usb-Handle-device-properties-with-software-node-API/20210202-205900
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: x86_64-randconfig-c002-20210202 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/399031fcde9483395785bd0eec474c584bd1e9fd
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Heikki-Krogerus/usb-Handle-device-properties-with-software-node-API/20210202-205900
        git checkout 399031fcde9483395785bd0eec474c584bd1e9fd
        # save the attached .config to linux build tree
        make W=1 ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/usb/dwc3/dwc3-haps.c: In function 'dwc3_haps_probe':
>> drivers/usb/dwc3/dwc3-haps.c:84:50: error: incompatible type for argument 2 of 'device_add_software_node'
      84 |  ret = device_add_software_node(&dwc->dwc3->dev, dwc3_haps_swnode);
         |                                                  ^~~~~~~~~~~~~~~~
         |                                                  |
         |                                                  const struct software_node
   In file included from drivers/usb/dwc3/dwc3-haps.c:16:
   include/linux/property.h:491:78: note: expected 'const struct software_node *' but argument is of type 'const struct software_node'
     491 | int device_add_software_node(struct device *dev, const struct software_node *swnode);
         |                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~


vim +/device_add_software_node +84 drivers/usb/dwc3/dwc3-haps.c

    39	
    40	static int dwc3_haps_probe(struct pci_dev *pci,
    41				   const struct pci_device_id *id)
    42	{
    43		struct dwc3_haps	*dwc;
    44		struct device		*dev = &pci->dev;
    45		struct resource		res[2];
    46		int			ret;
    47	
    48		ret = pcim_enable_device(pci);
    49		if (ret) {
    50			dev_err(dev, "failed to enable pci device\n");
    51			return -ENODEV;
    52		}
    53	
    54		pci_set_master(pci);
    55	
    56		dwc = devm_kzalloc(dev, sizeof(*dwc), GFP_KERNEL);
    57		if (!dwc)
    58			return -ENOMEM;
    59	
    60		dwc->dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO);
    61		if (!dwc->dwc3)
    62			return -ENOMEM;
    63	
    64		memset(res, 0x00, sizeof(struct resource) * ARRAY_SIZE(res));
    65	
    66		res[0].start	= pci_resource_start(pci, 0);
    67		res[0].end	= pci_resource_end(pci, 0);
    68		res[0].name	= "dwc_usb3";
    69		res[0].flags	= IORESOURCE_MEM;
    70	
    71		res[1].start	= pci->irq;
    72		res[1].name	= "dwc_usb3";
    73		res[1].flags	= IORESOURCE_IRQ;
    74	
    75		ret = platform_device_add_resources(dwc->dwc3, res, ARRAY_SIZE(res));
    76		if (ret) {
    77			dev_err(dev, "couldn't add resources to dwc3 device\n");
    78			goto err;
    79		}
    80	
    81		dwc->pci = pci;
    82		dwc->dwc3->dev.parent = dev;
    83	
  > 84		ret = device_add_software_node(&dwc->dwc3->dev, dwc3_haps_swnode);
    85		if (ret)
    86			goto err;
    87	
    88		ret = platform_device_add(dwc->dwc3);
    89		if (ret) {
    90			dev_err(dev, "failed to register dwc3 device\n");
    91			goto err;
    92		}
    93	
    94		pci_set_drvdata(pci, dwc);
    95	
    96		return 0;
    97	err:
    98		device_remove_software_node(&dwc->dwc3->dev);
    99		platform_device_put(dwc->dwc3);
   100		return ret;
   101	}
   102	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/drivers/usb/dwc3/dwc3-haps.c b/drivers/usb/dwc3/dwc3-haps.c
index 55b4a901168e8..a0f046855a233 100644
--- a/drivers/usb/dwc3/dwc3-haps.c
+++ b/drivers/usb/dwc3/dwc3-haps.c
@@ -33,6 +33,10 @@  static const struct property_entry initial_properties[] = {
 	{ },
 };
 
+static const struct software_node dwc3_haps_swnode = {
+	.properties = initial_properties,
+};
+
 static int dwc3_haps_probe(struct pci_dev *pci,
 			   const struct pci_device_id *id)
 {
@@ -77,7 +81,7 @@  static int dwc3_haps_probe(struct pci_dev *pci,
 	dwc->pci = pci;
 	dwc->dwc3->dev.parent = dev;
 
-	ret = platform_device_add_properties(dwc->dwc3, initial_properties);
+	ret = device_add_software_node(&dwc->dwc3->dev, dwc3_haps_swnode);
 	if (ret)
 		goto err;
 
@@ -91,6 +95,7 @@  static int dwc3_haps_probe(struct pci_dev *pci,
 
 	return 0;
 err:
+	device_remove_software_node(&dwc->dwc3->dev);
 	platform_device_put(dwc->dwc3);
 	return ret;
 }
@@ -99,6 +104,7 @@  static void dwc3_haps_remove(struct pci_dev *pci)
 {
 	struct dwc3_haps *dwc = pci_get_drvdata(pci);
 
+	device_remove_software_node(&dwc->dwc3->dev);
 	platform_device_unregister(dwc->dwc3);
 }