From: Jan Nikitenko <jan.nikitenko@gmail.com>
To: Antti Palosaari <crope@iki.fi>
Cc: linux-media@vger.kernel.org,
Mauro Carvalho Chehab <mchehab@infradead.org>
Subject: [PATCH] af9015: avoid magically sized temporal buffer in eeprom_dump
Date: Thu, 18 Jun 2009 13:22:27 +0200 [thread overview]
Message-ID: <20090618112227.GA9930@nikitenko.systek.local> (raw)
In-Reply-To: <4A2EF922.5040102@iki.fi>
Replace printing to magically sized temporal buffer with use of KERN_CONT
for continual printing of eeprom registers dump.
Since deb_info is defined as dprintk, which is defined as printk without
additional parameters, meaning that deb_info is equivalent to direct printk
(without KERN_ facility), we can use KERN_DEBUG and KERN_CONT in there,
eliminating the need for sprintf into temporal buffer with not easily
readable/magical size.
Though it's strange, that deb_info definition uses printk without KERN_
facility and callers don't use it either.
Signed-off-by: Jan Nikitenko <jan.nikitenko@gmail.com>
---
(added missing Singned-off)
I do not see better solution for the magical sized buffer, since print_hex_dump
like functions need dump of registers in memory (so the magical sized temporal
buffer would be needed for a copy anyway).
If deb_info was defined with inside KERN_ facility, then this patch would not
be valid and so the magically sized temporal buffer might be acceptable to keep
there.
This patch depends on 'af9015: fix stack corruption bug' patch.
linux/drivers/media/dvb/dvb-usb/af9015.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff -r 722c6faf3ab5 linux/drivers/media/dvb/dvb-usb/af9015.c
--- a/linux/drivers/media/dvb/dvb-usb/af9015.c Wed Jun 17 22:39:23 2009 -0300
+++ b/linux/drivers/media/dvb/dvb-usb/af9015.c Thu Jun 18 08:49:58 2009 +0200
@@ -541,24 +541,22 @@
/* dump eeprom */
static int af9015_eeprom_dump(struct dvb_usb_device *d)
{
- char buf[4+3*16+1], buf2[4];
u8 reg, val;
for (reg = 0; ; reg++) {
if (reg % 16 == 0) {
if (reg)
- deb_info("%s\n", buf);
- sprintf(buf, "%02x: ", reg);
+ deb_info(KERN_CONT "\n");
+ deb_info(KERN_DEBUG "%02x:", reg);
}
if (af9015_read_reg_i2c(d, AF9015_I2C_EEPROM, reg, &val) == 0)
- sprintf(buf2, "%02x ", val);
+ deb_info(KERN_CONT, " %02x", val);
else
- strcpy(buf2, "-- ");
- strcat(buf, buf2);
+ deb_info(KERN_CONT, " --");
if (reg == 0xff)
break;
}
- deb_info("%s\n", buf);
+ deb_info(KERN_CONT "\n");
return 0;
}
next prev parent reply other threads:[~2009-06-18 11:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-09 22:31 [PATCH] af9015: fix stack corruption bug Jan Nikitenko
2009-06-10 0:06 ` Antti Palosaari
2009-06-18 11:12 ` [PATCH] af9015: avoid magically sized temporal buffer in eeprom_dump Jan Nikitenko
2009-06-18 11:22 ` Jan Nikitenko [this message]
2009-06-18 21:00 ` Trent Piepho
2009-06-19 7:32 ` [PATCH v2] af9015: avoid magically sized temporary " Jan Nikitenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090618112227.GA9930@nikitenko.systek.local \
--to=jan.nikitenko@gmail.com \
--cc=crope@iki.fi \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.