ieee1394/ieee1394_transactions: LIndent fixes
This patch contains fixes by LIndent. Signed-off-by: Jens-Michael Hoffmann <jensmh@gmx.de> Signed-off-by: Jody McIntyre <scjody@modernduck.com>
This commit is contained in:
parent
6649e92d79
commit
16c333a34a
|
@ -24,7 +24,6 @@
|
||||||
#include "nodemgr.h"
|
#include "nodemgr.h"
|
||||||
#include "ieee1394_transactions.h"
|
#include "ieee1394_transactions.h"
|
||||||
|
|
||||||
|
|
||||||
#define PREP_ASYNC_HEAD_ADDRESS(tc) \
|
#define PREP_ASYNC_HEAD_ADDRESS(tc) \
|
||||||
packet->tcode = tc; \
|
packet->tcode = tc; \
|
||||||
packet->header[0] = (packet->node_id << 16) | (packet->tlabel << 10) \
|
packet->header[0] = (packet->node_id << 16) | (packet->tlabel << 10) \
|
||||||
|
@ -32,80 +31,82 @@
|
||||||
packet->header[1] = (packet->host->node_id << 16) | (addr >> 32); \
|
packet->header[1] = (packet->host->node_id << 16) | (addr >> 32); \
|
||||||
packet->header[2] = addr & 0xffffffff
|
packet->header[2] = addr & 0xffffffff
|
||||||
|
|
||||||
|
|
||||||
static void fill_async_readquad(struct hpsb_packet *packet, u64 addr)
|
static void fill_async_readquad(struct hpsb_packet *packet, u64 addr)
|
||||||
{
|
{
|
||||||
PREP_ASYNC_HEAD_ADDRESS(TCODE_READQ);
|
PREP_ASYNC_HEAD_ADDRESS(TCODE_READQ);
|
||||||
packet->header_size = 12;
|
packet->header_size = 12;
|
||||||
packet->data_size = 0;
|
packet->data_size = 0;
|
||||||
packet->expect_response = 1;
|
packet->expect_response = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fill_async_readblock(struct hpsb_packet *packet, u64 addr, int length)
|
static void fill_async_readblock(struct hpsb_packet *packet, u64 addr,
|
||||||
|
int length)
|
||||||
{
|
{
|
||||||
PREP_ASYNC_HEAD_ADDRESS(TCODE_READB);
|
PREP_ASYNC_HEAD_ADDRESS(TCODE_READB);
|
||||||
packet->header[3] = length << 16;
|
packet->header[3] = length << 16;
|
||||||
packet->header_size = 16;
|
packet->header_size = 16;
|
||||||
packet->data_size = 0;
|
packet->data_size = 0;
|
||||||
packet->expect_response = 1;
|
packet->expect_response = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fill_async_writequad(struct hpsb_packet *packet, u64 addr, quadlet_t data)
|
static void fill_async_writequad(struct hpsb_packet *packet, u64 addr,
|
||||||
|
quadlet_t data)
|
||||||
{
|
{
|
||||||
PREP_ASYNC_HEAD_ADDRESS(TCODE_WRITEQ);
|
PREP_ASYNC_HEAD_ADDRESS(TCODE_WRITEQ);
|
||||||
packet->header[3] = data;
|
packet->header[3] = data;
|
||||||
packet->header_size = 16;
|
packet->header_size = 16;
|
||||||
packet->data_size = 0;
|
packet->data_size = 0;
|
||||||
packet->expect_response = 1;
|
packet->expect_response = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fill_async_writeblock(struct hpsb_packet *packet, u64 addr, int length)
|
static void fill_async_writeblock(struct hpsb_packet *packet, u64 addr,
|
||||||
|
int length)
|
||||||
{
|
{
|
||||||
PREP_ASYNC_HEAD_ADDRESS(TCODE_WRITEB);
|
PREP_ASYNC_HEAD_ADDRESS(TCODE_WRITEB);
|
||||||
packet->header[3] = length << 16;
|
packet->header[3] = length << 16;
|
||||||
packet->header_size = 16;
|
packet->header_size = 16;
|
||||||
packet->expect_response = 1;
|
packet->expect_response = 1;
|
||||||
packet->data_size = length + (length % 4 ? 4 - (length % 4) : 0);
|
packet->data_size = length + (length % 4 ? 4 - (length % 4) : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fill_async_lock(struct hpsb_packet *packet, u64 addr, int extcode,
|
static void fill_async_lock(struct hpsb_packet *packet, u64 addr, int extcode,
|
||||||
int length)
|
int length)
|
||||||
{
|
{
|
||||||
PREP_ASYNC_HEAD_ADDRESS(TCODE_LOCK_REQUEST);
|
PREP_ASYNC_HEAD_ADDRESS(TCODE_LOCK_REQUEST);
|
||||||
packet->header[3] = (length << 16) | extcode;
|
packet->header[3] = (length << 16) | extcode;
|
||||||
packet->header_size = 16;
|
packet->header_size = 16;
|
||||||
packet->data_size = length;
|
packet->data_size = length;
|
||||||
packet->expect_response = 1;
|
packet->expect_response = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fill_iso_packet(struct hpsb_packet *packet, int length, int channel,
|
static void fill_iso_packet(struct hpsb_packet *packet, int length, int channel,
|
||||||
int tag, int sync)
|
int tag, int sync)
|
||||||
{
|
{
|
||||||
packet->header[0] = (length << 16) | (tag << 14) | (channel << 8)
|
packet->header[0] = (length << 16) | (tag << 14) | (channel << 8)
|
||||||
| (TCODE_ISO_DATA << 4) | sync;
|
| (TCODE_ISO_DATA << 4) | sync;
|
||||||
|
|
||||||
packet->header_size = 4;
|
packet->header_size = 4;
|
||||||
packet->data_size = length;
|
packet->data_size = length;
|
||||||
packet->type = hpsb_iso;
|
packet->type = hpsb_iso;
|
||||||
packet->tcode = TCODE_ISO_DATA;
|
packet->tcode = TCODE_ISO_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fill_phy_packet(struct hpsb_packet *packet, quadlet_t data)
|
static void fill_phy_packet(struct hpsb_packet *packet, quadlet_t data)
|
||||||
{
|
{
|
||||||
packet->header[0] = data;
|
packet->header[0] = data;
|
||||||
packet->header[1] = ~data;
|
packet->header[1] = ~data;
|
||||||
packet->header_size = 8;
|
packet->header_size = 8;
|
||||||
packet->data_size = 0;
|
packet->data_size = 0;
|
||||||
packet->expect_response = 0;
|
packet->expect_response = 0;
|
||||||
packet->type = hpsb_raw; /* No CRC added */
|
packet->type = hpsb_raw; /* No CRC added */
|
||||||
packet->speed_code = IEEE1394_SPEED_100; /* Force speed to be 100Mbps */
|
packet->speed_code = IEEE1394_SPEED_100; /* Force speed to be 100Mbps */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fill_async_stream_packet(struct hpsb_packet *packet, int length,
|
static void fill_async_stream_packet(struct hpsb_packet *packet, int length,
|
||||||
int channel, int tag, int sync)
|
int channel, int tag, int sync)
|
||||||
{
|
{
|
||||||
packet->header[0] = (length << 16) | (tag << 14) | (channel << 8)
|
packet->header[0] = (length << 16) | (tag << 14) | (channel << 8)
|
||||||
| (TCODE_STREAM_DATA << 4) | sync;
|
| (TCODE_STREAM_DATA << 4) | sync;
|
||||||
|
|
||||||
packet->header_size = 4;
|
packet->header_size = 4;
|
||||||
packet->data_size = length;
|
packet->data_size = length;
|
||||||
|
@ -172,99 +173,96 @@ int hpsb_get_tlabel(struct hpsb_packet *packet)
|
||||||
*/
|
*/
|
||||||
void hpsb_free_tlabel(struct hpsb_packet *packet)
|
void hpsb_free_tlabel(struct hpsb_packet *packet)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
struct hpsb_tlabel_pool *tp;
|
struct hpsb_tlabel_pool *tp;
|
||||||
|
|
||||||
tp = &packet->host->tpool[packet->node_id & NODE_MASK];
|
tp = &packet->host->tpool[packet->node_id & NODE_MASK];
|
||||||
|
|
||||||
BUG_ON(packet->tlabel > 63 || packet->tlabel < 0);
|
BUG_ON(packet->tlabel > 63 || packet->tlabel < 0);
|
||||||
|
|
||||||
spin_lock_irqsave(&tp->lock, flags);
|
spin_lock_irqsave(&tp->lock, flags);
|
||||||
BUG_ON(!test_and_clear_bit(packet->tlabel, tp->pool));
|
BUG_ON(!test_and_clear_bit(packet->tlabel, tp->pool));
|
||||||
spin_unlock_irqrestore(&tp->lock, flags);
|
spin_unlock_irqrestore(&tp->lock, flags);
|
||||||
|
|
||||||
up(&tp->count);
|
up(&tp->count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int hpsb_packet_success(struct hpsb_packet *packet)
|
int hpsb_packet_success(struct hpsb_packet *packet)
|
||||||
{
|
{
|
||||||
switch (packet->ack_code) {
|
switch (packet->ack_code) {
|
||||||
case ACK_PENDING:
|
case ACK_PENDING:
|
||||||
switch ((packet->header[1] >> 12) & 0xf) {
|
switch ((packet->header[1] >> 12) & 0xf) {
|
||||||
case RCODE_COMPLETE:
|
case RCODE_COMPLETE:
|
||||||
return 0;
|
return 0;
|
||||||
case RCODE_CONFLICT_ERROR:
|
case RCODE_CONFLICT_ERROR:
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
case RCODE_DATA_ERROR:
|
case RCODE_DATA_ERROR:
|
||||||
return -EREMOTEIO;
|
return -EREMOTEIO;
|
||||||
case RCODE_TYPE_ERROR:
|
case RCODE_TYPE_ERROR:
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
case RCODE_ADDRESS_ERROR:
|
case RCODE_ADDRESS_ERROR:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
default:
|
default:
|
||||||
HPSB_ERR("received reserved rcode %d from node %d",
|
HPSB_ERR("received reserved rcode %d from node %d",
|
||||||
(packet->header[1] >> 12) & 0xf,
|
(packet->header[1] >> 12) & 0xf,
|
||||||
packet->node_id);
|
packet->node_id);
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
}
|
}
|
||||||
HPSB_PANIC("reached unreachable code 1 in %s", __FUNCTION__);
|
HPSB_PANIC("reached unreachable code 1 in %s", __FUNCTION__);
|
||||||
|
|
||||||
case ACK_BUSY_X:
|
case ACK_BUSY_X:
|
||||||
case ACK_BUSY_A:
|
case ACK_BUSY_A:
|
||||||
case ACK_BUSY_B:
|
case ACK_BUSY_B:
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
|
||||||
case ACK_TYPE_ERROR:
|
case ACK_TYPE_ERROR:
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
|
|
||||||
case ACK_COMPLETE:
|
case ACK_COMPLETE:
|
||||||
if (packet->tcode == TCODE_WRITEQ
|
if (packet->tcode == TCODE_WRITEQ
|
||||||
|| packet->tcode == TCODE_WRITEB) {
|
|| packet->tcode == TCODE_WRITEB) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
HPSB_ERR("impossible ack_complete from node %d "
|
HPSB_ERR("impossible ack_complete from node %d "
|
||||||
"(tcode %d)", packet->node_id, packet->tcode);
|
"(tcode %d)", packet->node_id, packet->tcode);
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case ACK_DATA_ERROR:
|
||||||
|
if (packet->tcode == TCODE_WRITEB
|
||||||
|
|| packet->tcode == TCODE_LOCK_REQUEST) {
|
||||||
|
return -EAGAIN;
|
||||||
|
} else {
|
||||||
|
HPSB_ERR("impossible ack_data_error from node %d "
|
||||||
|
"(tcode %d)", packet->node_id, packet->tcode);
|
||||||
|
return -EAGAIN;
|
||||||
|
}
|
||||||
|
|
||||||
case ACK_DATA_ERROR:
|
case ACK_ADDRESS_ERROR:
|
||||||
if (packet->tcode == TCODE_WRITEB
|
return -EINVAL;
|
||||||
|| packet->tcode == TCODE_LOCK_REQUEST) {
|
|
||||||
return -EAGAIN;
|
|
||||||
} else {
|
|
||||||
HPSB_ERR("impossible ack_data_error from node %d "
|
|
||||||
"(tcode %d)", packet->node_id, packet->tcode);
|
|
||||||
return -EAGAIN;
|
|
||||||
}
|
|
||||||
|
|
||||||
case ACK_ADDRESS_ERROR:
|
case ACK_TARDY:
|
||||||
return -EINVAL;
|
case ACK_CONFLICT_ERROR:
|
||||||
|
case ACKX_NONE:
|
||||||
|
case ACKX_SEND_ERROR:
|
||||||
|
case ACKX_ABORTED:
|
||||||
|
case ACKX_TIMEOUT:
|
||||||
|
/* error while sending */
|
||||||
|
return -EAGAIN;
|
||||||
|
|
||||||
case ACK_TARDY:
|
default:
|
||||||
case ACK_CONFLICT_ERROR:
|
HPSB_ERR("got invalid ack %d from node %d (tcode %d)",
|
||||||
case ACKX_NONE:
|
packet->ack_code, packet->node_id, packet->tcode);
|
||||||
case ACKX_SEND_ERROR:
|
return -EAGAIN;
|
||||||
case ACKX_ABORTED:
|
}
|
||||||
case ACKX_TIMEOUT:
|
|
||||||
/* error while sending */
|
|
||||||
return -EAGAIN;
|
|
||||||
|
|
||||||
default:
|
HPSB_PANIC("reached unreachable code 2 in %s", __FUNCTION__);
|
||||||
HPSB_ERR("got invalid ack %d from node %d (tcode %d)",
|
|
||||||
packet->ack_code, packet->node_id, packet->tcode);
|
|
||||||
return -EAGAIN;
|
|
||||||
}
|
|
||||||
|
|
||||||
HPSB_PANIC("reached unreachable code 2 in %s", __FUNCTION__);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct hpsb_packet *hpsb_make_readpacket(struct hpsb_host *host, nodeid_t node,
|
struct hpsb_packet *hpsb_make_readpacket(struct hpsb_host *host, nodeid_t node,
|
||||||
u64 addr, size_t length)
|
u64 addr, size_t length)
|
||||||
{
|
{
|
||||||
struct hpsb_packet *packet;
|
struct hpsb_packet *packet;
|
||||||
|
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -289,8 +287,9 @@ struct hpsb_packet *hpsb_make_readpacket(struct hpsb_host *host, nodeid_t node,
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct hpsb_packet *hpsb_make_writepacket (struct hpsb_host *host, nodeid_t node,
|
struct hpsb_packet *hpsb_make_writepacket(struct hpsb_host *host, nodeid_t node,
|
||||||
u64 addr, quadlet_t *buffer, size_t length)
|
u64 addr, quadlet_t * buffer,
|
||||||
|
size_t length)
|
||||||
{
|
{
|
||||||
struct hpsb_packet *packet;
|
struct hpsb_packet *packet;
|
||||||
|
|
||||||
|
@ -301,7 +300,7 @@ struct hpsb_packet *hpsb_make_writepacket (struct hpsb_host *host, nodeid_t node
|
||||||
if (!packet)
|
if (!packet)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (length % 4) { /* zero padding bytes */
|
if (length % 4) { /* zero padding bytes */
|
||||||
packet->data[length >> 2] = 0;
|
packet->data[length >> 2] = 0;
|
||||||
}
|
}
|
||||||
packet->host = host;
|
packet->host = host;
|
||||||
|
@ -323,8 +322,9 @@ struct hpsb_packet *hpsb_make_writepacket (struct hpsb_host *host, nodeid_t node
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct hpsb_packet *hpsb_make_streampacket(struct hpsb_host *host, u8 *buffer, int length,
|
struct hpsb_packet *hpsb_make_streampacket(struct hpsb_host *host, u8 * buffer,
|
||||||
int channel, int tag, int sync)
|
int length, int channel, int tag,
|
||||||
|
int sync)
|
||||||
{
|
{
|
||||||
struct hpsb_packet *packet;
|
struct hpsb_packet *packet;
|
||||||
|
|
||||||
|
@ -335,7 +335,7 @@ struct hpsb_packet *hpsb_make_streampacket(struct hpsb_host *host, u8 *buffer, i
|
||||||
if (!packet)
|
if (!packet)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (length % 4) { /* zero padding bytes */
|
if (length % 4) { /* zero padding bytes */
|
||||||
packet->data[length >> 2] = 0;
|
packet->data[length >> 2] = 0;
|
||||||
}
|
}
|
||||||
packet->host = host;
|
packet->host = host;
|
||||||
|
@ -353,14 +353,15 @@ struct hpsb_packet *hpsb_make_streampacket(struct hpsb_host *host, u8 *buffer, i
|
||||||
}
|
}
|
||||||
|
|
||||||
struct hpsb_packet *hpsb_make_lockpacket(struct hpsb_host *host, nodeid_t node,
|
struct hpsb_packet *hpsb_make_lockpacket(struct hpsb_host *host, nodeid_t node,
|
||||||
u64 addr, int extcode, quadlet_t *data,
|
u64 addr, int extcode,
|
||||||
quadlet_t arg)
|
quadlet_t * data, quadlet_t arg)
|
||||||
{
|
{
|
||||||
struct hpsb_packet *p;
|
struct hpsb_packet *p;
|
||||||
u32 length;
|
u32 length;
|
||||||
|
|
||||||
p = hpsb_alloc_packet(8);
|
p = hpsb_alloc_packet(8);
|
||||||
if (!p) return NULL;
|
if (!p)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
p->host = host;
|
p->host = host;
|
||||||
p->node_id = node;
|
p->node_id = node;
|
||||||
|
@ -389,15 +390,16 @@ struct hpsb_packet *hpsb_make_lockpacket(struct hpsb_host *host, nodeid_t node,
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct hpsb_packet *hpsb_make_lock64packet(struct hpsb_host *host, nodeid_t node,
|
struct hpsb_packet *hpsb_make_lock64packet(struct hpsb_host *host,
|
||||||
u64 addr, int extcode, octlet_t *data,
|
nodeid_t node, u64 addr, int extcode,
|
||||||
octlet_t arg)
|
octlet_t * data, octlet_t arg)
|
||||||
{
|
{
|
||||||
struct hpsb_packet *p;
|
struct hpsb_packet *p;
|
||||||
u32 length;
|
u32 length;
|
||||||
|
|
||||||
p = hpsb_alloc_packet(16);
|
p = hpsb_alloc_packet(16);
|
||||||
if (!p) return NULL;
|
if (!p)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
p->host = host;
|
p->host = host;
|
||||||
p->node_id = node;
|
p->node_id = node;
|
||||||
|
@ -430,18 +432,18 @@ struct hpsb_packet *hpsb_make_lock64packet(struct hpsb_host *host, nodeid_t node
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct hpsb_packet *hpsb_make_phypacket(struct hpsb_host *host,
|
struct hpsb_packet *hpsb_make_phypacket(struct hpsb_host *host, quadlet_t data)
|
||||||
quadlet_t data)
|
|
||||||
{
|
{
|
||||||
struct hpsb_packet *p;
|
struct hpsb_packet *p;
|
||||||
|
|
||||||
p = hpsb_alloc_packet(0);
|
p = hpsb_alloc_packet(0);
|
||||||
if (!p) return NULL;
|
if (!p)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
p->host = host;
|
p->host = host;
|
||||||
fill_phy_packet(p, data);
|
fill_phy_packet(p, data);
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct hpsb_packet *hpsb_make_isopacket(struct hpsb_host *host,
|
struct hpsb_packet *hpsb_make_isopacket(struct hpsb_host *host,
|
||||||
|
@ -451,7 +453,8 @@ struct hpsb_packet *hpsb_make_isopacket(struct hpsb_host *host,
|
||||||
struct hpsb_packet *p;
|
struct hpsb_packet *p;
|
||||||
|
|
||||||
p = hpsb_alloc_packet(length);
|
p = hpsb_alloc_packet(length);
|
||||||
if (!p) return NULL;
|
if (!p)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
p->host = host;
|
p->host = host;
|
||||||
fill_iso_packet(p, length, channel, tag, sync);
|
fill_iso_packet(p, length, channel, tag, sync);
|
||||||
|
@ -467,47 +470,46 @@ struct hpsb_packet *hpsb_make_isopacket(struct hpsb_host *host,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int hpsb_read(struct hpsb_host *host, nodeid_t node, unsigned int generation,
|
int hpsb_read(struct hpsb_host *host, nodeid_t node, unsigned int generation,
|
||||||
u64 addr, quadlet_t *buffer, size_t length)
|
u64 addr, quadlet_t * buffer, size_t length)
|
||||||
{
|
{
|
||||||
struct hpsb_packet *packet;
|
struct hpsb_packet *packet;
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
BUG_ON(in_interrupt()); // We can't be called in an interrupt, yet
|
BUG_ON(in_interrupt()); // We can't be called in an interrupt, yet
|
||||||
|
|
||||||
packet = hpsb_make_readpacket(host, node, addr, length);
|
packet = hpsb_make_readpacket(host, node, addr, length);
|
||||||
|
|
||||||
if (!packet) {
|
if (!packet) {
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet->generation = generation;
|
packet->generation = generation;
|
||||||
retval = hpsb_send_packet_and_wait(packet);
|
retval = hpsb_send_packet_and_wait(packet);
|
||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
goto hpsb_read_fail;
|
goto hpsb_read_fail;
|
||||||
|
|
||||||
retval = hpsb_packet_success(packet);
|
retval = hpsb_packet_success(packet);
|
||||||
|
|
||||||
if (retval == 0) {
|
if (retval == 0) {
|
||||||
if (length == 4) {
|
if (length == 4) {
|
||||||
*buffer = packet->header[3];
|
*buffer = packet->header[3];
|
||||||
} else {
|
} else {
|
||||||
memcpy(buffer, packet->data, length);
|
memcpy(buffer, packet->data, length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hpsb_read_fail:
|
hpsb_read_fail:
|
||||||
hpsb_free_tlabel(packet);
|
hpsb_free_tlabel(packet);
|
||||||
hpsb_free_packet(packet);
|
hpsb_free_packet(packet);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int hpsb_write(struct hpsb_host *host, nodeid_t node, unsigned int generation,
|
int hpsb_write(struct hpsb_host *host, nodeid_t node, unsigned int generation,
|
||||||
u64 addr, quadlet_t *buffer, size_t length)
|
u64 addr, quadlet_t * buffer, size_t length)
|
||||||
{
|
{
|
||||||
struct hpsb_packet *packet;
|
struct hpsb_packet *packet;
|
||||||
int retval;
|
int retval;
|
||||||
|
@ -515,62 +517,61 @@ int hpsb_write(struct hpsb_host *host, nodeid_t node, unsigned int generation,
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
BUG_ON(in_interrupt()); // We can't be called in an interrupt, yet
|
BUG_ON(in_interrupt()); // We can't be called in an interrupt, yet
|
||||||
|
|
||||||
packet = hpsb_make_writepacket (host, node, addr, buffer, length);
|
packet = hpsb_make_writepacket(host, node, addr, buffer, length);
|
||||||
|
|
||||||
if (!packet)
|
if (!packet)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
packet->generation = generation;
|
packet->generation = generation;
|
||||||
retval = hpsb_send_packet_and_wait(packet);
|
retval = hpsb_send_packet_and_wait(packet);
|
||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
goto hpsb_write_fail;
|
goto hpsb_write_fail;
|
||||||
|
|
||||||
retval = hpsb_packet_success(packet);
|
retval = hpsb_packet_success(packet);
|
||||||
|
|
||||||
hpsb_write_fail:
|
hpsb_write_fail:
|
||||||
hpsb_free_tlabel(packet);
|
hpsb_free_tlabel(packet);
|
||||||
hpsb_free_packet(packet);
|
hpsb_free_packet(packet);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
||||||
int hpsb_lock(struct hpsb_host *host, nodeid_t node, unsigned int generation,
|
int hpsb_lock(struct hpsb_host *host, nodeid_t node, unsigned int generation,
|
||||||
u64 addr, int extcode, quadlet_t *data, quadlet_t arg)
|
u64 addr, int extcode, quadlet_t * data, quadlet_t arg)
|
||||||
{
|
{
|
||||||
struct hpsb_packet *packet;
|
struct hpsb_packet *packet;
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
|
||||||
BUG_ON(in_interrupt()); // We can't be called in an interrupt, yet
|
BUG_ON(in_interrupt()); // We can't be called in an interrupt, yet
|
||||||
|
|
||||||
packet = hpsb_make_lockpacket(host, node, addr, extcode, data, arg);
|
packet = hpsb_make_lockpacket(host, node, addr, extcode, data, arg);
|
||||||
if (!packet)
|
if (!packet)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
packet->generation = generation;
|
packet->generation = generation;
|
||||||
retval = hpsb_send_packet_and_wait(packet);
|
retval = hpsb_send_packet_and_wait(packet);
|
||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
goto hpsb_lock_fail;
|
goto hpsb_lock_fail;
|
||||||
|
|
||||||
retval = hpsb_packet_success(packet);
|
retval = hpsb_packet_success(packet);
|
||||||
|
|
||||||
if (retval == 0) {
|
if (retval == 0) {
|
||||||
*data = packet->data[0];
|
*data = packet->data[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
hpsb_lock_fail:
|
hpsb_lock_fail:
|
||||||
hpsb_free_tlabel(packet);
|
hpsb_free_tlabel(packet);
|
||||||
hpsb_free_packet(packet);
|
hpsb_free_packet(packet);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int hpsb_send_gasp(struct hpsb_host *host, int channel, unsigned int generation,
|
int hpsb_send_gasp(struct hpsb_host *host, int channel, unsigned int generation,
|
||||||
quadlet_t *buffer, size_t length, u32 specifier_id,
|
quadlet_t * buffer, size_t length, u32 specifier_id,
|
||||||
unsigned int version)
|
unsigned int version)
|
||||||
{
|
{
|
||||||
struct hpsb_packet *packet;
|
struct hpsb_packet *packet;
|
||||||
|
@ -587,7 +588,8 @@ int hpsb_send_gasp(struct hpsb_host *host, int channel, unsigned int generation,
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
packet->data[0] = cpu_to_be32((host->node_id << 16) | specifier_id_hi);
|
packet->data[0] = cpu_to_be32((host->node_id << 16) | specifier_id_hi);
|
||||||
packet->data[1] = cpu_to_be32((specifier_id_lo << 24) | (version & 0x00ffffff));
|
packet->data[1] =
|
||||||
|
cpu_to_be32((specifier_id_lo << 24) | (version & 0x00ffffff));
|
||||||
|
|
||||||
memcpy(&(packet->data[2]), buffer, length - 8);
|
memcpy(&(packet->data[2]), buffer, length - 8);
|
||||||
|
|
||||||
|
@ -602,4 +604,4 @@ int hpsb_send_gasp(struct hpsb_host *host, int channel, unsigned int generation,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* 0 */
|
#endif /* 0 */
|
||||||
|
|
Loading…
Reference in New Issue