i2c: stub: use pr_fmt
Instead of hard coding "i2c-stub:", let's use the pr_fmt mechanism to achieve the same more easily. This makes it easier to stay consistent when adding new messages. Also, remove an unneeded OOM message while we are here. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
This commit is contained in:
parent
df5da47fe7
commit
6c42778780
|
@ -15,7 +15,8 @@
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define DEBUG 1
|
#define DEBUG
|
||||||
|
#define pr_fmt(fmt) "i2c-stub: " fmt
|
||||||
|
|
||||||
#include <linux/errno.h>
|
#include <linux/errno.h>
|
||||||
#include <linux/i2c.h>
|
#include <linux/i2c.h>
|
||||||
|
@ -342,7 +343,7 @@ static int __init i2c_stub_allocate_banks(int i)
|
||||||
if (!chip->bank_words)
|
if (!chip->bank_words)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
pr_debug("i2c-stub: Allocated %u banks of %u words each (registers 0x%02x to 0x%02x)\n",
|
pr_debug("Allocated %u banks of %u words each (registers 0x%02x to 0x%02x)\n",
|
||||||
chip->bank_mask, chip->bank_size, chip->bank_start,
|
chip->bank_mask, chip->bank_size, chip->bank_start,
|
||||||
chip->bank_end);
|
chip->bank_end);
|
||||||
|
|
||||||
|
@ -363,28 +364,27 @@ static int __init i2c_stub_init(void)
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
|
||||||
if (!chip_addr[0]) {
|
if (!chip_addr[0]) {
|
||||||
pr_err("i2c-stub: Please specify a chip address\n");
|
pr_err("Please specify a chip address\n");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < MAX_CHIPS && chip_addr[i]; i++) {
|
for (i = 0; i < MAX_CHIPS && chip_addr[i]; i++) {
|
||||||
if (chip_addr[i] < 0x03 || chip_addr[i] > 0x77) {
|
if (chip_addr[i] < 0x03 || chip_addr[i] > 0x77) {
|
||||||
pr_err("i2c-stub: Invalid chip address 0x%02x\n",
|
pr_err("Invalid chip address 0x%02x\n",
|
||||||
chip_addr[i]);
|
chip_addr[i]);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pr_info("i2c-stub: Virtual chip at 0x%02x\n", chip_addr[i]);
|
pr_info("Virtual chip at 0x%02x\n", chip_addr[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate memory for all chips at once */
|
/* Allocate memory for all chips at once */
|
||||||
stub_chips_nr = i;
|
stub_chips_nr = i;
|
||||||
stub_chips = kcalloc(stub_chips_nr, sizeof(struct stub_chip),
|
stub_chips = kcalloc(stub_chips_nr, sizeof(struct stub_chip),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (!stub_chips) {
|
if (!stub_chips)
|
||||||
pr_err("i2c-stub: Out of memory\n");
|
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
|
||||||
for (i = 0; i < stub_chips_nr; i++) {
|
for (i = 0; i < stub_chips_nr; i++) {
|
||||||
INIT_LIST_HEAD(&stub_chips[i].smbus_blocks);
|
INIT_LIST_HEAD(&stub_chips[i].smbus_blocks);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue