From: Akinobu Mita <akinobu.mita@gmail.com>
To: linux-scsi@vger.kernel.org
Cc: Akinobu Mita <akinobu.mita@gmail.com>,
Hans de Goede <hdegoede@redhat.com>, Tejun Heo <tj@kernel.org>,
Christoph Hellwig <hch@lst.de>,
"James E.J. Bottomley" <JBottomley@parallels.com>,
linux-ide@vger.kernel.org
Subject: [PATCH v4 10/11] ata: ahci_platform: adjust module reference for scsi host
Date: Mon, 19 Jan 2015 00:06:08 +0900 [thread overview]
Message-ID: <1421593569-5089-11-git-send-email-akinobu.mita@gmail.com> (raw)
In-Reply-To: <1421593569-5089-1-git-send-email-akinobu.mita@gmail.com>
The ahci platform drivers depend on libahci_platform module. The
module reference of these scsi host is initialized to libahci_platform's
one. Because these drivers use ahci_platform_init_host() which is
defined in libahci_platform module and calls scsi_host_alloc()
internally. So these drivers can be unloaded even if the scsi device
is being accessed.
This fixes it by converting into ahci_platform_init_host() macro so that
these drivers can pass their correct module reference through
__ata_host_alloc_pinfo().
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
Cc: linux-ide@vger.kernel.org
Cc: linux-scsi@vger.kernel.org
---
drivers/ata/libahci_platform.c | 14 ++++++++------
include/linux/ahci_platform.h | 9 ++++++---
2 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c
index 0b03f90..ea75416 100644
--- a/drivers/ata/libahci_platform.c
+++ b/drivers/ata/libahci_platform.c
@@ -395,10 +395,11 @@ err_out:
EXPORT_SYMBOL_GPL(ahci_platform_get_resources);
/**
- * ahci_platform_init_host - Bring up an ahci-platform host
+ * __ahci_platform_init_host - Bring up an ahci-platform host
* @pdev: platform device pointer for the host
* @hpriv: ahci-host private data for the host
* @pi_template: template for the ata_port_info to use
+ * @owner: module which will be the owner of the ahci-platform host
*
* This function does all the usual steps needed to bring up an
* ahci-platform host, note any necessary resources (ie clks, phys, etc.)
@@ -407,9 +408,10 @@ EXPORT_SYMBOL_GPL(ahci_platform_get_resources);
* RETURNS:
* 0 on success otherwise a negative error code
*/
-int ahci_platform_init_host(struct platform_device *pdev,
- struct ahci_host_priv *hpriv,
- const struct ata_port_info *pi_template)
+int __ahci_platform_init_host(struct platform_device *pdev,
+ struct ahci_host_priv *hpriv,
+ const struct ata_port_info *pi_template,
+ struct module *owner)
{
struct device *dev = &pdev->dev;
struct ata_port_info pi = *pi_template;
@@ -443,7 +445,7 @@ int ahci_platform_init_host(struct platform_device *pdev,
*/
n_ports = max(ahci_nr_ports(hpriv->cap), fls(hpriv->port_map));
- host = ata_host_alloc_pinfo(dev, ppi, n_ports);
+ host = __ata_host_alloc_pinfo(dev, ppi, n_ports, owner);
if (!host)
return -ENOMEM;
@@ -495,7 +497,7 @@ int ahci_platform_init_host(struct platform_device *pdev,
return ahci_host_activate(host, irq, &ahci_platform_sht);
}
-EXPORT_SYMBOL_GPL(ahci_platform_init_host);
+EXPORT_SYMBOL_GPL(__ahci_platform_init_host);
static void ahci_host_stop(struct ata_host *host)
{
diff --git a/include/linux/ahci_platform.h b/include/linux/ahci_platform.h
index 642d6ae..0dcac84 100644
--- a/include/linux/ahci_platform.h
+++ b/include/linux/ahci_platform.h
@@ -28,9 +28,12 @@ int ahci_platform_enable_resources(struct ahci_host_priv *hpriv);
void ahci_platform_disable_resources(struct ahci_host_priv *hpriv);
struct ahci_host_priv *ahci_platform_get_resources(
struct platform_device *pdev);
-int ahci_platform_init_host(struct platform_device *pdev,
- struct ahci_host_priv *hpriv,
- const struct ata_port_info *pi_template);
+int __ahci_platform_init_host(struct platform_device *pdev,
+ struct ahci_host_priv *hpriv,
+ const struct ata_port_info *pi_template,
+ struct module *owner);
+#define ahci_platform_init_host(pdev, hpriv, pi_template) \
+ __ahci_platform_init_host(pdev, hpriv, pi_template, THIS_MODULE)
int ahci_platform_suspend_host(struct device *dev);
int ahci_platform_resume_host(struct device *dev);
--
1.9.1
next prev parent reply other threads:[~2015-01-18 15:07 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-18 15:05 [PATCH v4 00/11] scsi: fix module reference mismatch for scsi host Akinobu Mita
2015-01-18 15:05 ` [PATCH v4 01/11] ata: prepare to move module reference from scsi_host_template to Scsi_Host Akinobu Mita
2015-01-18 15:06 ` [PATCH v4 07/11] scsi: " Akinobu Mita
2015-01-18 15:06 ` Akinobu Mita [this message]
2015-01-18 15:30 ` [PATCH v4 10/11] ata: ahci_platform: adjust module reference for scsi host Hans de Goede
2015-01-18 15:06 ` [PATCH v4 11/11] ata: pata_of_platform: " Akinobu Mita
2015-01-19 14:22 ` [PATCH v4 00/11] scsi: fix module reference mismatch " Tejun Heo
[not found] ` <20150119142206.GE8140-Gd/HAXX7CRxy/B6EtB590w@public.gmane.org>
2015-01-20 14:57 ` Akinobu Mita
2015-01-20 15:18 ` Tejun Heo
2015-01-20 15:20 ` Alan Stern
[not found] ` <Pine.LNX.4.44L0.1501201013440.1150-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2015-01-22 13:17 ` Akinobu Mita
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1421593569-5089-11-git-send-email-akinobu.mita@gmail.com \
--to=akinobu.mita@gmail.com \
--cc=JBottomley@parallels.com \
--cc=hch@lst.de \
--cc=hdegoede@redhat.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).