Skip to content

Commit 73c4638

Browse files
yaodehaungalexandrebelloni
authored andcommitted
rtc: s35390a: use u8 instead of char for register buffer
The register buffer in s35390a_get_reg() was previously defined as `char *buf`. This is not ideal since register data represents raw binary values rather than textual data. Switch the type to `u8 *buf` to better reflect its intended usage and to avoid potential issues with sign extension when handling register values on platforms where `char` is signed by default. This change improves type safety and makes the code consistent with other RTC drivers that operate on raw register data. Signed-off-by: Nick Huang <sef1548@gmail.com> Link: https://patch.msgid.link/20250920174224.108795-1-sef1548@gmail.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
1 parent 9d6d6b0 commit 73c4638

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

drivers/rtc/rtc-s35390a.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ struct s35390a {
6666
int twentyfourhour;
6767
};
6868

69-
static int s35390a_set_reg(struct s35390a *s35390a, int reg, char *buf, int len)
69+
static int s35390a_set_reg(struct s35390a *s35390a, int reg, u8 *buf, int len)
7070
{
7171
struct i2c_client *client = s35390a->client[reg];
7272
struct i2c_msg msg[] = {
@@ -83,7 +83,7 @@ static int s35390a_set_reg(struct s35390a *s35390a, int reg, char *buf, int len)
8383
return 0;
8484
}
8585

86-
static int s35390a_get_reg(struct s35390a *s35390a, int reg, char *buf, int len)
86+
static int s35390a_get_reg(struct s35390a *s35390a, int reg, u8 *buf, int len)
8787
{
8888
struct i2c_client *client = s35390a->client[reg];
8989
struct i2c_msg msg[] = {
@@ -168,7 +168,7 @@ static int s35390a_read_status(struct s35390a *s35390a, char *status1)
168168

169169
static int s35390a_disable_test_mode(struct s35390a *s35390a)
170170
{
171-
char buf[1];
171+
u8 buf[1];
172172

173173
if (s35390a_get_reg(s35390a, S35390A_CMD_STATUS2, buf, sizeof(buf)) < 0)
174174
return -EIO;
@@ -210,7 +210,7 @@ static int s35390a_rtc_set_time(struct device *dev, struct rtc_time *tm)
210210
struct i2c_client *client = to_i2c_client(dev);
211211
struct s35390a *s35390a = i2c_get_clientdata(client);
212212
int i;
213-
char buf[7], status;
213+
u8 buf[7], status;
214214

215215
dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d mday=%d, "
216216
"mon=%d, year=%d, wday=%d\n", __func__, tm->tm_sec,
@@ -239,7 +239,7 @@ static int s35390a_rtc_read_time(struct device *dev, struct rtc_time *tm)
239239
{
240240
struct i2c_client *client = to_i2c_client(dev);
241241
struct s35390a *s35390a = i2c_get_clientdata(client);
242-
char buf[7], status;
242+
u8 buf[7], status;
243243
int i, err;
244244

245245
if (s35390a_read_status(s35390a, &status) == 1)
@@ -273,7 +273,7 @@ static int s35390a_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
273273
{
274274
struct i2c_client *client = to_i2c_client(dev);
275275
struct s35390a *s35390a = i2c_get_clientdata(client);
276-
char buf[3], sts = 0;
276+
u8 buf[3], sts = 0;
277277
int err, i;
278278

279279
dev_dbg(&client->dev, "%s: alm is secs=%d, mins=%d, hours=%d mday=%d, "\
@@ -326,7 +326,7 @@ static int s35390a_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
326326
{
327327
struct i2c_client *client = to_i2c_client(dev);
328328
struct s35390a *s35390a = i2c_get_clientdata(client);
329-
char buf[3], sts;
329+
u8 buf[3], sts;
330330
int i, err;
331331

332332
err = s35390a_get_reg(s35390a, S35390A_CMD_STATUS2, &sts, sizeof(sts));
@@ -383,7 +383,7 @@ static int s35390a_rtc_ioctl(struct device *dev, unsigned int cmd,
383383
{
384384
struct i2c_client *client = to_i2c_client(dev);
385385
struct s35390a *s35390a = i2c_get_clientdata(client);
386-
char sts;
386+
u8 sts;
387387
int err;
388388

389389
switch (cmd) {
@@ -422,7 +422,7 @@ static int s35390a_probe(struct i2c_client *client)
422422
unsigned int i;
423423
struct s35390a *s35390a;
424424
struct rtc_device *rtc;
425-
char buf, status1;
425+
u8 buf, status1;
426426
struct device *dev = &client->dev;
427427

428428
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))

0 commit comments

Comments
 (0)