From patchwork Thu Dec 14 18:40:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 755078 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="HDOuX50S" Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 134CC10E; Thu, 14 Dec 2023 10:40:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702579259; x=1734115259; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=G18B/IrnfrebrjvuaMIQ0eCCWtBtYWxi9zew/6c/ODs=; b=HDOuX50Skft9RqXi5wDVrpxjOrP5dcz7dBbaATjyPOQrx5TYBGsc+SU6 s+nGb+zXW5yU0cq6O/RutLpa45MDzVGhJ+ni5Ap3H1y1LURHgER4/tjtJ uL4Pi/o1dUdAkk8v17Rub4keqJ5fUBcWwXnsGJpyKBD7sOi6Szmy0GTF9 Q+jv2M8+C+++ua34jNpBaP0cfSiQryPs/8ogeZV5LDgyYwrasAHuNUiyh 6xzSoD17Ag85JBj1V9wC464RXTk8nQK8sDQGfhzJI91P/MpneUNte/u9V Hc98qwTzm+tyZW+9IIf45aOtM+3uf5X9eH4Zm0pf4rxQu999fpQ73MScL g==; X-IronPort-AV: E=McAfee;i="6600,9927,10924"; a="385582264" X-IronPort-AV: E=Sophos;i="6.04,276,1695711600"; d="scan'208";a="385582264" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Dec 2023 10:40:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10924"; a="840374564" X-IronPort-AV: E=Sophos;i="6.04,276,1695711600"; d="scan'208";a="840374564" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 14 Dec 2023 10:40:56 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 1BF5B13A; Thu, 14 Dec 2023 20:40:53 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Patrick Rudolph , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Pavel Machek , Lee Jones Subject: [PATCH v1 1/4] leds: max5970: Remove unused variable Date: Thu, 14 Dec 2023 20:40:08 +0200 Message-ID: <20231214184050.1272848-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20231214184050.1272848-1-andriy.shevchenko@linux.intel.com> References: <20231214184050.1272848-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 leds-max5970.c:50:21: warning: variable 'num_leds' set but not used [-Wunused-but-set-variable] Remove unused variable. Fixes: 736214b4b02a ("leds: max5970: Add support for max5970") Signed-off-by: Andy Shevchenko --- drivers/leds/leds-max5970.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/leds/leds-max5970.c b/drivers/leds/leds-max5970.c index 456a16a47450..7959d079ae94 100644 --- a/drivers/leds/leds-max5970.c +++ b/drivers/leds/leds-max5970.c @@ -45,7 +45,7 @@ static int max5970_led_probe(struct platform_device *pdev) struct regmap *regmap; struct device_node *led_node, *child; struct max5970_led *ddata; - int ret = -ENODEV, num_leds = 0; + int ret = -ENODEV; regmap = dev_get_regmap(pdev->dev.parent, NULL); if (!regmap) @@ -89,7 +89,6 @@ static int max5970_led_probe(struct platform_device *pdev) dev_err(dev, "Failed to initialize LED %u\n", reg); return ret; } - num_leds++; } return ret; From patchwork Thu Dec 14 18:40:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 755077 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="H7MHMM6/" Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1ED46111; Thu, 14 Dec 2023 10:41:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702579260; x=1734115260; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tzobM1VNBQfa71tbk5guQU+1z1I5o1Ve5XDjWlrKIeY=; b=H7MHMM6/7Qck/xw8bbwtm4m2q0mfAbrb+FobfXH3FajSTLlx1B+tZI9e foRfZqGuQDQwcOC8Y0uY/N4PrHYAVHmlL8YbbvfMjWw5Ebkqw8eBHrMxU oCTOmJ6wdUYlIyLMyOa4VMY6TAIuQGsqJU2jyJFfbhgeb2n/laJZ++F5r hRqFs1LwTeEBFKpijS6MJQrXWWM7X3LGSi496PPNEkvURY4kUJZWzSXjn 8ox0lDF8zAXYdrV0YFZseb7ndmSfOsoQVRBw3hAsqxXXDLa2p2ggjU8X7 dwjiuMD4TX8UZe2aFIv42xa+ErUAkx5IpNQnS75+JF47Y8Vzh9/E/lmYZ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10924"; a="385582275" X-IronPort-AV: E=Sophos;i="6.04,276,1695711600"; d="scan'208";a="385582275" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Dec 2023 10:40:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10924"; a="840374565" X-IronPort-AV: E=Sophos;i="6.04,276,1695711600"; d="scan'208";a="840374565" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 14 Dec 2023 10:40:56 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 2BCD23AE; Thu, 14 Dec 2023 20:40:53 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Patrick Rudolph , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Pavel Machek , Lee Jones Subject: [PATCH v1 2/4] leds: max5970: Make use of device properties Date: Thu, 14 Dec 2023 20:40:09 +0200 Message-ID: <20231214184050.1272848-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20231214184050.1272848-1-andriy.shevchenko@linux.intel.com> References: <20231214184050.1272848-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 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/leds-max5970.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/leds/leds-max5970.c b/drivers/leds/leds-max5970.c index 7959d079ae94..de57b385b4f6 100644 --- a/drivers/leds/leds-max5970.c +++ b/drivers/leds/leds-max5970.c @@ -9,8 +9,9 @@ #include #include -#include +#include #include +#include #include #define ldev_to_maxled(c) container_of(c, struct max5970_led, cdev) @@ -40,25 +41,24 @@ static int max5970_led_set_brightness(struct led_classdev *cdev, static int max5970_led_probe(struct platform_device *pdev) { + struct fwnode_handle *led_node, *child; struct device *dev = &pdev->dev; - struct device_node *np = dev_of_node(dev->parent); struct regmap *regmap; - struct device_node *led_node, *child; struct max5970_led *ddata; int ret = -ENODEV; - regmap = dev_get_regmap(pdev->dev.parent, NULL); + regmap = dev_get_regmap(dev->parent, NULL); if (!regmap) return -ENODEV; - led_node = of_get_child_by_name(np, "leds"); + led_node = device_get_named_child_node(dev->parent, "leds"); if (!led_node) return -ENODEV; - for_each_available_child_of_node(led_node, child) { + fwnode_for_each_available_child_node(led_node, child) { u32 reg; - if (of_property_read_u32(child, "reg", ®)) + if (fwnode_property_read_u32(child, "reg", ®)) continue; if (reg >= MAX5970_NUM_LEDS) { @@ -68,7 +68,7 @@ static int max5970_led_probe(struct platform_device *pdev) ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL); if (!ddata) { - of_node_put(child); + fwnode_handle_put(child); return -ENOMEM; } @@ -76,8 +76,8 @@ static int max5970_led_probe(struct platform_device *pdev) ddata->regmap = regmap; ddata->dev = dev; - if (of_property_read_string(child, "label", &ddata->cdev.name)) - ddata->cdev.name = child->name; + if (fwnode_property_read_string(child, "label", &ddata->cdev.name)) + ddata->cdev.name = fwnode_get_name(child); ddata->cdev.max_brightness = 1; ddata->cdev.brightness_set_blocking = max5970_led_set_brightness; @@ -85,7 +85,7 @@ static int max5970_led_probe(struct platform_device *pdev) ret = devm_led_classdev_register(dev, &ddata->cdev); if (ret < 0) { - of_node_put(child); + fwnode_handle_put(child); dev_err(dev, "Failed to initialize LED %u\n", reg); return ret; } @@ -100,8 +100,8 @@ static struct platform_driver max5970_led_driver = { }, .probe = max5970_led_probe, }; - module_platform_driver(max5970_led_driver); + MODULE_AUTHOR("Patrick Rudolph "); MODULE_AUTHOR("Naresh Solanki "); MODULE_DESCRIPTION("MAX5970_hot-swap controller LED driver"); From patchwork Thu Dec 14 18:40:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 754165 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="PnhH0gOR" Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE20D10F; Thu, 14 Dec 2023 10:41:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702579281; x=1734115281; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=spWRbrUoo3GHPvJawqTt5vlWN5LSpxWaXUCc4b6zvNY=; b=PnhH0gORm5FI1q/3PBOYd32mecI8eniLr8pY4AcSk/VWDVwYcZQAUY7e p6P/2ufKNHXggs5cnM3BR2Hyk0fpuXGmi0dAj7vKYN5F1xXKlPHzY5Uis mzFW96f1Fh8Imh1ilLtVFpLUCQUh7J97HLu9Gb6Z5GM2A787/YcC4ydRU F5W8G0Egq2QQ1W46bsVD/4czyB8UPcfMVvFUezuYUa/1lfTGqnaJtEAjI GpJC6FDtubAPr8c7WI2gz9/CZK6TVuRc+jd/UJPOfHqjvNBWtCywq9Ynm LuVi6GGVJCjNNH+b1WFlw0sm+aKo3ukErR5TRmcAWBphp+7hrBUhlWdtf g==; X-IronPort-AV: E=McAfee;i="6600,9927,10924"; a="461631068" X-IronPort-AV: E=Sophos;i="6.04,276,1695711600"; d="scan'208";a="461631068" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Dec 2023 10:40:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10924"; a="803395262" X-IronPort-AV: E=Sophos;i="6.04,276,1695711600"; d="scan'208";a="803395262" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 14 Dec 2023 10:40:54 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 3196E44F; Thu, 14 Dec 2023 20:40:53 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Patrick Rudolph , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Pavel Machek , Lee Jones Subject: [PATCH v1 3/4] leds: max5970: Make use of dev_err_probe() Date: Thu, 14 Dec 2023 20:40:10 +0200 Message-ID: <20231214184050.1272848-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20231214184050.1272848-1-andriy.shevchenko@linux.intel.com> References: <20231214184050.1272848-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 Simplify the error handling in probe function by switching from dev_err() to dev_err_probe(). Signed-off-by: Andy Shevchenko --- drivers/leds/leds-max5970.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/leds/leds-max5970.c b/drivers/leds/leds-max5970.c index de57b385b4f6..60db3c28d7d9 100644 --- a/drivers/leds/leds-max5970.c +++ b/drivers/leds/leds-max5970.c @@ -62,7 +62,7 @@ static int max5970_led_probe(struct platform_device *pdev) continue; if (reg >= MAX5970_NUM_LEDS) { - dev_err(dev, "invalid LED (%u >= %d)\n", reg, MAX5970_NUM_LEDS); + dev_err_probe(dev, -EINVAL, "invalid LED (%u >= %d)\n", reg, MAX5970_NUM_LEDS); continue; } @@ -86,8 +86,7 @@ static int max5970_led_probe(struct platform_device *pdev) ret = devm_led_classdev_register(dev, &ddata->cdev); if (ret < 0) { fwnode_handle_put(child); - dev_err(dev, "Failed to initialize LED %u\n", reg); - return ret; + return dev_err_probe(dev, ret, "Failed to initialize LED %u\n", reg); } } From patchwork Thu Dec 14 18:40:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 755076 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="c8VMBTW6" Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FA9912B; Thu, 14 Dec 2023 10:41:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702579282; x=1734115282; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ejqGTJqRJV94y5/KtwKcYw2iSBE0q2SaQ5pb83PDPgA=; b=c8VMBTW6kAcPZcH66f2rP+cogRfWLGxZtPDNkDM1TFpKWwLfNVNiduF5 xIhH3XR8VIPjA5qwJlUfrmoLllHLtQE1/JItWfmj4bpue8K+UMFdQZPwk IRVAowZjK1oE4O7LMI3/8LTPRE8j+sCIbBGER9ZyUevF5YAp7P9bxsYM2 hlcmGd9n2C8YI7QnqQoboD621GsUq9xJnhk25z73SQiLmaWI8NHX7MId0 6gn/sa3mmNN0rYYoN0MsjbgsDPEkKPr4ejyI/kyKIixr/+57I7oxK6xeO Rib2NrnNe6FYzakhFSxFWoq5o3OjHj5/b3rGwz3NMr55pbqNYNQHxKTAz Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10924"; a="461631064" X-IronPort-AV: E=Sophos;i="6.04,276,1695711600"; d="scan'208";a="461631064" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Dec 2023 10:40:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10924"; a="803395261" X-IronPort-AV: E=Sophos;i="6.04,276,1695711600"; d="scan'208";a="803395261" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 14 Dec 2023 10:40:54 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 4511D46D; Thu, 14 Dec 2023 20:40:53 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Patrick Rudolph , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Pavel Machek , Lee Jones Subject: [PATCH v1 4/4] leds: max5970: Add missing headers Date: Thu, 14 Dec 2023 20:40:11 +0200 Message-ID: <20231214184050.1272848-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20231214184050.1272848-1-andriy.shevchenko@linux.intel.com> References: <20231214184050.1272848-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 Don't inherit headers "by chance" from others. Include the needed ones explicitly. Signed-off-by: Andy Shevchenko --- drivers/leds/leds-max5970.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/leds/leds-max5970.c b/drivers/leds/leds-max5970.c index 60db3c28d7d9..56a584311581 100644 --- a/drivers/leds/leds-max5970.c +++ b/drivers/leds/leds-max5970.c @@ -7,9 +7,13 @@ * Author: Patrick Rudolph */ +#include +#include +#include #include #include #include +#include #include #include #include