From patchwork Fri Feb 7 15:17:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13965254 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 52B691EB1BD; Fri, 7 Feb 2025 15:18:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738941515; cv=none; b=nWa9zJdKWhE3iQ6PrALllq9it8WuDgYoIoqfsrtypEgAktu48RtZOuLp4TtTX+DQdQ6FgQBA9xbz79OayRUf77Mmyw1CfqAH11cS5pLsBZQNrl6tZXGhTUhObis+x/Po3bZiFUl/RoeY+HYtf/VBwx80RAFAn6/1KkIpJXUeQW8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738941515; c=relaxed/simple; bh=xb+nwPJyddffTQeZ/9ZVscSmAF5CIVQ8h4wBVD/QKwc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Wm5KD53xs+0VDe12IIHMFTdqKn7KwPHMu/bTOPQDDmAxjw2QwMmr/77pPkzl2qIAGgeNCZVwFnRR/R9VNsXJZgWtohB4ZV48DV+wYY+TnA8+oOp7OUvTOG/YqmSeIv6O1G8rQ+1/BEbf7I7rMiGI/viWFTi34nX2KtriPCJZDxo= 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=VjDaN8s8; arc=none smtp.client-ip=192.198.163.18 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="VjDaN8s8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1738941514; x=1770477514; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xb+nwPJyddffTQeZ/9ZVscSmAF5CIVQ8h4wBVD/QKwc=; b=VjDaN8s8Y3GwBTJXBGmnYQZeCMZSqWw7F5Yt7sGnpp4snukWiEYc9/7H d0wfMEnv4XhEYrdf3/XnllXhpoZW2YtWWeFP0/SVMwSt6w0OhOCjfCA9U UIfOlRos+U5ma9j8un5Qo2awY0gPzg36S9UXnUaoBpxAasH45AzAgsA+D biowu7+HcJbKGtBZGlvKs3E2nH3o92hKcoF31ReA5kW+z7mPfiL3tbA2t RZbQqhXFXvFSV6BgiHQlR94XUWpZO7r2oCWvts1hO3wKCfH+KH/zpUYyy XdVbr4T9+gngUwZJXRU3zlPXTSWewaEl/rJ6obPRSXhtOMBuzevJHJfhz A==; X-CSE-ConnectionGUID: QGVFuh3fSAW6GMkVVYZaCQ== X-CSE-MsgGUID: ustW/JEzTIijFAJxTvCdWQ== X-IronPort-AV: E=McAfee;i="6700,10204,11338"; a="38815621" X-IronPort-AV: E=Sophos;i="6.13,267,1732608000"; d="scan'208";a="38815621" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Feb 2025 07:18:30 -0800 X-CSE-ConnectionGUID: 2fgJ7cGTShqf+NuiSHDfSQ== X-CSE-MsgGUID: FlJM2Y+KRXWjac2kmCi3Qw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,267,1732608000"; d="scan'208";a="116599313" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa004.fm.intel.com with ESMTP; 07 Feb 2025 07:18:28 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7FF15116; Fri, 07 Feb 2025 17:18:26 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Cc: Linus Walleij , Bartosz Golaszewski , Kees Cook , "Gustavo A. R. Silva" , Geert Uytterhoeven Subject: [PATCH v2 1/7] gpio: 74x164: Remove unneeded dependency to OF_GPIO Date: Fri, 7 Feb 2025 17:17:08 +0200 Message-ID: <20250207151825.2122419-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20250207151825.2122419-1-andriy.shevchenko@linux.intel.com> References: <20250207151825.2122419-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Remove unneeded dependency to OF_GPIO which driver does not use. Fixes: 3c7469514dbe ("gpio: 74x164: Make use of device properties") Reviewed-by: Geert Uytterhoeven Signed-off-by: Andy Shevchenko --- drivers/gpio/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 24c7dabe153b..4dbf2198a858 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -1766,7 +1766,6 @@ menu "SPI GPIO expanders" config GPIO_74X164 tristate "74x164 serial-in/parallel-out 8-bits shift register" - depends on OF_GPIO help Driver for 74x164 compatible serial-in/parallel-out 8-outputs shift registers. This driver can be used to provide access From patchwork Fri Feb 7 15:17:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13965250 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 45F541E5B67; Fri, 7 Feb 2025 15:18:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738941513; cv=none; b=d3Cbp1PeIdyNzdhaAFp32poy0cAvU4dWavHYHBzdHuv3Jl3D0hF7oe6ksjkgEZIkQOZbkxk3rtwmMz9Lwtc4k3flstP0cxTy8SRJwtWbV4XeMktDIWlLr3tJbI7Rwv9E1Qc0YqLHUnMmlB/1dr1FOUxwIUMfj4+lu6Eqpov+fMU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738941513; c=relaxed/simple; bh=OPZPEzubgWFgSDqq2IdR1CiH9zps4lf42a2bMs4pJx8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RPpgnzq+AihzZG/ZJwmXA0lO8yLfRjisSKVFDTvVZwDRpdxaSPvekLZC9SmqK8PX0ByTAD2u2vIZ0hi0bgsXunCThd5eP0QxLW4x7d1bl3x8i+M69oJQCgLj5OSfpPiK/gWhjRHWsSbLQOuyEFMXBtkQ6ZDZ1bAcFdCpnUa224A= 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=XyJr4Q1q; arc=none smtp.client-ip=192.198.163.18 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="XyJr4Q1q" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1738941512; x=1770477512; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OPZPEzubgWFgSDqq2IdR1CiH9zps4lf42a2bMs4pJx8=; b=XyJr4Q1qGNQgzYxrLjPpkP+v+x+OhAmCuBRbHVTC9N95bz/bY2RPlj8o kAWzNkBS/pF+uvVpuYgV0zMV55wxfOc5OpKzMuZuVrw+xVBm3yhnD3UfL BacIyGsmqoIgy4pwnVogJqBcYP22dbkkeSo4pF686DM2zuXpR9c4JAed6 SW68W6zwdygPmFhjssUtyOF6CKRY2GTFGIF5YYogzvMzU0QxDzv8jmdla 5xd2GlgQzI9Xoov47gVCl/UI0T49ZlC7baxy/leTivXM4/54fS1KWbxV7 1GDDrQ544NdIo1upA6i8H9qUYjPZuT+gS90jYglIb2HmB91ghuoI9bmvU w==; X-CSE-ConnectionGUID: RbvRz2TsQz+b63QQXItVsQ== X-CSE-MsgGUID: QM73s09WSQeXRUPnF9NLXg== X-IronPort-AV: E=McAfee;i="6700,10204,11338"; a="38815617" X-IronPort-AV: E=Sophos;i="6.13,267,1732608000"; d="scan'208";a="38815617" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Feb 2025 07:18:30 -0800 X-CSE-ConnectionGUID: LXg0QpDkQCu4fQYsGjErMg== X-CSE-MsgGUID: mT39GpXhRIuUk/aNh/y7ZA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,267,1732608000"; d="scan'208";a="116599311" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa004.fm.intel.com with ESMTP; 07 Feb 2025 07:18:28 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 92FD538D; Fri, 07 Feb 2025 17:18:26 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Cc: Linus Walleij , Bartosz Golaszewski , Kees Cook , "Gustavo A. R. Silva" Subject: [PATCH v2 2/7] gpio: 74x164: Simplify code with cleanup helpers Date: Fri, 7 Feb 2025 17:17:09 +0200 Message-ID: <20250207151825.2122419-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20250207151825.2122419-1-andriy.shevchenko@linux.intel.com> References: <20250207151825.2122419-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use macros defined in linux/cleanup.h to automate resource lifetime control in the driver. Signed-off-by: Andy Shevchenko --- drivers/gpio/gpio-74x164.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c index fca6cd2eb1dd..70c662bbca7b 100644 --- a/drivers/gpio/gpio-74x164.c +++ b/drivers/gpio/gpio-74x164.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -43,13 +44,10 @@ static int gen_74x164_get_value(struct gpio_chip *gc, unsigned offset) struct gen_74x164_chip *chip = gpiochip_get_data(gc); u8 bank = chip->registers - 1 - offset / 8; u8 pin = offset % 8; - int ret; - mutex_lock(&chip->lock); - ret = (chip->buffer[bank] >> pin) & 0x1; - mutex_unlock(&chip->lock); + guard(mutex)(&chip->lock); - return ret; + return (chip->buffer[bank] >> pin) & 0x1; } static void gen_74x164_set_value(struct gpio_chip *gc, @@ -59,14 +57,14 @@ static void gen_74x164_set_value(struct gpio_chip *gc, u8 bank = chip->registers - 1 - offset / 8; u8 pin = offset % 8; - mutex_lock(&chip->lock); + guard(mutex)(&chip->lock); + if (val) chip->buffer[bank] |= (1 << pin); else chip->buffer[bank] &= ~(1 << pin); __gen_74x164_write_config(chip); - mutex_unlock(&chip->lock); } static void gen_74x164_set_multiple(struct gpio_chip *gc, unsigned long *mask, @@ -78,7 +76,8 @@ static void gen_74x164_set_multiple(struct gpio_chip *gc, unsigned long *mask, size_t bank; unsigned long bitmask; - mutex_lock(&chip->lock); + guard(mutex)(&chip->lock); + for_each_set_clump8(offset, bankmask, mask, chip->registers * 8) { bank = chip->registers - 1 - offset / 8; bitmask = bitmap_get_value8(bits, offset) & bankmask; @@ -87,7 +86,6 @@ static void gen_74x164_set_multiple(struct gpio_chip *gc, unsigned long *mask, chip->buffer[bank] |= bitmask; } __gen_74x164_write_config(chip); - mutex_unlock(&chip->lock); } static int gen_74x164_direction_output(struct gpio_chip *gc, From patchwork Fri Feb 7 15:17:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13965249 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 6BB78238D58; Fri, 7 Feb 2025 15:18:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738941512; cv=none; b=WJxKocXaMC1JEu+FFc6pmeYTmxmPNn/Ll3MvCkmw8i7FyNZCz4Ir2snDbOpEy0qEE6Cne4EQuiqbefrm6FmEq3k3XuNDpntPfMI0RabkFJ3KTe78VeiAiBLsw0TnARORMODNGByJSMQ626dYMwXVtCQO9xhn/Qow2v8x48iqVVI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738941512; c=relaxed/simple; bh=MprMiMuV+6PSWzh5qcNiBjouyTdWbepTzVpCMiEoexc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FksCTGLUDqzs5BJ8t6XrANgCPfWEQ5b/6C7tKJJxZOZRs+DL6T+wI7/X4dnelTcvzEp6D4Mkbr4BuP4P0NfeP2diKMv1Rb2CpCpi9P1Gy7NeLgccBTvXCl8pe6kvoRfKm1tVPouCAxUrFNjBy2346io5s33WzPX0JInhgKwC16A= 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=HPVUQb9i; arc=none smtp.client-ip=192.198.163.18 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="HPVUQb9i" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1738941511; x=1770477511; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MprMiMuV+6PSWzh5qcNiBjouyTdWbepTzVpCMiEoexc=; b=HPVUQb9iyebAe94yXz6yhRqyPqgk75KgnZx6BwcFsAhVJTpe7yA9W0Ep 8AFygC4SI1N6Kr1F9MFsqWkfE73CPt1YYZfJ/cEcQU0XWjwBsItIG9i1X SmUO6E6U9dYqL+H/RFB3+/vM5xY87X2CiMEmodHgvUFLyYdvyqsg0JCcK PyF+FrzCQGo2Z7pMgdOk1RPsqcZumVPAjiBTE8tsb2E7Nl5E/bCa+crSA ACi78WiYJLUBnMM6DCPuAnCI3wQhtVHmcoNA0CbEmd+TGH8rHqcDXXuYS x0pl33CRUBJPzG9vTMMLLlXldkdXKI+vVgDEOnku5xCuUa0NMlzDeC/ee A==; X-CSE-ConnectionGUID: Fh7RfJLuS96ejanzLUZU6A== X-CSE-MsgGUID: d7E1tk1oRwOGY0yaKfeUsQ== X-IronPort-AV: E=McAfee;i="6700,10204,11338"; a="38815609" X-IronPort-AV: E=Sophos;i="6.13,267,1732608000"; d="scan'208";a="38815609" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Feb 2025 07:18:30 -0800 X-CSE-ConnectionGUID: nkcY8q7tR4alKYqFWIgdIQ== X-CSE-MsgGUID: SofFb9WSQj6+qh13Aet7QA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,267,1732608000"; d="scan'208";a="116599312" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa004.fm.intel.com with ESMTP; 07 Feb 2025 07:18:28 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id A286F428; Fri, 07 Feb 2025 17:18:26 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Cc: Linus Walleij , Bartosz Golaszewski , Kees Cook , "Gustavo A. R. Silva" Subject: [PATCH v2 3/7] gpio: 74x164: Annotate buffer with __counted_by() Date: Fri, 7 Feb 2025 17:17:10 +0200 Message-ID: <20250207151825.2122419-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20250207151825.2122419-1-andriy.shevchenko@linux.intel.com> References: <20250207151825.2122419-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add the __counted_by() compiler attribute to the flexible array member volumes to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and CONFIG_FORTIFY_SOURCE. Use struct_size() instead of manually calculating the number of bytes to allocate the private structure with a buffer. Reviewed-by: Gustavo A. R. Silva Signed-off-by: Andy Shevchenko --- drivers/gpio/gpio-74x164.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c index 70c662bbca7b..7844f8a58834 100644 --- a/drivers/gpio/gpio-74x164.c +++ b/drivers/gpio/gpio-74x164.c @@ -30,7 +30,7 @@ struct gen_74x164_chip { * register at the end of the transfer. So, to have a logical * numbering, store the bytes in reverse order. */ - u8 buffer[]; + u8 buffer[] __counted_by(registers); }; static int __gen_74x164_write_config(struct gen_74x164_chip *chip) @@ -97,6 +97,7 @@ static int gen_74x164_direction_output(struct gpio_chip *gc, static int gen_74x164_probe(struct spi_device *spi) { + struct device *dev = &spi->dev; struct gen_74x164_chip *chip; u32 nregs; int ret; @@ -116,10 +117,12 @@ static int gen_74x164_probe(struct spi_device *spi) return -EINVAL; } - chip = devm_kzalloc(&spi->dev, sizeof(*chip) + nregs, GFP_KERNEL); + chip = devm_kzalloc(dev, struct_size(chip, buffer, nregs), GFP_KERNEL); if (!chip) return -ENOMEM; + chip->registers = nregs; + chip->gpiod_oe = devm_gpiod_get_optional(&spi->dev, "enable", GPIOD_OUT_LOW); if (IS_ERR(chip->gpiod_oe)) @@ -133,10 +136,7 @@ static int gen_74x164_probe(struct spi_device *spi) chip->gpio_chip.set = gen_74x164_set_value; chip->gpio_chip.set_multiple = gen_74x164_set_multiple; chip->gpio_chip.base = -1; - - chip->registers = nregs; chip->gpio_chip.ngpio = GEN_74X164_NUMBER_GPIOS * chip->registers; - chip->gpio_chip.can_sleep = true; chip->gpio_chip.parent = &spi->dev; chip->gpio_chip.owner = THIS_MODULE; From patchwork Fri Feb 7 15:17:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13965251 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 C4E0E1EB19C; Fri, 7 Feb 2025 15:18:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738941514; cv=none; b=BFA2DfQfFQDRiMRMvRrDLFr5wduqpTWIXu/hlC+VktbKTEol/ucW6sVVM7N4iqdQ8XrT+ZW/kTagIlmIMI5sOk8ZkqU78nQ0tcuwzfFG+OuST8LLhWqZ+3HAab0uiIByiyNJb6Kryc7/s2cTtOJG8mukLH96xmzocTej5AhC9ic= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738941514; c=relaxed/simple; bh=ENGCXMU4WTWaSHW6BE0m953OZ1GFz2d8DBXIDnt7ISw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NNTeQjJ3kZkikLTdi/84oGsaB4JWVRhlrIl5IsL2Q1HkYqD3MBnEv+32Uu4x1+nAB32NsdzaPhbvk3B6OcjPQl8TVEh4CpTNwUiWlPVUXSeuvIj4TiIZsLzSYtupVvfPatwagrqhlnCfEE9JVl5Z6ckjpv4rAyn5JynE2wCqSSw= 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=kqMjOydc; arc=none smtp.client-ip=192.198.163.18 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="kqMjOydc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1738941513; x=1770477513; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ENGCXMU4WTWaSHW6BE0m953OZ1GFz2d8DBXIDnt7ISw=; b=kqMjOydcMjMQlCfi6pmPhU9yorYx8ZdHS5p5NFyiLpW5c+Q9QleNFMMS jYcln41GWEDXGq651UMJxzZUL//Q/rWVY3TflT06UkYGVDWn2QSzFsOii 9HdkeXrAULW1U6eHrNtJaN0wsFQgAFB8cF5mao50s4GBXJ3/Jx8vmiNiu +HIne9WuRwfTBPwcwERYEGpbmnl3h6pD1qIqlF4Fr4mjA5dRuvmw6NqeR 6RgQECA1yA3tMZ0m8LGTeWqA+fooAW2Q5VVJbqoWnYTEM4kPxGuDSNzhD qcfHeKUkffVONmgN9WXiL6eIKHEs2S5N9iZM+bwW/u/E88LsTinM9urao w==; X-CSE-ConnectionGUID: fYf7hs+MQ3S8GlzqJVgwaA== X-CSE-MsgGUID: j6CBdRIoQteIhTASPF5I7w== X-IronPort-AV: E=McAfee;i="6700,10204,11338"; a="38815615" X-IronPort-AV: E=Sophos;i="6.13,267,1732608000"; d="scan'208";a="38815615" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Feb 2025 07:18:30 -0800 X-CSE-ConnectionGUID: vlwryk4wSr65t8RLyzDhIw== X-CSE-MsgGUID: lGAcB5d9RHqi8L4OxamRHg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,267,1732608000"; d="scan'208";a="116599314" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa004.fm.intel.com with ESMTP; 07 Feb 2025 07:18:28 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id A85AD322; Fri, 07 Feb 2025 17:18:26 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Cc: Linus Walleij , Bartosz Golaszewski , Kees Cook , "Gustavo A. R. Silva" Subject: [PATCH v2 4/7] gpio: 74x164: Make use of the macros from bits.h Date: Fri, 7 Feb 2025 17:17:11 +0200 Message-ID: <20250207151825.2122419-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20250207151825.2122419-1-andriy.shevchenko@linux.intel.com> References: <20250207151825.2122419-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Make use of BIT() and GENMASK() where it makes sense. Signed-off-by: Andy Shevchenko --- drivers/gpio/gpio-74x164.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c index 7844f8a58834..0f720d539fa7 100644 --- a/drivers/gpio/gpio-74x164.c +++ b/drivers/gpio/gpio-74x164.c @@ -47,7 +47,7 @@ static int gen_74x164_get_value(struct gpio_chip *gc, unsigned offset) guard(mutex)(&chip->lock); - return (chip->buffer[bank] >> pin) & 0x1; + return !!(chip->buffer[bank] & BIT(pin)); } static void gen_74x164_set_value(struct gpio_chip *gc, @@ -60,9 +60,9 @@ static void gen_74x164_set_value(struct gpio_chip *gc, guard(mutex)(&chip->lock); if (val) - chip->buffer[bank] |= (1 << pin); + chip->buffer[bank] |= BIT(pin); else - chip->buffer[bank] &= ~(1 << pin); + chip->buffer[bank] &= ~BIT(pin); __gen_74x164_write_config(chip); } From patchwork Fri Feb 7 15:17:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13965255 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 63BC61F37C6; Fri, 7 Feb 2025 15:18:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738941516; cv=none; b=a/7Vk1/OR2TQ0N7aVzrtpwd0Ohj/bRlolLHu7nSvP3Q6dNsLi6hi4gSVeWlDADmAC5XMYnUkqTeZlwIQiS1vjtXlFCuJkONORim+ccf8rujAH6mACYZkOFg5UjwPxGsOls+v0WlOFw1A/nEfapqYqH1F6OTBUGPmAY/1L2GYQMc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738941516; c=relaxed/simple; bh=RpIKikbcDWkM5Hzt3hYTUmGzsoMxr9PAEMTrIc2EYnU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hY8/+vvuSUcJSaqaex7TZW1tUehAMS2rmcwuXaTbDC41ncf2Aq5dlziqhPrKEYdbODjkEFHc5GV6kGoj1zkC2TJCxUDegIdIg5xxOgFvxL/jGmHWh6yRm+1lIyZr6U8j8FuQFU7UFIBeDWJZOzDhU+nEHHO0zBSm/n0FAN5rroY= 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=W+FdVtAb; arc=none smtp.client-ip=192.198.163.18 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="W+FdVtAb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1738941515; x=1770477515; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RpIKikbcDWkM5Hzt3hYTUmGzsoMxr9PAEMTrIc2EYnU=; b=W+FdVtAbalaTEOR6VIttCkrFgW++fUZxxD9afYxoNYwaVa3sijgiOU2l dIk8wKVJwYdHonCkyd51i95VosPNDV1oEIsMbWNCPbF6cZK/RpgNJCRR3 4s/Grig1rguqOFXqRb3dmNcmsR/HLLoXOjO1Nq2t+Cy6QM9QhAKWO8a6x ee957hbLwB7IOBINaFxUDbC+eyEnklUjU+QxACi1wBvZ+zHzximYgzoCO V9T88ZoKYUQaXOBpRA2x4d0fGgbFI85JQmOCZG4mbbjclD53FFwWrnm0h T4vgIdI5PqrCSNU1aLVRjnIIOwuINaVmJN/hTlGxKBCxy4uuE4xEXWItg A==; X-CSE-ConnectionGUID: qjSxxWLyQ9qK3g36kvPWrg== X-CSE-MsgGUID: GbxcWY9LSoWCFZFmo8Yg0g== X-IronPort-AV: E=McAfee;i="6700,10204,11338"; a="38815627" X-IronPort-AV: E=Sophos;i="6.13,267,1732608000"; d="scan'208";a="38815627" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Feb 2025 07:18:33 -0800 X-CSE-ConnectionGUID: 2IVECy69Q06iB9ObmdsC9A== X-CSE-MsgGUID: 5HKF5HQ7S12bcVbnP0DVXQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,267,1732608000"; d="scan'208";a="116599318" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa004.fm.intel.com with ESMTP; 07 Feb 2025 07:18:31 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id BD382498; Fri, 07 Feb 2025 17:18:26 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Cc: Linus Walleij , Bartosz Golaszewski , Kees Cook , "Gustavo A. R. Silva" Subject: [PATCH v2 5/7] gpio: 74x164: Fully convert to use managed resources Date: Fri, 7 Feb 2025 17:17:12 +0200 Message-ID: <20250207151825.2122419-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20250207151825.2122419-1-andriy.shevchenko@linux.intel.com> References: <20250207151825.2122419-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert the driver probe stage to use managed resources. Signed-off-by: Andy Shevchenko --- drivers/gpio/gpio-74x164.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c index 0f720d539fa7..ecd691de8539 100644 --- a/drivers/gpio/gpio-74x164.c +++ b/drivers/gpio/gpio-74x164.c @@ -95,6 +95,19 @@ static int gen_74x164_direction_output(struct gpio_chip *gc, return 0; } +static void gen_74x164_deactivate(void *data) +{ + struct gen_74x164_chip *chip = data; + + gpiod_set_value_cansleep(chip->gpiod_oe, 0); +} + +static int gen_74x164_activate(struct device *dev, struct gen_74x164_chip *chip) +{ + gpiod_set_value_cansleep(chip->gpiod_oe, 1); + return devm_add_action_or_reset(dev, gen_74x164_deactivate, chip); +} + static int gen_74x164_probe(struct spi_device *spi) { struct device *dev = &spi->dev; @@ -128,8 +141,6 @@ static int gen_74x164_probe(struct spi_device *spi) if (IS_ERR(chip->gpiod_oe)) return PTR_ERR(chip->gpiod_oe); - spi_set_drvdata(spi, chip); - chip->gpio_chip.label = spi->modalias; chip->gpio_chip.direction_output = gen_74x164_direction_output; chip->gpio_chip.get = gen_74x164_get_value; @@ -149,18 +160,13 @@ static int gen_74x164_probe(struct spi_device *spi) if (ret) return dev_err_probe(&spi->dev, ret, "Config write failed\n"); - gpiod_set_value_cansleep(chip->gpiod_oe, 1); + ret = gen_74x164_activate(dev, chip); + if (ret) + return ret; return devm_gpiochip_add_data(&spi->dev, &chip->gpio_chip, chip); } -static void gen_74x164_remove(struct spi_device *spi) -{ - struct gen_74x164_chip *chip = spi_get_drvdata(spi); - - gpiod_set_value_cansleep(chip->gpiod_oe, 0); -} - static const struct spi_device_id gen_74x164_spi_ids[] = { { .name = "74hc595" }, { .name = "74lvc594" }, @@ -181,7 +187,6 @@ static struct spi_driver gen_74x164_driver = { .of_match_table = gen_74x164_dt_ids, }, .probe = gen_74x164_probe, - .remove = gen_74x164_remove, .id_table = gen_74x164_spi_ids, }; module_spi_driver(gen_74x164_driver); From patchwork Fri Feb 7 15:17:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13965256 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (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 DD0FD23ED7A; Fri, 7 Feb 2025 15:18:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738941516; cv=none; b=CNpwdngA/uvC0o+O47Bqku1D/UOQNukaSpfdkTPVpMZuqMpx+oateZczHjH2JVFER/1/fo7SqKrGU1TETT84R1Wzwon/DowB+ifNZnsioCGDH6GhoDBk5WV1MFEHS7vXrcpkvN7YxywmmJPgqq7LQj2zTgsP2tZaCcU3qs/PH+4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738941516; c=relaxed/simple; bh=oYsGlkndwSIdbxMwp9jLVvqe8dsRSKZN34Ak6SuKmJw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PxD/+iLl8GdSkSHGUL5kRfBM7rlPtXO23okuaNk4iRTGFD+4nyBJX7JPCdHsG3O9LeMQDJ6c8UNZj00TYQFwE1AP2eEN5Ft4B99CxlcjD6AGig460PSGDYB2rMSF2XoxxSy5QwZY1bHCf5k02iP0XxfxY0G+YFGUdtdGE7dXY6E= 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=DukCiBzu; arc=none smtp.client-ip=192.198.163.7 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="DukCiBzu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1738941515; x=1770477515; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oYsGlkndwSIdbxMwp9jLVvqe8dsRSKZN34Ak6SuKmJw=; b=DukCiBzu5G9gF1eBqCjAy7jNW4U4fZF7uhMtKRcRtcLC3Y9eJQ2ZBmrE vmQPrT8Qqdg3B8g8WlSuZfewcWKLtQMShDPQb6PYA9vYGV8mSdHWq3jOE qTMGFBih+HRg4BHcUryzu/w4E7zfNWaLZjMHtaJFNMvOgsAFxsKEgvUP1 mbsY2fMv8dyTPl+UKNRutP45Mm7WgEYSN9PUT2lZpwGsocTkEz7/Ogo0T dPC5TszpwAmIIWysndurMLk0qvPFbVgf8MxShN/XD+iJdKp+np4/KhIZW E4ALZReWpxx+wNwpouWetLMtZRQPkc8LncoF7FvnL4FL0kbSJ/a3jsI7M g==; X-CSE-ConnectionGUID: Ja+BRg0dQa+ZowHmqXwh3A== X-CSE-MsgGUID: Nye+7PurQUexkhTkGrz+YQ== X-IronPort-AV: E=McAfee;i="6700,10204,11338"; a="64941728" X-IronPort-AV: E=Sophos;i="6.13,267,1732608000"; d="scan'208";a="64941728" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Feb 2025 07:18:33 -0800 X-CSE-ConnectionGUID: qGQlZK9LT4eksl5vlimExg== X-CSE-MsgGUID: eriNBc3FSSOFv7OlJ3UbYw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,267,1732608000"; d="scan'208";a="112179901" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa009.fm.intel.com with ESMTP; 07 Feb 2025 07:18:30 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id C2FB942B; Fri, 07 Feb 2025 17:18:26 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Cc: Linus Walleij , Bartosz Golaszewski , Kees Cook , "Gustavo A. R. Silva" Subject: [PATCH v2 6/7] gpio: 74x164: Switch to use dev_err_probe() Date: Fri, 7 Feb 2025 17:17:13 +0200 Message-ID: <20250207151825.2122419-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20250207151825.2122419-1-andriy.shevchenko@linux.intel.com> References: <20250207151825.2122419-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Switch to use dev_err_probe() to simplify the error path and unify a message template. Signed-off-by: Andy Shevchenko --- drivers/gpio/gpio-74x164.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c index ecd691de8539..bbeef03e3797 100644 --- a/drivers/gpio/gpio-74x164.c +++ b/drivers/gpio/gpio-74x164.c @@ -125,10 +125,8 @@ static int gen_74x164_probe(struct spi_device *spi) return ret; ret = device_property_read_u32(&spi->dev, "registers-number", &nregs); - if (ret) { - dev_err(&spi->dev, "Missing 'registers-number' property.\n"); - return -EINVAL; - } + if (ret) + return dev_err_probe(dev, ret, "Missing 'registers-number' property.\n"); chip = devm_kzalloc(dev, struct_size(chip, buffer, nregs), GFP_KERNEL); if (!chip) From patchwork Fri Feb 7 15:17:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13965252 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (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 3F83C1EB1A2; Fri, 7 Feb 2025 15:18:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738941514; cv=none; b=nPmcitNSFX1yM6fLo8WX2zlduYGUTEpmh2GlMsUnepzQVWQq5XSVMVEerXxMlD8t+N/hu2ebH3Mavuj8hpe5QgKBpU++8wVFw+/wea1YTYulQHmY75B6C8dWywI76M0pIUkWi7CbQHIMe5khvPTdZkceTCCMfZXxDPtT7oUp8E4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738941514; c=relaxed/simple; bh=26dwUP/V8uN5xsZwNQvoZJ1H86oZuP5cbB4CjDRjYVg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XVU+iL447vmjRm+ZVjGsl+HZK4BTi1d9joQZJ+VR1jxibrgts1lILwsr0UqhXne3CkdwYsxS0IT3OGuZ4vj+TOSNv82Yg56QF1FQ31hyxGh0JvTLdyFcJarICQqGLrA/LyHD254UdSruZUBcGXvD1Xz5rnQi3Aos62hMv3aKE14= 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=AkrfcEFL; arc=none smtp.client-ip=192.198.163.7 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="AkrfcEFL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1738941513; x=1770477513; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=26dwUP/V8uN5xsZwNQvoZJ1H86oZuP5cbB4CjDRjYVg=; b=AkrfcEFLyJ/A9jPA/Fms81jEUKiPJhGRLTSefqWf+z1hIUpA6kfQ7Uha /wj/PK76rKbS2/8/KBE5xEYzcSLIlx86CwEbqEvvLr+2h85wd8GxToPfz dCDmNVUESSe9Ok6/JwNyTJ2RTf0I+qZipivRUIs4mS4+TjUgU1Wx7eD9s pW+IPNUGg3Qs4z338SbFpzeuFD3Q/ZIb6CkYW5ikbQu8qHJFNPE8YKqVb hJHl6pqD7dgl/tdSZ6Lf8O/1oh+1Og2uHVeDh9A2Ctze8t0b6MPey6Rqe QjyGwRaeOrWed1Aj8ZQWE2gwkle9S5YDxTxdYE7sQf2xEWU6EXEY0OdYW Q==; X-CSE-ConnectionGUID: qqPFBi1qSmWPDkxWy5tqxw== X-CSE-MsgGUID: SmnlMipfSgaQdW65lfcXeA== X-IronPort-AV: E=McAfee;i="6700,10204,11338"; a="64941723" X-IronPort-AV: E=Sophos;i="6.13,267,1732608000"; d="scan'208";a="64941723" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Feb 2025 07:18:33 -0800 X-CSE-ConnectionGUID: +N051xMoTT6/FgVfiANSyA== X-CSE-MsgGUID: 2YGEshMWSQqWw1jy1NxKdQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,267,1732608000"; d="scan'208";a="112179900" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa009.fm.intel.com with ESMTP; 07 Feb 2025 07:18:30 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id D2A6D4B0; Fri, 07 Feb 2025 17:18:26 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Cc: Linus Walleij , Bartosz Golaszewski , Kees Cook , "Gustavo A. R. Silva" Subject: [PATCH v2 7/7] gpio: 74x164: Utilise temporary variable for struct device Date: Fri, 7 Feb 2025 17:17:14 +0200 Message-ID: <20250207151825.2122419-8-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20250207151825.2122419-1-andriy.shevchenko@linux.intel.com> References: <20250207151825.2122419-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We have a temporary variable to keep a pointer to struct device. Utilise it where it makes sense. Signed-off-by: Andy Shevchenko --- drivers/gpio/gpio-74x164.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c index bbeef03e3797..db41abcd73e1 100644 --- a/drivers/gpio/gpio-74x164.c +++ b/drivers/gpio/gpio-74x164.c @@ -124,7 +124,7 @@ static int gen_74x164_probe(struct spi_device *spi) if (ret < 0) return ret; - ret = device_property_read_u32(&spi->dev, "registers-number", &nregs); + ret = device_property_read_u32(dev, "registers-number", &nregs); if (ret) return dev_err_probe(dev, ret, "Missing 'registers-number' property.\n"); @@ -134,8 +134,7 @@ static int gen_74x164_probe(struct spi_device *spi) chip->registers = nregs; - chip->gpiod_oe = devm_gpiod_get_optional(&spi->dev, "enable", - GPIOD_OUT_LOW); + chip->gpiod_oe = devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_LOW); if (IS_ERR(chip->gpiod_oe)) return PTR_ERR(chip->gpiod_oe); @@ -147,7 +146,7 @@ static int gen_74x164_probe(struct spi_device *spi) chip->gpio_chip.base = -1; chip->gpio_chip.ngpio = GEN_74X164_NUMBER_GPIOS * chip->registers; chip->gpio_chip.can_sleep = true; - chip->gpio_chip.parent = &spi->dev; + chip->gpio_chip.parent = dev; chip->gpio_chip.owner = THIS_MODULE; ret = devm_mutex_init(&spi->dev, &chip->lock);