Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933899AbbGUTPS (ORCPT ); Tue, 21 Jul 2015 15:15:18 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:39439 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933708AbbGUTPN (ORCPT ); Tue, 21 Jul 2015 15:15:13 -0400 Date: Tue, 21 Jul 2015 12:15:12 -0700 From: Greg KH To: Stephen Chandler Paul Cc: Dmitry Torokhov , Andrew Morton , Mauro Carvalho Chehab , Arnd Bergmann , Joe Perches , Jiri Slaby , Vishnu Patekar , Sebastian Ott , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-api@vger.kernel.org, Benjamin Tissoires , Hans de Goede Subject: Re: [RFC] Input: Add ps2emu module Message-ID: <20150721191512.GB21710@kroah.com> References: <1437505634-8633-1-git-send-email-cpaul@redhat.com> <1437505634-8633-2-git-send-email-cpaul@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1437505634-8633-2-git-send-email-cpaul@redhat.com> User-Agent: Mutt/1.5.23+102 (2ca89bed6448) (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1584 Lines: 56 On Tue, Jul 21, 2015 at 03:07:14PM -0400, Stephen Chandler Paul wrote: > +#define ps2emu_warn(format, args...) \ > + dev_warn(ps2emu_misc.this_device, format, ## args) Don't make a wrapper function for another wrapper function, just spell the thing out in the code, makes it much easier to debug and maintain over time. It will also cause you to rename "this_device" to "dev" to make it easier to type :) > +static int ps2emu_char_open(struct inode *inode, struct file *file) > +{ > + struct ps2emu_device *ps2emu = NULL; > + > + ps2emu = kzalloc(sizeof(struct ps2emu_device), GFP_KERNEL); > + if (!ps2emu) > + return -ENOMEM; > + > + init_waitqueue_head(&ps2emu->waitq); > + > + ps2emu->serio.write = ps2emu_device_write; > + ps2emu->serio.port_data = ps2emu; > + > + file->private_data = ps2emu; > + > + nonseekable_open(inode, file); Why call this at all? > + ret = copy_to_user(buffer, &ps2emu->buf[ps2emu->tail], copylen); > + if (ret) > + return ret; Wrong error value, please return -EFAULT. > + rc = copy_from_user(&cmd, buffer, sizeof(cmd)); > + if (rc) > + return rc; Same thing here, -EFAULT. > + case PS2EMU_CMD_SEND_INTERRUPT: > + if (unlikely(!ps2emu->running)) { Unless you can verify likely/unlikely actually makes a difference in your code, don't ever use it. Hint, it's not needed here. thanks, greg k-h -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/