Skip to content

Commit 50528fa

Browse files
committed
Merge tag 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev
Pull libata update from Jeff Garzik: - More ACPI fixes, cleanups - Minor cleanups for sata_highbank, pata_at32, pata_octeon_cf, sata_rcar - pata_legacy: small bug found in opti chipset code (untested fix, due to ancient h/w) - sata_fsl: RX water mark config knob, some h/w needs it - pata_imx: cleanups, DeviceTree support - SCSI<->ATA translator: properly export translator version, not device firmware version * tag 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev: sata_highbank: Rename proc_name to the module name ACPI/libata: Restore libata.noacpi support [libata] acpi: make ata_ap_acpi_handle not block [libata] SCSI: really use SATL version in VPD pata_imx: add devicetree support pata_imx: use void __iomem * for regs pata_imx: cleanup error path pata_imx: Use devm_clk_get sata_rcar: Convert to devm_ioremap_resource() fsl/sata: create a sysfs entry for rx water mark libata-acpi: remove redundent code for power resource handling sata_highbank: make ahci_highbank_pm_ops static pata_octeon_cf: Use resource_size function pata_legacy: bogus clock in opti82c46x_set_piomode() pata_at32: use module_platform_driver_probe()
2 parents 3ed1c47 + 2cc1144 commit 50528fa

10 files changed

Lines changed: 140 additions & 85 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
* Freescale i.MX PATA Controller
2+
3+
Required properties:
4+
- compatible: "fsl,imx27-pata"
5+
- reg: Address range of the PATA Controller
6+
- interrupts: The interrupt of the PATA Controller
7+
- clocks: the clocks for the PATA Controller
8+
9+
Example:
10+
11+
pata: pata@83fe0000 {
12+
compatible = "fsl,imx51-pata", "fsl,imx27-pata";
13+
reg = <0x83fe0000 0x4000>;
14+
interrupts = <70>;
15+
clocks = <&clks 161>;
16+
status = "disabled";
17+
};

‎drivers/ata/libata-acpi.c‎

Lines changed: 29 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include <linux/pci.h>
1818
#include <linux/slab.h>
1919
#include <linux/pm_runtime.h>
20-
#include <linux/pm_qos.h>
2120
#include <scsi/scsi_device.h>
2221
#include "libata.h"
2322

@@ -61,7 +60,8 @@ acpi_handle ata_ap_acpi_handle(struct ata_port *ap)
6160
if (ap->flags & ATA_FLAG_ACPI_SATA)
6261
return NULL;
6362

64-
return acpi_get_child(DEVICE_ACPI_HANDLE(ap->host->dev), ap->port_no);
63+
return ap->scsi_host ?
64+
DEVICE_ACPI_HANDLE(&ap->scsi_host->shost_gendev) : NULL;
6565
}
6666
EXPORT_SYMBOL(ata_ap_acpi_handle);
6767

@@ -77,7 +77,7 @@ acpi_handle ata_dev_acpi_handle(struct ata_device *dev)
7777
acpi_integer adr;
7878
struct ata_port *ap = dev->link->ap;
7979

80-
if (dev->flags & ATA_DFLAG_ACPI_DISABLED)
80+
if (libata_noacpi || dev->flags & ATA_DFLAG_ACPI_DISABLED)
8181
return NULL;
8282

8383
if (ap->flags & ATA_FLAG_ACPI_SATA) {
@@ -240,28 +240,15 @@ void ata_acpi_dissociate(struct ata_host *host)
240240
}
241241
}
242242

