“fb1c8f93d869b34cacb8b8932e2b83d96a19d720”上不存在“include/linux/rwlock_api_smp.h”
提交 2907e031 编写于 作者: J Joerg Schambacher 提交者: Zheng Zengkai

Fixes a problem when module probes before i2c module is available

raspberrypi inclusion
category: feature
bugzilla: 50432

--------------------------------

The driver crashed while a NULL pointer returned by i2c_get_adapter()
has been used to access the i2c bus functions.
The headphone probing function hb_hp_probe() now returns -EPROBE_DEFER
in case the i2c module has not been loaded yet.
Signed-off-by: NJoerg Schambacher <joerg@i2audio.com>
Signed-off-by: NFang Yafen <yafen@iscas.ac.cn>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 fcd64917
...@@ -315,12 +315,14 @@ static int hb_hp_detect(void) ...@@ -315,12 +315,14 @@ static int hb_hp_detect(void)
{ {
struct i2c_adapter *adap = i2c_get_adapter(1); struct i2c_adapter *adap = i2c_get_adapter(1);
int ret; int ret;
struct i2c_client tpa_i2c_client = { struct i2c_client tpa_i2c_client = {
.addr = 0x60, .addr = 0x60,
.adapter = adap, .adapter = adap,
}; };
if (!adap)
return -EPROBE_DEFER; /* I2C module not yet available */
ret = i2c_smbus_read_byte(&tpa_i2c_client) >= 0; ret = i2c_smbus_read_byte(&tpa_i2c_client) >= 0;
i2c_put_adapter(adap); i2c_put_adapter(adap);
return ret; return ret;
...@@ -342,7 +344,10 @@ static int snd_rpi_hifiberry_dacplus_probe(struct platform_device *pdev) ...@@ -342,7 +344,10 @@ static int snd_rpi_hifiberry_dacplus_probe(struct platform_device *pdev)
struct of_changeset ocs; struct of_changeset ocs;
/* probe for head phone amp */ /* probe for head phone amp */
if (hb_hp_detect()) { ret = hb_hp_detect();
if (ret < 0)
return ret;
if (ret) {
card->aux_dev = hifiberry_dacplus_aux_devs; card->aux_dev = hifiberry_dacplus_aux_devs;
card->num_aux_devs = card->num_aux_devs =
ARRAY_SIZE(hifiberry_dacplus_aux_devs); ARRAY_SIZE(hifiberry_dacplus_aux_devs);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册