<commit_before>/*
 * I2C multiplexer using a single register
 *
 * Copyright 2015 Freescale Semiconductor
 * <NAME>  <<EMAIL>>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.
 */

#include <linux/i2c.h>
#include <linux/i2c-mux.h>
#include <linux/init.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of_address.h>
#include <linux/platform_data/i2c-mux-reg.h>
#include <linux/platform_device.h>
#include <linux/slab.h>

struct regmux {
	struct i2c_adapter *parent;
	struct i2c_adapter **adap; /* child busses */
	struct i2c_mux_reg_platform_data data;
};

static int i2c_mux_reg_set(const struct regmux *mux, unsigned int chan_id)
{
	if (!mux->data.reg)
		return -EINVAL;

	switch (mux->data.reg_size) {
	case 4:
		if (mux->data.little_endian) {
			iowrite32(chan_id, mux->data.reg);
			if (!mux->data.write_only)
				ioread32(mux->data.reg);
		} else {
			iowrite32be(chan_id, mux->data.reg);
			if (!mux->data.write_only)
				ioread32(mux->data.reg);
		}
		break;
	case 2:
		if (mux->data.little_endian) {
			iowrite16(chan_id, mux->data.reg);
			if (!mux->data.write_only)
				ioread16(mux->data.reg);
		} else {
			iowrite16be(chan_id, mux->data.reg);
			if (!mux->data.write_only)
				ioread16be(mux->data.reg);
		}
		break;<commit_msg>i2c: mux: reg Change ioread endianness for readback<commit_after>/*
 * I2C multiplexer using a single register
 *
 * Copyright 2015 Freescale Semiconductor
 * <NAME>  <<EMAIL>>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.
 */

#include <linux/i2c.h>
#include <linux/i2c-mux.h>
#include <linux/init.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of_address.h>
#include <linux/platform_data/i2c-mux-reg.h>
#include <linux/platform_device.h>
#include <linux/slab.h>

struct regmux {
	struct i2c_adapter *parent;
	struct i2c_adapter **adap; /* child busses */
	struct i2c_mux_reg_platform_data data;
};

static int i2c_mux_reg_set(const struct regmux *mux, unsigned int chan_id)
{
	if (!mux->data.reg)
		return -EINVAL;

	/*
	 * Write to the register, followed by a read to ensure the write is
	 * completed on a "posted" bus, for example PCI or write buffers.
	 * The endianness of reading doesn't matter and the return data
	 * is not used.
	 */
	switch (mux->data.reg_size) {
	case 4:
		if (mux->data.little_endian)
			iowrite32(chan_id, mux->data.reg);
		else
			iowrite32be(chan_id, mux->data.reg);
		if (!mux->data.write_only)
			ioread32(mux->data.reg);
		break;
	case 2:
		if (mux->data.little_endian)
			iowrite16(chan_id, mux->data.reg);
		else
			iowrite16be(chan_id, mux->data.reg);
		if (!mux->data.write_only)
			ioread16(mux->data.reg);
		break;
{'fraction_non_alphanumeric': 0.13143231727302523, 'fraction_numerical': 0.01933792199278925, 'mean_word_length': 3.970684039087948, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6251271', 'n_tokens_mistral': 1239, 'n_tokens_neox': 1138, 'n_words': 301}