sch56xx-common.c (a54fe61639d9f3b6765fee32edda7cfceb6d705a) sch56xx-common.c (10655bb6df25514e0ae8406637c3b4acbc812fe5)
1// SPDX-License-Identifier: GPL-2.0-or-later
2/***************************************************************************
3 * Copyright (C) 2010-2012 Hans de Goede <hdegoede@redhat.com> *
4 * *
5 ***************************************************************************/
6
7#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
8

--- 234 unchanged lines hidden (view full) ---

243 return (msb << 4) | (lsn & 0x0f);
244}
245EXPORT_SYMBOL(sch56xx_read_virtual_reg12);
246
247/*
248 * Regmap support
249 */
250
1// SPDX-License-Identifier: GPL-2.0-or-later
2/***************************************************************************
3 * Copyright (C) 2010-2012 Hans de Goede <hdegoede@redhat.com> *
4 * *
5 ***************************************************************************/
6
7#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
8

--- 234 unchanged lines hidden (view full) ---

243 return (msb << 4) | (lsn & 0x0f);
244}
245EXPORT_SYMBOL(sch56xx_read_virtual_reg12);
246
247/*
248 * Regmap support
249 */
250
251int sch56xx_regmap_read16(struct regmap *map, unsigned int reg, unsigned int *val)
252{
253 int lsb, msb, ret;
254
255 /* See sch56xx_read_virtual_reg16() */
256 ret = regmap_read(map, reg, &lsb);
257 if (ret < 0)
258 return ret;
259
260 ret = regmap_read(map, reg + 1, &msb);
261 if (ret < 0)
262 return ret;
263
264 *val = lsb | (msb << 8);
265
266 return 0;
267}
268EXPORT_SYMBOL(sch56xx_regmap_read16);
269
270int sch56xx_regmap_write16(struct regmap *map, unsigned int reg, unsigned int val)
271{
272 int ret;
273
274 ret = regmap_write(map, reg, val & 0xff);
275 if (ret < 0)
276 return ret;
277
278 return regmap_write(map, reg + 1, (val >> 8) & 0xff);
279}
280EXPORT_SYMBOL(sch56xx_regmap_write16);
281
251static int sch56xx_reg_write(void *context, unsigned int reg, unsigned int val)
252{
253 struct sch56xx_bus_context *bus = context;
254 int ret;
255
256 mutex_lock(bus->lock);
257 ret = sch56xx_write_virtual_reg(bus->addr, (u16)reg, (u8)val);
258 mutex_unlock(bus->lock);

--- 363 unchanged lines hidden ---
282static int sch56xx_reg_write(void *context, unsigned int reg, unsigned int val)
283{
284 struct sch56xx_bus_context *bus = context;
285 int ret;
286
287 mutex_lock(bus->lock);
288 ret = sch56xx_write_virtual_reg(bus->addr, (u16)reg, (u8)val);
289 mutex_unlock(bus->lock);

--- 363 unchanged lines hidden ---