From patchwork Mon Jan 17 11:21:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 533092 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EEE3EC433EF for ; Mon, 17 Jan 2022 11:21:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233807AbiAQLVV (ORCPT ); Mon, 17 Jan 2022 06:21:21 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:34694 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239048AbiAQLVV (ORCPT ); Mon, 17 Jan 2022 06:21:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642418479; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=MFk2Yhrf7+vbacvAPXTK15PgmzSBL/7HEQPGEAm06cA=; b=TW+/GI2dkndCCARVEFhYjls58IWSIN6EOW6k40iRlLobz2UjVUh73Xpxb5NGKYQrMr2N5S KivQOelTjZGO9YEUD1BXreDrzSV03ZjJFOJMX6znyLBdhm6m3gf3UcGZLoCXi3/l2uZPAC t/dK+5gXdHGDXJoK7mOHfzOJ7jVjKUo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-41-CW3vOB3mPy-dwE9cx7tC0Q-1; Mon, 17 Jan 2022 06:21:16 -0500 X-MC-Unique: CW3vOB3mPy-dwE9cx7tC0Q-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 51241100CCC0; Mon, 17 Jan 2022 11:21:15 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.39.193.194]) by smtp.corp.redhat.com (Postfix) with ESMTP id BCB58752C9; Mon, 17 Jan 2022 11:21:10 +0000 (UTC) From: Hans de Goede To: Pavel Machek Cc: Hans de Goede , linux-leds@vger.kernel.org, Henning Schild , kernel test robot Subject: [PATCH 1/2] leds: simatic-ipc-leds: Make simatic_ipc_led_mem_res static Date: Mon, 17 Jan 2022 12:21:08 +0100 Message-Id: <20220117112109.215695-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org simatic_ipc_led_mem_res is not used outside of the driver, make it static. Cc: Henning Schild Reported-by: kernel test robot Signed-off-by: Hans de Goede --- drivers/leds/simple/simatic-ipc-leds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/simple/simatic-ipc-leds.c b/drivers/leds/simple/simatic-ipc-leds.c index ff2c96e73241..179110448659 100644 --- a/drivers/leds/simple/simatic-ipc-leds.c +++ b/drivers/leds/simple/simatic-ipc-leds.c @@ -39,7 +39,7 @@ static struct simatic_ipc_led simatic_ipc_leds_io[] = { }; /* the actual start will be discovered with PCI, 0 is a placeholder */ -struct resource simatic_ipc_led_mem_res = DEFINE_RES_MEM_NAMED(0, SZ_4K, KBUILD_MODNAME); +static struct resource simatic_ipc_led_mem_res = DEFINE_RES_MEM_NAMED(0, SZ_4K, KBUILD_MODNAME); static void *simatic_ipc_led_memory; From patchwork Mon Jan 17 11:21:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 532731 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5AC57C433F5 for ; Mon, 17 Jan 2022 11:21:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239047AbiAQLVU (ORCPT ); Mon, 17 Jan 2022 06:21:20 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59291 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236242AbiAQLVT (ORCPT ); Mon, 17 Jan 2022 06:21:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642418479; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AyH60sfTvvph6+RX0SU8Ph5zVQEHEPB8dqcptx1BpjU=; b=Pwc+2uH5Dk/fGMCrhs6MrC3EaNYnr9TPx1oFvYQr66Bf8AjE4Iv2SXyNpTwBVXUdHIOuxL bxFV4wVJcFbqzO237BKUAww7Gomqgb0AoY10JwOOnjSntaor0wEyrkq3jG7Bs3ZXAURZbS ovhY1a7y4ZCB470zULij+6wxyrJSfZc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-374-jVrrHo_8Ojixs6ep_Ta8Qg-1; Mon, 17 Jan 2022 06:21:17 -0500 X-MC-Unique: jVrrHo_8Ojixs6ep_Ta8Qg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B24AD1934100; Mon, 17 Jan 2022 11:21:16 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.39.193.194]) by smtp.corp.redhat.com (Postfix) with ESMTP id 99FBC752C9; Mon, 17 Jan 2022 11:21:15 +0000 (UTC) From: Hans de Goede To: Pavel Machek Cc: Hans de Goede , linux-leds@vger.kernel.org, Henning Schild , kernel test robot Subject: [PATCH 2/2] leds: simatic-ipc-leds: Don't directly deref ioremap_resource() returned ptr Date: Mon, 17 Jan 2022 12:21:09 +0100 Message-Id: <20220117112109.215695-2-hdegoede@redhat.com> In-Reply-To: <20220117112109.215695-1-hdegoede@redhat.com> References: <20220117112109.215695-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Sparse (rightly) currently gives the following warning: drivers/leds/simple/simatic-ipc-leds.c:155:40: sparse: sparse: incorrect type in assignment (different address spaces) expected void *static [toplevel] simatic_ipc_led_memory got void [noderef] __iomem * Fix this by changing the type of simatic_ipc_led_memory to void __iomem * and use readl()/writel() to access it. Cc: Henning Schild Reported-by: kernel test robot Signed-off-by: Hans de Goede --- Note this is not tested on actual hw, since I do not have the hw in question --- drivers/leds/simple/simatic-ipc-leds.c | 32 +++++++++++++++----------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/drivers/leds/simple/simatic-ipc-leds.c b/drivers/leds/simple/simatic-ipc-leds.c index 179110448659..078d43f5ba38 100644 --- a/drivers/leds/simple/simatic-ipc-leds.c +++ b/drivers/leds/simple/simatic-ipc-leds.c @@ -41,7 +41,7 @@ static struct simatic_ipc_led simatic_ipc_leds_io[] = { /* the actual start will be discovered with PCI, 0 is a placeholder */ static struct resource simatic_ipc_led_mem_res = DEFINE_RES_MEM_NAMED(0, SZ_4K, KBUILD_MODNAME); -static void *simatic_ipc_led_memory; +static void __iomem *simatic_ipc_led_memory; static struct simatic_ipc_led simatic_ipc_leds_mem[] = { {0x500 + 0x1A0, "red:" LED_FUNCTION_STATUS "-1"}, @@ -92,21 +92,22 @@ static void simatic_ipc_led_set_mem(struct led_classdev *led_cd, enum led_brightness brightness) { struct simatic_ipc_led *led = cdev_to_led(led_cd); + void __iomem *reg = simatic_ipc_led_memory + led->value; + u32 val; - u32 *p; - - p = simatic_ipc_led_memory + led->value; - *p = (*p & ~1) | (brightness == LED_OFF); + val = readl(reg); + val = (val & ~1) | (brightness == LED_OFF); + writel(val, reg); } static enum led_brightness simatic_ipc_led_get_mem(struct led_classdev *led_cd) { struct simatic_ipc_led *led = cdev_to_led(led_cd); + void __iomem *reg = simatic_ipc_led_memory + led->value; + u32 val; - u32 *p; - - p = simatic_ipc_led_memory + led->value; - return (*p & 1) ? LED_OFF : led_cd->max_brightness; + val = readl(reg); + return (val & 1) ? LED_OFF : led_cd->max_brightness; } static int simatic_ipc_leds_probe(struct platform_device *pdev) @@ -116,8 +117,9 @@ static int simatic_ipc_leds_probe(struct platform_device *pdev) struct simatic_ipc_led *ipcled; struct led_classdev *cdev; struct resource *res; + void __iomem *reg; int err, type; - u32 *p; + u32 val; switch (plat->devmode) { case SIMATIC_IPC_DEVICE_227D: @@ -157,11 +159,13 @@ static int simatic_ipc_leds_probe(struct platform_device *pdev) return PTR_ERR(simatic_ipc_led_memory); /* initialize power/watchdog LED */ - p = simatic_ipc_led_memory + 0x500 + 0x1D8; /* PM_WDT_OUT */ - *p = (*p & ~1); - p = simatic_ipc_led_memory + 0x500 + 0x1C0; /* PM_BIOS_BOOT_N */ - *p = (*p | 1); + reg = simatic_ipc_led_memory + 0x500 + 0x1D8; /* PM_WDT_OUT */ + val = readl(reg); + writel(val & ~1, reg); + reg = simatic_ipc_led_memory + 0x500 + 0x1C0; /* PM_BIOS_BOOT_N */ + val = readl(reg); + writel(val | 1, reg); break; default: return -ENODEV;