All of lore.kernel.org
 help / color / mirror / Atom feed
From: Finn Thain <fthain@telegraphics.com.au>
To: <linux-kernel@vger.kernel.org>, <linux-m68k@vger.kernel.org>,
	<linuxppc-dev@lists.ozlabs.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>
Subject: [RFC v4 22/25] m68k/mac: Adopt naming and calling conventions for PRAM routines
Date: Sun, 12 Jul 2015 20:25:49 +1000	[thread overview]
Message-ID: <20150712102532.705917057@telegraphics.com.au> (raw)
In-Reply-To: 20150712102527.356151908@telegraphics.com.au

[-- Attachment #1: mac68k-pram-function-names-and-signatures --]
[-- Type: text/plain, Size: 6554 bytes --]

Adopt the existing *_read_byte and *_write_byte naming convention.
Rename via_pram_readbyte and via_pram_writebyte to avoid confusion.
Adjust calling conventions of mac_pram_* functions to match the
arch_nvram_ops struct methods.

Signed-off-by: Finn Thain <fthain@telegraphics.com.au>

---

Changes since v1:
- Don't introduce the arch_nvram_ops struct in this patch, even if it 
would form a logical progression. Since the struct would get replaced
later on, some might see it as churn.

Changes since v2:
- Rename via_pram_send() and via_pram_recv() as
via_rtc_send() and via_rtc_recv() resp.

---
 arch/m68k/mac/misc.c |   91 +++++++++++++++++++++++++--------------------------
 1 file changed, 46 insertions(+), 45 deletions(-)

Index: linux/arch/m68k/mac/misc.c
===================================================================
--- linux.orig/arch/m68k/mac/misc.c	2015-07-12 20:24:53.000000000 +1000
+++ linux/arch/m68k/mac/misc.c	2015-07-12 20:25:20.000000000 +1000
@@ -61,7 +61,7 @@ static void cuda_write_time(long data)
 		cuda_poll();
 }
 
