Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S268279AbUI2Jat (ORCPT ); Wed, 29 Sep 2004 05:30:49 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S268278AbUI2Jat (ORCPT ); Wed, 29 Sep 2004 05:30:49 -0400 Received: from styx.suse.cz ([82.119.242.94]:9091 "EHLO shadow.suse.cz") by vger.kernel.org with ESMTP id S268282AbUI2Jag (ORCPT ); Wed, 29 Sep 2004 05:30:36 -0400 Date: Wed, 29 Sep 2004 11:31:03 +0200 From: Vojtech Pavlik To: Dmitry Torokhov Cc: LKML Subject: Re: [PATCH 7/8] Psmouse - add packet size Message-ID: <20040929093103.GB3150@ucw.cz> References: <200409290140.53350.dtor_core@ameritech.net> <200409290147.35864.dtor_core@ameritech.net> <20040929071504.GB2648@ucw.cz> <200409290229.28652.dtor_core@ameritech.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200409290229.28652.dtor_core@ameritech.net> User-Agent: Mutt/1.4.1i Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2195 Lines: 70 On Wed, Sep 29, 2004 at 02:29:28AM -0500, Dmitry Torokhov wrote: > On Wednesday 29 September 2004 02:15 am, Vojtech Pavlik wrote: > > On Wed, Sep 29, 2004 at 01:47:34AM -0500, Dmitry Torokhov wrote: > > > > > -int alps_detect(struct psmouse *psmouse) > > > +int alps_detect(struct psmouse *psmouse, int set_properties) > > > { > > > - return alps_get_model(psmouse) < 0 ? 0 : 1; > > > + if (alps_get_model(psmouse) < 0) > > > + return 0; > > > + > > > + if (set_properties) { > > > + psmouse->vendor = "ALPS"; > > > + psmouse->name = "TouchPad"; > > > + } > > > + return 1; > > > } > > > > I think we should return -1 (or -errno) on failure and 0 on success, > > like everybody else does. > > > > All *detect functions return boolean value - either the device was detected or > not. I think it makes most sense. Negative error is convenient when function > normally returns some other meaningful value, like length. *detect is a simple > yes/no question, it is not really an error at all. psmouse_probe() is very similar in its use, as are a lot of other functions in the serio framework - and they return 0 on success, and -1 on failure. I see it as "detected/initialized" = success (0) and "not detected / failed to initialize" = fail (-1). I agree that your view also makes sense, however I'd like to keep the driver return values consistent to make it easier to read. Maybe renaming the *_detect functions to *_probe would make it more obvious. > > This should be: > > > > if (param[0] != 3) > > return -1; > > if (set_properties) { > > set_bit(REL_WHEEL, psmouse->dev.relbit); > > if (!psmouse->vendor) psmouse->vendor = "Generic"; > > if (!psmouse->name) psmouse->name = "Wheel Mouse"; > > psmouse->pktsize = 4; > > } > > return 0; > > > > ... and similarly elsewhere. You save one level of nesting and it makes > > more sense. > > > > Ok, will change. > > -- > Dmitry > -- Vojtech Pavlik SuSE Labs, SuSE CR - 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/