[PATCH] uml: remove NULL checks and add some CodingStyle
Remove redundant NULL checks before [kv]free + small CodingStyle cleanup for arch/ Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com> Signed-off-by: Jeff Dike <jdike@addtoit.com> Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
committed by
Linus Torvalds
parent
893bb96a29
commit
191ef966ac
@@ -89,7 +89,9 @@ void sigio_handler(int sig, union uml_pt_regs *regs)
|
|||||||
struct irq_fd *irq_fd;
|
struct irq_fd *irq_fd;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
if(smp_sigio_handler()) return;
|
if (smp_sigio_handler())
|
||||||
|
return;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
n = os_waiting_for_events(active_fds);
|
n = os_waiting_for_events(active_fds);
|
||||||
if (n <= 0) {
|
if (n <= 0) {
|
||||||
@@ -114,15 +116,13 @@ static void maybe_sigio_broken(int fd, int type)
|
|||||||
if ((type == IRQ_WRITE) && !pty_output_sigio) {
|
if ((type == IRQ_WRITE) && !pty_output_sigio) {
|
||||||
write_sigio_workaround();
|
write_sigio_workaround();
|
||||||
add_sigio_fd(fd, 0);
|
add_sigio_fd(fd, 0);
|
||||||
}
|
} else if ((type == IRQ_READ) && !pty_close_sigio) {
|
||||||
else if((type == IRQ_READ) && !pty_close_sigio){
|
|
||||||
write_sigio_workaround();
|
write_sigio_workaround();
|
||||||
add_sigio_fd(fd, 1);
|
add_sigio_fd(fd, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int activate_fd(int irq, int fd, int type, void *dev_id)
|
int activate_fd(int irq, int fd, int type, void *dev_id)
|
||||||
{
|
{
|
||||||
struct pollfd *tmp_pfd;
|
struct pollfd *tmp_pfd;
|
||||||
@@ -140,8 +140,10 @@ int activate_fd(int irq, int fd, int type, void *dev_id)
|
|||||||
if (new_fd == NULL)
|
if (new_fd == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if(type == IRQ_READ) events = UM_POLLIN | UM_POLLPRI;
|
if (type == IRQ_READ)
|
||||||
else events = UM_POLLOUT;
|
events = UM_POLLIN | UM_POLLPRI;
|
||||||
|
else
|
||||||
|
events = UM_POLLOUT;
|
||||||
*new_fd = ((struct irq_fd) { .next = NULL,
|
*new_fd = ((struct irq_fd) { .next = NULL,
|
||||||
.id = dev_id,
|
.id = dev_id,
|
||||||
.fd = fd,
|
.fd = fd,
|
||||||
@@ -198,10 +200,8 @@ int activate_fd(int irq, int fd, int type, void *dev_id)
|
|||||||
* then we free the buffer tmp_fds and try again.
|
* then we free the buffer tmp_fds and try again.
|
||||||
*/
|
*/
|
||||||
irq_unlock(flags);
|
irq_unlock(flags);
|
||||||
if (tmp_pfd != NULL) {
|
|
||||||
kfree(tmp_pfd);
|
kfree(tmp_pfd);
|
||||||
tmp_pfd = NULL;
|
tmp_pfd = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
tmp_pfd = um_kmalloc(n);
|
tmp_pfd = um_kmalloc(n);
|
||||||
if (tmp_pfd == NULL)
|
if (tmp_pfd == NULL)
|
||||||
@@ -277,7 +277,8 @@ static struct irq_fd *find_irq_by_fd(int fd, int irqnum, int *index_out)
|
|||||||
int fdi;
|
int fdi;
|
||||||
|
|
||||||
for (irq = active_fds; irq != NULL; irq = irq->next) {
|
for (irq = active_fds; irq != NULL; irq = irq->next) {
|
||||||
if((irq->fd == fd) && (irq->irq == irqnum)) break;
|
if ((irq->fd == fd) && (irq->irq == irqnum))
|
||||||
|
break;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
if (irq == NULL) {
|
if (irq == NULL) {
|
||||||
@@ -294,7 +295,7 @@ static struct irq_fd *find_irq_by_fd(int fd, int irqnum, int *index_out)
|
|||||||
}
|
}
|
||||||
*index_out = i;
|
*index_out = i;
|
||||||
out:
|
out:
|
||||||
return(irq);
|
return irq;
|
||||||
}
|
}
|
||||||
|
|
||||||
void reactivate_fd(int fd, int irqnum)
|
void reactivate_fd(int fd, int irqnum)
|
||||||
@@ -341,12 +342,12 @@ int deactivate_all_fds(void)
|
|||||||
for (irq = active_fds; irq != NULL; irq = irq->next) {
|
for (irq = active_fds; irq != NULL; irq = irq->next) {
|
||||||
err = os_clear_fd_async(irq->fd);
|
err = os_clear_fd_async(irq->fd);
|
||||||
if (err)
|
if (err)
|
||||||
return(err);
|
return err;
|
||||||
}
|
}
|
||||||
/* If there is a signal already queued, after unblocking ignore it */
|
/* If there is a signal already queued, after unblocking ignore it */
|
||||||
os_set_ioignore();
|
os_set_ioignore();
|
||||||
|
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void forward_interrupts(int pid)
|
void forward_interrupts(int pid)
|
||||||
@@ -393,11 +394,11 @@ int um_request_irq(unsigned int irq, int fd, int type,
|
|||||||
|
|
||||||
err = request_irq(irq, handler, irqflags, devname, dev_id);
|
err = request_irq(irq, handler, irqflags, devname, dev_id);
|
||||||
if (err)
|
if (err)
|
||||||
return(err);
|
return err;
|
||||||
|
|
||||||
if (fd != -1)
|
if (fd != -1)
|
||||||
err = activate_fd(irq, fd, type, dev_id);
|
err = activate_fd(irq, fd, type, dev_id);
|
||||||
return(err);
|
return err;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(um_request_irq);
|
EXPORT_SYMBOL(um_request_irq);
|
||||||
EXPORT_SYMBOL(reactivate_fd);
|
EXPORT_SYMBOL(reactivate_fd);
|
||||||
@@ -409,7 +410,7 @@ unsigned long irq_lock(void)
|
|||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
spin_lock_irqsave(&irq_spinlock, flags);
|
spin_lock_irqsave(&irq_spinlock, flags);
|
||||||
return(flags);
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
void irq_unlock(unsigned long flags)
|
void irq_unlock(unsigned long flags)
|
||||||
@@ -488,5 +489,5 @@ int init_aio_irq(int irq, char *name, irqreturn_t (*handler)(int, void *,
|
|||||||
os_close_file(fds[0]);
|
os_close_file(fds[0]);
|
||||||
os_close_file(fds[1]);
|
os_close_file(fds[1]);
|
||||||
out:
|
out:
|
||||||
return(err);
|
return err;
|
||||||
}
|
}
|
||||||
|
@@ -54,7 +54,7 @@ int os_waiting_for_events(struct irq_fd *active_fds)
|
|||||||
|
|
||||||
int os_isatty(int fd)
|
int os_isatty(int fd)
|
||||||
{
|
{
|
||||||
return(isatty(fd));
|
return isatty(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
int os_create_pollfd(int fd, int events, void *tmp_pfd, int size_tmpfds)
|
int os_create_pollfd(int fd, int events, void *tmp_pfd, int size_tmpfds)
|
||||||
@@ -73,18 +73,15 @@ int os_create_pollfd(int fd, int events, void *tmp_pfd, int size_tmpfds)
|
|||||||
}
|
}
|
||||||
pollfds = tmp_pfd;
|
pollfds = tmp_pfd;
|
||||||
pollfds_size++;
|
pollfds_size++;
|
||||||
} else {
|
} else
|
||||||
/* remove not used tmp_pfd */
|
kfree(tmp_pfd); /* remove not used tmp_pfd */
|
||||||
if (tmp_pfd != NULL)
|
|
||||||
kfree(tmp_pfd);
|
|
||||||
}
|
|
||||||
|
|
||||||
pollfds[pollfds_num] = ((struct pollfd) { .fd = fd,
|
pollfds[pollfds_num] = ((struct pollfd) { .fd = fd,
|
||||||
.events = events,
|
.events = events,
|
||||||
.revents = 0 });
|
.revents = 0 });
|
||||||
pollfds_num++;
|
pollfds_num++;
|
||||||
|
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void os_free_irq_by_cb(int (*test)(struct irq_fd *, void *), void *arg,
|
void os_free_irq_by_cb(int (*test)(struct irq_fd *, void *), void *arg,
|
||||||
@@ -110,7 +107,6 @@ void os_free_irq_by_cb(int (*test)(struct irq_fd *, void *), void *arg,
|
|||||||
/* This moves the *whole* array after pollfds[i]
|
/* This moves the *whole* array after pollfds[i]
|
||||||
* (though it doesn't spot as such)!
|
* (though it doesn't spot as such)!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
memmove(&pollfds[i], &pollfds[i + 1],
|
memmove(&pollfds[i], &pollfds[i + 1],
|
||||||
(pollfds_num - i) * sizeof(pollfds[0]));
|
(pollfds_num - i) * sizeof(pollfds[0]));
|
||||||
if(*last_irq_ptr2 == &old_fd->next)
|
if(*last_irq_ptr2 == &old_fd->next)
|
||||||
@@ -129,10 +125,9 @@ void os_free_irq_by_cb(int (*test)(struct irq_fd *, void *), void *arg,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int os_get_pollfd(int i)
|
int os_get_pollfd(int i)
|
||||||
{
|
{
|
||||||
return(pollfds[i].fd);
|
return pollfds[i].fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
void os_set_pollfd(int i, int fd)
|
void os_set_pollfd(int i, int fd)
|
||||||
@@ -151,8 +146,10 @@ void init_irq_signals(int on_sigstack)
|
|||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
flags = on_sigstack ? SA_ONSTACK : 0;
|
flags = on_sigstack ? SA_ONSTACK : 0;
|
||||||
if(timer_irq_inited) h = (__sighandler_t) alarm_handler;
|
if (timer_irq_inited)
|
||||||
else h = boot_timer_handler;
|
h = (__sighandler_t)alarm_handler;
|
||||||
|
else
|
||||||
|
h = boot_timer_handler;
|
||||||
|
|
||||||
set_handler(SIGVTALRM, h, flags | SA_RESTART,
|
set_handler(SIGVTALRM, h, flags | SA_RESTART,
|
||||||
SIGUSR1, SIGIO, SIGWINCH, SIGALRM, -1);
|
SIGUSR1, SIGIO, SIGWINCH, SIGALRM, -1);
|
||||||
|
Reference in New Issue
Block a user