Skip to content

Commit 17936b4

Browse files
JoePerchesSamuel Ortiz
authored andcommitted
NFC: Standardize logging style
Use standardized styles to minimize coding defects. Always use nfc_<level> where feasible. Add \n to formats where appropriate. Typo "it it" correction. Add #define pr_fmt where appropriate. Remove function tracing logging messages. Remove OOM messages. Signed-off-by: Joe Perches <[email protected]> Signed-off-by: Samuel Ortiz <[email protected]>
1 parent 073a625 commit 17936b4

File tree

8 files changed

+50
-61
lines changed

8 files changed

+50
-61
lines changed

drivers/nfc/mei_phy.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1919
*/
2020

21+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
22+
2123
#include <linux/module.h>
2224
#include <linux/slab.h>
2325
#include <linux/nfc.h>
@@ -60,13 +62,13 @@ int nfc_mei_phy_enable(void *phy_id)
6062

6163
r = mei_cl_enable_device(phy->device);
6264
if (r < 0) {
63-
pr_err("MEI_PHY: Could not enable device\n");
65+
pr_err("Could not enable device\n");
6466
return r;
6567
}
6668

6769
r = mei_cl_register_event_cb(phy->device, nfc_mei_event_cb, phy);
6870
if (r) {
69-
pr_err("MEY_PHY: Event cb registration failed\n");
71+
pr_err("Event cb registration failed\n");
7072
mei_cl_disable_device(phy->device);
7173
phy->powered = 0;
7274

drivers/nfc/microread/i2c.c

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1919
*/
2020

21+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
22+
2123
#include <linux/module.h>
2224
#include <linux/i2c.h>
2325
#include <linux/delay.h>
@@ -95,12 +97,8 @@ static int check_crc(struct sk_buff *skb)
9597
crc = crc ^ skb->data[i];
9698

9799
if (crc != skb->data[skb->len-1]) {
98-
pr_err(MICROREAD_I2C_DRIVER_NAME
99-
": CRC error 0x%x != 0x%x\n",
100-
crc, skb->data[skb->len-1]);
101-
102-
pr_info(DRIVER_DESC ": %s : BAD CRC\n", __func__);
103-
100+
pr_err("CRC error 0x%x != 0x%x\n", crc, skb->data[skb->len-1]);
101+
pr_info("%s: BAD CRC\n", __func__);
104102
return -EPERM;
105103
}
106104

@@ -160,18 +158,15 @@ static int microread_i2c_read(struct microread_i2c_phy *phy,
160158
u8 tmp[MICROREAD_I2C_LLC_MAX_SIZE - 1];
161159
struct i2c_client *client = phy->i2c_dev;
162160

163-
pr_debug("%s\n", __func__);
164-
165161
r = i2c_master_recv(client, &len, 1);
166162
if (r != 1) {
167-
dev_err(&client->dev, "cannot read len byte\n");
163+
nfc_err(&client->dev, "cannot read len byte\n");
168164
return -EREMOTEIO;
169165
}
170166

171167
if ((len < MICROREAD_I2C_LLC_MIN_SIZE) ||
172168
(len > MICROREAD_I2C_LLC_MAX_SIZE)) {
173-
dev_err(&client->dev, "invalid len byte\n");
174-
pr_err("invalid len byte\n");
169+
nfc_err(&client->dev, "invalid len byte\n");
175170
r = -EBADMSG;
176171
goto flush;
177172
}
@@ -228,7 +223,6 @@ static irqreturn_t microread_i2c_irq_thread_fn(int irq, void *phy_id)
228223
}
229224

230225
client = phy->i2c_dev;
231-
dev_dbg(&client->dev, "IRQ\n");
232226

233227
if (phy->hard_fault != 0)
234228
return IRQ_HANDLED;
@@ -263,20 +257,18 @@ static int microread_i2c_probe(struct i2c_client *client,
263257
dev_get_platdata(&client->dev);
264258
int r;
265259

266-
dev_dbg(&client->dev, "client %p", client);
260+
dev_dbg(&client->dev, "client %p\n", client);
267261

268262
if (!pdata) {
269-
dev_err(&client->dev, "client %p: missing platform data",
263+
nfc_err(&client->dev, "client %p: missing platform data\n",
270264
client);
271265
return -EINVAL;
272266
}
273267

274268
phy = devm_kzalloc(&client->dev, sizeof(struct microread_i2c_phy),
275269
GFP_KERNEL);
276-
if (!phy) {
277-
dev_err(&client->dev, "Can't allocate microread phy");
270+
if (!phy)
278271
return -ENOMEM;
279-
}
280272

281273
i2c_set_clientdata(client, phy);
282274
phy->i2c_dev = client;
@@ -285,7 +277,7 @@ static int microread_i2c_probe(struct i2c_client *client,
285277
IRQF_TRIGGER_RISING | IRQF_ONESHOT,
286278
MICROREAD_I2C_DRIVER_NAME, phy);
287279
if (r) {
288-
dev_err(&client->dev, "Unable to register IRQ handler");
280+
nfc_err(&client->dev, "Unable to register IRQ handler\n");
289281
return r;
290282
}
291283

@@ -296,7 +288,7 @@ static int microread_i2c_probe(struct i2c_client *client,
296288
if (r < 0)
297289
goto err_irq;
298290

299-
dev_info(&client->dev, "Probed");
291+
nfc_info(&client->dev, "Probed");
300292

301293
return 0;
302294

@@ -310,8 +302,6 @@ static int microread_i2c_remove(struct i2c_client *client)
310302
{
311303
struct microread_i2c_phy *phy = i2c_get_clientdata(client);
312304

313-
dev_dbg(&client->dev, "%s\n", __func__);
314-
315305
microread_remove(phy->hdev);
316306

317307
free_irq(client->irq, phy);

drivers/nfc/microread/mei.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1919
*/
2020

21+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
22+
2123
#include <linux/module.h>
2224
#include <linux/mod_devicetable.h>
2325
#include <linux/nfc.h>
@@ -59,8 +61,6 @@ static int microread_mei_remove(struct mei_cl_device *device)
5961
{
6062
struct nfc_mei_phy *phy = mei_cl_get_drvdata(device);
6163

62-
pr_info("Removing microread\n");
63-
6464
microread_remove(phy->hdev);
6565

6666
nfc_mei_phy_free(phy);

drivers/nfc/microread/microread.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1919
*/
2020

21+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
22+
2123
#include <linux/module.h>
2224
#include <linux/delay.h>
2325
#include <linux/slab.h>
@@ -546,7 +548,7 @@ static void microread_target_discovered(struct nfc_hci_dev *hdev, u8 gate,
546548
kfree_skb(skb);
547549

548550
if (r)
549-
pr_err("Failed to handle discovered target err=%d", r);
551+
pr_err("Failed to handle discovered target err=%d\n", r);
550552
}
551553

552554
static int microread_event_received(struct nfc_hci_dev *hdev, u8 gate,
@@ -656,7 +658,6 @@ int microread_probe(void *phy_id, struct nfc_phy_ops *phy_ops, char *llc_name,
656658

657659
info = kzalloc(sizeof(struct microread_info), GFP_KERNEL);
658660
if (!info) {
659-
pr_err("Cannot allocate memory for microread_info.\n");
660661
r = -ENOMEM;
661662
goto err_info_alloc;
662663
}
@@ -686,7 +687,7 @@ int microread_probe(void *phy_id, struct nfc_phy_ops *phy_ops, char *llc_name,
686687
MICROREAD_CMD_TAILROOM,
687688
phy_payload);
688689
if (!info->hdev) {
689-
pr_err("Cannot allocate nfc hdev.\n");
690+
pr_err("Cannot allocate nfc hdev\n");
690691
r = -ENOMEM;
691692
goto err_alloc_hdev;
692693
}

drivers/nfc/nfcwilink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ static int nfcwilink_get_bts_file_name(struct nfcwilink *drv, char *file_name)
171171
dev_dbg(&drv->pdev->dev, "wait_for_completion_timeout returned %ld\n",
172172
comp_ret);
173173
if (comp_ret == 0) {
174-
dev_err(&drv->pdev->dev,
174+
nfc_err(&drv->pdev->dev,
175175
"timeout on wait_for_completion_timeout\n");
176176
return -ETIMEDOUT;
177177
}

drivers/nfc/pn533.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,7 +1450,7 @@ static int pn533_target_found(struct pn533 *dev, u8 tg, u8 *tgdata,
14501450
struct nfc_target nfc_tgt;
14511451
int rc;
14521452

1453-
dev_dbg(&dev->interface->dev, "%s - modulation=%d\n",
1453+
dev_dbg(&dev->interface->dev, "%s: modulation=%d\n",
14541454
__func__, dev->poll_mod_curr);
14551455

14561456
if (tg != 1)
@@ -2004,8 +2004,7 @@ static int pn533_activate_target(struct nfc_dev *nfc_dev,
20042004
struct pn533 *dev = nfc_get_drvdata(nfc_dev);
20052005
int rc;
20062006

2007-
dev_dbg(&dev->interface->dev, "%s - protocol=%u\n",
2008-
__func__, protocol);
2007+
dev_dbg(&dev->interface->dev, "%s: protocol=%u\n", __func__, protocol);
20092008

20102009
if (dev->poll_mod_count) {
20112010
nfc_err(&dev->interface->dev,

drivers/nfc/pn544/i2c.c

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1919
*/
2020

21+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
22+
2123
#include <linux/crc-ccitt.h>
2224
#include <linux/module.h>
2325
#include <linux/i2c.h>
@@ -151,8 +153,7 @@ static void pn544_hci_i2c_platform_init(struct pn544_i2c_phy *phy)
151153
char rset_cmd[] = { 0x05, 0xF9, 0x04, 0x00, 0xC3, 0xE5 };
152154
int count = sizeof(rset_cmd);
153155

154-
pr_info(DRIVER_DESC ": %s\n", __func__);
155-
dev_info(&phy->i2c_dev->dev, "Detecting nfc_en polarity\n");
156+
nfc_info(&phy->i2c_dev->dev, "Detecting nfc_en polarity\n");
156157

157158
/* Disable fw download */
158159
gpio_set_value(phy->gpio_fw, 0);
@@ -173,15 +174,15 @@ static void pn544_hci_i2c_platform_init(struct pn544_i2c_phy *phy)
173174
dev_dbg(&phy->i2c_dev->dev, "Sending reset cmd\n");
174175
ret = i2c_master_send(phy->i2c_dev, rset_cmd, count);
175176
if (ret == count) {
176-
dev_info(&phy->i2c_dev->dev,
177+
nfc_info(&phy->i2c_dev->dev,
177178
"nfc_en polarity : active %s\n",
178179
(polarity == 0 ? "low" : "high"));
179180
goto out;
180181
}
181182
}
182183
}
183184

184-
dev_err(&phy->i2c_dev->dev,
185+
nfc_err(&phy->i2c_dev->dev,
185186
"Could not detect nfc_en polarity, fallback to active high\n");
186187

187188
out:
@@ -201,7 +202,7 @@ static int pn544_hci_i2c_enable(void *phy_id)
201202
{
202203
struct pn544_i2c_phy *phy = phy_id;
203204

204-
pr_info(DRIVER_DESC ": %s\n", __func__);
205+
pr_info("%s\n", __func__);
205206

206207
pn544_hci_i2c_enable_mode(phy, PN544_HCI_MODE);
207208

@@ -214,8 +215,6 @@ static void pn544_hci_i2c_disable(void *phy_id)
214215
{
215216
struct pn544_i2c_phy *phy = phy_id;
216217

217-
pr_info(DRIVER_DESC ": %s\n", __func__);
218-
219218
gpio_set_value(phy->gpio_fw, 0);
220219
gpio_set_value(phy->gpio_en, !phy->en_polarity);
221220
usleep_range(10000, 15000);
@@ -298,11 +297,9 @@ static int check_crc(u8 *buf, int buflen)
298297
crc = ~crc;
299298

300299
if (buf[len - 2] != (crc & 0xff) || buf[len - 1] != (crc >> 8)) {
301-
pr_err(PN544_HCI_I2C_DRIVER_NAME
302-
": CRC error 0x%x != 0x%x 0x%x\n",
300+
pr_err("CRC error 0x%x != 0x%x 0x%x\n",
303301
crc, buf[len - 1], buf[len - 2]);
304-
305-
pr_info(DRIVER_DESC ": %s : BAD CRC\n", __func__);
302+
pr_info("%s: BAD CRC\n", __func__);
306303
print_hex_dump(KERN_DEBUG, "crc: ", DUMP_PREFIX_NONE,
307304
16, 2, buf, buflen, false);
308305
return -EPERM;
@@ -328,13 +325,13 @@ static int pn544_hci_i2c_read(struct pn544_i2c_phy *phy, struct sk_buff **skb)
328325

329326
r = i2c_master_recv(client, &len, 1);
330327
if (r != 1) {
331-
dev_err(&client->dev, "cannot read len byte\n");
328+
nfc_err(&client->dev, "cannot read len byte\n");
332329
return -EREMOTEIO;
333330
}
334331

335332
if ((len < (PN544_HCI_I2C_LLC_MIN_SIZE - 1)) ||
336333
(len > (PN544_HCI_I2C_LLC_MAX_SIZE - 1))) {
337-
dev_err(&client->dev, "invalid len byte\n");
334+
nfc_err(&client->dev, "invalid len byte\n");
338335
r = -EBADMSG;
339336
goto flush;
340337
}
@@ -386,7 +383,7 @@ static int pn544_hci_i2c_fw_read_status(struct pn544_i2c_phy *phy)
386383

387384
r = i2c_master_recv(client, (char *) &response, sizeof(response));
388385
if (r != sizeof(response)) {
389-
dev_err(&client->dev, "cannot read fw status\n");
386+
nfc_err(&client->dev, "cannot read fw status\n");
390387
return -EIO;
391388
}
392389

@@ -478,8 +475,7 @@ static int pn544_hci_i2c_fw_download(void *phy_id, const char *firmware_name)
478475
{
479476
struct pn544_i2c_phy *phy = phy_id;
480477

481-
pr_info(DRIVER_DESC ": Starting Firmware Download (%s)\n",
482-
firmware_name);
478+
pr_info("Starting Firmware Download (%s)\n", firmware_name);
483479

484480
strcpy(phy->firmware_name, firmware_name);
485481

@@ -493,7 +489,7 @@ static int pn544_hci_i2c_fw_download(void *phy_id, const char *firmware_name)
493489
static void pn544_hci_i2c_fw_work_complete(struct pn544_i2c_phy *phy,
494490
int result)
495491
{
496-
pr_info(DRIVER_DESC ": Firmware Download Complete, result=%d\n", result);
492+
pr_info("Firmware Download Complete, result=%d\n", result);
497493

498494
pn544_hci_i2c_disable(phy);
499495

@@ -694,14 +690,14 @@ static int pn544_hci_i2c_probe(struct i2c_client *client,
694690
dev_dbg(&client->dev, "IRQ: %d\n", client->irq);
695691

696692
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
697-
dev_err(&client->dev, "Need I2C_FUNC_I2C\n");
693+
nfc_err(&client->dev, "Need I2C_FUNC_I2C\n");
698694
return -ENODEV;
699695
}
700696

701697
phy = devm_kzalloc(&client->dev, sizeof(struct pn544_i2c_phy),
702698
GFP_KERNEL);
703699
if (!phy) {
704-
dev_err(&client->dev,
700+
nfc_err(&client->dev,
705701
"Cannot allocate memory for pn544 i2c phy.\n");
706702
return -ENOMEM;
707703
}
@@ -714,18 +710,18 @@ static int pn544_hci_i2c_probe(struct i2c_client *client,
714710

715711
pdata = client->dev.platform_data;
716712
if (pdata == NULL) {
717-
dev_err(&client->dev, "No platform data\n");
713+
nfc_err(&client->dev, "No platform data\n");
718714
return -EINVAL;
719715
}
720716

721717
if (pdata->request_resources == NULL) {
722-
dev_err(&client->dev, "request_resources() missing\n");
718+
nfc_err(&client->dev, "request_resources() missing\n");
723719
return -EINVAL;
724720
}
725721

726722
r = pdata->request_resources(client);
727723
if (r) {
728-
dev_err(&client->dev, "Cannot get platform resources\n");
724+
nfc_err(&client->dev, "Cannot get platform resources\n");
729725
return r;
730726
}
731727

@@ -739,7 +735,7 @@ static int pn544_hci_i2c_probe(struct i2c_client *client,
739735
IRQF_TRIGGER_RISING | IRQF_ONESHOT,
740736
PN544_HCI_I2C_DRIVER_NAME, phy);
741737
if (r < 0) {
742-
dev_err(&client->dev, "Unable to register IRQ handler\n");
738+
nfc_err(&client->dev, "Unable to register IRQ handler\n");
743739
goto err_rti;
744740
}
745741

0 commit comments

Comments
 (0)