From nobody Thu Feb 12 21:45:24 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B8A81991D9; Thu, 6 Jun 2024 17:30:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717695046; cv=none; b=j5KSIonjANi84yVuO3vRhdgOJY06YHpCzZMS8onw5wZELCBav0w7Uz0uJT4M115N2CgWn5g6PRFb5JG6edK9oJET21xsmlns/0M7+CTpO7EGTbilAJ7+v+J/pVo5tvJLSO0F78EhXSevs7s/Ls4an2jVnhkW7zwRdI1nKO3ovXg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717695046; c=relaxed/simple; bh=5YQCa8UVebd8nCd5+11hDHGlbqk8BQoGJTU401XyJxw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DBn1vlIH9PnorWO4BhniM9m4egnP5zw1xD46r3bpJZjybpHHukdLIf1mkwsLbP4cxenZd5M+qj1CY4K3uamFG3sdPWfkfaFi6vFDqRO45QlsHIRA4Slg7OkWjopuk7E8NUGL9zjCbr2svPfuzajMJoh586+6oa83rYfrJkyyloo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=FSjJLI1B; arc=none smtp.client-ip=192.198.163.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="FSjJLI1B" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717695044; x=1749231044; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5YQCa8UVebd8nCd5+11hDHGlbqk8BQoGJTU401XyJxw=; b=FSjJLI1B0qDTAyaINsurGB9jH5ebSnuOUWkB1yyVzaGdUaZzYObrqx4S a7w2x4QpLWqqrOMQd+Ym5W/J7qXwsQAJ/W0BKc/iF9gu4wsxLo1tjtLzk j1zLhngpRT9FO6oAfcjmh/VtX8AgDSMs6KN68paNGuFsUjTkDzw9s0aRs rbGOCFfscsXQwpxbqQ11yec8/wNGuLAzgNXOy2fIPJtkGDZnoNIlcfuUD JI2nnJFXbcjvb8YSQSiC0qiFEohZv3vMF+H28swHfmjP1FDnYas4PUmQh u4aauuPdcC16cfkRx5Y5ekr3j+kFNAzF0SGbaYvTy8LkkyBOwXVENkzDI g==; X-CSE-ConnectionGUID: /VM9+RPXRQGky+F2kWzWaA== X-CSE-MsgGUID: 6qGyQckDSS+p996Xo4oLpQ== X-IronPort-AV: E=McAfee;i="6600,9927,11095"; a="14191999" X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="14191999" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2024 10:30:42 -0700 X-CSE-ConnectionGUID: +/WMy0gpS+204HBPvSapuA== X-CSE-MsgGUID: h74mzfkjSOqbenqFhNfL5w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="38164432" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa009.fm.intel.com with ESMTP; 06 Jun 2024 10:30:40 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 67E7AF7; Thu, 06 Jun 2024 20:30:39 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Pavel Machek , Lee Jones Subject: [PATCH v1 1/6] leds: spi-byte: call of_node_put() on error path Date: Thu, 6 Jun 2024 20:29:18 +0300 Message-ID: <20240606173037.3091598-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240606173037.3091598-1-andriy.shevchenko@linux.intel.com> References: <20240606173037.3091598-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a missing call to of_node_put(np) on error. Signed-off-by: Andy Shevchenko --- drivers/leds/leds-spi-byte.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/leds/leds-spi-byte.c b/drivers/leds/leds-spi-byte.c index 96296db5f410..b04cf502e603 100644 --- a/drivers/leds/leds-spi-byte.c +++ b/drivers/leds/leds-spi-byte.c @@ -91,7 +91,6 @@ static int spi_byte_probe(struct spi_device *spi) dev_err(dev, "Device must have exactly one LED sub-node."); return -EINVAL; } - child =3D of_get_next_available_child(dev_of_node(dev), NULL); =20 led =3D devm_kzalloc(dev, sizeof(*led), GFP_KERNEL); if (!led) @@ -104,11 +103,13 @@ static int spi_byte_probe(struct spi_device *spi) led->ldev.max_brightness =3D led->cdef->max_value - led->cdef->off_value; led->ldev.brightness_set_blocking =3D spi_byte_brightness_set_blocking; =20 + child =3D of_get_next_available_child(dev_of_node(dev), NULL); state =3D of_get_property(child, "default-state", NULL); if (state) { if (!strcmp(state, "on")) { led->ldev.brightness =3D led->ldev.max_brightness; } else if (strcmp(state, "off")) { + of_node_put(child); /* all other cases except "off" */ dev_err(dev, "default-state can only be 'on' or 'off'"); return -EINVAL; @@ -123,9 +124,12 @@ static int spi_byte_probe(struct spi_device *spi) =20 ret =3D devm_led_classdev_register_ext(&spi->dev, &led->ldev, &init_data); if (ret) { + of_node_put(child); mutex_destroy(&led->mutex); return ret; } + + of_node_put(child); spi_set_drvdata(spi, led); =20 return 0; --=20 2.43.0.rc1.1336.g36b5255a03ac From nobody Thu Feb 12 21:45:24 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E556419922F; Thu, 6 Jun 2024 17:30:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717695047; cv=none; b=PCoGV+RHhEmD3Kp0NF6795OlOHTxiCg6sYEXC1VbKO8e3NZ/erBUmU10gMnW/y5asQFJ2PrzJoLMGv4yki6LfnevQKaPe9Hp3qDYtdJj4v900Qq77sPVaAf286zgMSFLqrhI0fkOCjqexIQmcwy6TLuV+DH26F46yuZ7+oEXDL0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717695047; c=relaxed/simple; bh=+T0sENgNAG9M5FwnYrWEQdFRsy0FTQjbFITtNZYR/ds=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rz5FoCWVcLl1acLpPVa+kYO3WGX1kHH3x8RAYm/8gmaSeYMMRgM5HbpLYfTx0h4cmJuOrQBOdHYrXpoBWfifx4+tCduj9F+9cwXzFgFlI5Z0G5/yHvCb3REyiVtqanQgbC+Vmdw/agxqgG+WO+mTpPp/ZAmFtgaqJWWGNpO4StM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Aasd1Bzs; arc=none smtp.client-ip=192.198.163.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Aasd1Bzs" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717695046; x=1749231046; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+T0sENgNAG9M5FwnYrWEQdFRsy0FTQjbFITtNZYR/ds=; b=Aasd1Bzs8tTN98XAksxXhpO+aO1z3TUE5b1Vlz/jjylJNKQpvBtntNeG fW3DKo6rGMDF37y1cPwseszbRC+puWKUkGJ06oYqHxmwKyICezebzlrRK jykDVeS+nZ6GU5e+lUc+WLWkKOjctYax9JlbV7yVfIvSf8pONfQ3PN1U0 7lkDTJO2WVfA+H4ZgvHyG8g9y8NXdz7B5hPG4RGocHjUkjtw1faDwsul+ fhWcFy0yH6LfW9CP2g7W0Y0WRAcGDQn6leuXgMxhORmOFaJEDvIgcY758 qhQyWNKvUCgV/3jWEcEFIEsl04tRnalMwNraHKEvs4k7a1Ac2+w72m2Ee A==; X-CSE-ConnectionGUID: 9+gfrYFDRA6kN6S5YOSPsw== X-CSE-MsgGUID: mp3mJHFtTN+E5ZWp4HyLWw== X-IronPort-AV: E=McAfee;i="6600,9927,11095"; a="14192008" X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="14192008" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2024 10:30:42 -0700 X-CSE-ConnectionGUID: saaOhPoHRbas2EatagOU0g== X-CSE-MsgGUID: iirFD67tTFm08JDcJmnQ+w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="38164434" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa009.fm.intel.com with ESMTP; 06 Jun 2024 10:30:40 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 71CD12A4; Thu, 06 Jun 2024 20:30:39 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Pavel Machek , Lee Jones Subject: [PATCH v1 2/6] leds: spi-byte: Get rid of custom led_init_default_state_get() Date: Thu, 6 Jun 2024 20:29:19 +0300 Message-ID: <20240606173037.3091598-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240606173037.3091598-1-andriy.shevchenko@linux.intel.com> References: <20240606173037.3091598-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" LED core provides a helper to parse default state from firmware node. Use it instead of custom implementation. Signed-off-by: Andy Shevchenko --- drivers/leds/leds-spi-byte.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/leds/leds-spi-byte.c b/drivers/leds/leds-spi-byte.c index b04cf502e603..76733946c99a 100644 --- a/drivers/leds/leds-spi-byte.c +++ b/drivers/leds/leds-spi-byte.c @@ -84,7 +84,7 @@ static int spi_byte_probe(struct spi_device *spi) struct device *dev =3D &spi->dev; struct spi_byte_led *led; struct led_init_data init_data =3D {}; - const char *state; + enum led_default_state state; int ret; =20 if (of_get_available_child_count(dev_of_node(dev)) !=3D 1) { @@ -104,17 +104,10 @@ static int spi_byte_probe(struct spi_device *spi) led->ldev.brightness_set_blocking =3D spi_byte_brightness_set_blocking; =20 child =3D of_get_next_available_child(dev_of_node(dev), NULL); - state =3D of_get_property(child, "default-state", NULL); - if (state) { - if (!strcmp(state, "on")) { - led->ldev.brightness =3D led->ldev.max_brightness; - } else if (strcmp(state, "off")) { - of_node_put(child); - /* all other cases except "off" */ - dev_err(dev, "default-state can only be 'on' or 'off'"); - return -EINVAL; - } - } + + state =3D led_init_default_state_get(of_fwnode_handle(child)); + if (state =3D=3D LEDS_DEFSTATE_ON) + led->ldev.brightness =3D led->ldev.max_brightness; spi_byte_brightness_set_blocking(&led->ldev, led->ldev.brightness); =20 --=20 2.43.0.rc1.1336.g36b5255a03ac From nobody Thu Feb 12 21:45:24 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 93189197A6A; Thu, 6 Jun 2024 17:30:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717695044; cv=none; b=l4Y2s8yfwbBtz6W4MD/ZhuxjwcJLwOZ0PR16vodc4Pajwa9G5qP++dtEZlQ3HLKMkzO4BOaZNBfYzUZWLxx2mI/dKZTUDpVL5tGn4LiIH0BMHaUDZUMeUawUpGssMn/SiVKnuz01ljX859t909xKFZ+cEQNZXVo7yRWuFm0Phag= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717695044; c=relaxed/simple; bh=nWxfJAb/+1mkNjtmtDnUm6qW8y1b8t5E/REvy73XYYc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i1nHYHupQp16F2YXkWodIFyzHEvE3GzvLfIt82XAW0EJ9f471plVX+kVoCaIUzES4CtAuC/KA2cgCiMkf9k8RY5dg9NUHliF/qUBSSmySYVhIABJGdGPKMRTc/r4d+7qXbdXBZeBFd8/2OWldFd+ExrK7mjXAmalainLrWOjH4A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=bSSpF0Jz; arc=none smtp.client-ip=192.198.163.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="bSSpF0Jz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717695042; x=1749231042; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nWxfJAb/+1mkNjtmtDnUm6qW8y1b8t5E/REvy73XYYc=; b=bSSpF0JzkjxVJ6pm9FJHoaqt1KLjIR0aYecX+9944KYZ+RCRB9GCDT+G dzx7SDywK2pd5gFvi7U94J85NobZtsb7PuLI4GSLPFMGxsGqwBdZHvthv SQSCSSzIaWWp/3OMWqQa2tIAJem5uHKL09V+dY9z6xGdxyOPnGbqwD1Ly IWKDMlCtzhjEjXp1uOLDF5aV5l25sREFwUvAoe1zwdJiEKAQzzBrgaTbv SFMHxbJpM/8pNgr1fxy/Nw7FwvD79gVCkOXihKsJvzULhHUIP1uKNhy8H YwSB2ymQu78SMwOXHZslgsSbtGc8k6hebjkcchxjY1USjOu6EjdxZ0Teq g==; X-CSE-ConnectionGUID: /CmCJF1rQL61kiEM+4muxg== X-CSE-MsgGUID: STPl9IlPQr+bfKXokNMzoA== X-IronPort-AV: E=McAfee;i="6600,9927,11095"; a="14192002" X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="14192002" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2024 10:30:42 -0700 X-CSE-ConnectionGUID: pILV47EHS2W8SLgATK2rAw== X-CSE-MsgGUID: R6CM1whQTyu3hqaw4eV0cg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="38164433" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa009.fm.intel.com with ESMTP; 06 Jun 2024 10:30:40 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 89A6930B; Thu, 06 Jun 2024 20:30:39 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Pavel Machek , Lee Jones Subject: [PATCH v1 3/6] leds: spi-byte: Make use of device properties Date: Thu, 6 Jun 2024 20:29:20 +0300 Message-ID: <20240606173037.3091598-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240606173037.3091598-1-andriy.shevchenko@linux.intel.com> References: <20240606173037.3091598-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Convert the module to be property provider agnostic and allow it to be used on non-OF platforms. Add mod_devicetable.h include. Signed-off-by: Andy Shevchenko --- drivers/leds/Kconfig | 1 - drivers/leds/leds-spi-byte.c | 15 +++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 7211f0a4f88f..2e1925d2068c 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -865,7 +865,6 @@ config LEDS_SPI_BYTE tristate "LED support for SPI LED controller with a single byte" depends on LEDS_CLASS depends on SPI - depends on OF help This option enables support for LED controller which use a single byte for controlling the brightness. Currently the following controller is diff --git a/drivers/leds/leds-spi-byte.c b/drivers/leds/leds-spi-byte.c index 76733946c99a..1fc0a8cc123e 100644 --- a/drivers/leds/leds-spi-byte.c +++ b/drivers/leds/leds-spi-byte.c @@ -29,8 +29,9 @@ */ =20 #include +#include #include -#include +#include #include #include #include @@ -80,14 +81,14 @@ static int spi_byte_brightness_set_blocking(struct led_= classdev *dev, =20 static int spi_byte_probe(struct spi_device *spi) { - struct device_node *child; + struct fwnode_handle *child __free(fwnode_handle) =3D NULL; struct device *dev =3D &spi->dev; struct spi_byte_led *led; struct led_init_data init_data =3D {}; enum led_default_state state; int ret; =20 - if (of_get_available_child_count(dev_of_node(dev)) !=3D 1) { + if (device_get_child_node_count(dev) !=3D 1) { dev_err(dev, "Device must have exactly one LED sub-node."); return -EINVAL; } @@ -103,26 +104,24 @@ static int spi_byte_probe(struct spi_device *spi) led->ldev.max_brightness =3D led->cdef->max_value - led->cdef->off_value; led->ldev.brightness_set_blocking =3D spi_byte_brightness_set_blocking; =20 - child =3D of_get_next_available_child(dev_of_node(dev), NULL); + child =3D device_get_next_child_node(dev, NULL); =20 - state =3D led_init_default_state_get(of_fwnode_handle(child)); + state =3D led_init_default_state_get(child); if (state =3D=3D LEDS_DEFSTATE_ON) led->ldev.brightness =3D led->ldev.max_brightness; spi_byte_brightness_set_blocking(&led->ldev, led->ldev.brightness); =20 - init_data.fwnode =3D of_fwnode_handle(child); + init_data.fwnode =3D child; init_data.devicename =3D "leds-spi-byte"; init_data.default_label =3D ":"; =20 ret =3D devm_led_classdev_register_ext(&spi->dev, &led->ldev, &init_data); if (ret) { - of_node_put(child); mutex_destroy(&led->mutex); return ret; } =20 - of_node_put(child); spi_set_drvdata(spi, led); =20 return 0; --=20 2.43.0.rc1.1336.g36b5255a03ac From nobody Thu Feb 12 21:45:24 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 58FE819922A; Thu, 6 Jun 2024 17:30:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717695047; cv=none; b=VOlXvDAKjwZYsjUU/CJ24gPSnMFUijNVczLgqnTWxW6XHBMfULWBfqeWnj6Q0cMiNozQXNHNlgSFQCuVfMgVdcB+AKPLFSDtb+46wlMFr3KHYuUvsRdXF9XzO8fCukytN9HK+kCxIKx7KuGq1XAvZgHtJr/BOhKSQmgS7tLJA3s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717695047; c=relaxed/simple; bh=QBmoVRhUJZlP7PTuWcuGpKu7NTGstVCtnVRAN1E5hLQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P8XUQwIH7GGC4i6fHZPXwqfLM9VoPACjVBwyLiMZFlibJQM7UP+HxcW3KqkR/YoXocXtwaFaCsS1gNXMrbOicgf3ZKyFzULxSVuBhD0cfk923CJJGXmTLKEFeUQSjgBkJcas+YVDcrbmORObhlGRCiJRvXNnspQu9wiAsO1JQn4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Q2hEA5wh; arc=none smtp.client-ip=192.198.163.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Q2hEA5wh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717695046; x=1749231046; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QBmoVRhUJZlP7PTuWcuGpKu7NTGstVCtnVRAN1E5hLQ=; b=Q2hEA5whgM8Wpp2zRDQFSFqBT1XNumVY6iPODNXQxaYw7hginnScI/JG FNV6OZfYzm8GDOVN9xOXmKBBrowq3yENC/inSos1N9Bq8c9CYcke6B9To /S1rzx/1dKGzj58ZVGV4hIcoh0+uejssqrzINcgGnTRL1x6L6Xo9Ab4ld VhqetqN9nP7erhBAXHAaFu/FQ75Vbxijn3+qlpwf649fBFIY/q34Em0vm QVdHdMmjOHhUCny+9I6i8D47s9YVyee/O10EMCwM2YSh0RJgWa3w7pC3l 7aNnXW586uKAndxbH2JcLXjQiEnIcHxbhmoFSNJvtF3Xu6EeGtA7Z22Bb Q==; X-CSE-ConnectionGUID: dDGHkDrJQTy/11upQFvmJg== X-CSE-MsgGUID: ZqaKf1gfSUae0nAId7grcg== X-IronPort-AV: E=McAfee;i="6600,9927,11095"; a="14192013" X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="14192013" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2024 10:30:42 -0700 X-CSE-ConnectionGUID: JD70v06MTVG8J74bIvUcIA== X-CSE-MsgGUID: jmfgeVq2T/6APnArntHyzQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="38164435" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa009.fm.intel.com with ESMTP; 06 Jun 2024 10:30:40 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 8EE362CF; Thu, 06 Jun 2024 20:30:39 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Pavel Machek , Lee Jones Subject: [PATCH v1 4/6] leds: spi-byte: Utilise temporary variable for struct device Date: Thu, 6 Jun 2024 20:29:21 +0300 Message-ID: <20240606173037.3091598-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240606173037.3091598-1-andriy.shevchenko@linux.intel.com> References: <20240606173037.3091598-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" We have a temporary variable to keep a pointer to struct device. Utilise it where it makes sense. Signed-off-by: Andy Shevchenko --- drivers/leds/leds-spi-byte.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/leds-spi-byte.c b/drivers/leds/leds-spi-byte.c index 1fc0a8cc123e..e63958e584c2 100644 --- a/drivers/leds/leds-spi-byte.c +++ b/drivers/leds/leds-spi-byte.c @@ -116,7 +116,7 @@ static int spi_byte_probe(struct spi_device *spi) init_data.devicename =3D "leds-spi-byte"; init_data.default_label =3D ":"; =20 - ret =3D devm_led_classdev_register_ext(&spi->dev, &led->ldev, &init_data); + ret =3D devm_led_classdev_register_ext(dev, &led->ldev, &init_data); if (ret) { mutex_destroy(&led->mutex); return ret; --=20 2.43.0.rc1.1336.g36b5255a03ac From nobody Thu Feb 12 21:45:24 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F1C6C1991DD; Thu, 6 Jun 2024 17:30:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717695046; cv=none; b=dVW2J9k4EsO7fkSXKTTcCaA2r2OcgBKyrQRFo/yinupYraxUwvsnk5PIncjKZ9GKHt4CB56+Srs+GxzeJPZLnRCFwY38qA8vQNJhhencI25cM6T1FctscrQV1owXOZBF0Q6a2t9BN8jprRqaFfF11LiJxTdA93f5kNOKQnw4vn4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717695046; c=relaxed/simple; bh=BCX/043BK+EE/JmjauW+PrrtG3fUrZvHQpf4V8w3pOE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U8xR/KupkJS1/0seP4MPN0SUnfz0mbW2HTxTPlYBSAIrTEewitpx3MGkBS9vil45AMrZL+JhZyI0EW8V+uoS/4Ua04oR5wMED066W3LLroyMFsFEzrwbCkVN15u9Tc3syc6HMWR4PsVn/m7Ik8olXlWcaCeRoSjUW6aGiWQGh9E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=QVY8xs0Q; arc=none smtp.client-ip=198.175.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="QVY8xs0Q" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717695046; x=1749231046; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BCX/043BK+EE/JmjauW+PrrtG3fUrZvHQpf4V8w3pOE=; b=QVY8xs0QxUaCGHqHQ6AiTGEyIiLN7uyZVruq4pXGv0BK28zwTUL+OlQg jrAvorBegiltyyNCv3AEnT4LnHvGkk/xwxKQYHfJRz4DC5TKTHTT6M//G sC7SGmNrsHI0KjTL7ERhG63b9cIIknsW3n3QI17BYLNMt6lueiukbGP8O NrRuXtd/DgJLCzUXxYDZl8pgooR26tm2Qcg0LOz7N0DiKizfZom6z5PAt vAOWllC4eGRSrMXw2t2+SGiEdenxgTPjMcoVfWfNnC95ciZ+8DBlCBUNJ LbioscPEzxVt4TsMsRlzyrPmdGDm5jtLo+6MDFkoAiXTjP3YrBf2xZLAZ g==; X-CSE-ConnectionGUID: kAjadE15RBu8kCtTZMZz6g== X-CSE-MsgGUID: L4W6HkA/SKOFQ1QBby4VyQ== X-IronPort-AV: E=McAfee;i="6600,9927,11095"; a="24956031" X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="24956031" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2024 10:30:45 -0700 X-CSE-ConnectionGUID: 4Ofs/nIeQA+HlYCfLlyj9w== X-CSE-MsgGUID: QQxd/5k1RCqXBekkrwasjw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="38490680" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa006.jf.intel.com with ESMTP; 06 Jun 2024 10:30:43 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id A6920371; Thu, 06 Jun 2024 20:30:39 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Pavel Machek , Lee Jones Subject: [PATCH v1 5/6] leds: spi-byte: Use devm_mutex_init() for mutex initialization Date: Thu, 6 Jun 2024 20:29:22 +0300 Message-ID: <20240606173037.3091598-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240606173037.3091598-1-andriy.shevchenko@linux.intel.com> References: <20240606173037.3091598-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In this driver LEDs are registered using devm_led_classdev_register() so they are automatically unregistered after module's remove() is done. led_classdev_unregister() calls module's led_set_brightness() to turn off the LEDs and that callback uses mutex which was destroyed already in module's remove() so use devm API instead. Signed-off-by: Andy Shevchenko --- drivers/leds/leds-spi-byte.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/drivers/leds/leds-spi-byte.c b/drivers/leds/leds-spi-byte.c index e63958e584c2..985bbbed251b 100644 --- a/drivers/leds/leds-spi-byte.c +++ b/drivers/leds/leds-spi-byte.c @@ -31,9 +31,9 @@ #include #include #include +#include #include #include -#include #include =20 struct spi_byte_chipdef { @@ -97,8 +97,11 @@ static int spi_byte_probe(struct spi_device *spi) if (!led) return -ENOMEM; =20 + ret =3D devm_mutex_init(dev, &led->mutex); + if (ret) + return ret; + led->spi =3D spi; - mutex_init(&led->mutex); led->cdef =3D device_get_match_data(dev); led->ldev.brightness =3D LED_OFF; led->ldev.max_brightness =3D led->cdef->max_value - led->cdef->off_value; @@ -116,33 +119,16 @@ static int spi_byte_probe(struct spi_device *spi) init_data.devicename =3D "leds-spi-byte"; init_data.default_label =3D ":"; =20 - ret =3D devm_led_classdev_register_ext(dev, &led->ldev, &init_data); - if (ret) { - mutex_destroy(&led->mutex); - return ret; - } - - spi_set_drvdata(spi, led); - - return 0; -} - -static void spi_byte_remove(struct spi_device *spi) -{ - struct spi_byte_led *led =3D spi_get_drvdata(spi); - - mutex_destroy(&led->mutex); + return devm_led_classdev_register_ext(dev, &led->ldev, &init_data); } =20 static struct spi_driver spi_byte_driver =3D { .probe =3D spi_byte_probe, - .remove =3D spi_byte_remove, .driver =3D { .name =3D KBUILD_MODNAME, .of_match_table =3D spi_byte_dt_ids, }, }; - module_spi_driver(spi_byte_driver); =20 MODULE_AUTHOR("Christian Mauderer "); --=20 2.43.0.rc1.1336.g36b5255a03ac From nobody Thu Feb 12 21:45:24 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B234199234; Thu, 6 Jun 2024 17:30:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717695047; cv=none; b=hyOx3ruYQHOuzIxketbIoB07FRQQnB6RhBBP1D5NsZi6odtmVXyn2gmce8ndE0vSxnoShHsfFzvdP12ticATyJyhN7QEuMMInj9PyhH1kS3jgUkRKhbyiqdiIHdfLB4HKScz3gtwOhjygCwCzqJ6liASAL0876ohix3T6uB4Nek= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717695047; c=relaxed/simple; bh=SMIWLQZ2FupVBlM31XPw4RYjoVZTvalI7UR2L9gYyHQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P+rDFhU5u7HdKNfxI/rV/F/FXcPD7eFhiVQzde8NbVRPfHzlxnLO/Nggkmg56tenBj6vyyOfh2HAIaz90MwWivJvt3d3o54/cPP5pRlFQMkk/h6FC5FEM8ARY2mWQIWeSM0+I+0Q9Qc/Z/QLQ5OR5ZLEnih2Ein1i/hUcXS7BY4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Qk2Fi7js; arc=none smtp.client-ip=192.198.163.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Qk2Fi7js" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717695046; x=1749231046; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SMIWLQZ2FupVBlM31XPw4RYjoVZTvalI7UR2L9gYyHQ=; b=Qk2Fi7jsAL/9nPlhRxH4ZbcxNZoiKjs7URBIKHJ7hiTuibefieBKbU6i dK707S1swMLHSvzj4cQjv1g4ZSGyYUOReS5+tgrr63D20rAcTS/1f4f5g 6U4/i7IDaAM5/f6/adcFxkwsn87R/OW7KVsaZX6aYGv/G9YQEHncJPKlu INihz+hUefqWVYuD/DD2ccbWZfgE7ux5GrW3LF0cZHyKT22dXgmOWvhj2 cAQ7ocOWCfPnjTfoP5ZJxV6/RzDdpxcMkhsYn+K+iEDDesrFYnXaVY/RB 97VjOJH+X78OcKfjRFSOHI7cLO0YDQnJ6Y9zx/XzmxHGFtIBF9yU9ks1O g==; X-CSE-ConnectionGUID: aPm333LZSUCOxTpjKLUxbg== X-CSE-MsgGUID: /3m8v5tDT++6etYWIzV0RQ== X-IronPort-AV: E=McAfee;i="6600,9927,11095"; a="14192017" X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="14192017" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2024 10:30:44 -0700 X-CSE-ConnectionGUID: iCYEa+upQaOoKpBzwNf6cQ== X-CSE-MsgGUID: bdLa/RDYQ9+S4deA6N+Z7w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="38164438" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa009.fm.intel.com with ESMTP; 06 Jun 2024 10:30:43 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id ABC9E339; Thu, 06 Jun 2024 20:30:39 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Pavel Machek , Lee Jones Subject: [PATCH v1 6/6] leds: spi-byte: Move OF ID table closer to their user Date: Thu, 6 Jun 2024 20:29:23 +0300 Message-ID: <20240606173037.3091598-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240606173037.3091598-1-andriy.shevchenko@linux.intel.com> References: <20240606173037.3091598-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There is no code that uses ID table directly, except the struct device_driver at the end of the file. Hence, move table closer to its user. It's always possible to access them via a pointer. Signed-off-by: Andy Shevchenko --- drivers/leds/leds-spi-byte.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/leds/leds-spi-byte.c b/drivers/leds/leds-spi-byte.c index 985bbbed251b..d24d0ddf347c 100644 --- a/drivers/leds/leds-spi-byte.c +++ b/drivers/leds/leds-spi-byte.c @@ -56,13 +56,6 @@ static const struct spi_byte_chipdef ubnt_acb_spi_led_cd= ef =3D { .max_value =3D 0x3F, }; =20 -static const struct of_device_id spi_byte_dt_ids[] =3D { - { .compatible =3D "ubnt,acb-spi-led", .data =3D &ubnt_acb_spi_led_cdef }, - {}, -}; - -MODULE_DEVICE_TABLE(of, spi_byte_dt_ids); - static int spi_byte_brightness_set_blocking(struct led_classdev *dev, enum led_brightness brightness) { @@ -122,6 +115,12 @@ static int spi_byte_probe(struct spi_device *spi) return devm_led_classdev_register_ext(dev, &led->ldev, &init_data); } =20 +static const struct of_device_id spi_byte_dt_ids[] =3D { + { .compatible =3D "ubnt,acb-spi-led", .data =3D &ubnt_acb_spi_led_cdef }, + {} +}; +MODULE_DEVICE_TABLE(of, spi_byte_dt_ids); + static struct spi_driver spi_byte_driver =3D { .probe =3D spi_byte_probe, .driver =3D { --=20 2.43.0.rc1.1336.g36b5255a03ac