Skip to content

Commit ce4a8ff

Browse files
committed
[Edgecore][as4625-54p/54t] Support kernel 6.1 and bookworm
Signed-off-by: Brandon Chuang <[email protected]>
1 parent 5bec164 commit ce4a8ff

File tree

6 files changed

+15
-66
lines changed

6 files changed

+15
-66
lines changed

device/accton/x86_64-accton_as4625_54p-r0/sonic_platform/helper.py

-7
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,6 @@ def pci_get_value(self, resource, offset):
3737
status = False
3838
return status, result
3939

40-
def run_interactive_command(self, cmd):
41-
try:
42-
os.system(cmd)
43-
except Exception:
44-
return False
45-
return True
46-
4740
def read_txt_file(self, file_path):
4841
try:
4942
with open(file_path, encoding='unicode_escape', errors='replace') as fd:

platform/broadcom/sonic-platform-modules-accton/as4625-54p/modules/x86-64-accton-as4625-54p-cpld.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ static int as4625_cpld_probe(struct i2c_client *client,
445445
return ret;
446446
}
447447

448-
static int as4625_cpld_remove(struct i2c_client *client)
448+
static void as4625_cpld_remove(struct i2c_client *client)
449449
{
450450
struct as4625_cpld_data *data = i2c_get_clientdata(client);
451451
const struct attribute_group *group = NULL;
@@ -466,7 +466,6 @@ static int as4625_cpld_remove(struct i2c_client *client)
466466
}
467467

468468
kfree(data);
469-
return 0;
470469
}
471470

472471
static int as4625_cpld_read_internal(struct i2c_client *client, u8 reg)

platform/broadcom/sonic-platform-modules-accton/as4625-54p/modules/x86-64-accton-as4625-54p-fan.c

+5-18
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ DECLARE_FAN_TARGET_RPM_SENSOR_DEV_ATTR(1);
146146
DECLARE_FAN_TARGET_RPM_SENSOR_DEV_ATTR(2);
147147
DECLARE_FAN_TARGET_RPM_SENSOR_DEV_ATTR(3);
148148

