| .. | .. |
|---|
| 1 | | -/* ------------------------------------------------------------------------- |
|---|
| 2 | | - * i2c-algo-bit.c i2c driver algorithms for bit-shift adapters |
|---|
| 3 | | - * ------------------------------------------------------------------------- |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0+ |
|---|
| 2 | +/* |
|---|
| 3 | + * i2c-algo-bit.c: i2c driver algorithms for bit-shift adapters |
|---|
| 4 | + * |
|---|
| 4 | 5 | * Copyright (C) 1995-2000 Simon G. Vogl |
|---|
| 5 | | - |
|---|
| 6 | | - This program is free software; you can redistribute it and/or modify |
|---|
| 7 | | - it under the terms of the GNU General Public License as published by |
|---|
| 8 | | - the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 | | - (at your option) any later version. |
|---|
| 10 | | - |
|---|
| 11 | | - This program is distributed in the hope that it will be useful, |
|---|
| 12 | | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | | - GNU General Public License for more details. |
|---|
| 15 | | - * ------------------------------------------------------------------------- */ |
|---|
| 16 | | - |
|---|
| 17 | | -/* With some changes from Frodo Looijaard <frodol@dds.nl>, Kyösti Mälkki |
|---|
| 18 | | - <kmalkki@cc.hut.fi> and Jean Delvare <jdelvare@suse.de> */ |
|---|
| 6 | + * |
|---|
| 7 | + * With some changes from Frodo Looijaard <frodol@dds.nl>, Kyösti Mälkki |
|---|
| 8 | + * <kmalkki@cc.hut.fi> and Jean Delvare <jdelvare@suse.de> |
|---|
| 9 | + */ |
|---|
| 19 | 10 | |
|---|
| 20 | 11 | #include <linux/kernel.h> |
|---|
| 21 | 12 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 612 | 603 | return ret; |
|---|
| 613 | 604 | } |
|---|
| 614 | 605 | |
|---|
| 606 | +/* |
|---|
| 607 | + * We print a warning when we are not flagged to support atomic transfers but |
|---|
| 608 | + * will try anyhow. That's what the I2C core would do as well. Sadly, we can't |
|---|
| 609 | + * modify the algorithm struct at probe time because this struct is exported |
|---|
| 610 | + * 'const'. |
|---|
| 611 | + */ |
|---|
| 612 | +static int bit_xfer_atomic(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[], |
|---|
| 613 | + int num) |
|---|
| 614 | +{ |
|---|
| 615 | + struct i2c_algo_bit_data *adap = i2c_adap->algo_data; |
|---|
| 616 | + |
|---|
| 617 | + if (!adap->can_do_atomic) |
|---|
| 618 | + dev_warn(&i2c_adap->dev, "not flagged for atomic transfers\n"); |
|---|
| 619 | + |
|---|
| 620 | + return bit_xfer(i2c_adap, msgs, num); |
|---|
| 621 | +} |
|---|
| 622 | + |
|---|
| 615 | 623 | static u32 bit_func(struct i2c_adapter *adap) |
|---|
| 616 | 624 | { |
|---|
| 617 | 625 | return I2C_FUNC_I2C | I2C_FUNC_NOSTART | I2C_FUNC_SMBUS_EMUL | |
|---|
| .. | .. |
|---|
| 624 | 632 | /* -----exported algorithm data: ------------------------------------- */ |
|---|
| 625 | 633 | |
|---|
| 626 | 634 | const struct i2c_algorithm i2c_bit_algo = { |
|---|
| 627 | | - .master_xfer = bit_xfer, |
|---|
| 628 | | - .functionality = bit_func, |
|---|
| 635 | + .master_xfer = bit_xfer, |
|---|
| 636 | + .master_xfer_atomic = bit_xfer_atomic, |
|---|
| 637 | + .functionality = bit_func, |
|---|
| 629 | 638 | }; |
|---|
| 630 | 639 | EXPORT_SYMBOL(i2c_bit_algo); |
|---|
| 631 | 640 | |
|---|