From patchwork Mon Nov 4 14:55:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 178433 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp1587878ilf; Mon, 4 Nov 2019 06:56:04 -0800 (PST) X-Google-Smtp-Source: APXvYqzYjzw4dZN3DGOU9zjSWdDEY6uMIxAKjcL5NkrmQDObjDSdkd56NZnTmgp7lTzslNOPugyB X-Received: by 2002:a50:eb8e:: with SMTP id y14mr30304740edr.285.1572879364430; Mon, 04 Nov 2019 06:56:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572879364; cv=none; d=google.com; s=arc-20160816; b=H5KS3e8lCzwrylHTxTQhBZ1IS+hmgeCX05rtAPvcih8eO5L8CxwRUY1jcsG6zUmNQ/ UP/HedNt33D4Rhs52Hwq60aiP80Q67hhV00lnBfizDVf3GBcDZxk+qeTRDk76hEAfXws 0iLnpO7entwEPLKh0p8a4zldQk7zk2Z8H2su4e6TP1dckiMY0uLPyYSRzPbeMYBJZrY5 FBGN/wZ0EXx86r/imDhvBygXPuaK4B6CRKgStAyGkYkWYxOxF240+J2AGbe/4MPImKz7 7MBPgmPjN+/CcCmAfZ9xfFwNpuPJq89PMdKxmSIkzq76oVGilGEjTYwl9P/FrwpK3peb FkBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=YfzrifobDwqmPupmbBTkgex3i/62L95dETxEsNhCitc=; b=RvYAJl5T49J/YLiHhO/cB8tEg+StMtF3DLU37sBxA9wSN+m+XyAfvUPS8BHiNR5BYC gfyVkvzoKQF1Ufq5NWrQywdbzChFk1loFhPiMPmpvQ6E0sg0KWOJ2FzzuX1BEdaS3ibA XcySfhwvePHfJC9V/odgAytk+SQBIIQyWhWC2HnIH3kQN/XzotjPAzBcle5hAftt4/BZ neX/TnKYRLiqxDWoaBk3RjHyne7sON3Wtukmi/glP6Zw97JXK6nIy38YQm8fSUSOKc5J mKkypvCoRPbBeaOuicbLNSoL/ElPLEdC/L3PI2XEI5GYHpQ6yVwI+zp1TV8egi1c0GZG CK4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qMMI6qAG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l11si3445959ejq.208.2019.11.04.06.56.03; Mon, 04 Nov 2019 06:56:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qMMI6qAG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728952AbfKDO4A (ORCPT + 26 others); Mon, 4 Nov 2019 09:56:00 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:34822 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728287AbfKDOz5 (ORCPT ); Mon, 4 Nov 2019 09:55:57 -0500 Received: by mail-wr1-f66.google.com with SMTP id l10so17440608wrb.2 for ; Mon, 04 Nov 2019 06:55:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YfzrifobDwqmPupmbBTkgex3i/62L95dETxEsNhCitc=; b=qMMI6qAGmWeIwjwHlDY7ackZJkBPQhNiRo5UG68ciwDpDnSN+MFctcz4FzCtFXv6qf KtbOPa0SrHG1RrQAtOOag07iyq9b08ZKs2hlVm8IUk76jFUylm6/Hu63QYkXS/Es0kdJ 9AmMzxZjM4QK6YU2rAuOaY6OF1pUPZ2C/FxXFRjuHvYg2rvFkjlYDNb+JfexYSSE4rwB 4kZoSqgPa3ITNfzn9VaMUNOAnDAf9oNi9zFS3fg4G4yIah1ZgW/9jLZsLQL3gQ6lotTz BsF+hBnxXwgPDbroNQ+Jxyp3f+2vD0/5PwLv+Y6a107c9HwNs8DjKlxllWDK7XjP8V3T CVAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YfzrifobDwqmPupmbBTkgex3i/62L95dETxEsNhCitc=; b=mHB4P8zFlmms6M4TQSUqzDtP5no6dJyXpDzzheS75tmlP7CCUOlqTjb74NURvcfuSm 7NmQAK8/o8GMwXS8WMAB/ruoBUmgHvf+BitZd49cuxNXWp05/0/ArHJU0ObM46WHTSMA 73OYFLQNsx00ENlIjUHaqdVcXT0xMKu+bMflPUI1dvNQ/teC6s2lDpvfnSzeCodP8wL/ pEwGelv8nn4GX2n6W1//osNxILf1KPk5MTdoa5eQ+MbBcq32WI4/VUFxLAKNTiOXzuuw B0BiwPbWUwcsYLExzLOWh9FTCnRHEkFbCHrW87m0wnz+LOVEaGZuPoHH9GEdtOJlIGbJ PzZg== X-Gm-Message-State: APjAAAWY+ZAcD4CcbsIMVeNrVzuF6jrxYJYuXmYGU4qaXks3EgdPerER EMGsmQEUqZb0oNe4omEzMTBi8g== X-Received: by 2002:a5d:6947:: with SMTP id r7mr18393045wrw.129.1572879354640; Mon, 04 Nov 2019 06:55:54 -0800 (PST) Received: from mai.imgcgcw.net ([2a01:e34:ed2f:f020:58da:b044:f184:d281]) by smtp.gmail.com with ESMTPSA id f143sm18490907wme.40.2019.11.04.06.55.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2019 06:55:53 -0800 (PST) From: Daniel Lezcano To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 2/2] clocksource/drivers/sh_mtu2: Do not loop using platform_get_irq_by_name() Date: Mon, 4 Nov 2019 15:55:43 +0100 Message-Id: <20191104145543.2523-2-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191104145543.2523-1-daniel.lezcano@linaro.org> References: <2210d602-bdab-5256-57b4-6e499c4b7644@linaro.org> <20191104145543.2523-1-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Geert Uytterhoeven As platform_get_irq_by_name() now prints an error when the interrupt does not exist, looping over possibly non-existing interrupts causes the printing of scary messages like: sh_mtu2 fcff0000.timer: IRQ tgi1a not found sh_mtu2 fcff0000.timer: IRQ tgi2a not found Fix this by using the platform_irq_count() helper, to avoid touching non-existent interrupts. Limit the returned number of interrupts to the maximum number of channels currently supported by the driver in a future-proof way, i.e. using ARRAY_SIZE() instead of a hardcoded number. Fixes: 7723f4c5ecdb8d83 ("driver core: platform: Add an error message to platform_get_irq*()") Signed-off-by: Geert Uytterhoeven Signed-off-by: Daniel Lezcano Link: https://lore.kernel.org/r/20191016143003.28561-1-geert+renesas@glider.be --- drivers/clocksource/sh_mtu2.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 354b27d14a19..62812f80b5cc 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -328,12 +328,13 @@ static int sh_mtu2_register(struct sh_mtu2_channel *ch, const char *name) return 0; } +static const unsigned int sh_mtu2_channel_offsets[] = { + 0x300, 0x380, 0x000, +}; + static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, unsigned int index, struct sh_mtu2_device *mtu) { - static const unsigned int channel_offsets[] = { - 0x300, 0x380, 0x000, - }; char name[6]; int irq; int ret; @@ -356,7 +357,7 @@ static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, unsigned int index, return ret; } - ch->base = mtu->mapbase + channel_offsets[index]; + ch->base = mtu->mapbase + sh_mtu2_channel_offsets[index]; ch->index = index; return sh_mtu2_register(ch, dev_name(&mtu->pdev->dev)); @@ -408,7 +409,12 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu, } /* Allocate and setup the channels. */ - mtu->num_channels = 3; + ret = platform_irq_count(pdev); + if (ret < 0) + goto err_unmap; + + mtu->num_channels = min_t(unsigned int, ret, + ARRAY_SIZE(sh_mtu2_channel_offsets)); mtu->channels = kcalloc(mtu->num_channels, sizeof(*mtu->channels), GFP_KERNEL);