Skip to content

Commit 7f2feec

Browse files
izumi777jbarnes993
authored andcommitted
PCI: pciehp: replace printk with dev_printk
This patch replaces printks within pciehp module with dev_printks. Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
1 parent 83e9ad5 commit 7f2feec

5 files changed

Lines changed: 263 additions & 186 deletions

File tree

‎drivers/pci/hotplug/pciehp.h‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,19 @@ extern struct workqueue_struct *pciehp_wq;
5757
#define warn(format, arg...) \
5858
printk(KERN_WARNING "%s: " format, MY_NAME , ## arg)
5959

60+
#define ctrl_dbg(ctrl, format, arg...) \
61+
do { \
62+
if (pciehp_debug) \
63+
dev_printk(, &ctrl->pcie->device, \
64+
format, ## arg); \
65+
} while (0)
66+
#define ctrl_err(ctrl, format, arg...) \
67+
dev_err(&ctrl->pcie->device, format, ## arg)
68+
#define ctrl_info(ctrl, format, arg...) \
69+
dev_info(&ctrl->pcie->device, format, ## arg)
70+
#define ctrl_warn(ctrl, format, arg...) \
71+
dev_warn(&ctrl->pcie->device, format, ## arg)
72+
6073
#define SLOT_NAME_SIZE 10
6174
struct slot {
6275
u8 bus;
@@ -171,7 +184,7 @@ static inline struct slot *pciehp_find_slot(struct controller *ctrl, u8 device)
171184
return slot;
172185
}
173186

174-
err("%s: slot (device=0x%x) not found\n", __func__, device);
187+
ctrl_err(ctrl, "%s: slot (device=0x%x) not found\n", __func__, device);
175188
return NULL;
176189
}
177190

‎drivers/pci/hotplug/pciehp_core.c‎

Lines changed: 46 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,10 @@ static int set_lock_status(struct hotplug_slot *hotplug_slot, u8 status)
144144
* sysfs interface which allows the user to toggle the Electro Mechanical
145145
* Interlock. Valid values are either 0 or 1. 0 == unlock, 1 == lock
146146
*/
147-
static ssize_t lock_write_file(struct hotplug_slot *slot, const char *buf,
148-
size_t count)
147+
static ssize_t lock_write_file(struct hotplug_slot *hotplug_slot,
148+
const char *buf, size_t count)
149149
{
150+
struct slot *slot = hotplug_slot->private;
150151
unsigned long llock;
151152
u8 lock;
152153
int retval = 0;
@@ -157,10 +158,11 @@ static ssize_t lock_write_file(struct hotplug_slot *slot, const char *buf,
157158
switch (lock) {
158159
case 0:
159160
case 1:
160-
retval = set_lock_status(slot, lock);
161+
retval = set_lock_status(hotplug_slot, lock);
161162
break;
162163
default:
163-
err ("%d is an invalid lock value\n", lock);
164+
ctrl_err(slot->ctrl, "%d is an invalid lock value\n",
165+
lock);
164166
retval = -EINVAL;
165167
}
166168
if (retval)
@@ -180,7 +182,10 @@ static struct hotplug_slot_attribute hotplug_slot_attr_lock = {
180182
*/
181183
static void release_slot(struct hotplug_slot *hotplug_slot)
182184
{
183-
dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
185+
struct slot *slot = hotplug_slot->private;
186+
187+
ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n",
188+
__func__, hotplug_slot->name);
184189

185190
kfree(hotplug_slot->info);
186191
kfree(hotplug_slot);
@@ -215,9 +220,9 @@ static int init_slots(struct controller *ctrl)
215220
get_adapter_status(hotplug_slot, &info->adapter_status);
216221
slot->hotplug_slot = hotplug_slot;
217222

218-
dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x "
219-
"slot_device_offset=%x\n", slot->bus, slot->device,
220-
slot->hp_slot, slot->number, ctrl->slot_device_offset);
223+
ctrl_dbg(ctrl, "Registering bus=%x dev=%x hp_slot=%x sun=%x "
224+
"slot_device_offset=%x\n", slot->bus, slot->device,
225+
slot->hp_slot, slot->number, ctrl->slot_device_offset);
221226
duplicate_name:
222227
retval = pci_hp_register(hotplug_slot,
223228
ctrl->pci_dev->subordinate,
@@ -233,9 +238,11 @@ static int init_slots(struct controller *ctrl)
233238
if (len < SLOT_NAME_SIZE)
234239
goto duplicate_name;
235240
else
236-
err("duplicate slot name overflow\n");
241+
ctrl_err(ctrl, "duplicate slot name "
242+
"overflow\n");
237243
}
238-
err("pci_hp_register failed with error %d\n", retval);
244+
ctrl_err(ctrl, "pci_hp_register failed with error %d\n",
245+
retval);
239246
goto error_info;
240247
}
241248
/* create additional sysfs entries */
@@ -244,7 +251,8 @@ static int init_slots(struct controller *ctrl)
244251
&hotplug_slot_attr_lock.attr);
245252
if (retval) {
246253
pci_hp_deregister(hotplug_slot);
247-
err("cannot create additional sysfs entries\n");
254+
ctrl_err(ctrl, "cannot create additional sysfs "
255+
"entries\n");
248256
goto error_info;
249257
}
250258
}
@@ -278,7 +286,8 @@ static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status)
278286
{
279287
struct slot *slot = hotplug_slot->private;
280288

281-
dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
289+
ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n",
290+
__func__, hotplug_slot->name);
282291

283292
hotplug_slot->info->attention_status = status;
284293

@@ -293,7 +302,8 @@ static int enable_slot(struct hotplug_slot *hotplug_slot)
293302
{
294303
struct slot *slot = hotplug_slot->private;
295304

296-
dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
305+
ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n",
306+
__func__, hotplug_slot->name);
297307

298308
return pciehp_sysfs_enable_slot(slot);
299309
}
@@ -303,7 +313,8 @@ static int disable_slot(struct hotplug_slot *hotplug_slot)
303313
{
304314
struct slot *slot = hotplug_slot->private;
305315

306-
dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
316+
ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n",
317+
__func__, hotplug_slot->name);
307318

308319
return pciehp_sysfs_disable_slot(slot);
309320
}
@@ -313,7 +324,8 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
313324
struct slot *slot = hotplug_slot->private;
314325
int retval;
315326

316-
dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
327+
ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n",
328+
__func__, hotplug_slot->name);
317329

318330
retval = slot->hpc_ops->get_power_status(slot, value);
319331
if (retval < 0)
@@ -327,7 +339,8 @@ static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value)
327339
struct slot *slot = hotplug_slot->private;
328340
int retval;
329341

330-
dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
342+
ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n",
343+
__func__, hotplug_slot->name);
331344

332345
retval = slot->hpc_ops->get_attention_status(slot, value);
333346
if (retval < 0)
@@ -341,7 +354,8 @@ static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value)
341354
struct slot *slot = hotplug_slot->private;
342355
int retval;
343356

344-
dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
357+
ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n",
358+
__func__, hotplug_slot->name);
345359

346360
retval = slot->hpc_ops->get_latch_status(slot, value);
347361
if (retval < 0)
@@ -355,7 +369,8 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
355369
struct slot *slot = hotplug_slot->private;
356370
int retval;
357371

358-
dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
372+
ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n",
373+
__func__, hotplug_slot->name);
359374

360375
retval = slot->hpc_ops->get_adapter_status(slot, value);
361376
if (retval < 0)
@@ -370,7 +385,8 @@ static int get_max_bus_speed(struct hotplug_slot *hotplug_slot,
370385
struct slot *slot = hotplug_slot->private;
371386
int retval;
372387

373-
dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
388+
ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n",
389+
__func__, hotplug_slot->name);
374390

375391
retval = slot->hpc_ops->get_max_bus_speed(slot, value);
376392
if (retval < 0)
@@ -384,7 +400,8 @@ static int get_cur_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_spe
384400
struct slot *slot = hotplug_slot->private;
385401
int retval;
386402

387-
dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
403+
ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n",
404+
__func__, hotplug_slot->name);
388405

389406
retval = slot->hpc_ops->get_cur_bus_speed(slot, value);
390407
if (retval < 0)
@@ -402,14 +419,15 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
402419
struct pci_dev *pdev = dev->port;
403420

404421
if (pciehp_force)
405-
dbg("Bypassing BIOS check for pciehp use on %s\n",
406-
pci_name(pdev));
422+
dev_info(&dev->device,
423+
"Bypassing BIOS check for pciehp use on %s\n",
424+
pci_name(pdev));
407425
else if (pciehp_get_hp_hw_control_from_firmware(pdev))
408426
goto err_out_none;
409427

410428
ctrl = pcie_init(dev);
411429
if (!ctrl) {
412-
dbg("%s: controller initialization failed\n", PCIE_MODULE_NAME);
430+
dev_err(&dev->device, "controller initialization failed\n");
413431
goto err_out_none;
414432
}
415433
set_service_data(dev, ctrl);
@@ -418,11 +436,10 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
418436
rc = init_slots(ctrl);
419437
if (rc) {
420438
if (rc == -EBUSY)
421-
warn("%s: slot already registered by another "
422-
"hotplug driver\n", PCIE_MODULE_NAME);
439+
ctrl_warn(ctrl, "slot already registered by another "
440+
"hotplug driver\n");
423441
else
424-
err("%s: slot initialization failed\n",
425-
PCIE_MODULE_NAME);
442+
ctrl_err(ctrl, "slot initialization failed\n");
426443
goto err_out_release_ctlr;
427444
}
428445

@@ -461,13 +478,13 @@ static void pciehp_remove (struct pcie_device *dev)
461478
#ifdef CONFIG_PM
462479
static int pciehp_suspend (struct pcie_device *dev, pm_message_t state)
463480
{
464-
printk("%s ENTRY\n", __func__);
481+
dev_info(&dev->device, "%s ENTRY\n", __func__);
465482
return 0;
466483
}
467484

468485
static int pciehp_resume (struct pcie_device *dev)
469486
{
470-
printk("%s ENTRY\n", __func__);
487+
dev_info(&dev->device, "%s ENTRY\n", __func__);
471488
if (pciehp_force) {
472489
struct controller *ctrl = get_service_data(dev);
473490
struct slot *t_slot;

0 commit comments

Comments
 (0)