Skip to content

Commit

Permalink
crypto: ccp - rename ccp driver initialize files as sp device
Browse files Browse the repository at this point in the history
CCP device initializes is now integerated into higher level SP device,
to avoid the confusion lets rename the ccp driver initialization files
(ccp-platform.c->sp-platform.c, ccp-pci.c->sp-pci.c). The patch does not
make any functional changes other than renaming file and structures

Signed-off-by: Brijesh Singh <[email protected]>
Acked-by: Gary R Hook <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
codomania authored and herbertx committed Jul 18, 2017
1 parent f4d18d6 commit d0ebbc0
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 93 deletions.
4 changes: 2 additions & 2 deletions drivers/crypto/ccp/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
obj-$(CONFIG_CRYPTO_DEV_CCP_DD) += ccp.o
ccp-objs := sp-dev.o ccp-platform.o
ccp-objs := sp-dev.o sp-platform.o
ccp-$(CONFIG_CRYPTO_DEV_SP_CCP) += ccp-dev.o \
ccp-ops.o \
ccp-dev-v3.o \
ccp-dev-v5.o \
ccp-dmaengine.o \
ccp-debugfs.o
ccp-$(CONFIG_PCI) += ccp-pci.o
ccp-$(CONFIG_PCI) += sp-pci.o

obj-$(CONFIG_CRYPTO_DEV_CCP_CRYPTO) += ccp-crypto.o
ccp-crypto-objs := ccp-crypto-main.o \
Expand Down
6 changes: 0 additions & 6 deletions drivers/crypto/ccp/ccp-dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -626,12 +626,6 @@ struct ccp5_desc {
struct dword7 dw7;
};

int ccp_pci_init(void);
void ccp_pci_exit(void);

int ccp_platform_init(void);
void ccp_platform_exit(void);

void ccp_add_device(struct ccp_device *ccp);
void ccp_del_device(struct ccp_device *ccp);

Expand Down
12 changes: 6 additions & 6 deletions drivers/crypto/ccp/sp-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,13 @@ static int __init sp_mod_init(void)
#ifdef CONFIG_X86
int ret;

ret = ccp_pci_init();
ret = sp_pci_init();
if (ret)
return ret;

/* Don't leave the driver loaded if init failed */
if (ccp_present() != 0) {
ccp_pci_exit();
sp_pci_exit();
return -ENODEV;
}

Expand All @@ -258,13 +258,13 @@ static int __init sp_mod_init(void)
#ifdef CONFIG_ARM64
int ret;

ret = ccp_platform_init();
ret = sp_platform_init();
if (ret)
return ret;

/* Don't leave the driver loaded if init failed */
if (ccp_present() != 0) {
ccp_platform_exit();
sp_platform_exit();
return -ENODEV;
}

Expand All @@ -277,11 +277,11 @@ static int __init sp_mod_init(void)
static void __exit sp_mod_exit(void)
{
#ifdef CONFIG_X86
ccp_pci_exit();
sp_pci_exit();
#endif

#ifdef CONFIG_ARM64
ccp_platform_exit();
sp_platform_exit();
#endif
}

Expand Down
80 changes: 40 additions & 40 deletions drivers/crypto/ccp/ccp-pci.c → drivers/crypto/ccp/sp-pci.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* AMD Cryptographic Coprocessor (CCP) driver
* AMD Secure Processor device driver
*
* Copyright (C) 2013,2016 Advanced Micro Devices, Inc.
*
Expand Down Expand Up @@ -28,35 +28,35 @@

#define MSIX_VECTORS 2

