Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

i2c: Change prototypes of refcounting functions

Use more standard prototypes for i2c_use_client() and
i2c_release_client(). The former now returns a pointer to the client,
and the latter no longer returns anything. This matches what all other
subsystems do.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: David Brownell <david-b@pacbell.net>

authored by

Jean Delvare and committed by
Jean Delvare
e48d3319 bdc511f4

+26 -27
+20 -4
drivers/i2c/i2c-core.c
··· 764 764 } 765 765 EXPORT_SYMBOL(i2c_detach_client); 766 766 767 - int i2c_use_client(struct i2c_client *client) 767 + /** 768 + * i2c_use_client - increments the reference count of the i2c client structure 769 + * @client: the client being referenced 770 + * 771 + * Each live reference to a client should be refcounted. The driver model does 772 + * that automatically as part of driver binding, so that most drivers don't 773 + * need to do this explicitly: they hold a reference until they're unbound 774 + * from the device. 775 + * 776 + * A pointer to the client with the incremented reference counter is returned. 777 + */ 778 + struct i2c_client *i2c_use_client(struct i2c_client *client) 768 779 { 769 780 get_device(&client->dev); 770 - return 0; 781 + return client; 771 782 } 772 783 EXPORT_SYMBOL(i2c_use_client); 773 784 774 - int i2c_release_client(struct i2c_client *client) 785 + /** 786 + * i2c_release_client - release a use of the i2c client structure 787 + * @client: the client being no longer referenced 788 + * 789 + * Must be called when a user of a client is finished with it. 790 + */ 791 + void i2c_release_client(struct i2c_client *client) 775 792 { 776 793 put_device(&client->dev); 777 - return 0; 778 794 } 779 795 EXPORT_SYMBOL(i2c_release_client); 780 796
+4 -18
drivers/media/video/vino.c
··· 2589 2589 /* First try D1 and then SAA7191 */ 2590 2590 if (vino_drvdata->camera.driver 2591 2591 && (vino_drvdata->camera.owner == VINO_NO_CHANNEL)) { 2592 - if (i2c_use_client(vino_drvdata->camera.driver)) { 2593 - ret = -ENODEV; 2594 - goto out; 2595 - } 2596 - 2592 + i2c_use_client(vino_drvdata->camera.driver); 2597 2593 vino_drvdata->camera.owner = vcs->channel; 2598 2594 vcs->input = VINO_INPUT_D1; 2599 2595 vcs->data_norm = VINO_DATA_NORM_D1; ··· 2598 2602 int input, data_norm; 2599 2603 int saa7191_input; 2600 2604 2601 - if (i2c_use_client(vino_drvdata->decoder.driver)) { 2602 - ret = -ENODEV; 2603 - goto out; 2604 - } 2605 - 2605 + i2c_use_client(vino_drvdata->decoder.driver); 2606 2606 input = VINO_INPUT_COMPOSITE; 2607 2607 2608 2608 saa7191_input = vino_get_saa7191_input(input); ··· 2680 2688 } 2681 2689 2682 2690 if (vino_drvdata->decoder.owner == VINO_NO_CHANNEL) { 2683 - if (i2c_use_client(vino_drvdata->decoder.driver)) { 2684 - ret = -ENODEV; 2685 - goto out; 2686 - } 2691 + i2c_use_client(vino_drvdata->decoder.driver); 2687 2692 vino_drvdata->decoder.owner = vcs->channel; 2688 2693 } 2689 2694 ··· 2748 2759 } 2749 2760 2750 2761 if (vino_drvdata->camera.owner == VINO_NO_CHANNEL) { 2751 - if (i2c_use_client(vino_drvdata->camera.driver)) { 2752 - ret = -ENODEV; 2753 - goto out; 2754 - } 2762 + i2c_use_client(vino_drvdata->camera.driver); 2755 2763 vino_drvdata->camera.owner = vcs->channel; 2756 2764 } 2757 2765
+2 -5
include/linux/i2c.h
··· 386 386 extern int i2c_attach_client(struct i2c_client *); 387 387 extern int i2c_detach_client(struct i2c_client *); 388 388 389 - /* Should be used to make sure that client-struct is valid and that it 390 - is okay to access the i2c-client. 391 - returns -ENODEV if client has gone in the meantime */ 392 - extern int i2c_use_client(struct i2c_client *); 393 - extern int i2c_release_client(struct i2c_client *); 389 + extern struct i2c_client *i2c_use_client(struct i2c_client *client); 390 + extern void i2c_release_client(struct i2c_client *client); 394 391 395 392 /* call the i2c_client->command() of all attached clients with 396 393 * the given arguments */