From nobody Fri Dec 19 04:58:41 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (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 5A90F1FDE01; Tue, 3 Dec 2024 19:53:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733255629; cv=none; b=Lp5UwKOujT64SKDHCw5jDGqrdAsLsIa1fJDYdGULxzKJQA5yHuSIvjEDcNArLwG93BoPqc460SOKyl0oBFg8c7t4I1mVGIhKlM/8MrYtJw43OAzbPiQqUNGpPj8TiHxEVL4lSyOWAK7zVI9Iyv+T0HEVZ/IMTjRSX142YtfJHbI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733255629; c=relaxed/simple; bh=k0U7x5txhIwPf3i1UbHPJyFPcTsk++ZRkAs+XIUL2eM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JpgYkp/nmgbLn0+xtftdBtCK0ojS3zlVTA9b/lPVkI1UbFc767BUTEWkOUDP95ELvorx8/GfI5Vna7kOx5P5CdKi26gd79iGXcZ+LPl6bsMEFyYCBeX35uFMtzij+q2bnEWNaZWxvtO36pENFNKQc9tRRlsFLqZgmR4VVC1lP2U= 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=DLOb/yoZ; arc=none smtp.client-ip=198.175.65.20 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="DLOb/yoZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1733255627; x=1764791627; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=k0U7x5txhIwPf3i1UbHPJyFPcTsk++ZRkAs+XIUL2eM=; b=DLOb/yoZX/JCExLk4RaOqqx1R/KvKEnuS66QorwkwKK/s8XAhpqseJWc 6XHa3dJ9AJL9PK/tr1qKVFcXNd0vifOJN4oV4N3qa5uo0KabI6fHkXQKk 21R47X67rpWWsLEtzMgPZ+TKaiYlUmPCZy2uL9y1NIJ9MMVL69dOFLAC5 oZnBL/W06H+tKAnjZeBqEFLUkewhppADyvc4mFgyl71QR5E//6btwO14Q JvlYOD8SvMyPLwpjWNHkGv44an5qlMR3suNlWRZQpUdrDDh3kznUC9MWN 03gZ+P1YuL4G9Z5kaM89OUsqRtONUh9u7JKUb3zTtJ7DL4TW5nK6C4yXx Q==; X-CSE-ConnectionGUID: 0GZcfPWSSa+yI2AYLiN70g== X-CSE-MsgGUID: a+9uuE7mSC2cXpDB2dcx8g== X-IronPort-AV: E=McAfee;i="6700,10204,11275"; a="33238667" X-IronPort-AV: E=Sophos;i="6.12,206,1728975600"; d="scan'208";a="33238667" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2024 11:53:46 -0800 X-CSE-ConnectionGUID: /zo2BtZgRr6Uit5X1q3gjg== X-CSE-MsgGUID: DZk0GpLyT/qfExhRXGld7Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,206,1728975600"; d="scan'208";a="98621150" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa004.jf.intel.com with ESMTP; 03 Dec 2024 11:53:44 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 5619642D; Tue, 03 Dec 2024 21:53:43 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , "andy.shevchenko@gmail.com" , linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org Cc: Jonathan Cameron , Lars-Peter Clausen Subject: [PATCH v1 1/2] driver core: Split devres APIs to device/devres.h Date: Tue, 3 Dec 2024 21:48:51 +0200 Message-ID: <20241203195340.855879-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20241203195340.855879-1-andriy.shevchenko@linux.intel.com> References: <20241203195340.855879-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" device.h is a huge header which is hard to follow and easy to miss something. Improve that by splitting devres APIs to device/devres.h. In particular this helps to speedup the build of the code that includes device.h solely for a devres APIs. Signed-off-by: Andy Shevchenko --- include/linux/device.h | 122 +-------------------------------- include/linux/device/devres.h | 124 ++++++++++++++++++++++++++++++++++ 2 files changed, 127 insertions(+), 119 deletions(-) create mode 100644 include/linux/device/devres.h diff --git a/include/linux/device.h b/include/linux/device.h index 667cb6db9019..ad8ffbfc8651 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -12,6 +12,7 @@ #ifndef _DEVICE_H_ #define _DEVICE_H_ =20 +#include #include #include #include @@ -26,11 +27,11 @@ #include #include #include -#include + #include #include +#include #include -#include #include =20 struct device; @@ -281,123 +282,6 @@ int __must_check device_create_bin_file(struct device= *dev, void device_remove_bin_file(struct device *dev, const struct bin_attribute *attr); =20 -/* device resource management */ -typedef void (*dr_release_t)(struct device *dev, void *res); -typedef int (*dr_match_t)(struct device *dev, void *res, void *match_data); - -void *__devres_alloc_node(dr_release_t release, size_t size, gfp_t gfp, - int nid, const char *name) __malloc; -#define devres_alloc(release, size, gfp) \ - __devres_alloc_node(release, size, gfp, NUMA_NO_NODE, #release) -#define devres_alloc_node(release, size, gfp, nid) \ - __devres_alloc_node(release, size, gfp, nid, #release) - -void devres_for_each_res(struct device *dev, dr_release_t release, - dr_match_t match, void *match_data, - void (*fn)(struct device *, void *, void *), - void *data); -void devres_free(void *res); -void devres_add(struct device *dev, void *res); -void *devres_find(struct device *dev, dr_release_t release, - dr_match_t match, void *match_data); -void *devres_get(struct device *dev, void *new_res, - dr_match_t match, void *match_data); -void *devres_remove(struct device *dev, dr_release_t release, - dr_match_t match, void *match_data); -int devres_destroy(struct device *dev, dr_release_t release, - dr_match_t match, void *match_data); -int devres_release(struct device *dev, dr_release_t release, - dr_match_t match, void *match_data); - -/* devres group */ -void * __must_check devres_open_group(struct device *dev, void *id, gfp_t = gfp); -void devres_close_group(struct device *dev, void *id); -void devres_remove_group(struct device *dev, void *id); -int devres_release_group(struct device *dev, void *id); - -/* managed devm_k.alloc/kfree for device drivers */ -void *devm_kmalloc(struct device *dev, size_t size, gfp_t gfp) __alloc_siz= e(2); -void *devm_krealloc(struct device *dev, void *ptr, size_t size, - gfp_t gfp) __must_check __realloc_size(3); -__printf(3, 0) char *devm_kvasprintf(struct device *dev, gfp_t gfp, - const char *fmt, va_list ap) __malloc; -__printf(3, 4) char *devm_kasprintf(struct device *dev, gfp_t gfp, - const char *fmt, ...) __malloc; -static inline void *devm_kzalloc(struct device *dev, size_t size, gfp_t gf= p) -{ - return devm_kmalloc(dev, size, gfp | __GFP_ZERO); -} -static inline void *devm_kmalloc_array(struct device *dev, - size_t n, size_t size, gfp_t flags) -{ - size_t bytes; - - if (unlikely(check_mul_overflow(n, size, &bytes))) - return NULL; - - return devm_kmalloc(dev, bytes, flags); -} -static inline void *devm_kcalloc(struct device *dev, - size_t n, size_t size, gfp_t flags) -{ - return devm_kmalloc_array(dev, n, size, flags | __GFP_ZERO); -} -static inline __realloc_size(3, 4) void * __must_check -devm_krealloc_array(struct device *dev, void *p, size_t new_n, size_t new_= size, gfp_t flags) -{ - size_t bytes; - - if (unlikely(check_mul_overflow(new_n, new_size, &bytes))) - return NULL; - - return devm_krealloc(dev, p, bytes, flags); -} - -void devm_kfree(struct device *dev, const void *p); -char *devm_kstrdup(struct device *dev, const char *s, gfp_t gfp) __malloc; -const char *devm_kstrdup_const(struct device *dev, const char *s, gfp_t gf= p); -void *devm_kmemdup(struct device *dev, const void *src, size_t len, gfp_t = gfp) - __realloc_size(3); - -unsigned long devm_get_free_pages(struct device *dev, - gfp_t gfp_mask, unsigned int order); -void devm_free_pages(struct device *dev, unsigned long addr); - -#ifdef CONFIG_HAS_IOMEM -void __iomem *devm_ioremap_resource(struct device *dev, - const struct resource *res); -void __iomem *devm_ioremap_resource_wc(struct device *dev, - const struct resource *res); - -void __iomem *devm_of_iomap(struct device *dev, - struct device_node *node, int index, - resource_size_t *size); -#else - -static inline -void __iomem *devm_ioremap_resource(struct device *dev, - const struct resource *res) -{ - return ERR_PTR(-EINVAL); -} - -static inline -void __iomem *devm_ioremap_resource_wc(struct device *dev, - const struct resource *res) -{ - return ERR_PTR(-EINVAL); -} - -static inline -void __iomem *devm_of_iomap(struct device *dev, - struct device_node *node, int index, - resource_size_t *size) -{ - return ERR_PTR(-EINVAL); -} - -#endif - /* allows to add/remove a custom action to devres stack */ void devm_remove_action(struct device *dev, void (*action)(void *), void *= data); void devm_release_action(struct device *dev, void (*action)(void *), void = *data); diff --git a/include/linux/device/devres.h b/include/linux/device/devres.h new file mode 100644 index 000000000000..128d65defafc --- /dev/null +++ b/include/linux/device/devres.h @@ -0,0 +1,124 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _DEVICE_DEVRES_H_ +#define _DEVICE_DEVRES_H_ + +#include +#include +#include +#include +#include +#include + +struct device; +struct device_node; +struct resource; + +/* device resource management */ +typedef void (*dr_release_t)(struct device *dev, void *res); +typedef int (*dr_match_t)(struct device *dev, void *res, void *match_data); + +void * __malloc +__devres_alloc_node(dr_release_t release, size_t size, gfp_t gfp, int nid,= const char *name); +#define devres_alloc(release, size, gfp) \ + __devres_alloc_node(release, size, gfp, NUMA_NO_NODE, #release) +#define devres_alloc_node(release, size, gfp, nid) \ + __devres_alloc_node(release, size, gfp, nid, #release) + +void devres_for_each_res(struct device *dev, dr_release_t release, + dr_match_t match, void *match_data, + void (*fn)(struct device *, void *, void *), + void *data); +void devres_free(void *res); +void devres_add(struct device *dev, void *res); +void *devres_find(struct device *dev, dr_release_t release, dr_match_t mat= ch, void *match_data); +void *devres_get(struct device *dev, void *new_res, dr_match_t match, void= *match_data); +void *devres_remove(struct device *dev, dr_release_t release, dr_match_t m= atch, void *match_data); +int devres_destroy(struct device *dev, dr_release_t release, dr_match_t ma= tch, void *match_data); +int devres_release(struct device *dev, dr_release_t release, dr_match_t ma= tch, void *match_data); + +/* devres group */ +void * __must_check devres_open_group(struct device *dev, void *id, gfp_t = gfp); +void devres_close_group(struct device *dev, void *id); +void devres_remove_group(struct device *dev, void *id); +int devres_release_group(struct device *dev, void *id); + +/* managed devm_k.alloc/kfree for device drivers */ +void * __alloc_size(2) +devm_kmalloc(struct device *dev, size_t size, gfp_t gfp); +void * __must_check __realloc_size(3) +devm_krealloc(struct device *dev, void *ptr, size_t size, gfp_t gfp); +static inline void *devm_kzalloc(struct device *dev, size_t size, gfp_t gf= p) +{ + return devm_kmalloc(dev, size, gfp | __GFP_ZERO); +} +static inline void *devm_kmalloc_array(struct device *dev, size_t n, size_= t size, gfp_t flags) +{ + size_t bytes; + + if (unlikely(check_mul_overflow(n, size, &bytes))) + return NULL; + + return devm_kmalloc(dev, bytes, flags); +} +static inline void *devm_kcalloc(struct device *dev, size_t n, size_t size= , gfp_t flags) +{ + return devm_kmalloc_array(dev, n, size, flags | __GFP_ZERO); +} +static inline __realloc_size(3, 4) void * __must_check +devm_krealloc_array(struct device *dev, void *p, size_t new_n, size_t new_= size, gfp_t flags) +{ + size_t bytes; + + if (unlikely(check_mul_overflow(new_n, new_size, &bytes))) + return NULL; + + return devm_krealloc(dev, p, bytes, flags); +} + +void devm_kfree(struct device *dev, const void *p); + +void * __realloc_size(3) +devm_kmemdup(struct device *dev, const void *src, size_t len, gfp_t gfp); + +char * __malloc +devm_kstrdup(struct device *dev, const char *s, gfp_t gfp); +const char *devm_kstrdup_const(struct device *dev, const char *s, gfp_t gf= p); +char * __printf(3, 0) __malloc +devm_kvasprintf(struct device *dev, gfp_t gfp, const char *fmt, va_list ap= ); +char * __printf(3, 4) __malloc +devm_kasprintf(struct device *dev, gfp_t gfp, const char *fmt, ...); + +unsigned long devm_get_free_pages(struct device *dev, gfp_t gfp_mask, unsi= gned int order); +void devm_free_pages(struct device *dev, unsigned long addr); + +#ifdef CONFIG_HAS_IOMEM + +void __iomem *devm_ioremap_resource(struct device *dev, const struct resou= rce *res); +void __iomem *devm_ioremap_resource_wc(struct device *dev, const struct re= source *res); + +void __iomem *devm_of_iomap(struct device *dev, struct device_node *node, = int index, + resource_size_t *size); +#else + +static inline +void __iomem *devm_ioremap_resource(struct device *dev, const struct resou= rce *res) +{ + return ERR_PTR(-EINVAL); +} + +static inline +void __iomem *devm_ioremap_resource_wc(struct device *dev, const struct re= source *res) +{ + return ERR_PTR(-EINVAL); +} + +static inline +void __iomem *devm_of_iomap(struct device *dev, struct device_node *node, = int index, + resource_size_t *size) +{ + return ERR_PTR(-EINVAL); +} + +#endif + +#endif /* _DEVICE_DEVRES_H_ */ --=20 2.43.0.rc1.1336.g36b5255a03ac From nobody Fri Dec 19 04:58:41 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (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 5E21A202F86; Tue, 3 Dec 2024 19:53:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733255630; cv=none; b=lOTPTv7ZfQ3vp4fdguoz9N/2ZTV/2GZtrg+YmFrkQywCUQ9I4jk0nK4yU9oDW+3uFyZjgcYc59nG5ZlRx5uldGRZFMNDrwzQaY9Maiei1jJP+/ejGKaA2HoSw4iPODbG7pEiljM13VO+CvOoiXwVDwWAjTHbnNKS9l3/lmU3TYQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733255630; c=relaxed/simple; bh=pyUYHh95ohHtp9zFDPFoOhi3+W1Y80mrJ/4n1GI/sEg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EGTChK+20Gzu+8oCYRiXKyc7w5zjFWCSfVjJoTkvHZd/JF8tFiMLhzCkps3M0vOobLMm9PUneypEIMq+P4HPA+s6iceJjbQ94lxw+deufj/Fsew9OPnpMqKw3khsF+bWDnIqewnvLwSyZoEWuTavkFBDLCijrwIYiGy0+swC4Dk= 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=k87i4zbr; arc=none smtp.client-ip=198.175.65.20 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="k87i4zbr" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1733255627; x=1764791627; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pyUYHh95ohHtp9zFDPFoOhi3+W1Y80mrJ/4n1GI/sEg=; b=k87i4zbrKJE9I+TwjjRIy0lp8fm6qiZsP9UMaZf4zYPDCYMlUEGkeqfY lpSwdWbpo7xOYPASjg1nKtKnuPxGiK79PsvQTLSTtRtaxOrT0hDre2MXG zlYaIWZRdtCQnaF3s+e6GTlLC5x2P3YMrKZtrws/xlYIei6RDtZ//okBu uVh5hqPB5nYyv2dr/kSGZ1S58L3yRaZujITTLRjHh1u/6htMGftD6Hjo9 1WAUvP4mGCTXqI/+5oM++3MTAGQryX9T7jECtoQySZK48JC2TN0Cen55B xkKboaQdro7bagM4RbOVX5eDLNuXB7i5kesTQMaxHdrViEgVmJ8XnfzPZ w==; X-CSE-ConnectionGUID: HQbXvxFhSHqpUxQbcTh/NA== X-CSE-MsgGUID: x/LuHl2QQIGFpeobG80a+g== X-IronPort-AV: E=McAfee;i="6700,10204,11275"; a="33238671" X-IronPort-AV: E=Sophos;i="6.12,206,1728975600"; d="scan'208";a="33238671" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2024 11:53:47 -0800 X-CSE-ConnectionGUID: 8mB7cbDTReKx5lztkL3KBg== X-CSE-MsgGUID: SekiPKj0TrepfrA8G9xPPg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,206,1728975600"; d="scan'208";a="98621153" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa004.jf.intel.com with ESMTP; 03 Dec 2024 11:53:45 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 20312557; Tue, 03 Dec 2024 21:53:44 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , "andy.shevchenko@gmail.com" , linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org Cc: Jonathan Cameron , Lars-Peter Clausen Subject: [PATCH v1 2/2] iio: imu: st_lsm9ds0: Replace device.h with what is needed Date: Tue, 3 Dec 2024 21:48:52 +0200 Message-ID: <20241203195340.855879-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20241203195340.855879-1-andriy.shevchenko@linux.intel.com> References: <20241203195340.855879-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" Instead of including a huge device.h with tons of dependencies include only what driver actually uses. Signed-off-by: Andy Shevchenko --- drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c | 2 +- drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c b/drivers/iio/imu/= st_lsm9ds0/st_lsm9ds0_i2c.c index d03cec3b24fe..2b1b57761688 100644 --- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c +++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c @@ -7,7 +7,7 @@ * Author: Andy Shevchenko */ =20 -#include +#include #include #include #include diff --git a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c b/drivers/iio/imu/= st_lsm9ds0/st_lsm9ds0_spi.c index 69e9135795a3..d3bfd74a69ab 100644 --- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c +++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c @@ -7,7 +7,7 @@ * Author: Andy Shevchenko */ =20 -#include +#include #include #include #include --=20 2.43.0.rc1.1336.g36b5255a03ac