Skip to contentSkip to conversation

mmc: omap3: make local symbols static

PATCH New Grazvydas Ignotas 4 participants 6 messages Jun 16, 2010 – Aug 13, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 mmc: omap3: make local symbols static

Make driver local variables and functions static and remove them from the arch header.

---
 arch/arm/include/asm/arch-omap3/mmc.h |    9 ---------
 drivers/mmc/omap3_mmc.c               |   33 +++++++++++++++++----------------
 2 files changed, 17 insertions(+), 25 deletions(-)
arch/arm/include/asm/arch-omap3/mmc.h +0 -9
index 196ffdc..3e3e631 100644
@@ -230,13 +230,4 @@ typedef union {
 	mmc_csd_reg_t Card_CSD;
 } mmc_resp_t;
 
-extern mmc_card_data mmc_dev;
-
-unsigned char mmc_lowlevel_init(void);
-unsigned char mmc_send_command(unsigned int cmd, unsigned int arg,
-			       unsigned int *response);
-unsigned char mmc_setup_clock(unsigned int iclk, unsigned short clkd);
-unsigned char mmc_set_opendrain(unsigned char state);
-unsigned char mmc_read_data(unsigned int *output_buf);
-
 #endif /* MMC_H */
drivers/mmc/omap3_mmc.c +17 -16
index 96c0e65..dc331a0 100644
@@ -32,7 +32,7 @@
 #include <asm/io.h>
 #include <asm/arch/mmc.h>
 
