From nobody Tue Feb 10 04:14:16 2026 Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3AEB42702CB for ; Fri, 28 Feb 2025 14:07:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740751655; cv=none; b=Spi/+C60TGFEczC28bhRTFVXTgloBZojqFOHYSxtZjToUC8gpzM99Vk3zoeKlWRC/N9UHKe1Df4xlPnkuTK4hB75qeOx8KBLz0N0kB1QP1kVlW6MVQYeaMr+31cfCBRK255AjZXw9GHHVF0aiJv3psSK8svddqu4PEpzTFM1+ZE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740751655; c=relaxed/simple; bh=KnTT7JVjJd7L84lbqgaLnnpzphht/b/4e/xeT/zzGuY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZbjWIe6UxDqpkwQ2K4jhWqehnOHvUR9B5L+hZtbCytyZTUnjuyFcTLzZuAHON70TCae3MdxokS5XZCl00nakysMZDWHqJKM38+VzKhcGUntQkJE8Iz1/YyojW0wAnt/RP5frBWgJKOnpWRJd8MQtZIDxj07ToFg+4cXc/JUE378= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=vhrOgg2a; arc=none smtp.client-ip=209.85.208.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="vhrOgg2a" Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-5e04cb346eeso3602147a12.2 for ; Fri, 28 Feb 2025 06:07:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1740751650; x=1741356450; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=XNaBzsv98dZxOnoY4pQ3hhfyEv1+PH+c26jk5v5UbcU=; b=vhrOgg2aZzOd7RHT7K//qXuwRzvsaz4MFsjVoDelpXKBUjMPSvIgzT6bBKwLVTbQmZ VRKD2pCMB3yjkeq0prZ65/MeBO3cnurRHrgd80hTWrmxImi/msDee3LZQkZO7nUHxLqP RmAnybYsLu2jBsM9fMSK7tQKUT04/iBLxq6snU1164ReVjrX/tzR3FwgvsMdyYQItrbq 0pg94gzAuGLRpvllaJZ5nlu3z+TZoqSd5SgZz+e+sP3O8rjyBH00+OvgNyuRvQkObyaD yu3cmDmWgsdnr7o+nA9ShVaXrOT7nWZCT48jNMYGcYL26P4QRph1DQFFKCkTxhgVKq6b FgFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740751650; x=1741356450; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XNaBzsv98dZxOnoY4pQ3hhfyEv1+PH+c26jk5v5UbcU=; b=C9ZPrRUpVLpznBsObnJwEPiugZndfbKmyYHNBXsYamW6/DZi8bR4HdGQhLS3bUubl8 rEDyJP7YjZMYWqK8qmy25ePU/6XIO7Hkole1Mr+YJ6DBSOqQbW+ghusR+lGtBF5NAG8v U4aUmssSJ3HDT8zo6x29UeFSLNPJAnH79yggnNXMZ2xcDUYi1PaH5tH2dbWI6edJCjke Hx3oS5qq+v0Xy4KnIaibzCMgqN7WA5DnI3ujDNStDwSSWtwSTORvjC6QrheDDRz2XDZz 4dAOq61gXaZFlq7OWBPVacHnPa1jXMbQ0L/V15+u/4C73Ua4uOwgxYUI8odrCuYpuD3X 4sdQ== X-Gm-Message-State: AOJu0YweH8zIhoW2MHSsIzPZxx0NT2DGRg/o26h2vpwwpxleJ6m00p/s 4+nQ0rkwa+Xok/SZt9o5+CJfCpT6N0ekP/ocEPr72InmsfZtsKEMalD9YPjC2tE= X-Gm-Gg: ASbGncu15C9A8Leac9O20tM8GtXUZRhHtGdDKqUtX9rDZ34gVQ7AQlXkNfxQoNDTob3 fq/o3yL3sh+0QGYugROOWP8hDxFkyRuS30UgPV3by8PYmiiODdvQBi9iyr9l5YAFjQqXo8sO+sJ zsYz8+3zRxYNKb0pndvcRQT8K2/G933DKA4iZs9rW9+AFZGEzAto4pxvzfIAgTKZni+zlqHtEsr qCMPCxnPWhBaWNhniQdzRh4LW698JcFjyCKZxPgp+sVrNYvln5qfBQS/Gee6AYJRKtqXQ5eUKKR RBubruf4vpNIjW8lIKPK9VAJT0qrgn4veUfu5KQBufvJl5vo4kJv5W/0iFBdmFEdkwcfLiiTMkx 8Pw4MuUv0uA== X-Google-Smtp-Source: AGHT+IHJgHIb94bIAN1OxpmT/CmpG5hxROPCgFLfrUaKlqlLkHckO5CTYjuy4Kdl9gpiKvePvUPO6w== X-Received: by 2002:a05:6402:35d3:b0:5e0:9959:83cd with SMTP id 4fb4d7f45d1cf-5e4d6b70ef7mr2396243a12.21.1740751650375; Fri, 28 Feb 2025 06:07:30 -0800 (PST) Received: from puffmais.c.googlers.com (30.171.91.34.bc.googleusercontent.com. [34.91.171.30]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5e4c3fb51f9sm2550839a12.55.2025.02.28.06.07.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Feb 2025 06:07:30 -0800 (PST) From: =?utf-8?q?Andr=C3=A9_Draszik?= Date: Fri, 28 Feb 2025 14:07:28 +0000 Subject: [PATCH 15/18] rtc: rx8581: drop needless struct rx8581 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250228-rtc-cleanups-v1-15-b44cec078481@linaro.org> References: <20250228-rtc-cleanups-v1-0-b44cec078481@linaro.org> In-Reply-To: <20250228-rtc-cleanups-v1-0-b44cec078481@linaro.org> To: Chanwoo Choi , Krzysztof Kozlowski , Alexandre Belloni , Joel Stanley , Andrew Jeffery , Hans Ulli Kroll , Linus Walleij , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , =?utf-8?q?T=C3=B3th_J=C3=A1nos?= , Dianlong Li Cc: linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-amlogic@lists.infradead.org, =?utf-8?q?Andr=C3=A9_Draszik?= X-Mailer: b4 0.14.2 This private data struct has one member only, there is no need to allocate data for it and pass that around via the various callbacks, just to extract that one member. Instead, we can just pass that one member and avoid the extra memory allocation, reducing runtime memory consumption. Signed-off-by: Andr=C3=A9 Draszik --- drivers/rtc/rtc-rx8581.c | 63 +++++++++++++++++++-------------------------= ---- 1 file changed, 25 insertions(+), 38 deletions(-) diff --git a/drivers/rtc/rtc-rx8581.c b/drivers/rtc/rtc-rx8581.c index 785ebaca07ac971eee34559f8d1e0a8a872cbba9..20c2dff01bae833ae4e100cc38c= d5f030017be75 100644 --- a/drivers/rtc/rtc-rx8581.c +++ b/drivers/rtc/rtc-rx8581.c @@ -52,10 +52,6 @@ #define RX8571_USER_RAM 0x10 #define RX8571_NVRAM_SIZE 0x10 =20 -struct rx8581 { - struct regmap *regmap; -}; - struct rx85x1_config { struct regmap_config regmap; unsigned int num_nvram; @@ -71,14 +67,14 @@ static int rx8581_rtc_read_time(struct device *dev, str= uct rtc_time *tm) unsigned char date[7]; unsigned int data; int err; - struct rx8581 *rx8581 =3D i2c_get_clientdata(client); + struct regmap *regmap =3D i2c_get_clientdata(client); =20 /* First we ensure that the "update flag" is not set, we read the * time and date then re-read the "update flag". If the update flag * has been set, we know that the time has changed during the read so * we repeat the whole process again. */ - err =3D regmap_read(rx8581->regmap, RX8581_REG_FLAG, &data); + err =3D regmap_read(regmap, RX8581_REG_FLAG, &data); if (err < 0) return err; =20 @@ -91,20 +87,20 @@ static int rx8581_rtc_read_time(struct device *dev, str= uct rtc_time *tm) do { /* If update flag set, clear it */ if (data & RX8581_FLAG_UF) { - err =3D regmap_write(rx8581->regmap, RX8581_REG_FLAG, - data & ~RX8581_FLAG_UF); + err =3D regmap_write(regmap, RX8581_REG_FLAG, + data & ~RX8581_FLAG_UF); if (err < 0) return err; } =20 /* Now read time and date */ - err =3D regmap_bulk_read(rx8581->regmap, RX8581_REG_SC, date, + err =3D regmap_bulk_read(regmap, RX8581_REG_SC, date, sizeof(date)); if (err < 0) return err; =20 /* Check flag register */ - err =3D regmap_read(rx8581->regmap, RX8581_REG_FLAG, &data); + err =3D regmap_read(regmap, RX8581_REG_FLAG, &data); if (err < 0) return err; } while (data & RX8581_FLAG_UF); @@ -136,7 +132,7 @@ static int rx8581_rtc_set_time(struct device *dev, stru= ct rtc_time *tm) struct i2c_client *client =3D to_i2c_client(dev); int err; unsigned char buf[7]; - struct rx8581 *rx8581 =3D i2c_get_clientdata(client); + struct regmap *regmap =3D i2c_get_clientdata(client); =20 dev_dbg(dev, "%s: secs=3D%d, mins=3D%d, hours=3D%d, " "mday=3D%d, mon=3D%d, year=3D%d, wday=3D%d\n", @@ -159,25 +155,23 @@ static int rx8581_rtc_set_time(struct device *dev, st= ruct rtc_time *tm) buf[RX8581_REG_DW] =3D (0x1 << tm->tm_wday); =20 /* Stop the clock */ - err =3D regmap_update_bits(rx8581->regmap, RX8581_REG_CTRL, + err =3D regmap_update_bits(regmap, RX8581_REG_CTRL, RX8581_CTRL_STOP, RX8581_CTRL_STOP); if (err < 0) return err; =20 /* write register's data */ - err =3D regmap_bulk_write(rx8581->regmap, RX8581_REG_SC, - buf, sizeof(buf)); + err =3D regmap_bulk_write(regmap, RX8581_REG_SC, buf, sizeof(buf)); if (err < 0) return err; =20 /* get VLF and clear it */ - err =3D regmap_update_bits(rx8581->regmap, RX8581_REG_FLAG, - RX8581_FLAG_VLF, 0); + err =3D regmap_update_bits(regmap, RX8581_REG_FLAG, RX8581_FLAG_VLF, 0); if (err < 0) return err; =20 /* Restart the clock */ - return regmap_update_bits(rx8581->regmap, RX8581_REG_CTRL, + return regmap_update_bits(regmap, RX8581_REG_CTRL, RX8581_CTRL_STOP, 0); } =20 @@ -189,29 +183,27 @@ static const struct rtc_class_ops rx8581_rtc_ops =3D { static int rx8571_nvram_read(void *priv, unsigned int offset, void *val, size_t bytes) { - struct rx8581 *rx8581 =3D priv; + struct regmap *regmap =3D priv; =20 - return regmap_bulk_read(rx8581->regmap, RX8571_USER_RAM + offset, - val, bytes); + return regmap_bulk_read(regmap, RX8571_USER_RAM + offset, val, bytes); } =20 static int rx8571_nvram_write(void *priv, unsigned int offset, void *val, size_t bytes) { - struct rx8581 *rx8581 =3D priv; + struct regmap *regmap =3D priv; =20 - return regmap_bulk_write(rx8581->regmap, RX8571_USER_RAM + offset, - val, bytes); + return regmap_bulk_write(regmap, RX8571_USER_RAM + offset, val, bytes); } =20 static int rx85x1_nvram_read(void *priv, unsigned int offset, void *val, size_t bytes) { - struct rx8581 *rx8581 =3D priv; + struct regmap *regmap =3D priv; unsigned int tmp_val; int ret; =20 - ret =3D regmap_read(rx8581->regmap, RX8581_REG_RAM, &tmp_val); + ret =3D regmap_read(regmap, RX8581_REG_RAM, &tmp_val); (*(unsigned char *)val) =3D (unsigned char) tmp_val; =20 return ret; @@ -220,12 +212,11 @@ static int rx85x1_nvram_read(void *priv, unsigned int= offset, void *val, static int rx85x1_nvram_write(void *priv, unsigned int offset, void *val, size_t bytes) { - struct rx8581 *rx8581 =3D priv; + struct regmap *regmap =3D priv; unsigned char tmp_val; =20 tmp_val =3D *((unsigned char *)val); - return regmap_write(rx8581->regmap, RX8581_REG_RAM, - (unsigned int)tmp_val); + return regmap_write(regmap, RX8581_REG_RAM, (unsigned int)tmp_val); } =20 static const struct rx85x1_config rx8581_config =3D { @@ -248,7 +239,7 @@ static const struct rx85x1_config rx8571_config =3D { =20 static int rx8581_probe(struct i2c_client *client) { - struct rx8581 *rx8581; + struct regmap *regmap; const struct rx85x1_config *config =3D &rx8581_config; const void *data =3D of_device_get_match_data(&client->dev); struct rtc_device *rtc; @@ -276,15 +267,11 @@ static int rx8581_probe(struct i2c_client *client) if (data) config =3D data; =20 - rx8581 =3D devm_kzalloc(&client->dev, sizeof(struct rx8581), GFP_KERNEL); - if (!rx8581) - return -ENOMEM; - - i2c_set_clientdata(client, rx8581); + regmap =3D devm_regmap_init_i2c(client, &config->regmap); + if (IS_ERR(regmap)) + return PTR_ERR(regmap); =20 - rx8581->regmap =3D devm_regmap_init_i2c(client, &config->regmap); - if (IS_ERR(rx8581->regmap)) - return PTR_ERR(rx8581->regmap); + i2c_set_clientdata(client, regmap); =20 rtc =3D devm_rtc_allocate_device(&client->dev); if (IS_ERR(rtc)) @@ -299,7 +286,7 @@ static int rx8581_probe(struct i2c_client *client) ret =3D devm_rtc_register_device(rtc); =20 for (i =3D 0; i < config->num_nvram; i++) { - nvmem_cfg[i].priv =3D rx8581; + nvmem_cfg[i].priv =3D regmap; devm_rtc_nvmem_register(rtc, &nvmem_cfg[i]); } =20 --=20 2.48.1.711.g2feabab25a-goog