mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Robert Jarzmik <robert.jarzmik@free.fr>
To: barebox@lists.infradead.org
Subject: [PATCH V2 2/8] drivers/mtd: cosmetic changes
Date: Fri, 16 Dec 2011 22:50:28 +0100	[thread overview]
Message-ID: <1324072234-31634-3-git-send-email-robert.jarzmik@free.fr> (raw)
In-Reply-To: <1324072234-31634-1-git-send-email-robert.jarzmik@free.fr>

Fix whitespace, replace all debug() by dev_dbg(), and fix
line length to 80 characters.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
---
 drivers/mtd/core.c |   47 ++++++++++++++++++++++-------------------------
 1 files changed, 22 insertions(+), 25 deletions(-)

diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c
index 6db21d6..3bfcaf4 100644
--- a/drivers/mtd/core.c
+++ b/drivers/mtd/core.c
@@ -14,11 +14,6 @@
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
  */
 #include <common.h>
 #include <linux/mtd/nand.h>
@@ -31,7 +26,8 @@
 #include <nand.h>
 #include <errno.h>
 
-static 	ssize_t nand_read(struct cdev *cdev, void* buf, size_t count, ulong offset, ulong flags)
+static 	ssize_t nand_read(struct cdev *cdev, void* buf, size_t count,
+			  ulong offset, ulong flags)
 {
 	struct mtd_info *info = cdev->priv;
 	size_t retlen;
@@ -49,6 +45,7 @@ static 	ssize_t nand_read(struct cdev *cdev, void* buf, size_t count, ulong offs
 }
 
 #define NOTALIGNED(x) (x & (info->writesize - 1)) != 0
+#define MTDPGALG(x) ((x) & (info->writesize - 1))
 
 #ifdef CONFIG_NAND_WRITE
 static int all_ff(const void *buf, int len)
@@ -62,7 +59,8 @@ static int all_ff(const void *buf, int len)
 	return 1;
 }
 
