1 From 4be98b29d123fc7615ea8404fbda450ec8acb084 Mon Sep 17 00:00:00 2001
2 From: Joerg Schambacher <joerg@i2audio.com>
3 Date: Fri, 16 Oct 2020 15:17:07 +0200
4 Subject: [PATCH] Fixes a problem when module probes before i2c module
7 The driver crashed while a NULL pointer returned by i2c_get_adapter()
8 has been used to access the i2c bus functions.
9 The headphone probing function hb_hp_probe() now returns -EPROBE_DEFER
10 in case the i2c module has not been loaded yet.
12 Signed-off-by: Joerg Schambacher <joerg@i2audio.com>
14 sound/soc/bcm/hifiberry_dacplus.c | 9 +++++++--
15 1 file changed, 7 insertions(+), 2 deletions(-)
17 --- a/sound/soc/bcm/hifiberry_dacplus.c
18 +++ b/sound/soc/bcm/hifiberry_dacplus.c
19 @@ -315,12 +315,14 @@ static int hb_hp_detect(void)
21 struct i2c_adapter *adap = i2c_get_adapter(1);
24 struct i2c_client tpa_i2c_client = {
30 + return -EPROBE_DEFER; /* I2C module not yet available */
32 ret = i2c_smbus_read_byte(&tpa_i2c_client) >= 0;
33 i2c_put_adapter(adap);
35 @@ -342,7 +344,10 @@ static int snd_rpi_hifiberry_dacplus_pro
36 struct of_changeset ocs;
38 /* probe for head phone amp */
39 - if (hb_hp_detect()) {
40 + ret = hb_hp_detect();
44 card->aux_dev = hifiberry_dacplus_aux_devs;
46 ARRAY_SIZE(hifiberry_dacplus_aux_devs);