243-
/**
244-
* ata_acpi_gtm - execute _GTM
245-
* @ap: target ATA port
246-
* @gtm: out parameter for _GTM result
247-
*
248-
* Evaluate _GTM and store the result in @gtm.
249-
*
250-
* LOCKING:
251-
* EH context.
252-
*
253-
* RETURNS:
254-
* 0 on success, -ENOENT if _GTM doesn't exist, -errno on failure.
255-
*/
256-
int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *gtm)
243+
static int __ata_acpi_gtm(struct ata_port *ap, acpi_handle handle,
244+
struct ata_acpi_gtm *gtm)
257245
{
258246
struct acpi_buffer output = { .length = ACPI_ALLOCATE_BUFFER };
259247
union acpi_object *out_obj;
260248
acpi_status status;
261249
int rc = 0;
262250

263-
status = acpi_evaluate_object(ata_ap_acpi_handle(ap), "_GTM", NULL,
264-
&output);
251+
status = acpi_evaluate_object(handle, "_GTM", NULL, &output);
265252

266253
rc = -ENOENT;
267254
if (status == AE_NOT_FOUND)
@@ -295,6 +282,27 @@ int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *gtm)
295282
return rc;
296283
}
297284

285+
/**
286+
* ata_acpi_gtm - execute _GTM
287+
* @ap: target ATA port
288+
* @gtm: out parameter for _GTM result
289+
*
290+
* Evaluate _GTM and store the result in @gtm.
291+
*
292+
* LOCKING:
293+
* EH context.
294+
*
295+
* RETURNS:
296+
* 0 on success, -ENOENT if _GTM doesn't exist, -errno on failure.
297+
*/
298+
int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *gtm)
299+
{
300+
if (ata_ap_acpi_handle(ap))
301+
return __ata_acpi_gtm(ap, ata_ap_acpi_handle(ap), gtm);
302+
else
303+
return -EINVAL;
304+
}
305+
298306
EXPORT_SYMBOL_GPL(ata_acpi_gtm);
299307

300308
/**
@@ -1020,38 +1028,6 @@ void ata_acpi_on_disable(struct ata_device *dev)
10201028
ata_acpi_clear_gtf(dev);
10211029
}
10221030

1023-
static void ata_acpi_register_power_resource(struct ata_device *dev)
1024-
{
1025-
struct scsi_device *sdev = dev->sdev;
1026-
acpi_handle handle;
1027-
1028-
handle = ata_dev_acpi_handle(dev);
1029-
if (handle)
1030-
acpi_dev_pm_add_dependent(handle, &sdev->sdev_gendev);
1031-
}
1032-
1033-
static void ata_acpi_unregister_power_resource(struct ata_device *dev)
1034-
{
1035-
struct scsi_device *sdev = dev->sdev;
1036-
acpi_handle handle;
1037-
1038-
handle = ata_dev_acpi_handle(dev);
1039-
if (handle)
1040-
acpi_dev_pm_remove_dependent(handle, &sdev->sdev_gendev);
1041-
}
1042-
1043-
void ata_acpi_bind(struct ata_device *dev)
1044-
{
1045-
ata_acpi_register_power_resource(dev);
1046-
if (zpodd_dev_enabled(dev))
1047-
dev_pm_qos_expose_flags(&dev->sdev->sdev_gendev, 0);
1048-
}
1049-
1050-
void ata_acpi_unbind(struct ata_device *dev)
1051-
{
1052-
ata_acpi_unregister_power_resource(dev);
1053-
}
1054-
10551031
static int compat_pci_ata(struct ata_port *ap)
10561032
{
10571033
struct device *dev = ap->tdev.parent;
@@ -1071,7 +1047,7 @@ static int compat_pci_ata(struct ata_port *ap)
10711047

10721048
static int ata_acpi_bind_host(struct ata_port *ap, acpi_handle *handle)
10731049
{
1074-
if (ap->flags & ATA_FLAG_ACPI_SATA)
1050+
if (libata_noacpi || ap->flags & ATA_FLAG_ACPI_SATA)
10751051
return -ENODEV;
10761052

10771053
*handle = acpi_get_child(DEVICE_ACPI_HANDLE(ap->tdev.parent),
@@ -1080,7 +1056,7 @@ static int ata_acpi_bind_host(struct ata_port *ap, acpi_handle *handle)
10801056
if (!*handle)
10811057
return -ENODEV;
10821058

1083-
if (ata_acpi_gtm(ap, &ap->__acpi_init_gtm) == 0)
1059+
if (__ata_acpi_gtm(ap, *handle, &ap->__acpi_init_gtm) == 0)
10841060
ap->pflags |= ATA_PFLAG_INIT_GTM_VALID;
10851061

10861062
return 0;

‎drivers/ata/libata-scsi.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include <linux/hdreg.h>
5050
#include <linux/uaccess.h>
5151
#include <linux/suspend.h>
52+
#include <linux/pm_qos.h>
5253
#include <asm/unaligned.h>
5354

5455
#include "libata.h"
@@ -2126,7 +2127,6 @@ static unsigned int ata_scsiop_inq_89(struct ata_scsi_args *args, u8 *rbuf)
21262127
memcpy(&rbuf[8], "linux ", 8);
21272128
memcpy(&rbuf[16], "libata ", 16);
21282129
memcpy(&rbuf[32], DRV_VERSION, 4);
2129-
ata_id_string(args->id, &rbuf[32], ATA_ID_FW_REV, 4);
21302130

21312131
/* we don't store the ATA device signature, so we fake it */
21322132

