@@ -1753,38 +1753,14 @@ int cs35l41_get_speaker_id(struct device *dev, int amp_index, int num_amps, int
17531753 return speaker_id ;
17541754}
17551755
1756- static int cs35l41_hda_read_acpi (struct cs35l41_hda * cs35l41 , const char * hid , int id )
1756+ int cs35l41_hda_parse_acpi (struct cs35l41_hda * cs35l41 , struct device * physdev , int id )
17571757{
17581758 struct cs35l41_hw_cfg * hw_cfg = & cs35l41 -> hw_cfg ;
17591759 u32 values [HDA_MAX_COMPONENTS ];
1760- struct acpi_device * adev ;
1761- struct device * physdev ;
1762- struct spi_device * spi ;
1763- const char * sub ;
17641760 char * property ;
17651761 size_t nval ;
17661762 int i , ret ;
17671763
1768- adev = acpi_dev_get_first_match_dev (hid , NULL , -1 );
1769- if (!adev ) {
1770- dev_err (cs35l41 -> dev , "Failed to find an ACPI device for %s\n" , hid );
1771- return - ENODEV ;
1772- }
1773-
1774- cs35l41 -> dacpi = adev ;
1775- physdev = get_device (acpi_get_first_physical_node (adev ));
1776-
1777- sub = acpi_get_subsystem_id (ACPI_HANDLE (physdev ));
1778- if (IS_ERR (sub ))
1779- sub = NULL ;
1780- cs35l41 -> acpi_subsystem_id = sub ;
1781-
1782- ret = cs35l41_add_dsd_properties (cs35l41 , physdev , id , hid );
1783- if (!ret ) {
1784- dev_info (cs35l41 -> dev , "Using extra _DSD properties, bypassing _DSD in ACPI\n" );
1785- goto out ;
1786- }
1787-
17881764 property = "cirrus,dev-index" ;
17891765 ret = device_property_count_u32 (physdev , property );
17901766 if (ret <= 0 )
@@ -1816,8 +1792,9 @@ static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, i
18161792 /* To use the same release code for all laptop variants we can't use devm_ version of
18171793 * gpiod_get here, as CLSA010* don't have a fully functional bios with an _DSD node
18181794 */
1819- cs35l41 -> reset_gpio = fwnode_gpiod_get_index (acpi_fwnode_handle (adev ), "reset" , cs35l41 -> index ,
1820- GPIOD_OUT_LOW , "cs35l41-reset" );
1795+ cs35l41 -> reset_gpio = fwnode_gpiod_get_index (acpi_fwnode_handle (cs35l41 -> dacpi ), "reset" ,
1796+ cs35l41 -> index , GPIOD_OUT_LOW ,
1797+ "cs35l41-reset" );
18211798
18221799 property = "cirrus,speaker-position" ;
18231800 ret = device_property_read_u32_array (physdev , property , values , nval );
@@ -1873,6 +1850,51 @@ static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, i
18731850 hw_cfg -> bst_type = CS35L41_EXT_BOOST ;
18741851
18751852 hw_cfg -> valid = true;
1853+
1854+ return 0 ;
1855+ err :
1856+ dev_err (cs35l41 -> dev , "Failed property %s: %d\n" , property , ret );
1857+ hw_cfg -> valid = false;
1858+ hw_cfg -> gpio1 .valid = false;
1859+ hw_cfg -> gpio2 .valid = false;
1860+ acpi_dev_put (cs35l41 -> dacpi );
1861+
1862+ return ret ;
1863+ }
1864+
1865+ static int cs35l41_hda_read_acpi (struct cs35l41_hda * cs35l41 , const char * hid , int id )
1866+ {
1867+ struct acpi_device * adev ;
1868+ struct device * physdev ;
1869+ struct spi_device * spi ;
1870+ const char * sub ;
1871+ int ret ;
1872+
1873+ adev = acpi_dev_get_first_match_dev (hid , NULL , -1 );
1874+ if (!adev ) {
1875+ dev_err (cs35l41 -> dev , "Failed to find an ACPI device for %s\n" , hid );
1876+ return - ENODEV ;
1877+ }
1878+
1879+ cs35l41 -> dacpi = adev ;
1880+ physdev = get_device (acpi_get_first_physical_node (adev ));
1881+
1882+ sub = acpi_get_subsystem_id (ACPI_HANDLE (physdev ));
1883+ if (IS_ERR (sub ))
1884+ sub = NULL ;
1885+ cs35l41 -> acpi_subsystem_id = sub ;
1886+
1887+ ret = cs35l41_add_dsd_properties (cs35l41 , physdev , id , hid );
1888+ if (!ret ) {
1889+ dev_info (cs35l41 -> dev , "Using extra _DSD properties, bypassing _DSD in ACPI\n" );
1890+ goto out ;
1891+ }
1892+
1893+ ret = cs35l41_hda_parse_acpi (cs35l41 , physdev , id );
1894+ if (ret ) {
1895+ put_device (physdev );
1896+ return ret ;
1897+ }
18761898out :
18771899 put_device (physdev );
18781900
@@ -1888,16 +1910,6 @@ static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, i
18881910 }
18891911
18901912 return 0 ;
1891-
1892- err :
1893- dev_err (cs35l41 -> dev , "Failed property %s: %d\n" , property , ret );
1894- hw_cfg -> valid = false;
1895- hw_cfg -> gpio1 .valid = false;
1896- hw_cfg -> gpio2 .valid = false;
1897- acpi_dev_put (cs35l41 -> dacpi );
1898- put_device (physdev );
1899-
1900- return ret ;
19011913}
19021914
19031915int cs35l41_hda_probe (struct device * dev , const char * device_name , int id , int irq ,
0 commit comments