@@ -474,9 +474,10 @@ static void ak8975_power_off(const struct ak8975_data *data)
474474 * Return 0 if the i2c device is the one we expect.
475475 * return a negative error number otherwise
476476 */
477- static int ak8975_who_i_am (struct i2c_client * client ,
477+ static int ak8975_who_i_am (const struct ak8975_data * data ,
478478 enum asahi_compass_chipset type )
479479{
480+ struct i2c_client * client = data -> client ;
480481 u8 wia_val [2 ];
481482 int ret ;
482483
@@ -598,10 +599,9 @@ static int ak8975_setup_irq(struct ak8975_data *data)
598599 * Perform some start-of-day setup, including reading the asa calibration
599600 * values and caching them.
600601 */
601- static int ak8975_setup (struct i2c_client * client )
602+ static int ak8975_setup (struct ak8975_data * data )
602603{
603- struct iio_dev * indio_dev = i2c_get_clientdata (client );
604- struct ak8975_data * data = iio_priv (indio_dev );
604+ struct i2c_client * client = data -> client ;
605605 int ret ;
606606
607607 /* Write the fused rom access mode. */
@@ -706,12 +706,13 @@ static int wait_conversion_complete_interrupt(struct ak8975_data *data,
706706 return ret > 0 ? 0 : - ETIMEDOUT ;
707707}
708708
709- static int ak8975_start_read_axis (struct ak8975_data * data ,
710- const struct i2c_client * client )
709+ static int ak8975_start_read_axis (struct ak8975_data * data )
711710{
712- /* Set up the device for taking a sample. */
713- int ret = ak8975_set_mode ( data , MODE_ONCE ) ;
711+ struct i2c_client * client = data -> client ;
712+ int ret ;
714713
714+ /* Set up the device for taking a sample. */
715+ ret = ak8975_set_mode (data , MODE_ONCE );
715716 if (ret < 0 ) {
716717 dev_err (& client -> dev , "Error in setting operating mode\n" );
717718 return ret ;
@@ -744,7 +745,7 @@ static int ak8975_read_axis(struct iio_dev *indio_dev, int index, int *val)
744745
745746 mutex_lock (& data -> lock );
746747
747- ret = ak8975_start_read_axis (data , client );
748+ ret = ak8975_start_read_axis (data );
748749 if (ret )
749750 goto exit ;
750751
@@ -856,7 +857,7 @@ static void ak8975_fill_buffer(struct iio_dev *indio_dev)
856857
857858 mutex_lock (& data -> lock );
858859
859- ret = ak8975_start_read_axis (data , client );
860+ ret = ak8975_start_read_axis (data );
860861 if (ret )
861862 goto unlock ;
862863
@@ -968,15 +969,15 @@ static int ak8975_probe(struct i2c_client *client)
968969 if (ret )
969970 return ret ;
970971
971- ret = ak8975_who_i_am (client , data -> def -> type );
972+ ret = ak8975_who_i_am (data , data -> def -> type );
972973 if (ret ) {
973974 dev_err (& client -> dev , "Unexpected device\n" );
974975 goto power_off ;
975976 }
976977 dev_dbg (& client -> dev , "Asahi compass chip %s\n" , name );
977978
978979 /* Perform some basic start-of-day setup of the device. */
979- ret = ak8975_setup (client );
980+ ret = ak8975_setup (data );
980981 if (ret ) {
981982 dev_err (& client -> dev , "%s initialization fails\n" , name );
982983 goto power_off ;
0 commit comments