Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp516799rdb; Thu, 8 Feb 2024 12:30:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IFow5IsNvQIIlQeJCi/GrsM9EsxueYxas74soS5QB3ZZVgFwWWeQflhzOLcZuZ1iq9telgv X-Received: by 2002:a05:6358:591e:b0:179:24b4:41fb with SMTP id g30-20020a056358591e00b0017924b441fbmr307482rwf.3.1707424205864; Thu, 08 Feb 2024 12:30:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707424205; cv=pass; d=google.com; s=arc-20160816; b=q+CYkNH9d5WYJZv40MlK1HXTaP45M/8POh3SDgwvCtM32ytfi+21Z8Cerg9WEGYQsP atZqtEz8wAivI5XdgkFGC1GWahRE8J7qRUoR3Ig2nlHXPeDHW1lJCeYjs2BSRW4d6sVW 3hMz56tUdqDiBIEJ/86P7mZGPpZP4oU9wVGPHXSoOjcMzA5hERnS7Zo6457UG6u991pV fR2gyAQY4ZSu5f78V2caGgG6Hdm9rAFF/ZQIcu3FqCvzuq8q+rtbThcehDX0IZw/zpAK PopUVgRZ0+bgzudtpuydl27yJhP1h+v3AyzJz3Z3/7SaReCl3YbHuDRhT68D8jBD0on2 9Scw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=JVsqcGei7siW0fHnROYsdSsFWu3A0g1PQ15MBjzkZ40=; fh=CjrOF3z8xeUaQUroGqJgAL2MgEn5vwgnTeuPhd1zoeI=; b=tMNM+ATlBnBeTL1TIbhWyRJYlEkJqBLtAxHpRgHO99Iy4eDX9UaZdHIH/4YmPDtdgl 4B+u1ImVg2/deeQkdMe9tzuQZq+s0obnw4MbKBwR+BPaITQwrMU2cTsXMHJUKBHZhC2P 35dYiqMv67Od464Fj9X9ZFpry1dz2bX1krMsg8H/MlPEGnCv5ewyJTwXQOYJJc0LaBbk Sr2H8fFWMqBykjmGvUo5wCRxlgt3K7c8qB8xatHO9NAT590ORXLSsMei/uZt4Xa4yab1 h3GQLg2/TGl9p0m5OG4e8TFewklYWWbB5zsN26M8973e36MojfF7Qvh+ZtGYSEV7UG9L jpzA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lWRcnp35; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-58665-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58665-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=2; AJvYcCXLwP5P8dQfe7ehDEUE02TG64xb1U2s+M2nau6gqQ09RLfFK/xfiGDRgy4+vs1b7zFK0KjmbBTnazho2fsucpITqgY7QizH6A3FOQCqcw== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id w190-20020a6362c7000000b005dc4827d5d4si378865pgb.178.2024.02.08.12.30.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 12:30:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58665-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lWRcnp35; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-58665-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58665-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 653DC288AAD for ; Thu, 8 Feb 2024 20:27:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C9C4B38DE7; Thu, 8 Feb 2024 20:27:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="lWRcnp35" Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4038438DFC for ; Thu, 8 Feb 2024 20:27:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707424034; cv=none; b=sXguq8Di9HL+zzRuM2+C5zpmVvKOgFwNCiUHqEYtNs1I5XDCb2Gl7WtSYr+Rg7KrghvrpuufzAScKYIpcQ8eV53kSi0MG0EhW85IzZ3TMM4iCwO0SICv6tD5boAxtS2EyDvlK5uF2LztJ8SozT7X1fDtMExRsVw3mjsA4ONQR2E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707424034; c=relaxed/simple; bh=3P3uwJagr0FmLmf2/VrMSkMUj3jH7rR6a/yAEJUMRhs=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=CvD7bENg8so/5diEtu9vnPEYAlGt9RApY/k/lvl/XFu6hKaR8pUtOi2+GFtY/X+7wzUCIOmXzSgHTGrSZZo/H/C7O/sKEUKu90hhCKK82Pl+CxcR8+egoT/S4LUT4bArEFVPGzZc6c1IBvGvAN6nQm3DB2zelETO5EvbzKoUwKg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=lWRcnp35; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-410585542b3so1966065e9.2 for ; Thu, 08 Feb 2024 12:27:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707424027; x=1708028827; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=JVsqcGei7siW0fHnROYsdSsFWu3A0g1PQ15MBjzkZ40=; b=lWRcnp35W0+8rdXrny0vdDIly4q6V+Lq30BApLEdhp/GCruEuyiuacgkXq8T5hZh2R OYuxF1ysaHYFnSHGOrfHYH346x80LBgOqvG6ylRzOzCnRrV5kNpAJeSIhdQaCDts8u4l NmpoaBCRKGMcX8S1i4Fxd8xo4AGWknaYrpt4l2qw9QytufBDGekEU+r9NUiDFpkp4k6S k5XQjHFLl3WvZmPITaZJUydx13jwkbO0sLWunD36WYAoY5adURH4yt7oNxxOyF3j0N2T 6k4Kms0/PEQnbR7xA2q9gKISvZ3himMUAH2STg1jYnO/2THUe5u4EKwMyWcFYzTJfTIw ttzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707424027; x=1708028827; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=JVsqcGei7siW0fHnROYsdSsFWu3A0g1PQ15MBjzkZ40=; b=U9Q8HxCAvQ2HPT6bujPRb7YeusDLCIGbIwbnDqVXmXbinKXIYxT3B6abKPHIDvtUcW Vdy+B9SrBu4x6uSv9qAHQCtkogZPlnRn4cm1byLDO6B0uah60aydZ7Gbkoq21NNMJdJg zyD7FnaEeuH5QhoQoLTfRyQpViZPh3rtsozmGLlfBOf6H45ba9aTmREK7LaO6oTURpcC CHrnx92NXjHEv9qMToFCHv+6igYQhcUfMEMzSy24P4uoLo59F1Fp4CjctKfgKNyvMkOm 5Q5/7pXtsyPauDXSOxrj38dexn07D4YKar3gMGHwL90Qneel1lGPcUGUQOiBpRUfOcXm FDLQ== X-Gm-Message-State: AOJu0YzueV1sXDfUkkkml6aiDlizxllvXJhOI44U1J8bOIYnJEEP/wML f91HhSsivFY7+yPIt5dB4QDT6DwGh7sDhlgVFKDvgnKmbXm1l2Oukz5AgGB44KY= X-Received: by 2002:a05:600c:510b:b0:410:4a4:6cd0 with SMTP id o11-20020a05600c510b00b0041004a46cd0mr280276wms.33.1707424027212; Thu, 08 Feb 2024 12:27:07 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCU8vdVe1g94d63MmNRK8LV5w35qEHHLyJiAaP8z4fGuhssyY99zgJWQWR+dkI9+yD70cGXd8QIYrbxkVhch1Zq23QZzjYZjwjqI1hizJ9pYPagQM2sysH9CmKWS9FT5zB1x2IPNBwkS2TpWFJYddDjabhmeBSJzPtcTPoq8SBE7i2pmCd+5dm1s9OiSF1zKYIPfRlUOq7ZyId5pzUVcl6/sAJQKt12IRlwnHv2PJiO8boF4cJa4s1bSV8fmRSNO+uefS8t6N4TRcN7Bl1vnYhdH Received: from krzk-bin.. ([178.197.222.62]) by smtp.gmail.com with ESMTPSA id e13-20020a05600c4e4d00b0040ffd94cd27sm375567wmq.45.2024.02.08.12.27.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 12:27:06 -0800 (PST) From: Krzysztof Kozlowski To: Mika Westerberg , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Krzysztof Kozlowski Subject: [PATCH] gpio: constify opaque pointer in gpio_device_find() match function Date: Thu, 8 Feb 2024 21:27:04 +0100 Message-Id: <20240208202704.631203-1-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The match function used in gpio_device_find() should not modify the contents of passed opaque pointer, because such modification would not be necessary for actual matching and it could lead to quite unreadable, spaghetti code. Signed-off-by: Krzysztof Kozlowski --- drivers/gpio/gpiolib-acpi.c | 2 +- drivers/gpio/gpiolib-of.c | 7 ++++--- drivers/gpio/gpiolib.c | 6 +++--- include/linux/gpio/driver.h | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index cd3e9657cc36..899cd505073e 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -126,7 +126,7 @@ static DEFINE_MUTEX(acpi_gpio_deferred_req_irqs_lock); static LIST_HEAD(acpi_gpio_deferred_req_irqs_list); static bool acpi_gpio_deferred_req_irqs_done; -static int acpi_gpiochip_find(struct gpio_chip *gc, void *data) +static int acpi_gpiochip_find(struct gpio_chip *gc, const void *data) { return device_match_acpi_handle(&gc->gpiodev->dev, data); } diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 77509aa19900..35d717fd393f 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -118,9 +118,10 @@ int of_gpio_get_count(struct device *dev, const char *con_id) return ret ? ret : -ENOENT; } -static int of_gpiochip_match_node_and_xlate(struct gpio_chip *chip, void *data) +static int of_gpiochip_match_node_and_xlate(struct gpio_chip *chip, + const void *data) { - struct of_phandle_args *gpiospec = data; + const struct of_phandle_args *gpiospec = data; return device_match_of_node(&chip->gpiodev->dev, gpiospec->np) && chip->of_xlate && @@ -852,7 +853,7 @@ static void of_gpiochip_remove_hog(struct gpio_chip *chip, gpiochip_free_own_desc(desc); } -static int of_gpiochip_match_node(struct gpio_chip *chip, void *data) +static int of_gpiochip_match_node(struct gpio_chip *chip, const void *data) { return device_match_of_node(&chip->gpiodev->dev, data); } diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 24d046268a01..0e332b24c7b8 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1114,7 +1114,7 @@ EXPORT_SYMBOL_GPL(gpiochip_remove); */ struct gpio_device *gpio_device_find(void *data, int (*match)(struct gpio_chip *gc, - void *data)) + const void *data)) { struct gpio_device *gdev; @@ -1136,7 +1136,7 @@ struct gpio_device *gpio_device_find(void *data, } EXPORT_SYMBOL_GPL(gpio_device_find); -static int gpio_chip_match_by_label(struct gpio_chip *gc, void *label) +static int gpio_chip_match_by_label(struct gpio_chip *gc, const void *label) { return gc->label && !strcmp(gc->label, label); } @@ -1156,7 +1156,7 @@ struct gpio_device *gpio_device_find_by_label(const char *label) } EXPORT_SYMBOL_GPL(gpio_device_find_by_label); -static int gpio_chip_match_by_fwnode(struct gpio_chip *gc, void *fwnode) +static int gpio_chip_match_by_fwnode(struct gpio_chip *gc, const void *fwnode) { return device_match_fwnode(&gc->gpiodev->dev, fwnode); } diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 3a37d058cfcf..51b23211794d 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -629,7 +629,7 @@ int devm_gpiochip_add_data_with_key(struct device *dev, struct gpio_chip *gc, struct lock_class_key *request_key); struct gpio_device *gpio_device_find(void *data, - int (*match)(struct gpio_chip *gc, void *data)); + int (*match)(struct gpio_chip *gc, const void *data)); struct gpio_device *gpio_device_find_by_label(const char *label); struct gpio_device *gpio_device_find_by_fwnode(const struct fwnode_handle *fwnode); -- 2.34.1