149-
static struct attribute *as4625_fan_attributes[] = {
149+
static struct attribute *as4625_fan_attrs[] = {
150150
/* fan related attributes */
151151
DECLARE_FAN_FAULT_ATTR(1),
152152
DECLARE_FAN_FAULT_ATTR(2),
@@ -166,6 +166,8 @@ static struct attribute *as4625_fan_attributes[] = {
166166
NULL
167167
};
168168

169+
ATTRIBUTE_GROUPS(as4625_fan);
170+
169171
#define FAN_DUTY_CYCLE_REG_MASK 0x0F
170172
#define FAN_MAX_DUTY_CYCLE 100
171173
#define FAN_REG_VAL_TO_SPEED_RPM_STEP 150
@@ -292,10 +294,6 @@ static ssize_t fan_show_value(struct device *dev, struct device_attribute *da,
292294
return ret;
293295
}
294296

295-
static const struct attribute_group as4625_fan_group = {
296-
.attrs = as4625_fan_attributes,
297-
};
298-
299297
static struct as4625_fan_data *as4625_fan_update_device(struct device *dev)
300298
{
301299
if (time_after(jiffies, data->last_updated + HZ + HZ / 2) ||
@@ -332,30 +330,19 @@ static int as4625_fan_probe(struct platform_device *pdev)
332330
{
333331
int status;
334332

335-
data->hwmon_dev = hwmon_device_register_with_info(&pdev->dev,
336-
DRVNAME, NULL, NULL, NULL);
333+
data->hwmon_dev = devm_hwmon_device_register_with_groups(&pdev->dev,
334+
DRVNAME, data, as4625_fan_groups);
337335
if (IS_ERR(data->hwmon_dev)) {
338336
status = PTR_ERR(data->hwmon_dev);
339337
return status;
340338
}
341339

342-
/* Register sysfs hooks */
343-
status = sysfs_create_group(&data->hwmon_dev->kobj, &as4625_fan_group);
344-
if (status)
345-
goto exit_remove;
346-
347340
dev_info(&pdev->dev, "device created\n");
348341
return 0;
349-
350-
exit_remove:
351-
hwmon_device_unregister(data->hwmon_dev);
352-
return status;
353342
}
354343

355344
static int as4625_fan_remove(struct platform_device *pdev)
356345
{
357-
sysfs_remove_group(&data->hwmon_dev->kobj, &as4625_fan_group);
358-
hwmon_device_unregister(data->hwmon_dev);
359346
return 0;
360347
}
361348

platform/broadcom/sonic-platform-modules-accton/as4625-54p/modules/x86-64-accton-as4625-54p-psu.c

+1-18
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ static const unsigned short normal_i2c[] = { I2C_CLIENT_END };
6565
/* Each client has this additional data
6666
*/
6767
struct as4625_54p_psu_data {
68-
struct device *hwmon_dev;
6968
struct mutex update_lock;
7069
char valid; /* !=0 if registers are valid */
7170
unsigned long last_updated; /* In jiffies */
@@ -203,35 +202,19 @@ static int as4625_54p_psu_probe(struct i2c_client *client,
203202
goto exit_free;
204203
}
205204

206-
data->hwmon_dev = hwmon_device_register_with_info(&client->dev,
207-
DRVNAME, NULL, NULL, NULL);
208-
if (IS_ERR(data->hwmon_dev)) {
209-
status = PTR_ERR(data->hwmon_dev);
210-
goto exit_remove;
211-
}
212-
213-
dev_info(&client->dev, "%s: psu '%s'\n",
214-
dev_name(data->hwmon_dev), client->name);
215-
216205
return 0;
217-
218-
exit_remove:
219-
sysfs_remove_group(&client->dev.kobj, &as4625_54p_psu_group);
220206
exit_free:
221207
kfree(data);
222208
exit:
223209
return status;
224210
}
225211

226-
static int as4625_54p_psu_remove(struct i2c_client *client)
212+
static void as4625_54p_psu_remove(struct i2c_client *client)
227213
{
228214
struct as4625_54p_psu_data *data = i2c_get_clientdata(client);
229215

230-
hwmon_device_unregister(data->hwmon_dev);
231216
sysfs_remove_group(&client->dev.kobj, &as4625_54p_psu_group);
232217
kfree(data);
233-
234-
return 0;
235218
}
236219

237220
enum psu_index

platform/broadcom/sonic-platform-modules-accton/as4625-54t/modules/x86-64-accton-as4625-54t-psu.c

+1-18
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ static const unsigned short normal_i2c[] = { I2C_CLIENT_END };
6565
/* Each client has this additional data
6666
*/
6767
struct as4625_54t_psu_data {
68-
struct device *hwmon_dev;
6968
struct mutex update_lock;
7069
char valid; /* !=0 if registers are valid */
7170
unsigned long last_updated; /* In jiffies */
@@ -203,35 +202,19 @@ static int as4625_54t_psu_probe(struct i2c_client *client,
203202
goto exit_free;
204203
}
205204

206-
data->hwmon_dev = hwmon_device_register_with_info(&client->dev,
207-
DRVNAME, NULL, NULL, NULL);
208-
if (IS_ERR(data->hwmon_dev)) {
209-
status = PTR_ERR(data->hwmon_dev);
210-
goto exit_remove;
211-
}
212-
213-
dev_info(&client->dev, "%s: psu '%s'\n",
214-
dev_name(data->hwmon_dev), client->name);
215-
216205
return 0;
217-
218-
exit_remove:
219-
sysfs_remove_group(&client->dev.kobj, &as4625_54t_psu_group);
220206
exit_free:
221207
kfree(data);
222208
exit:
223209
return status;
224210
}
225211

226-
static int as4625_54t_psu_remove(struct i2c_client *client)
212+
static void as4625_54t_psu_remove(struct i2c_client *client)
227213
{
228214
struct as4625_54t_psu_data *data = i2c_get_clientdata(client);
229215

230-
hwmon_device_unregister(data->hwmon_dev);
231216
sysfs_remove_group(&client->dev.kobj, &as4625_54t_psu_group);
232217
kfree(data);
233-
234-
return 0;
235218
}
236219

237220
enum psu_index

platform/broadcom/sonic-platform-modules-accton/common/modules/ym2651y.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
#include <linux/sysfs.h>
3333
#include <linux/slab.h>
3434

35+
#define __STDC_WANT_LIB_EXT1__ 1
36+
#include <linux/string.h>
37+
3538
#define MAX_FAN_DUTY_CYCLE 100
3639

3740
/* Addresses scanned
@@ -514,7 +517,6 @@ static void ym2651y_remove(struct i2c_client *client)
514517
hwmon_device_unregister(data->hwmon_dev);
515518
sysfs_remove_group(&client->dev.kobj, &ym2651y_group);
516519
kfree(data);
517-
518520
}
519521

520522
static const struct i2c_device_id ym2651y_id[] = {
@@ -672,7 +674,11 @@ static struct ym2651y_data *ym2651y_update_device(struct device *dev)
672674
goto exit;
673675
}
674676

677+
#ifdef __STDC_LIB_EXT1__
678+
strncpy_s(data->fan_dir, sizeof(data->fan_dir), fan_dir + 1, ARRAY_SIZE(data->fan_dir) - 1);
679+
else
675680
strncpy(data->fan_dir, fan_dir+1, ARRAY_SIZE(data->fan_dir)-1);
681+
#endif
676682
data->fan_dir[ARRAY_SIZE(data->fan_dir)-1] = '\0';
677683

678684
/* Read mfr_id */
@@ -769,5 +775,3 @@ module_i2c_driver(ym2651y_driver);
769775
MODULE_AUTHOR("Brandon Chuang <[email protected]>");
770776
MODULE_DESCRIPTION("3Y Power YM-2651Y driver");
771777
MODULE_LICENSE("GPL");
772-
773-

0 commit comments

Comments
 (0)