Skip to content

Commit 7c85154

Browse files
committed
Merge branches 'acpi-numa', 'acpi-glue', 'acpi-config' and 'acpi-pmic'
* acpi-numa: ACPI: Add LoongArch support for ACPI_PROCESSOR/ACPI_NUMA * acpi-glue: driver core: Split device_platform_notify() software nodes: Split software_node_notify() ACPI: glue: Eliminate acpi_platform_notify() ACPI: bus: Rename functions to avoid name collision ACPI: glue: Change return type of two functions to void ACPI: glue: Rearrange acpi_device_notify() * acpi-config: ACPI: configfs: Make get_header() to return error pointer ACPI: configfs: Use sysfs_emit() in "show" functions * acpi-pmic: ACPI / PMIC: XPower: optimize MIPI PMIQ sequence I2C-bus accesses ACPI / PMIC: XPower: optimize I2C-bus accesses
5 parents b46a8ed + b1121e2 + b2ebd9d + 45c16fe + fd080a0 commit 7c85154

File tree

12 files changed

+149
-136
lines changed

12 files changed

+149
-136
lines changed

drivers/acpi/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,9 @@ config ACPI_CPPC_LIB
280280

281281
config ACPI_PROCESSOR
282282
tristate "Processor"
283-
depends on X86 || IA64 || ARM64
283+
depends on X86 || IA64 || ARM64 || LOONGARCH
284284
select ACPI_PROCESSOR_IDLE
285-
select ACPI_CPU_FREQ_PSS if X86 || IA64
285+
select ACPI_CPU_FREQ_PSS if X86 || IA64 || LOONGARCH
286286
default y
287287
help
288288
This driver adds support for the ACPI Processor package. It is required

drivers/acpi/acpi_configfs.c

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,16 @@ static inline struct acpi_table_header *get_header(struct config_item *cfg)
7070
if (!table->header)
7171
pr_err("table not loaded\n");
7272

73-
return table->header;
73+
return table->header ?: ERR_PTR(-EINVAL);
7474
}
7575

