From: David Brownell Subject: Re: [PATCH] spi_mpc83xx: handle odd transfer sizes Date: Wed, 10 Sep 2008 14:05:39 -0700 Message-ID: <200809101405.39285.david-b@pacbell.net> References: <1221041160-19342-1-git-send-email-jacmet@sunsite.dk> <200809101028.01997.david-b@pacbell.net> <87k5djdeew.fsf@macbook.be.48ers.dk> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org, joakim.tjernlund-SNLAxHN9vbcOP4wsBPIw7w@public.gmane.org To: Peter Korsgaard Return-path: In-Reply-To: <87k5djdeew.fsf-uXGAPMMVk8amE9MCos8gUmSdvHPH+/yF@public.gmane.org> Content-Disposition: inline List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: spi-devel-general-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: spi-devel-general-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: linux-spi.vger.kernel.org On Wednesday 10 September 2008, Peter Korsgaard wrote: > It would indeed be clearer to change it to to return -errno on errors > instead, but the problem my patch solves is real (crash on too small > message lengths) and I wanted to keep the patch to it's minimum now > that we're so close to 2.6.27. > > But I can change it to use return -EINVAL instead if you prefer - The > caller doesn't care as long as it's != 0. > > Then we can do the real cleanup later and push it for 2.6.28. OK, I was thinking this minimal tweak to your patch. It adds only one more patch segment, and makes the routine obey stndard kernel calling conventions ... still a small patch. :) --- g26.orig/drivers/spi/spi_mpc83xx.c 2008-09-10 14:03:03.000000000 -0700 +++ g26/drivers/spi/spi_mpc83xx.c 2008-09-10 10:27:23.000000000 -0700 @@ -315,13 +315,13 @@ static int mpc83xx_spi_bufs(struct spi_d if (bits_per_word > 8) { /* invalid length? */ if (len & 1) - return len; + return -EINVAL; len /= 2; } if (bits_per_word > 16) { /* invalid length? */ if (len & 1) - return len; + return -EINVAL; len /= 2; } mpc83xx_spi->count = len; @@ -340,7 +340,7 @@ static int mpc83xx_spi_bufs(struct spi_d /* disable rx ints */ mpc83xx_spi_write_reg(&mpc83xx_spi->base->mask, 0); - return mpc83xx_spi->count; + return 0; } static void mpc83xx_spi_work(struct work_struct *work) ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/