From: "Henri Häkkinen" <henuxd@gmail.com>
To: gregkh@suse.de, mithlesh@linsyssoft.com, wfp5p@virginia.edu,
reodge@gmail.com, andrea.gelmini@gelma.net, henuxd@gmail.com
Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: [PATCH] staging:comedi: Fixed coding convention issues.
Date: Sat, 12 Jun 2010 14:04:04 +0300 [thread overview]
Message-ID: <1276340644-5211-1-git-send-email-henuxd@gmail.com> (raw)
Cleaned up and fixed coding convention issues as reporteed by
checkpatch.pl tool on the file `drivers.c'. Added logging macros
to `comedidev.h'.
Signed-off-by: Henri Häkkinen <henuxd@gmail.com>
---
drivers/staging/comedi/comedidev.h | 54 ++++++++++++++++++++-
drivers/staging/comedi/drivers.c | 89 ++++++++++++++++++------------------
2 files changed, 95 insertions(+), 48 deletions(-)
diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h
index 4eb2b77..5c78564 100644
--- a/drivers/staging/comedi/comedidev.h
+++ b/drivers/staging/comedi/comedidev.h
@@ -43,11 +43,59 @@
#include "comedi.h"
-#define DPRINTK(format, args...) do { \
- if (comedi_debug) \
- printk(KERN_DEBUG "comedi: " format , ## args); \
+#define comedi_printk(level, fmt, args...) \
+ printk(level "comedi: " pr_fmt(fmt), ##args)
+
+#define DPRINTK(format, args...) \
+do { \
+ if (comedi_debug) \
+ comedi_printk(KERN_DEBUG, fmt, ##args); \
} while (0)
+#define comedi_emerg(fmt, ...) \
+ comedi_printk(KERN_EMERG, fmt, ##__VA_ARGS__)
+#define comedi_alert(fmt, ...) \
+ comedi_printk(KERN_ALERT, fmt, ##__VA_ARGS__)
+#define comedi_crit(fmt, ...) \
+ comedi_printk(KERN_CRIT, fmt, ##__VA_ARGS__)
+#define comedi_err(fmt, ...) \
+ comedi_printk(KERN_ERR, fmt, ##__VA_ARGS__)
+#define comedi_warn(fmt, ...) \
+ comedi_printk(KERN_WARN, fmt, ##__VA_ARGS__)
+#define comedi_notice(fmt, ...) \
+ comedi_printk(KERN_NOTICE, fmt, ##__VA_ARGS__)
+#define comedi_info(fmt, ...) \
+ comedi_printk(KERN_INFO, fmt, ##__VA_ARGS__)
+
+/* comedi_devel() should produce zero code unless DEBUG is defined */
+#ifdef DEBUG
+#define comedi_devel(fmt, ...) \
+ comedi_printk(KERN_DEBUG, fmt, ##__VA_ARGS__)
+#else
+#define comedi_devel(fmt, ...) \
+({ \
+ if (0) \
+ comedi_printk(KERN_DEBUG, fmt, ##__VA_ARGS_); \
+ 0; \
+})
+#endif
+
+#if defined(DEBUG)
+#define comedi_debug(fmt, ..) \
+ comedi_printk(KERN_DEBUG, fmt, ##__VA_ARGS__)
+#elif defined(CONFIG_DYNAMIC_DEBUG)
+/* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */
+#define comedi_debug(fmt, ...) \
+ dynamic_pr_debug(fmt, ##__VA_ARGS__)
+#else
+#define comedi_debug(fmt, ...) \
+({ \
+ if (0) \
+ comedi_printk(KERN_DEBUG, fmt, ##__VA_ARGS__); \
+ 0; \
+})
+#endif
+
#define COMEDI_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c))
#define COMEDI_VERSION_CODE COMEDI_VERSION(COMEDI_MAJORVERSION, \
COMEDI_MINORVERSION, COMEDI_MICROVERSION)
diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index 4a29ed7..a649e7f 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/staging/comedi/drivers.c
@@ -117,8 +117,7 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it)
for (driv = comedi_drivers; driv; driv = driv->next) {
if (!try_module_get(driv->module)) {
- printk
- (KERN_INFO "comedi: failed to increment module count, skipping\n");
+ comedi_info("failed to increment module count, skipping\n");
continue;
}
if (driv->num_names) {
@@ -149,8 +148,7 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* report valid board names before returning error */
for (driv = comedi_drivers; driv; driv = driv->next) {
if (!try_module_get(driv->module)) {
- printk(KERN_INFO
- "comedi: failed to increment module count\n");
+ comedi_info("failed to increment module count\n");
continue;
}
comedi_report_boards(driv);
@@ -205,9 +203,8 @@ int comedi_driver_unregister(struct comedi_driver *driver)
mutex_lock(&dev->mutex);
if (dev->attached && dev->driver == driver) {
if (dev->use_count)
- printk
- (KERN_WARNING "BUG! detaching device with use_count=%d\n",
- dev->use_count);
+ printk(KERN_WARNING
+ "BUG! detaching device with use_count=%d\n", dev->use_count);
comedi_device_detach(dev);
}
mutex_unlock(&dev->mutex);
@@ -325,8 +322,8 @@ static void comedi_report_boards(struct comedi_driver *driv)
unsigned int i;
const char *const *name_ptr;
- printk(KERN_INFO "comedi: valid board names for %s driver are:\n",
- driv->driver_name);
+ comedi_info("valid board names for %s driver are:\n",
+ driv->driver_name);
name_ptr = driv->board_name;
for (i = 0; i < driv->num_names; i++) {
@@ -441,21 +438,19 @@ int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s,
if (async->buf_page_list) {
unsigned i;
for (i = 0; i < async->n_buf_pages; ++i) {
- if (async->buf_page_list[i].virt_addr) {
- clear_bit(PG_reserved, &(virt_to_page(async->buf_page_list[i].virt_addr)->flags));
+ void *virt_addr = async->buf_page_list[i].virt_addr;
+ dma_addr_t dma_addr = async->buf_page_list[i].dma_addr;
+
+ if (virt_addr) {
+ struct page *page = virt_to_page(virt_addr);
+ clear_bit(PG_reserved, &page->flags);
if (s->async_dma_dir != DMA_NONE) {
dma_free_coherent(dev->hw_dev,
PAGE_SIZE,
- async->
- buf_page_list
- [i].virt_addr,
- async->
- buf_page_list
- [i].dma_addr);
+ virt_addr,
+ dma_addr);
} else {
- free_page((unsigned long)
- async->buf_page_list[i].
- virt_addr);
+ free_page((unsigned long) virt_addr);
}
}
}
@@ -478,26 +473,29 @@ int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s,
}
if (pages) {
for (i = 0; i < n_pages; i++) {
+ struct comedi_buf_page *buf_page =
+ &async->buf_page_list[i];
+ dma_addr_t dma_addr = buf_page->dma_addr;
+ struct page *page;
+
if (s->async_dma_dir != DMA_NONE) {
- async->buf_page_list[i].virt_addr =
+ buf_page->virt_addr =
dma_alloc_coherent(dev->hw_dev,
PAGE_SIZE,
- &async->
- buf_page_list
- [i].dma_addr,
+ &dma_addr,
GFP_KERNEL |
__GFP_COMP);
} else {
- async->buf_page_list[i].virt_addr =
+ buf_page->virt_addr =
(void *)
get_zeroed_page(GFP_KERNEL);
}
- if (async->buf_page_list[i].virt_addr == NULL)
+ if (buf_page->virt_addr == NULL)
break;
- set_bit(PG_reserved,
- &(virt_to_page(async->buf_page_list[i].virt_addr)->flags));
- pages[i] = virt_to_page(async->buf_page_list[i].virt_addr);
+ page = virt_to_page(buf_page->virt_addr);
+ set_bit(PG_reserved, &page->flags);
+ pages[i] = page;
}
}
if (i == n_pages) {
@@ -510,24 +508,27 @@ int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s,
/* Some allocation failed above. */
if (async->buf_page_list) {
for (i = 0; i < n_pages; i++) {
- if (async->buf_page_list[i].virt_addr ==
- NULL) {
+ struct comedi_buf_page *buf_page =
+ &async->buf_page_list[i];
+ void *virt_addr =
+ buf_page->virt_addr;
+ dma_addr_t dma_addr =
+ buf_page->dma_addr;
+ struct page *page =
+ virt_to_page(virt_addr);
+
+ if (virt_addr == NULL)
break;
- }
- clear_bit(PG_reserved, &(virt_to_page(async->buf_page_list[i].virt_addr)->flags));
+
+ clear_bit(PG_reserved, &page->flags);
if (s->async_dma_dir != DMA_NONE) {
dma_free_coherent(dev->hw_dev,
PAGE_SIZE,
- async->
- buf_page_list
- [i].virt_addr,
- async->
- buf_page_list
- [i].dma_addr);
+ virt_addr,
+ dma_addr);
} else {
free_page((unsigned long)
- async->buf_page_list
- [i].virt_addr);
+ virt_addr);
}
}
vfree(async->buf_page_list);
@@ -646,8 +647,7 @@ unsigned comedi_buf_write_free(struct comedi_async *async, unsigned int nbytes)
{
if ((int)(async->buf_write_count + nbytes -
async->buf_write_alloc_count) > 0) {
- printk
- (KERN_INFO "comedi: attempted to write-free more bytes than have been write-allocated.\n");
+ comedi_info("attempted to write-free more bytes than have been write-allocated.\n");
nbytes = async->buf_write_alloc_count - async->buf_write_count;
}
async->buf_write_count += nbytes;
@@ -683,8 +683,7 @@ unsigned comedi_buf_read_free(struct comedi_async *async, unsigned int nbytes)
smp_mb();
if ((int)(async->buf_read_count + nbytes -
async->buf_read_alloc_count) > 0) {
- printk(KERN_INFO
- "comedi: attempted to read-free more bytes than have been read-allocated.\n");
+ comedi_info("attempted to read-free more bytes than have been read-allocated.\n");
nbytes = async->buf_read_alloc_count - async->buf_read_count;
}
async->buf_read_count += nbytes;
--
1.7.1
next reply other threads:[~2010-06-13 13:56 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-12 11:04 Henri Häkkinen [this message]
-- strict thread matches above, loose matches on Subject: below --
2010-06-14 6:34 [PATCH] staging:comedi: Fixed coding convention issues Henri Häkkinen
2010-06-17 23:02 ` Greg KH
2010-06-12 10:14 Henri Häkkinen
2010-06-13 2:14 ` Mark Rankilor
2010-06-13 5:07 ` Joe Perches
2010-06-13 5:30 ` Joe Perches
2010-06-13 11:27 ` Henri Häkkinen
2010-06-13 18:11 ` Joe Perches
2010-06-17 22:51 ` Greg KH
2010-06-17 23:15 ` Joe Perches
2010-06-17 23:28 ` Greg KH
2010-06-17 23:47 ` Joe Perches
2010-06-18 12:16 ` Ian Abbott
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=1276340644-5211-1-git-send-email-henuxd@gmail.com \
--to=henuxd@gmail.com \
--cc=andrea.gelmini@gelma.net \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mithlesh@linsyssoft.com \
--cc=reodge@gmail.com \
--cc=wfp5p@virginia.edu \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).