From patchwork Sun Jan 14 15:25:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 762882 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (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 848A32581; Sun, 14 Jan 2024 15:28:06 +0000 (UTC) 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="k5CtHXcP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705246086; x=1736782086; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2P1HUQEL9BH9iq7NRkO7iC2HHKfx0MlaeZdmt4UObTc=; b=k5CtHXcPKs5UZh4vG/xKnxY5aMXq/idlYz7640AsZXFkSPxy2NAGknkC GFI3aMs74hH64Ot9UYkTdeLBdco5Y4ziEap0AeKUMozioYCPqIPKRegQj DHTD0383RYzSwreClcFXoBDPjOVMDVoYkxWF962zy3743JTK0qcH31q4u 2Lccl5mfY30HLsnL93wW3KtG4Vr4tQE1zJQbJz2OXgO/il9zsmGB/O9Ai gKtbMOcy5aXCy1mntIkiTxT8j4bJe9uK+cHqOQzxJg65f0u8f13r4SvAW 1NzIRjAYY7aSNSeB6XLoe/Xv+RZiE3m8JTsmpXtRD+QILUaVxZTTU4/lu g==; X-IronPort-AV: E=McAfee;i="6600,9927,10953"; a="6829674" X-IronPort-AV: E=Sophos;i="6.04,194,1695711600"; d="scan'208";a="6829674" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jan 2024 07:28:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10953"; a="956601546" X-IronPort-AV: E=Sophos;i="6.04,194,1695711600"; d="scan'208";a="956601546" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga005.jf.intel.com with ESMTP; 14 Jan 2024 07:28:03 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 239071A3; Sun, 14 Jan 2024 17:28:02 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Lee Jones , Daniel Thompson , Jingoo Han , Helge Deller Subject: [PATCH v1 1/4] backlight: hx8357: Make use of device properties Date: Sun, 14 Jan 2024 17:25:08 +0200 Message-ID: <20240114152759.1040563-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240114152759.1040563-1-andriy.shevchenko@linux.intel.com> References: <20240114152759.1040563-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-fbdev@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. Include mod_devicetable.h explicitly to replace the dropped of.h which included mod_devicetable.h indirectly. Signed-off-by: Andy Shevchenko --- drivers/video/backlight/hx8357.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/video/backlight/hx8357.c b/drivers/video/backlight/hx8357.c index bf18337ff0c2..c7fd10d55c5d 100644 --- a/drivers/video/backlight/hx8357.c +++ b/drivers/video/backlight/hx8357.c @@ -8,9 +8,9 @@ #include #include #include +#include #include -#include -#include +#include #include #define HX8357_NUM_IM_PINS 3 @@ -564,6 +564,8 @@ static struct lcd_ops hx8357_ops = { .get_power = hx8357_get_power, }; +typedef int (*hx8357_init)(struct lcd_device *); + static const struct of_device_id hx8357_dt_ids[] = { { .compatible = "himax,hx8357", @@ -582,7 +584,7 @@ static int hx8357_probe(struct spi_device *spi) struct device *dev = &spi->dev; struct lcd_device *lcdev; struct hx8357_data *lcd; - const struct of_device_id *match; + hx8357_init init; int i, ret; lcd = devm_kzalloc(&spi->dev, sizeof(*lcd), GFP_KERNEL); @@ -597,8 +599,8 @@ static int hx8357_probe(struct spi_device *spi) lcd->spi = spi; - match = of_match_device(hx8357_dt_ids, &spi->dev); - if (!match || !match->data) + init = device_get_match_data(dev); + if (!init) return -EINVAL; lcd->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); @@ -627,7 +629,7 @@ static int hx8357_probe(struct spi_device *spi) hx8357_lcd_reset(lcdev); - ret = ((int (*)(struct lcd_device *))match->data)(lcdev); + ret = init(lcdev); if (ret) { dev_err(&spi->dev, "Couldn't initialize panel\n"); return ret; From patchwork Sun Jan 14 15:25:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 762881 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 058625231; Sun, 14 Jan 2024 15:28:07 +0000 (UTC) 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="lv2cvrH3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705246088; x=1736782088; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gErb4SvLDcsU5HgGSgzQl+lRFtQWIMD24E+MzwAOiTg=; b=lv2cvrH3ZI/CZfvOKUvkZ1pRjK8AEWogUEIolZdWqIcY8h59JIRIrQeK Fl6sgPUpkWCmdftzgMeOgGACqFeogl//Iez6V1ueBoGoUoEnyvGH49XUA fkUSs8RcsVnbTrVoH3enng7yTqVgsCluuI5rxVojCEPM/YQ0U8y1OMbW1 t0dfRvnCAtFY7PHp7Uh9xF59EOGH2rZ+jTJvEcmLt4vg88cKl8VDz9wHv GTC5N9GkLFAQNHscDpttncI/yvwCunGwOUZA5CRCdf4b0q1yMOkzL+Z9H IOxH/d4qyWuY7QrRn/LNKCX8aPWBUSVOTMf1SeM6VKS0YkINsMnDUz1u7 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10953"; a="12835872" X-IronPort-AV: E=Sophos;i="6.04,194,1695711600"; d="scan'208";a="12835872" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jan 2024 07:28:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10953"; a="1030429356" X-IronPort-AV: E=Sophos;i="6.04,194,1695711600"; d="scan'208";a="1030429356" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 14 Jan 2024 07:28:03 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 3825C3AE; Sun, 14 Jan 2024 17:28:02 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Lee Jones , Daniel Thompson , Jingoo Han , Helge Deller Subject: [PATCH v1 2/4] backlight: hx8357: Move OF table closer to its consumer Date: Sun, 14 Jan 2024 17:25:09 +0200 Message-ID: <20240114152759.1040563-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240114152759.1040563-1-andriy.shevchenko@linux.intel.com> References: <20240114152759.1040563-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Move OF table near to the user. While at it, drop comma at terminator entry. Signed-off-by: Andy Shevchenko Reviewed-by: Javier Martinez Canillas --- drivers/video/backlight/hx8357.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/video/backlight/hx8357.c b/drivers/video/backlight/hx8357.c index c7fd10d55c5d..8709d9141cfb 100644 --- a/drivers/video/backlight/hx8357.c +++ b/drivers/video/backlight/hx8357.c @@ -566,19 +566,6 @@ static struct lcd_ops hx8357_ops = { typedef int (*hx8357_init)(struct lcd_device *); -static const struct of_device_id hx8357_dt_ids[] = { - { - .compatible = "himax,hx8357", - .data = hx8357_lcd_init, - }, - { - .compatible = "himax,hx8369", - .data = hx8369_lcd_init, - }, - {}, -}; -MODULE_DEVICE_TABLE(of, hx8357_dt_ids); - static int hx8357_probe(struct spi_device *spi) { struct device *dev = &spi->dev; @@ -640,6 +627,19 @@ static int hx8357_probe(struct spi_device *spi) return 0; } +static const struct of_device_id hx8357_dt_ids[] = { + { + .compatible = "himax,hx8357", + .data = hx8357_lcd_init, + }, + { + .compatible = "himax,hx8369", + .data = hx8369_lcd_init, + }, + {} +}; +MODULE_DEVICE_TABLE(of, hx8357_dt_ids); + static struct spi_driver hx8357_driver = { .probe = hx8357_probe, .driver = { From patchwork Sun Jan 14 15:25:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 762744 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 B78433D65; Sun, 14 Jan 2024 15:28:07 +0000 (UTC) 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="gixEha1f" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705246087; x=1736782087; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KtcwDtLKAtATSufVVVCnn6c5MCnYP7WhV++Dk6UXa9k=; b=gixEha1f9cr4TByba64mmJewzG5z+e+4cYiXZhbaW+QIoSFmjduCgzob qnftY0v7QYFfqJwyt1knS+mjJ6+C1Un7awmgieKkiYWbtOLKGoaSWOauU 2x3vmo6yakdqwJOZtmjPT4pFPF8fybCmFu/jskDghqXYf09LEcj/I/PH9 pRBqfXgxNLalqG++LNiKDC98T/vdt+ZxFervB/JM4hVibLGfU1NY551hx amMGKaVxLpK6igaa6CZkY2IgOZutjcCYYF4/uwxhJ7Hb3fAvFVWx+ioPv IqeVmW8VRgYlSVhuwRk7TESF3HuEoZ5sr0Ud7gZYmgLYFwMxmjjD67aFt w==; X-IronPort-AV: E=McAfee;i="6600,9927,10953"; a="12835866" X-IronPort-AV: E=Sophos;i="6.04,194,1695711600"; d="scan'208";a="12835866" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jan 2024 07:28:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10953"; a="1030429355" X-IronPort-AV: E=Sophos;i="6.04,194,1695711600"; d="scan'208";a="1030429355" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 14 Jan 2024 07:28:03 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 47AC83EA; Sun, 14 Jan 2024 17:28:02 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Lee Jones , Daniel Thompson , Jingoo Han , Helge Deller Subject: [PATCH v1 3/4] backlight: hx8357: Make use of dev_err_probe() Date: Sun, 14 Jan 2024 17:25:10 +0200 Message-ID: <20240114152759.1040563-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240114152759.1040563-1-andriy.shevchenko@linux.intel.com> References: <20240114152759.1040563-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-fbdev@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 Reviewed-by: Javier Martinez Canillas --- drivers/video/backlight/hx8357.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/video/backlight/hx8357.c b/drivers/video/backlight/hx8357.c index 8709d9141cfb..fbe02fd73272 100644 --- a/drivers/video/backlight/hx8357.c +++ b/drivers/video/backlight/hx8357.c @@ -579,10 +579,8 @@ static int hx8357_probe(struct spi_device *spi) return -ENOMEM; ret = spi_setup(spi); - if (ret < 0) { - dev_err(&spi->dev, "SPI setup failed.\n"); - return ret; - } + if (ret < 0) + return dev_err_probe(dev, ret, "SPI setup failed.\n"); lcd->spi = spi; @@ -617,10 +615,8 @@ static int hx8357_probe(struct spi_device *spi) hx8357_lcd_reset(lcdev); ret = init(lcdev); - if (ret) { - dev_err(&spi->dev, "Couldn't initialize panel\n"); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "Couldn't initialize panel\n"); dev_info(&spi->dev, "Panel probed\n"); From patchwork Sun Jan 14 15:25:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 762743 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (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 39E94524B; Sun, 14 Jan 2024 15:28:08 +0000 (UTC) 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="P6vUiQ/z" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705246088; x=1736782088; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HHwu/+ttKG6+gQ16tPnQoTnLOBcKuPt3xGBj8B08rW8=; b=P6vUiQ/z8+ClUM7MsCyEGN1OUnmuQNa+KxhMopg0SkJM7RyQ1FN1GqF3 Ex1g8eIOQ9PaRBJcqw1TcR+o+ZsZwyxbwVsqoPSIasDp/waa+jcW+hplO d7sYUA+ThVp8OJjgm4p13DLOqskf2zNKPLb2O8Cv1g9tIcuM0TZWru2xe HeV1jOnkYfdogEmVIIAyUR8GU6wjumRzPs/ioJT2RytNlhyxEg+jC/gLY S37Sa0beihIys/vdVatI5QWqxFp6C/sYqRX2yvA7M+QVYp46WW0QvGVV5 4NVvBnJwR4x7ppM9i1W0JACCBHYzZk/8p6F4NPfkHw74IlfKSlpmiQnYW w==; X-IronPort-AV: E=McAfee;i="6600,9927,10953"; a="6829681" X-IronPort-AV: E=Sophos;i="6.04,194,1695711600"; d="scan'208";a="6829681" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jan 2024 07:28:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10953"; a="956601547" X-IronPort-AV: E=Sophos;i="6.04,194,1695711600"; d="scan'208";a="956601547" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga005.jf.intel.com with ESMTP; 14 Jan 2024 07:28:03 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 4D3D039B; Sun, 14 Jan 2024 17:28:02 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Lee Jones , Daniel Thompson , Jingoo Han , Helge Deller Subject: [PATCH v1 4/4] backlight: hx8357: Utilise temporary variable for struct device Date: Sun, 14 Jan 2024 17:25:11 +0200 Message-ID: <20240114152759.1040563-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240114152759.1040563-1-andriy.shevchenko@linux.intel.com> References: <20240114152759.1040563-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We have a temporary variable to keep pointer to struct device. Utilise it inside the ->probe() implementation. Signed-off-by: Andy Shevchenko Reviewed-by: Javier Martinez Canillas --- drivers/video/backlight/hx8357.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/video/backlight/hx8357.c b/drivers/video/backlight/hx8357.c index fbe02fd73272..e4dc76f25f8e 100644 --- a/drivers/video/backlight/hx8357.c +++ b/drivers/video/backlight/hx8357.c @@ -574,7 +574,7 @@ static int hx8357_probe(struct spi_device *spi) hx8357_init init; int i, ret; - lcd = devm_kzalloc(&spi->dev, sizeof(*lcd), GFP_KERNEL); + lcd = devm_kzalloc(dev, sizeof(*lcd), GFP_KERNEL); if (!lcd) return -ENOMEM; @@ -604,8 +604,7 @@ static int hx8357_probe(struct spi_device *spi) gpiod_set_consumer_name(lcd->im_pins->desc[i], "im_pins"); } - lcdev = devm_lcd_device_register(&spi->dev, "mxsfb", &spi->dev, lcd, - &hx8357_ops); + lcdev = devm_lcd_device_register(dev, "mxsfb", dev, lcd, &hx8357_ops); if (IS_ERR(lcdev)) { ret = PTR_ERR(lcdev); return ret; @@ -618,7 +617,7 @@ static int hx8357_probe(struct spi_device *spi) if (ret) return dev_err_probe(dev, ret, "Couldn't initialize panel\n"); - dev_info(&spi->dev, "Panel probed\n"); + dev_info(dev, "Panel probed\n"); return 0; }