@@ -3668,7 +3668,9 @@ void ata_scsi_scan_host(struct ata_port *ap, int sync)
36683668
if (!IS_ERR(sdev)) {
36693669
dev->sdev = sdev;
36703670
scsi_device_put(sdev);
3671-
ata_acpi_bind(dev);
3671+
if (zpodd_dev_enabled(dev))
3672+
dev_pm_qos_expose_flags(
3673+
&sdev->sdev_gendev, 0);
36723674
} else {
36733675
dev->sdev = NULL;
36743676
}
@@ -3767,7 +3769,6 @@ static void ata_scsi_remove_dev(struct ata_device *dev)
37673769

37683770
if (zpodd_dev_enabled(dev))
37693771
zpodd_exit(dev);
3770-
ata_acpi_unbind(dev);
37713772

37723773
/* clearing dev->sdev is protected by host lock */
37733774
sdev = dev->sdev;

‎drivers/ata/pata_at32.c‎

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -393,18 +393,7 @@ static struct platform_driver pata_at32_driver = {
393393
},
394394
};
395395

396-
static int __init pata_at32_init(void)
397-
{
398-
return platform_driver_probe(&pata_at32_driver, pata_at32_probe);
399-
}
400-
401-
static void __exit pata_at32_exit(void)
402-
{
403-
platform_driver_unregister(&pata_at32_driver);
404-
}
405-
406-
module_init(pata_at32_init);
407-
module_exit(pata_at32_exit);
396+
module_platform_driver_probe(pata_at32_driver, pata_at32_probe);
408397

409398
MODULE_LICENSE("GPL");
410399
MODULE_DESCRIPTION("AVR32 SMC/CFC PATA Driver");

‎drivers/ata/pata_imx.c‎

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
struct pata_imx_priv {
3838
struct clk *clk;
3939
/* timings/interrupt/control regs */
40-
u8 *host_regs;
40+
void __iomem *host_regs;
4141
u32 ata_ctl;
4242
};
4343

@@ -98,6 +98,7 @@ static int pata_imx_probe(struct platform_device *pdev)
9898
struct pata_imx_priv *priv;
9999
int irq = 0;
100100
struct resource *io_res;
101+
int ret;
101102

102103
io_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
103104
if (io_res == NULL)
@@ -112,7 +113,7 @@ static int pata_imx_probe(struct platform_device *pdev)
112113
if (!priv)
113114
return -ENOMEM;
114115

