2023-03-15 08:21:53

by Javier Carrasco

[permalink] [raw]
Subject: [PATCH 0/2] rtc: pcf8523: standardize code

A series of patches have introduced coding-style issues that make
checkpatch generate a number of easy-to-fix errors and warnings.
Furthermore, some cleanups and refactoring operations left an
unnecessary OR operation behind. These patches claim tosolve
these minor issues.

Javier Carrasco (2):
rtc: pcf8523: fix coding-style issues
rtc: pcf8523: remove unnecessary OR operation

drivers/rtc/rtc-pcf8523.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)

--
2.37.2



2023-03-15 08:22:08

by Javier Carrasco

[permalink] [raw]
Subject: [PATCH 1/2] rtc: pcf8523: fix coding-style issues

Minor modifications for coding-style correctness (tabs, spaces and blank
lines before and after brackets). In total 7 errors, 3 warnings and 1
check where removed from the checkpatch output without damaging code
readability.

Signed-off-by: Javier Carrasco <[email protected]>
---
drivers/rtc/rtc-pcf8523.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/rtc/rtc-pcf8523.c b/drivers/rtc/rtc-pcf8523.c
index 2e111cdb94f7..ccb5aa690433 100644
--- a/drivers/rtc/rtc-pcf8523.c
+++ b/drivers/rtc/rtc-pcf8523.c
@@ -21,7 +21,7 @@
#define PCF8523_CONTROL2_AF BIT(3)

#define PCF8523_REG_CONTROL3 0x02
-#define PCF8523_CONTROL3_PM GENMASK(7,5)
+#define PCF8523_CONTROL3_PM GENMASK(7, 5)
#define PCF8523_PM_STANDBY 0x7
#define PCF8523_CONTROL3_BLF BIT(2) /* battery low bit, read-only */
#define PCF8523_CONTROL3_BSF BIT(3)
@@ -234,8 +234,7 @@ static int pcf8523_param_get(struct device *dev, struct rtc_param *param)
int ret;
u32 value;

- switch(param->param) {
-
+ switch (param->param) {
case RTC_PARAM_BACKUP_SWITCH_MODE:
ret = regmap_read(pcf8523->regmap, PCF8523_REG_CONTROL3, &value);
if (ret < 0)
@@ -243,7 +242,7 @@ static int pcf8523_param_get(struct device *dev, struct rtc_param *param)

value = FIELD_GET(PCF8523_CONTROL3_PM, value);

- switch(value) {
+ switch (value) {
case 0x0:
case 0x4:
param->uvalue = RTC_BSM_LEVEL;
@@ -273,7 +272,7 @@ static int pcf8523_param_set(struct device *dev, struct rtc_param *param)
struct pcf8523 *pcf8523 = dev_get_drvdata(dev);
u8 mode;

- switch(param->param) {
+ switch (param->param) {
case RTC_PARAM_BACKUP_SWITCH_MODE:
switch (param->uvalue) {
case RTC_BSM_DISABLED:
@@ -385,9 +384,9 @@ static const struct rtc_class_ops pcf8523_rtc_ops = {
};

static const struct regmap_config regmap_config = {
- .reg_bits = 8,
- .val_bits = 8,
- .max_register = 0x13,
+ .reg_bits = 8,
+ .val_bits = 8,
+ .max_register = 0x13,
};

static int pcf8523_probe(struct i2c_client *client)
--
2.37.2


2023-03-15 08:22:11

by Javier Carrasco

[permalink] [raw]
Subject: [PATCH 2/2] rtc: pcf8523: remove unnecessary OR operation

The value variable is initialized to 0 and it is not used to set any
other bits rather than the one that defines the capacitor value. Setting
this capacitor value is the only purpose of the function where the
variable is defined and therefore the OR operation does not apply as a
way to foresee functionality extensions either.

Signed-off-by: Javier Carrasco <[email protected]>
---
drivers/rtc/rtc-pcf8523.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-pcf8523.c b/drivers/rtc/rtc-pcf8523.c
index ccb5aa690433..e7115ebef707 100644
--- a/drivers/rtc/rtc-pcf8523.c
+++ b/drivers/rtc/rtc-pcf8523.c
@@ -65,7 +65,7 @@ static int pcf8523_load_capacitance(struct pcf8523 *pcf8523, struct device_node
load);
fallthrough;
case 12500:
- value |= PCF8523_CONTROL1_CAP_SEL;
+ value = PCF8523_CONTROL1_CAP_SEL;
break;
case 7000:
break;
--
2.37.2


2023-03-17 22:25:36

by Alexandre Belloni

[permalink] [raw]
Subject: Re: [PATCH 0/2] rtc: pcf8523: standardize code


On Wed, 15 Mar 2023 09:20:19 +0100, Javier Carrasco wrote:
> A series of patches have introduced coding-style issues that make
> checkpatch generate a number of easy-to-fix errors and warnings.
> Furthermore, some cleanups and refactoring operations left an
> unnecessary OR operation behind. These patches claim tosolve
> these minor issues.
>
> Javier Carrasco (2):
> rtc: pcf8523: fix coding-style issues
> rtc: pcf8523: remove unnecessary OR operation
>
> [...]

Applied, thanks!

[1/2] rtc: pcf8523: fix coding-style issues
commit: b48cc753c017d1f5c6e317538205d40e70d04f3c
[2/2] rtc: pcf8523: remove unnecessary OR operation
commit: dc87fad6448fc574456516404469c0c2c48d642e

Best regards,

--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com