Skip to content

Commit eba9eba

Browse files
author
Stefan Richter
committed
firewire: sbp2: use dev_printk API
All messages are uniformly prefixed by driver name and device name now. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
1 parent 64d2172 commit eba9eba

1 file changed

Lines changed: 51 additions & 42 deletions

File tree

‎drivers/firewire/sbp2.c‎

Lines changed: 51 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ static void sbp2_queue_work(struct sbp2_logical_unit *lu, unsigned long delay)
165165
*/
166166
struct sbp2_target {
167167
struct fw_unit *unit;
168-
const char *bus_id;
169168
struct list_head lu_list;
170169

171170
u64 management_agent_address;
@@ -181,11 +180,21 @@ struct sbp2_target {
181180
int blocked; /* ditto */
182181
};
183182

184-
static struct fw_device *target_device(struct sbp2_target *tgt)
183+
static struct fw_device *target_parent_device(struct sbp2_target *tgt)
185184
{
186185
return fw_parent_device(tgt->unit);
187186
}
188187

188+
static const struct device *tgt_dev(const struct sbp2_target *tgt)
189+
{
190+
return &tgt->unit->device;
191+
}
192+
193+
static const struct device *lu_dev(const struct sbp2_logical_unit *lu)
194+
{
195+
return &lu->tgt->unit->device;
196+
}
197+
189198
/* Impossible login_id, to detect logout attempt before successful login */
190199
#define INVALID_LOGIN_ID 0x10000
191200

@@ -430,7 +439,8 @@ static void sbp2_status_write(struct fw_card *card, struct fw_request *request,
430439
memcpy(status.data, payload + 8, length - 8);
431440

432441
if (STATUS_GET_SOURCE(status) == 2 || STATUS_GET_SOURCE(status) == 3) {
433-
fw_notify("non-orb related status write, not handled\n");
442+
dev_notice(lu_dev(lu),
443+
"non-ORB related status write, not handled\n");
434444
fw_send_response(card, request, RCODE_COMPLETE);
435445
return;
436446
}
@@ -451,7 +461,7 @@ static void sbp2_status_write(struct fw_card *card, struct fw_request *request,
451461
orb->callback(orb, &status);
452462
kref_put(&orb->kref, free_orb); /* orb callback reference */
453463
} else {
454-
fw_error("status write for unknown orb\n");
464+
dev_err(lu_dev(lu), "status write for unknown ORB\n");
455465
}
456466

457467
fw_send_response(card, request, RCODE_COMPLETE);
@@ -492,7 +502,7 @@ static void complete_transaction(struct fw_card *card, int rcode,
492502
static void sbp2_send_orb(struct sbp2_orb *orb, struct sbp2_logical_unit *lu,
493503
int node_id, int generation, u64 offset)
494504
{
495-
struct fw_device *device = target_device(lu->tgt);
505+
struct fw_device *device = target_parent_device(lu->tgt);
496506
struct sbp2_pointer orb_pointer;
497507
unsigned long flags;
498508

@@ -513,7 +523,7 @@ static void sbp2_send_orb(struct sbp2_orb *orb, struct sbp2_logical_unit *lu,
513523

514524
static int sbp2_cancel_orbs(struct sbp2_logical_unit *lu)
515525
{
516-
struct fw_device *device = target_device(lu->tgt);
526+
struct fw_device *device = target_parent_device(lu->tgt);
517527
struct sbp2_orb *orb, *next;
518528
struct list_head list;
519529
unsigned long flags;
@@ -552,7 +562,7 @@ static int sbp2_send_management_orb(struct sbp2_logical_unit *lu, int node_id,
552562
int generation, int function,
553563
int lun_or_login_id, void *response)
554564
{
555-
struct fw_device *device = target_device(lu->tgt);
565+
struct fw_device *device = target_parent_device(lu->tgt);
556566
struct sbp2_management_orb *orb;
557567
unsigned int timeout;
558568
int retval = -ENOMEM;
@@ -612,20 +622,20 @@ static int sbp2_send_management_orb(struct sbp2_logical_unit *lu, int node_id,
612622

613623
retval = -EIO;
614624
if (sbp2_cancel_orbs(lu) == 0) {
615-
fw_error("%s: orb reply timed out, rcode=0x%02x\n",
616-
lu->tgt->bus_id, orb->base.rcode);
625+
dev_err(lu_dev(lu), "ORB reply timed out, rcode 0x%02x\n",
626+
orb->base.rcode);
617627
goto out;
618628
}
619629

620630
if (orb->base.rcode != RCODE_COMPLETE) {
621-
fw_error("%s: management write failed, rcode 0x%02x\n",
622-
lu->tgt->bus_id, orb->base.rcode);
631+
dev_err(lu_dev(lu), "management write failed, rcode 0x%02x\n",
632+
orb->base.rcode);
623633
goto out;
624634
}
625635

626636
if (STATUS_GET_RESPONSE(orb->status) != 0 ||
627637
STATUS_GET_SBP_STATUS(orb->status) != 0) {
628-
fw_error("%s: error status: %d:%d\n", lu->tgt->bus_id,
638+
dev_err(lu_dev(lu), "error status: %d:%d\n",
629639
STATUS_GET_RESPONSE(orb->status),
630640
STATUS_GET_SBP_STATUS(orb->status));
631641
goto out;
@@ -648,7 +658,7 @@ static int sbp2_send_management_orb(struct sbp2_logical_unit *lu, int node_id,
648658

649659
static void sbp2_agent_reset(struct sbp2_logical_unit *lu)
650660
{
651-
struct fw_device *device = target_device(lu->tgt);
661+
struct fw_device *device = target_parent_device(lu->tgt);
652662
__be32 d = 0;
653663

654664
fw_run_transaction(device->card, TCODE_WRITE_QUADLET_REQUEST,
@@ -665,7 +675,7 @@ static void complete_agent_reset_write_no_wait(struct fw_card *card,
665675

666676
static void sbp2_agent_reset_no_wait(struct sbp2_logical_unit *lu)
667677
{
668-
struct fw_device *device = target_device(lu->tgt);
678+
struct fw_device *device = target_parent_device(lu->tgt);
669679
struct fw_transaction *t;
670680
static __be32 d;
671681

@@ -704,7 +714,7 @@ static inline void sbp2_allow_block(struct sbp2_logical_unit *lu)
704714
static void sbp2_conditionally_block(struct sbp2_logical_unit *lu)
705715
{
706716
struct sbp2_target *tgt = lu->tgt;
707-
struct fw_card *card = target_device(tgt)->card;
717+
struct fw_card *card = target_parent_device(tgt)->card;
708718
struct Scsi_Host *shost =
709719
container_of((void *)tgt, struct Scsi_Host, hostdata[0]);
710720
unsigned long flags;
@@ -728,7 +738,7 @@ static void sbp2_conditionally_block(struct sbp2_logical_unit *lu)
728738
static void sbp2_conditionally_unblock(struct sbp2_logical_unit *lu)
729739
{
730740
struct sbp2_target *tgt = lu->tgt;
731-
struct fw_card *card = target_device(tgt)->card;
741+
struct fw_card *card = target_parent_device(tgt)->card;
732742
struct Scsi_Host *shost =
733743
container_of((void *)tgt, struct Scsi_Host, hostdata[0]);
734744
unsigned long flags;
@@ -753,7 +763,7 @@ static void sbp2_conditionally_unblock(struct sbp2_logical_unit *lu)
753763
*/
754764
static void sbp2_unblock(struct sbp2_target *tgt)
755765
{
756-
struct fw_card *card = target_device(tgt)->card;
766+
struct fw_card *card = target_parent_device(tgt)->card;
757767
struct Scsi_Host *shost =
758768
container_of((void *)tgt, struct Scsi_Host, hostdata[0]);
759769
unsigned long flags;
@@ -794,7 +804,7 @@ static int sbp2_lun2int(u16 lun)
794804
*/
795805
static void sbp2_set_busy_timeout(struct sbp2_logical_unit *lu)
796806
{
797-
struct fw_device *device = target_device(lu->tgt);
807+
struct fw_device *device = target_parent_device(lu->tgt);
798808
__be32 d = cpu_to_be32(SBP2_CYCLE_LIMIT | SBP2_RETRY_LIMIT);
799809

800810
fw_run_transaction(device->card, TCODE_WRITE_QUADLET_REQUEST,
@@ -809,7 +819,7 @@ static void sbp2_login(struct work_struct *work)
809819
struct sbp2_logical_unit *lu =
810820
container_of(work, struct sbp2_logical_unit, work.work);
811821
struct sbp2_target *tgt = lu->tgt;
812-
struct fw_device *device = target_device(tgt);
822+
struct fw_device *device = target_parent_device(tgt);
813823
struct Scsi_Host *shost;
814824
struct scsi_device *sdev;
815825
struct sbp2_login_response response;
@@ -833,8 +843,8 @@ static void sbp2_login(struct work_struct *work)
833843
if (lu->retries++ < 5) {
834844
sbp2_queue_work(lu, DIV_ROUND_UP(HZ, 5));
835845
} else {
836-
fw_error("%s: failed to login to LUN %04x\n",
837-
tgt->bus_id, lu->lun);
846+
dev_err(tgt_dev(tgt), "failed to login to LUN %04x\n",
847+
lu->lun);
838848
/* Let any waiting I/O fail from now on. */
839849
sbp2_unblock(lu->tgt);
840850
}
@@ -851,8 +861,8 @@ static void sbp2_login(struct work_struct *work)
851861
<< 32) | be32_to_cpu(response.command_block_agent.low);
852862
lu->login_id = be32_to_cpu(response.misc) & 0xffff;
853863

854-
fw_notify("%s: logged in to LUN %04x (%d retries)\n",
855-
tgt->bus_id, lu->lun, lu->retries);
864+
dev_notice(tgt_dev(tgt), "logged in to LUN %04x (%d retries)\n",
865+
lu->lun, lu->retries);
856866

857867
/* set appropriate retry limit(s) in BUSY_TIMEOUT register */
858868
sbp2_set_busy_timeout(lu);
@@ -919,7 +929,7 @@ static void sbp2_reconnect(struct work_struct *work)
919929
struct sbp2_logical_unit *lu =
920930
container_of(work, struct sbp2_logical_unit, work.work);
921931
struct sbp2_target *tgt = lu->tgt;
922-
struct fw_device *device = target_device(tgt);
932+
struct fw_device *device = target_parent_device(tgt);
923933
int generation, node_id, local_node_id;
924934

925935
if (fw_device_is_shutdown(device))
@@ -943,7 +953,7 @@ static void sbp2_reconnect(struct work_struct *work)
943953
smp_rmb(); /* get current card generation */
944954
if (generation == device->card->generation ||
945955
lu->retries++ >= 5) {
946-
fw_error("%s: failed to reconnect\n", tgt->bus_id);
956+
dev_err(tgt_dev(tgt), "failed to reconnect\n");
947957
lu->retries = 0;
948958
PREPARE_DELAYED_WORK(&lu->work, sbp2_login);
949959
}
@@ -957,8 +967,8 @@ static void sbp2_reconnect(struct work_struct *work)
957967
smp_wmb(); /* node IDs must not be older than generation */
958968
lu->generation = generation;
959969

960-
fw_notify("%s: reconnected to LUN %04x (%d retries)\n",
961-
tgt->bus_id, lu->lun, lu->retries);
970+
dev_notice(tgt_dev(tgt), "reconnected to LUN %04x (%d retries)\n",
971+
lu->lun, lu->retries);
962972

963973
sbp2_agent_reset(lu);
964974
sbp2_cancel_orbs(lu);
@@ -1068,8 +1078,8 @@ static void sbp2_clamp_management_orb_timeout(struct sbp2_target *tgt)
10681078
unsigned int timeout = tgt->mgt_orb_timeout;
10691079

10701080
if (timeout > 40000)
1071-
fw_notify("%s: %ds mgt_ORB_timeout limited to 40s\n",
1072-
tgt->bus_id, timeout / 1000);
1081+
dev_notice(tgt_dev(tgt), "%ds mgt_ORB_timeout limited to 40s\n",
1082+
timeout / 1000);
10731083

10741084
tgt->mgt_orb_timeout = clamp_val(timeout, 5000, 40000);
10751085
}
@@ -1081,9 +1091,9 @@ static void sbp2_init_workarounds(struct sbp2_target *tgt, u32 model,
10811091
unsigned int w = sbp2_param_workarounds;
10821092

10831093
if (w)
1084-
fw_notify("Please notify linux1394-devel@lists.sourceforge.net "
1085-
"if you need the workarounds parameter for %s\n",
1086-
tgt->bus_id);
1094+
dev_notice(tgt_dev(tgt),
1095+
"Please notify linux1394-devel@lists.sf.net "
1096+
"if you need the workarounds parameter\n");
10871097

10881098
if (w & SBP2_WORKAROUND_OVERRIDE)
10891099
goto out;
@@ -1103,9 +1113,9 @@ static void sbp2_init_workarounds(struct sbp2_target *tgt, u32 model,
11031113
}
11041114
out:
11051115
if (w)
1106-
fw_notify("Workarounds for %s: 0x%x "
1107-
"(firmware_revision 0x%06x, model_id 0x%06x)\n",
1108-
tgt->bus_id, w, firmware_revision, model);
1116+
dev_notice(tgt_dev(tgt), "workarounds 0x%x "
1117+
"(firmware_revision 0x%06x, model_id 0x%06x)\n",
1118+
w, firmware_revision, model);
11091119
tgt->workarounds = w;
11101120
}
11111121

@@ -1133,7 +1143,6 @@ static int sbp2_probe(struct device *dev)
11331143
dev_set_drvdata(&unit->device, tgt);
11341144
tgt->unit = unit;
11351145
INIT_LIST_HEAD(&tgt->lu_list);
1136-
tgt->bus_id = dev_name(&unit->device);
11371146
tgt->guid = (u64)device->config_rom[3] << 32 | device->config_rom[4];
11381147

11391148
if (fw_device_enable_phys_dma(device) < 0)
@@ -1239,7 +1248,7 @@ static int sbp2_remove(struct device *dev)
12391248
kfree(lu);
12401249
}
12411250
scsi_remove_host(shost);
1242-
fw_notify("released %s, target %d:0:0\n", tgt->bus_id, shost->host_no);
1251+
dev_notice(dev, "released target %d:0:0\n", shost->host_no);
12431252

12441253
scsi_host_put(shost);
12451254
return 0;
@@ -1325,7 +1334,7 @@ static void complete_command_orb(struct sbp2_orb *base_orb,
13251334
{
13261335
struct sbp2_command_orb *orb =
13271336
container_of(base_orb, struct sbp2_command_orb, base);
1328-
struct fw_device *device = target_device(orb->lu->tgt);
1337+
struct fw_device *device = target_parent_device(orb->lu->tgt);
13291338
int result;
13301339

13311340
if (status != NULL) {
@@ -1433,7 +1442,7 @@ static int sbp2_scsi_queuecommand(struct Scsi_Host *shost,
14331442
struct scsi_cmnd *cmd)
14341443
{
14351444
struct sbp2_logical_unit *lu = cmd->device->hostdata;
1436-
struct fw_device *device = target_device(lu->tgt);
1445+
struct fw_device *device = target_parent_device(lu->tgt);
14371446
struct sbp2_command_orb *orb;
14381447
int generation, retval = SCSI_MLQUEUE_HOST_BUSY;
14391448

@@ -1442,15 +1451,15 @@ static int sbp2_scsi_queuecommand(struct Scsi_Host *shost,
14421451
* transfer direction not handled.
14431452
*/
14441453
if (cmd->sc_data_direction == DMA_BIDIRECTIONAL) {
1445-
fw_error("Can't handle DMA_BIDIRECTIONAL, rejecting command\n");
1454+
dev_err(lu_dev(lu), "cannot handle bidirectional command\n");
14461455
cmd->result = DID_ERROR << 16;
14471456
cmd->scsi_done(cmd);
14481457
return 0;
14491458
}
14501459

14511460
orb = kzalloc(sizeof(*orb), GFP_ATOMIC);
14521461
if (orb == NULL) {
1453-
fw_notify("failed to alloc orb\n");
1462+
dev_notice(lu_dev(lu), "failed to alloc ORB\n");
14541463
return SCSI_MLQUEUE_HOST_BUSY;
14551464
}
14561465

@@ -1550,7 +1559,7 @@ static int sbp2_scsi_abort(struct scsi_cmnd *cmd)
15501559
{
15511560
struct sbp2_logical_unit *lu = cmd->device->hostdata;
15521561

1553-
fw_notify("%s: sbp2_scsi_abort\n", lu->tgt->bus_id);
1562+
dev_notice(lu_dev(lu), "sbp2_scsi_abort\n");
15541563
sbp2_agent_reset(lu);
15551564
sbp2_cancel_orbs(lu);
15561565

0 commit comments

Comments
 (0)