提交 efc9812e 编写于 作者: H Heikki Krogerus 提交者: Greg Kroah-Hartman

usb: dwc3: haps: Constify the software node

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: NHeikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20210204141711.53775-4-heikki.krogerus@linux.intel.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 e81dee55
...@@ -33,6 +33,10 @@ static const struct property_entry initial_properties[] = { ...@@ -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, static int dwc3_haps_probe(struct pci_dev *pci,
const struct pci_device_id *id) const struct pci_device_id *id)
{ {
...@@ -77,7 +81,7 @@ static int dwc3_haps_probe(struct pci_dev *pci, ...@@ -77,7 +81,7 @@ static int dwc3_haps_probe(struct pci_dev *pci,
dwc->pci = pci; dwc->pci = pci;
dwc->dwc3->dev.parent = dev; 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) if (ret)
goto err; goto err;
...@@ -91,6 +95,7 @@ static int dwc3_haps_probe(struct pci_dev *pci, ...@@ -91,6 +95,7 @@ static int dwc3_haps_probe(struct pci_dev *pci,
return 0; return 0;
err: err:
device_remove_software_node(&dwc->dwc3->dev);
platform_device_put(dwc->dwc3); platform_device_put(dwc->dwc3);
return ret; return ret;
} }
...@@ -99,6 +104,7 @@ static void dwc3_haps_remove(struct pci_dev *pci) ...@@ -99,6 +104,7 @@ static void dwc3_haps_remove(struct pci_dev *pci)
{ {
struct dwc3_haps *dwc = pci_get_drvdata(pci); struct dwc3_haps *dwc = pci_get_drvdata(pci);
device_remove_software_node(&dwc->dwc3->dev);
platform_device_unregister(dwc->dwc3); platform_device_unregister(dwc->dwc3);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册