7676
static ssize_t acpi_table_aml_read(struct config_item *cfg,
7777
void *data, size_t size)
7878
{
7979
struct acpi_table_header *h = get_header(cfg);
8080

81-
if (!h)
82-
return -EINVAL;
81+
if (IS_ERR(h))
82+
return PTR_ERR(h);
8383

8484
if (data)
8585
memcpy(data, h, h->length);
@@ -100,82 +100,82 @@ static ssize_t acpi_table_signature_show(struct config_item *cfg, char *str)
100100
{
101101
struct acpi_table_header *h = get_header(cfg);
102102

103-
if (!h)
104-
return -EINVAL;
103+
if (IS_ERR(h))
104+
return PTR_ERR(h);
105105

106-
return sprintf(str, "%.*s\n", ACPI_NAMESEG_SIZE, h->signature);
106+
return sysfs_emit(str, "%.*s\n", ACPI_NAMESEG_SIZE, h->signature);
107107
}
108108

109109
static ssize_t acpi_table_length_show(struct config_item *cfg, char *str)
110110
{
111111
struct acpi_table_header *h = get_header(cfg);
112112

113-
if (!h)
114-
return -EINVAL;
113+
if (IS_ERR(h))
114+
return PTR_ERR(h);
115115

116-
return sprintf(str, "%d\n", h->length);
116+
return sysfs_emit(str, "%d\n", h->length);
117117
}
118118

119119
static ssize_t acpi_table_revision_show(struct config_item *cfg, char *str)
120120
{
121121
struct acpi_table_header *h = get_header(cfg);
122122

123-
if (!h)
124-
return -EINVAL;
123+
if (IS_ERR(h))
124+
return PTR_ERR(h);
125125

126-
return sprintf(str, "%d\n", h->revision);
126+
return sysfs_emit(str, "%d\n", h->revision);
127127
}
128128

129129
static ssize_t acpi_table_oem_id_show(struct config_item *cfg, char *str)
130130
{
131131
struct acpi_table_header *h = get_header(cfg);
132132

133-
if (!h)
134-
return -EINVAL;
133+
if (IS_ERR(h))
134+
return PTR_ERR(h);
135135

136-
return sprintf(str, "%.*s\n", ACPI_OEM_ID_SIZE, h->oem_id);
136+
return sysfs_emit(str, "%.*s\n", ACPI_OEM_ID_SIZE, h->oem_id);
137137
}
138138

139139
static ssize_t acpi_table_oem_table_id_show(struct config_item *cfg, char *str)
140140
{
141141
struct acpi_table_header *h = get_header(cfg);
142142

143-
if (!h)
144-
return -EINVAL;
143+
if (IS_ERR(h))
144+
return PTR_ERR(h);
145145

146-
return sprintf(str, "%.*s\n", ACPI_OEM_TABLE_ID_SIZE, h->oem_table_id);
146+
return sysfs_emit(str, "%.*s\n", ACPI_OEM_TABLE_ID_SIZE, h->oem_table_id);
147147
}
148148

149149
static ssize_t acpi_table_oem_revision_show(struct config_item *cfg, char *str)
150150
{
151151
struct acpi_table_header *h = get_header(cfg);
152152

153-
if (!h)
154-
return -EINVAL;
153+
if (IS_ERR(h))
154+
return PTR_ERR(h);
155155

156-
return sprintf(str, "%d\n", h->oem_revision);
156+
return sysfs_emit(str, "%d\n", h->oem_revision);
157157
}
158158

159159
static ssize_t acpi_table_asl_compiler_id_show(struct config_item *cfg,
160160
char *str)
161161
{
162162
struct acpi_table_header *h = get_header(cfg);
163163

164-
if (!h)
165-
return -EINVAL;
164+
if (IS_ERR(h))
165+
return PTR_ERR(h);
166166

167-
return sprintf(str, "%.*s\n", ACPI_NAMESEG_SIZE, h->asl_compiler_id);
167+
return sysfs_emit(str, "%.*s\n", ACPI_NAMESEG_SIZE, h->asl_compiler_id);
168168
}
169169

170170
static ssize_t acpi_table_asl_compiler_revision_show(struct config_item *cfg,
171171
char *str)
172172
{
173173
struct acpi_table_header *h = get_header(cfg);
174174

175-
if (!h)
176-
return -EINVAL;
175+
if (IS_ERR(h))
176+
return PTR_ERR(h);
177177

178-
return sprintf(str, "%d\n", h->asl_compiler_revision);
178+
return sysfs_emit(str, "%d\n", h->asl_compiler_revision);
179179
}
180180

181181
CONFIGFS_ATTR_RO(acpi_table_, signature);

drivers/acpi/bus.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -498,24 +498,24 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
498498
acpi_evaluate_ost(handle, type, ost_code, NULL);
499499
}
500500

501-
static void acpi_device_notify(acpi_handle handle, u32 event, void *data)
501+
static void acpi_notify_device(acpi_handle handle, u32 event, void *data)
502502
{
503503
struct acpi_device *device = data;
504504

505505
device->driver->ops.notify(device, event);
506506
}
507507

508-
static void acpi_device_notify_fixed(void *data)
508+
static void acpi_notify_device_fixed(void *data)
509509
{
510510
struct acpi_device *device = data;
511511

512512
/* Fixed hardware devices have no handles */
513-
acpi_device_notify(NULL, ACPI_FIXED_HARDWARE_EVENT, device);
513+
acpi_notify_device(NULL, ACPI_FIXED_HARDWARE_EVENT, device);
514514
}
515515

516516
static u32 acpi_device_fixed_event(void *data)
517517
{
518-
acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_device_notify_fixed, data);
518+
acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_notify_device_fixed, data);
519519
return ACPI_INTERRUPT_HANDLED;
520520
}
521521

@@ -536,7 +536,7 @@ static int acpi_device_install_notify_handler(struct acpi_device *device)
536536
else
537537
status = acpi_install_notify_handler(device->handle,
538538
ACPI_DEVICE_NOTIFY,
539-
acpi_device_notify,
539+
acpi_notify_device,
540540
device);
541541

542542
if (ACPI_FAILURE(status))
@@ -554,7 +554,7 @@ static void acpi_device_remove_notify_handler(struct acpi_device *device)
554554
acpi_device_fixed_event);
555555
else
556556
acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY,
557-
acpi_device_notify);
557+
acpi_notify_device);
558558
}
559559

560560
/* Handle events targeting \_SB device (at present only graceful shutdown) */

