From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0460DC433E2 for ; Mon, 14 Sep 2020 15:25:36 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8B06E20665 for ; Mon, 14 Sep 2020 15:25:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="cRwI03B3"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="yXjmEl6l" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8B06E20665 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-ID:References:In-Reply-To:Subject:To:From: Date:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=YtbLnGJ0jp12W576OiPn35q2Bb067IQc1tb0Rz7jAbg=; b=cRwI03B3cyeViJPAQ4KzjK+e2 5V6indspDxXwUvf2sw+ZSeQztpxwD5Dc3MGljLzD8jEVBpapMfaX2VhtNOzKdtqAwoiZqCn/CpMbo mV5IzbBJ1SjhrtkbqDQjrznXmnWuYUwcmSEQrkQtwPLzXbj59nnDUcHqHT2pYrsrkInRoACdMwiLs AgKq8ZNl6krevmZ3rCLd+v3dLfXcSIIGjl3NviH1pmparnaM9mbGpyvuoUwBV0z3gtIm7ZNYnZJwG gKxSuEQtFpMpaErKzsz1QLNfL5eKOiDJVMbh7YcEBpYjR8/iqYKPQd+1RUEi304WHAcJAMFVfiDKh i4vxquZTw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHqK3-0006UY-14; Mon, 14 Sep 2020 15:23:15 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHqHl-0005Jk-Ef for linux-arm-kernel@lists.infradead.org; Mon, 14 Sep 2020 15:20:54 +0000 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DBE7820639; Mon, 14 Sep 2020 15:20:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600096852; bh=SxgwuzST+JSvYJRya+PVcp2/F0AEFrRW37h2Gsc+7V0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=yXjmEl6lYb+CMo9qlJJ1g4ZfKswQatENxl/z8bFZseaoC6wuWzREtpR7VZX8HHY5W ko72GcE7VHXAL9yPyvBjSmxAj0DOLKxnEFWna/wanDwU/RCJm/wQ2VaGfnKqPO5lTi ahwagrDpRpMCXfZqNLBXFqk5CaGYnXOa98S7oumU= Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kHqHh-00Bj4r-Sy; Mon, 14 Sep 2020 16:20:49 +0100 MIME-Version: 1.0 Date: Mon, 14 Sep 2020 16:20:49 +0100 From: Marc Zyngier To: Grzegorz Jaszczyk Subject: Re: [RESEND PATCH v5 2/5] irqchip/irq-pruss-intc: Add a PRUSS irqchip driver for PRUSS interrupts In-Reply-To: References: <1598886558-16546-1-git-send-email-grzegorz.jaszczyk@linaro.org> <1598886558-16546-3-git-send-email-grzegorz.jaszczyk@linaro.org> <87mu1vl46q.wl-maz@kernel.org> User-Agent: Roundcube Webmail/1.4.8 Message-ID: <98edb75abcd08e93b46c7b6dcf26ad23@kernel.org> X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: grzegorz.jaszczyk@linaro.org, tglx@linutronix.de, jason@lakedaemon.net, s-anna@ti.com, robh+dt@kernel.org, lee.jones@linaro.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, david@lechnology.com, praneeth@ti.com, afd@ti.com, rogerq@ti.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200914_112053_694519_356CD4E5 X-CRM114-Status: GOOD ( 18.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Roger Quadros , linux-omap@vger.kernel.org, jason@lakedaemon.net, "Bajjuri, Praneeth" , linux-kernel@vger.kernel.org, "Andrew F . Davis" , robh+dt@kernel.org, tglx@linutronix.de, Lee Jones , linux-arm-kernel@lists.infradead.org, David Lechner Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2020-09-14 15:57, Grzegorz Jaszczyk wrote: > On Sat, 12 Sep 2020 at 11:44, Marc Zyngier wrote: [...] >> > +static void pruss_intc_update_cmr(struct pruss_intc *intc, int evt, s8 ch) >> > +{ >> > + u32 idx, offset, val; >> > + >> > + idx = evt / CMR_EVT_PER_REG; >> > + offset = (evt % CMR_EVT_PER_REG) * CMR_EVT_MAP_BITS; >> > + >> > + val = pruss_intc_read_reg(intc, PRU_INTC_CMR(idx)); >> > + val &= ~(CMR_EVT_MAP_MASK << offset); >> > + val |= ch << offset; >> >> Why is 'ch' a signed value? Shifting a signed value, specially when >> casing it to a larger, unsigned type definitely is in UB territory. >> Similar funnies can be said about evt. >> >> And given that the caller does use unsigned types, you really are >> asking for trouble. Please fix this. > > Sure, thank you for pointing this out - I will change to u8. Please change evt too. Anything that is used to compute masks/shifts should be unsigned. [...] >> > +static void pruss_intc_init(struct pruss_intc *intc) >> > +{ >> > + const struct pruss_intc_match_data *soc_config = intc->soc_config; >> > + int i; >> > + int num_chnl_map_regs = DIV_ROUND_UP(soc_config->num_system_events, >> > + CMR_EVT_PER_REG); >> > + int num_host_intr_regs = DIV_ROUND_UP(soc_config->num_host_events, >> > + HMR_CH_PER_REG); >> > + int num_event_type_regs = >> > + DIV_ROUND_UP(soc_config->num_system_events, 32); >> >> Please keep assignments on a single line. > > Keeping entire assignment in single line will break the 80 columns > rule, what about changing it into: There is no such thing as a "80 column rule". As I often say, I no longer own a vt100. > > - int i; > - int num_chnl_map_regs = > DIV_ROUND_UP(soc_config->num_system_events, > - CMR_EVT_PER_REG); > - int num_host_intr_regs = > DIV_ROUND_UP(soc_config->num_host_events, > - HMR_CH_PER_REG); > - int num_event_type_regs = > - DIV_ROUND_UP(soc_config->num_system_events, > 32); > + int num_chnl_map_regs, num_host_intr_regs, num_event_type_regs, > i; > + > + num_chnl_map_regs = DIV_ROUND_UP(soc_config->num_system_events, > + CMR_EVT_PER_REG); > + num_host_intr_regs = DIV_ROUND_UP(soc_config->num_host_events, > + HMR_CH_PER_REG); > + num_event_type_regs = > DIV_ROUND_UP(soc_config->num_system_events, 32); > > Will it be ok? Sure. M. -- Jazz is not dead. It just smells funny... _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel