Skip to content

Commit e7b969c

Browse files
vlsunilPaul Walmsley
authored andcommitted
ACPI: RIMT: Fix unused function warnings when CONFIG_IOMMU_API is disabled
When CONFIG_IOMMU_API is disabled, some functions defined outside its conditional scope become unused, triggering compiler warnings reported by the kernel test robot. Move these function definitions inside the #ifdef CONFIG_IOMMU_API block to prevent unused function warnings when the configuration is disabled. Fixes: 8f77295 ("ACPI: RISC-V: Add support for RIMT") Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Signed-off-by: Sunil V L <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent ca525d5 commit e7b969c

File tree

1 file changed

+61
-61
lines changed

1 file changed

+61
-61
lines changed

drivers/acpi/riscv/rimt.c

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -61,30 +61,6 @@ static int rimt_set_fwnode(struct acpi_rimt_node *rimt_node,
6161
return 0;
6262
}
6363

64-
/**
65-
* rimt_get_fwnode() - Retrieve fwnode associated with an RIMT node
66-
*
67-
* @node: RIMT table node to be looked-up
68-
*
69-
* Returns: fwnode_handle pointer on success, NULL on failure
70-
*/
71-
static struct fwnode_handle *rimt_get_fwnode(struct acpi_rimt_node *node)
72-
{
73-
struct fwnode_handle *fwnode = NULL;
74-
struct rimt_fwnode *curr;
75-
76-
spin_lock(&rimt_fwnode_lock);
77-
list_for_each_entry(curr, &rimt_fwnode_list, list) {
78-
if (curr->rimt_node == node) {
79-
fwnode = curr->fwnode;
80-
break;
81-
}
82-
}
83-
spin_unlock(&rimt_fwnode_lock);
84-
85-
return fwnode;
86-
}
87-
8864
static acpi_status rimt_match_node_callback(struct acpi_rimt_node *node,
8965
void *context)
9066
{
@@ -202,6 +178,67 @@ static struct acpi_rimt_node *rimt_scan_node(enum acpi_rimt_node_type type,
202178
return NULL;
203179
}
204180

181+
/*
182+
* RISC-V supports IOMMU as a PCI device or a platform device.
183+
* When it is a platform device, there should be a namespace device as
184+
* well along with RIMT. To create the link between RIMT information and
185+
* the platform device, the IOMMU driver should register itself with the
186+
* RIMT module. This is true for PCI based IOMMU as well.
187+
*/
188+
int rimt_iommu_register(struct device *dev)
189+
{
190+
struct fwnode_handle *rimt_fwnode;
191+
struct acpi_rimt_node *node;
192+
193+
node = rimt_scan_node(ACPI_RIMT_NODE_TYPE_IOMMU, dev);
194+
if (!node) {
195+
pr_err("Could not find IOMMU node in RIMT\n");
196+
return -ENODEV;
197+
}
198+
199+
if (dev_is_pci(dev)) {
200+
rimt_fwnode = acpi_alloc_fwnode_static();
201+
if (!rimt_fwnode)
202+
return -ENOMEM;
203+
204+
rimt_fwnode->dev = dev;
205+
if (!dev->fwnode)
206+
dev->fwnode = rimt_fwnode;
207+
208+
rimt_set_fwnode(node, rimt_fwnode);
209+
} else {
210+
rimt_set_fwnode(node, dev->fwnode);
211+
}
212+
213+
return 0;
214+
}
215+
216+
#ifdef CONFIG_IOMMU_API
217+
218+
/**
219+
* rimt_get_fwnode() - Retrieve fwnode associated with an RIMT node
220+
*
221+
* @node: RIMT table node to be looked-up
222+
*
223+
* Returns: fwnode_handle pointer on success, NULL on failure
224+
*/
225+
static struct fwnode_handle *rimt_get_fwnode(struct acpi_rimt_node *node)
226+
{
227+
struct fwnode_handle *fwnode = NULL;
228+
struct rimt_fwnode *curr;
229+
230+
spin_lock(&rimt_fwnode_lock);
231+
list_for_each_entry(curr, &rimt_fwnode_list, list) {
232+
if (curr->rimt_node == node) {
233+
fwnode = curr->fwnode;
234+
break;
235+
}
236+
}
237+
spin_unlock(&rimt_fwnode_lock);
238+
239+
return fwnode;
240+
}
241+
205242
static bool rimt_pcie_rc_supports_ats(struct acpi_rimt_node *node)
206243
{
207244
struct acpi_rimt_pcie_rc *pci_rc;
@@ -290,43 +327,6 @@ static struct acpi_rimt_node *rimt_node_get_id(struct acpi_rimt_node *node,
290327
return NULL;
291328
}
292329

293-
/*
294-
* RISC-V supports IOMMU as a PCI device or a platform device.
295-
* When it is a platform device, there should be a namespace device as
296-
* well along with RIMT. To create the link between RIMT information and
297-
* the platform device, the IOMMU driver should register itself with the
298-
* RIMT module. This is true for PCI based IOMMU as well.
299-
*/
300-
int rimt_iommu_register(struct device *dev)
301-
{
302-
struct fwnode_handle *rimt_fwnode;
303-
struct acpi_rimt_node *node;
304-
305-
node = rimt_scan_node(ACPI_RIMT_NODE_TYPE_IOMMU, dev);
306-
if (!node) {
307-
pr_err("Could not find IOMMU node in RIMT\n");
308-
return -ENODEV;
309-
}
310-
311-
if (dev_is_pci(dev)) {
312-
rimt_fwnode = acpi_alloc_fwnode_static();
313-
if (!rimt_fwnode)
314-
return -ENOMEM;
315-
316-
rimt_fwnode->dev = dev;
317-
if (!dev->fwnode)
318-
dev->fwnode = rimt_fwnode;
319-
320-
rimt_set_fwnode(node, rimt_fwnode);
321-
} else {
322-
rimt_set_fwnode(node, dev->fwnode);
323-
}
324-
325-
return 0;
326-
}
327-
328-
#ifdef CONFIG_IOMMU_API
329-
330330
static struct acpi_rimt_node *rimt_node_map_id(struct acpi_rimt_node *node,
331331
u32 id_in, u32 *id_out,
332332
u8 type_mask)

0 commit comments

Comments
 (0)