drivers/acpi/glue.c

Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -285,29 +285,27 @@ int acpi_unbind_one(struct device *dev)
285285
}
286286
EXPORT_SYMBOL_GPL(acpi_unbind_one);
287287

288-
static int acpi_device_notify(struct device *dev)
288+
void acpi_device_notify(struct device *dev)
289289
{
290290
struct acpi_bus_type *type = acpi_get_bus_type(dev);
291291
struct acpi_device *adev;
292292
int ret;
293293

294294
ret = acpi_bind_one(dev, NULL);
295-
if (ret && type) {
296-
struct acpi_device *adev;
295+
if (ret) {
296+
if (!type)
297+
goto err;
297298

298299
adev = type->find_companion(dev);
299300
if (!adev) {
300-
pr_debug("Unable to get handle for %s\n", dev_name(dev));
301-
ret = -ENODEV;
302-
goto out;
301+
dev_dbg(dev, "ACPI companion not found\n");
302+
goto err;
303303
}
304304
ret = acpi_bind_one(dev, adev);
305305
if (ret)
306-
goto out;
306+
goto err;
307307
}
308308
adev = ACPI_COMPANION(dev);
309-
if (!adev)
310-
goto out;
311309

312310
if (dev_is_platform(dev))
313311
acpi_configure_pmsi_domain(dev);
@@ -317,27 +315,22 @@ static int acpi_device_notify(struct device *dev)
317315
else if (adev->handler && adev->handler->bind)
318316
adev->handler->bind(dev);
319317

320-
out:
321-
if (!ret) {
322-
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
318+
acpi_handle_debug(ACPI_HANDLE(dev), "Bound to device %s\n",
319+
dev_name(dev));
323320

324-
acpi_get_name(ACPI_HANDLE(dev), ACPI_FULL_PATHNAME, &buffer);
325-
pr_debug("Device %s -> %s\n", dev_name(dev), (char *)buffer.pointer);
326-
kfree(buffer.pointer);
327-
} else {
328-
pr_debug("Device %s -> No ACPI support\n", dev_name(dev));
329-
}
321+
return;
330322

331-
return ret;
323+
err:
324+
dev_dbg(dev, "No ACPI support\n");
332325
}
333326

334-
static int acpi_device_notify_remove(struct device *dev)
327+
void acpi_device_notify_remove(struct device *dev)
335328
{
336329
struct acpi_device *adev = ACPI_COMPANION(dev);
337330
struct acpi_bus_type *type;
338331

339332
if (!adev)
340-
return 0;
333+
return;
341334

342335
type = acpi_get_bus_type(dev);
343336
if (type && type->cleanup)
@@ -346,20 +339,4 @@ static int acpi_device_notify_remove(struct device *dev)
346339
adev->handler->unbind(dev);
347340

348341
acpi_unbind_one(dev);
349-
return 0;
350-
}
351-
352-
int acpi_platform_notify(struct device *dev, enum kobject_action action)
353-
{
354-
switch (action) {
355-
case KOBJ_ADD:
356-
acpi_device_notify(dev);
357-
break;
358-
case KOBJ_REMOVE:
359-
acpi_device_notify_remove(dev);
360-
break;
361-
default:
362-
break;
363-
}
364-
return 0;
365342
}

drivers/acpi/numa/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
config ACPI_NUMA
33
bool "NUMA support"
44
depends on NUMA
5-
depends on (X86 || IA64 || ARM64)
5+
depends on (X86 || IA64 || ARM64 || LOONGARCH)
66
default y if IA64 || ARM64
77

88
config ACPI_HMAT

drivers/acpi/numa/srat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ int __init srat_disabled(void)
206206
return acpi_numa < 0;
207207
}
208208

209-
#if defined(CONFIG_X86) || defined(CONFIG_ARM64)
209+
#if defined(CONFIG_X86) || defined(CONFIG_ARM64) || defined(CONFIG_LOONGARCH)
210210
/*
211211
* Callback for SLIT parsing. pxm_to_node() returns NUMA_NO_NODE for
212212
* I/O localities since SRAT does not list them. I/O localities are

drivers/acpi/pmic/intel_pmic_xpower.c

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,17 @@ static int intel_xpower_pmic_update_power(struct regmap *regmap, int reg,
178178
{
179179
int data, ret;
180180

181-
/* GPIO1 LDO regulator needs special handling */
182-
if (reg == XPOWER_GPI1_CTRL)
183-
return regmap_update_bits(regmap, reg, GPI1_LDO_MASK,
184-
on ? GPI1_LDO_ON : GPI1_LDO_OFF);
185-
186181
ret = iosf_mbi_block_punit_i2c_access();
187182
if (ret)
188183
return ret;
189184