-const unsigned short mmc_transspeed_val[15][4] = {
+static const unsigned short mmc_transspeed_val[15][4] = {
 	{CLKD(10, 1), CLKD(10, 10), CLKD(10, 100), CLKD(10, 1000)},
 	{CLKD(12, 1), CLKD(12, 10), CLKD(12, 100), CLKD(12, 1000)},
 	{CLKD(13, 1), CLKD(13, 10), CLKD(13, 100), CLKD(13, 1000)},
@@ -50,7 +50,7 @@ const unsigned short mmc_transspeed_val[15][4] = {
 	{CLKD(80, 1), CLKD(80, 10), CLKD(80, 100), CLKD(80, 1000)}
 };
 
-mmc_card_data cur_card_data;
+static mmc_card_data cur_card_data;
 static block_dev_desc_t mmc_blk_dev;
 static hsmmc_t *mmc_base = (hsmmc_t *)OMAP_HSMMC_BASE;
 
@@ -59,7 +59,7 @@ block_dev_desc_t *mmc_get_dev(int dev)
 	return (block_dev_desc_t *) &mmc_blk_dev;
 }
 
-unsigned char mmc_board_init(void)
+static unsigned char mmc_board_init(void)
 {
 	t2_t *t2_base = (t2_t *)T2_BASE;
 
@@ -77,7 +77,7 @@ unsigned char mmc_board_init(void)
 	return 1;
 }
 
-void mmc_init_stream(void)
+static void mmc_init_stream(void)
 {
 	writel(readl(&mmc_base->con) | INIT_INITSTREAM, &mmc_base->con);
 
@@ -92,7 +92,7 @@ void mmc_init_stream(void)
 	writel(readl(&mmc_base->con) & ~INIT_INITSTREAM, &mmc_base->con);
 }
 
-unsigned char mmc_clock_config(unsigned int iclk, unsigned short clk_div)
+static unsigned char mmc_clock_config(unsigned int iclk, unsigned short clk_div)
 {
 	unsigned int val;
 
@@ -121,7 +121,7 @@ unsigned char mmc_clock_config(unsigned int iclk, unsigned short clk_div)
 	return 1;
 }
 
-unsigned char mmc_init_setup(void)
+static unsigned char mmc_init_setup(void)
 {
 	unsigned int reg_val;
 
@@ -155,7 +155,7 @@ unsigned char mmc_init_setup(void)
 	return 1;
 }
 
-unsigned char mmc_send_cmd(unsigned int cmd, unsigned int arg,
+static unsigned char mmc_send_cmd(unsigned int cmd, unsigned int arg,
 				unsigned int *response)
 {
 	unsigned int mmc_stat;
@@ -191,7 +191,7 @@ unsigned char mmc_send_cmd(unsigned int cmd, unsigned int arg,
 	return 1;
 }
 
-unsigned char mmc_read_data(unsigned int *output_buf)
+static unsigned char mmc_read_data(unsigned int *output_buf)
 {
 	unsigned int mmc_stat;
 	unsigned int read_count = 0;
@@ -232,7 +232,7 @@ unsigned char mmc_read_data(unsigned int *output_buf)
 	return 1;
 }
 
-unsigned char mmc_detect_card(mmc_card_data *mmc_card_cur)
+static unsigned char mmc_detect_card(mmc_card_data *mmc_card_cur)
 {
 	unsigned char err;
 	unsigned int argument = 0;
@@ -343,7 +343,7 @@ unsigned char mmc_detect_card(mmc_card_data *mmc_card_cur)
 	return 1;
 }
 
-unsigned char mmc_read_cardsize(mmc_card_data *mmc_dev_data,
+static unsigned char mmc_read_cardsize(mmc_card_data *mmc_dev_data,
 				mmc_csd_reg_t *cur_csd)
 {
 	mmc_extended_csd_reg_t ext_csd;
@@ -397,9 +397,9 @@ unsigned char mmc_read_cardsize(mmc_card_data *mmc_dev_data,
 	return 1;
 }
 
-unsigned char omap_mmc_read_sect(unsigned int start_sec, unsigned int num_bytes,
-				 mmc_card_data *mmc_c,
-				 unsigned long *output_buf)
+static unsigned char omap_mmc_read_sect(unsigned int start_sec,
+		unsigned int num_bytes, mmc_card_data *mmc_c,
+		unsigned long *output_buf)
 {
 	unsigned char err;
 	unsigned int argument;
@@ -435,7 +435,7 @@ unsigned char omap_mmc_read_sect(unsigned int start_sec, unsigned int num_bytes,
 	return 1;
 }
 
-unsigned char configure_mmc(mmc_card_data *mmc_card_cur)
+static unsigned char configure_mmc(mmc_card_data *mmc_card_cur)
 {
 	unsigned char ret_val;
 	unsigned int argument;
@@ -504,8 +504,9 @@ unsigned char configure_mmc(mmc_card_data *mmc_card_cur)
 
 	return 1;
 }
-unsigned long mmc_bread(int dev_num, unsigned long blknr, lbaint_t blkcnt,
-			void *dst)
+
+static unsigned long mmc_bread(int dev_num, unsigned long blknr,
+		lbaint_t blkcnt, void *dst)
 {
 	omap_mmc_read_sect(blknr, (blkcnt * MMCSD_SECTOR_SIZE), &cur_card_data,
 				(unsigned long *) dst);
Signature · 1 line
1.6.3.3
#1 lore raw

PATCH 2/2 mmc: omap3: fix block read function

The OMAP3 block read function is not following API and always returning 1 instead of read block count, fix it. Also to simplify code, merge it with with a helper function, which was only called from the block read function.

After this patch ext2 filesystem can be used properly.

---
 drivers/mmc/omap3_mmc.c |   47 +++++++++++++++++++++--------------------------
 1 files changed, 21 insertions(+), 26 deletions(-)
drivers/mmc/omap3_mmc.c +21 -26
index dc331a0..af74997 100644
@@ -397,42 +397,45 @@ static unsigned char mmc_read_cardsize(mmc_card_data *mmc_dev_data,
 	return 1;
 }
 
-static unsigned char omap_mmc_read_sect(unsigned int start_sec,
-		unsigned int num_bytes, mmc_card_data *mmc_c,
-		unsigned long *output_buf)
+static unsigned long mmc_bread(int dev_num, unsigned long blknr,
+		lbaint_t blkcnt, void *dst)
 {
 	unsigned char err;
 	unsigned int argument;
 	unsigned int resp[4];
-	unsigned int num_sec_val =
-		(num_bytes + (MMCSD_SECTOR_SIZE - 1)) / MMCSD_SECTOR_SIZE;
+	unsigned int *output_buf = dst;
 	unsigned int sec_inc_val;
+	lbaint_t i;
 
-	if (num_sec_val == 0)
-		return 1;
+	if (blkcnt == 0)
+		return 0;
 
-	if (mmc_c->mode == SECTOR_MODE) {
-		argument = start_sec;
+	if (cur_card_data.mode == SECTOR_MODE) {
+		argument = blknr;
 		sec_inc_val = 1;
 	} else {
-		argument = start_sec * MMCSD_SECTOR_SIZE;
+		argument = blknr * MMCSD_SECTOR_SIZE;
 		sec_inc_val = MMCSD_SECTOR_SIZE;
 	}
 
-	while (num_sec_val) {
+	for (i = 0; i < blkcnt; i++) {
 		err = mmc_send_cmd(MMC_CMD17, argument, resp);
-		if (err != 1)
-			return err;
+		if (err != 1) {
+			printf("mmc: CMD17 failed, status = %08x\n", err);
+			break;
+		}
 
-		err = mmc_read_data((unsigned int *) output_buf);
-		if (err != 1)
-			return err;
+		err = mmc_read_data(output_buf);
+		if (err != 1) {
+			printf("mmc: read failed, status = %08x\n", err);
+			break;
+		}
 
 		output_buf += (MMCSD_SECTOR_SIZE / 4);
 		argument += sec_inc_val;
-		num_sec_val--;
 	}
-	return 1;
+
+	return i;
 }
 
 static unsigned char configure_mmc(mmc_card_data *mmc_card_cur)
@@ -505,14 +508,6 @@ static unsigned char configure_mmc(mmc_card_data *mmc_card_cur)
 	return 1;
 }
 
-static unsigned long mmc_bread(int dev_num, unsigned long blknr,
-		lbaint_t blkcnt, void *dst)
-{
-	omap_mmc_read_sect(blknr, (blkcnt * MMCSD_SECTOR_SIZE), &cur_card_data,
-				(unsigned long *) dst);
-	return 1;
-}
-
 int mmc_legacy_init(int verbose)
 {
 	if (configure_mmc(&cur_card_data) != 1)
Signature · 1 line
1.6.3.3
#2 lore raw

PATCH 1/2 mmc: omap3: make local symbols static

In reply to Grazvydas Ignotas

Dear Andy,

Quoted 8 lines · In message <[email protected]> Grazvydas…

Make driver local variables and functions static and remove them from the arch header.

---
 arch/arm/include/asm/arch-omap3/mmc.h |    9 ---------
 drivers/mmc/omap3_mmc.c               |   33 +++++++++++++++++----------------
 2 files changed, 17 insertions(+), 25 deletions(-)

I haven't seen commants for these two patches:

http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/79999

Are they in your queue?

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Conquest is easy. Control is not.
	-- Kirk, "Mirror, Mirror", stardate unknown
#3 lore raw

PATCH 1/2 mmc: omap3: make local symbols static

Quoted 12 lines · Wolfgang Denk

Dear Andy,

Quoted 8 lines · In message <[email protected]> Grazvydas…

Make driver local variables and functions static and remove them from the arch header.

---
?arch/arm/include/asm/arch-omap3/mmc.h | ? ?9 --------- ?drivers/mmc/omap3_mmc.c ? ? ? ? ? ? ? | ? 33 +++++++++++++++++---------------- ?2 files changed, 17 insertions(+), 25 deletions(-)

Quoted 3 lines

I haven't seen commants for these two patches:

http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/79999

I tested these two patches today on Beagle (OMAP3) and Panda (OMAP4).

I was able to boot linux and rootfs images from MMC on both machines, so:

Unfortunately the patches didn't apply cleanly, but the fixes were simple. I have the modified patches in the omap4-next-upstream branch of my repo for convenience:

http://www.sakoman.com/cgi-bin/gitweb.cgi?p=u-boot.git;a=shortlog;h=refs/heads/omap4-next-upstream

Regards,

Steve

#4 lore raw

PATCH 1/2 mmc: omap3: make local symbols static

Quoted 33 lines

Subject: Re: [U-Boot] [PATCH 1/2] mmc: omap3: make local symbols static

Quoted 3 lines · Wolfgang Denk

Dear Andy,

In message <[email protected]>

Quoted 7 lines · Grazvydas Ignotas
Quoted 7 lines

Make driver local variables and functions static and remove them from the arch header.

---
?arch/arm/include/asm/arch-omap3/mmc.h | ? ?9 --------- ?drivers/mmc/omap3_mmc.c ? ? ? ? ? ? ? | ? 33 +++++++++++++++++--------

--------

Quoted 5 lines
Quoted 1 line

?2 files changed, 17 insertions(+), 25 deletions(-)

I haven't seen commants for these two patches:

http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/79999

I tested these two patches today on Beagle (OMAP3) and Panda (OMAP4).

I was able to boot linux and rootfs images from MMC on both machines, so:

Unfortunately the patches didn't apply cleanly, but the fixes were simple. I have the modified patches in the omap4-next-upstream branch of my repo for convenience:

Quoted 6 lines

http://www.sakoman.com/cgi-bin/gitweb.cgi?p=u-
boot.git;a=shortlog;h=refs/heads/omap4-next-upstream

Regards,

Steve

I have added to u-boot-ti master.

The e-mail address in the signed-off-by was incorrect. I believe using "at" is not allowed.

I manually edited. I'll send a pull request to Wolfgang.

Its upto him to accept these mmc related patches.

Regards,
Sandeep

#5 lore raw

PATCH 1/2 mmc: omap3: make local symbols static

Quoted 9 lines
Quoted 9 lines

Unfortunately the patches didn't apply cleanly, but the fixes were simple. ?I have the modified patches in the omap4-next-upstream branch of my repo for convenience:

http://www.sakoman.com/cgi-bin/gitweb.cgi?p=u-
boot.git;a=shortlog;h=refs/heads/omap4-next-upstream

Regards,

Quoted 8 lines
Quoted 1 line

Steve

I have added to u-boot-ti master.

The e-mail address in the signed-off-by was incorrect. I believe using "at" is not allowed.

I manually edited. I'll send a pull request to Wolfgang.

Looking good, thanks Steve and Sandeep!