-static __u8 cuda_read_pram(int offset)
+static unsigned char cuda_pram_read_byte(int offset)
 {
 	struct adb_request req;
 	if (cuda_request(&req, NULL, 4, CUDA_PACKET, CUDA_GET_PRAM,
@@ -72,7 +72,7 @@ static __u8 cuda_read_pram(int offset)
 	return req.reply[3];
 }
 
-static void cuda_write_pram(int offset, __u8 data)
+static void cuda_pram_write_byte(unsigned char data, int offset)
 {
 	struct adb_request req;
 	if (cuda_request(&req, NULL, 5, CUDA_PACKET, CUDA_SET_PRAM,
@@ -84,8 +84,8 @@ static void cuda_write_pram(int offset,
 #else
 #define cuda_read_time() 0
 #define cuda_write_time(n)
-#define cuda_read_pram NULL
-#define cuda_write_pram NULL
+#define cuda_pram_read_byte NULL
+#define cuda_pram_write_byte NULL
 #endif
 
 #ifdef CONFIG_ADB_PMU68K
@@ -116,7 +116,7 @@ static void pmu_write_time(long data)
 		pmu_poll();
 }
 
-static __u8 pmu_read_pram(int offset)
+static unsigned char pmu_pram_read_byte(int offset)
 {
 	struct adb_request req;
 	if (pmu_request(&req, NULL, 3, PMU_READ_NVRAM,
@@ -127,7 +127,7 @@ static __u8 pmu_read_pram(int offset)
 	return req.reply[3];
 }
 
-static void pmu_write_pram(int offset, __u8 data)
+static void pmu_pram_write_byte(unsigned char data, int offset)
 {
 	struct adb_request req;
 	if (pmu_request(&req, NULL, 4, PMU_WRITE_NVRAM,
@@ -139,8 +139,8 @@ static void pmu_write_pram(int offset, _
 #else
 #define pmu_read_time() 0
 #define pmu_write_time(n)
-#define pmu_read_pram NULL
-#define pmu_write_pram NULL
+#define pmu_pram_read_byte NULL
+#define pmu_pram_write_byte NULL
 #endif
 
 #if 0 /* def CONFIG_ADB_MACIISI */
@@ -169,7 +169,7 @@ static void maciisi_write_time(long data
 			(data >> 8) & 0xFF, data & 0xFF);
 }
 
-static __u8 maciisi_read_pram(int offset)
+static unsigned char maciisi_pram_read_byte(int offset)
 {
 	struct adb_request req;
 	if (maciisi_request(&req, NULL, 4, CUDA_PACKET, CUDA_GET_PRAM,
@@ -178,7 +178,7 @@ static __u8 maciisi_read_pram(int offset
 	return req.reply[3];
 }
 
-static void maciisi_write_pram(int offset, __u8 data)
+static void maciisi_pram_write_byte(unsigned char data, int offset)
 {
 	struct adb_request req;
 	maciisi_request(&req, NULL, 5, CUDA_PACKET, CUDA_SET_PRAM,
@@ -187,8 +187,8 @@ static void maciisi_write_pram(int offse
 #else
 #define maciisi_read_time() 0
 #define maciisi_write_time(n)
-#define maciisi_read_pram NULL
-#define maciisi_write_pram NULL
+#define maciisi_pram_read_byte NULL
+#define maciisi_pram_write_byte NULL
 #endif
 
 /*
@@ -198,7 +198,7 @@ static void maciisi_write_pram(int offse
  * the RTC should be enabled.
  */
 
-static __u8 via_pram_readbyte(void)
+static __u8 via_rtc_recv(void)
 {
 	int	i,reg;
 	__u8	data;
@@ -225,7 +225,7 @@ static __u8 via_pram_readbyte(void)
 	return data;
 }
 
-static void via_pram_writebyte(__u8 data)
+static void via_rtc_send(__u8 data)
 {
 	int	i,reg,bit;
 
@@ -262,17 +262,17 @@ static void via_pram_command(int command
 	via1[vBufB] = (via1[vBufB] | VIA1B_vRTCClk) & ~VIA1B_vRTCEnb;
 
 	if (command & 0xFF00) {		/* extended (two-byte) command */
-		via_pram_writebyte((command & 0xFF00) >> 8);
-		via_pram_writebyte(command & 0xFF);
+		via_rtc_send((command & 0xFF00) >> 8);
+		via_rtc_send(command & 0xFF);
 		is_read = command & 0x8000;
 	} else {			/* one-byte command */
-		via_pram_writebyte(command);
+		via_rtc_send(command);
 		is_read = command & 0x80;
 	}
 	if (is_read) {
-		*data = via_pram_readbyte();
+		*data = via_rtc_recv();
 	} else {
-		via_pram_writebyte(*data);
+		via_rtc_send(*data);
 	}
 
 	/* All done, disable the RTC */
@@ -282,12 +282,12 @@ static void via_pram_command(int command
 	local_irq_restore(flags);
 }
 
-static __u8 via_read_pram(int offset)
+static unsigned char via_pram_read_byte(int offset)
 {
 	return 0;
 }
 
-static void via_write_pram(int offset, __u8 data)
+static void via_pram_write_byte(unsigned char data, int offset)
 {
 }
 
@@ -453,50 +453,51 @@ void pmu_shutdown(void)
  *-------------------------------------------------------------------
  */
 
-void mac_pram_read(int offset, __u8 *buffer, int len)
+unsigned char mac_pram_read_byte(int addr)
 {
-	__u8 (*func)(int);
-	int i;
+	unsigned char (*func)(int);
 
 	switch(macintosh_config->adb_type) {
 	case MAC_ADB_IISI:
-		func = maciisi_read_pram; break;
+		func = maciisi_pram_read_byte;
+		break;
 	case MAC_ADB_PB1:
 	case MAC_ADB_PB2:
-		func = pmu_read_pram; break;
+		func = pmu_pram_read_byte;
+		break;
 	case MAC_ADB_CUDA:
-		func = cuda_read_pram; break;
+		func = cuda_pram_read_byte;
+		break;
 	default:
-		func = via_read_pram;
-	}
-	if (!func)
-		return;
-	for (i = 0 ; i < len ; i++) {
-		buffer[i] = (*func)(offset++);
+		func = via_pram_read_byte;
 	}
+
+	if (func)
+		return (*func)(addr);
+	return 0xff;
 }
 
-void mac_pram_write(int offset, __u8 *buffer, int len)
+void mac_pram_write_byte(unsigned char val, int addr)
 {
-	void (*func)(int, __u8);
-	int i;
+	void (*func)(unsigned char, int);
 
 	switch(macintosh_config->adb_type) {
 	case MAC_ADB_IISI:
-		func = maciisi_write_pram; break;
+		func = maciisi_pram_write_byte;
+		break;
 	case MAC_ADB_PB1:
 	case MAC_ADB_PB2:
-		func = pmu_write_pram; break;
+		func = pmu_pram_write_byte;
+		break;
 	case MAC_ADB_CUDA:
-		func = cuda_write_pram; break;
+		func = cuda_pram_write_byte;
+		break;
 	default:
-		func = via_write_pram;
-	}
-	if (!func)
-		return;
-	for (i = 0 ; i < len ; i++) {
-		(*func)(offset++, buffer[i]);
+		func = via_pram_write_byte;
 	}
+
+	if (func)
+		(*func)(val, addr);
 }
 
 void mac_poweroff(void)



WARNING: multiple messages have this Message-ID (diff)
From: Finn Thain <fthain@telegraphics.com.au>
To: linux-kernel@vger.kernel.org, linux-m68k@vger.kernel.org,
	linuxppc-dev@lists.ozlabs.org,
	Geert Uytterhoeven <geert@linux-m68k.org>
Subject: [RFC v4 22/25] m68k/mac: Adopt naming and calling conventions for PRAM routines
Date: Sun, 12 Jul 2015 20:25:49 +1000	[thread overview]
Message-ID: <20150712102532.705917057@telegraphics.com.au> (raw)
In-Reply-To: 20150712102527.356151908@telegraphics.com.au

[-- Attachment #1: mac68k-pram-function-names-and-signatures --]
[-- Type: text/plain, Size: 6552 bytes --]

Adopt the existing *_read_byte and *_write_byte naming convention.
Rename via_pram_readbyte and via_pram_writebyte to avoid confusion.
Adjust calling conventions of mac_pram_* functions to match the
arch_nvram_ops struct methods.

Signed-off-by: Finn Thain <fthain@telegraphics.com.au>

---

Changes since v1:
- Don't introduce the arch_nvram_ops struct in this patch, even if it 
would form a logical progression. Since the struct would get replaced
later on, some might see it as churn.

Changes since v2:
- Rename via_pram_send() and via_pram_recv() as
via_rtc_send() and via_rtc_recv() resp.

---
 arch/m68k/mac/misc.c |   91 +++++++++++++++++++++++++--------------------------
 1 file changed, 46 insertions(+), 45 deletions(-)

Index: linux/arch/m68k/mac/misc.c
===================================================================
--- linux.orig/arch/m68k/mac/misc.c	2015-07-12 20:24:53.000000000 +1000
+++ linux/arch/m68k/mac/misc.c	2015-07-12 20:25:20.000000000 +1000
@@ -61,7 +61,7 @@ static void cuda_write_time(long data)
 		cuda_poll();
 }
 
-static __u8 cuda_read_pram(int offset)
+static unsigned char cuda_pram_read_byte(int offset)
 {
 	struct adb_request req;
 	if (cuda_request(&req, NULL, 4, CUDA_PACKET, CUDA_GET_PRAM,
@@ -72,7 +72,7 @@ static __u8 cuda_read_pram(int offset)
 	return req.reply[3];
 }
 
-static void cuda_write_pram(int offset, __u8 data)
+static void cuda_pram_write_byte(unsigned char data, int offset)
 {
 	struct adb_request req;
 	if (cuda_request(&req, NULL, 5, CUDA_PACKET, CUDA_SET_PRAM,
@@ -84,8 +84,8 @@ static void cuda_write_pram(int offset,
 #else
 #define cuda_read_time() 0
 #define cuda_write_time(n)
-#define cuda_read_pram NULL
-#define cuda_write_pram NULL
+#define cuda_pram_read_byte NULL
+#define cuda_pram_write_byte NULL
 #endif
 
 #ifdef CONFIG_ADB_PMU68K
@@ -116,7 +116,7 @@ static void pmu_write_time(long data)
 		pmu_poll();
 }
 
-static __u8 pmu_read_pram(int offset)
+static unsigned char pmu_pram_read_byte(int offset)
 {
 	struct adb_request req;
 	if (pmu_request(&req, NULL, 3, PMU_READ_NVRAM,
@@ -127,7 +127,7 @@ static __u8 pmu_read_pram(int offset)
 	return req.reply[3];
 }
 
-static void pmu_write_pram(int offset, __u8 data)
+static void pmu_pram_write_byte(unsigned char data, int offset)
 {
 	struct adb_request req;
 	if (pmu_request(&req, NULL, 4, PMU_WRITE_NVRAM,
@@ -139,8 +139,8 @@ static void pmu_write_pram(int offset, _
 #else
 #define pmu_read_time() 0
 #define pmu_write_time(n)
-#define pmu_read_pram NULL
-#define pmu_write_pram NULL
+#define pmu_pram_read_byte NULL
+#define pmu_pram_write_byte NULL
 #endif
 
 #if 0 /* def CONFIG_ADB_MACIISI */
@@ -169,7 +169,7 @@ static void maciisi_write_time(long data
 			(data >> 8) & 0xFF, data & 0xFF);
 }
 
-static __u8 maciisi_read_pram(int offset)
+static unsigned char maciisi_pram_read_byte(int offset)
 {
 	struct adb_request req;
 	if (maciisi_request(&req, NULL, 4, CUDA_PACKET, CUDA_GET_PRAM,
@@ -178,7 +178,7 @@ static __u8 maciisi_read_pram(int offset
 	return req.reply[3];
 }
 
-static void maciisi_write_pram(int offset, __u8 data)
+static void maciisi_pram_write_byte(unsigned char data, int offset)
 {
 	struct adb_request req;
 	maciisi_request(&req, NULL, 5, CUDA_PACKET, CUDA_SET_PRAM,
@@ -187,8 +187,8 @@ static void maciisi_write_pram(int offse
 #else
 #define maciisi_read_time() 0
 #define maciisi_write_time(n)
-#define maciisi_read_pram NULL
-#define maciisi_write_pram NULL
+#define maciisi_pram_read_byte NULL
+#define maciisi_pram_write_byte NULL
 #endif
 
 /*
@@ -198,7 +198,7 @@ static void maciisi_write_pram(int offse
  * the RTC should be enabled.
  */
 
-static __u8 via_pram_readbyte(void)
+static __u8 via_rtc_recv(void)
 {
 	int	i,reg;
 	__u8	data;
@@ -225,7 +225,7 @@ static __u8 via_pram_readbyte(void)
 	return data;
 }
 
-static void via_pram_writebyte(__u8 data)
+static void via_rtc_send(__u8 data)
 {
 	int	i,reg,bit;
 
@@ -262,17 +262,17 @@ static void via_pram_command(int command
 	via1[vBufB] = (via1[vBufB] | VIA1B_vRTCClk) & ~VIA1B_vRTCEnb;
 
 	if (command & 0xFF00) {		/* extended (two-byte) command */
-		via_pram_writebyte((command & 0xFF00) >> 8);
-		via_pram_writebyte(command & 0xFF);
+		via_rtc_send((command & 0xFF00) >> 8);
+		via_rtc_send(command & 0xFF);
 		is_read = command & 0x8000;
 	} else {			/* one-byte command */
-		via_pram_writebyte(command);
+		via_rtc_send(command);
 		is_read = command & 0x80;
 	}
 	if (is_read) {
-		*data = via_pram_readbyte();
+		*data = via_rtc_recv();
 	} else {
-		via_pram_writebyte(*data);
+		via_rtc_send(*data);
 	}
 
 	/* All done, disable the RTC */
@@ -282,12 +282,12 @@ static void via_pram_command(int command
 	local_irq_restore(flags);
 }
 
-static __u8 via_read_pram(int offset)
+static unsigned char via_pram_read_byte(int offset)
 {
 	return 0;
 }
 
-static void via_write_pram(int offset, __u8 data)
+static void via_pram_write_byte(unsigned char data, int offset)
 {
 }
 
@@ -453,50 +453,51 @@ void pmu_shutdown(void)
  *-------------------------------------------------------------------
  */
 
-void mac_pram_read(int offset, __u8 *buffer, int len)
+unsigned char mac_pram_read_byte(int addr)
 {
-	__u8 (*func)(int);
-	int i;
+	unsigned char (*func)(int);
 
 	switch(macintosh_config->adb_type) {
 	case MAC_ADB_IISI:
-		func = maciisi_read_pram; break;
+		func = maciisi_pram_read_byte;
+		break;
 	case MAC_ADB_PB1:
 	case MAC_ADB_PB2:
-		func = pmu_read_pram; break;
+		func = pmu_pram_read_byte;
+		break;
 	case MAC_ADB_CUDA:
-		func = cuda_read_pram; break;
+		func = cuda_pram_read_byte;
+		break;
 	default:
-		func = via_read_pram;
-	}
-	if (!func)
-		return;
-	for (i = 0 ; i < len ; i++) {
-		buffer[i] = (*func)(offset++);
+		func = via_pram_read_byte;
 	}
+
+	if (func)
+		return (*func)(addr);
+	return 0xff;
 }
 
-void mac_pram_write(int offset, __u8 *buffer, int len)
+void mac_pram_write_byte(unsigned char val, int addr)
 {
-	void (*func)(int, __u8);
-	int i;
+	void (*func)(unsigned char, int);
 
 	switch(macintosh_config->adb_type) {
 	case MAC_ADB_IISI:
-		func = maciisi_write_pram; break;
+		func = maciisi_pram_write_byte;
+		break;
 	case MAC_ADB_PB1:
 	case MAC_ADB_PB2:
-		func = pmu_write_pram; break;
+		func = pmu_pram_write_byte;
+		break;
 	case MAC_ADB_CUDA:
-		func = cuda_write_pram; break;
+		func = cuda_pram_write_byte;
+		break;
 	default:
-		func = via_write_pram;
-	}
-	if (!func)
-		return;
-	for (i = 0 ; i < len ; i++) {
-		(*func)(offset++, buffer[i]);
+		func = via_pram_write_byte;
 	}
+
+	if (func)
+		(*func)(val, addr);
 }
 
 void mac_poweroff(void)

WARNING: multiple messages have this Message-ID (diff)
From: Finn Thain <fthain@telegraphics.com.au>
To: <linux-kernel@vger.kernel.org>, <linux-m68k@vger.kernel.org>,
	<linuxppc-dev@lists.ozlabs.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>
Subject: [RFC v4 22/25] m68k/mac: Adopt naming and calling conventions for PRAM routines
Date: Sun, 12 Jul 2015 20:25:49 +1000	[thread overview]
Message-ID: <20150712102532.705917057@telegraphics.com.au> (raw)
In-Reply-To: 20150712102527.356151908@telegraphics.com.au

Adopt the existing *_read_byte and *_write_byte naming convention.
Rename via_pram_readbyte and via_pram_writebyte to avoid confusion.
Adjust calling conventions of mac_pram_* functions to match the
arch_nvram_ops struct methods.

Signed-off-by: Finn Thain <fthain@telegraphics.com.au>

---

Changes since v1:
- Don't introduce the arch_nvram_ops struct in this patch, even if it 
would form a logical progression. Since the struct would get replaced
later on, some might see it as churn.

Changes since v2:
- Rename via_pram_send() and via_pram_recv() as
via_rtc_send() and via_rtc_recv() resp.

---
 arch/m68k/mac/misc.c |   91 +++++++++++++++++++++++++--------------------------
 1 file changed, 46 insertions(+), 45 deletions(-)

Index: linux/arch/m68k/mac/misc.c
===================================================================
--- linux.orig/arch/m68k/mac/misc.c	2015-07-12 20:24:53.000000000 +1000
+++ linux/arch/m68k/mac/misc.c	2015-07-12 20:25:20.000000000 +1000
@@ -61,7 +61,7 @@ static void cuda_write_time(long data)
 		cuda_poll();
 }
 
-static __u8 cuda_read_pram(int offset)
+static unsigned char cuda_pram_read_byte(int offset)
 {
 	struct adb_request req;
 	if (cuda_request(&req, NULL, 4, CUDA_PACKET, CUDA_GET_PRAM,
@@ -72,7 +72,7 @@ static __u8 cuda_read_pram(int offset)
 	return req.reply[3];
 }
 
-static void cuda_write_pram(int offset, __u8 data)
+static void cuda_pram_write_byte(unsigned char data, int offset)
 {
 	struct adb_request req;
 	if (cuda_request(&req, NULL, 5, CUDA_PACKET, CUDA_SET_PRAM,
@@ -84,8 +84,8 @@ static void cuda_write_pram(int offset,
 #else
 #define cuda_read_time() 0
 #define cuda_write_time(n)
-#define cuda_read_pram NULL
-#define cuda_write_pram NULL
+#define cuda_pram_read_byte NULL
+#define cuda_pram_write_byte NULL
 #endif
 
 #ifdef CONFIG_ADB_PMU68K
@@ -116,7 +116,7 @@ static void pmu_write_time(long data)
 		pmu_poll();
 }
 
-static __u8 pmu_read_pram(int offset)
+static unsigned char pmu_pram_read_byte(int offset)
 {
 	struct adb_request req;
 	if (pmu_request(&req, NULL, 3, PMU_READ_NVRAM,
@@ -127,7 +127,7 @@ static __u8 pmu_read_pram(int offset)
 	return req.reply[3];
 }
 
-static void pmu_write_pram(int offset, __u8 data)
+static void pmu_pram_write_byte(unsigned char data, int offset)
 {
 	struct adb_request req;
 	if (pmu_request(&req, NULL, 4, PMU_WRITE_NVRAM,
@@ -139,8 +139,8 @@ static void pmu_write_pram(int offset, _
 #else
 #define pmu_read_time() 0
 #define pmu_write_time(n)
-#define pmu_read_pram NULL
-#define pmu_write_pram NULL
+#define pmu_pram_read_byte NULL
+#define pmu_pram_write_byte NULL
 #endif
 
 #if 0 /* def CONFIG_ADB_MACIISI */
@@ -169,7 +169,7 @@ static void maciisi_write_time(long data
 			(data >> 8) & 0xFF, data & 0xFF);
 }
 
-static __u8 maciisi_read_pram(int offset)
+static unsigned char maciisi_pram_read_byte(int offset)
 {
 	struct adb_request req;
 	if (maciisi_request(&req, NULL, 4, CUDA_PACKET, CUDA_GET_PRAM,
@@ -178,7 +178,7 @@ static __u8 maciisi_read_pram(int offset
 	return req.reply[3];
 }
 
-static void maciisi_write_pram(int offset, __u8 data)
+static void maciisi_pram_write_byte(unsigned char data, int offset)
 {
 	struct adb_request req;
 	maciisi_request(&req, NULL, 5, CUDA_PACKET, CUDA_SET_PRAM,
@@ -187,8 +187,8 @@ static void maciisi_write_pram(int offse
 #else
 #define maciisi_read_time() 0
 #define maciisi_write_time(n)
-#define maciisi_read_pram NULL
-#define maciisi_write_pram NULL
+#define maciisi_pram_read_byte NULL
+#define maciisi_pram_write_byte NULL
 #endif
 
 /*
@@ -198,7 +198,7 @@ static void maciisi_write_pram(int offse
  * the RTC should be enabled.
  */
 
-static __u8 via_pram_readbyte(void)
+static __u8 via_rtc_recv(void)
 {
 	int	i,reg;
 	__u8	data;
@@ -225,7 +225,7 @@ static __u8 via_pram_readbyte(void)
 	return data;
 }
 
-static void via_pram_writebyte(__u8 data)
+static void via_rtc_send(__u8 data)
 {
 	int	i,reg,bit;
 
@@ -262,17 +262,17 @@ static void via_pram_command(int command
 	via1[vBufB] = (via1[vBufB] | VIA1B_vRTCClk) & ~VIA1B_vRTCEnb;
 
 	if (command & 0xFF00) {		/* extended (two-byte) command */
-		via_pram_writebyte((command & 0xFF00) >> 8);
-		via_pram_writebyte(command & 0xFF);
+		via_rtc_send((command & 0xFF00) >> 8);
+		via_rtc_send(command & 0xFF);
 		is_read = command & 0x8000;
 	} else {			/* one-byte command */
-		via_pram_writebyte(command);
+		via_rtc_send(command);
 		is_read = command & 0x80;
 	}
 	if (is_read) {
-		*data = via_pram_readbyte();
+		*data = via_rtc_recv();
 	} else {
-		via_pram_writebyte(*data);
+		via_rtc_send(*data);
 	}
 
 	/* All done, disable the RTC */
@@ -282,12 +282,12 @@ static void via_pram_command(int command
 	local_irq_restore(flags);
 }
 
-static __u8 via_read_pram(int offset)
+static unsigned char via_pram_read_byte(int offset)
 {
 	return 0;
 }
 
-static void via_write_pram(int offset, __u8 data)
+static void via_pram_write_byte(unsigned char data, int offset)
 {
 }
 
@@ -453,50 +453,51 @@ void pmu_shutdown(void)
  *-------------------------------------------------------------------
  */
 
-void mac_pram_read(int offset, __u8 *buffer, int len)
+unsigned char mac_pram_read_byte(int addr)
 {
-	__u8 (*func)(int);
-	int i;
+	unsigned char (*func)(int);
 
 	switch(macintosh_config->adb_type) {
 	case MAC_ADB_IISI:
-		func = maciisi_read_pram; break;
+		func = maciisi_pram_read_byte;
+		break;
 	case MAC_ADB_PB1:
 	case MAC_ADB_PB2:
-		func = pmu_read_pram; break;
+		func = pmu_pram_read_byte;
+		break;
 	case MAC_ADB_CUDA:
-		func = cuda_read_pram; break;
+		func = cuda_pram_read_byte;
+		break;
 	default:
-		func = via_read_pram;
-	}
-	if (!func)
-		return;
-	for (i = 0 ; i < len ; i++) {
-		buffer[i] = (*func)(offset++);
+		func = via_pram_read_byte;
 	}
+
+	if (func)
+		return (*func)(addr);
+	return 0xff;
 }
 
-void mac_pram_write(int offset, __u8 *buffer, int len)
+void mac_pram_write_byte(unsigned char val, int addr)
 {
-	void (*func)(int, __u8);
-	int i;
+	void (*func)(unsigned char, int);
 
 	switch(macintosh_config->adb_type) {
 	case MAC_ADB_IISI:
-		func = maciisi_write_pram; break;
+		func = maciisi_pram_write_byte;
+		break;
 	case MAC_ADB_PB1:
 	case MAC_ADB_PB2:
-		func = pmu_write_pram; break;
+		func = pmu_pram_write_byte;
+		break;
 	case MAC_ADB_CUDA:
-		func = cuda_write_pram; break;
+		func = cuda_pram_write_byte;
+		break;
 	default:
-		func = via_write_pram;
-	}
-	if (!func)
-		return;
-	for (i = 0 ; i < len ; i++) {
-		(*func)(offset++, buffer[i]);
+		func = via_pram_write_byte;
 	}
+
+	if (func)
+		(*func)(val, addr);
 }
 
 void mac_poweroff(void)

  parent reply	other threads:[~2015-07-12 10:42 UTC|newest]

Thread overview: 115+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-12 10:25 [RFC v4 00/25] Re-use nvram module Finn Thain
2015-07-12 10:25 ` Finn Thain
2015-07-12 10:25 ` [RFC v4 01/25] scsi/atari_scsi: Dont select CONFIG_NVRAM Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25 ` [RFC v4 02/25] char/nvram: Use bitwise OR to obtain Atari video mode data Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25 ` [RFC v4 03/25] m68k/atari: Move Atari-specific code out of drivers/char/nvram.c Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-13 18:13   ` Andreas Schwab
2015-07-13 18:13     ` Andreas Schwab
2015-07-14  8:17     ` Finn Thain
2015-07-14  8:23       ` Geert Uytterhoeven
2015-07-14  8:33         ` Andreas Schwab
2015-07-14  8:33           ` Andreas Schwab
2015-07-22  3:52       ` Michael Schmitz
2015-07-22  4:22         ` Finn Thain
2015-07-22 14:32           ` Christian T. Steigies
2015-07-22 23:46             ` Michael Schmitz
2015-07-23  0:49               ` Finn Thain
2015-07-23  9:21           ` Christian T. Steigies
2015-07-24  2:56             ` Michael Schmitz
2015-07-24 19:07               ` Christian T. Steigies
2015-07-25  0:35                 ` Finn Thain
2015-07-25  1:00                   ` Michael Ellerman
2015-07-25  7:38                     ` Finn Thain
2015-07-26  1:37                     ` Finn Thain
2015-07-25  0:51                 ` Michael Schmitz
2015-07-25  7:27                   ` Finn Thain
2015-07-26  1:02                     ` Michael Schmitz
2015-07-26  1:19                       ` Finn Thain
2015-07-27  2:23                         ` Michael Schmitz
2015-07-27  5:51                           ` Finn Thain
2015-07-12 10:25 ` [RFC v4 04/25] m68k/atari: Replace nvram_{read,write}_byte with arch_nvram_ops Finn Thain
2015-07-12 10:25   ` [RFC v4 04/25] m68k/atari: Replace nvram_{read, write}_byte " Finn Thain
2015-07-12 10:25   ` [RFC v4 04/25] m68k/atari: Replace nvram_{read,write}_byte " Finn Thain
2015-07-12 10:25 ` [RFC v4 05/25] char/nvram: Re-order functions to remove forward declarations and #ifdefs Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25 ` [RFC v4 06/25] char/nvram: Adopt arch_nvram_ops Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25 ` [RFC v4 07/25] x86/thinkpad_acpi: Use arch_nvram_ops methods instead of nvram_read_byte() and nvram_write_byte() Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25 ` [RFC v4 08/25] char/nvram: Allow the set_checksum and initialize ioctls to be omitted Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25 ` [RFC v4 09/25] char/nvram: Implement NVRAM read/write methods Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25 ` [RFC v4 10/25] char/nvram: Use generic fixed_size_llseek() Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25 ` [RFC v4 11/25] m68k/atari: Implement arch_nvram_ops methods and enable CONFIG_HAVE_ARCH_NVRAM_OPS Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25 ` [RFC v4 12/25] char/nvram: Add "devname:nvram" module alias Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25 ` [RFC v4 13/25] powerpc: Cleanup nvram includes Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25 ` [RFC v4 14/25] powerpc: Add missing ppc_md.nvram_size for CHRP and PowerMac Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25 ` [RFC v4 15/25] powerpc: Implement arch_nvram_ops.get_size() and remove old nvram_* exports Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25 ` [RFC v4 16/25] powerpc: Implement nvram sync ioctl Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25 ` [RFC v4 17/25] powerpc, fbdev: Use arch_nvram_ops methods instead of nvram_read_byte() and nvram_write_byte() Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25   ` [RFC v4 17/25] powerpc, fbdev: Use arch_nvram_ops methods instead of nvram_read_byte() and nvram_wri Finn Thain
2015-07-12 10:25   ` [RFC v4 17/25] powerpc, fbdev: Use arch_nvram_ops methods instead of nvram_read_byte() and nvram_write_byte() Finn Thain
2015-07-14  7:58   ` Finn Thain
2015-07-14  7:58     ` [RFC v4 17/25] powerpc, fbdev: Use arch_nvram_ops methods instead of nvram_read_byte() and nvram Finn Thain
2015-07-14 11:52     ` [RFC v4 17/25] powerpc, fbdev: Use arch_nvram_ops methods instead of nvram_read_byte() and nvram_write_byte() Benjamin Herrenschmidt
2015-07-14 11:52       ` [RFC v4 17/25] powerpc, fbdev: Use arch_nvram_ops methods instead of nvram_read_byte() and nvram Benjamin Herrenschmidt
2015-07-15  5:21       ` [RFC v4 17/25] powerpc, fbdev: Use arch_nvram_ops methods instead of nvram_read_byte() and nvram_write_byte() Finn Thain
2015-07-15  5:21         ` [RFC v4 17/25] powerpc, fbdev: Use arch_nvram_ops methods instead of nvram_read_byte() and nvram Finn Thain
2015-07-16  6:01         ` [RFC v4 17/25] powerpc, fbdev: Use arch_nvram_ops methods instead of nvram_read_byte() and nvram_write_byte() Finn Thain
2015-07-16  6:01           ` [RFC v4 17/25] powerpc, fbdev: Use arch_nvram_ops methods instead of nvram_read_byte() and nvram Finn Thain
2015-09-18  8:17           ` [RFC v4 17/25] powerpc, fbdev: Use arch_nvram_ops methods instead of nvram_read_byte() and nvram_write_byte() Finn Thain
2015-09-18  8:17             ` [RFC v4 17/25] powerpc, fbdev: Use arch_nvram_ops methods instead of nvram_read_byte() and nvram Finn Thain
2015-07-12 10:25 ` [RFC v4 18/25] nvram: Drop nvram_* symbol exports and prototypes Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25 ` [RFC v4 19/25] powerpc: Remove CONFIG_GENERIC_NVRAM and adopt CONFIG_HAVE_ARCH_NVRAM_OPS Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25 ` [RFC v4 20/25] char/generic_nvram: Remove as unused Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25 ` [RFC v4 21/25] powerpc: Adopt nvram module for PPC64 Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25 ` Finn Thain [this message]
2015-07-12 10:25   ` [RFC v4 22/25] m68k/mac: Adopt naming and calling conventions for PRAM routines Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25 ` [RFC v4 23/25] m68k/mac: Use macros for RTC accesses not magic numbers Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25 ` [RFC v4 24/25] m68k/mac: Fix PRAM accessors Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25 ` [RFC v4 25/25] m68k: Dispatch nvram_ops calls to Atari or Mac functions Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-12 10:25   ` Finn Thain
2015-07-13  7:55 ` [RFC v4 00/25] Re-use nvram module Geert Uytterhoeven
2015-07-14  7:57   ` Finn Thain

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=20150712102532.705917057@telegraphics.com.au \
    --to=fthain@telegraphics.com.au \
    --cc=geert@linux-m68k.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.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.