Skip to content

Commit 74e491e

Browse files
l1kdjbw
authored andcommitted
PCI/DOE: Make mailbox creation API private
The PCI core has just been amended to create a pci_doe_mb struct for every DOE instance on device enumeration. CXL (the only in-tree DOE user so far) has been migrated to use those mailboxes instead of creating its own. That leaves pcim_doe_create_mb() and pci_doe_for_each_off() without any callers, so drop them. pci_doe_supports_prot() is now only used internally, so declare it static. pci_doe_destroy_mb() is no longer used as callback for devm_add_action(), so refactor it to accept a struct pci_doe_mb pointer instead of a generic void pointer. Because pci_doe_create_mb() is only called on device enumeration, i.e. before driver binding, the workqueue name never contains a driver name. So replace dev_driver_string() with dev_bus_name() when generating the workqueue name. Tested-by: Ira Weiny <ira.weiny@intel.com> Signed-off-by: Lukas Wunner <lukas@wunner.de> Reviewed-by: Ming Li <ming4.li@intel.com> Reviewed-by: Ira Weiny <ira.weiny@intel.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Acked-by: Bjorn Helgaas <bhelgaas@google.com> Link: https://lore.kernel.org/r/64f614b6584982986c55d2c6229b4ee2b276dd59.1678543498.git.lukas@wunner.de Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent af0a6c3 commit 74e491e

3 files changed

Lines changed: 4 additions & 52 deletions

File tree

.clang-format

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,6 @@ ForEachMacros:
520520
- 'of_property_for_each_string'
521521
- 'of_property_for_each_u32'
522522
- 'pci_bus_for_each_resource'
523-
- 'pci_doe_for_each_off'
524523
- 'pcl_for_each_chunk'
525524
- 'pcl_for_each_segment'
526525
- 'pcm_for_each_format'

drivers/pci/doe.c

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ static struct pci_doe_mb *pci_doe_create_mb(struct pci_dev *pdev,
455455
xa_init(&doe_mb->prots);
456456

457457
doe_mb->work_queue = alloc_ordered_workqueue("%s %s DOE [%x]", 0,
458-
dev_driver_string(&pdev->dev),
458+
dev_bus_name(&pdev->dev),
459459
pci_name(pdev),
460460
doe_mb->cap_offset);
461461
if (!doe_mb->work_queue) {
@@ -499,50 +499,18 @@ static struct pci_doe_mb *pci_doe_create_mb(struct pci_dev *pdev,
499499
/**
500500
* pci_doe_destroy_mb() - Destroy a DOE mailbox object
501501
*
502-
* @ptr: Pointer to DOE mailbox
502+
* @doe_mb: DOE mailbox
503503
*
504504
* Destroy all internal data structures created for the DOE mailbox.
505505
*/
506-
static void pci_doe_destroy_mb(void *ptr)
506+
static void pci_doe_destroy_mb(struct pci_doe_mb *doe_mb)
507507
{
508-
struct pci_doe_mb *doe_mb = ptr;
509-
510508
pci_doe_cancel_tasks(doe_mb);
511509
xa_destroy(&doe_mb->prots);
512510
destroy_workqueue(doe_mb->work_queue);
513511
kfree(doe_mb);
514512
}
515513

516-
/**
517-
* pcim_doe_create_mb() - Create a DOE mailbox object
518-
*
519-
* @pdev: PCI device to create the DOE mailbox for
520-
* @cap_offset: Offset of the DOE mailbox
521-
*
522-
* Create a single mailbox object to manage the mailbox protocol at the
523-
* cap_offset specified. The mailbox will automatically be destroyed on
524-
* driver unbinding from @pdev.
525-
*
526-
* RETURNS: created mailbox object on success
527-
* ERR_PTR(-errno) on failure
528-
*/
529-
struct pci_doe_mb *pcim_doe_create_mb(struct pci_dev *pdev, u16 cap_offset)
530-
{
531-
struct pci_doe_mb *doe_mb;
532-
int rc;
533-
534-
doe_mb = pci_doe_create_mb(pdev, cap_offset);
535-
if (IS_ERR(doe_mb))
536-
return doe_mb;
537-
538-
rc = devm_add_action_or_reset(&pdev->dev, pci_doe_destroy_mb, doe_mb);
539-
if (rc)
540-
return ERR_PTR(rc);
541-
542-
return doe_mb;
543-
}
544-
EXPORT_SYMBOL_GPL(pcim_doe_create_mb);
545-
546514
/**
547515
* pci_doe_supports_prot() - Return if the DOE instance supports the given
548516
* protocol
@@ -552,7 +520,7 @@ EXPORT_SYMBOL_GPL(pcim_doe_create_mb);
552520
*
553521
* RETURNS: True if the DOE mailbox supports the protocol specified
554522
*/
555-
bool pci_doe_supports_prot(struct pci_doe_mb *doe_mb, u16 vid, u8 type)
523+
static bool pci_doe_supports_prot(struct pci_doe_mb *doe_mb, u16 vid, u8 type)
556524
{
557525
unsigned long index;
558526
void *entry;
@@ -567,7 +535,6 @@ bool pci_doe_supports_prot(struct pci_doe_mb *doe_mb, u16 vid, u8 type)
567535

568536
return false;
569537
}
570-
EXPORT_SYMBOL_GPL(pci_doe_supports_prot);
571538

572539
/**
573540
* pci_doe_submit_task() - Submit a task to be processed by the state machine

include/linux/pci-doe.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,6 @@
1515

1616
struct pci_doe_mb;
1717

18-
/**
19-
* pci_doe_for_each_off - Iterate each DOE capability
20-
* @pdev: struct pci_dev to iterate
21-
* @off: u16 of config space offset of each mailbox capability found
22-
*/
23-
#define pci_doe_for_each_off(pdev, off) \
24-
for (off = pci_find_next_ext_capability(pdev, off, \
25-
PCI_EXT_CAP_ID_DOE); \
26-
off > 0; \
27-
off = pci_find_next_ext_capability(pdev, off, \
28-
PCI_EXT_CAP_ID_DOE))
29-
30-
struct pci_doe_mb *pcim_doe_create_mb(struct pci_dev *pdev, u16 cap_offset);
31-
bool pci_doe_supports_prot(struct pci_doe_mb *doe_mb, u16 vid, u8 type);
3218
struct pci_doe_mb *pci_find_doe_mailbox(struct pci_dev *pdev, u16 vendor,
3319
u8 type);
3420

0 commit comments

Comments
 (0)