Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757577AbbEEUk1 (ORCPT ); Tue, 5 May 2015 16:40:27 -0400 Received: from mail-bn1on0139.outbound.protection.outlook.com ([157.56.110.139]:58848 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750882AbbEEUkZ (ORCPT ); Tue, 5 May 2015 16:40:25 -0400 Authentication-Results: freescale.com; dkim=none (message not signed) header.d=none; Message-ID: <1430858413.16357.252.camel@freescale.com> Subject: Re: [PATCH 1/7] staging: fsl-mc: MC bus IRQ support From: Scott Wood To: Rivera Jose-B46482 CC: Dan Carpenter , "devel@driverdev.osuosl.org" , Yoder Stuart-B08248 , Hamciuc Bogdan-BHAMCIU1 , "arnd@arndb.de" , "Sharma Bhupesh-B45370" , "gregkh@linuxfoundation.org" , "linux-kernel@vger.kernel.org" , "agraf@suse.de" , "Erez Nir-RM30794" , katz Itai-RM05202 , Marginean Alexandru-R89243 , Schmitt Richard-B43082 Date: Tue, 5 May 2015 15:40:13 -0500 In-Reply-To: References: <1430242750-17745-1-git-send-email-German.Rivera@freescale.com> <1430242750-17745-2-git-send-email-German.Rivera@freescale.com> <20150430114957.GW14154@mwanda> <20150505084830.GL16501@mwanda> <20150505164011.GT14154@mwanda> <1430855801.16357.251.camel@freescale.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.10-0ubuntu1~14.10.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Originating-IP: [2601:2:5800:3f7:12bf:48ff:fe84:c9a0] X-ClientProxiedBy: BN3PR09CA0011.namprd09.prod.outlook.com (25.160.111.149) To BY1PR03MB1482.namprd03.prod.outlook.com (25.162.210.140) X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR03MB1482; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:BY1PR03MB1482;BCL:0;PCL:0;RULEID:;SRVR:BY1PR03MB1482; X-Forefront-PRVS: 0567A15835 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6009001)(377424004)(51704005)(377454003)(52314003)(24454002)(13464003)(87976001)(23676002)(50226001)(5820100001)(36756003)(122386002)(103116003)(33646002)(86362001)(62966003)(42186005)(2950100001)(19580395003)(77156002)(46102003)(50986999)(19580405001)(93886004)(40100003)(50466002)(47776003)(5001960100002)(92566002)(107886002)(110136002)(76176999)(3826002)(4001430100001)(4001450100001);DIR:OUT;SFP:1102;SCL:1;SRVR:BY1PR03MB1482;H:[IPv6:2601:2:5800:3f7:12bf:48ff:fe84:c9a0];FPR:;SPF:None;MLV:sfv;LANG:en; X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2015 20:40:21.3874 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR03MB1482 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3542 Lines: 77 On Tue, 2015-05-05 at 15:22 -0500, Rivera Jose-B46482 wrote: > > > > -----Original Message----- > > From: Wood Scott-B07421 > > Sent: Tuesday, May 05, 2015 2:57 PM > > To: Dan Carpenter > > Cc: Rivera Jose-B46482; devel@driverdev.osuosl.org; Yoder Stuart-B08248; > > Hamciuc Bogdan-BHAMCIU1; arnd@arndb.de; Sharma Bhupesh-B45370; > > gregkh@linuxfoundation.org; linux-kernel@vger.kernel.org; agraf@suse.de; > > Erez Nir-RM30794; katz Itai-RM05202; Marginean Alexandru-R89243; Schmitt > > Richard-B43082 > > Subject: Re: [PATCH 1/7] staging: fsl-mc: MC bus IRQ support > > > > On Tue, 2015-05-05 at 19:40 +0300, Dan Carpenter wrote: > > > On Tue, May 05, 2015 at 04:08:49PM +0000, Jose Rivera wrote: > > > > > Subject: Re: [PATCH 1/7] staging: fsl-mc: MC bus IRQ support > > > > > > > > > > On Mon, May 04, 2015 at 10:09:08PM +0000, Jose Rivera wrote: > > > > > > > > + WARN_ON((int16_t)irq_count < 0); > > > > > > > > > > > > > > This code is doing "WARN_ON(test_bit(15, (unsigned long > > > > > *)&irq_count));". > > > > > > > That seems like nonsense. Anyway, just delete the WARN_ON(). > > > > > > > > > > > > > I disagree. This WARN_ON is checking that irq_count is in the > > > > > > expected range (it fits in int16_t as a positive number). The > > > > > > dprc_scan_objects() function expects irq_count to be of type > > > > > > "unsigned int" (which is 32-bit unsigned) > > > > > > > > > > > > > > > > You're not allowed to disagree because it's a testable thing and > > > > > not an opinion about style or something. :P What you want is: > > > > > > > > > > WARN_ON(irq_count > SHRT_MAX); > > > > > > > > > I see your point now. The check "(int16_t)irq_count < 0)" will not > > > > be able to catch 0x10000 > 0x7fff, but "irq_count > SHRT_MAX) will. > > > > So I'll make the suggested change, but I would prefer to use S16_MAX > > > > rather than SHRT_MAX. > > > > > > > > > > Huh? I didn't even know about the S16_MAX definition. There are > > > literally no users of it in the kernel. It's not very fair because > > > there are few users of SHRT_MAX. But there are literally no users of > > > S32_MAX in the kernel and 358 users of INT_MAX. > > > > > > Don't insist that you must be special and different from everyone else. > > > > There are some users of U16_MAX, U32_MAX, and U64_MAX. Why use a limit > > for a different type than is being used? Why have s16/s32 at all if > > you're going to conflate it with short/int elsewhere? > > > > That said, I don't see where this code is actually using s16 (or > > int16_t) for irq_count except in these weird error checks. German, why > > do you need to check against 0x7fff (whatever you call it) at all? > > Won't comparing to a promoted-to-unsigned-int .max_count (as you do > > immediately after the WARN_ON) suffice? > > > mc_bus->resource_pools[FSL_MC_POOL_IRQ].max_count is of type int16_t > (and is so, because its value comes from an MC API that returns > an int16_t). The reason for checking irq_count against 0x7ffff is to > catch the case in which irq_count is out of range (irq_count originates > from values coming from the MC device, so we should do some validation > before using it) Comparing irq_count with max_count will catch any condition that comparing irq_count with 0x7fff will catch. -Scott -- 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/