@@ -156,16 +156,15 @@ static inline int pca955x_ledstate(u8 ls, int led_num)
156156 * Write to frequency prescaler register, used to program the
157157 * period of the PWM output. period = (PSCx + 1) / 38
158158 */
159- static int pca955x_write_psc (struct i2c_client * client , int n , u8 val )
159+ static int pca955x_write_psc (struct pca955x * pca955x , int n , u8 val )
160160{
161- struct pca955x * pca955x = i2c_get_clientdata (client );
162161 u8 cmd = pca955x_num_input_regs (pca955x -> chipdef -> bits ) + (2 * n );
163162 int ret ;
164163
165- ret = i2c_smbus_write_byte_data (client , cmd , val );
164+ ret = i2c_smbus_write_byte_data (pca955x -> client , cmd , val );
166165 if (ret < 0 )
167- dev_err (& client -> dev , "%s: reg 0x%x, val 0x%x, err %d\n" ,
168- __func__ , n , val , ret );
166+ dev_err (& pca955x -> client -> dev , "%s: reg 0x%x, val 0x%x, err %d\n" , __func__ , n ,
167+ val , ret );
169168 return ret ;
170169}
171170
@@ -176,66 +175,60 @@ static int pca955x_write_psc(struct i2c_client *client, int n, u8 val)
176175 *
177176 * Duty cycle is (256 - PWMx) / 256
178177 */
179- static int pca955x_write_pwm (struct i2c_client * client , int n , u8 val )
178+ static int pca955x_write_pwm (struct pca955x * pca955x , int n , u8 val )
180179{
181- struct pca955x * pca955x = i2c_get_clientdata (client );
182180 u8 cmd = pca955x_num_input_regs (pca955x -> chipdef -> bits ) + 1 + (2 * n );
183181 int ret ;
184182
185- ret = i2c_smbus_write_byte_data (client , cmd , val );
183+ ret = i2c_smbus_write_byte_data (pca955x -> client , cmd , val );
186184 if (ret < 0 )
187- dev_err (& client -> dev , "%s: reg 0x%x, val 0x%x, err %d\n" ,
188- __func__ , n , val , ret );
185+ dev_err (& pca955x -> client -> dev , "%s: reg 0x%x, val 0x%x, err %d\n" , __func__ , n ,
186+ val , ret );
189187 return ret ;
190188}
191189
192190/*
193191 * Write to LED selector register, which determines the source that
194192 * drives the LED output.
195193 */
196- static int pca955x_write_ls (struct i2c_client * client , int n , u8 val )
194+ static int pca955x_write_ls (struct pca955x * pca955x , int n , u8 val )
197195{
198- struct pca955x * pca955x = i2c_get_clientdata (client );
199196 u8 cmd = pca955x_num_input_regs (pca955x -> chipdef -> bits ) + 4 + n ;
200197 int ret ;
201198
202- ret = i2c_smbus_write_byte_data (client , cmd , val );
199+ ret = i2c_smbus_write_byte_data (pca955x -> client , cmd , val );
203200 if (ret < 0 )
204- dev_err (& client -> dev , "%s: reg 0x%x, val 0x%x, err %d\n" ,
205- __func__ , n , val , ret );
201+ dev_err (& pca955x -> client -> dev , "%s: reg 0x%x, val 0x%x, err %d\n" , __func__ , n ,
202+ val , ret );
206203 return ret ;
207204}
208205
209206/*
210207 * Read the LED selector register, which determines the source that
211208 * drives the LED output.
212209 */
213- static int pca955x_read_ls (struct i2c_client * client , int n , u8 * val )
210+ static int pca955x_read_ls (struct pca955x * pca955x , int n , u8 * val )
214211{
215- struct pca955x * pca955x = i2c_get_clientdata (client );
216212 u8 cmd = pca955x_num_input_regs (pca955x -> chipdef -> bits ) + 4 + n ;
217213 int ret ;
218214
219- ret = i2c_smbus_read_byte_data (client , cmd );
215+ ret = i2c_smbus_read_byte_data (pca955x -> client , cmd );
220216 if (ret < 0 ) {
221- dev_err (& client -> dev , "%s: reg 0x%x, err %d\n" ,
222- __func__ , n , ret );
217+ dev_err (& pca955x -> client -> dev , "%s: reg 0x%x, err %d\n" , __func__ , n , ret );
223218 return ret ;
224219 }
225220 * val = (u8 )ret ;
226221 return 0 ;
227222}
228223
229- static int pca955x_read_pwm (struct i2c_client * client , int n , u8 * val )
224+ static int pca955x_read_pwm (struct pca955x * pca955x , int n , u8 * val )
230225{
231- struct pca955x * pca955x = i2c_get_clientdata (client );
232226 u8 cmd = pca955x_num_input_regs (pca955x -> chipdef -> bits ) + 1 + (2 * n );
233227 int ret ;
234228
235- ret = i2c_smbus_read_byte_data (client , cmd );
229+ ret = i2c_smbus_read_byte_data (pca955x -> client , cmd );
236230 if (ret < 0 ) {
237- dev_err (& client -> dev , "%s: reg 0x%x, err %d\n" ,
238- __func__ , n , ret );
231+ dev_err (& pca955x -> client -> dev , "%s: reg 0x%x, err %d\n" , __func__ , n , ret );
239232 return ret ;
240233 }
241234 * val = (u8 )ret ;
@@ -249,7 +242,7 @@ static enum led_brightness pca955x_led_get(struct led_classdev *led_cdev)
249242 u8 ls , pwm ;
250243 int ret ;
251244
252- ret = pca955x_read_ls (pca955x -> client , pca955x_led -> led_num / 4 , & ls );
245+ ret = pca955x_read_ls (pca955x , pca955x_led -> led_num / 4 , & ls );
253246 if (ret )
254247 return ret ;
255248
@@ -264,7 +257,7 @@ static enum led_brightness pca955x_led_get(struct led_classdev *led_cdev)
264257 ret = LED_HALF ;
265258 break ;
266259 case PCA955X_LS_BLINK1 :
267- ret = pca955x_read_pwm (pca955x -> client , 1 , & pwm );
260+ ret = pca955x_read_pwm (pca955x , 1 , & pwm );
268261 if (ret )
269262 return ret ;
270263 ret = 255 - pwm ;
@@ -286,7 +279,7 @@ static int pca955x_led_set(struct led_classdev *led_cdev,
286279
287280 mutex_lock (& pca955x -> lock );
288281
289- ret = pca955x_read_ls (pca955x -> client , reg , & ls );
282+ ret = pca955x_read_ls (pca955x , reg , & ls );
290283 if (ret )
291284 goto out ;
292285
@@ -308,14 +301,14 @@ static int pca955x_led_set(struct led_classdev *led_cdev,
308301 * OFF, HALF, or FULL. But, this is probably better than
309302 * just turning off for all other values.
310303 */
311- ret = pca955x_write_pwm (pca955x -> client , 1 , 255 - value );
304+ ret = pca955x_write_pwm (pca955x , 1 , 255 - value );
312305 if (ret )
313306 goto out ;
314307 ls = pca955x_ledsel (ls , bit , PCA955X_LS_BLINK1 );
315308 break ;
316309 }
317310
318- ret = pca955x_write_ls (pca955x -> client , reg , ls );
311+ ret = pca955x_write_ls (pca955x , reg , ls );
319312
320313out :
321314 mutex_unlock (& pca955x -> lock );
@@ -579,22 +572,22 @@ static int pca955x_probe(struct i2c_client *client)
579572 }
580573
581574 /* PWM0 is used for half brightness or 50% duty cycle */
582- err = pca955x_write_pwm (client , 0 , 255 - LED_HALF );
575+ err = pca955x_write_pwm (pca955x , 0 , 255 - LED_HALF );
583576 if (err )
584577 return err ;
585578
586579 if (!keep_pwm ) {
587580 /* PWM1 is used for variable brightness, default to OFF */
588- err = pca955x_write_pwm (client , 1 , 0 );
581+ err = pca955x_write_pwm (pca955x , 1 , 0 );
589582 if (err )
590583 return err ;
591584 }
592585
593586 /* Set to fast frequency so we do not see flashing */
594- err = pca955x_write_psc (client , 0 , 0 );
587+ err = pca955x_write_psc (pca955x , 0 , 0 );
595588 if (err )
596589 return err ;
597- err = pca955x_write_psc (client , 1 , 0 );
590+ err = pca955x_write_psc (pca955x , 1 , 0 );
598591 if (err )
599592 return err ;
600593
0 commit comments