* write(fd, buf, 52) from 32bit app was returning 56. Most of callers did not
care, but some (arm registration) did, and anyway it looks bad if request for
writing 52 bytes returns 56. And returning sizeof anything in 'int' is not
good as well. So all functions now return '0' instead of
sizeof(struct raw1394_request) on success, and write() itself provides correct
return value (it just returns value it was asked to write on success as raw1394
does not do any partial writes at all).
* Related to this was problem that write() could have returned 0 when kernel
state would become corrupted and moved to different state than
opened/initialized/connected. Now it returns -EBADFD which seemed appropriate.
Signed-off-by: Petr Vandrovec <petr@vandrovec.name>
Acked-by: Dan Dennedy <dan@dennedy.org>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de> (split into 3 patches)
req->req.length = 0;
queue_complete_req(req);
req->req.length = 0;
queue_complete_req(req);
- return sizeof(struct raw1394_request);
}
static int state_initialized(struct file_info *fi, struct pending_request *req)
}
static int state_initialized(struct file_info *fi, struct pending_request *req)
req->req.generation = atomic_read(&internal_generation);
req->req.length = 0;
queue_complete_req(req);
req->req.generation = atomic_read(&internal_generation);
req->req.length = 0;
queue_complete_req(req);
- return sizeof(struct raw1394_request);
}
switch (req->req.type) {
}
switch (req->req.type) {
}
queue_complete_req(req);
}
queue_complete_req(req);
- return sizeof(struct raw1394_request);
}
static void handle_iso_listen(struct file_info *fi, struct pending_request *req)
}
static void handle_iso_listen(struct file_info *fi, struct pending_request *req)
if (req->req.error) {
req->req.length = 0;
queue_complete_req(req);
if (req->req.error) {
req->req.length = 0;
queue_complete_req(req);
- return sizeof(struct raw1394_request);
}
hpsb_set_packet_complete_task(packet,
}
hpsb_set_packet_complete_task(packet,
hpsb_free_tlabel(packet);
queue_complete_req(req);
}
hpsb_free_tlabel(packet);
queue_complete_req(req);
}
- return sizeof(struct raw1394_request);
}
static int handle_iso_send(struct file_info *fi, struct pending_request *req,
}
static int handle_iso_send(struct file_info *fi, struct pending_request *req,
req->req.error = RAW1394_ERROR_MEMFAULT;
req->req.length = 0;
queue_complete_req(req);
req->req.error = RAW1394_ERROR_MEMFAULT;
req->req.length = 0;
queue_complete_req(req);
- return sizeof(struct raw1394_request);
queue_complete_req(req);
}
queue_complete_req(req);
}
- return sizeof(struct raw1394_request);
}
static int handle_async_send(struct file_info *fi, struct pending_request *req)
}
static int handle_async_send(struct file_info *fi, struct pending_request *req)
req->req.error = RAW1394_ERROR_INVALID_ARG;
req->req.length = 0;
queue_complete_req(req);
req->req.error = RAW1394_ERROR_INVALID_ARG;
req->req.length = 0;
queue_complete_req(req);
- return sizeof(struct raw1394_request);
}
data_size = req->req.length - header_length;
}
data_size = req->req.length - header_length;
req->req.error = RAW1394_ERROR_MEMFAULT;
req->req.length = 0;
queue_complete_req(req);
req->req.error = RAW1394_ERROR_MEMFAULT;
req->req.length = 0;
queue_complete_req(req);
- return sizeof(struct raw1394_request);
req->req.error = RAW1394_ERROR_MEMFAULT;
req->req.length = 0;
queue_complete_req(req);
req->req.error = RAW1394_ERROR_MEMFAULT;
req->req.length = 0;
queue_complete_req(req);
- return sizeof(struct raw1394_request);
}
packet->type = hpsb_async;
}
packet->type = hpsb_async;
queue_complete_req(req);
}
queue_complete_req(req);
}
- return sizeof(struct raw1394_request);
}
static int arm_read(struct hpsb_host *host, int nodeid, quadlet_t * buffer,
}
static int arm_read(struct hpsb_host *host, int nodeid, quadlet_t * buffer,
spin_lock_irqsave(&host_info_lock, flags);
list_add_tail(&addr->addr_list, &fi->addr_list);
spin_unlock_irqrestore(&host_info_lock, flags);
spin_lock_irqsave(&host_info_lock, flags);
list_add_tail(&addr->addr_list, &fi->addr_list);
spin_unlock_irqrestore(&host_info_lock, flags);
- return sizeof(struct raw1394_request);
}
retval =
hpsb_register_addrspace(&raw1394_highlevel, fi->host, &arm_ops,
}
retval =
hpsb_register_addrspace(&raw1394_highlevel, fi->host, &arm_ops,
return (-EALREADY);
}
free_pending_request(req); /* immediate success or fail */
return (-EALREADY);
}
free_pending_request(req); /* immediate success or fail */
- return sizeof(struct raw1394_request);
}
static int arm_unregister(struct file_info *fi, struct pending_request *req)
}
static int arm_unregister(struct file_info *fi, struct pending_request *req)
vfree(addr->addr_space_buffer);
kfree(addr);
free_pending_request(req); /* immediate success or fail */
vfree(addr->addr_space_buffer);
kfree(addr);
free_pending_request(req); /* immediate success or fail */
- return sizeof(struct raw1394_request);
}
retval =
hpsb_unregister_addrspace(&raw1394_highlevel, fi->host,
}
retval =
hpsb_unregister_addrspace(&raw1394_highlevel, fi->host,
vfree(addr->addr_space_buffer);
kfree(addr);
free_pending_request(req); /* immediate success or fail */
vfree(addr->addr_space_buffer);
kfree(addr);
free_pending_request(req); /* immediate success or fail */
- return sizeof(struct raw1394_request);
}
/* Copy data from ARM buffer(s) to user buffer. */
}
/* Copy data from ARM buffer(s) to user buffer. */
* queue no response, and therefore nobody
* will free it. */
free_pending_request(req);
* queue no response, and therefore nobody
* will free it. */
free_pending_request(req);
- return sizeof(struct raw1394_request);
} else {
DBGMSG("arm_get_buf request exceeded mapping");
spin_unlock_irqrestore(&host_info_lock, flags);
} else {
DBGMSG("arm_get_buf request exceeded mapping");
spin_unlock_irqrestore(&host_info_lock, flags);
* queue no response, and therefore nobody
* will free it. */
free_pending_request(req);
* queue no response, and therefore nobody
* will free it. */
free_pending_request(req);
- return sizeof(struct raw1394_request);
} else {
DBGMSG("arm_set_buf request exceeded mapping");
spin_unlock_irqrestore(&host_info_lock, flags);
} else {
DBGMSG("arm_set_buf request exceeded mapping");
spin_unlock_irqrestore(&host_info_lock, flags);
(req->req.misc == RAW1394_NOTIFY_ON)) {
fi->notification = (u8) req->req.misc;
free_pending_request(req); /* we have to free the request, because we queue no response, and therefore nobody will free it */
(req->req.misc == RAW1394_NOTIFY_ON)) {
fi->notification = (u8) req->req.misc;
free_pending_request(req); /* we have to free the request, because we queue no response, and therefore nobody will free it */
- return sizeof(struct raw1394_request);
}
/* error EINVAL (22) invalid argument */
return (-EINVAL);
}
/* error EINVAL (22) invalid argument */
return (-EINVAL);
req->req.length = 0;
queue_complete_req(req);
}
req->req.length = 0;
queue_complete_req(req);
}
- return sizeof(struct raw1394_request);
}
static int get_config_rom(struct file_info *fi, struct pending_request *req)
{
}
static int get_config_rom(struct file_info *fi, struct pending_request *req)
{
- int ret = sizeof(struct raw1394_request);
quadlet_t *data = kmalloc(req->req.length, GFP_KERNEL);
int status;
quadlet_t *data = kmalloc(req->req.length, GFP_KERNEL);
int status;
static int update_config_rom(struct file_info *fi, struct pending_request *req)
{
static int update_config_rom(struct file_info *fi, struct pending_request *req)
{
- int ret = sizeof(struct raw1394_request);
quadlet_t *data = kmalloc(req->req.length, GFP_KERNEL);
if (!data)
return -ENOMEM;
quadlet_t *data = kmalloc(req->req.length, GFP_KERNEL);
if (!data)
return -ENOMEM;
hpsb_update_config_rom_image(fi->host);
free_pending_request(req);
hpsb_update_config_rom_image(fi->host);
free_pending_request(req);
- return sizeof(struct raw1394_request);
/* we have to free the request, because we queue no response,
* and therefore nobody will free it */
free_pending_request(req);
/* we have to free the request, because we queue no response,
* and therefore nobody will free it */
free_pending_request(req);
- return sizeof(struct raw1394_request);
} else {
for (dentry =
fi->csr1212_dirs[dr]->value.directory.dentries_head;
} else {
for (dentry =
fi->csr1212_dirs[dr]->value.directory.dentries_head;
case RAW1394_REQ_ECHO:
queue_complete_req(req);
case RAW1394_REQ_ECHO:
queue_complete_req(req);
- return sizeof(struct raw1394_request);
case RAW1394_REQ_ISO_SEND:
print_old_iso_deprecation();
case RAW1394_REQ_ISO_SEND:
print_old_iso_deprecation();
case RAW1394_REQ_ISO_LISTEN:
print_old_iso_deprecation();
handle_iso_listen(fi, req);
case RAW1394_REQ_ISO_LISTEN:
print_old_iso_deprecation();
handle_iso_listen(fi, req);
- return sizeof(struct raw1394_request);
case RAW1394_REQ_FCP_LISTEN:
handle_fcp_listen(fi, req);
case RAW1394_REQ_FCP_LISTEN:
handle_fcp_listen(fi, req);
- return sizeof(struct raw1394_request);
case RAW1394_REQ_RESET_BUS:
if (req->req.misc == RAW1394_LONG_RESET) {
DBGMSG("busreset called (type: LONG)");
hpsb_reset_bus(fi->host, LONG_RESET);
free_pending_request(req); /* we have to free the request, because we queue no response, and therefore nobody will free it */
case RAW1394_REQ_RESET_BUS:
if (req->req.misc == RAW1394_LONG_RESET) {
DBGMSG("busreset called (type: LONG)");
hpsb_reset_bus(fi->host, LONG_RESET);
free_pending_request(req); /* we have to free the request, because we queue no response, and therefore nobody will free it */
- return sizeof(struct raw1394_request);
}
if (req->req.misc == RAW1394_SHORT_RESET) {
DBGMSG("busreset called (type: SHORT)");
hpsb_reset_bus(fi->host, SHORT_RESET);
free_pending_request(req); /* we have to free the request, because we queue no response, and therefore nobody will free it */
}
if (req->req.misc == RAW1394_SHORT_RESET) {
DBGMSG("busreset called (type: SHORT)");
hpsb_reset_bus(fi->host, SHORT_RESET);
free_pending_request(req); /* we have to free the request, because we queue no response, and therefore nobody will free it */
- return sizeof(struct raw1394_request);
}
/* error EINVAL (22) invalid argument */
return (-EINVAL);
}
/* error EINVAL (22) invalid argument */
return (-EINVAL);
req->req.generation = get_hpsb_generation(fi->host);
req->req.length = 0;
queue_complete_req(req);
req->req.generation = get_hpsb_generation(fi->host);
req->req.length = 0;
queue_complete_req(req);
- return sizeof(struct raw1394_request);
}
switch (req->req.type) {
}
switch (req->req.type) {
if (req->req.length == 0) {
req->req.error = RAW1394_ERROR_INVALID_ARG;
queue_complete_req(req);
if (req->req.length == 0) {
req->req.error = RAW1394_ERROR_INVALID_ARG;
queue_complete_req(req);
- return sizeof(struct raw1394_request);
}
return handle_async_request(fi, req, node);
}
return handle_async_request(fi, req, node);
{
struct file_info *fi = (struct file_info *)file->private_data;
struct pending_request *req;
{
struct file_info *fi = (struct file_info *)file->private_data;
struct pending_request *req;
+ ssize_t retval = -EBADFD;
#ifdef CONFIG_COMPAT
if (count == sizeof(struct compat_raw1394_req) &&
#ifdef CONFIG_COMPAT
if (count == sizeof(struct compat_raw1394_req) &&
if (retval < 0) {
free_pending_request(req);
if (retval < 0) {
free_pending_request(req);
+ } else {
+ BUG_ON(retval);
+ retval = count;