From patchwork Wed Apr 8 18:59:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 6182251 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C76669F2EC for ; Wed, 8 Apr 2015 19:03:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D41C92026F for ; Wed, 8 Apr 2015 19:03:54 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EE15620145 for ; Wed, 8 Apr 2015 19:03:53 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YfvDP-0005i4-N1; Wed, 08 Apr 2015 19:00:43 +0000 Received: from mail-pa0-x22f.google.com ([2607:f8b0:400e:c03::22f]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YfvDK-0005W1-WB for linux-arm-kernel@lists.infradead.org; Wed, 08 Apr 2015 19:00:39 +0000 Received: by pabtp1 with SMTP id tp1so17731134pab.2 for ; Wed, 08 Apr 2015 12:00:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=VuOLflH3gjD6FEmqJWi4jRXWmB97CXXAxBSypPksME4=; b=GUZJ+2NhKqX7R5K2qgMrM/zJCcqxHqWiOqV3NtsALK0C+1jxsGOu9z9KTQCMIFGUpy 2Ljt+k15RuvGvIN1sTNDWpnGk7B4SDuyHvOtEoOUNNC3hzE4RwTuadrRzX9PeaQyfiEg +BJjhanOj18w+Epgi2/i7nVwVg6/GCEzBF0XJWf5jxRuqJZHdHTbU6QnifMfmSXsjaIj 5+/xy5GUxtmEMzmon84mWCt0YgN2lblBKAwpeZQfGplStEagDWqh2QpTM161kvqk7xds Q8tYoMGo4Yuj9eETK3bW5iMXu08qWD4gxGB3T7BYD4vNp6gWVWDvSmL209zBffOoqhJR GMqg== X-Received: by 10.66.150.165 with SMTP id uj5mr49652909pab.54.1428519617246; Wed, 08 Apr 2015 12:00:17 -0700 (PDT) Received: from ld-irv-0074.broadcom.com (5520-maca-inet1-outside.broadcom.com. [216.31.211.11]) by mx.google.com with ESMTPSA id qv9sm12212165pab.27.2015.04.08.12.00.15 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Apr 2015 12:00:16 -0700 (PDT) From: Brian Norris To: Tejun Heo Subject: [PATCH] ata: ahci_st: fixup layering violations / drvdata errors Date: Wed, 8 Apr 2015 11:59:59 -0700 Message-Id: <1428519599-31885-1-git-send-email-computersforpeace@gmail.com> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150408_120039_143919_7BB4AFF5 X-CRM114-Status: GOOD ( 14.31 ) X-Spam-Score: -0.8 (/) Cc: kernel@stlinux.com, Srinivas Kandagatla , linux-kernel@vger.kernel.org, Patrice Chotard , linux-ide@vger.kernel.org, Brian Norris , linux-arm-kernel@lists.infradead.org, Maxime Coquelin X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When working on another SATA driver that uses libahci_platform, I noticed an error in this driver; it tries to the the driver data for its device, while libata also thinks it can set the driver data. See: ahci_platform_init_host() -> ata_host_alloc_pinfo() -> ata_host_alloc() -> dev_set_drvdata() So instead of sticking the IP-specific platform data into drvdata, let's use the plat_data variable that is reserved for this use. Signed-off-by: Brian Norris Cc: Srinivas Kandagatla Cc: Maxime Coquelin Cc: Patrice Chotard Acked-by: Maxime Coquelin --- This is ONLY compile tested; I don't have hardware to run. This looks like it could have ramifications on suspend/resume support, and hot device removal (e.g., sysfs unbind), so it might qualify as -stable, if someone can test it drivers/ata/ahci_st.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/ata/ahci_st.c b/drivers/ata/ahci_st.c index bc971af262e7..2bd2375c2ab1 100644 --- a/drivers/ata/ahci_st.c +++ b/drivers/ata/ahci_st.c @@ -37,7 +37,6 @@ struct st_ahci_drv_data { struct reset_control *pwr; struct reset_control *sw_rst; struct reset_control *pwr_rst; - struct ahci_host_priv *hpriv; }; static void st_ahci_configure_oob(void __iomem *mmio) @@ -57,7 +56,9 @@ static void st_ahci_configure_oob(void __iomem *mmio) static int st_ahci_deassert_resets(struct device *dev) { - struct st_ahci_drv_data *drv_data = dev_get_drvdata(dev); + struct ata_host *host = dev_get_drvdata(dev); + struct ahci_host_priv *hpriv = host->private_data; + struct st_ahci_drv_data *drv_data = hpriv->plat_data; int err; if (drv_data->pwr) { @@ -68,7 +69,7 @@ static int st_ahci_deassert_resets(struct device *dev) } } - st_ahci_configure_oob(drv_data->hpriv->mmio); + st_ahci_configure_oob(hpriv->mmio); if (drv_data->sw_rst) { err = reset_control_deassert(drv_data->sw_rst); @@ -92,8 +93,8 @@ static int st_ahci_deassert_resets(struct device *dev) static void st_ahci_host_stop(struct ata_host *host) { struct ahci_host_priv *hpriv = host->private_data; + struct st_ahci_drv_data *drv_data = hpriv->plat_data; struct device *dev = host->dev; - struct st_ahci_drv_data *drv_data = dev_get_drvdata(dev); int err; if (drv_data->pwr) { @@ -107,7 +108,9 @@ static void st_ahci_host_stop(struct ata_host *host) static int st_ahci_probe_resets(struct platform_device *pdev) { - struct st_ahci_drv_data *drv_data = platform_get_drvdata(pdev); + struct ata_host *host = dev_get_drvdata(&pdev->dev); + struct ahci_host_priv *hpriv = host->private_data; + struct st_ahci_drv_data *drv_data = hpriv->plat_data; drv_data->pwr = devm_reset_control_get(&pdev->dev, "pwr-dwn"); if (IS_ERR(drv_data->pwr)) { @@ -161,8 +164,7 @@ static int st_ahci_probe(struct platform_device *pdev) hpriv = ahci_platform_get_resources(pdev); if (IS_ERR(hpriv)) return PTR_ERR(hpriv); - - drv_data->hpriv = hpriv; + hpriv->plat_data = drv_data; err = st_ahci_probe_resets(pdev); if (err) @@ -185,8 +187,9 @@ static int st_ahci_probe(struct platform_device *pdev) #ifdef CONFIG_PM_SLEEP static int st_ahci_suspend(struct device *dev) { - struct st_ahci_drv_data *drv_data = dev_get_drvdata(dev); - struct ahci_host_priv *hpriv = drv_data->hpriv; + struct ata_host *host = dev_get_drvdata(dev); + struct ahci_host_priv *hpriv = host->private_data; + struct st_ahci_drv_data *drv_data = hpriv->plat_data; int err; err = ahci_platform_suspend_host(dev); @@ -208,8 +211,8 @@ static int st_ahci_suspend(struct device *dev) static int st_ahci_resume(struct device *dev) { - struct st_ahci_drv_data *drv_data = dev_get_drvdata(dev); - struct ahci_host_priv *hpriv = drv_data->hpriv; + struct ata_host *host = dev_get_drvdata(dev); + struct ahci_host_priv *hpriv = host->private_data; int err; err = ahci_platform_enable_resources(hpriv);