Skip to content

Commit 1c1fbb8

Browse files
committed
ata: libata: Assign print_id at port allocation time
While the assignment of ap->print_id could have been moved to ata_host_alloc(), let's simply move it to ata_port_alloc(). If you allocate a port, you want to give it a unique name that can be used for printing. By moving the ap->print_id assignment to ata_port_alloc(), means that we can also remove the ap->print_id assignment from ata_sas_port_alloc(). This will allow a LLD to use the ata_port_*() print functions before ata_host_register() has been called. Reviewed-by: Damien Le Moal <[email protected]> Reviewed-by: Hannes Reinecke <[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 1dd63a6 commit 1c1fbb8

File tree

3 files changed

+1
-7
lines changed

3 files changed

+1
-7
lines changed

drivers/ata/libata-core.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5470,7 +5470,7 @@ struct ata_port *ata_port_alloc(struct ata_host *host)
54705470

54715471
ap->pflags |= ATA_PFLAG_INITIALIZING | ATA_PFLAG_FROZEN;
54725472
ap->lock = &host->lock;
5473-
ap->print_id = -1;
5473+
ap->print_id = atomic_inc_return(&ata_print_id);
54745474
ap->host = host;
54755475
ap->dev = host->dev;
54765476

@@ -5907,10 +5907,6 @@ int ata_host_register(struct ata_host *host, const struct scsi_host_template *sh
59075907
return -EINVAL;
59085908
}
59095909

5910-
/* give ports names and add SCSI hosts */
5911-
for (i = 0; i < host->n_ports; i++)
5912-
host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
5913-
59145910
/* Create associated sysfs transport objects */
59155911
for (i = 0; i < host->n_ports; i++) {
59165912
rc = ata_tport_add(host->dev,host->ports[i]);

drivers/ata/libata-sata.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,6 @@ struct ata_port *ata_sas_port_alloc(struct ata_host *host,
12341234
ap->flags |= port_info->flags;
12351235
ap->ops = port_info->port_ops;
12361236
ap->cbl = ATA_CBL_SATA;
1237-
ap->print_id = atomic_inc_return(&ata_print_id);
12381237

12391238
return ap;
12401239
}

drivers/ata/libata.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ enum {
3232

3333
#define ATA_PORT_TYPE_NAME "ata_port"
3434

35-
extern atomic_t ata_print_id;
3635
extern int atapi_passthru16;
3736
extern int libata_fua;
3837
extern int libata_noacpi;

0 commit comments

Comments
 (0)