115-
priv->clk = clk_get(&pdev->dev, NULL);
116+
priv->clk = devm_clk_get(&pdev->dev, NULL);
116117
if (IS_ERR(priv->clk)) {
117118
dev_err(&pdev->dev, "Failed to get clock\n");
118119
return PTR_ERR(priv->clk);
@@ -121,8 +122,10 @@ static int pata_imx_probe(struct platform_device *pdev)
121122
clk_prepare_enable(priv->clk);
122123

123124
host = ata_host_alloc(&pdev->dev, 1);
124-
if (!host)
125-
goto free_priv;
125+
if (!host) {
126+
ret = -ENOMEM;
127+
goto err;
128+
}
126129

127130
host->private_data = priv;
128131
ap = host->ports[0];
@@ -135,7 +138,8 @@ static int pata_imx_probe(struct platform_device *pdev)
135138
resource_size(io_res));
136139
if (!priv->host_regs) {
137140
dev_err(&pdev->dev, "failed to map IO/CTL base\n");
138-
goto free_priv;
141+
ret = -EBUSY;
142+
goto err;
139143
}
140144

141145
ap->ioaddr.cmd_addr = priv->host_regs + PATA_IMX_DRIVE_DATA;
@@ -158,13 +162,17 @@ static int pata_imx_probe(struct platform_device *pdev)
158162
priv->host_regs + PATA_IMX_ATA_INT_EN);
159163

160164
/* activate */
161-
return ata_host_activate(host, irq, ata_sff_interrupt, 0,
165+
ret = ata_host_activate(host, irq, ata_sff_interrupt, 0,
162166
&pata_imx_sht);
163167

164-
free_priv:
168+
if (ret)
169+
goto err;
170+
171+
return 0;
172+
err:
165173
clk_disable_unprepare(priv->clk);
166-
clk_put(priv->clk);
167-
return -ENOMEM;
174+
175+
return ret;
168176
}
169177

170178
static int pata_imx_remove(struct platform_device *pdev)
@@ -177,7 +185,6 @@ static int pata_imx_remove(struct platform_device *pdev)
177185
__raw_writel(0, priv->host_regs + PATA_IMX_ATA_INT_EN);
178186

179187
clk_disable_unprepare(priv->clk);
180-
clk_put(priv->clk);
181188

182189
return 0;
183190
}
@@ -223,11 +230,20 @@ static const struct dev_pm_ops pata_imx_pm_ops = {
223230
};
224231
#endif
225232

233+
static const struct of_device_id imx_pata_dt_ids[] = {
234+
{
235+
.compatible = "fsl,imx27-pata",
236+
}, {
237+
/* sentinel */
238+
}
239+
};
240+
226241
static struct platform_driver pata_imx_driver = {
227242
.probe = pata_imx_probe,
228243
.remove = pata_imx_remove,
229244
.driver = {
230245
.name = DRV_NAME,
246+
.of_match_table = imx_pata_dt_ids,
231247
.owner = THIS_MODULE,
232248
#ifdef CONFIG_PM
233249
.pm = &pata_imx_pm_ops,

‎drivers/ata/pata_legacy.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ static void opti82c46x_set_piomode(struct ata_port *ap, struct ata_device *adev)
542542
u8 sysclk;
543543

544544
/* Get the clock */
545-
sysclk = opti_syscfg(0xAC) & 0xC0; /* BIOS set */
545+
sysclk = (opti_syscfg(0xAC) & 0xC0) >> 6; /* BIOS set */
546546

547547
/* Enter configuration mode */
548548
ioread16(ap->ioaddr.error_addr);

‎drivers/ata/pata_octeon_cf.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ static int octeon_cf_probe(struct platform_device *pdev)
926926
goto free_cf_port;
927927
}
928928
cs1 = devm_ioremap_nocache(&pdev->dev, res_cs1->start,
929-
res_cs1->end - res_cs1->start + 1);
929+
resource_size(res_cs1));
930930

931931
if (!cs1)
932932
goto free_cf_port;

0 commit comments

Comments
 (0)