From patchwork Thu Jun 6 17:29:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 802200 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-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 struct spi_byte_chipdef { @@ -97,8 +97,11 @@ static int spi_byte_probe(struct spi_device *spi) if (!led) return -ENOMEM; + ret = devm_mutex_init(dev, &led->mutex); + if (ret) + return ret; + led->spi = spi; - mutex_init(&led->mutex); led->cdef = device_get_match_data(dev); led->ldev.brightness = LED_OFF; led->ldev.max_brightness = led->cdef->max_value - led->cdef->off_value; @@ -116,33 +119,16 @@ static int spi_byte_probe(struct spi_device *spi) init_data.devicename = "leds-spi-byte"; init_data.default_label = ":"; - ret = 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 = spi_get_drvdata(spi); - - mutex_destroy(&led->mutex); + return devm_led_classdev_register_ext(dev, &led->ldev, &init_data); } static struct spi_driver spi_byte_driver = { .probe = spi_byte_probe, - .remove = spi_byte_remove, .driver = { .name = KBUILD_MODNAME, .of_match_table = spi_byte_dt_ids, }, }; - module_spi_driver(spi_byte_driver); MODULE_AUTHOR("Christian Mauderer "); From patchwork Thu Jun 6 17:29:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 802199 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-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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_cdef = { .max_value = 0x3F, }; -static const struct of_device_id spi_byte_dt_ids[] = { - { .compatible = "ubnt,acb-spi-led", .data = &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); } +static const struct of_device_id spi_byte_dt_ids[] = { + { .compatible = "ubnt,acb-spi-led", .data = &ubnt_acb_spi_led_cdef }, + {} +}; +MODULE_DEVICE_TABLE(of, spi_byte_dt_ids); + static struct spi_driver spi_byte_driver = { .probe = spi_byte_probe, .driver = {