Skip to content

Commit 0d3603a

Browse files
committed
ata,scsi: Remove wrapper ata_sas_port_alloc()
The ata_sas_port_alloc() wrapper mainly exists in order to export the internal libata function which it wraps. The secondary reason is that it initializes some ata_port struct members. However, ata_sas_port_alloc() is only used in a single location, sas_ata_init(), which already performs some ata_port struct member initialization, so it does not make sense to spread this initialization out over two separate locations. Thus, remove the wrapper and instead export the libata function directly, and move the libsas specific ata_port initialization to sas_ata_init(), which already does some ata_port initialization. Reviewed-by: Hannes Reinecke <[email protected]> Reviewed-by: John Garry <[email protected]> Reviewed-by: Martin K. Petersen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Niklas Cassel <[email protected]>
1 parent 1228713 commit 0d3603a

File tree

5 files changed

+11
-49
lines changed

5 files changed

+11
-49
lines changed

drivers/ata/libata-core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5501,6 +5501,7 @@ struct ata_port *ata_port_alloc(struct ata_host *host)
55015501

55025502
return ap;
55035503
}
5504+
EXPORT_SYMBOL_GPL(ata_port_alloc);
55045505

55055506
void ata_port_free(struct ata_port *ap)
55065507
{

drivers/ata/libata-sata.c

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,41 +1204,6 @@ int ata_scsi_change_queue_depth(struct scsi_device *sdev, int queue_depth)
12041204
}
12051205
EXPORT_SYMBOL_GPL(ata_scsi_change_queue_depth);
12061206

1207-
/**
1208-
* ata_sas_port_alloc - Allocate port for a SAS attached SATA device
1209-
* @host: ATA host container for all SAS ports
1210-
* @port_info: Information from low-level host driver
1211-
* @shost: SCSI host that the scsi device is attached to
1212-
*
1213-
* LOCKING:
1214-
* PCI/etc. bus probe sem.
1215-
*
1216-
* RETURNS:
1217-
* ata_port pointer on success / NULL on failure.
1218-
*/
1219-
1220-
struct ata_port *ata_sas_port_alloc(struct ata_host *host,
1221-
struct ata_port_info *port_info,
1222-
struct Scsi_Host *shost)
1223-
{
1224-
struct ata_port *ap;
1225-
1226-
ap = ata_port_alloc(host);
1227-
if (!ap)
1228-
return NULL;
1229-
1230-
ap->port_no = 0;
1231-
ap->pio_mask = port_info->pio_mask;
1232-
ap->mwdma_mask = port_info->mwdma_mask;
1233-
ap->udma_mask = port_info->udma_mask;
1234-
ap->flags |= port_info->flags;
1235-
ap->ops = port_info->port_ops;
1236-
ap->cbl = ATA_CBL_SATA;
1237-
1238-
return ap;
1239-
}
1240-
EXPORT_SYMBOL_GPL(ata_sas_port_alloc);
1241-
12421207
/**
12431208
* ata_sas_device_configure - Default device_configure routine for libata
12441209
* devices

drivers/ata/libata.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ extern void ata_link_init(struct ata_port *ap, struct ata_link *link, int pmp);
8181
extern int sata_link_init_spd(struct ata_link *link);
8282
extern int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg);
8383
extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg);
84-
extern struct ata_port *ata_port_alloc(struct ata_host *host);
8584
extern const char *sata_spd_string(unsigned int spd);
8685
extern unsigned int ata_read_log_page(struct ata_device *dev, u8 log,
8786
u8 page, void *buf, unsigned int sectors);

drivers/scsi/libsas/sas_ata.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -572,15 +572,6 @@ static struct ata_port_operations sas_sata_ops = {
572572
.end_eh = sas_ata_end_eh,
573573
};
574574

575-
static struct ata_port_info sata_port_info = {
576-
.flags = ATA_FLAG_SATA | ATA_FLAG_PIO_DMA | ATA_FLAG_NCQ |
577-
ATA_FLAG_SAS_HOST | ATA_FLAG_FPDMA_AUX,
578-
.pio_mask = ATA_PIO4,
579-
.mwdma_mask = ATA_MWDMA2,
580-
.udma_mask = ATA_UDMA6,
581-
.port_ops = &sas_sata_ops
582-
};
583-
584575
int sas_ata_init(struct domain_device *found_dev)
585576
{
586577
struct sas_ha_struct *ha = found_dev->port->ha;
@@ -597,13 +588,20 @@ int sas_ata_init(struct domain_device *found_dev)
597588

598589
ata_host_init(ata_host, ha->dev, &sas_sata_ops);
599590

600-
ap = ata_sas_port_alloc(ata_host, &sata_port_info, shost);
591+
ap = ata_port_alloc(ata_host);
601592
if (!ap) {
602-
pr_err("ata_sas_port_alloc failed.\n");
593+
pr_err("ata_port_alloc failed.\n");
603594
rc = -ENODEV;
604595
goto free_host;
605596
}
606597

598+
ap->port_no = 0;
599+
ap->pio_mask = ATA_PIO4;
600+
ap->mwdma_mask = ATA_MWDMA2;
601+
ap->udma_mask = ATA_UDMA6;
602+
ap->flags |= ATA_FLAG_SATA | ATA_FLAG_PIO_DMA | ATA_FLAG_NCQ |
603+
ATA_FLAG_SAS_HOST | ATA_FLAG_FPDMA_AUX;
604+
ap->ops = &sas_sata_ops;
607605
ap->private_data = found_dev;
608606
ap->cbl = ATA_CBL_SATA;
609607
ap->scsi_host = shost;

include/linux/libata.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,9 +1244,8 @@ extern int sata_link_debounce(struct ata_link *link,
12441244
extern int sata_link_scr_lpm(struct ata_link *link, enum ata_lpm_policy policy,
12451245
bool spm_wakeup);
12461246
extern int ata_slave_link_init(struct ata_port *ap);
1247-
extern struct ata_port *ata_sas_port_alloc(struct ata_host *,
1248-
struct ata_port_info *, struct Scsi_Host *);
12491247
extern void ata_port_probe(struct ata_port *ap);
1248+
extern struct ata_port *ata_port_alloc(struct ata_host *host);
12501249
extern void ata_port_free(struct ata_port *ap);
12511250
extern int ata_tport_add(struct device *parent, struct ata_port *ap);
12521251
extern void ata_tport_delete(struct ata_port *ap);

0 commit comments

Comments
 (0)