Skip to content

Commit

Permalink
[SCSI] struct device - replace bus_id with dev_name(), dev_set_name()
Browse files Browse the repository at this point in the history
[jejb: limit ioctl to returning 20 characters to avoid overrun
       on long device names and add a few more conversions]
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
  • Loading branch information
Kay Sievers authored and James Bottomley committed Jan 2, 2009
1 parent b58602a commit 71610f5
Show file tree
Hide file tree
Showing 26 changed files with 79 additions and 81 deletions.
8 changes: 4 additions & 4 deletions drivers/misc/enclosure.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ enclosure_register(struct device *dev, const char *name, int components,
edev->edev.class = &enclosure_class;
edev->edev.parent = get_device(dev);
edev->cb = cb;
snprintf(edev->edev.bus_id, BUS_ID_SIZE, "%s", name);
dev_set_name(&edev->edev, name);
err = device_register(&edev->edev);
if (err)
goto err;
Expand Down Expand Up @@ -170,7 +170,7 @@ EXPORT_SYMBOL_GPL(enclosure_unregister);
static void enclosure_link_name(struct enclosure_component *cdev, char *name)
{
strcpy(name, "enclosure_device:");
strcat(name, cdev->cdev.bus_id);
strcat(name, dev_name(&cdev->cdev));
}

static void enclosure_remove_links(struct enclosure_component *cdev)
Expand Down Expand Up @@ -256,9 +256,9 @@ enclosure_component_register(struct enclosure_device *edev,
cdev = &ecomp->cdev;
cdev->parent = get_device(&edev->edev);
if (name)
snprintf(cdev->bus_id, BUS_ID_SIZE, "%s", name);
dev_set_name(cdev, name);
else
snprintf(cdev->bus_id, BUS_ID_SIZE, "%u", number);
dev_set_name(cdev, "%u", number);

cdev->release = enclosure_component_release;
cdev->groups = enclosure_groups;
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/NCR_D700.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ NCR_D700_probe(struct device *dev)
return -ENOMEM;

p->dev = dev;
snprintf(p->name, sizeof(p->name), "D700(%s)", dev->bus_id);
snprintf(p->name, sizeof(p->name), "D700(%s)", dev_name(dev));
if (request_irq(irq, NCR_D700_intr, IRQF_SHARED, p->name, p)) {
printk(KERN_ERR "D700: request_irq failed\n");
kfree(p);
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/advansys.c
Original file line number Diff line number Diff line change
Expand Up @@ -2527,7 +2527,7 @@ static void asc_prt_scsi_host(struct Scsi_Host *s)
{
struct asc_board *boardp = shost_priv(s);

printk("Scsi_Host at addr 0x%p, device %s\n", s, boardp->dev->bus_id);
printk("Scsi_Host at addr 0x%p, device %s\n", s, dev_name(boardp->dev));
printk(" host_busy %u, host_no %d, last_reset %d,\n",
s->host_busy, s->host_no, (unsigned)s->last_reset);

Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/aic94xx/aic94xx_tmf.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ int asd_I_T_nexus_reset(struct domain_device *dev)
asd_clear_nexus_I_T(dev, NEXUS_PHASE_PRE);
/* send a hard reset */
ASD_DPRINTK("sending %s reset to %s\n",
reset_type ? "hard" : "soft", phy->dev.bus_id);
reset_type ? "hard" : "soft", dev_name(&phy->dev));
res = sas_phy_reset(phy, reset_type);
if (res == TMF_RESP_FUNC_COMPLETE) {
/* wait for the maximum settle time */
Expand Down
6 changes: 2 additions & 4 deletions drivers/scsi/hosts.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
shost->dma_boundary = 0xffffffff;

device_initialize(&shost->shost_gendev);
snprintf(shost->shost_gendev.bus_id, BUS_ID_SIZE, "host%d",
shost->host_no);
dev_set_name(&shost->shost_gendev, "host%d", shost->host_no);
#ifndef CONFIG_SYSFS_DEPRECATED
shost->shost_gendev.bus = &scsi_bus_type;
#endif
Expand All @@ -398,8 +397,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
device_initialize(&shost->shost_dev);
shost->shost_dev.parent = &shost->shost_gendev;
shost->shost_dev.class = &shost_class;
snprintf(shost->shost_dev.bus_id, BUS_ID_SIZE, "host%d",
shost->host_no);
dev_set_name(&shost->shost_dev, "host%d", shost->host_no);
shost->shost_dev.groups = scsi_sysfs_shost_attr_groups;

shost->ehandler = kthread_run(scsi_error_handler, shost,
Expand Down
4 changes: 2 additions & 2 deletions drivers/scsi/ibmvscsi/ibmvfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1145,10 +1145,10 @@ static void ibmvfc_set_login_info(struct ibmvfc_host *vhost)
login_info->async.len = vhost->async_crq.size * sizeof(*vhost->async_crq.msgs);
strncpy(login_info->partition_name, vhost->partition_name, IBMVFC_MAX_NAME);
strncpy(login_info->device_name,
vhost->host->shost_gendev.bus_id, IBMVFC_MAX_NAME);
dev_name(&vhost->host->shost_gendev), IBMVFC_MAX_NAME);

location = of_get_property(of_node, "ibm,loc-code", NULL);
location = location ? location : vhost->dev->bus_id;
location = location ? location : dev_name(vhost->dev);
strncpy(login_info->drc_name, location, IBMVFC_MAX_NAME);
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/ipr.c
Original file line number Diff line number Diff line change
Expand Up @@ -2184,7 +2184,7 @@ static void ipr_dump_location_data(struct ipr_ioa_cfg *ioa_cfg,
sizeof(struct ipr_dump_entry_header);
driver_dump->location_entry.hdr.data_type = IPR_DUMP_DATA_TYPE_ASCII;
driver_dump->location_entry.hdr.id = IPR_DUMP_LOCATION_ID;
strcpy(driver_dump->location_entry.location, ioa_cfg->pdev->dev.bus_id);
strcpy(driver_dump->location_entry.location, dev_name(&ioa_cfg->pdev->dev));
driver_dump->hdr.num_entries++;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/ipr.h
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,7 @@ struct ipr_dump_entry_header {

struct ipr_dump_location_entry {
struct ipr_dump_entry_header hdr;
u8 location[BUS_ID_SIZE];
u8 location[20];
}__attribute__((packed));

struct ipr_dump_trace_entry {
Expand Down
3 changes: 1 addition & 2 deletions drivers/scsi/lasi700.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ lasi700_probe(struct parisc_device *dev)

hostdata = kzalloc(sizeof(*hostdata), GFP_KERNEL);
if (!hostdata) {
printk(KERN_ERR "%s: Failed to allocate host data\n",
dev->dev.bus_id);
dev_printk(KERN_ERR, dev, "Failed to allocate host data\n");
return -ENOMEM;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/libsas/sas_discover.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ int sas_notify_lldd_dev_found(struct domain_device *dev)
if (res) {
printk("sas: driver on pcidev %s cannot handle "
"device %llx, error:%d\n",
sas_ha->dev->bus_id,
dev_name(sas_ha->dev),
SAS_ADDR(dev->sas_addr), res);
}
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/libsas/sas_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void sas_dprint_phye(int phyid, enum phy_event pe)

void sas_dprint_hae(struct sas_ha_struct *sas_ha, enum ha_event he)
{
SAS_DPRINTK("ha %s: %s event\n", sas_ha->dev->bus_id,
SAS_DPRINTK("ha %s: %s event\n", dev_name(sas_ha->dev),
sas_hae_str[he]);
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/libsas/sas_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ static void sas_form_port(struct asd_sas_phy *phy)
sas_port_add_phy(port->port, phy->phy);

SAS_DPRINTK("%s added to %s, phy_mask:0x%x (%16llx)\n",
phy->phy->dev.bus_id,port->port->dev.bus_id,
dev_name(&phy->phy->dev), dev_name(&port->port->dev),
port->phy_mask,
SAS_ADDR(port->attached_sas_addr));

Expand Down
3 changes: 1 addition & 2 deletions drivers/scsi/raid_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,7 @@ int raid_component_add(struct raid_template *r,struct device *raid_dev,
rc->dev.parent = get_device(component_dev);
rc->num = rd->component_count++;

snprintf(rc->dev.bus_id, sizeof(rc->dev.bus_id),
"component-%d", rc->num);
dev_set_name(&rc->dev, "component-%d", rc->num);
list_add_tail(&rc->node, &rd->component_list);
rc->dev.class = &raid_class.class;
err = device_add(&rc->dev);
Expand Down
4 changes: 2 additions & 2 deletions drivers/scsi/scsi_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -2508,7 +2508,7 @@ static void pseudo_0_release(struct device *dev)
}

static struct device pseudo_primary = {
.bus_id = "pseudo_0",
.init_name = "pseudo_0",
.release = pseudo_0_release,
};

Expand Down Expand Up @@ -2680,7 +2680,7 @@ static int sdebug_add_adapter(void)
sdbg_host->dev.bus = &pseudo_lld_bus;
sdbg_host->dev.parent = &pseudo_primary;
sdbg_host->dev.release = &sdebug_release_adapter;
sprintf(sdbg_host->dev.bus_id, "adapter%d", scsi_debug_add_host);
dev_set_name(&sdbg_host->dev, "adapter%d", scsi_debug_add_host);

error = device_register(&sdbg_host->dev);

Expand Down
9 changes: 8 additions & 1 deletion drivers/scsi/scsi_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,17 @@ EXPORT_SYMBOL(scsi_set_medium_removal);
static int scsi_ioctl_get_pci(struct scsi_device *sdev, void __user *arg)
{
struct device *dev = scsi_get_device(sdev->host);
const char *name;

if (!dev)
return -ENXIO;
return copy_to_user(arg, dev->bus_id, sizeof(dev->bus_id))? -EFAULT: 0;

name = dev_name(dev);

/* compatibility with old ioctl which only returned
* 20 characters */
return copy_to_user(arg, name, min(strlen(name), (size_t)20))
? -EFAULT: 0;
}


Expand Down
7 changes: 3 additions & 4 deletions drivers/scsi/scsi_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,7 @@ static struct scsi_target *scsi_alloc_target(struct device *parent,
device_initialize(dev);
starget->reap_ref = 1;
dev->parent = get_device(parent);
sprintf(dev->bus_id, "target%d:%d:%d",
shost->host_no, channel, id);
dev_set_name(dev, "target%d:%d:%d", shost->host_no, channel, id);
#ifndef CONFIG_SYSFS_DEPRECATED
dev->bus = &scsi_bus_type;
#endif
Expand Down Expand Up @@ -1021,7 +1020,7 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget,
if (rescan || !scsi_device_created(sdev)) {
SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO
"scsi scan: device exists on %s\n",
sdev->sdev_gendev.bus_id));
dev_name(&sdev->sdev_gendev)));
if (sdevp)
*sdevp = sdev;
else
Expand Down Expand Up @@ -1160,7 +1159,7 @@ static void scsi_sequential_lun_scan(struct scsi_target *starget,
struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);

SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO "scsi scan: Sequential scan of"
"%s\n", starget->dev.bus_id));
"%s\n", dev_name(&starget->dev)));

max_dev_lun = min(max_scsi_luns, shost->max_lun);
/*
Expand Down
12 changes: 5 additions & 7 deletions drivers/scsi/scsi_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1079,16 +1079,14 @@ void scsi_sysfs_device_initialize(struct scsi_device *sdev)
device_initialize(&sdev->sdev_gendev);
sdev->sdev_gendev.bus = &scsi_bus_type;
sdev->sdev_gendev.type = &scsi_dev_type;
sprintf(sdev->sdev_gendev.bus_id,"%d:%d:%d:%d",
sdev->host->host_no, sdev->channel, sdev->id,
sdev->lun);

dev_set_name(&sdev->sdev_gendev, "%d:%d:%d:%d",
sdev->host->host_no, sdev->channel, sdev->id, sdev->lun);

device_initialize(&sdev->sdev_dev);
sdev->sdev_dev.parent = &sdev->sdev_gendev;
sdev->sdev_dev.class = &sdev_class;
snprintf(sdev->sdev_dev.bus_id, BUS_ID_SIZE,
"%d:%d:%d:%d", sdev->host->host_no,
sdev->channel, sdev->id, sdev->lun);
dev_set_name(&sdev->sdev_dev, "%d:%d:%d:%d",
sdev->host->host_no, sdev->channel, sdev->id, sdev->lun);
sdev->scsi_level = starget->scsi_level;
transport_setup_device(&sdev->sdev_gendev);
spin_lock_irqsave(shost->host_lock, flags);
Expand Down
18 changes: 9 additions & 9 deletions drivers/scsi/scsi_transport_fc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2486,8 +2486,8 @@ fc_rport_create(struct Scsi_Host *shost, int channel,
device_initialize(dev); /* takes self reference */
dev->parent = get_device(&shost->shost_gendev); /* parent reference */
dev->release = fc_rport_dev_release;
sprintf(dev->bus_id, "rport-%d:%d-%d",
shost->host_no, channel, rport->number);
dev_set_name(dev, "rport-%d:%d-%d",
shost->host_no, channel, rport->number);
transport_setup_device(dev);

error = device_add(dev);
Expand Down Expand Up @@ -3164,8 +3164,8 @@ fc_vport_setup(struct Scsi_Host *shost, int channel, struct device *pdev,
device_initialize(dev); /* takes self reference */
dev->parent = get_device(pdev); /* takes parent reference */
dev->release = fc_vport_dev_release;
sprintf(dev->bus_id, "vport-%d:%d-%d",
shost->host_no, channel, vport->number);
dev_set_name(dev, "vport-%d:%d-%d",
shost->host_no, channel, vport->number);
transport_setup_device(dev);

error = device_add(dev);
Expand All @@ -3188,19 +3188,19 @@ fc_vport_setup(struct Scsi_Host *shost, int channel, struct device *pdev,
*/
if (pdev != &shost->shost_gendev) {
error = sysfs_create_link(&shost->shost_gendev.kobj,
&dev->kobj, dev->bus_id);
&dev->kobj, dev_name(dev));
if (error)
printk(KERN_ERR
"%s: Cannot create vport symlinks for "
"%s, err=%d\n",
__func__, dev->bus_id, error);
__func__, dev_name(dev), error);
}
spin_lock_irqsave(shost->host_lock, flags);
vport->flags &= ~FC_VPORT_CREATING;
spin_unlock_irqrestore(shost->host_lock, flags);

dev_printk(KERN_NOTICE, pdev,
"%s created via shost%d channel %d\n", dev->bus_id,
"%s created via shost%d channel %d\n", dev_name(dev),
shost->host_no, channel);

*ret_vport = vport;
Expand Down Expand Up @@ -3297,7 +3297,7 @@ fc_vport_terminate(struct fc_vport *vport)
return stat;

if (dev->parent != &shost->shost_gendev)
sysfs_remove_link(&shost->shost_gendev.kobj, dev->bus_id);
sysfs_remove_link(&shost->shost_gendev.kobj, dev_name(dev));
transport_remove_device(dev);
device_del(dev);
transport_destroy_device(dev);
Expand Down Expand Up @@ -3329,7 +3329,7 @@ fc_vport_sched_delete(struct work_struct *work)
dev_printk(KERN_ERR, vport->dev.parent,
"%s: %s could not be deleted created via "
"shost%d channel %d - error %d\n", __func__,
vport->dev.bus_id, vport->shost->host_no,
dev_name(&vport->dev), vport->shost->host_no,
vport->channel, stat);
}

Expand Down
11 changes: 4 additions & 7 deletions drivers/scsi/scsi_transport_iscsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ iscsi_create_endpoint(int dd_size)

ep->id = id;
ep->dev.class = &iscsi_endpoint_class;
snprintf(ep->dev.bus_id, BUS_ID_SIZE, "ep-%llu",
(unsigned long long) id);
dev_set_name(&ep->dev, "ep-%llu", (unsigned long long) id);
err = device_register(&ep->dev);
if (err)
goto free_ep;
Expand Down Expand Up @@ -724,8 +723,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
}
session->target_id = id;

snprintf(session->dev.bus_id, BUS_ID_SIZE, "session%u",
session->sid);
dev_set_name(&session->dev, "session%u", session->sid);
err = device_add(&session->dev);
if (err) {
iscsi_cls_session_printk(KERN_ERR, session,
Expand Down Expand Up @@ -898,8 +896,7 @@ iscsi_create_conn(struct iscsi_cls_session *session, int dd_size, uint32_t cid)
if (!get_device(&session->dev))
goto free_conn;

snprintf(conn->dev.bus_id, BUS_ID_SIZE, "connection%d:%u",
session->sid, cid);
dev_set_name(&conn->dev, "connection%d:%u", session->sid, cid);
conn->dev.parent = &session->dev;
conn->dev.release = iscsi_conn_release;
err = device_register(&conn->dev);
Expand Down Expand Up @@ -1816,7 +1813,7 @@ iscsi_register_transport(struct iscsi_transport *tt)
priv->t.create_work_queue = 1;

priv->dev.class = &iscsi_transport_class;
snprintf(priv->dev.bus_id, BUS_ID_SIZE, "%s", tt->name);
dev_set_name(&priv->dev, "%s", tt->name);
err = device_register(&priv->dev);
if (err)
goto free_priv;
Expand Down
Loading

0 comments on commit 71610f5

Please sign in to comment.