-static ssize_t nand_write(struct cdev* cdev, const void *buf, size_t _count, ulong offset, ulong flags)
+static ssize_t nand_write(struct cdev* cdev, const void *buf, size_t _count,
+			  ulong offset, ulong flags)
 {
 	struct mtd_info *info = cdev->priv;
 	size_t retlen, now;
@@ -75,24 +73,29 @@ static ssize_t nand_write(struct cdev* cdev, const void *buf, size_t _count, ulo
 		return -EINVAL;
 	}
 
-	debug("write: 0x%08lx 0x%08x\n", offset, count);
-
+	dev_dbg(cdev->dev, "write: 0x%08lx 0x%08x\n", offset, count);
 	while (count) {
 		now = count > info->writesize ? info->writesize : count;
 
 		if (NOTALIGNED(now)) {
-			debug("not aligned: %d %ld\n", info->writesize, (offset % info->writesize));
+			dev_dbg(cdev->dev, "not aligned: %d %ld\n",
+				info->writesize,
+				(offset % info->writesize));
 			wrbuf = xmalloc(info->writesize);
 			memset(wrbuf, 0xff, info->writesize);
 			memcpy(wrbuf + (offset % info->writesize), buf, now);
 			if (!all_ff(wrbuf, info->writesize))
-				ret = info->write(info, offset & ~(info->writesize - 1),
-						info->writesize, &retlen, wrbuf);
+				ret = info->write(info, MTDPGALG(offset),
+						  info->writesize, &retlen,
+						  wrbuf);
 			free(wrbuf);
 		} else {
 			if (!all_ff(buf, info->writesize))
-				ret = info->write(info, offset, now, &retlen, buf);
-			debug("offset: 0x%08lx now: 0x%08x retlen: 0x%08x\n", offset, now, retlen);
+				ret = info->write(info, offset, now, &retlen,
+						  buf);
+			dev_dbg(cdev->dev,
+				"offset: 0x%08lx now: 0x%08x retlen: 0x%08x\n",
+				offset, now, retlen);
 		}
 		if (ret)
 			goto out;
@@ -114,11 +117,11 @@ static int nand_ioctl(struct cdev *cdev, int request, void *buf)
 
 	switch (request) {
 	case MEMGETBADBLOCK:
-		debug("MEMGETBADBLOCK: 0x%08lx\n", (off_t)buf);
+		dev_dbg(cdev->dev, "MEMGETBADBLOCK: 0x%08lx\n", (off_t)buf);
 		return info->block_isbad(info, (off_t)buf);
 #ifdef CONFIG_NAND_WRITE
 	case MEMSETBADBLOCK:
-		debug("MEMSETBADBLOCK: 0x%08lx\n", (off_t)buf);
+		dev_dbg(cdev->dev, "MEMSETBADBLOCK: 0x%08lx\n", (off_t)buf);
 		return info->block_markbad(info, (off_t)buf);
 #endif
 	case MEMGETINFO:
@@ -150,7 +153,7 @@ static ssize_t nand_erase(struct cdev *cdev, size_t count, unsigned long offset)
 	erase.len = info->erasesize;
 
 	while (count > 0) {
-		debug("erase %d %d\n", erase.addr, erase.len);
+		dev_dbg(cdev->dev, "erase %d %d\n", erase.addr, erase.len);
 
 		ret = info->block_isbad(info, erase.addr);
 		if (ret > 0) {
@@ -169,13 +172,6 @@ static ssize_t nand_erase(struct cdev *cdev, size_t count, unsigned long offset)
 }
 #endif
 
-#if 0
-static char* mtd_get_size(struct device_d *, struct param_d *param)
-{
-	static char 
-}
-#endif
-
 static struct file_operations nand_ops = {
 	.read   = nand_read,
 #ifdef CONFIG_NAND_WRITE
@@ -187,7 +183,8 @@ static struct file_operations nand_ops = {
 };
 
 #ifdef CONFIG_NAND_READ_OOB
-static ssize_t nand_read_oob(struct cdev *cdev, void *buf, size_t count, ulong offset, ulong flags)
+static ssize_t nand_read_oob(struct cdev *cdev, void *buf, size_t count,
+			     ulong offset, ulong flags)
 {
 	struct mtd_info *info = cdev->priv;
 	struct nand_chip *chip = info->priv;
-- 
1.7.5.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2011-12-16 21:51 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-16 21:50 [PATCH V2 0/8] mtd framework rework Robert Jarzmik
2011-12-16 21:50 ` [PATCH V2 1/8] drivers/mtd: move nand.c into core.c Robert Jarzmik
2011-12-16 21:50 ` Robert Jarzmik [this message]
2011-12-16 21:50 ` [PATCH V2 3/8] drivers/mtd: transfer NAND notions to MTD core Robert Jarzmik
2011-12-19  9:49   ` Sascha Hauer
2011-12-19 10:48     ` Robert Jarzmik
2011-12-19 11:08       ` Sascha Hauer
2011-12-16 21:50 ` [PATCH V2 4/8] drivers/mtd: recover NAND default device name "nand" Robert Jarzmik
2011-12-16 21:50 ` [PATCH V2 5/8] drivers/mtd: fix core multiple MTD registrations Robert Jarzmik
2011-12-16 21:50 ` [PATCH V2 6/8] drivers/mtd: add mtd core hooks Robert Jarzmik
2011-12-16 21:50 ` [PATCH V2 7/8] mtd/drivers: split mtd mtdoob devices Robert Jarzmik
2011-12-19  9:50   ` Sascha Hauer
2011-12-19 10:50     ` Robert Jarzmik
2011-12-16 21:50 ` [PATCH V2 8/8] drivers/mtd: add the mtdraw device (data+oob) Robert Jarzmik

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=1324072234-31634-3-git-send-email-robert.jarzmik@free.fr \
    --to=robert.jarzmik@free.fr \
    --cc=barebox@lists.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox