Skip to content

Commit baf29cc

Browse files
committed
Merge tag 'ata-6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux
Pull ata updates from Damien Le Moal: - Constify struct pci_device_id (Christophe) - Remove unused code in the sata_gemini driver (David) - Improve libahci_platform to allow supporting non consecutive port numbers as specified in device trees (Josua) - Cleanup ahci driver code handling of port numbers with the new helper ahci_ignore_port() (me) - Use pm_sleep_ptr() to remove CONFIG_PM_SLEEP ifdefs in the ahci_st driver (Raphael). More of these changes will be included in the next cycle * tag 'ata-6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux: ahci: st: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() ahci: Introduce ahci_ignore_port() helper ata: libahci_platform: support non-consecutive port numbers ata: sata_gemini: Remove remaining reset glue ata: sata_gemini: Remove unused gemini_sata_reset_bridge() ata: Constify struct pci_device_id
2 parents 88e4506 + f2809aa commit baf29cc

File tree

10 files changed

+60
-47
lines changed

10 files changed

+60
-47
lines changed

drivers/ata/ahci.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ struct ahci_port_priv {
328328
struct ahci_host_priv {
329329
/* Input fields */
330330
unsigned int flags; /* AHCI_HFLAG_* */
331-
u32 mask_port_map; /* mask out particular bits */
331+
u32 mask_port_map; /* Mask of valid ports */
332332

333333
void __iomem * mmio; /* bus-independent mem map */
334334
u32 cap; /* cap to use */
@@ -379,6 +379,17 @@ struct ahci_host_priv {
379379
int port);
380380
};
381381

382+
/*
383+
* Return true if a port should be ignored because it is excluded from
384+
* the host port map.
385+
*/
386+
static inline bool ahci_ignore_port(struct ahci_host_priv *hpriv,
387+
unsigned int portid)
388+
{
389+
return portid >= hpriv->nports ||
390+
!(hpriv->mask_port_map & (1 << portid));
391+
}
392+
382393
extern int ahci_ignore_sss;
383394

384395
extern const struct attribute_group *ahci_shost_groups[];

drivers/ata/ahci_brcm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,9 @@ static unsigned int brcm_ahci_read_id(struct ata_device *dev,
288288

289289
/* Re-initialize and calibrate the PHY */
290290
for (i = 0; i < hpriv->nports; i++) {
291+
if (ahci_ignore_port(hpriv, i))
292+
continue;
293+
291294
rc = phy_init(hpriv->phys[i]);
292295
if (rc)
293296
goto disable_phys;

drivers/ata/ahci_ceva.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ static int ceva_ahci_platform_enable_resources(struct ahci_host_priv *hpriv)
206206
goto disable_clks;
207207

208208
for (i = 0; i < hpriv->nports; i++) {
209+
if (ahci_ignore_port(hpriv, i))
210+
continue;
211+
209212
rc = phy_init(hpriv->phys[i]);
210213
if (rc)
211214
goto disable_rsts;
@@ -215,6 +218,9 @@ static int ceva_ahci_platform_enable_resources(struct ahci_host_priv *hpriv)
215218
ahci_platform_deassert_rsts(hpriv);
216219

217220
for (i = 0; i < hpriv->nports; i++) {
221+
if (ahci_ignore_port(hpriv, i))
222+
continue;
223+
218224
rc = phy_power_on(hpriv->phys[i]);
219225
if (rc) {
220226
phy_exit(hpriv->phys[i]);

drivers/ata/ahci_st.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ static int st_ahci_probe(struct platform_device *pdev)
176176
return 0;
177177
}
178178

179-
#ifdef CONFIG_PM_SLEEP
180179
static int st_ahci_suspend(struct device *dev)
181180
{
182181
struct ata_host *host = dev_get_drvdata(dev);
@@ -221,9 +220,8 @@ static int st_ahci_resume(struct device *dev)
221220

222221
return ahci_platform_resume_host(dev);
223222
}
224-
#endif
225223

226-
static SIMPLE_DEV_PM_OPS(st_ahci_pm_ops, st_ahci_suspend, st_ahci_resume);
224+
static DEFINE_SIMPLE_DEV_PM_OPS(st_ahci_pm_ops, st_ahci_suspend, st_ahci_resume);
227225

228226
static const struct of_device_id st_ahci_match[] = {
229227
{ .compatible = "st,ahci", },
@@ -234,7 +232,7 @@ MODULE_DEVICE_TABLE(of, st_ahci_match);
234232
static struct platform_driver st_ahci_driver = {
235233
.driver = {
236234
.name = DRV_NAME,
237-
.pm = &st_ahci_pm_ops,
235+
.pm = pm_sleep_ptr(&st_ahci_pm_ops),
238236
.of_match_table = st_ahci_match,
239237
},
240238
.probe = st_ahci_probe,

drivers/ata/ata_generic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id
209209
return ata_pci_bmdma_init_one(dev, ppi, &generic_sht, (void *)id, 0);
210210
}
211211

212-
static struct pci_device_id ata_generic[] = {
212+
static const struct pci_device_id ata_generic[] = {
213213
{ PCI_DEVICE(PCI_VENDOR_ID_PCTECH, PCI_DEVICE_ID_PCTECH_SAMURAI_IDE), },
214214
{ PCI_DEVICE(PCI_VENDOR_ID_HOLTEK, PCI_DEVICE_ID_HOLTEK_6565), },
215215
{ PCI_DEVICE(PCI_VENDOR_ID_UMC, PCI_DEVICE_ID_UMC_UM8673F), },

drivers/ata/libahci_platform.c

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ int ahci_platform_enable_phys(struct ahci_host_priv *hpriv)
4949
int rc, i;
5050

5151
for (i = 0; i < hpriv->nports; i++) {
52+
if (ahci_ignore_port(hpriv, i))
53+
continue;
54+
5255
rc = phy_init(hpriv->phys[i]);
5356
if (rc)
5457
goto disable_phys;
@@ -70,6 +73,9 @@ int ahci_platform_enable_phys(struct ahci_host_priv *hpriv)
7073

7174
disable_phys:
7275
while (--i >= 0) {
76+
if (ahci_ignore_port(hpriv, i))
77+
continue;
78+
7379
phy_power_off(hpriv->phys[i]);
7480
phy_exit(hpriv->phys[i]);
7581
}
@@ -88,6 +94,9 @@ void ahci_platform_disable_phys(struct ahci_host_priv *hpriv)
8894
int i;
8995

9096
for (i = 0; i < hpriv->nports; i++) {
97+
if (ahci_ignore_port(hpriv, i))
98+
continue;
99+
91100
phy_power_off(hpriv->phys[i]);
92101
phy_exit(hpriv->phys[i]);
93102
}
@@ -432,6 +441,20 @@ static int ahci_platform_get_firmware(struct ahci_host_priv *hpriv,
432441
return 0;
433442
}
434443

444+
static u32 ahci_platform_find_max_port_id(struct device *dev)
445+
{
446+
u32 max_port = 0;
447+
448+
for_each_child_of_node_scoped(dev->of_node, child) {
449+
u32 port;
450+
451+
if (!of_property_read_u32(child, "reg", &port))
452+
max_port = max(max_port, port);
453+
}
454+
455+
return max_port;
456+
}
457+
435458
/**
436459
* ahci_platform_get_resources - Get platform resources
437460
* @pdev: platform device to get resources for
@@ -458,6 +481,7 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev,
458481
struct device *dev = &pdev->dev;
459482
struct ahci_host_priv *hpriv;
460483
u32 mask_port_map = 0;
484+
u32 max_port;
461485

462486
if (!devres_open_group(dev, NULL, GFP_KERNEL))
463487
return ERR_PTR(-ENOMEM);
@@ -549,15 +573,17 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev,
549573
goto err_out;
550574
}
551575

576+
/* find maximum port id for allocating structures */
577+
max_port = ahci_platform_find_max_port_id(dev);
552578
/*
553-
* If no sub-node was found, we still need to set nports to
554-
* one in order to be able to use the
579+
* Set nports according to maximum port id. Clamp at
580+
* AHCI_MAX_PORTS, warning message for invalid port id
581+
* is generated later.
582+
* When DT has no sub-nodes max_port is 0, nports is 1,
583+
* in order to be able to use the
555584
* ahci_platform_[en|dis]able_[phys|regulators] functions.
556585
*/
557-
if (child_nodes)
558-
hpriv->nports = child_nodes;
559-
else
560-
hpriv->nports = 1;
586+
hpriv->nports = min(AHCI_MAX_PORTS, max_port + 1);
561587

562588
hpriv->phys = devm_kcalloc(dev, hpriv->nports, sizeof(*hpriv->phys), GFP_KERNEL);
563589
if (!hpriv->phys) {
@@ -625,6 +651,8 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev,
625651
* If no sub-node was found, keep this for device tree
626652
* compatibility
627653
*/
654+
hpriv->mask_port_map |= BIT(0);
655+
628656
rc = ahci_platform_get_phy(hpriv, 0, dev, dev->of_node);
629657
if (rc)
630658
goto err_out;

drivers/ata/pata_atp867x.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ static int atp867x_reinit_one(struct pci_dev *pdev)
525525
}
526526
#endif
527527

528-
static struct pci_device_id atp867x_pci_tbl[] = {
528+
static const struct pci_device_id atp867x_pci_tbl[] = {
529529
{ PCI_VDEVICE(ARTOP, PCI_DEVICE_ID_ARTOP_ATP867A), 0 },
530530
{ PCI_VDEVICE(ARTOP, PCI_DEVICE_ID_ARTOP_ATP867B), 0 },
531531
{ },

drivers/ata/pata_piccolo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static int ata_tosh_init_one(struct pci_dev *dev, const struct pci_device_id *id
9797
return ata_pci_bmdma_init_one(dev, ppi, &tosh_sht, NULL, 0);
9898
}
9999

100-
static struct pci_device_id ata_tosh[] = {
100+
static const struct pci_device_id ata_tosh[] = {
101101
{ PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_1), },
102102
{ PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_2), },
103103
{ PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_3), },

drivers/ata/sata_gemini.c

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <linux/mfd/syscon.h>
1212
#include <linux/regmap.h>
1313
#include <linux/delay.h>
14-
#include <linux/reset.h>
1514
#include <linux/of.h>
1615
#include <linux/clk.h>
1716
#include <linux/io.h>
@@ -27,8 +26,6 @@
2726
* @muxmode: the current muxing mode
2827
* @ide_pins: if the device is using the plain IDE interface pins
2928
* @sata_bridge: if the device enables the SATA bridge
30-
* @sata0_reset: SATA0 reset handler
31-
* @sata1_reset: SATA1 reset handler
3229
* @sata0_pclk: SATA0 PCLK handler
3330
* @sata1_pclk: SATA1 PCLK handler
3431
*/
@@ -38,8 +35,6 @@ struct sata_gemini {
3835
enum gemini_muxmode muxmode;
3936
bool ide_pins;
4037
bool sata_bridge;
41-
struct reset_control *sata0_reset;
42-
struct reset_control *sata1_reset;
4338
struct clk *sata0_pclk;
4439
struct clk *sata1_pclk;
4540
};
@@ -224,18 +219,6 @@ void gemini_sata_stop_bridge(struct sata_gemini *sg, unsigned int bridge)
224219
}
225220
EXPORT_SYMBOL(gemini_sata_stop_bridge);
226221

227-
int gemini_sata_reset_bridge(struct sata_gemini *sg,
228-
unsigned int bridge)
229-
{
230-
if (bridge == 0)
231-
reset_control_reset(sg->sata0_reset);
232-
else
233-
reset_control_reset(sg->sata1_reset);
234-
msleep(10);
235-
return gemini_sata_setup_bridge(sg, bridge);
236-
}
237-
EXPORT_SYMBOL(gemini_sata_reset_bridge);
238-
239222
static int gemini_sata_bridge_init(struct sata_gemini *sg)
240223
{
241224
struct device *dev = sg->dev;
@@ -265,21 +248,6 @@ static int gemini_sata_bridge_init(struct sata_gemini *sg)
265248
return ret;
266249
}
267250

268-
sg->sata0_reset = devm_reset_control_get_exclusive(dev, "sata0");
269-
if (IS_ERR(sg->sata0_reset)) {
270-
dev_err(dev, "no SATA0 reset controller\n");
271-
clk_disable_unprepare(sg->sata1_pclk);
272-
clk_disable_unprepare(sg->sata0_pclk);
273-
return PTR_ERR(sg->sata0_reset);
274-
}
275-
sg->sata1_reset = devm_reset_control_get_exclusive(dev, "sata1");
276-
if (IS_ERR(sg->sata1_reset)) {
277-
dev_err(dev, "no SATA1 reset controller\n");
278-
clk_disable_unprepare(sg->sata1_pclk);
279-
clk_disable_unprepare(sg->sata0_pclk);
280-
return PTR_ERR(sg->sata1_reset);
281-
}
282-
283251
sata_id = readl(sg->base + GEMINI_SATA_ID);
284252
sata_phy_id = readl(sg->base + GEMINI_SATA_PHY_ID);
285253
sg->sata_bridge = true;

drivers/ata/sata_gemini.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,5 @@ bool gemini_sata_bridge_enabled(struct sata_gemini *sg, bool is_ata1);
1717
enum gemini_muxmode gemini_sata_get_muxmode(struct sata_gemini *sg);
1818
int gemini_sata_start_bridge(struct sata_gemini *sg, unsigned int bridge);
1919
void gemini_sata_stop_bridge(struct sata_gemini *sg, unsigned int bridge);
20-
int gemini_sata_reset_bridge(struct sata_gemini *sg, unsigned int bridge);
2120

2221
#endif

0 commit comments

Comments
 (0)