185+
/* GPIO1 LDO regulator needs special handling */
186+
if (reg == XPOWER_GPI1_CTRL) {
187+
ret = regmap_update_bits(regmap, reg, GPI1_LDO_MASK,
188+
on ? GPI1_LDO_ON : GPI1_LDO_OFF);
189+
goto out;
190+
}
191+
190192
if (regmap_read(regmap, reg, &data)) {
191193
ret = -EIO;
192194
goto out;
@@ -234,6 +236,11 @@ static int intel_xpower_pmic_get_raw_temp(struct regmap *regmap, int reg)
234236
return ret;
235237

236238
if (adc_ts_pin_ctrl & AXP288_ADC_TS_CURRENT_ON_OFF_MASK) {
239+
/*
240+
* AXP288_ADC_TS_PIN_CTRL reads are cached by the regmap, so
241+
* this does to a single I2C-transfer, and thus there is no
242+
* need to explicitly call iosf_mbi_block_punit_i2c_access().
243+
*/
237244
ret = regmap_update_bits(regmap, AXP288_ADC_TS_PIN_CTRL,
238245
AXP288_ADC_TS_CURRENT_ON_OFF_MASK,
239246
AXP288_ADC_TS_CURRENT_ON_ONDEMAND);
@@ -244,6 +251,10 @@ static int intel_xpower_pmic_get_raw_temp(struct regmap *regmap, int reg)
244251
usleep_range(6000, 10000);
245252
}
246253

254+
ret = iosf_mbi_block_punit_i2c_access();
255+
if (ret)
256+
return ret;
257+
247258
ret = regmap_bulk_read(regmap, AXP288_GP_ADC_H, buf, 2);
248259
if (ret == 0)
249260
ret = (buf[0] << 4) + ((buf[1] >> 4) & 0x0f);
@@ -254,13 +265,39 @@ static int intel_xpower_pmic_get_raw_temp(struct regmap *regmap, int reg)
254265
AXP288_ADC_TS_CURRENT_ON);
255266
}
256267

268+
iosf_mbi_unblock_punit_i2c_access();
269+
270+
return ret;
271+
}
272+
273+
static int intel_xpower_exec_mipi_pmic_seq_element(struct regmap *regmap,
274+
u16 i2c_address, u32 reg_address,
275+
u32 value, u32 mask)
276+
{
277+
int ret;
278+
279+
if (i2c_address != 0x34) {
280+
pr_err("%s: Unexpected i2c-addr: 0x%02x (reg-addr 0x%x value 0x%x mask 0x%x)\n",
281+
__func__, i2c_address, reg_address, value, mask);
282+
return -ENXIO;
283+
}
284+
285+
ret = iosf_mbi_block_punit_i2c_access();
286+
if (ret)
287+
return ret;
288+
289+
ret = regmap_update_bits(regmap, reg_address, mask, value);
290+
291+
iosf_mbi_unblock_punit_i2c_access();
292+
257293
return ret;
258294
}
259295

260296
static struct intel_pmic_opregion_data intel_xpower_pmic_opregion_data = {
261297
.get_power = intel_xpower_pmic_get_power,
262298
.update_power = intel_xpower_pmic_update_power,
263299
.get_raw_temp = intel_xpower_pmic_get_raw_temp,
300+
.exec_mipi_pmic_seq_element = intel_xpower_exec_mipi_pmic_seq_element,
264301
.power_table = power_table,
265302
.power_table_count = ARRAY_SIZE(power_table),
266303
.thermal_table = thermal_table,

drivers/base/base.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,6 @@ int devtmpfs_delete_node(struct device *dev);
202202
static inline int devtmpfs_create_node(struct device *dev) { return 0; }
203203
static inline int devtmpfs_delete_node(struct device *dev) { return 0; }
204204
#endif
205+
206+
void software_node_notify(struct device *dev);
207+
void software_node_notify_remove(struct device *dev);

0 commit comments

Comments
 (0)