struct ccp_pci {
struct sp_pci {
int msix_count;
struct msix_entry msix_entry[MSIX_VECTORS];
};

static int ccp_get_msix_irqs(struct sp_device *sp)
static int sp_get_msix_irqs(struct sp_device *sp)
{
struct ccp_pci *ccp_pci = sp->dev_specific;
struct sp_pci *sp_pci = sp->dev_specific;
struct device *dev = sp->dev;
struct pci_dev *pdev = to_pci_dev(dev);
int v, ret;

for (v = 0; v < ARRAY_SIZE(ccp_pci->msix_entry); v++)
ccp_pci->msix_entry[v].entry = v;
for (v = 0; v < ARRAY_SIZE(sp_pci->msix_entry); v++)
sp_pci->msix_entry[v].entry = v;

ret = pci_enable_msix_range(pdev, ccp_pci->msix_entry, 1, v);
ret = pci_enable_msix_range(pdev, sp_pci->msix_entry, 1, v);
if (ret < 0)
return ret;

ccp_pci->msix_count = ret;
sp_pci->msix_count = ret;
sp->use_tasklet = true;

sp->psp_irq = ccp_pci->msix_entry[0].vector;
sp->ccp_irq = (ccp_pci->msix_count > 1) ? ccp_pci->msix_entry[1].vector
: ccp_pci->msix_entry[0].vector;
sp->psp_irq = sp_pci->msix_entry[0].vector;
sp->ccp_irq = (sp_pci->msix_count > 1) ? sp_pci->msix_entry[1].vector
: sp_pci->msix_entry[0].vector;
return 0;
}

static int ccp_get_msi_irq(struct sp_device *sp)
static int sp_get_msi_irq(struct sp_device *sp)
{
struct device *dev = sp->dev;
struct pci_dev *pdev = to_pci_dev(dev);
Expand All @@ -72,18 +72,18 @@ static int ccp_get_msi_irq(struct sp_device *sp)
return 0;
}

static int ccp_get_irqs(struct sp_device *sp)
static int sp_get_irqs(struct sp_device *sp)
{
struct device *dev = sp->dev;
int ret;

ret = ccp_get_msix_irqs(sp);
ret = sp_get_msix_irqs(sp);
if (!ret)
return 0;

/* Couldn't get MSI-X vectors, try MSI */
dev_notice(dev, "could not enable MSI-X (%d), trying MSI\n", ret);
ret = ccp_get_msi_irq(sp);
ret = sp_get_msi_irq(sp);
if (!ret)
return 0;

Expand All @@ -93,13 +93,13 @@ static int ccp_get_irqs(struct sp_device *sp)
return ret;
}

static void ccp_free_irqs(struct sp_device *sp)
static void sp_free_irqs(struct sp_device *sp)
{
struct ccp_pci *ccp_pci = sp->dev_specific;
struct sp_pci *sp_pci = sp->dev_specific;
struct device *dev = sp->dev;
struct pci_dev *pdev = to_pci_dev(dev);

if (ccp_pci->msix_count)
if (sp_pci->msix_count)
pci_disable_msix(pdev);
else if (sp->psp_irq)
pci_disable_msi(pdev);
Expand All @@ -108,10 +108,10 @@ static void ccp_free_irqs(struct sp_device *sp)
sp->psp_irq = 0;
}

static int ccp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
static int sp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
struct sp_device *sp;
struct ccp_pci *ccp_pci;
struct sp_pci *sp_pci;
struct device *dev = &pdev->dev;
void __iomem * const *iomap_table;
int bar_mask;
Expand All @@ -122,11 +122,11 @@ static int ccp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
if (!sp)
goto e_err;

ccp_pci = devm_kzalloc(dev, sizeof(*ccp_pci), GFP_KERNEL);
if (!ccp_pci)
sp_pci = devm_kzalloc(dev, sizeof(*sp_pci), GFP_KERNEL);
if (!sp_pci)
goto e_err;

sp->dev_specific = ccp_pci;
sp->dev_specific = sp_pci;
sp->dev_vdata = (struct sp_dev_vdata *)id->driver_data;
if (!sp->dev_vdata) {
ret = -ENODEV;
Expand Down Expand Up @@ -161,7 +161,7 @@ static int ccp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
goto e_err;
}

ret = ccp_get_irqs(sp);
ret = sp_get_irqs(sp);
if (ret)
goto e_err;

Expand Down Expand Up @@ -192,7 +192,7 @@ static int ccp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
return ret;
}

static void ccp_pci_remove(struct pci_dev *pdev)
static void sp_pci_remove(struct pci_dev *pdev)
{
struct device *dev = &pdev->dev;
struct sp_device *sp = dev_get_drvdata(dev);
Expand All @@ -202,21 +202,21 @@ static void ccp_pci_remove(struct pci_dev *pdev)

sp_destroy(sp);

ccp_free_irqs(sp);
sp_free_irqs(sp);

dev_notice(dev, "disabled\n");
}

#ifdef CONFIG_PM
static int ccp_pci_suspend(struct pci_dev *pdev, pm_message_t state)
static int sp_pci_suspend(struct pci_dev *pdev, pm_message_t state)
{
struct device *dev = &pdev->dev;
struct sp_device *sp = dev_get_drvdata(dev);

return sp_suspend(sp, state);
}

static int ccp_pci_resume(struct pci_dev *pdev)
static int sp_pci_resume(struct pci_dev *pdev)
{
struct device *dev = &pdev->dev;
struct sp_device *sp = dev_get_drvdata(dev);
Expand Down Expand Up @@ -245,32 +245,32 @@ static const struct sp_dev_vdata dev_vdata[] = {
#endif
},
};
static const struct pci_device_id ccp_pci_table[] = {
static const struct pci_device_id sp_pci_table[] = {
{ PCI_VDEVICE(AMD, 0x1537), (kernel_ulong_t)&dev_vdata[0] },
{ PCI_VDEVICE(AMD, 0x1456), (kernel_ulong_t)&dev_vdata[1] },
{ PCI_VDEVICE(AMD, 0x1468), (kernel_ulong_t)&dev_vdata[2] },
/* Last entry must be zero */
{ 0, }
};
MODULE_DEVICE_TABLE(pci, ccp_pci_table);
MODULE_DEVICE_TABLE(pci, sp_pci_table);

static struct pci_driver ccp_pci_driver = {
static struct pci_driver sp_pci_driver = {
.name = "ccp",
.id_table = ccp_pci_table,
.probe = ccp_pci_probe,
.remove = ccp_pci_remove,
.id_table = sp_pci_table,
.probe = sp_pci_probe,
.remove = sp_pci_remove,
#ifdef CONFIG_PM
.suspend = ccp_pci_suspend,
.resume = ccp_pci_resume,
.suspend = sp_pci_suspend,
.resume = sp_pci_resume,
#endif
};

int ccp_pci_init(void)
int sp_pci_init(void)
{
return pci_register_driver(&ccp_pci_driver);
return pci_register_driver(&sp_pci_driver);
}

void ccp_pci_exit(void)
void sp_pci_exit(void)
{
pci_unregister_driver(&ccp_pci_driver);
pci_unregister_driver(&sp_pci_driver);
}
Loading

0 comments on commit d0ebbc0

Please sign in to comment.