Skip to content

Commit

Permalink
libata: make ata_print_id atomic
Browse files Browse the repository at this point in the history
This variable is incremented from multiple contexts (module_init via
libata-lldds and the libsas discovery thread).  Make it atomic to head
off any chance of libsas and libata creating duplicate ids.

Acked-by: Jacek Danecki <jacek.danecki@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
  • Loading branch information
Dan Williams authored and Jeff Garzik committed Apr 12, 2012
1 parent 99b80e9 commit 85d6725
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions drivers/ata/libata-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
static void ata_dev_xfermask(struct ata_device *dev);
static unsigned long ata_dev_blacklisted(const struct ata_device *dev);

unsigned int ata_print_id = 1;
atomic_t ata_print_id = ATOMIC_INIT(1);

struct ata_force_param {
const char *name;
Expand Down Expand Up @@ -6029,7 +6029,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)

/* give ports names and add SCSI hosts */
for (i = 0; i < host->n_ports; i++)
host->ports[i]->print_id = ata_print_id++;
host->ports[i]->print_id = atomic_inc_return(&ata_print_id);


/* Create associated sysfs transport objects */
Expand Down
4 changes: 2 additions & 2 deletions drivers/ata/libata-scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -3843,7 +3843,7 @@ int ata_sas_async_port_init(struct ata_port *ap)
int rc = ap->ops->port_start(ap);

if (!rc) {
ap->print_id = ata_print_id++;
ap->print_id = atomic_inc_return(&ata_print_id);
__ata_port_probe(ap);
}

Expand All @@ -3867,7 +3867,7 @@ int ata_sas_port_init(struct ata_port *ap)
int rc = ap->ops->port_start(ap);

if (!rc) {
ap->print_id = ata_print_id++;
ap->print_id = atomic_inc_return(&ata_print_id);
rc = ata_port_probe(ap);
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/ata/libata.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ enum {
ATA_DNXFER_QUIET = (1 << 31),
};

extern unsigned int ata_print_id;
extern atomic_t ata_print_id;
extern int atapi_passthru16;
extern int libata_fua;
extern int libata_noacpi;
Expand Down

0 comments on commit 85d6725

Please sign in to comment.