Received: by 10.213.65.68 with SMTP id h4csp2375795imn; Mon, 2 Apr 2018 06:31:10 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/qggDfL2kI/oyIRHLEb/5h8yYf98cffNLe8L/4xVkWHv+z+H/6MFY3FNDJTH6A3NmBFFxe X-Received: by 2002:a17:902:4003:: with SMTP id b3-v6mr10200064pld.15.1522675870241; Mon, 02 Apr 2018 06:31:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522675870; cv=none; d=google.com; s=arc-20160816; b=DTPvNCxPLj75jo2ltXKLCHY1QdW4Q5a1XcyIVVCLBYAKTm8BIKqVbp7+vA7beXTxB0 lAarkMebXyz63FPfUJWFBejZ7MiaQYdiP4OdDv97aZIJaItqaom++Etoq5yHFHGow0ai vd+txNASUvOf8WDHe+FZooMNh/5Q/POo1GREpcVlFY5Da6Mh6sqNzhMPNPazpcPwpQRP jcy/xXtarrn/Xtm/fPNMPTVWXCekGDH14SkhStzGfzvNNrO7e3bHulVX0KRAOE1Z725U W1T7/wpzxgWzVy6TOwfCOHqm7mNvzTn/skK6WTfH9ysKZBZG6SCXbVR851xsjDpS69HV AmSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:dkim-signature:arc-authentication-results; bh=qPzWN7nCkNd5Et82RaaMKT0dS5T3VvtI8dQFid971LE=; b=0OsNh8LHzBvlkxqK99rAYv2zLFPNaUNIO6JQU54EYCDK1KsKcSyEgo9c85h4z7UVXh Ga18ipuk6nj2awMBZ48xfmkrh6A88XQeesYNFHY8PBEP7o6bDXjKVyf/D7kONLQ0iTIu 5seHQ6MgIDhpkx4CIqqerUka4aZVcXlZvJttzvPGfp/8FUR8cEoi5rRbRZ2k+BLcrNjd yjX9n5UrbDcWlHUe0IZX1li6nq1591DFRA36ROnZA8ayP0EHweyUjKEMslY8yPV7evd7 XSZ76LBX+iBNXt+ZxE9EiNuB3S41PMvZWjU5IpZzDsEcy3vAcrJouymz0x3zWM4ZMZej 1yQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=w4cES7gj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bh7-v6si313718plb.711.2018.04.02.06.30.54; Mon, 02 Apr 2018 06:31:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=w4cES7gj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750931AbeDBN3r (ORCPT + 99 others); Mon, 2 Apr 2018 09:29:47 -0400 Received: from lelnx193.ext.ti.com ([198.47.27.77]:43153 "EHLO lelnx193.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750724AbeDBN3p (ORCPT ); Mon, 2 Apr 2018 09:29:45 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id w32DTet6027923; Mon, 2 Apr 2018 08:29:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1522675780; bh=R0LgqUUumwzr9IDMAF4iA7pFF03hdzhJjAOCKxGM91c=; h=From:To:CC:Subject:Date; b=w4cES7gjToXQH3bfSwa9MjOSBbUd+Msc7ChoYZ93pv7JtKWg0cdQhpD8mXTtmrFMS h4BcYNkPDmnh/TmlcAsD1UO8kAUkiTDb7759ROkFNpV0q7eK3vdKRkgSThbI8vjTGn +rpG9Xw/V0XYLI3QsythM067Reig6qH/55oDZRAo= Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w32DTe1Y011856; Mon, 2 Apr 2018 08:29:40 -0500 Received: from DLEE113.ent.ti.com (157.170.170.24) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Mon, 2 Apr 2018 08:29:40 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Mon, 2 Apr 2018 08:29:40 -0500 Received: from a0393678ub.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w32DTbXG007254; Mon, 2 Apr 2018 08:29:38 -0500 From: Kishon Vijay Abraham I To: , Lorenzo Pieralisi , Bjorn Helgaas CC: , , Gustavo Pimentel Subject: [PATCH] PCI: endpoint: Create configfs entry for each pci_epf_device_id table entry Date: Mon, 2 Apr 2018 18:59:35 +0530 Message-ID: <20180402132935.32008-1-kishon@ti.com> X-Mailer: git-send-email 2.16.2 MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to be able to provide correct driver_data for pci_epf device, a separate configfs entry for each pci_epf_device_id table entry in pci_epf_driver is required. Add support to create configfs entry for each pci_epf_device_id table entry here. Signed-off-by: Kishon Vijay Abraham I --- drivers/pci/endpoint/pci-epf-core.c | 23 +++++++++++++++++++++-- include/linux/pci-epf.h | 4 ++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/drivers/pci/endpoint/pci-epf-core.c b/drivers/pci/endpoint/pci-epf-core.c index 59ed29e550e9..d6787f39fd41 100644 --- a/drivers/pci/endpoint/pci-epf-core.c +++ b/drivers/pci/endpoint/pci-epf-core.c @@ -15,6 +15,8 @@ #include #include +static DEFINE_MUTEX(pci_epf_mutex); + static struct bus_type pci_epf_bus_type; static const struct device_type pci_epf_type; @@ -139,7 +141,13 @@ EXPORT_SYMBOL_GPL(pci_epf_alloc_space); */ void pci_epf_unregister_driver(struct pci_epf_driver *driver) { - pci_ep_cfs_remove_epf_group(driver->group); + struct config_group *group; + + mutex_lock(&pci_epf_mutex); + list_for_each_entry(group, &driver->epf_group, group_entry) + pci_ep_cfs_remove_epf_group(group); + list_del(&driver->epf_group); + mutex_unlock(&pci_epf_mutex); driver_unregister(&driver->driver); } EXPORT_SYMBOL_GPL(pci_epf_unregister_driver); @@ -155,6 +163,8 @@ int __pci_epf_register_driver(struct pci_epf_driver *driver, struct module *owner) { int ret; + struct config_group *group; + const struct pci_epf_device_id *id; if (!driver->ops) return -EINVAL; @@ -169,7 +179,16 @@ int __pci_epf_register_driver(struct pci_epf_driver *driver, if (ret) return ret; - driver->group = pci_ep_cfs_add_epf_group(driver->driver.name); + INIT_LIST_HEAD(&driver->epf_group); + + id = driver->id_table; + while (id->name[0]) { + group = pci_ep_cfs_add_epf_group(id->name); + mutex_lock(&pci_epf_mutex); + list_add_tail(&group->group_entry, &driver->epf_group); + mutex_unlock(&pci_epf_mutex); + id++; + } return 0; } diff --git a/include/linux/pci-epf.h b/include/linux/pci-epf.h index e897bf076701..a30dcaafa6e8 100644 --- a/include/linux/pci-epf.h +++ b/include/linux/pci-epf.h @@ -72,7 +72,7 @@ struct pci_epf_ops { * @driver: PCI EPF driver * @ops: set of function pointers for performing EPF operations * @owner: the owner of the module that registers the PCI EPF driver - * @group: configfs group corresponding to the PCI EPF driver + * @epf_group: list of configfs group corresponding to the PCI EPF driver * @id_table: identifies EPF devices for probing */ struct pci_epf_driver { @@ -82,7 +82,7 @@ struct pci_epf_driver { struct device_driver driver; struct pci_epf_ops *ops; struct module *owner; - struct config_group *group; + struct list_head epf_group; const struct pci_epf_device_id *id_table; }; -- 2.16.2