Maybe, a better subject? drivers: init pdev drivers in constructors
On Fri, 29 Jan 2016 15:08:30 +0100 David Marchand <david.marchand at 6wind.com> wrote: > Now that pdev drivers have been converted to pci drivers, there is nothing > left in their init functions that can't go in a constructor. > pdev / vdev drivers init order is changed by this commit, but I can't see > why we would need to preserve it. > > Signed-off-by: David Marchand <david.marchand at 6wind.com> > --- > drivers/crypto/qat/rte_qat_cryptodev.c | 13 +++--------- > drivers/net/bnx2x/bnx2x_ethdev.c | 26 +++--------------------- > drivers/net/cxgbe/cxgbe_ethdev.c | 19 +++--------------- > drivers/net/e1000/em_ethdev.c | 13 +++--------- > drivers/net/e1000/igb_ethdev.c | 34 ++++---------------------------- > drivers/net/enic/enic_ethdev.c | 18 +++-------------- > drivers/net/fm10k/fm10k_ethdev.c | 19 +++--------------- > drivers/net/i40e/i40e_ethdev.c | 19 +++--------------- > drivers/net/i40e/i40e_ethdev_vf.c | 19 +++--------------- > drivers/net/ixgbe/ixgbe_ethdev.c | 36 > +++------------------------------- > drivers/net/mlx4/mlx4.c | 19 +++--------------- > drivers/net/mlx5/mlx5.c | 19 +++--------------- > drivers/net/nfp/nfp_net.c | 14 +++---------- > drivers/net/virtio/virtio_ethdev.c | 22 ++++----------------- > drivers/net/vmxnet3/vmxnet3_ethdev.c | 18 +++-------------- > 15 files changed, 47 insertions(+), 261 deletions(-) > > diff --git a/drivers/crypto/qat/rte_qat_cryptodev.c > b/drivers/crypto/qat/rte_qat_cryptodev.c > index 6853aee..ded5d60 100644 > --- a/drivers/crypto/qat/rte_qat_cryptodev.c > +++ b/drivers/crypto/qat/rte_qat_cryptodev.c > @@ -124,17 +124,10 @@ static struct rte_cryptodev_driver rte_qat_pmd = { > .dev_private_size = sizeof(struct qat_pmd_private), > }; > > -static int > -rte_qat_pmd_init(const char *name __rte_unused, const char *params > __rte_unused) > +/* Driver registration */ > +static void __attribute__((constructor, used)) > +rte_qat_pmd_init(void) > { > PMD_INIT_FUNC_TRACE(); > rte_eal_pci_register(&rte_qat_pmd.pci_drv); > - return 0; > } > - > -static struct rte_driver pmd_qat_drv = { > - .type = PMD_PDEV, > - .init = rte_qat_pmd_init, > -}; > - > -PMD_REGISTER_DRIVER(pmd_qat_drv); What about introducing a macro for this? RTE_REGISTER_PCI_DRIVER(rte_qad_pmd); Regards Jan