mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-11 00:08:50 +00:00
platform/x86/intel/vsec: Add intel_vsec_register
Add and export intel_vsec_register() to allow the registration of Intel extended capabilities from other drivers. Add check to look for memory conflicts before registering a new capability. Since the vsec provider may not be a PCI device, add a parent field to intel_vsec_platform_info() to allow specifying the parent device for device managed cleanup. Signed-off-by: Gayatri Kammela <gayatri.kammela@linux.intel.com> Signed-off-by: David E. Box <david.e.box@linux.intel.com> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Link: https://lore.kernel.org/r/20231129222132.2331261-8-david.e.box@linux.intel.com Signed-off-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
6dfc2514ac
commit
4edbd117ba
@ -152,9 +152,15 @@ static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *he
|
||||
struct intel_vsec_device __free(kfree) *intel_vsec_dev = NULL;
|
||||
struct resource __free(kfree) *res = NULL;
|
||||
struct resource *tmp;
|
||||
struct device *parent;
|
||||
unsigned long quirks = info->quirks;
|
||||
int i;
|
||||
|
||||
if (info->parent)
|
||||
parent = info->parent;
|
||||
else
|
||||
parent = &pdev->dev;
|
||||
|
||||
if (!intel_vsec_supported(header->id, info->caps))
|
||||
return -EINVAL;
|
||||
|
||||
@ -189,6 +195,12 @@ static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *he
|
||||
header->offset + i * (header->entry_size * sizeof(u32));
|
||||
tmp->end = tmp->start + (header->entry_size * sizeof(u32)) - 1;
|
||||
tmp->flags = IORESOURCE_MEM;
|
||||
|
||||
/* Check resource is not in use */
|
||||
if (!request_mem_region(tmp->start, resource_size(tmp), ""))
|
||||
return -EBUSY;
|
||||
|
||||
release_mem_region(tmp->start, resource_size(tmp));
|
||||
}
|
||||
|
||||
intel_vsec_dev->pcidev = pdev;
|
||||
@ -205,7 +217,7 @@ static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *he
|
||||
* Pass the ownership of intel_vsec_dev and resource within it to
|
||||
* intel_vsec_add_aux()
|
||||
*/
|
||||
return intel_vsec_add_aux(pdev, &pdev->dev, no_free_ptr(intel_vsec_dev),
|
||||
return intel_vsec_add_aux(pdev, parent, no_free_ptr(intel_vsec_dev),
|
||||
intel_vsec_name(header->id));
|
||||
}
|
||||
|
||||
@ -323,6 +335,16 @@ static bool intel_vsec_walk_vsec(struct pci_dev *pdev,
|
||||
return have_devices;
|
||||
}
|
||||
|
||||
void intel_vsec_register(struct pci_dev *pdev,
|
||||
struct intel_vsec_platform_info *info)
|
||||
{
|
||||
if (!pdev || !info)
|
||||
return;
|
||||
|
||||
intel_vsec_walk_header(pdev, info);
|
||||
}
|
||||
EXPORT_SYMBOL_NS_GPL(intel_vsec_register, INTEL_VSEC);
|
||||
|
||||
static int intel_vsec_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
||||
{
|
||||
struct intel_vsec_platform_info *info;
|
||||
|
@ -69,6 +69,7 @@ enum intel_vsec_quirks {
|
||||
|
||||
/* Platform specific data */
|
||||
struct intel_vsec_platform_info {
|
||||
struct device *parent;
|
||||
struct intel_vsec_header **headers;
|
||||
unsigned long caps;
|
||||
unsigned long quirks;
|
||||
@ -99,4 +100,7 @@ static inline struct intel_vsec_device *auxdev_to_ivdev(struct auxiliary_device
|
||||
{
|
||||
return container_of(auxdev, struct intel_vsec_device, auxdev);
|
||||
}
|
||||
|
||||
void intel_vsec_register(struct pci_dev *pdev,
|
||||
struct intel_vsec_platform_info *info);
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user