OSDN Git Service

Merge 4.2-rc3 into staging-next
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 20 Jul 2015 20:21:28 +0000 (13:21 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 20 Jul 2015 20:21:28 +0000 (13:21 -0700)
We need the staging fixes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
279 files changed:
Documentation/ABI/testing/sysfs-bus-iio
drivers/iio/accel/bma180.c
drivers/iio/accel/bmc150-accel.c
drivers/iio/accel/kxcjk-1013.c
drivers/iio/accel/mma9551_core.c
drivers/iio/accel/mma9551_core.h
drivers/iio/accel/mma9553.c
drivers/iio/accel/st_accel_i2c.c
drivers/iio/accel/stk8312.c
drivers/iio/accel/stk8ba50.c
drivers/iio/adc/Kconfig
drivers/iio/adc/cc10001_adc.c
drivers/iio/adc/mcp3422.c
drivers/iio/adc/ti-adc081c.c
drivers/iio/common/ssp_sensors/ssp_dev.c
drivers/iio/dac/ad5064.c
drivers/iio/dac/ad5380.c
drivers/iio/dac/ad5446.c
drivers/iio/dac/max5821.c
drivers/iio/frequency/adf4350.c
drivers/iio/gyro/itg3200_core.c
drivers/iio/gyro/st_gyro_i2c.c
drivers/iio/humidity/si7005.c
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
drivers/iio/industrialio-buffer.c
drivers/iio/industrialio-core.c
drivers/iio/industrialio-triggered-buffer.c
drivers/iio/light/Kconfig
drivers/iio/light/Makefile
drivers/iio/light/apds9300.c
drivers/iio/light/bh1750.c
drivers/iio/light/cm32181.c
drivers/iio/light/cm3232.c
drivers/iio/light/cm3323.c
drivers/iio/light/cm36651.c
drivers/iio/light/gp2ap020a00f.c
drivers/iio/light/hid-sensor-prox.c
drivers/iio/light/isl29125.c
drivers/iio/light/jsa1212.c
drivers/iio/light/ltr501.c
drivers/iio/light/rpr0521.c [new file with mode: 0644]
drivers/iio/light/tcs3414.c
drivers/iio/light/tcs3472.c
drivers/iio/light/tsl4531.c
drivers/iio/light/vcnl4000.c
drivers/iio/magnetometer/bmc150_magn.c
drivers/iio/magnetometer/st_magn_i2c.c
drivers/iio/pressure/Kconfig
drivers/iio/pressure/ms5611.h
drivers/iio/pressure/ms5611_core.c
drivers/iio/pressure/ms5611_i2c.c
drivers/iio/pressure/ms5611_spi.c
drivers/iio/pressure/st_pressure_i2c.c
drivers/iio/temperature/mlx90614.c
drivers/iio/temperature/tmp006.c
drivers/staging/android/ion/ion.c
drivers/staging/android/ion/ion_chunk_heap.c
drivers/staging/android/ion/ion_page_pool.c
drivers/staging/android/ion/ion_system_heap.c
drivers/staging/comedi/Kconfig
drivers/staging/comedi/comedi_compat32.c
drivers/staging/comedi/comedi_fops.c
drivers/staging/comedi/drivers/cb_pcimdas.c
drivers/staging/comedi/drivers/dac02.c
drivers/staging/comedi/drivers/das08_cs.c
drivers/staging/comedi/drivers/das16m1.c
drivers/staging/comedi/drivers/dmm32at.c
drivers/staging/comedi/drivers/fl512.c
drivers/staging/comedi/drivers/ni_daq_dio24.c
drivers/staging/comedi/drivers/s626.c
drivers/staging/dgap/dgap.c
drivers/staging/fbtft/Kconfig
drivers/staging/fbtft/Makefile
drivers/staging/fbtft/fb_uc1611.c [new file with mode: 0644]
drivers/staging/fbtft/fbtft-core.c
drivers/staging/fbtft/fbtft_device.c
drivers/staging/fbtft/flexfb.c
drivers/staging/ft1000/ft1000-usb/ft1000_debug.c
drivers/staging/ft1000/ft1000-usb/ft1000_download.c
drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
drivers/staging/iio/addac/adt7316-i2c.c
drivers/staging/iio/iio_dummy_evgen.c
drivers/staging/iio/iio_simple_dummy.c
drivers/staging/iio/iio_simple_dummy.h
drivers/staging/iio/iio_simple_dummy_buffer.c
drivers/staging/iio/light/isl29018.c
drivers/staging/iio/light/isl29028.c
drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h
drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
drivers/staging/lustre/lnet/lnet/router_proc.c
drivers/staging/lustre/lustre/fid/fid_request.c
drivers/staging/lustre/lustre/fld/fld_cache.c
drivers/staging/lustre/lustre/fld/fld_request.c
drivers/staging/lustre/lustre/include/obd_class.h
drivers/staging/lustre/lustre/include/obd_support.h
drivers/staging/lustre/lustre/lclient/lcommon_cl.c
drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
drivers/staging/lustre/lustre/libcfs/debug.c
drivers/staging/lustre/lustre/libcfs/fail.c
drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c
drivers/staging/lustre/lustre/libcfs/module.c
drivers/staging/lustre/lustre/libcfs/tracefile.c
drivers/staging/lustre/lustre/libcfs/tracefile.h
drivers/staging/lustre/lustre/llite/file.c
drivers/staging/lustre/lustre/llite/llite_lib.c
drivers/staging/lustre/lustre/llite/xattr_cache.c
drivers/staging/lustre/lustre/lmv/lmv_intent.c
drivers/staging/lustre/lustre/lmv/lmv_obd.c
drivers/staging/lustre/lustre/lov/lov_dev.c
drivers/staging/lustre/lustre/lov/lov_io.c
drivers/staging/lustre/lustre/lov/lov_merge.c
drivers/staging/lustre/lustre/lov/lov_obd.c
drivers/staging/lustre/lustre/lov/lov_pool.c
drivers/staging/lustre/lustre/lov/lov_request.c
drivers/staging/lustre/lustre/mdc/mdc_request.c
drivers/staging/lustre/lustre/mgc/mgc_request.c
drivers/staging/lustre/lustre/obdclass/cl_page.c
drivers/staging/lustre/lustre/obdclass/class_obd.c
drivers/staging/lustre/lustre/obdclass/genops.c
drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
drivers/staging/lustre/lustre/obdclass/llog.c
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
drivers/staging/lustre/lustre/obdclass/lustre_peer.c
drivers/staging/lustre/lustre/obdclass/obd_config.c
drivers/staging/lustre/lustre/obdclass/obd_mount.c
drivers/staging/lustre/lustre/obdclass/uuid.c
drivers/staging/lustre/lustre/obdecho/echo_client.c
drivers/staging/lustre/lustre/osc/osc_cache.c
drivers/staging/lustre/lustre/osc/osc_dev.c
drivers/staging/lustre/lustre/osc/osc_page.c
drivers/staging/lustre/lustre/osc/osc_request.c
drivers/staging/lustre/lustre/ptlrpc/client.c
drivers/staging/lustre/lustre/ptlrpc/import.c
drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
drivers/staging/lustre/lustre/ptlrpc/nrs.c
drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c
drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
drivers/staging/lustre/lustre/ptlrpc/sec_config.c
drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
drivers/staging/lustre/lustre/ptlrpc/service.c
drivers/staging/lustre/sysfs-fs-lustre
drivers/staging/mt29f_spinand/mt29f_spinand.c
drivers/staging/octeon/ethernet-tx.c
drivers/staging/ozwpan/ozusbsvc1.c
drivers/staging/rtl8188eu/core/rtw_ap.c
drivers/staging/rtl8188eu/core/rtw_ieee80211.c
drivers/staging/rtl8188eu/core/rtw_mlme.c
drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
drivers/staging/rtl8188eu/core/rtw_pwrctrl.c
drivers/staging/rtl8188eu/core/rtw_wlan_util.c
drivers/staging/rtl8188eu/hal/hal_com.c
drivers/staging/rtl8188eu/hal/hal_intf.c
drivers/staging/rtl8188eu/hal/rf_cfg.c
drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c
drivers/staging/rtl8188eu/hal/usb_halinit.c
drivers/staging/rtl8188eu/include/HalVerDef.h
drivers/staging/rtl8188eu/include/hal_intf.h
drivers/staging/rtl8188eu/include/ieee80211.h
drivers/staging/rtl8188eu/include/rtl8188e_hal.h
drivers/staging/rtl8188eu/include/rtw_pwrctrl.h
drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
drivers/staging/rtl8188eu/os_dep/usb_intf.c
drivers/staging/rtl8192e/dot11d.c
drivers/staging/rtl8192e/dot11d.h
drivers/staging/rtl8192e/rtl8192e/r8190P_def.h
drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c
drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.h
drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
drivers/staging/rtl8192e/rtl8192e/r8192E_dev.h
drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.h
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.h
drivers/staging/rtl8192e/rtl8192e/rtl_core.c
drivers/staging/rtl8192e/rtl8192e/rtl_core.h
drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
drivers/staging/rtl8192e/rtl8192e/rtl_dm.h
drivers/staging/rtl8192e/rtl8192e/rtl_ps.h
drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
drivers/staging/rtl8192e/rtl819x_BA.h
drivers/staging/rtl8192e/rtl819x_HT.h
drivers/staging/rtl8192e/rtl819x_HTProc.c
drivers/staging/rtl8192e/rtl819x_Qos.h
drivers/staging/rtl8192e/rtl819x_TS.h
drivers/staging/rtl8192e/rtl819x_TSProc.c
drivers/staging/rtl8192e/rtllib.h
drivers/staging/rtl8192e/rtllib_debug.h
drivers/staging/rtl8192e/rtllib_rx.c
drivers/staging/rtl8192e/rtllib_softmac.c
drivers/staging/rtl8192e/rtllib_tx.c
drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c
drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c
drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
drivers/staging/rtl8192u/r819xU_firmware.c
drivers/staging/rtl8712/rtl8712_recv.c
drivers/staging/rtl8712/rtl871x_security.c
drivers/staging/rtl8723au/hal/odm.c
drivers/staging/rts5208/sd.c
drivers/staging/sm750fb/ddk750_chip.c
drivers/staging/sm750fb/ddk750_chip.h
drivers/staging/sm750fb/ddk750_display.c
drivers/staging/sm750fb/ddk750_display.h
drivers/staging/sm750fb/ddk750_dvi.c
drivers/staging/sm750fb/ddk750_dvi.h
drivers/staging/sm750fb/ddk750_help.c
drivers/staging/sm750fb/ddk750_help.h
drivers/staging/sm750fb/ddk750_hwi2c.c
drivers/staging/sm750fb/ddk750_mode.c
drivers/staging/sm750fb/ddk750_mode.h
drivers/staging/sm750fb/ddk750_power.c
drivers/staging/sm750fb/ddk750_power.h
drivers/staging/sm750fb/ddk750_reg.h
drivers/staging/sm750fb/ddk750_sii164.c
drivers/staging/sm750fb/ddk750_sii164.h
drivers/staging/sm750fb/sm750.c
drivers/staging/sm750fb/sm750.h
drivers/staging/sm750fb/sm750_accel.c
drivers/staging/sm750fb/sm750_accel.h
drivers/staging/sm750fb/sm750_cursor.c
drivers/staging/sm750fb/sm750_help.h
drivers/staging/sm750fb/sm750_hw.c
drivers/staging/sm750fb/sm750_hw.h
drivers/staging/sm7xxfb/sm7xx.h
drivers/staging/sm7xxfb/sm7xxfb.c
drivers/staging/speakup/keyhelp.c
drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c
drivers/staging/unisys/Kconfig
drivers/staging/unisys/include/visorbus.h
drivers/staging/unisys/visorbus/controlvmchannel.h
drivers/staging/unisys/visorbus/controlvmcompletionstatus.h
drivers/staging/unisys/visorbus/iovmcall_gnuc.h
drivers/staging/unisys/visorbus/periodic_work.c
drivers/staging/unisys/visorbus/vbuschannel.h
drivers/staging/unisys/visorbus/vbusdeviceinfo.h
drivers/staging/unisys/visorbus/visorbus_main.c
drivers/staging/unisys/visorbus/visorbus_private.h
drivers/staging/unisys/visorbus/visorchannel.c
drivers/staging/unisys/visorbus/visorchipset.c
drivers/staging/unisys/visorbus/vmcallinterface.h
drivers/staging/unisys/visornic/visornic_main.c
drivers/staging/vme/devices/vme_user.c
drivers/staging/vt6655/device.h
drivers/staging/vt6655/device_main.c
drivers/staging/vt6655/power.c
drivers/staging/vt6655/rf.c
drivers/staging/vt6655/rf.h
drivers/staging/vt6655/upc.h
drivers/staging/vt6656/rxtx.c
drivers/staging/wilc1000/coreconfigurator.c
drivers/staging/wilc1000/fifo_buffer.c
drivers/staging/wilc1000/host_interface.c
drivers/staging/wilc1000/linux_mon.c
drivers/staging/wilc1000/linux_wlan.c
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
drivers/staging/wilc1000/wilc_wfi_netdevice.c
drivers/staging/wilc1000/wilc_wfi_netdevice.h
drivers/staging/wilc1000/wilc_wlan.c
drivers/staging/wilc1000/wilc_wlan_cfg.c
drivers/staging/wilc1000/wilc_wlan_if.h
drivers/staging/xgifb/Makefile
drivers/staging/xgifb/XGI_main_26.c
drivers/staging/xgifb/vb_util.c [deleted file]
drivers/staging/xgifb/vb_util.h
include/linux/iio/triggered_buffer.h
tools/iio/generic_buffer.c
tools/iio/iio_event_monitor.c
tools/iio/iio_utils.c
tools/iio/iio_utils.h
tools/iio/lsiio.c

index 70c9b1a..b8753f7 100644 (file)
@@ -413,6 +413,11 @@ Description:
                to compute the calories burnt by the user.
 
 What:          /sys/bus/iio/devices/iio:deviceX/in_accel_scale_available
+What:          /sys/.../iio:deviceX/in_anglvel_scale_available
+What:          /sys/.../iio:deviceX/in_magn_scale_available
+What:          /sys/.../iio:deviceX/in_illuminance_scale_available
+What:          /sys/.../iio:deviceX/in_intensity_scale_available
+What:          /sys/.../iio:deviceX/in_proximity_scale_available
 What:          /sys/.../iio:deviceX/in_voltageX_scale_available
 What:          /sys/.../iio:deviceX/in_voltage-voltage_scale_available
 What:          /sys/.../iio:deviceX/out_voltageX_scale_available
index 75c6d21..f04b884 100644 (file)
@@ -846,7 +846,6 @@ MODULE_DEVICE_TABLE(i2c, bma180_ids);
 static struct i2c_driver bma180_driver = {
        .driver = {
                .name   = "bma180",
-               .owner  = THIS_MODULE,
                .pm     = BMA180_PM_OPS,
        },
        .probe          = bma180_probe,
index cc5a357..e84e2a1 100644 (file)
@@ -241,7 +241,6 @@ static const struct {
                                       {500000, BMC150_ACCEL_SLEEP_500_MS},
                                       {1000000, BMC150_ACCEL_SLEEP_1_SEC} };
 
-
 static int bmc150_accel_set_mode(struct bmc150_accel_data *data,
                                 enum bmc150_power_modes mode,
                                 int dur_us)
@@ -259,8 +258,9 @@ static int bmc150_accel_set_mode(struct bmc150_accel_data *data,
                                dur_val =
                                bmc150_accel_sleep_value_table[i].reg_value;
                }
-       } else
+       } else {
                dur_val = 0;
+       }
 
        if (dur_val < 0)
                return -EINVAL;
@@ -288,7 +288,7 @@ static int bmc150_accel_set_bw(struct bmc150_accel_data *data, int val,
 
        for (i = 0; i < ARRAY_SIZE(bmc150_accel_samp_freq_table); ++i) {
                if (bmc150_accel_samp_freq_table[i].val == val &&
-                               bmc150_accel_samp_freq_table[i].val2 == val2) {
+                   bmc150_accel_samp_freq_table[i].val2 == val2) {
                        ret = i2c_smbus_write_byte_data(
                                data->client,
                                BMC150_ACCEL_REG_PMU_BW,
@@ -351,8 +351,7 @@ static int bmc150_accel_chip_init(struct bmc150_accel_data *data)
 
        ret = i2c_smbus_read_byte_data(data->client, BMC150_ACCEL_REG_CHIP_ID);
        if (ret < 0) {
-               dev_err(&data->client->dev,
-                       "Error: Reading chip id\n");
+               dev_err(&data->client->dev, "Error: Reading chip id\n");
                return ret;
        }
 
@@ -376,8 +375,7 @@ static int bmc150_accel_chip_init(struct bmc150_accel_data *data)
                                        BMC150_ACCEL_REG_PMU_RANGE,
                                        BMC150_ACCEL_DEF_RANGE_4G);
        if (ret < 0) {
-               dev_err(&data->client->dev,
-                                       "Error writing reg_pmu_range\n");
+               dev_err(&data->client->dev, "Error writing reg_pmu_range\n");
                return ret;
        }
 
@@ -437,12 +435,13 @@ static int bmc150_accel_set_power_state(struct bmc150_accel_data *data, bool on)
 {
        int ret;
 
-       if (on)
+       if (on) {
                ret = pm_runtime_get_sync(&data->client->dev);
-       else {
+       else {
                pm_runtime_mark_last_busy(&data->client->dev);
                ret = pm_runtime_put_autosuspend(&data->client->dev);
        }
+
        if (ret < 0) {
                dev_err(&data->client->dev,
                        "Failed: bmc150_accel_set_power_state for %d\n", on);
@@ -514,13 +513,13 @@ static int bmc150_accel_set_interrupt(struct bmc150_accel_data *data, int i,
        }
 
        /*
-        * We will expect the enable and disable to do operation in
-        * in reverse order. This will happen here anyway as our
-        * resume operation uses sync mode runtime pm calls, the
-        * suspend operation will be delayed by autosuspend delay
-        * So the disable operation will still happen in reverse of
-        * enable operation. When runtime pm is disabled the mode
-        * is always on so sequence doesn't matter
+        * We will expect the enable and disable to do operation in reverse
+        * order. This will happen here anyway, as our resume operation uses
+        * sync mode runtime pm calls. The suspend operation will be delayed
+        * by autosuspend delay.
+        * So the disable operation will still happen in reverse order of
+        * enable operation. When runtime pm is disabled the mode is always on,
+        * so sequence doesn't matter.
         */
        ret = bmc150_accel_set_power_state(data, state);
        if (ret < 0)
@@ -574,7 +573,6 @@ out_fix_power_state:
        return ret;
 }
 
-
 static int bmc150_accel_set_scale(struct bmc150_accel_data *data, int val)
 {
        int ret, i;
@@ -674,8 +672,9 @@ static int bmc150_accel_read_raw(struct iio_dev *indio_dev,
                if (chan->type == IIO_TEMP) {
                        *val = BMC150_ACCEL_TEMP_CENTER_VAL;
                        return IIO_VAL_INT;
-               } else
+               } else {
                        return -EINVAL;
+               }
        case IIO_CHAN_INFO_SCALE:
                *val = 0;
                switch (chan->type) {
@@ -776,7 +775,7 @@ static int bmc150_accel_write_event(struct iio_dev *indio_dev,
 
        switch (info) {
        case IIO_EV_INFO_VALUE:
-               data->slope_thres = val & 0xFF;
+               data->slope_thres = val & BMC150_ACCEL_SLOPE_THRES_MASK;
                break;
        case IIO_EV_INFO_PERIOD:
                data->slope_dur = val & BMC150_ACCEL_SLOPE_DUR_MASK;
@@ -793,7 +792,6 @@ static int bmc150_accel_read_event_config(struct iio_dev *indio_dev,
                                          enum iio_event_type type,
                                          enum iio_event_direction dir)
 {
-
        struct bmc150_accel_data *data = iio_priv(indio_dev);
 
        return data->ev_enable_state;
@@ -827,7 +825,7 @@ static int bmc150_accel_write_event_config(struct iio_dev *indio_dev,
 }
 
 static int bmc150_accel_validate_trigger(struct iio_dev *indio_dev,
-                                  struct iio_trigger *trig)
+                                        struct iio_trigger *trig)
 {
        struct bmc150_accel_data *data = iio_priv(indio_dev);
        int i;
@@ -963,6 +961,7 @@ static int __bmc150_accel_fifo_flush(struct iio_dev *indio_dev,
        u16 buffer[BMC150_ACCEL_FIFO_LENGTH * 3];
        int64_t tstamp;
        uint64_t sample_period;
+
        ret = i2c_smbus_read_byte_data(data->client,
                                       BMC150_ACCEL_REG_FIFO_STATUS);
        if (ret < 0) {
@@ -1255,7 +1254,7 @@ static int bmc150_accel_trig_try_reen(struct iio_trigger *trig)
 }
 
 static int bmc150_accel_trigger_set_state(struct iio_trigger *trig,
-                                                  bool state)
+                                         bool state)
 {
        struct bmc150_accel_trigger *t = iio_trigger_get_drvdata(trig);
        struct bmc150_accel_data *data = t->data;
@@ -1314,26 +1313,32 @@ static int bmc150_accel_handle_roc_event(struct iio_dev *indio_dev)
                dir = IIO_EV_DIR_RISING;
 
        if (ret & BMC150_ACCEL_ANY_MOTION_BIT_X)
-               iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ACCEL,
-                                                       0,
-                                                       IIO_MOD_X,
-                                                       IIO_EV_TYPE_ROC,
-                                                       dir),
-                                                       data->timestamp);
+               iio_push_event(indio_dev,
+                              IIO_MOD_EVENT_CODE(IIO_ACCEL,
+                                                 0,
+                                                 IIO_MOD_X,
+                                                 IIO_EV_TYPE_ROC,
+                                                 dir),
+                              data->timestamp);
+
        if (ret & BMC150_ACCEL_ANY_MOTION_BIT_Y)
-               iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ACCEL,
-                                                       0,
-                                                       IIO_MOD_Y,
-                                                       IIO_EV_TYPE_ROC,
-                                                       dir),
-                                                       data->timestamp);
+               iio_push_event(indio_dev,
+                              IIO_MOD_EVENT_CODE(IIO_ACCEL,
+                                                 0,
+                                                 IIO_MOD_Y,
+                                                 IIO_EV_TYPE_ROC,
+                                                 dir),
+                              data->timestamp);
+
        if (ret & BMC150_ACCEL_ANY_MOTION_BIT_Z)
-               iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ACCEL,
-                                                       0,
-                                                       IIO_MOD_Z,
-                                                       IIO_EV_TYPE_ROC,
-                                                       dir),
-                                                       data->timestamp);
+               iio_push_event(indio_dev,
+                              IIO_MOD_EVENT_CODE(IIO_ACCEL,
+                                                 0,
+                                                 IIO_MOD_Z,
+                                                 IIO_EV_TYPE_ROC,
+                                                 dir),
+                              data->timestamp);
+
        return ret;
 }
 
@@ -1365,7 +1370,9 @@ static irqreturn_t bmc150_accel_irq_thread_handler(int irq, void *private)
                                        BMC150_ACCEL_INT_MODE_LATCH_INT |
                                        BMC150_ACCEL_INT_MODE_LATCH_RESET);
                if (ret)
-                       dev_err(&data->client->dev, "Error writing reg_int_rst_latch\n");
+                       dev_err(&data->client->dev,
+                               "Error writing reg_int_rst_latch\n");
+
                ret = IRQ_HANDLED;
        } else {
                ret = IRQ_NONE;
@@ -1412,13 +1419,13 @@ static const char *bmc150_accel_match_acpi_device(struct device *dev, int *data)
        if (!id)
                return NULL;
 
-       *data = (int) id->driver_data;
+       *data = (int)id->driver_data;
 
        return dev_name(dev);
 }
 
 static int bmc150_accel_gpio_probe(struct i2c_client *client,
-                                       struct bmc150_accel_data *data)
+                                  struct bmc150_accel_data *data)
 {
        struct device *dev;
        struct gpio_desc *gpio;
index 0d9bd35..8128579 100644 (file)
@@ -658,10 +658,8 @@ static int kxcjk1013_set_scale(struct kxcjk1013_data *data, int val)
        int ret, i;
        enum kxcjk1013_mode store_mode;
 
-
        for (i = 0; i < ARRAY_SIZE(KXCJK1013_scale_table); ++i) {
                if (KXCJK1013_scale_table[i].scale == val) {
-
                        ret = kxcjk1013_get_mode(data, &store_mode);
                        if (ret < 0)
                                return ret;
@@ -820,7 +818,6 @@ static int kxcjk1013_read_event_config(struct iio_dev *indio_dev,
                                          enum iio_event_type type,
                                          enum iio_event_direction dir)
 {
-
        struct kxcjk1013_data *data = iio_priv(indio_dev);
 
        return data->ev_enable_state;
index 2fd2a99..c34c5ce 100644 (file)
@@ -297,7 +297,7 @@ EXPORT_SYMBOL(mma9551_read_status_byte);
  * Returns: 0 on success, negative value on failure.
  */
 int mma9551_read_config_word(struct i2c_client *client, u8 app_id,
-                           u16 reg, u16 *val)
+                            u16 reg, u16 *val)
 {
        int ret;
        __be16 v;
@@ -328,12 +328,12 @@ EXPORT_SYMBOL(mma9551_read_config_word);
  * Returns: 0 on success, negative value on failure.
  */
 int mma9551_write_config_word(struct i2c_client *client, u8 app_id,
-                            u16 reg, u16 val)
+                             u16 reg, u16 val)
 {
        __be16 v = cpu_to_be16(val);
 
        return mma9551_transfer(client, app_id, MMA9551_CMD_WRITE_CONFIG, reg,
-                               (u8 *) &v, 2, NULL, 0);
+                               (u8 *)&v, 2, NULL, 0);
 }
 EXPORT_SYMBOL(mma9551_write_config_word);
 
@@ -373,7 +373,7 @@ EXPORT_SYMBOL(mma9551_read_status_word);
  * @client:    I2C client
  * @app_id:    Application ID
  * @reg:       Application register
- * @len:       Length of array to read in bytes
+ * @len:       Length of array to read (in words)
  * @buf:       Array of words to read
  *
  * Read multiple configuration registers (word-sized registers).
@@ -385,23 +385,22 @@ EXPORT_SYMBOL(mma9551_read_status_word);
  * Returns: 0 on success, negative value on failure.
  */
 int mma9551_read_config_words(struct i2c_client *client, u8 app_id,
-                            u16 reg, u8 len, u16 *buf)
+                             u16 reg, u8 len, u16 *buf)
 {
        int ret, i;
-       int len_words = len / sizeof(u16);
        __be16 be_buf[MMA9551_MAX_MAILBOX_DATA_REGS / 2];
 
-       if (len_words > ARRAY_SIZE(be_buf)) {
+       if (len > ARRAY_SIZE(be_buf)) {
                dev_err(&client->dev, "Invalid buffer size %d\n", len);
                return -EINVAL;
        }
 
        ret = mma9551_transfer(client, app_id, MMA9551_CMD_READ_CONFIG,
-                              reg, NULL, 0, (u8 *) be_buf, len);
+                              reg, NULL, 0, (u8 *)be_buf, len * sizeof(u16));
        if (ret < 0)
                return ret;
 
-       for (i = 0; i < len_words; i++)
+       for (i = 0; i < len; i++)
                buf[i] = be16_to_cpu(be_buf[i]);
 
        return 0;
@@ -413,7 +412,7 @@ EXPORT_SYMBOL(mma9551_read_config_words);
  * @client:    I2C client
  * @app_id:    Application ID
  * @reg:       Application register
- * @len:       Length of array to read in bytes
+ * @len:       Length of array to read (in words)
  * @buf:       Array of words to read
  *
  * Read multiple status registers (word-sized registers).
@@ -428,20 +427,19 @@ int mma9551_read_status_words(struct i2c_client *client, u8 app_id,
                              u16 reg, u8 len, u16 *buf)
 {
        int ret, i;
-       int len_words = len / sizeof(u16);
        __be16 be_buf[MMA9551_MAX_MAILBOX_DATA_REGS / 2];
 
-       if (len_words > ARRAY_SIZE(be_buf)) {
+       if (len > ARRAY_SIZE(be_buf)) {
                dev_err(&client->dev, "Invalid buffer size %d\n", len);
                return -EINVAL;
        }
 
        ret = mma9551_transfer(client, app_id, MMA9551_CMD_READ_STATUS,
-                              reg, NULL, 0, (u8 *) be_buf, len);
+                              reg, NULL, 0, (u8 *)be_buf, len * sizeof(u16));
        if (ret < 0)
                return ret;
 
-       for (i = 0; i < len_words; i++)
+       for (i = 0; i < len; i++)
                buf[i] = be16_to_cpu(be_buf[i]);
 
        return 0;
@@ -453,7 +451,7 @@ EXPORT_SYMBOL(mma9551_read_status_words);
  * @client:    I2C client
  * @app_id:    Application ID
  * @reg:       Application register
- * @len:       Length of array to write in bytes
+ * @len:       Length of array to write (in words)
  * @buf:       Array of words to write
  *
  * Write multiple configuration registers (word-sized registers).
@@ -468,19 +466,18 @@ int mma9551_write_config_words(struct i2c_client *client, u8 app_id,
                               u16 reg, u8 len, u16 *buf)
 {
        int i;
-       int len_words = len / sizeof(u16);
        __be16 be_buf[(MMA9551_MAX_MAILBOX_DATA_REGS - 1) / 2];
 
-       if (len_words > ARRAY_SIZE(be_buf)) {
+       if (len > ARRAY_SIZE(be_buf)) {
                dev_err(&client->dev, "Invalid buffer size %d\n", len);
                return -EINVAL;
        }
 
-       for (i = 0; i < len_words; i++)
+       for (i = 0; i < len; i++)
                be_buf[i] = cpu_to_be16(buf[i]);
 
        return mma9551_transfer(client, app_id, MMA9551_CMD_WRITE_CONFIG,
-                               reg, (u8 *) be_buf, len, NULL, 0);
+                               reg, (u8 *)be_buf, len * sizeof(u16), NULL, 0);
 }
 EXPORT_SYMBOL(mma9551_write_config_words);
 
index 79939e4..5e88e64 100644 (file)
@@ -53,13 +53,13 @@ int mma9551_write_config_byte(struct i2c_client *client, u8 app_id,
 int mma9551_read_status_byte(struct i2c_client *client, u8 app_id,
                             u16 reg, u8 *val);
 int mma9551_read_config_word(struct i2c_client *client, u8 app_id,
-                           u16 reg, u16 *val);
+                            u16 reg, u16 *val);
 int mma9551_write_config_word(struct i2c_client *client, u8 app_id,
-                            u16 reg, u16 val);
+                             u16 reg, u16 val);
 int mma9551_read_status_word(struct i2c_client *client, u8 app_id,
                             u16 reg, u16 *val);
 int mma9551_read_config_words(struct i2c_client *client, u8 app_id,
-                            u16 reg, u8 len, u16 *buf);
+                             u16 reg, u8 len, u16 *buf);
 int mma9551_read_status_words(struct i2c_client *client, u8 app_id,
                              u16 reg, u8 len, u16 *buf);
 int mma9551_write_config_words(struct i2c_client *client, u8 app_id,
index 8bfc618..a605280 100644 (file)
@@ -182,6 +182,10 @@ struct mma9553_conf_regs {
 
 struct mma9553_data {
        struct i2c_client *client;
+       /*
+        * 1. Serialize access to HW (requested by mma9551_core API).
+        * 2. Serialize sequences that power on/off the device and access HW.
+        */
        struct mutex mutex;
        struct mma9553_conf_regs conf;
        struct mma9553_event events[MMA9553_EVENTS_INFO_SIZE];
@@ -322,7 +326,8 @@ static int mma9553_read_activity_stepcnt(struct mma9553_data *data,
        int ret;
 
        ret = mma9551_read_status_words(data->client, MMA9551_APPID_PEDOMETER,
-                                       MMA9553_REG_STATUS, sizeof(u32), buf);
+                                       MMA9553_REG_STATUS, ARRAY_SIZE(buf),
+                                       buf);
        if (ret < 0) {
                dev_err(&data->client->dev,
                        "error reading status and stepcnt\n");
@@ -342,10 +347,10 @@ static int mma9553_conf_gpio(struct mma9553_data *data)
        struct mma9553_event *ev_step_detect;
        bool activity_enabled;
 
-       activity_enabled =
-           mma9553_is_any_event_enabled(data, true, IIO_ACTIVITY);
-       ev_step_detect =
-           mma9553_get_event(data, IIO_STEPS, IIO_NO_MOD, IIO_EV_DIR_NONE);
+       activity_enabled = mma9553_is_any_event_enabled(data, true,
+                                                       IIO_ACTIVITY);
+       ev_step_detect = mma9553_get_event(data, IIO_STEPS, IIO_NO_MOD,
+                                          IIO_EV_DIR_NONE);
 
        /*
         * If both step detector and activity are enabled, use the MRGFL bit.
@@ -371,9 +376,8 @@ static int mma9553_conf_gpio(struct mma9553_data *data)
                        return ret;
        }
 
-       ret = mma9551_gpio_config(data->client,
-                                 MMA9553_DEFAULT_GPIO_PIN,
-                                 appid, bitnum, MMA9553_DEFAULT_GPIO_POLARITY);
+       ret = mma9551_gpio_config(data->client, MMA9553_DEFAULT_GPIO_PIN, appid,
+                                 bitnum, MMA9553_DEFAULT_GPIO_POLARITY);
        if (ret < 0)
                return ret;
        data->gpio_bitnum = bitnum;
@@ -394,17 +398,16 @@ static int mma9553_init(struct mma9553_data *data)
         * a device identification command to differentiate the MMA9553L
         * from the MMA9550L.
         */
-       ret =
-           mma9551_read_config_words(data->client, MMA9551_APPID_PEDOMETER,
-                                     MMA9553_REG_CONF_SLEEPMIN,
-                                     sizeof(data->conf), (u16 *) &data->conf);
+       ret = mma9551_read_config_words(data->client, MMA9551_APPID_PEDOMETER,
+                                       MMA9553_REG_CONF_SLEEPMIN,
+                                       sizeof(data->conf) / sizeof(u16),
+                                       (u16 *)&data->conf);
        if (ret < 0) {
                dev_err(&data->client->dev,
                        "failed to read configuration registers\n");
                return ret;
        }
 
-
        /* Reset GPIO */
        data->gpio_bitnum = MMA9553_MAX_BITNUM;
        ret = mma9553_conf_gpio(data);
@@ -419,18 +422,18 @@ static int mma9553_init(struct mma9553_data *data)
        data->conf.sleepmin = MMA9553_DEFAULT_SLEEPMIN;
        data->conf.sleepmax = MMA9553_DEFAULT_SLEEPMAX;
        data->conf.sleepthd = MMA9553_DEFAULT_SLEEPTHD;
-       data->conf.config =
-           mma9553_set_bits(data->conf.config, 1, MMA9553_MASK_CONF_CONFIG);
+       data->conf.config = mma9553_set_bits(data->conf.config, 1,
+                                            MMA9553_MASK_CONF_CONFIG);
        /*
         * Clear the activity debounce counter when the activity level changes,
         * so that the confidence level applies for any activity level.
         */
        data->conf.config = mma9553_set_bits(data->conf.config, 1,
                                             MMA9553_MASK_CONF_ACT_DBCNTM);
-       ret =
-           mma9551_write_config_words(data->client, MMA9551_APPID_PEDOMETER,
-                                      MMA9553_REG_CONF_SLEEPMIN,
-                                      sizeof(data->conf), (u16 *) &data->conf);
+       ret = mma9551_write_config_words(data->client, MMA9551_APPID_PEDOMETER,
+                                        MMA9553_REG_CONF_SLEEPMIN,
+                                        sizeof(data->conf) / sizeof(u16),
+                                        (u16 *)&data->conf);
        if (ret < 0) {
                dev_err(&data->client->dev,
                        "failed to write configuration registers\n");
@@ -567,7 +570,7 @@ static int mma9553_read_raw(struct iio_dev *indio_dev,
                return IIO_VAL_INT;
        case IIO_CHAN_INFO_CALIBHEIGHT:
                tmp = mma9553_get_bits(data->conf.height_weight,
-                                       MMA9553_MASK_CONF_HEIGHT);
+                                      MMA9553_MASK_CONF_HEIGHT);
                *val = tmp / 100;       /* cm to m */
                *val2 = (tmp % 100) * 10000;
                return IIO_VAL_INT_PLUS_MICRO;
@@ -719,7 +722,6 @@ static int mma9553_read_event_config(struct iio_dev *indio_dev,
                                     enum iio_event_type type,
                                     enum iio_event_direction dir)
 {
-
        struct mma9553_data *data = iio_priv(indio_dev);
        struct mma9553_event *event;
 
@@ -1026,22 +1028,22 @@ static irqreturn_t mma9553_event_handler(int irq, void *private)
                return IRQ_HANDLED;
        }
 
-       ev_prev_activity =
-           mma9553_get_event(data, IIO_ACTIVITY,
-                             mma9553_activity_to_mod(data->activity),
-                             IIO_EV_DIR_FALLING);
-       ev_activity =
-           mma9553_get_event(data, IIO_ACTIVITY,
-                             mma9553_activity_to_mod(activity),
-                             IIO_EV_DIR_RISING);
-       ev_step_detect =
-           mma9553_get_event(data, IIO_STEPS, IIO_NO_MOD, IIO_EV_DIR_NONE);
+       ev_prev_activity = mma9553_get_event(data, IIO_ACTIVITY,
+                                            mma9553_activity_to_mod(
+                                            data->activity),
+                                            IIO_EV_DIR_FALLING);
+       ev_activity = mma9553_get_event(data, IIO_ACTIVITY,
+                                       mma9553_activity_to_mod(activity),
+                                       IIO_EV_DIR_RISING);
+       ev_step_detect = mma9553_get_event(data, IIO_STEPS, IIO_NO_MOD,
+                                          IIO_EV_DIR_NONE);
 
        if (ev_step_detect->enabled && (stepcnt != data->stepcnt)) {
                data->stepcnt = stepcnt;
                iio_push_event(indio_dev,
                               IIO_EVENT_CODE(IIO_STEPS, 0, IIO_NO_MOD,
-                              IIO_EV_DIR_NONE, IIO_EV_TYPE_CHANGE, 0, 0, 0),
+                                             IIO_EV_DIR_NONE,
+                                             IIO_EV_TYPE_CHANGE, 0, 0, 0),
                               data->timestamp);
        }
 
@@ -1051,17 +1053,19 @@ static irqreturn_t mma9553_event_handler(int irq, void *private)
                if (ev_prev_activity && ev_prev_activity->enabled)
                        iio_push_event(indio_dev,
                                       IIO_EVENT_CODE(IIO_ACTIVITY, 0,
-                                      ev_prev_activity->info->mod,
-                                      IIO_EV_DIR_FALLING,
-                                      IIO_EV_TYPE_THRESH, 0, 0, 0),
+                                                   ev_prev_activity->info->mod,
+                                                   IIO_EV_DIR_FALLING,
+                                                   IIO_EV_TYPE_THRESH, 0, 0,
+                                                   0),
                                       data->timestamp);
 
                if (ev_activity && ev_activity->enabled)
                        iio_push_event(indio_dev,
                                       IIO_EVENT_CODE(IIO_ACTIVITY, 0,
-                                      ev_activity->info->mod,
-                                      IIO_EV_DIR_RISING,
-                                      IIO_EV_TYPE_THRESH, 0, 0, 0),
+                                                     ev_activity->info->mod,
+                                                     IIO_EV_DIR_RISING,
+                                                     IIO_EV_TYPE_THRESH, 0, 0,
+                                                     0),
                                       data->timestamp);
        }
        mutex_unlock(&data->mutex);
@@ -1156,7 +1160,6 @@ static int mma9553_probe(struct i2c_client *client,
                                client->irq);
                        goto out_poweroff;
                }
-
        }
 
        ret = iio_device_register(indio_dev);
index d4ad72c..a2f1c20 100644 (file)
@@ -122,7 +122,6 @@ MODULE_DEVICE_TABLE(i2c, st_accel_id_table);
 
 static struct i2c_driver st_accel_driver = {
        .driver = {
-               .owner = THIS_MODULE,
                .name = "st-accel-i2c",
                .of_match_table = of_match_ptr(st_accel_of_match),
        },
index d211d9f..c2bd144 100644 (file)
  */
 
 #include <linux/acpi.h>
+#include <linux/gpio/consumer.h>
 #include <linux/i2c.h>
+#include <linux/interrupt.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/delay.h>
+#include <linux/iio/buffer.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
+#include <linux/iio/trigger.h>
+#include <linux/iio/triggered_buffer.h>
+#include <linux/iio/trigger_consumer.h>
 
 #define STK8312_REG_XOUT               0x00
 #define STK8312_REG_YOUT               0x01
 #define STK8312_REG_ZOUT               0x02
+#define STK8312_REG_INTSU              0x06
 #define STK8312_REG_MODE               0x07
+#define STK8312_REG_SR                 0x08
 #define STK8312_REG_STH                        0x13
 #define STK8312_REG_RESET              0x20
 #define STK8312_REG_AFECTRL            0x24
 #define STK8312_REG_OTPDATA            0x3E
 #define STK8312_REG_OTPCTRL            0x3F
 
-#define STK8312_MODE_ACTIVE            1
-#define STK8312_MODE_STANDBY           0
-#define STK8312_MODE_MASK              0x01
+#define STK8312_MODE_ACTIVE            0x01
+#define STK8312_MODE_STANDBY           0x00
+#define STK8312_DREADY_BIT             0x10
+#define STK8312_INT_MODE               0xC0
 #define STK8312_RNG_MASK               0xC0
+#define STK8312_SR_MASK                        0x07
+#define STK8312_SR_400HZ_IDX           0
 #define STK8312_RNG_SHIFT              6
 #define STK8312_READ_RETRIES           16
+#define STK8312_ALL_CHANNEL_MASK       7
+#define STK8312_ALL_CHANNEL_SIZE       3
 
 #define STK8312_DRIVER_NAME            "stk8312"
+#define STK8312_GPIO                   "stk8312_gpio"
+#define STK8312_IRQ_NAME               "stk8312_event"
 
 /*
  * The accelerometer has two measurement ranges:
@@ -53,32 +68,56 @@ static const int stk8312_scale_table[][2] = {
        {0, 461600}, {1, 231100}
 };
 
-#define STK8312_ACCEL_CHANNEL(reg, axis) {                     \
-       .type = IIO_ACCEL,                                      \
-       .address = reg,                                         \
-       .modified = 1,                                          \
-       .channel2 = IIO_MOD_##axis,                             \
-       .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),           \
-       .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),   \
+static const struct {
+       u16 val;
+       u32 val2;
+} stk8312_samp_freq_table[] = {
+       {400, 0}, {200, 0}, {100, 0}, {50, 0}, {25, 0},
+       {12, 500000}, {6, 250000}, {3, 125000}
+};
+
+#define STK8312_ACCEL_CHANNEL(index, reg, axis) {                      \
+       .type = IIO_ACCEL,                                              \
+       .address = reg,                                                 \
+       .modified = 1,                                                  \
+       .channel2 = IIO_MOD_##axis,                                     \
+       .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),                   \
+       .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) |          \
+                                   BIT(IIO_CHAN_INFO_SAMP_FREQ),       \
+       .scan_index = index,                                            \
+       .scan_type = {                                                  \
+               .sign = 's',                                            \
+               .realbits = 8,                                          \
+               .storagebits = 8,                                       \
+               .endianness = IIO_CPU,                                  \
+       },                                                              \
 }
 
 static const struct iio_chan_spec stk8312_channels[] = {
-       STK8312_ACCEL_CHANNEL(STK8312_REG_XOUT, X),
-       STK8312_ACCEL_CHANNEL(STK8312_REG_YOUT, Y),
-       STK8312_ACCEL_CHANNEL(STK8312_REG_ZOUT, Z),
+       STK8312_ACCEL_CHANNEL(0, STK8312_REG_XOUT, X),
+       STK8312_ACCEL_CHANNEL(1, STK8312_REG_YOUT, Y),
+       STK8312_ACCEL_CHANNEL(2, STK8312_REG_ZOUT, Z),
+       IIO_CHAN_SOFT_TIMESTAMP(3),
 };
 
 struct stk8312_data {
        struct i2c_client *client;
        struct mutex lock;
        int range;
+       u8 sample_rate_idx;
        u8 mode;
+       struct iio_trigger *dready_trig;
+       bool dready_trigger_on;
+       s8 buffer[16]; /* 3x8-bit channels + 5x8 padding + 64-bit timestamp */
 };
 
 static IIO_CONST_ATTR(in_accel_scale_available, STK8312_SCALE_AVAIL);
 
+static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("3.125 6.25 12.5 25 50 100 200 400");
+
 static struct attribute *stk8312_attributes[] = {
        &iio_const_attr_in_accel_scale_available.dev_attr.attr,
+       &iio_const_attr_sampling_frequency_available.dev_attr.attr,
        NULL,
 };
 
@@ -130,31 +169,19 @@ exit_err:
 static int stk8312_set_mode(struct stk8312_data *data, u8 mode)
 {
        int ret;
-       u8 masked_reg;
        struct i2c_client *client = data->client;
 
-       if (mode > 1)
-               return -EINVAL;
-       else if (mode == data->mode)
+       if (mode == data->mode)
                return 0;
 
-       ret = i2c_smbus_read_byte_data(client, STK8312_REG_MODE);
-       if (ret < 0) {
-               dev_err(&client->dev, "failed to change sensor mode\n");
-               return ret;
-       }
-       masked_reg = ret & (~STK8312_MODE_MASK);
-       masked_reg |= mode;
-
-       ret = i2c_smbus_write_byte_data(client,
-                       STK8312_REG_MODE, masked_reg);
+       ret = i2c_smbus_write_byte_data(client, STK8312_REG_MODE, mode);
        if (ret < 0) {
                dev_err(&client->dev, "failed to change sensor mode\n");
                return ret;
        }
 
        data->mode = mode;
-       if (mode == STK8312_MODE_ACTIVE) {
+       if (mode & STK8312_MODE_ACTIVE) {
                /* Need to run OTP sequence before entering active mode */
                usleep_range(1000, 5000);
                ret = stk8312_otp_init(data);
@@ -163,6 +190,85 @@ static int stk8312_set_mode(struct stk8312_data *data, u8 mode)
        return ret;
 }
 
+static int stk8312_set_interrupts(struct stk8312_data *data, u8 int_mask)
+{
+       int ret;
+       u8 mode;
+       struct i2c_client *client = data->client;
+
+       mode = data->mode;
+       /* We need to go in standby mode to modify registers */
+       ret = stk8312_set_mode(data, STK8312_MODE_STANDBY);
+       if (ret < 0)
+               return ret;
+
+       ret = i2c_smbus_write_byte_data(client, STK8312_REG_INTSU, int_mask);
+       if (ret < 0)
+               dev_err(&client->dev, "failed to set interrupts\n");
+
+       return stk8312_set_mode(data, mode);
+}
+
+static int stk8312_data_rdy_trigger_set_state(struct iio_trigger *trig,
+                                             bool state)
+{
+       struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
+       struct stk8312_data *data = iio_priv(indio_dev);
+       int ret;
+
+       if (state)
+               ret = stk8312_set_interrupts(data, STK8312_DREADY_BIT);
+       else
+               ret = stk8312_set_interrupts(data, 0x00);
+
+       if (ret < 0) {
+               dev_err(&data->client->dev, "failed to set trigger state\n");
+               return ret;
+       }
+
+       data->dready_trigger_on = state;
+
+       return ret;
+}
+
+static const struct iio_trigger_ops stk8312_trigger_ops = {
+       .set_trigger_state = stk8312_data_rdy_trigger_set_state,
+       .owner = THIS_MODULE,
+};
+
+static int stk8312_set_sample_rate(struct stk8312_data *data, int rate)
+{
+       int ret;
+       u8 masked_reg;
+       u8 mode;
+       struct i2c_client *client = data->client;
+
+       if (rate == data->sample_rate_idx)
+               return 0;
+
+       mode = data->mode;
+       /* We need to go in standby mode to modify registers */
+       ret = stk8312_set_mode(data, STK8312_MODE_STANDBY);
+       if (ret < 0)
+               return ret;
+
+       ret = i2c_smbus_read_byte_data(client, STK8312_REG_SR);
+       if (ret < 0) {
+               dev_err(&client->dev, "failed to set sampling rate\n");
+               return ret;
+       }
+
+       masked_reg = (ret & (~STK8312_SR_MASK)) | rate;
+
+       ret = i2c_smbus_write_byte_data(client, STK8312_REG_SR, masked_reg);
+       if (ret < 0)
+               dev_err(&client->dev, "failed to set sampling rate\n");
+       else
+               data->sample_rate_idx = rate;
+
+       return stk8312_set_mode(data, mode);
+}
+
 static int stk8312_set_range(struct stk8312_data *data, u8 range)
 {
        int ret;
@@ -208,12 +314,10 @@ static int stk8312_read_accel(struct stk8312_data *data, u8 address)
                return -EINVAL;
 
        ret = i2c_smbus_read_byte_data(client, address);
-       if (ret < 0) {
+       if (ret < 0)
                dev_err(&client->dev, "register read failed\n");
-               return ret;
-       }
 
-       return sign_extend32(ret, 7);
+       return ret;
 }
 
 static int stk8312_read_raw(struct iio_dev *indio_dev,
@@ -221,20 +325,37 @@ static int stk8312_read_raw(struct iio_dev *indio_dev,
                            int *val, int *val2, long mask)
 {
        struct stk8312_data *data = iio_priv(indio_dev);
-
-       if (chan->type != IIO_ACCEL)
-               return -EINVAL;
+       int ret;
 
        switch (mask) {
        case IIO_CHAN_INFO_RAW:
+               if (iio_buffer_enabled(indio_dev))
+                       return -EBUSY;
                mutex_lock(&data->lock);
-               *val = stk8312_read_accel(data, chan->address);
+               ret = stk8312_set_mode(data, data->mode | STK8312_MODE_ACTIVE);
+               if (ret < 0) {
+                       mutex_unlock(&data->lock);
+                       return -EINVAL;
+               }
+               ret = stk8312_read_accel(data, chan->address);
+               if (ret < 0) {
+                       stk8312_set_mode(data,
+                                        data->mode & (~STK8312_MODE_ACTIVE));
+                       mutex_unlock(&data->lock);
+                       return -EINVAL;
+               }
+               *val = sign_extend32(ret, 7);
+               stk8312_set_mode(data, data->mode & (~STK8312_MODE_ACTIVE));
                mutex_unlock(&data->lock);
                return IIO_VAL_INT;
        case IIO_CHAN_INFO_SCALE:
                *val = stk8312_scale_table[data->range - 1][0];
                *val2 = stk8312_scale_table[data->range - 1][1];
                return IIO_VAL_INT_PLUS_MICRO;
+       case IIO_CHAN_INFO_SAMP_FREQ:
+               *val = stk8312_samp_freq_table[data->sample_rate_idx].val;
+               *val2 = stk8312_samp_freq_table[data->sample_rate_idx].val2;
+               return IIO_VAL_INT_PLUS_MICRO;
        }
 
        return -EINVAL;
@@ -265,6 +386,20 @@ static int stk8312_write_raw(struct iio_dev *indio_dev,
                mutex_unlock(&data->lock);
 
                return ret;
+       case IIO_CHAN_INFO_SAMP_FREQ:
+               for (i = 0; i < ARRAY_SIZE(stk8312_samp_freq_table); i++)
+                       if (val == stk8312_samp_freq_table[i].val &&
+                           val2 == stk8312_samp_freq_table[i].val2) {
+                               index = i;
+                               break;
+                       }
+               if (index < 0)
+                       return -EINVAL;
+               mutex_lock(&data->lock);
+               ret = stk8312_set_sample_rate(data, index);
+               mutex_unlock(&data->lock);
+
+               return ret;
        }
 
        return -EINVAL;
@@ -277,6 +412,109 @@ static const struct iio_info stk8312_info = {
        .attrs                  = &stk8312_attribute_group,
 };
 
+static irqreturn_t stk8312_trigger_handler(int irq, void *p)
+{
+       struct iio_poll_func *pf = p;
+       struct iio_dev *indio_dev = pf->indio_dev;
+       struct stk8312_data *data = iio_priv(indio_dev);
+       int bit, ret, i = 0;
+       u8 buffer[STK8312_ALL_CHANNEL_SIZE];
+
+       mutex_lock(&data->lock);
+       /*
+        * Do a bulk read if all channels are requested,
+        * from 0x00 (XOUT) to 0x02 (ZOUT)
+        */
+       if (*(indio_dev->active_scan_mask) == STK8312_ALL_CHANNEL_MASK) {
+               ret = i2c_smbus_read_i2c_block_data(data->client,
+                                                   STK8312_REG_XOUT,
+                                                   STK8312_ALL_CHANNEL_SIZE,
+                                                   buffer);
+               if (ret < STK8312_ALL_CHANNEL_SIZE) {
+                       dev_err(&data->client->dev, "register read failed\n");
+                       mutex_unlock(&data->lock);
+                       goto err;
+               }
+               data->buffer[0] = buffer[0];
+               data->buffer[1] = buffer[1];
+               data->buffer[2] = buffer[2];
+       } else {
+               for_each_set_bit(bit, indio_dev->active_scan_mask,
+                          indio_dev->masklength) {
+                       ret = stk8312_read_accel(data, bit);
+                       if (ret < 0) {
+                               mutex_unlock(&data->lock);
+                               goto err;
+                       }
+                       data->buffer[i++] = ret;
+               }
+       }
+       mutex_unlock(&data->lock);
+
+       iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
+                                          pf->timestamp);
+err:
+       iio_trigger_notify_done(indio_dev->trig);
+
+       return IRQ_HANDLED;
+}
+
+static irqreturn_t stk8312_data_rdy_trig_poll(int irq, void *private)
+{
+       struct iio_dev *indio_dev = private;
+       struct stk8312_data *data = iio_priv(indio_dev);
+
+       if (data->dready_trigger_on)
+               iio_trigger_poll(data->dready_trig);
+
+       return IRQ_HANDLED;
+}
+
+static int stk8312_buffer_preenable(struct iio_dev *indio_dev)
+{
+       struct stk8312_data *data = iio_priv(indio_dev);
+
+       return stk8312_set_mode(data, data->mode | STK8312_MODE_ACTIVE);
+}
+
+static int stk8312_buffer_postdisable(struct iio_dev *indio_dev)
+{
+       struct stk8312_data *data = iio_priv(indio_dev);
+
+       return stk8312_set_mode(data, data->mode & (~STK8312_MODE_ACTIVE));
+}
+
+static const struct iio_buffer_setup_ops stk8312_buffer_setup_ops = {
+       .preenable   = stk8312_buffer_preenable,
+       .postenable  = iio_triggered_buffer_postenable,
+       .predisable  = iio_triggered_buffer_predisable,
+       .postdisable = stk8312_buffer_postdisable,
+};
+
+static int stk8312_gpio_probe(struct i2c_client *client)
+{
+       struct device *dev;
+       struct gpio_desc *gpio;
+       int ret;
+
+       if (!client)
+               return -EINVAL;
+
+       dev = &client->dev;
+
+       /* data ready gpio interrupt pin */
+       gpio = devm_gpiod_get_index(dev, STK8312_GPIO, 0, GPIOD_IN);
+       if (IS_ERR(gpio)) {
+               dev_err(dev, "acpi gpio get index failed\n");
+               return PTR_ERR(gpio);
+       }
+
+       ret = gpiod_to_irq(gpio);
+       dev_dbg(dev, "GPIO resource, no:%d irq:%d\n", desc_to_gpio(gpio), ret);
+
+       return ret;
+}
+
 static int stk8312_probe(struct i2c_client *client,
                         const struct i2c_device_id *id)
 {
@@ -308,30 +546,90 @@ static int stk8312_probe(struct i2c_client *client,
                dev_err(&client->dev, "failed to reset sensor\n");
                return ret;
        }
+       data->sample_rate_idx = STK8312_SR_400HZ_IDX;
        ret = stk8312_set_range(data, 1);
        if (ret < 0)
                return ret;
 
-       ret = stk8312_set_mode(data, STK8312_MODE_ACTIVE);
+       ret = stk8312_set_mode(data, STK8312_INT_MODE | STK8312_MODE_ACTIVE);
        if (ret < 0)
                return ret;
 
+       if (client->irq < 0)
+               client->irq = stk8312_gpio_probe(client);
+
+       if (client->irq >= 0) {
+               ret = devm_request_threaded_irq(&client->dev, client->irq,
+                                               stk8312_data_rdy_trig_poll,
+                                               NULL,
+                                               IRQF_TRIGGER_RISING |
+                                               IRQF_ONESHOT,
+                                               STK8312_IRQ_NAME,
+                                               indio_dev);
+               if (ret < 0) {
+                       dev_err(&client->dev, "request irq %d failed\n",
+                               client->irq);
+                       goto err_power_off;
+               }
+
+               data->dready_trig = devm_iio_trigger_alloc(&client->dev,
+                                                          "%s-dev%d",
+                                                          indio_dev->name,
+                                                          indio_dev->id);
+               if (!data->dready_trig) {
+                       ret = -ENOMEM;
+                       goto err_power_off;
+               }
+
+               data->dready_trig->dev.parent = &client->dev;
+               data->dready_trig->ops = &stk8312_trigger_ops;
+               iio_trigger_set_drvdata(data->dready_trig, indio_dev);
+               ret = iio_trigger_register(data->dready_trig);
+               if (ret) {
+                       dev_err(&client->dev, "iio trigger register failed\n");
+                       goto err_power_off;
+               }
+       }
+
+       ret = iio_triggered_buffer_setup(indio_dev,
+                                        iio_pollfunc_store_time,
+                                        stk8312_trigger_handler,
+                                        &stk8312_buffer_setup_ops);
+       if (ret < 0) {
+               dev_err(&client->dev, "iio triggered buffer setup failed\n");
+               goto err_trigger_unregister;
+       }
+
        ret = iio_device_register(indio_dev);
        if (ret < 0) {
                dev_err(&client->dev, "device_register failed\n");
-               stk8312_set_mode(data, STK8312_MODE_STANDBY);
+               goto err_buffer_cleanup;
        }
 
        return ret;
+
+err_buffer_cleanup:
+       iio_triggered_buffer_cleanup(indio_dev);
+err_trigger_unregister:
+       if (data->dready_trig)
+               iio_trigger_unregister(data->dready_trig);
+err_power_off:
+       stk8312_set_mode(data, STK8312_MODE_STANDBY);
+       return ret;
 }
 
 static int stk8312_remove(struct i2c_client *client)
 {
        struct iio_dev *indio_dev = i2c_get_clientdata(client);
+       struct stk8312_data *data = iio_priv(indio_dev);
 
        iio_device_unregister(indio_dev);
+       iio_triggered_buffer_cleanup(indio_dev);
+
+       if (data->dready_trig)
+               iio_trigger_unregister(data->dready_trig);
 
-       return stk8312_set_mode(iio_priv(indio_dev), STK8312_MODE_STANDBY);
+       return stk8312_set_mode(data, STK8312_MODE_STANDBY);
 }
 
 #ifdef CONFIG_PM_SLEEP
@@ -341,7 +639,7 @@ static int stk8312_suspend(struct device *dev)
 
        data = iio_priv(i2c_get_clientdata(to_i2c_client(dev)));
 
-       return stk8312_set_mode(data, STK8312_MODE_STANDBY);
+       return stk8312_set_mode(data, data->mode & (~STK8312_MODE_ACTIVE));
 }
 
 static int stk8312_resume(struct device *dev)
@@ -350,7 +648,7 @@ static int stk8312_resume(struct device *dev)
 
        data = iio_priv(i2c_get_clientdata(to_i2c_client(dev)));
 
-       return stk8312_set_mode(data, STK8312_MODE_ACTIVE);
+       return stk8312_set_mode(data, data->mode | STK8312_MODE_ACTIVE);
 }
 
 static SIMPLE_DEV_PM_OPS(stk8312_pm_ops, stk8312_suspend, stk8312_resume);
index 30950c6..16cee63 100644 (file)
  */
 
 #include <linux/acpi.h>
+#include <linux/gpio/consumer.h>
 #include <linux/i2c.h>
+#include <linux/interrupt.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/iio/buffer.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
+#include <linux/iio/trigger.h>
+#include <linux/iio/triggered_buffer.h>
+#include <linux/iio/trigger_consumer.h>
 
 #define STK8BA50_REG_XOUT                      0x02
 #define STK8BA50_REG_YOUT                      0x04
 #define STK8BA50_REG_ZOUT                      0x06
 #define STK8BA50_REG_RANGE                     0x0F
+#define STK8BA50_REG_BWSEL                     0x10
 #define STK8BA50_REG_POWMODE                   0x11
 #define STK8BA50_REG_SWRST                     0x14
+#define STK8BA50_REG_INTEN2                    0x17
+#define STK8BA50_REG_INTMAP2                   0x1A
 
 #define STK8BA50_MODE_NORMAL                   0
 #define STK8BA50_MODE_SUSPEND                  1
 #define STK8BA50_MODE_POWERBIT                 BIT(7)
 #define STK8BA50_DATA_SHIFT                    6
 #define STK8BA50_RESET_CMD                     0xB6
+#define STK8BA50_SR_1792HZ_IDX                 7
+#define STK8BA50_DREADY_INT_MASK               0x10
+#define STK8BA50_DREADY_INT_MAP                        0x81
+#define STK8BA50_ALL_CHANNEL_MASK              7
+#define STK8BA50_ALL_CHANNEL_SIZE              6
 
 #define STK8BA50_DRIVER_NAME                   "stk8ba50"
+#define STK8BA50_GPIO                          "stk8ba50_gpio"
+#define STK8BA50_IRQ_NAME                      "stk8ba50_event"
 
 #define STK8BA50_SCALE_AVAIL                   "0.0384 0.0767 0.1534 0.3069"
 
  *
  * Locally, the range is stored as a table index.
  */
-static const int stk8ba50_scale_table[][2] = {
+static const struct {
+       u8 reg_val;
+       u32 scale_val;
+} stk8ba50_scale_table[] = {
        {3, 38400}, {5, 76700}, {8, 153400}, {12, 306900}
 };
 
+/* Sample rates are stored as { <register value>, <Hz value> } */
+static const struct {
+       u8 reg_val;
+       u16 samp_freq;
+} stk8ba50_samp_freq_table[] = {
+       {0x08, 14},  {0x09, 25},  {0x0A, 56},  {0x0B, 112},
+       {0x0C, 224}, {0x0D, 448}, {0x0E, 896}, {0x0F, 1792}
+};
+
+/* Used to map scan mask bits to their corresponding channel register. */
+static const int stk8ba50_channel_table[] = {
+       STK8BA50_REG_XOUT,
+       STK8BA50_REG_YOUT,
+       STK8BA50_REG_ZOUT
+};
+
 struct stk8ba50_data {
        struct i2c_client *client;
        struct mutex lock;
        int range;
+       u8 sample_rate_idx;
+       struct iio_trigger *dready_trig;
+       bool dready_trigger_on;
+       /*
+        * 3 x 16-bit channels (10-bit data, 6-bit padding) +
+        * 1 x 16 padding +
+        * 4 x 16 64-bit timestamp
+        */
+       s16 buffer[8];
 };
 
-#define STK8BA50_ACCEL_CHANNEL(reg, axis) {                    \
-       .type = IIO_ACCEL,                                      \
-       .address = reg,                                         \
-       .modified = 1,                                          \
-       .channel2 = IIO_MOD_##axis,                             \
-       .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),           \
-       .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),   \
+#define STK8BA50_ACCEL_CHANNEL(index, reg, axis) {                     \
+       .type = IIO_ACCEL,                                              \
+       .address = reg,                                                 \
+       .modified = 1,                                                  \
+       .channel2 = IIO_MOD_##axis,                                     \
+       .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),                   \
+       .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),           \
+                                   BIT(IIO_CHAN_INFO_SAMP_FREQ),       \
+       .scan_index = index,                                            \
+       .scan_type = {                                                  \
+               .sign = 's',                                            \
+               .realbits = 10,                                         \
+               .storagebits = 16,                                      \
+               .shift = STK8BA50_DATA_SHIFT,                           \
+               .endianness = IIO_CPU,                                  \
+       },                                                              \
 }
 
 static const struct iio_chan_spec stk8ba50_channels[] = {
-       STK8BA50_ACCEL_CHANNEL(STK8BA50_REG_XOUT, X),
-       STK8BA50_ACCEL_CHANNEL(STK8BA50_REG_YOUT, Y),
-       STK8BA50_ACCEL_CHANNEL(STK8BA50_REG_ZOUT, Z),
+       STK8BA50_ACCEL_CHANNEL(0, STK8BA50_REG_XOUT, X),
+       STK8BA50_ACCEL_CHANNEL(1, STK8BA50_REG_YOUT, Y),
+       STK8BA50_ACCEL_CHANNEL(2, STK8BA50_REG_ZOUT, Z),
+       IIO_CHAN_SOFT_TIMESTAMP(3),
 };
 
 static IIO_CONST_ATTR(in_accel_scale_available, STK8BA50_SCALE_AVAIL);
 
+static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("14 25 56 112 224 448 896 1792");
+
 static struct attribute *stk8ba50_attributes[] = {
        &iio_const_attr_in_accel_scale_available.dev_attr.attr,
+       &iio_const_attr_sampling_frequency_available.dev_attr.attr,
        NULL,
 };
 
@@ -97,7 +154,61 @@ static int stk8ba50_read_accel(struct stk8ba50_data *data, u8 reg)
                return ret;
        }
 
-       return sign_extend32(ret >> STK8BA50_DATA_SHIFT, 9);
+       return ret;
+}
+
+static int stk8ba50_data_rdy_trigger_set_state(struct iio_trigger *trig,
+                                              bool state)
+{
+       struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
+       struct stk8ba50_data *data = iio_priv(indio_dev);
+       int ret;
+
+       if (state)
+               ret = i2c_smbus_write_byte_data(data->client,
+                       STK8BA50_REG_INTEN2, STK8BA50_DREADY_INT_MASK);
+       else
+               ret = i2c_smbus_write_byte_data(data->client,
+                       STK8BA50_REG_INTEN2, 0x00);
+
+       if (ret < 0)
+               dev_err(&data->client->dev, "failed to set trigger state\n");
+       else
+               data->dready_trigger_on = state;
+
+       return ret;
+}
+
+static const struct iio_trigger_ops stk8ba50_trigger_ops = {
+       .set_trigger_state = stk8ba50_data_rdy_trigger_set_state,
+       .owner = THIS_MODULE,
+};
+
+static int stk8ba50_set_power(struct stk8ba50_data *data, bool mode)
+{
+       int ret;
+       u8 masked_reg;
+       struct i2c_client *client = data->client;
+
+       ret = i2c_smbus_read_byte_data(client, STK8BA50_REG_POWMODE);
+       if (ret < 0)
+               goto exit_err;
+
+       if (mode)
+               masked_reg = ret | STK8BA50_MODE_POWERBIT;
+       else
+               masked_reg = ret & (~STK8BA50_MODE_POWERBIT);
+
+       ret = i2c_smbus_write_byte_data(client, STK8BA50_REG_POWMODE,
+                                       masked_reg);
+       if (ret < 0)
+               goto exit_err;
+
+       return ret;
+
+exit_err:
+       dev_err(&client->dev, "failed to change sensor mode\n");
+       return ret;
 }
 
 static int stk8ba50_read_raw(struct iio_dev *indio_dev,
@@ -105,17 +216,37 @@ static int stk8ba50_read_raw(struct iio_dev *indio_dev,
                             int *val, int *val2, long mask)
 {
        struct stk8ba50_data *data = iio_priv(indio_dev);
+       int ret;
 
        switch (mask) {
        case IIO_CHAN_INFO_RAW:
+               if (iio_buffer_enabled(indio_dev))
+                       return -EBUSY;
                mutex_lock(&data->lock);
-               *val = stk8ba50_read_accel(data, chan->address);
+               ret = stk8ba50_set_power(data, STK8BA50_MODE_NORMAL);
+               if (ret < 0) {
+                       mutex_unlock(&data->lock);
+                       return -EINVAL;
+               }
+               ret = stk8ba50_read_accel(data, chan->address);
+               if (ret < 0) {
+                       stk8ba50_set_power(data, STK8BA50_MODE_SUSPEND);
+                       mutex_unlock(&data->lock);
+                       return -EINVAL;
+               }
+               *val = sign_extend32(ret >> STK8BA50_DATA_SHIFT, 9);
+               stk8ba50_set_power(data, STK8BA50_MODE_SUSPEND);
                mutex_unlock(&data->lock);
                return IIO_VAL_INT;
        case IIO_CHAN_INFO_SCALE:
                *val = 0;
-               *val2 = stk8ba50_scale_table[data->range][1];
+               *val2 = stk8ba50_scale_table[data->range].scale_val;
                return IIO_VAL_INT_PLUS_MICRO;
+       case IIO_CHAN_INFO_SAMP_FREQ:
+               *val = stk8ba50_samp_freq_table
+                               [data->sample_rate_idx].samp_freq;
+               *val2 = 0;
+               return IIO_VAL_INT;
        }
 
        return -EINVAL;
@@ -136,7 +267,7 @@ static int stk8ba50_write_raw(struct iio_dev *indio_dev,
                        return -EINVAL;
 
                for (i = 0; i < ARRAY_SIZE(stk8ba50_scale_table); i++)
-                       if (val2 == stk8ba50_scale_table[i][1]) {
+                       if (val2 == stk8ba50_scale_table[i].scale_val) {
                                index = i;
                                break;
                        }
@@ -145,7 +276,7 @@ static int stk8ba50_write_raw(struct iio_dev *indio_dev,
 
                ret = i2c_smbus_write_byte_data(data->client,
                                STK8BA50_REG_RANGE,
-                               stk8ba50_scale_table[index][0]);
+                               stk8ba50_scale_table[index].reg_val);
                if (ret < 0)
                        dev_err(&data->client->dev,
                                        "failed to set measurement range\n");
@@ -153,6 +284,25 @@ static int stk8ba50_write_raw(struct iio_dev *indio_dev,
                        data->range = index;
 
                return ret;
+       case IIO_CHAN_INFO_SAMP_FREQ:
+               for (i = 0; i < ARRAY_SIZE(stk8ba50_samp_freq_table); i++)
+                       if (val == stk8ba50_samp_freq_table[i].samp_freq) {
+                               index = i;
+                               break;
+                       }
+               if (index < 0)
+                       return -EINVAL;
+
+               ret = i2c_smbus_write_byte_data(data->client,
+                               STK8BA50_REG_BWSEL,
+                               stk8ba50_samp_freq_table[index].reg_val);
+               if (ret < 0)
+                       dev_err(&data->client->dev,
+                                       "failed to set sampling rate\n");
+               else
+                       data->sample_rate_idx = index;
+
+               return ret;
        }
 
        return -EINVAL;
@@ -165,30 +315,100 @@ static const struct iio_info stk8ba50_info = {
        .attrs                  = &stk8ba50_attribute_group,
 };
 
-static int stk8ba50_set_power(struct stk8ba50_data *data, bool mode)
+static irqreturn_t stk8ba50_trigger_handler(int irq, void *p)
 {
+       struct iio_poll_func *pf = p;
+       struct iio_dev *indio_dev = pf->indio_dev;
+       struct stk8ba50_data *data = iio_priv(indio_dev);
+       int bit, ret, i = 0;
+
+       mutex_lock(&data->lock);
+       /*
+        * Do a bulk read if all channels are requested,
+        * from 0x02 (XOUT1) to 0x07 (ZOUT2)
+        */
+       if (*(indio_dev->active_scan_mask) == STK8BA50_ALL_CHANNEL_MASK) {
+               ret = i2c_smbus_read_i2c_block_data(data->client,
+                                                   STK8BA50_REG_XOUT,
+                                                   STK8BA50_ALL_CHANNEL_SIZE,
+                                                   (u8 *)data->buffer);
+               if (ret < STK8BA50_ALL_CHANNEL_SIZE) {
+                       dev_err(&data->client->dev, "register read failed\n");
+                       goto err;
+               }
+       } else {
+               for_each_set_bit(bit, indio_dev->active_scan_mask,
+                                indio_dev->masklength) {
+                       ret = stk8ba50_read_accel(data,
+                                                 stk8ba50_channel_table[bit]);
+                       if (ret < 0)
+                               goto err;
+
+                       data->buffer[i++] = ret;
+               }
+       }
+       iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
+                                          pf->timestamp);
+err:
+       mutex_unlock(&data->lock);
+       iio_trigger_notify_done(indio_dev->trig);
+
+       return IRQ_HANDLED;
+}
+
+static irqreturn_t stk8ba50_data_rdy_trig_poll(int irq, void *private)
+{
+       struct iio_dev *indio_dev = private;
+       struct stk8ba50_data *data = iio_priv(indio_dev);
+
+       if (data->dready_trigger_on)
+               iio_trigger_poll(data->dready_trig);
+
+       return IRQ_HANDLED;
+}
+
+static int stk8ba50_buffer_preenable(struct iio_dev *indio_dev)
+{
+       struct stk8ba50_data *data = iio_priv(indio_dev);
+
+       return stk8ba50_set_power(data, STK8BA50_MODE_NORMAL);
+}
+
+static int stk8ba50_buffer_postdisable(struct iio_dev *indio_dev)
+{
+       struct stk8ba50_data *data = iio_priv(indio_dev);
+
+       return stk8ba50_set_power(data, STK8BA50_MODE_SUSPEND);
+}
+
+static const struct iio_buffer_setup_ops stk8ba50_buffer_setup_ops = {
+       .preenable   = stk8ba50_buffer_preenable,
+       .postenable  = iio_triggered_buffer_postenable,
+       .predisable  = iio_triggered_buffer_predisable,
+       .postdisable = stk8ba50_buffer_postdisable,
+};
+
+static int stk8ba50_gpio_probe(struct i2c_client *client)
+{
+       struct device *dev;
+       struct gpio_desc *gpio;
        int ret;
-       u8 masked_reg;
-       struct i2c_client *client = data->client;
 
-       ret = i2c_smbus_read_byte_data(client, STK8BA50_REG_POWMODE);
-       if (ret < 0)
-               goto exit_err;
+       if (!client)
+               return -EINVAL;
 
-       if (mode)
-               masked_reg = ret | STK8BA50_MODE_POWERBIT;
-       else
-               masked_reg = ret & (~STK8BA50_MODE_POWERBIT);
+       dev = &client->dev;
 
-       ret = i2c_smbus_write_byte_data(client, STK8BA50_REG_POWMODE,
-                                       masked_reg);
-       if (ret < 0)
-               goto exit_err;
+       /* data ready gpio interrupt pin */
+       gpio = devm_gpiod_get_index(dev, STK8BA50_GPIO, 0, GPIOD_IN);
+       if (IS_ERR(gpio)) {
+               dev_err(dev, "acpi gpio get index failed\n");
+               return PTR_ERR(gpio);
+       }
 
-       return ret;
+       ret = gpiod_to_irq(gpio);
+       dev_dbg(dev, "GPIO resource, no:%d irq:%d\n", desc_to_gpio(gpio), ret);
 
-exit_err:
-       dev_err(&client->dev, "failed to change sensor mode\n");
        return ret;
 }
 
@@ -222,28 +442,104 @@ static int stk8ba50_probe(struct i2c_client *client,
                        STK8BA50_REG_SWRST, STK8BA50_RESET_CMD);
        if (ret < 0) {
                dev_err(&client->dev, "failed to reset sensor\n");
-               return ret;
+               goto err_power_off;
        }
 
        /* The default range is +/-2g */
        data->range = 0;
 
+       /* The default sampling rate is 1792 Hz (maximum) */
+       data->sample_rate_idx = STK8BA50_SR_1792HZ_IDX;
+
+       /* Set up interrupts */
+       ret = i2c_smbus_write_byte_data(client,
+                       STK8BA50_REG_INTEN2, STK8BA50_DREADY_INT_MASK);
+       if (ret < 0) {
+               dev_err(&client->dev, "failed to set up interrupts\n");
+               goto err_power_off;
+       }
+       ret = i2c_smbus_write_byte_data(client,
+                       STK8BA50_REG_INTMAP2, STK8BA50_DREADY_INT_MAP);
+       if (ret < 0) {
+               dev_err(&client->dev, "failed to set up interrupts\n");
+               goto err_power_off;
+       }
+
+       if (client->irq < 0)
+               client->irq = stk8ba50_gpio_probe(client);
+
+       if (client->irq >= 0) {
+               ret = devm_request_threaded_irq(&client->dev, client->irq,
+                                               stk8ba50_data_rdy_trig_poll,
+                                               NULL,
+                                               IRQF_TRIGGER_RISING |
+                                               IRQF_ONESHOT,
+                                               STK8BA50_IRQ_NAME,
+                                               indio_dev);
+               if (ret < 0) {
+                       dev_err(&client->dev, "request irq %d failed\n",
+                               client->irq);
+                       goto err_power_off;
+               }
+
+               data->dready_trig = devm_iio_trigger_alloc(&client->dev,
+                                                          "%s-dev%d",
+                                                          indio_dev->name,
+                                                          indio_dev->id);
+               if (!data->dready_trig) {
+                       ret = -ENOMEM;
+                       goto err_power_off;
+               }
+
+               data->dready_trig->dev.parent = &client->dev;
+               data->dready_trig->ops = &stk8ba50_trigger_ops;
+               iio_trigger_set_drvdata(data->dready_trig, indio_dev);
+               ret = iio_trigger_register(data->dready_trig);
+               if (ret) {
+                       dev_err(&client->dev, "iio trigger register failed\n");
+                       goto err_power_off;
+               }
+       }
+
+       ret = iio_triggered_buffer_setup(indio_dev,
+                                        iio_pollfunc_store_time,
+                                        stk8ba50_trigger_handler,
+                                        &stk8ba50_buffer_setup_ops);
+       if (ret < 0) {
+               dev_err(&client->dev, "iio triggered buffer setup failed\n");
+               goto err_trigger_unregister;
+       }
+
        ret = iio_device_register(indio_dev);
        if (ret < 0) {
                dev_err(&client->dev, "device_register failed\n");
-               stk8ba50_set_power(data, STK8BA50_MODE_SUSPEND);
+               goto err_buffer_cleanup;
        }
 
        return ret;
+
+err_buffer_cleanup:
+       iio_triggered_buffer_cleanup(indio_dev);
+err_trigger_unregister:
+       if (data->dready_trig)
+               iio_trigger_unregister(data->dready_trig);
+err_power_off:
+       stk8ba50_set_power(data, STK8BA50_MODE_SUSPEND);
+       return ret;
 }
 
 static int stk8ba50_remove(struct i2c_client *client)
 {
        struct iio_dev *indio_dev = i2c_get_clientdata(client);
+       struct stk8ba50_data *data = iio_priv(indio_dev);
 
        iio_device_unregister(indio_dev);
+       iio_triggered_buffer_cleanup(indio_dev);
 
-       return stk8ba50_set_power(iio_priv(indio_dev), STK8BA50_MODE_SUSPEND);
+       if (data->dready_trig)
+               iio_trigger_unregister(data->dready_trig);
+
+       return stk8ba50_set_power(data, STK8BA50_MODE_SUSPEND);
 }
 
 #ifdef CONFIG_PM_SLEEP
index eb0cd89..233d47b 100644 (file)
@@ -20,6 +20,9 @@ config AD7266
          Say yes here to build support for Analog Devices AD7265 and AD7266
          ADCs.
 
+         To compile this driver as a module, choose M here: the module will be
+         called ad7266.
+
 config AD7291
        tristate "Analog Devices AD7291 ADC driver"
        depends on I2C
@@ -52,8 +55,6 @@ config AD7476
          AD7277, AD7278, AD7475, AD7476, AD7477, AD7478, AD7466, AD7467, AD7468,
          AD7495, AD7910, AD7920, AD7920 SPI analog to digital converters (ADC).
 
-         If unsure, say N (but it's safe to say "Y").
-
          To compile this driver as a module, choose M here: the
          module will be called ad7476.
 
@@ -63,8 +64,7 @@ config AD7791
        select AD_SIGMA_DELTA
        help
          Say yes here to build support for Analog Devices AD7787, AD7788, AD7789,
-         AD7790 and AD7791 SPI analog to digital converters (ADC). If unsure, say
-         N (but it is safe to say "Y").
+         AD7790 and AD7791 SPI analog to digital converters (ADC).
 
          To compile this driver as a module, choose M here: the module will be
          called ad7791.
@@ -76,7 +76,6 @@ config AD7793
        help
          Say yes here to build support for Analog Devices AD7785, AD7792, AD7793,
          AD7794 and AD7795 SPI analog to digital converters (ADC).
-         If unsure, say N (but it's safe to say "Y").
 
          To compile this driver as a module, choose M here: the
          module will be called AD7793.
@@ -89,7 +88,6 @@ config AD7887
        help
          Say yes here to build support for Analog Devices
          AD7887 SPI analog to digital converter (ADC).
-         If unsure, say N (but it's safe to say "Y").
 
          To compile this driver as a module, choose M here: the
          module will be called ad7887.
@@ -117,6 +115,9 @@ config AD799X
          i2c analog to digital converters (ADC). Provides direct access
          via sysfs.
 
+         To compile this driver as a module, choose M here: the module will be
+         called ad799x.
+
 config AT91_ADC
        tristate "Atmel AT91 ADC"
        depends on ARCH_AT91
@@ -127,6 +128,9 @@ config AT91_ADC
        help
          Say yes here to build support for Atmel AT91 ADC.
 
+         To compile this driver as a module, choose M here: the module will be
+         called at91_adc.
+
 config AXP288_ADC
        tristate "X-Powers AXP288 ADC driver"
        depends on MFD_AXP20X
@@ -135,6 +139,9 @@ config AXP288_ADC
          device. Depending on platform configuration, this general purpose ADC can
          be used for sampling sensors such as thermal resistors.
 
+         To compile this driver as a module, choose M here: the module will be
+         called axp288_adc.
+
 config BERLIN2_ADC
        tristate "Marvell Berlin2 ADC driver"
        depends on ARCH_BERLIN
@@ -151,6 +158,9 @@ config DA9150_GPADC
          This driver can also be built as a module. If chosen, the module name
          will be da9150-gpadc.
 
+         To compile this driver as a module, choose M here: the module will be
+         called berlin2-adc.
+
 config CC10001_ADC
        tristate "Cosmic Circuits 10001 ADC driver"
        depends on HAS_IOMEM && HAVE_CLK && REGULATOR
@@ -170,12 +180,18 @@ config EXYNOS_ADC
          of SoCs for drivers such as the touchscreen and hwmon to use to share
          this resource.
 
+         To compile this driver as a module, choose M here: the module will be
+         called exynos_adc.
+
 config LP8788_ADC
        tristate "LP8788 ADC driver"
        depends on MFD_LP8788
        help
          Say yes here to build support for TI LP8788 ADC.
 
+         To compile this driver as a module, choose M here: the module will be
+         called lp8788_adc.
+
 config MAX1027
        tristate "Maxim max1027 ADC driver"
        depends on SPI
@@ -185,6 +201,9 @@ config MAX1027
          Say yes here to build support for Maxim SPI ADC models
          max1027, max1029 and max1031.
 
+         To compile this driver as a module, choose M here: the module will be
+         called max1027.
+
 config MAX1363
        tristate "Maxim max1363 ADC driver"
        depends on I2C
@@ -201,6 +220,9 @@ config MAX1363
          max11646, max11647) Provides direct access via sysfs and buffered
          data via the iio dev interface.
 
+         To compile this driver as a module, choose M here: the module will be
+         called max1363.
+
 config MCP320X
        tristate "Microchip Technology MCP3x01/02/04/08"
        depends on SPI
@@ -309,15 +331,18 @@ config TI_AM335X_ADC
          Say yes here to build support for Texas Instruments ADC
          driver which is also a MFD client.
 
+         To compile this driver as a module, choose M here: the module will be
+         called ti_am335x_adc.
+
 config TWL4030_MADC
        tristate "TWL4030 MADC (Monitoring A/D Converter)"
        depends on TWL4030_CORE
        help
-       This driver provides support for Triton TWL4030-MADC. The
-       driver supports both RT and SW conversion methods.
+         This driver provides support for Triton TWL4030-MADC. The
+         driver supports both RT and SW conversion methods.
 
-       This driver can also be built as a module. If so, the module will be
-       called twl4030-madc.
+         This driver can also be built as a module. If so, the module will be
+         called twl4030-madc.
 
 config TWL6030_GPADC
        tristate "TWL6030 GPADC (General Purpose A/D Converter) Support"
@@ -350,6 +375,9 @@ config VIPERBOARD_ADC
          Say yes here to access the ADC part of the Nano River
          Technologies Viperboard.
 
+         To compile this driver as a module, choose M here: the module will be
+         called viperboard_adc.
+
 config XILINX_XADC
        tristate "Xilinx XADC driver"
        depends on ARCH_ZYNQ || MICROBLAZE || COMPILE_TEST
index 115f6e9..8254f52 100644 (file)
@@ -62,6 +62,7 @@ struct cc10001_adc_device {
        struct regulator *reg;
        u16 *buf;
 
+       bool shared;
        struct mutex lock;
        unsigned int start_delay_ns;
        unsigned int eoc_delay_ns;
@@ -153,7 +154,8 @@ static irqreturn_t cc10001_adc_trigger_h(int irq, void *p)
 
        mutex_lock(&adc_dev->lock);
 
-       cc10001_adc_power_up(adc_dev);
+       if (!adc_dev->shared)
+               cc10001_adc_power_up(adc_dev);
 
        /* Calculate delay step for eoc and sampled data */
        delay_ns = adc_dev->eoc_delay_ns / CC10001_MAX_POLL_COUNT;
@@ -177,7 +179,8 @@ static irqreturn_t cc10001_adc_trigger_h(int irq, void *p)
        }
 
 done:
-       cc10001_adc_power_down(adc_dev);
+       if (!adc_dev->shared)
+               cc10001_adc_power_down(adc_dev);
 
        mutex_unlock(&adc_dev->lock);
 
@@ -196,7 +199,8 @@ static u16 cc10001_adc_read_raw_voltage(struct iio_dev *indio_dev,
        unsigned int delay_ns;
        u16 val;
 
-       cc10001_adc_power_up(adc_dev);
+       if (!adc_dev->shared)
+               cc10001_adc_power_up(adc_dev);
 
        /* Calculate delay step for eoc and sampled data */
        delay_ns = adc_dev->eoc_delay_ns / CC10001_MAX_POLL_COUNT;
@@ -205,7 +209,8 @@ static u16 cc10001_adc_read_raw_voltage(struct iio_dev *indio_dev,
 
        val = cc10001_adc_poll_done(indio_dev, chan->channel, delay_ns);
 
-       cc10001_adc_power_down(adc_dev);
+       if (!adc_dev->shared)
+               cc10001_adc_power_down(adc_dev);
 
        return val;
 }
@@ -322,8 +327,10 @@ static int cc10001_adc_probe(struct platform_device *pdev)
        adc_dev = iio_priv(indio_dev);
 
        channel_map = GENMASK(CC10001_ADC_NUM_CHANNELS - 1, 0);
-       if (!of_property_read_u32(node, "adc-reserved-channels", &ret))
+       if (!of_property_read_u32(node, "adc-reserved-channels", &ret)) {
+               adc_dev->shared = true;
                channel_map &= ~ret;
+       }
 
        adc_dev->reg = devm_regulator_get(&pdev->dev, "vref");
        if (IS_ERR(adc_dev->reg))
@@ -368,6 +375,14 @@ static int cc10001_adc_probe(struct platform_device *pdev)
        adc_dev->eoc_delay_ns = NSEC_PER_SEC / adc_clk_rate;
        adc_dev->start_delay_ns = adc_dev->eoc_delay_ns * CC10001_WAIT_CYCLES;
 
+       /*
+        * There is only one register to power-up/power-down the AUX ADC.
+        * If the ADC is shared among multiple CPUs, always power it up here.
+        * If the ADC is used only by the MIPS, power-up/power-down at runtime.
+        */
+       if (adc_dev->shared)
+               cc10001_adc_power_up(adc_dev);
+
        /* Setup the ADC channels available on the device */
        ret = cc10001_adc_channel_init(indio_dev, channel_map);
        if (ret < 0)
@@ -402,6 +417,7 @@ static int cc10001_adc_remove(struct platform_device *pdev)
        struct iio_dev *indio_dev = platform_get_drvdata(pdev);
        struct cc10001_adc_device *adc_dev = iio_priv(indio_dev);
 
+       cc10001_adc_power_down(adc_dev);
        iio_device_unregister(indio_dev);
        iio_triggered_buffer_cleanup(indio_dev);
        clk_disable_unprepare(adc_dev->adc_clk);
index b96c636..3555122 100644 (file)
@@ -404,7 +404,6 @@ MODULE_DEVICE_TABLE(of, mcp3422_of_match);
 static struct i2c_driver mcp3422_driver = {
        .driver = {
                .name = "mcp3422",
-               .owner = THIS_MODULE,
                .of_match_table = of_match_ptr(mcp3422_of_match),
        },
        .probe = mcp3422_probe,
index b3a82b4..2c8374f 100644 (file)
@@ -140,7 +140,6 @@ MODULE_DEVICE_TABLE(of, adc081c_of_match);
 static struct i2c_driver adc081c_driver = {
        .driver = {
                .name = "adc081c",
-               .owner = THIS_MODULE,
                .of_match_table = of_match_ptr(adc081c_of_match),
        },
        .probe = adc081c_probe,
index 9a40097..d338bb5 100644 (file)
@@ -700,7 +700,6 @@ static struct spi_driver ssp_driver = {
        .remove = ssp_remove,
        .driver = {
                .pm = &ssp_pm_ops,
-               .bus = &spi_bus_type,
                .owner = THIS_MODULE,
                .of_match_table = of_match_ptr(ssp_of_match),
                .name = "sensorhub"
index f03b92f..c067e68 100644 (file)
@@ -630,7 +630,6 @@ MODULE_DEVICE_TABLE(i2c, ad5064_i2c_ids);
 static struct i2c_driver ad5064_i2c_driver = {
        .driver = {
                   .name = "ad5064",
-                  .owner = THIS_MODULE,
        },
        .probe = ad5064_i2c_probe,
        .remove = ad5064_i2c_remove,
index 9de4c4d..130de9b 100644 (file)
@@ -593,7 +593,6 @@ MODULE_DEVICE_TABLE(i2c, ad5380_i2c_ids);
 static struct i2c_driver ad5380_i2c_driver = {
        .driver = {
                   .name = "ad5380",
-                  .owner = THIS_MODULE,
        },
        .probe = ad5380_i2c_probe,
        .remove = ad5380_i2c_remove,
index 46bb62a..07e17d7 100644 (file)
@@ -569,7 +569,6 @@ MODULE_DEVICE_TABLE(i2c, ad5446_i2c_ids);
 static struct i2c_driver ad5446_i2c_driver = {
        .driver = {
                   .name = "ad5446",
-                  .owner = THIS_MODULE,
        },
        .probe = ad5446_i2c_probe,
        .remove = ad5446_i2c_remove,
index 6e91449..28b8748 100644 (file)
@@ -392,7 +392,6 @@ static struct i2c_driver max5821_driver = {
        .driver = {
                .name   = "max5821",
                .pm     = MAX5821_PM_OPS,
-               .owner  = THIS_MODULE,
        },
        .probe          = max5821_probe,
        .remove         = max5821_remove,
index 10a0dfc..9890c81 100644 (file)
@@ -72,7 +72,6 @@ static int adf4350_sync_config(struct adf4350_state *st)
        for (i = ADF4350_REG5; i >= ADF4350_REG0; i--) {
                if ((st->regs_hw[i] != st->regs[i]) ||
                        ((i == ADF4350_REG0) && doublebuf)) {
-
                        switch (i) {
                        case ADF4350_REG1:
                        case ADF4350_REG4:
index f0fd940..c102a63 100644 (file)
@@ -379,7 +379,6 @@ MODULE_DEVICE_TABLE(i2c, itg3200_id);
 
 static struct i2c_driver itg3200_driver = {
        .driver = {
-               .owner  = THIS_MODULE,
                .name   = "itg3200",
                .pm     = &itg3200_pm_ops,
        },
index 64480b1..6848451 100644 (file)
@@ -99,7 +99,6 @@ MODULE_DEVICE_TABLE(i2c, st_gyro_id_table);
 
 static struct i2c_driver st_gyro_driver = {
        .driver = {
-               .owner = THIS_MODULE,
                .name = "st-gyro-i2c",
                .of_match_table = of_match_ptr(st_gyro_of_match),
        },
index bdd586e..91972cc 100644 (file)
@@ -177,7 +177,6 @@ MODULE_DEVICE_TABLE(i2c, si7005_id);
 static struct i2c_driver si7005_driver = {
        .driver = {
                .name   = "si7005",
-               .owner  = THIS_MODULE,
        },
        .probe = si7005_probe,
        .id_table = si7005_id,
index 65ce868..f0e0609 100644 (file)
@@ -690,6 +690,10 @@ static const struct iio_chan_spec inv_mpu_channels[] = {
 
 /* constant IIO attribute */
 static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("10 20 50 100 200 500");
+static IIO_CONST_ATTR(in_anglvel_scale_available,
+                                         "0.000133090 0.000266181 0.000532362 0.001064724");
+static IIO_CONST_ATTR(in_accel_scale_available,
+                                         "0.000598 0.001196 0.002392 0.004785");
 static IIO_DEV_ATTR_SAMP_FREQ(S_IRUGO | S_IWUSR, inv_fifo_rate_show,
        inv_mpu6050_fifo_rate_store);
 static IIO_DEVICE_ATTR(in_gyro_matrix, S_IRUGO, inv_attr_show, NULL,
@@ -702,6 +706,8 @@ static struct attribute *inv_attributes[] = {
        &iio_dev_attr_in_accel_matrix.dev_attr.attr,
        &iio_dev_attr_sampling_frequency.dev_attr.attr,
        &iio_const_attr_sampling_frequency_available.dev_attr.attr,
+       &iio_const_attr_in_accel_scale_available.dev_attr.attr,
+       &iio_const_attr_in_anglvel_scale_available.dev_attr.attr,
        NULL,
 };
 
@@ -921,7 +927,6 @@ static struct i2c_driver inv_mpu_driver = {
        .remove         =       inv_mpu_remove,
        .id_table       =       inv_mpu_id,
        .driver = {
-               .owner  =       THIS_MODULE,
                .name   =       "inv-mpu6050",
                .pm     =       INV_MPU6050_PMOPS,
                .acpi_match_table = ACPI_PTR(inv_acpi_match),
index 6eee1b0..f72be48 100644 (file)
@@ -71,8 +71,9 @@ static bool iio_buffer_ready(struct iio_dev *indio_dev, struct iio_buffer *buf,
 
        if (avail >= to_wait) {
                /* force a flush for non-blocking reads */
-               if (!to_wait && !avail && to_flush)
-                       iio_buffer_flush_hwfifo(indio_dev, buf, to_flush);
+               if (!to_wait && avail < to_flush)
+                       iio_buffer_flush_hwfifo(indio_dev, buf,
+                                               to_flush - avail);
                return true;
        }
 
@@ -100,8 +101,7 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf,
        struct iio_dev *indio_dev = filp->private_data;
        struct iio_buffer *rb = indio_dev->buffer;
        size_t datum_size;
-       size_t to_wait = 0;
-       size_t to_read;
+       size_t to_wait;
        int ret;
 
        if (!indio_dev->info)
@@ -119,14 +119,14 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf,
        if (!datum_size)
                return 0;
 
-       to_read = min_t(size_t, n / datum_size, rb->watermark);
-
-       if (!(filp->f_flags & O_NONBLOCK))
-               to_wait = to_read;
+       if (filp->f_flags & O_NONBLOCK)
+               to_wait = 0;
+       else
+               to_wait = min_t(size_t, n / datum_size, rb->watermark);
 
        do {
                ret = wait_event_interruptible(rb->pollq,
-                       iio_buffer_ready(indio_dev, rb, to_wait, to_read));
+                     iio_buffer_ready(indio_dev, rb, to_wait, n / datum_size));
                if (ret)
                        return ret;
 
index 3524b0d..d8051cd 100644 (file)
@@ -81,6 +81,14 @@ static const char * const iio_modifier_names[] = {
        [IIO_MOD_X] = "x",
        [IIO_MOD_Y] = "y",
        [IIO_MOD_Z] = "z",
+       [IIO_MOD_X_AND_Y] = "x&y",
+       [IIO_MOD_X_AND_Z] = "x&z",
+       [IIO_MOD_Y_AND_Z] = "y&z",
+       [IIO_MOD_X_AND_Y_AND_Z] = "x&y&z",
+       [IIO_MOD_X_OR_Y] = "x|y",
+       [IIO_MOD_X_OR_Z] = "x|z",
+       [IIO_MOD_Y_OR_Z] = "y|z",
+       [IIO_MOD_X_OR_Y_OR_Z] = "x|y|z",
        [IIO_MOD_ROOT_SUM_SQUARED_X_Y] = "sqrt(x^2+y^2)",
        [IIO_MOD_SUM_SQUARED_X_Y_Z] = "x^2+y^2+z^2",
        [IIO_MOD_LIGHT_BOTH] = "both",
index 15a5341..4b2858b 100644 (file)
@@ -24,8 +24,8 @@ static const struct iio_buffer_setup_ops iio_triggered_buffer_setup_ops = {
 /**
  * iio_triggered_buffer_setup() - Setup triggered buffer and pollfunc
  * @indio_dev:         IIO device structure
- * @pollfunc_bh:       Function which will be used as pollfunc bottom half
- * @pollfunc_th:       Function which will be used as pollfunc top half
+ * @h:                 Function which will be used as pollfunc top half
+ * @thread:            Function which will be used as pollfunc bottom half
  * @setup_ops:         Buffer setup functions to use for this device.
  *                     If NULL the default setup functions for triggered
  *                     buffers will be used.
@@ -42,8 +42,8 @@ static const struct iio_buffer_setup_ops iio_triggered_buffer_setup_ops = {
  * iio_triggered_buffer_cleanup().
  */
 int iio_triggered_buffer_setup(struct iio_dev *indio_dev,
-       irqreturn_t (*pollfunc_bh)(int irq, void *p),
-       irqreturn_t (*pollfunc_th)(int irq, void *p),
+       irqreturn_t (*h)(int irq, void *p),
+       irqreturn_t (*thread)(int irq, void *p),
        const struct iio_buffer_setup_ops *setup_ops)
 {
        struct iio_buffer *buffer;
@@ -57,8 +57,8 @@ int iio_triggered_buffer_setup(struct iio_dev *indio_dev,
 
        iio_device_attach_buffer(indio_dev, buffer);
 
-       indio_dev->pollfunc = iio_alloc_pollfunc(pollfunc_bh,
-                                                pollfunc_th,
+       indio_dev->pollfunc = iio_alloc_pollfunc(h,
+                                                thread,
                                                 IRQF_ONESHOT,
                                                 indio_dev,
                                                 "%s_consumer%d",
index a5c5925..b37e18d 100644 (file)
@@ -86,7 +86,7 @@ config CM3323
        depends on I2C
        tristate "Capella CM3323 color light sensor"
        help
-        Say Y here if you want to build a driver for Capela CM3323
+        Say Y here if you want to build a driver for Capella CM3323
         color sensor.
 
         To compile this driver as a module, choose M here: the module will
@@ -168,6 +168,17 @@ config JSA1212
         To compile this driver as a module, choose M here:
         the module will be called jsa1212.
 
+config RPR0521
+       tristate "ROHM RPR0521 ALS and proximity sensor driver"
+       depends on I2C
+       select REGMAP_I2C
+       help
+        Say Y here if you want to build support for ROHM's RPR0521
+        ambient light and proximity sensor device.
+
+        To compile this driver as a module, choose M here:
+        the module will be called rpr0521.
+
 config SENSORS_LM3533
        tristate "LM3533 ambient light sensor"
        depends on MFD_LM3533
index e2d50fd..adf9723 100644 (file)
@@ -19,6 +19,7 @@ obj-$(CONFIG_ISL29125)                += isl29125.o
 obj-$(CONFIG_JSA1212)          += jsa1212.o
 obj-$(CONFIG_SENSORS_LM3533)   += lm3533-als.o
 obj-$(CONFIG_LTR501)           += ltr501.o
+obj-$(CONFIG_RPR0521)          += rpr0521.o
 obj-$(CONFIG_SENSORS_TSL2563)  += tsl2563.o
 obj-$(CONFIG_STK3310)          += stk3310.o
 obj-$(CONFIG_TCS3414)          += tcs3414.o
index 9ddde0c..e1b9fa5 100644 (file)
@@ -515,7 +515,6 @@ MODULE_DEVICE_TABLE(i2c, apds9300_id);
 static struct i2c_driver apds9300_driver = {
        .driver = {
                .name   = APDS9300_DRV_NAME,
-               .owner  = THIS_MODULE,
                .pm     = APDS9300_PM_OPS,
        },
        .probe          = apds9300_probe,
index 564c2b3..8b41643 100644 (file)
@@ -319,7 +319,6 @@ MODULE_DEVICE_TABLE(i2c, bh1750_id);
 static struct i2c_driver bh1750_driver = {
        .driver = {
                .name = "bh1750",
-               .owner = THIS_MODULE,
                .pm = BH1750_PM_OPS,
        },
        .probe = bh1750_probe,
index 5d12ae5..1c0de2f 100644 (file)
@@ -358,7 +358,6 @@ static struct i2c_driver cm32181_driver = {
        .driver = {
                .name   = "cm32181",
                .of_match_table = of_match_ptr(cm32181_of_match),
-               .owner  = THIS_MODULE,
        },
        .id_table       = cm32181_id,
        .probe          = cm32181_probe,
index 39c8d99..1b508c6 100644 (file)
@@ -421,7 +421,6 @@ static const struct of_device_id cm3232_of_match[] = {
 static struct i2c_driver cm3232_driver = {
        .driver = {
                .name   = "cm3232",
-               .owner  = THIS_MODULE,
                .of_match_table = of_match_ptr(cm3232_of_match),
 #ifdef CONFIG_PM_SLEEP
                .pm     = &cm3232_pm_ops,
index a1d4905..d823c11 100644 (file)
@@ -29,7 +29,7 @@
 
 #define CM3323_CONF_SD_BIT     BIT(0) /* sensor disable */
 #define CM3323_CONF_AF_BIT     BIT(1) /* auto/manual force mode */
-#define CM3323_CONF_IT_MASK    (BIT(4) | BIT(5) | BIT(6))
+#define CM3323_CONF_IT_MASK    GENMASK(6, 4)
 #define CM3323_CONF_IT_SHIFT   4
 
 #define CM3323_INT_TIME_AVAILABLE "0.04 0.08 0.16 0.32 0.64 1.28"
@@ -133,9 +133,11 @@ static int cm3323_set_it_bits(struct cm3323_data *data, int val, int val2)
                                return ret;
 
                        data->reg_conf = reg_conf;
+
                        return 0;
                }
        }
+
        return -EINVAL;
 }
 
@@ -148,6 +150,7 @@ static int cm3323_get_it_bits(struct cm3323_data *data)
 
        if (bits >= ARRAY_SIZE(cm3323_int_time))
                return -EINVAL;
+
        return bits;
 }
 
@@ -155,7 +158,7 @@ static int cm3323_read_raw(struct iio_dev *indio_dev,
                           struct iio_chan_spec const *chan, int *val,
                           int *val2, long mask)
 {
-       int i, ret;
+       int ret;
        struct cm3323_data *data = iio_priv(indio_dev);
 
        switch (mask) {
@@ -172,14 +175,14 @@ static int cm3323_read_raw(struct iio_dev *indio_dev,
                return IIO_VAL_INT;
        case IIO_CHAN_INFO_INT_TIME:
                mutex_lock(&data->mutex);
-               i = cm3323_get_it_bits(data);
-               if (i < 0) {
+               ret = cm3323_get_it_bits(data);
+               if (ret < 0) {
                        mutex_unlock(&data->mutex);
-                       return -EINVAL;
+                       return ret;
                }
 
-               *val = cm3323_int_time[i].val;
-               *val2 = cm3323_int_time[i].val2;
+               *val = cm3323_int_time[ret].val;
+               *val2 = cm3323_int_time[ret].val2;
                mutex_unlock(&data->mutex);
 
                return IIO_VAL_INT_PLUS_MICRO;
@@ -243,11 +246,13 @@ static int cm3323_probe(struct i2c_client *client,
                dev_err(&client->dev, "cm3323 chip init failed\n");
                return ret;
        }
+
        ret = iio_device_register(indio_dev);
        if (ret < 0) {
                dev_err(&client->dev, "failed to register iio dev\n");
                goto err_init;
        }
+
        return 0;
 err_init:
        cm3323_disable(indio_dev);
index 39fc67e..2a39e14 100644 (file)
@@ -736,7 +736,6 @@ static struct i2c_driver cm36651_driver = {
        .driver = {
                .name   = "cm36651",
                .of_match_table = cm36651_of_match,
-               .owner  = THIS_MODULE,
        },
        .probe          = cm36651_probe,
        .remove         = cm36651_remove,
index 32b6449..0334a81 100644 (file)
@@ -1640,7 +1640,6 @@ static struct i2c_driver gp2ap020a00f_driver = {
        .driver = {
                .name   = GP2A_I2C_NAME,
                .of_match_table = of_match_ptr(gp2ap020a00f_of_match),
-               .owner  = THIS_MODULE,
        },
        .probe          = gp2ap020a00f_probe,
        .remove         = gp2ap020a00f_remove,
index 0d24847..45ca056 100644 (file)
@@ -284,8 +284,7 @@ static int hid_prox_probe(struct platform_device *pdev)
                goto error_free_dev_mem;
        }
 
-       indio_dev->num_channels =
-                               ARRAY_SIZE(prox_channels);
+       indio_dev->num_channels = ARRAY_SIZE(prox_channels);
        indio_dev->dev.parent = &pdev->dev;
        indio_dev->info = &prox_info;
        indio_dev->name = name;
index c82f4a6..e2945a2 100644 (file)
@@ -197,9 +197,21 @@ done:
        return IRQ_HANDLED;
 }
 
+static IIO_CONST_ATTR(scale_available, "0.005722 0.152590");
+
+static struct attribute *isl29125_attributes[] = {
+       &iio_const_attr_scale_available.dev_attr.attr,
+       NULL
+};
+
+static const struct attribute_group isl29125_attribute_group = {
+       .attrs = isl29125_attributes,
+};
+
 static const struct iio_info isl29125_info = {
        .read_raw = isl29125_read_raw,
        .write_raw = isl29125_write_raw,
+       .attrs = &isl29125_attribute_group,
        .driver_module = THIS_MODULE,
 };
 
@@ -334,7 +346,6 @@ static struct i2c_driver isl29125_driver = {
        .driver = {
                .name   = ISL29125_DRV_NAME,
                .pm     = &isl29125_pm_ops,
-               .owner  = THIS_MODULE,
        },
        .probe          = isl29125_probe,
        .remove         = isl29125_remove,
index 3a3af89..c4e8c6b 100644 (file)
@@ -457,7 +457,6 @@ static struct i2c_driver jsa1212_driver = {
        .driver = {
                .name   = JSA1212_DRIVER_NAME,
                .pm     = JSA1212_PM_OPS,
-               .owner  = THIS_MODULE,
                .acpi_match_table = ACPI_PTR(jsa1212_acpi_match),
        },
        .probe          = jsa1212_probe,
index b5a0e66..809a961 100644 (file)
@@ -1551,7 +1551,6 @@ static struct i2c_driver ltr501_driver = {
                .name   = LTR501_DRV_NAME,
                .pm     = &ltr501_pm_ops,
                .acpi_match_table = ACPI_PTR(ltr_acpi_match),
-               .owner  = THIS_MODULE,
        },
        .probe  = ltr501_probe,
        .remove = ltr501_remove,
diff --git a/drivers/iio/light/rpr0521.c b/drivers/iio/light/rpr0521.c
new file mode 100644 (file)
index 0000000..4b75bb0
--- /dev/null
@@ -0,0 +1,615 @@
+/*
+ * RPR-0521 ROHM Ambient Light and Proximity Sensor
+ *
+ * Copyright (c) 2015, Intel Corporation.
+ *
+ * This file is subject to the terms and conditions of version 2 of
+ * the GNU General Public License.  See the file COPYING in the main
+ * directory of this archive for more details.
+ *
+ * IIO driver for RPR-0521RS (7-bit I2C slave address 0x38).
+ *
+ * TODO: illuminance channel, PM support, buffer
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/i2c.h>
+#include <linux/regmap.h>
+#include <linux/delay.h>
+#include <linux/acpi.h>
+
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/pm_runtime.h>
+
+#define RPR0521_REG_SYSTEM_CTRL                0x40
+#define RPR0521_REG_MODE_CTRL          0x41
+#define RPR0521_REG_ALS_CTRL           0x42
+#define RPR0521_REG_PXS_CTRL           0x43
+#define RPR0521_REG_PXS_DATA           0x44 /* 16-bit, little endian */
+#define RPR0521_REG_ALS_DATA0          0x46 /* 16-bit, little endian */
+#define RPR0521_REG_ALS_DATA1          0x48 /* 16-bit, little endian */
+#define RPR0521_REG_ID                 0x92
+
+#define RPR0521_MODE_ALS_MASK          BIT(7)
+#define RPR0521_MODE_PXS_MASK          BIT(6)
+#define RPR0521_MODE_MEAS_TIME_MASK    GENMASK(3, 0)
+#define RPR0521_ALS_DATA0_GAIN_MASK    GENMASK(5, 4)
+#define RPR0521_ALS_DATA0_GAIN_SHIFT   4
+#define RPR0521_ALS_DATA1_GAIN_MASK    GENMASK(3, 2)
+#define RPR0521_ALS_DATA1_GAIN_SHIFT   2
+#define RPR0521_PXS_GAIN_MASK          GENMASK(5, 4)
+#define RPR0521_PXS_GAIN_SHIFT         4
+
+#define RPR0521_MODE_ALS_ENABLE                BIT(7)
+#define RPR0521_MODE_ALS_DISABLE       0x00
+#define RPR0521_MODE_PXS_ENABLE                BIT(6)
+#define RPR0521_MODE_PXS_DISABLE       0x00
+
+#define RPR0521_MANUFACT_ID            0xE0
+#define RPR0521_DEFAULT_MEAS_TIME      0x06 /* ALS - 100ms, PXS - 100ms */
+
+#define RPR0521_DRV_NAME               "RPR0521"
+#define RPR0521_REGMAP_NAME            "rpr0521_regmap"
+
+#define RPR0521_SLEEP_DELAY_MS 2000
+
+#define RPR0521_ALS_SCALE_AVAIL "0.007812 0.015625 0.5 1"
+#define RPR0521_PXS_SCALE_AVAIL "0.125 0.5 1"
+
+struct rpr0521_gain {
+       int scale;
+       int uscale;
+};
+
+static const struct rpr0521_gain rpr0521_als_gain[4] = {
+       {1, 0},         /* x1 */
+       {0, 500000},    /* x2 */
+       {0, 15625},     /* x64 */
+       {0, 7812},      /* x128 */
+};
+
+static const struct rpr0521_gain rpr0521_pxs_gain[3] = {
+       {1, 0},         /* x1 */
+       {0, 500000},    /* x2 */
+       {0, 125000},    /* x4 */
+};
+
+enum rpr0521_channel {
+       RPR0521_CHAN_ALS_DATA0,
+       RPR0521_CHAN_ALS_DATA1,
+       RPR0521_CHAN_PXS,
+};
+
+struct rpr0521_reg_desc {
+       u8 address;
+       u8 device_mask;
+};
+
+static const struct rpr0521_reg_desc rpr0521_data_reg[] = {
+       [RPR0521_CHAN_ALS_DATA0] = {
+               .address        = RPR0521_REG_ALS_DATA0,
+               .device_mask    = RPR0521_MODE_ALS_MASK,
+       },
+       [RPR0521_CHAN_ALS_DATA1] = {
+               .address        = RPR0521_REG_ALS_DATA1,
+               .device_mask    = RPR0521_MODE_ALS_MASK,
+       },
+       [RPR0521_CHAN_PXS]      = {
+               .address        = RPR0521_REG_PXS_DATA,
+               .device_mask    = RPR0521_MODE_PXS_MASK,
+       },
+};
+
+static const struct rpr0521_gain_info {
+       u8 reg;
+       u8 mask;
+       u8 shift;
+       const struct rpr0521_gain *gain;
+       int size;
+} rpr0521_gain[] = {
+       [RPR0521_CHAN_ALS_DATA0] = {
+               .reg    = RPR0521_REG_ALS_CTRL,
+               .mask   = RPR0521_ALS_DATA0_GAIN_MASK,
+               .shift  = RPR0521_ALS_DATA0_GAIN_SHIFT,
+               .gain   = rpr0521_als_gain,
+               .size   = ARRAY_SIZE(rpr0521_als_gain),
+       },
+       [RPR0521_CHAN_ALS_DATA1] = {
+               .reg    = RPR0521_REG_ALS_CTRL,
+               .mask   = RPR0521_ALS_DATA1_GAIN_MASK,
+               .shift  = RPR0521_ALS_DATA1_GAIN_SHIFT,
+               .gain   = rpr0521_als_gain,
+               .size   = ARRAY_SIZE(rpr0521_als_gain),
+       },
+       [RPR0521_CHAN_PXS] = {
+               .reg    = RPR0521_REG_PXS_CTRL,
+               .mask   = RPR0521_PXS_GAIN_MASK,
+               .shift  = RPR0521_PXS_GAIN_SHIFT,
+               .gain   = rpr0521_pxs_gain,
+               .size   = ARRAY_SIZE(rpr0521_pxs_gain),
+       },
+};
+
+struct rpr0521_data {
+       struct i2c_client *client;
+
+       /* protect device params updates (e.g state, gain) */
+       struct mutex lock;
+
+       /* device active status */
+       bool als_dev_en;
+       bool pxs_dev_en;
+
+       /* optimize runtime pm ops - enable device only if needed */
+       bool als_ps_need_en;
+       bool pxs_ps_need_en;
+
+       struct regmap *regmap;
+};
+
+static IIO_CONST_ATTR(in_intensity_scale_available, RPR0521_ALS_SCALE_AVAIL);
+static IIO_CONST_ATTR(in_proximity_scale_available, RPR0521_PXS_SCALE_AVAIL);
+
+static struct attribute *rpr0521_attributes[] = {
+       &iio_const_attr_in_intensity_scale_available.dev_attr.attr,
+       &iio_const_attr_in_proximity_scale_available.dev_attr.attr,
+       NULL,
+};
+
+static const struct attribute_group rpr0521_attribute_group = {
+       .attrs = rpr0521_attributes,
+};
+
+static const struct iio_chan_spec rpr0521_channels[] = {
+       {
+               .type = IIO_INTENSITY,
+               .modified = 1,
+               .address = RPR0521_CHAN_ALS_DATA0,
+               .channel2 = IIO_MOD_LIGHT_BOTH,
+               .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+                       BIT(IIO_CHAN_INFO_SCALE),
+       },
+       {
+               .type = IIO_INTENSITY,
+               .modified = 1,
+               .address = RPR0521_CHAN_ALS_DATA1,
+               .channel2 = IIO_MOD_LIGHT_IR,
+               .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+                       BIT(IIO_CHAN_INFO_SCALE),
+       },
+       {
+               .type = IIO_PROXIMITY,
+               .address = RPR0521_CHAN_PXS,
+               .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+                       BIT(IIO_CHAN_INFO_SCALE),
+       }
+};
+
+static int rpr0521_als_enable(struct rpr0521_data *data, u8 status)
+{
+       int ret;
+
+       ret = regmap_update_bits(data->regmap, RPR0521_REG_MODE_CTRL,
+                                RPR0521_MODE_ALS_MASK,
+                                status);
+       if (ret < 0)
+               return ret;
+
+       data->als_dev_en = true;
+
+       return 0;
+}
+
+static int rpr0521_pxs_enable(struct rpr0521_data *data, u8 status)
+{
+       int ret;
+
+       ret = regmap_update_bits(data->regmap, RPR0521_REG_MODE_CTRL,
+                                RPR0521_MODE_PXS_MASK,
+                                status);
+       if (ret < 0)
+               return ret;
+
+       data->pxs_dev_en = true;
+
+       return 0;
+}
+
+/**
+ * rpr0521_set_power_state - handles runtime PM state and sensors enabled status
+ *
+ * @data: rpr0521 device private data
+ * @on: state to be set for devices in @device_mask
+ * @device_mask: bitmask specifying for which device we need to update @on state
+ *
+ * We rely on rpr0521_runtime_resume to enable our @device_mask devices, but
+ * if (for example) PXS was enabled (pxs_dev_en = true) by a previous call to
+ * rpr0521_runtime_resume and we want to enable ALS we MUST set ALS enable
+ * bit of RPR0521_REG_MODE_CTRL here because rpr0521_runtime_resume will not
+ * be called twice.
+ */
+static int rpr0521_set_power_state(struct rpr0521_data *data, bool on,
+                                  u8 device_mask)
+{
+#ifdef CONFIG_PM
+       int ret;
+       u8 update_mask = 0;
+
+       if (device_mask & RPR0521_MODE_ALS_MASK) {
+               if (on && !data->als_ps_need_en && data->pxs_dev_en)
+                       update_mask |= RPR0521_MODE_ALS_MASK;
+               else
+                       data->als_ps_need_en = on;
+       }
+
+       if (device_mask & RPR0521_MODE_PXS_MASK) {
+               if (on && !data->pxs_ps_need_en && data->als_dev_en)
+                       update_mask |= RPR0521_MODE_PXS_MASK;
+               else
+                       data->pxs_ps_need_en = on;
+       }
+
+       if (update_mask) {
+               ret = regmap_update_bits(data->regmap, RPR0521_REG_MODE_CTRL,
+                                        update_mask, update_mask);
+               if (ret < 0)
+                       return ret;
+       }
+
+       if (on) {
+               ret = pm_runtime_get_sync(&data->client->dev);
+       } else {
+               pm_runtime_mark_last_busy(&data->client->dev);
+               ret = pm_runtime_put_autosuspend(&data->client->dev);
+       }
+       if (ret < 0) {
+               dev_err(&data->client->dev,
+                       "Failed: rpr0521_set_power_state for %d, ret %d\n",
+                       on, ret);
+               if (on)
+                       pm_runtime_put_noidle(&data->client->dev);
+
+               return ret;
+       }
+#endif
+       return 0;
+}
+
+static int rpr0521_get_gain(struct rpr0521_data *data, int chan,
+                           int *val, int *val2)
+{
+       int ret, reg, idx;
+
+       ret = regmap_read(data->regmap, rpr0521_gain[chan].reg, &reg);
+       if (ret < 0)
+               return ret;
+
+       idx = (rpr0521_gain[chan].mask & reg) >> rpr0521_gain[chan].shift;
+       *val = rpr0521_gain[chan].gain[idx].scale;
+       *val2 = rpr0521_gain[chan].gain[idx].uscale;
+
+       return 0;
+}
+
+static int rpr0521_set_gain(struct rpr0521_data *data, int chan,
+                           int val, int val2)
+{
+       int i, idx = -EINVAL;
+
+       /* get gain index */
+       for (i = 0; i < rpr0521_gain[chan].size; i++)
+               if (val == rpr0521_gain[chan].gain[i].scale &&
+                   val2 == rpr0521_gain[chan].gain[i].uscale) {
+                       idx = i;
+                       break;
+               }
+
+       if (idx < 0)
+               return idx;
+
+       return regmap_update_bits(data->regmap, rpr0521_gain[chan].reg,
+                                 rpr0521_gain[chan].mask,
+                                 idx << rpr0521_gain[chan].shift);
+}
+
+static int rpr0521_read_raw(struct iio_dev *indio_dev,
+                           struct iio_chan_spec const *chan, int *val,
+                           int *val2, long mask)
+{
+       struct rpr0521_data *data = iio_priv(indio_dev);
+       int ret;
+       u8 device_mask;
+       __le16 raw_data;
+
+       switch (mask) {
+       case IIO_CHAN_INFO_RAW:
+               if (chan->type != IIO_INTENSITY && chan->type != IIO_PROXIMITY)
+                       return -EINVAL;
+
+               device_mask = rpr0521_data_reg[chan->address].device_mask;
+
+               mutex_lock(&data->lock);
+               ret = rpr0521_set_power_state(data, true, device_mask);
+               if (ret < 0) {
+                       mutex_unlock(&data->lock);
+                       return ret;
+               }
+
+               ret = regmap_bulk_read(data->regmap,
+                                      rpr0521_data_reg[chan->address].address,
+                                      &raw_data, 2);
+               if (ret < 0) {
+                       rpr0521_set_power_state(data, false, device_mask);
+                       mutex_unlock(&data->lock);
+                       return ret;
+               }
+
+               ret = rpr0521_set_power_state(data, false, device_mask);
+               mutex_unlock(&data->lock);
+               if (ret < 0)
+                       return ret;
+
+               *val = le16_to_cpu(raw_data);
+
+               return IIO_VAL_INT;
+       case IIO_CHAN_INFO_SCALE:
+               mutex_lock(&data->lock);
+               ret = rpr0521_get_gain(data, chan->address, val, val2);
+               mutex_unlock(&data->lock);
+               if (ret < 0)
+                       return ret;
+
+               return IIO_VAL_INT_PLUS_MICRO;
+       default:
+               return -EINVAL;
+       }
+}
+
+static int rpr0521_write_raw(struct iio_dev *indio_dev,
+                            struct iio_chan_spec const *chan, int val,
+                            int val2, long mask)
+{
+       struct rpr0521_data *data = iio_priv(indio_dev);
+       int ret;
+
+       switch (mask) {
+       case IIO_CHAN_INFO_SCALE:
+               mutex_lock(&data->lock);
+               ret = rpr0521_set_gain(data, chan->address, val, val2);
+               mutex_unlock(&data->lock);
+
+               return ret;
+       default:
+               return -EINVAL;
+       }
+}
+
+static const struct iio_info rpr0521_info = {
+       .driver_module  = THIS_MODULE,
+       .read_raw       = rpr0521_read_raw,
+       .write_raw      = rpr0521_write_raw,
+       .attrs          = &rpr0521_attribute_group,
+};
+
+static int rpr0521_init(struct rpr0521_data *data)
+{
+       int ret;
+       int id;
+
+       ret = regmap_read(data->regmap, RPR0521_REG_ID, &id);
+       if (ret < 0) {
+               dev_err(&data->client->dev, "Failed to read REG_ID register\n");
+               return ret;
+       }
+
+       if (id != RPR0521_MANUFACT_ID) {
+               dev_err(&data->client->dev, "Wrong id, got %x, expected %x\n",
+                       id, RPR0521_MANUFACT_ID);
+               return -ENODEV;
+       }
+
+       /* set default measurement time - 100 ms for both ALS and PS */
+       ret = regmap_update_bits(data->regmap, RPR0521_REG_MODE_CTRL,
+                                RPR0521_MODE_MEAS_TIME_MASK,
+                                RPR0521_DEFAULT_MEAS_TIME);
+       if (ret) {
+               pr_err("regmap_update_bits returned %d\n", ret);
+               return ret;
+       }
+
+       ret = rpr0521_als_enable(data, RPR0521_MODE_ALS_ENABLE);
+       if (ret < 0)
+               return ret;
+       ret = rpr0521_pxs_enable(data, RPR0521_MODE_PXS_ENABLE);
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
+
+static int rpr0521_poweroff(struct rpr0521_data *data)
+{
+       int ret;
+
+       ret = regmap_update_bits(data->regmap, RPR0521_REG_MODE_CTRL,
+                                RPR0521_MODE_ALS_MASK |
+                                RPR0521_MODE_PXS_MASK,
+                                RPR0521_MODE_ALS_DISABLE |
+                                RPR0521_MODE_PXS_DISABLE);
+       if (ret < 0)
+               return ret;
+
+       data->als_dev_en = false;
+       data->pxs_dev_en = false;
+
+       return 0;
+}
+
+static bool rpr0521_is_volatile_reg(struct device *dev, unsigned int reg)
+{
+       switch (reg) {
+       case RPR0521_REG_MODE_CTRL:
+       case RPR0521_REG_ALS_CTRL:
+       case RPR0521_REG_PXS_CTRL:
+               return false;
+       default:
+               return true;
+       }
+}
+
+static const struct regmap_config rpr0521_regmap_config = {
+       .name           = RPR0521_REGMAP_NAME,
+
+       .reg_bits       = 8,
+       .val_bits       = 8,
+
+       .max_register   = RPR0521_REG_ID,
+       .cache_type     = REGCACHE_RBTREE,
+       .volatile_reg   = rpr0521_is_volatile_reg,
+};
+
+static int rpr0521_probe(struct i2c_client *client,
+                        const struct i2c_device_id *id)
+{
+       struct rpr0521_data *data;
+       struct iio_dev *indio_dev;
+       struct regmap *regmap;
+       int ret;
+
+       indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
+       if (!indio_dev)
+               return -ENOMEM;
+
+       regmap = devm_regmap_init_i2c(client, &rpr0521_regmap_config);
+       if (IS_ERR(regmap)) {
+               dev_err(&client->dev, "regmap_init failed!\n");
+               return PTR_ERR(regmap);
+       }
+
+       data = iio_priv(indio_dev);
+       i2c_set_clientdata(client, indio_dev);
+       data->client = client;
+       data->regmap = regmap;
+
+       mutex_init(&data->lock);
+
+       indio_dev->dev.parent = &client->dev;
+       indio_dev->info = &rpr0521_info;
+       indio_dev->name = RPR0521_DRV_NAME;
+       indio_dev->channels = rpr0521_channels;
+       indio_dev->num_channels = ARRAY_SIZE(rpr0521_channels);
+       indio_dev->modes = INDIO_DIRECT_MODE;
+
+       ret = rpr0521_init(data);
+       if (ret < 0) {
+               dev_err(&client->dev, "rpr0521 chip init failed\n");
+               return ret;
+       }
+       ret = iio_device_register(indio_dev);
+       if (ret < 0)
+               return ret;
+
+       ret = pm_runtime_set_active(&client->dev);
+       if (ret < 0)
+               goto err_iio_unregister;
+
+       pm_runtime_enable(&client->dev);
+       pm_runtime_set_autosuspend_delay(&client->dev, RPR0521_SLEEP_DELAY_MS);
+       pm_runtime_use_autosuspend(&client->dev);
+
+       return 0;
+
+err_iio_unregister:
+       iio_device_unregister(indio_dev);
+       return ret;
+}
+
+static int rpr0521_remove(struct i2c_client *client)
+{
+       struct iio_dev *indio_dev = i2c_get_clientdata(client);
+
+       pm_runtime_disable(&client->dev);
+       pm_runtime_set_suspended(&client->dev);
+       pm_runtime_put_noidle(&client->dev);
+
+       iio_device_unregister(indio_dev);
+       rpr0521_poweroff(iio_priv(indio_dev));
+
+       return 0;
+}
+
+#ifdef CONFIG_PM
+static int rpr0521_runtime_suspend(struct device *dev)
+{
+       struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
+       struct rpr0521_data *data = iio_priv(indio_dev);
+       int ret;
+
+       /* disable channels and sets {als,pxs}_dev_en to false */
+       mutex_lock(&data->lock);
+       ret = rpr0521_poweroff(data);
+       mutex_unlock(&data->lock);
+
+       return ret;
+}
+
+static int rpr0521_runtime_resume(struct device *dev)
+{
+       struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
+       struct rpr0521_data *data = iio_priv(indio_dev);
+       int ret;
+
+       if (data->als_ps_need_en) {
+               ret = rpr0521_als_enable(data, RPR0521_MODE_ALS_ENABLE);
+               if (ret < 0)
+                       return ret;
+               data->als_ps_need_en = false;
+       }
+
+       if (data->pxs_ps_need_en) {
+               ret = rpr0521_pxs_enable(data, RPR0521_MODE_PXS_ENABLE);
+               if (ret < 0)
+                       return ret;
+               data->pxs_ps_need_en = false;
+       }
+
+       return 0;
+}
+#endif
+
+static const struct dev_pm_ops rpr0521_pm_ops = {
+       SET_RUNTIME_PM_OPS(rpr0521_runtime_suspend,
+                          rpr0521_runtime_resume, NULL)
+};
+
+static const struct acpi_device_id rpr0521_acpi_match[] = {
+       {"RPR0521", 0},
+       { }
+};
+MODULE_DEVICE_TABLE(acpi, rpr0521_acpi_match);
+
+static const struct i2c_device_id rpr0521_id[] = {
+       {"rpr0521", 0},
+       { }
+};
+
+MODULE_DEVICE_TABLE(i2c, rpr0521_id);
+
+static struct i2c_driver rpr0521_driver = {
+       .driver = {
+               .name   = RPR0521_DRV_NAME,
+               .pm     = &rpr0521_pm_ops,
+               .acpi_match_table = ACPI_PTR(rpr0521_acpi_match),
+       },
+       .probe          = rpr0521_probe,
+       .remove         = rpr0521_remove,
+       .id_table       = rpr0521_id,
+};
+
+module_i2c_driver(rpr0521_driver);
+
+MODULE_AUTHOR("Daniel Baluta <daniel.baluta@intel.com>");
+MODULE_DESCRIPTION("RPR0521 ROHM Ambient Light and Proximity Sensor driver");
+MODULE_LICENSE("GPL v2");
index f8b1df0..f90f8c5 100644 (file)
@@ -392,7 +392,6 @@ static struct i2c_driver tcs3414_driver = {
        .driver = {
                .name   = TCS3414_DRV_NAME,
                .pm     = &tcs3414_pm_ops,
-               .owner  = THIS_MODULE,
        },
        .probe          = tcs3414_probe,
        .remove         = tcs3414_remove,
index 7525699..1b530bf 100644 (file)
@@ -366,7 +366,6 @@ static struct i2c_driver tcs3472_driver = {
        .driver = {
                .name   = TCS3472_DRV_NAME,
                .pm     = &tcs3472_pm_ops,
-               .owner  = THIS_MODULE,
        },
        .probe          = tcs3472_probe,
        .remove         = tcs3472_remove,
index 63c26e2..2697918 100644 (file)
@@ -247,7 +247,6 @@ static struct i2c_driver tsl4531_driver = {
        .driver = {
                .name   = TSL4531_DRV_NAME,
                .pm     = TSL4531_PM_OPS,
-               .owner  = THIS_MODULE,
        },
        .probe  = tsl4531_probe,
        .remove = tsl4531_remove,
index d948c47..c9d85bb 100644 (file)
@@ -185,7 +185,6 @@ static int vcnl4000_probe(struct i2c_client *client,
 static struct i2c_driver vcnl4000_driver = {
        .driver = {
                .name   = VCNL4000_DRV_NAME,
-               .owner  = THIS_MODULE,
        },
        .probe  = vcnl4000_probe,
        .id_table = vcnl4000_id,
index d4c1788..cd00271 100644 (file)
@@ -588,17 +588,6 @@ static int bmc150_magn_write_raw(struct iio_dev *indio_dev,
        }
 }
 
-static int bmc150_magn_validate_trigger(struct iio_dev *indio_dev,
-                                       struct iio_trigger *trig)
-{
-       struct bmc150_magn_data *data = iio_priv(indio_dev);
-
-       if (data->dready_trig != trig)
-               return -EINVAL;
-
-       return 0;
-}
-
 static ssize_t bmc150_magn_show_samp_freq_avail(struct device *dev,
                                                struct device_attribute *attr,
                                                char *buf)
@@ -659,7 +648,6 @@ static const struct iio_info bmc150_magn_info = {
        .attrs = &bmc150_magn_attrs_group,
        .read_raw = bmc150_magn_read_raw,
        .write_raw = bmc150_magn_write_raw,
-       .validate_trigger = bmc150_magn_validate_trigger,
        .driver_module = THIS_MODULE,
 };
 
@@ -682,7 +670,7 @@ static irqreturn_t bmc150_magn_trigger_handler(int irq, void *p)
                                           pf->timestamp);
 
 err:
-       iio_trigger_notify_done(data->dready_trig);
+       iio_trigger_notify_done(indio_dev->trig);
 
        return IRQ_HANDLED;
 }
@@ -827,6 +815,27 @@ static const struct iio_trigger_ops bmc150_magn_trigger_ops = {
        .owner = THIS_MODULE,
 };
 
+static int bmc150_magn_buffer_preenable(struct iio_dev *indio_dev)
+{
+       struct bmc150_magn_data *data = iio_priv(indio_dev);
+
+       return bmc150_magn_set_power_state(data, true);
+}
+
+static int bmc150_magn_buffer_postdisable(struct iio_dev *indio_dev)
+{
+       struct bmc150_magn_data *data = iio_priv(indio_dev);
+
+       return bmc150_magn_set_power_state(data, false);
+}
+
+static const struct iio_buffer_setup_ops bmc150_magn_buffer_setup_ops = {
+       .preenable = bmc150_magn_buffer_preenable,
+       .postenable = iio_triggered_buffer_postenable,
+       .predisable = iio_triggered_buffer_predisable,
+       .postdisable = bmc150_magn_buffer_postdisable,
+};
+
 static int bmc150_magn_gpio_probe(struct i2c_client *client)
 {
        struct device *dev;
@@ -932,16 +941,6 @@ static int bmc150_magn_probe(struct i2c_client *client,
                        goto err_poweroff;
                }
 
-               ret = iio_triggered_buffer_setup(indio_dev,
-                                                &iio_pollfunc_store_time,
-                                                bmc150_magn_trigger_handler,
-                                                NULL);
-               if (ret < 0) {
-                       dev_err(&client->dev,
-                               "iio triggered buffer setup failed\n");
-                       goto err_trigger_unregister;
-               }
-
                ret = request_threaded_irq(client->irq,
                                           iio_trigger_generic_data_rdy_poll,
                                           NULL,
@@ -951,14 +950,24 @@ static int bmc150_magn_probe(struct i2c_client *client,
                if (ret < 0) {
                        dev_err(&client->dev, "request irq %d failed\n",
                                client->irq);
-                       goto err_buffer_cleanup;
+                       goto err_trigger_unregister;
                }
        }
 
+       ret = iio_triggered_buffer_setup(indio_dev,
+                                        iio_pollfunc_store_time,
+                                        bmc150_magn_trigger_handler,
+                                        &bmc150_magn_buffer_setup_ops);
+       if (ret < 0) {
+               dev_err(&client->dev,
+                       "iio triggered buffer setup failed\n");
+               goto err_free_irq;
+       }
+
        ret = iio_device_register(indio_dev);
        if (ret < 0) {
                dev_err(&client->dev, "unable to register iio device\n");
-               goto err_free_irq;
+               goto err_buffer_cleanup;
        }
 
        ret = pm_runtime_set_active(&client->dev);
@@ -976,12 +985,11 @@ static int bmc150_magn_probe(struct i2c_client *client,
 
 err_iio_unregister:
        iio_device_unregister(indio_dev);
+err_buffer_cleanup:
+       iio_triggered_buffer_cleanup(indio_dev);
 err_free_irq:
        if (client->irq > 0)
                free_irq(client->irq, data->dready_trig);
-err_buffer_cleanup:
-       if (data->dready_trig)
-               iio_triggered_buffer_cleanup(indio_dev);
 err_trigger_unregister:
        if (data->dready_trig)
                iio_trigger_unregister(data->dready_trig);
@@ -1000,14 +1008,13 @@ static int bmc150_magn_remove(struct i2c_client *client)
        pm_runtime_put_noidle(&client->dev);
 
        iio_device_unregister(indio_dev);
+       iio_triggered_buffer_cleanup(indio_dev);
 
        if (client->irq > 0)
                free_irq(data->client->irq, data->dready_trig);
 
-       if (data->dready_trig) {
-               iio_triggered_buffer_cleanup(indio_dev);
+       if (data->dready_trig)
                iio_trigger_unregister(data->dready_trig);
-       }
 
        mutex_lock(&data->mutex);
        bmc150_magn_set_power_mode(data, BMC150_MAGN_POWER_MODE_SUSPEND, true);
@@ -1082,12 +1089,14 @@ static const struct dev_pm_ops bmc150_magn_pm_ops = {
 
 static const struct acpi_device_id bmc150_magn_acpi_match[] = {
        {"BMC150B", 0},
+       {"BMC156B", 0},
        {},
 };
 MODULE_DEVICE_TABLE(acpi, bmc150_magn_acpi_match);
 
 static const struct i2c_device_id bmc150_magn_id[] = {
        {"bmc150_magn", 0},
+       {"bmc156_magn", 0},
        {},
 };
 MODULE_DEVICE_TABLE(i2c, bmc150_magn_id);
index 5311d8a..28aa807 100644 (file)
@@ -85,7 +85,6 @@ MODULE_DEVICE_TABLE(i2c, st_magn_id_table);
 
 static struct i2c_driver st_magn_driver = {
        .driver = {
-               .owner = THIS_MODULE,
                .name = "st-magn-i2c",
                .of_match_table = of_match_ptr(st_magn_of_match),
        },
index fa62950..4745179 100644 (file)
@@ -53,10 +53,10 @@ config MPL3115
           will be called mpl3115.
 
 config MS5611
-       tristate "Measurement Specialities MS5611 pressure sensor driver"
+       tristate "Measurement Specialties MS5611 pressure sensor driver"
        help
-         Say Y here to build support for the Measurement Specialities
-         MS5611 pressure and temperature sensor.
+         Say Y here to build support for the Measurement Specialties
+         MS5611, MS5607 pressure and temperature sensors.
 
          To compile this driver as a module, choose M here: the module will
          be called ms5611_core.
index 099c6cd..23b93c7 100644 (file)
 
 #define MS5611_PROM_WORDS_NB           8
 
+enum {
+       MS5611,
+       MS5607,
+};
+
+struct ms5611_chip_info {
+       u16 prom[MS5611_PROM_WORDS_NB];
+
+       int (*temp_and_pressure_compensate)(struct ms5611_chip_info *chip_info,
+                                           s32 *temp, s32 *pressure);
+};
+
 struct ms5611_state {
        void *client;
        struct mutex lock;
@@ -36,9 +48,9 @@ struct ms5611_state {
        int (*read_adc_temp_and_pressure)(struct device *dev,
                                          s32 *temp, s32 *pressure);
 
-       u16 prom[MS5611_PROM_WORDS_NB];
+       struct ms5611_chip_info *chip_info;
 };
 
-int ms5611_probe(struct iio_dev *indio_dev, struct device *dev);
+int ms5611_probe(struct iio_dev *indio_dev, struct device *dev, int type);
 
 #endif /* _MS5611_H */
index e42c853..2f3d9b4 100644 (file)
@@ -9,6 +9,7 @@
  *
  * Data sheet:
  *  http://www.meas-spec.com/downloads/MS5611-01BA03.pdf
+ *  http://www.meas-spec.com/downloads/MS5607-02BA03.pdf
  *
  */
 
@@ -50,7 +51,8 @@ static int ms5611_read_prom(struct iio_dev *indio_dev)
        struct ms5611_state *st = iio_priv(indio_dev);
 
        for (i = 0; i < MS5611_PROM_WORDS_NB; i++) {
-               ret = st->read_prom_word(&indio_dev->dev, i, &st->prom[i]);
+               ret = st->read_prom_word(&indio_dev->dev,
+                                        i, &st->chip_info->prom[i]);
                if (ret < 0) {
                        dev_err(&indio_dev->dev,
                                "failed to read prom at %d\n", i);
@@ -58,7 +60,7 @@ static int ms5611_read_prom(struct iio_dev *indio_dev)
                }
        }
 
-       if (!ms5611_prom_is_valid(st->prom, MS5611_PROM_WORDS_NB)) {
+       if (!ms5611_prom_is_valid(st->chip_info->prom, MS5611_PROM_WORDS_NB)) {
                dev_err(&indio_dev->dev, "PROM integrity check failed\n");
                return -ENODEV;
        }
@@ -70,22 +72,30 @@ static int ms5611_read_temp_and_pressure(struct iio_dev *indio_dev,
                                         s32 *temp, s32 *pressure)
 {
        int ret;
-       s32 t, p;
-       s64 off, sens, dt;
        struct ms5611_state *st = iio_priv(indio_dev);
 
-       ret = st->read_adc_temp_and_pressure(&indio_dev->dev, &t, &p);
+       ret = st->read_adc_temp_and_pressure(&indio_dev->dev, temp, pressure);
        if (ret < 0) {
                dev_err(&indio_dev->dev,
                        "failed to read temperature and pressure\n");
                return ret;
        }
 
-       dt = t - (st->prom[5] << 8);
-       off = ((s64)st->prom[2] << 16) + ((st->prom[4] * dt) >> 7);
-       sens = ((s64)st->prom[1] << 15) + ((st->prom[3] * dt) >> 8);
+       return st->chip_info->temp_and_pressure_compensate(st->chip_info,
+                                                          temp, pressure);
+}
+
+static int ms5611_temp_and_pressure_compensate(struct ms5611_chip_info *chip_info,
+                                              s32 *temp, s32 *pressure)
+{
+       s32 t = *temp, p = *pressure;
+       s64 off, sens, dt;
 
-       t = 2000 + ((st->prom[6] * dt) >> 23);
+       dt = t - (chip_info->prom[5] << 8);
+       off = ((s64)chip_info->prom[2] << 16) + ((chip_info->prom[4] * dt) >> 7);
+       sens = ((s64)chip_info->prom[1] << 15) + ((chip_info->prom[3] * dt) >> 8);
+
+       t = 2000 + ((chip_info->prom[6] * dt) >> 23);
        if (t < 2000) {
                s64 off2, sens2, t2;
 
@@ -111,6 +121,42 @@ static int ms5611_read_temp_and_pressure(struct iio_dev *indio_dev,
        return 0;
 }
 
+static int ms5607_temp_and_pressure_compensate(struct ms5611_chip_info *chip_info,
+                                              s32 *temp, s32 *pressure)
+{
+       s32 t = *temp, p = *pressure;
+       s64 off, sens, dt;
+
+       dt = t - (chip_info->prom[5] << 8);
+       off = ((s64)chip_info->prom[2] << 17) + ((chip_info->prom[4] * dt) >> 6);
+       sens = ((s64)chip_info->prom[1] << 16) + ((chip_info->prom[3] * dt) >> 7);
+
+       t = 2000 + ((chip_info->prom[6] * dt) >> 23);
+       if (t < 2000) {
+               s64 off2, sens2, t2;
+
+               t2 = (dt * dt) >> 31;
+               off2 = (61 * (t - 2000) * (t - 2000)) >> 4;
+               sens2 = off2 << 1;
+
+               if (t < -1500) {
+                       s64 tmp = (t + 1500) * (t + 1500);
+
+                       off2 += 15 * tmp;
+                       sens2 += (8 * tmp);
+               }
+
+               t -= t2;
+               off -= off2;
+               sens -= sens2;
+       }
+
+       *temp = t;
+       *pressure = (((p * sens) >> 21) - off) >> 15;
+
+       return 0;
+}
+
 static int ms5611_reset(struct iio_dev *indio_dev)
 {
        int ret;
@@ -160,16 +206,23 @@ static int ms5611_read_raw(struct iio_dev *indio_dev,
        return -EINVAL;
 }
 
+static struct ms5611_chip_info chip_info_tbl[] = {
+       [MS5611] = {
+               .temp_and_pressure_compensate = ms5611_temp_and_pressure_compensate,
+       },
+       [MS5607] = {
+               .temp_and_pressure_compensate = ms5607_temp_and_pressure_compensate,
+       }
+};
+
 static const struct iio_chan_spec ms5611_channels[] = {
        {
                .type = IIO_PRESSURE,
-               .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
-                       BIT(IIO_CHAN_INFO_SCALE)
+               .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
        },
        {
                .type = IIO_TEMP,
-               .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
-                       BIT(IIO_CHAN_INFO_SCALE)
+               .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
        }
 };
 
@@ -189,12 +242,13 @@ static int ms5611_init(struct iio_dev *indio_dev)
        return ms5611_read_prom(indio_dev);
 }
 
-int ms5611_probe(struct iio_dev *indio_dev, struct device *dev)
+int ms5611_probe(struct iio_dev *indio_dev, struct device *dev, int type)
 {
        int ret;
        struct ms5611_state *st = iio_priv(indio_dev);
 
        mutex_init(&st->lock);
+       st->chip_info = &chip_info_tbl[type];
        indio_dev->dev.parent = dev;
        indio_dev->name = dev->driver->name;
        indio_dev->info = &ms5611_info;
index 748fd9a..245797d 100644 (file)
@@ -104,11 +104,12 @@ static int ms5611_i2c_probe(struct i2c_client *client,
        st->read_adc_temp_and_pressure = ms5611_i2c_read_adc_temp_and_pressure;
        st->client = client;
 
-       return ms5611_probe(indio_dev, &client->dev);
+       return ms5611_probe(indio_dev, &client->dev, id->driver_data);
 }
 
 static const struct i2c_device_id ms5611_id[] = {
-       { "ms5611", 0 },
+       { "ms5611", MS5611 },
+       { "ms5607", MS5607 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, ms5611_id);
@@ -116,7 +117,6 @@ MODULE_DEVICE_TABLE(i2c, ms5611_id);
 static struct i2c_driver ms5611_driver = {
        .driver = {
                .name = "ms5611",
-               .owner = THIS_MODULE,
        },
        .id_table = ms5611_id,
        .probe = ms5611_i2c_probe,
index 976726f..08ee6e8 100644 (file)
@@ -103,11 +103,13 @@ static int ms5611_spi_probe(struct spi_device *spi)
        st->read_adc_temp_and_pressure = ms5611_spi_read_adc_temp_and_pressure;
        st->client = spi;
 
-       return ms5611_probe(indio_dev, &spi->dev);
+       return ms5611_probe(indio_dev, &spi->dev,
+                           spi_get_device_id(spi)->driver_data);
 }
 
 static const struct spi_device_id ms5611_id[] = {
-       { "ms5611", 0 },
+       { "ms5611", MS5611 },
+       { "ms5607", MS5607 },
        { }
 };
 MODULE_DEVICE_TABLE(spi, ms5611_id);
index 137788b..8fcf976 100644 (file)
@@ -79,7 +79,6 @@ MODULE_DEVICE_TABLE(i2c, st_press_id_table);
 
 static struct i2c_driver st_press_driver = {
        .driver = {
-               .owner = THIS_MODULE,
                .name = "st-press-i2c",
                .of_match_table = of_match_ptr(st_press_of_match),
        },
index cb2e8ad..90f70b4 100644 (file)
@@ -551,7 +551,6 @@ static const struct dev_pm_ops mlx90614_pm_ops = {
 static struct i2c_driver mlx90614_driver = {
        .driver = {
                .name   = "mlx90614",
-               .owner  = THIS_MODULE,
                .pm     = &mlx90614_pm_ops,
        },
        .probe = mlx90614_probe,
index 8f21f32..e78c106 100644 (file)
@@ -36,9 +36,9 @@
 #define TMP006_CONFIG_DRDY_EN BIT(8)
 #define TMP006_CONFIG_DRDY BIT(7)
 
-#define TMP006_CONFIG_MOD_MASK 0x7000
+#define TMP006_CONFIG_MOD_MASK GENMASK(14, 12)
 
-#define TMP006_CONFIG_CR_MASK 0x0e00
+#define TMP006_CONFIG_CR_MASK GENMASK(11, 9)
 #define TMP006_CONFIG_CR_SHIFT 9
 
 #define TMP006_MANUFACTURER_MAGIC 0x5449
@@ -280,7 +280,6 @@ static struct i2c_driver tmp006_driver = {
        .driver = {
                .name   = "tmp006",
                .pm     = &tmp006_pm_ops,
-               .owner  = THIS_MODULE,
        },
        .probe = tmp006_probe,
        .remove = tmp006_remove,
index 6f48112..eec878e 100644 (file)
@@ -1103,10 +1103,10 @@ static struct dma_buf_ops dma_buf_ops = {
 struct dma_buf *ion_share_dma_buf(struct ion_client *client,
                                                struct ion_handle *handle)
 {
+       DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
        struct ion_buffer *buffer;
        struct dma_buf *dmabuf;
        bool valid_handle;
-       DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
 
        mutex_lock(&client->lock);
        valid_handle = ion_handle_validate(client, handle);
@@ -1466,7 +1466,6 @@ static const struct file_operations debug_heap_fops = {
        .release = single_release,
 };
 
-#ifdef DEBUG_HEAP_SHRINKER
 static int debug_shrink_set(void *data, u64 val)
 {
        struct ion_heap *heap = data;
@@ -1474,15 +1473,14 @@ static int debug_shrink_set(void *data, u64 val)
        int objs;
 
        sc.gfp_mask = -1;
-       sc.nr_to_scan = 0;
+       sc.nr_to_scan = val;
 
-       if (!val)
-               return 0;
-
-       objs = heap->shrinker.shrink(&heap->shrinker, &sc);
-       sc.nr_to_scan = objs;
+       if (!val) {
+               objs = heap->shrinker.count_objects(&heap->shrinker, &sc);
+               sc.nr_to_scan = objs;
+       }
 
-       heap->shrinker.shrink(&heap->shrinker, &sc);
+       heap->shrinker.scan_objects(&heap->shrinker, &sc);
        return 0;
 }
 
@@ -1495,14 +1493,13 @@ static int debug_shrink_get(void *data, u64 *val)
        sc.gfp_mask = -1;
        sc.nr_to_scan = 0;
 
-       objs = heap->shrinker.shrink(&heap->shrinker, &sc);
+       objs = heap->shrinker.count_objects(&heap->shrinker, &sc);
        *val = objs;
        return 0;
 }
 
 DEFINE_SIMPLE_ATTRIBUTE(debug_shrink_fops, debug_shrink_get,
                        debug_shrink_set, "%llu\n");
-#endif
 
 void ion_device_add_heap(struct ion_device *dev, struct ion_heap *heap)
 {
@@ -1540,8 +1537,7 @@ void ion_device_add_heap(struct ion_device *dev, struct ion_heap *heap)
                        path, heap->name);
        }
 
-#ifdef DEBUG_HEAP_SHRINKER
-       if (heap->shrinker.shrink) {
+       if (heap->shrinker.count_objects && heap->shrinker.scan_objects) {
                char debug_name[64];
 
                snprintf(debug_name, 64, "%s_shrink", heap->name);
@@ -1556,7 +1552,7 @@ void ion_device_add_heap(struct ion_device *dev, struct ion_heap *heap)
                                path, debug_name);
                }
        }
-#endif
+
        up_write(&dev->lock);
 }
 
index 5474615..0813163 100644 (file)
@@ -173,8 +173,8 @@ struct ion_heap *ion_chunk_heap_create(struct ion_platform_heap *heap_data)
        chunk_heap->heap.ops = &chunk_heap_ops;
        chunk_heap->heap.type = ION_HEAP_TYPE_CHUNK;
        chunk_heap->heap.flags = ION_HEAP_FLAG_DEFER_FREE;
-       pr_debug("%s: base %lu size %zu align %ld\n", __func__, chunk_heap->base,
-               heap_data->size, heap_data->align);
+       pr_debug("%s: base %lu size %zu align %ld\n", __func__,
+               chunk_heap->base, heap_data->size, heap_data->align);
 
        return &chunk_heap->heap;
 
index 4b88f11..19ad3ab 100644 (file)
@@ -116,7 +116,7 @@ static int ion_page_pool_total(struct ion_page_pool *pool, bool high)
 int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask,
                                int nr_to_scan)
 {
-       int freed;
+       int freed = 0;
        bool high;
 
        if (current_is_kswapd())
@@ -127,7 +127,7 @@ int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask,
        if (nr_to_scan == 0)
                return ion_page_pool_total(pool, high);
 
-       for (freed = 0; freed < nr_to_scan; freed++) {
+       while (freed < nr_to_scan) {
                struct page *page;
 
                mutex_lock(&pool->mutex);
@@ -141,6 +141,7 @@ int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask,
                }
                mutex_unlock(&pool->mutex);
                ion_page_pool_free_pages(pool, page);
+               freed += (1 << pool->order);
        }
 
        return freed;
index da2a63c..7a7a9a0 100644 (file)
@@ -212,14 +212,26 @@ static int ion_system_heap_shrink(struct ion_heap *heap, gfp_t gfp_mask,
 {
        struct ion_system_heap *sys_heap;
        int nr_total = 0;
-       int i;
+       int i, nr_freed;
+       int only_scan = 0;
 
        sys_heap = container_of(heap, struct ion_system_heap, heap);
 
+       if (!nr_to_scan)
+               only_scan = 1;
+
        for (i = 0; i < num_orders; i++) {
                struct ion_page_pool *pool = sys_heap->pools[i];
 
-               nr_total += ion_page_pool_shrink(pool, gfp_mask, nr_to_scan);
+               nr_freed = ion_page_pool_shrink(pool, gfp_mask, nr_to_scan);
+               nr_total += nr_freed;
+
+               if (!only_scan) {
+                       nr_to_scan -= nr_freed;
+                       /* shrink completed */
+                       if (nr_to_scan <= 0)
+                               break;
+               }
        }
 
        return nr_total;
index 7dee73d..57e71f9 100644 (file)
@@ -2,7 +2,7 @@ config COMEDI
        tristate "Data acquisition support (comedi)"
        depends on m
        ---help---
-         Enable support a wide range of data acquisition devices
+         Enable support for a wide range of data acquisition devices
          for Linux.
 
 if COMEDI
index 2584824..f356386 100644 (file)
@@ -202,7 +202,8 @@ static int get_compat_cmd(struct comedi_cmd __user *cmd,
        err |= __get_user(temp.uint, &cmd32->stop_arg);
        err |= __put_user(temp.uint, &cmd->stop_arg);
        err |= __get_user(temp.uptr, &cmd32->chanlist);
-       err |= __put_user(compat_ptr(temp.uptr), &cmd->chanlist);
+       err |= __put_user((unsigned int __force *)compat_ptr(temp.uptr),
+                       &cmd->chanlist);
        err |= __get_user(temp.uint, &cmd32->chanlist_len);
        err |= __put_user(temp.uint, &cmd->chanlist_len);
        err |= __get_user(temp.uptr, &cmd32->data);
index 985d94b..4820ab6 100644 (file)
@@ -2599,14 +2599,14 @@ static int comedi_open(struct inode *inode, struct file *file)
        cfp->dev = dev;
 
        mutex_lock(&dev->mutex);
-       if (!dev->attached && !capable(CAP_NET_ADMIN)) {
-               dev_dbg(dev->class_dev, "not attached and not CAP_NET_ADMIN\n");
+       if (!dev->attached && !capable(CAP_SYS_ADMIN)) {
+               dev_dbg(dev->class_dev, "not attached and not CAP_SYS_ADMIN\n");
                rc = -ENODEV;
                goto out;
        }
        if (dev->attached && dev->use_count == 0) {
                if (!try_module_get(dev->driver->module)) {
-                       rc = -ENOSYS;
+                       rc = -ENXIO;
                        goto out;
                }
                if (dev->open) {
index 4ebf5aa..47e3839 100644 (file)
@@ -141,11 +141,13 @@ static const struct comedi_lrange cb_pcimdas_ai_uni_range = {
  * jumper-settable on the board. The settings are not software-readable.
  */
 static const struct comedi_lrange cb_pcimdas_ao_range = {
-       4, {
+       6, {
                BIP_RANGE(10),
                BIP_RANGE(5),
                UNI_RANGE(10),
-               UNI_RANGE(5)
+               UNI_RANGE(5),
+               RANGE_ext(-1, 1),
+               RANGE_ext(0, 1)
        }
 };
 
index a6798ad..a562df4 100644 (file)
@@ -130,11 +130,7 @@ static int dac02_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        s->range_table  = &das02_ao_ranges;
        s->insn_write   = dac02_ao_insn_write;
 
-       ret = comedi_alloc_subdev_readback(s);
-       if (ret)
-               return ret;
-
-       return 0;
+       return comedi_alloc_subdev_readback(s);
 }
 
 static struct comedi_driver dac02_driver = {
index 93fab68..9c02b17 100644 (file)
@@ -108,7 +108,7 @@ static struct pcmcia_driver das08_cs_driver = {
 };
 module_comedi_pcmcia_driver(driver_das08_cs, das08_cs_driver);
 
-MODULE_AUTHOR("David A. Schleef <ds@schleef.org>, "
-             "Frank Mori Hess <fmhess@users.sourceforge.net>");
+MODULE_AUTHOR("David A. Schleef <ds@schleef.org>");
+MODULE_AUTHOR("Frank Mori Hess <fmhess@users.sourceforge.net>");
 MODULE_DESCRIPTION("Comedi driver for ComputerBoards DAS-08 PCMCIA boards");
 MODULE_LICENSE("GPL");
index a18a887..3a37373 100644 (file)
@@ -69,18 +69,18 @@ irq can be omitted, although the cmd interface will not work without it.
 
     "cio-das16/m1"
 
-  0    a/d bits 0-3, mux               start 12 bit
-  1    a/d bits 4-11           unused
-  2    status          control
-  3    di 4 bit                do 4 bit
-  4    unused                  clear interrupt
-  5    interrupt, pacer
-  6    channel/gain queue address
-  7    channel/gain queue data
-  89ab 8254
-  cdef 8254
-  400  8255
-  404-407      8254
+  0            a/d bits 0-3, mux               start 12 bit
+  1            a/d bits 4-11           unused
+  2            status          control
+  3            di 4 bit                do 4 bit
+  4            unused                  clear interrupt
+  5            interrupt, pacer
+  6            channel/gain queue address
+  7            channel/gain queue data
+  89ab         8254
+  cdef         8254
+  400          8255
+  404-407      8254
 
 */
 
@@ -411,15 +411,18 @@ static void das16m1_handler(struct comedi_device *dev, unsigned int status)
        hw_counter = comedi_8254_read(devpriv->counter, 1);
        /* make sure hardware counter reading is not bogus due to initial value
         * not having been loaded yet */
-       if (devpriv->adc_count == 0 && hw_counter == devpriv->initial_hw_count) {
+       if (devpriv->adc_count == 0 &&
+           hw_counter == devpriv->initial_hw_count) {
                num_samples = 0;
        } else {
-               /* The calculation of num_samples looks odd, but it uses the following facts.
-                * 16 bit hardware counter is initialized with value of zero (which really
-                * means 0x1000).  The counter decrements by one on each conversion
-                * (when the counter decrements from zero it goes to 0xffff).  num_samples
-                * is a 16 bit variable, so it will roll over in a similar fashion to the
-                * hardware counter.  Work it out, and this is what you get. */
+               /* The calculation of num_samples looks odd, but it uses the
+                * following facts. 16 bit hardware counter is initialized with
+                * value of zero (which really means 0x1000).  The counter
+                * decrements by one on each conversion (when the counter
+                * decrements from zero it goes to 0xffff).  num_samples is a
+                * 16 bit variable, so it will roll over in a similar fashion
+                * to the hardware counter.  Work it out, and this is what you
+                * get. */
                num_samples = -hw_counter - devpriv->adc_count;
        }
        /*  check if we only need some of the points */
index bb2883c..958c0d4 100644 (file)
@@ -607,11 +607,7 @@ static int dmm32at_attach(struct comedi_device *dev,
 
        /* Digital I/O subdevice */
        s = &dev->subdevices[2];
-       ret = subdev_8255_init(dev, s, dmm32at_8255_io, DMM32AT_8255_IOBASE);
-       if (ret)
-               return ret;
-
-       return 0;
+       return subdev_8255_init(dev, s, dmm32at_8255_io, DMM32AT_8255_IOBASE);
 }
 
 static struct comedi_driver dmm32at_driver = {
index e1f4932..55cae61 100644 (file)
@@ -136,11 +136,7 @@ static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        s->range_table  = &range_fl512;
        s->insn_write   = fl512_ao_insn_write;
 
-       ret = comedi_alloc_subdev_readback(s);
-       if (ret)
-               return ret;
-
-       return 0;
+       return comedi_alloc_subdev_readback(s);
 }
 
 static struct comedi_driver fl512_driver = {
index a208cb3..d9de83a 100644 (file)
@@ -55,11 +55,7 @@ static int dio24_auto_attach(struct comedi_device *dev,
 
        /* 8255 dio */
        s = &dev->subdevices[0];
-       ret = subdev_8255_init(dev, s, NULL, 0x00);
-       if (ret)
-               return ret;
-
-       return 0;
+       return subdev_8255_init(dev, s, NULL, 0x00);
 }
 
 static struct comedi_driver driver_dio24 = {
index 781918d..35f0f67 100644 (file)
@@ -2852,11 +2852,7 @@ static int s626_auto_attach(struct comedi_device *dev,
        s->insn_read    = s626_enc_insn_read;
        s->insn_write   = s626_enc_insn_write;
 
-       ret = s626_initialize(dev);
-       if (ret)
-               return ret;
-
-       return 0;
+       return s626_initialize(dev);
 }
 
 static void s626_detach(struct comedi_device *dev)
index 26b0446..b344e03 100644 (file)
@@ -7004,25 +7004,29 @@ static void dgap_cleanup_board(struct board_t *brd)
        kfree(brd);
 }
 
-static void dgap_remove_one(struct pci_dev *dev)
+static void dgap_stop(bool removesys, struct pci_driver *drv)
 {
-       unsigned int i;
-       ulong lock_flags;
-       struct pci_driver *drv = to_pci_driver(dev->dev.driver);
+       unsigned long lock_flags;
 
        spin_lock_irqsave(&dgap_poll_lock, lock_flags);
        dgap_poll_stop = 1;
        spin_unlock_irqrestore(&dgap_poll_lock, lock_flags);
 
-       /* Turn off poller right away. */
        del_timer_sync(&dgap_poll_timer);
-
-       dgap_remove_driver_sysfiles(drv);
+       if (removesys)
+               dgap_remove_driver_sysfiles(drv);
 
        device_destroy(dgap_class, MKDEV(DIGI_DGAP_MAJOR, 0));
        class_destroy(dgap_class);
        unregister_chrdev(DIGI_DGAP_MAJOR, "dgap");
+}
 
+static void dgap_remove_one(struct pci_dev *dev)
+{
+       unsigned int i;
+       struct pci_driver *drv = to_pci_driver(dev->dev.driver);
+
+       dgap_stop(true, drv);
        for (i = 0; i < dgap_numboards; ++i) {
                dgap_remove_ports_sysfiles(dgap_board[i]);
                dgap_cleanup_tty(dgap_board[i]);
@@ -7096,21 +7100,6 @@ failed_class:
        return rc;
 }
 
-static void dgap_stop(void)
-{
-       unsigned long lock_flags;
-
-       spin_lock_irqsave(&dgap_poll_lock, lock_flags);
-       dgap_poll_stop = 1;
-       spin_unlock_irqrestore(&dgap_poll_lock, lock_flags);
-
-       del_timer_sync(&dgap_poll_timer);
-
-       device_destroy(dgap_class, MKDEV(DIGI_DGAP_MAJOR, 0));
-       class_destroy(dgap_class);
-       unregister_chrdev(DIGI_DGAP_MAJOR, "dgap");
-}
-
 /************************************************************************
  *
  * Driver load/unload functions
@@ -7133,8 +7122,10 @@ static int dgap_init_module(void)
                return rc;
 
        rc = pci_register_driver(&dgap_driver);
-       if (rc)
-               goto err_stop;
+       if (rc) {
+               dgap_stop(false, NULL);
+               return rc;
+       }
 
        rc = dgap_create_driver_sysfiles(&dgap_driver);
        if (rc)
@@ -7146,9 +7137,6 @@ static int dgap_init_module(void)
 
 err_unregister:
        pci_unregister_driver(&dgap_driver);
-err_stop:
-       dgap_stop();
-
        return rc;
 }
 
index d401878..f7e68fd 100644 (file)
@@ -152,6 +152,12 @@ config FB_TFT_TLS8204
        help
          Generic Framebuffer support for TLS8204
 
+config FB_TFT_UC1611
+       tristate "FB driver for the UC1611 LCD controller"
+       depends on FB_TFT
+       help
+         Generic Framebuffer support for UC1611
+
 config FB_TFT_UC1701
        tristate "FB driver for the UC1701 LCD Controller"
        depends on FB_TFT
index 554b526..b26efdc 100644 (file)
@@ -27,6 +27,7 @@ obj-$(CONFIG_FB_TFT_SSD1351)     += fb_ssd1351.o
 obj-$(CONFIG_FB_TFT_ST7735R)     += fb_st7735r.o
 obj-$(CONFIG_FB_TFT_TINYLCD)     += fb_tinylcd.o
 obj-$(CONFIG_FB_TFT_TLS8204)     += fb_tls8204.o
+obj-$(CONFIG_FB_TFT_UC1611)      += fb_uc1611.o
 obj-$(CONFIG_FB_TFT_UC1701)      += fb_uc1701.o
 obj-$(CONFIG_FB_TFT_UPD161704)   += fb_upd161704.o
 obj-$(CONFIG_FB_TFT_WATTEROTT)   += fb_watterott.o
diff --git a/drivers/staging/fbtft/fb_uc1611.c b/drivers/staging/fbtft/fb_uc1611.c
new file mode 100644 (file)
index 0000000..32f3a9d
--- /dev/null
@@ -0,0 +1,350 @@
+/*
+ * FB driver for the UltraChip UC1611 LCD controller
+ *
+ * The display is 4-bit grayscale (16 shades) 240x160.
+ *
+ * Copyright (C) 2015 Henri Chain
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/gpio.h>
+#include <linux/spi/spi.h>
+#include <linux/delay.h>
+
+#include "fbtft.h"
+
+#define DRVNAME                "fb_uc1611"
+#define WIDTH          240
+#define HEIGHT         160
+#define BPP            8
+#define FPS            40
+
+/*
+ * LCD voltage is a combination of ratio, gain, pot and temp
+ *
+ * V_LCD = V_BIAS * ratio
+ * V_LCD = (C_V0 + C_PM Ã— pot) * (1 + (T - 25) * temp)
+ * C_V0 and C_PM depend on ratio and gain
+ * T is ambient temperature
+ */
+
+/* BR -> actual ratio: 0-3 -> 5, 10, 11, 13 */
+static unsigned ratio = 2;
+module_param(ratio, uint, 0);
+MODULE_PARM_DESC(ratio, "BR[1:0] Bias voltage ratio: 0-3 (default: 2)");
+
+static unsigned gain = 3;
+module_param(gain, uint, 0);
+MODULE_PARM_DESC(gain, "GN[1:0] Bias voltage gain: 0-3 (default: 3)");
+
+static unsigned pot = 16;
+module_param(pot, uint, 0);
+MODULE_PARM_DESC(pot, "PM[6:0] Bias voltage pot.: 0-63 (default: 16)");
+
+/* TC -> % compensation per deg C: 0-3 -> -.05, -.10, -.015, -.20 */
+static unsigned temp;
+module_param(temp, uint, 0);
+MODULE_PARM_DESC(temp, "TC[1:0] Temperature compensation: 0-3 (default: 0)");
+
+/* PC[1:0] -> LCD capacitance: 0-3 -> <20nF, 20-28 nF, 29-40 nF, 40-56 nF */
+static unsigned load = 1;
+module_param(load, uint, 0);
+MODULE_PARM_DESC(load, "PC[1:0] Panel Loading: 0-3 (default: 1)");
+
+/* PC[3:2] -> V_LCD: 0, 1, 3 -> ext., int. with ratio = 5, int. standard */
+static unsigned pump = 3;
+module_param(pump, uint, 0);
+MODULE_PARM_DESC(pump, "PC[3:2] Pump control: 0,1,3 (default: 3)");
+
+static int init_display(struct fbtft_par *par)
+{
+       int ret;
+
+       fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "%s()\n", __func__);
+
+       /* Set CS active high */
+       par->spi->mode |= SPI_CS_HIGH;
+       ret = par->spi->master->setup(par->spi);
+       if (ret) {
+               dev_err(par->info->device, "Could not set SPI_CS_HIGH\n");
+               return ret;
+       }
+
+       /* Reset controller */
+       write_reg(par, 0xE2);
+
+       /* Set bias ratio */
+       write_reg(par, 0xE8 | (ratio & 0x03));
+
+       /* Set bias gain and potentiometer */
+       write_reg(par, 0x81);
+       write_reg(par, (gain & 0x03) << 6 | (pot & 0x3F));
+
+       /* Set temperature compensation */
+       write_reg(par, 0x24 | (temp & 0x03));
+
+       /* Set panel loading */
+       write_reg(par, 0x28 | (load & 0x03));
+
+       /* Set pump control */
+       write_reg(par, 0x2C | (pump & 0x03));
+
+       /* Set inverse display */
+       write_reg(par, 0xA6 | (0x01 & 0x01));
+
+       /* Set 4-bit grayscale mode */
+       write_reg(par, 0xD0 | (0x02 & 0x03));
+
+       /* Set Display enable */
+       write_reg(par, 0xA8 | 0x07);
+
+       return 0;
+}
+
+static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
+{
+       fbtft_par_dbg(DEBUG_SET_ADDR_WIN, par,
+                     "%s(xs=%d, ys=%d, xe=%d, ye=%d)\n",
+                     __func__, xs, ys, xe, ye);
+
+       switch (par->info->var.rotate) {
+       case 90:
+       case 270:
+               /* Set column address */
+               write_reg(par, ys & 0x0F);
+               write_reg(par, 0x10 | (ys >> 4));
+
+               /* Set page address (divide xs by 2) (not used by driver) */
+               write_reg(par, 0x60 | ((xs >> 1) & 0x0F));
+               write_reg(par, 0x70 | (xs >> 5));
+               break;
+       default:
+               /* Set column address (not used by driver) */
+               write_reg(par, xs & 0x0F);
+               write_reg(par, 0x10 | (xs >> 4));
+
+               /* Set page address (divide ys by 2) */
+               write_reg(par, 0x60 | ((ys >> 1) & 0x0F));
+               write_reg(par, 0x70 | (ys >> 5));
+               break;
+       }
+}
+
+static int blank(struct fbtft_par *par, bool on)
+{
+       fbtft_par_dbg(DEBUG_BLANK, par, "%s(blank=%s)\n",
+                     __func__, on ? "true" : "false");
+
+       if (on)
+               write_reg(par, 0xA8 | 0x00);
+       else
+               write_reg(par, 0xA8 | 0x07);
+       return 0;
+}
+
+static int set_var(struct fbtft_par *par)
+{
+       fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "%s()\n", __func__);
+
+       /* par->info->fix.visual = FB_VISUAL_PSEUDOCOLOR; */
+       par->info->var.grayscale = 1;
+       par->info->var.red.offset    = 0;
+       par->info->var.red.length    = 8;
+       par->info->var.green.offset  = 0;
+       par->info->var.green.length  = 8;
+       par->info->var.blue.offset   = 0;
+       par->info->var.blue.length   = 8;
+       par->info->var.transp.offset = 0;
+       par->info->var.transp.length = 0;
+
+       switch (par->info->var.rotate) {
+       case 90:
+               /* Set RAM address control */
+               write_reg(par, 0x88
+                       | (0x0 & 0x1) << 2 /* Increment positively */
+                       | (0x1 & 0x1) << 1 /* Increment page first */
+                       | (0x1 & 0x1));    /* Wrap around (default) */
+
+               /* Set LCD mapping */
+               write_reg(par, 0xC0
+                       | (0x0 & 0x1) << 2 /* Mirror Y OFF */
+                       | (0x0 & 0x1) << 1 /* Mirror X OFF */
+                       | (0x0 & 0x1));    /* MS nibble last (default) */
+               break;
+       case 180:
+               /* Set RAM address control */
+               write_reg(par, 0x88
+                       | (0x0 & 0x1) << 2 /* Increment positively */
+                       | (0x0 & 0x1) << 1 /* Increment column first */
+                       | (0x1 & 0x1));    /* Wrap around (default) */
+
+               /* Set LCD mapping */
+               write_reg(par, 0xC0
+                       | (0x1 & 0x1) << 2 /* Mirror Y ON */
+                       | (0x0 & 0x1) << 1 /* Mirror X OFF */
+                       | (0x0 & 0x1));    /* MS nibble last (default) */
+               break;
+       case 270:
+               /* Set RAM address control */
+               write_reg(par, 0x88
+                       | (0x0 & 0x1) << 2 /* Increment positively */
+                       | (0x1 & 0x1) << 1 /* Increment page first */
+                       | (0x1 & 0x1));    /* Wrap around (default) */
+
+               /* Set LCD mapping */
+               write_reg(par, 0xC0
+                       | (0x1 & 0x1) << 2 /* Mirror Y ON */
+                       | (0x1 & 0x1) << 1 /* Mirror X ON */
+                       | (0x0 & 0x1));    /* MS nibble last (default) */
+               break;
+       default:
+               /* Set RAM address control */
+               write_reg(par, 0x88
+                       | (0x0 & 0x1) << 2 /* Increment positively */
+                       | (0x0 & 0x1) << 1 /* Increment column first */
+                       | (0x1 & 0x1));    /* Wrap around (default) */
+
+               /* Set LCD mapping */
+               write_reg(par, 0xC0
+                       | (0x0 & 0x1) << 2 /* Mirror Y OFF */
+                       | (0x1 & 0x1) << 1 /* Mirror X ON */
+                       | (0x0 & 0x1));    /* MS nibble last (default) */
+               break;
+       }
+
+       return 0;
+}
+
+static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
+{
+       u8 *vmem8 = (u8 *)(par->info->screen_base);
+       u8 *buf8 = (u8 *)(par->txbuf.buf);
+       u16 *buf16 = (u16 *)(par->txbuf.buf);
+       int line_length = par->info->fix.line_length;
+       int y_start = (offset / line_length);
+       int y_end = (offset + len - 1) / line_length;
+       int x, y, i;
+       int ret = 0;
+
+       fbtft_par_dbg(DEBUG_WRITE_VMEM, par, "%s()\n", __func__);
+
+       switch (par->pdata->display.buswidth) {
+       case 8:
+               switch (par->info->var.rotate) {
+               case 90:
+               case 270:
+                       i = y_start * line_length;
+                       for (y = y_start; y <= y_end; y++) {
+                               for (x = 0; x < line_length; x += 2) {
+                                       *buf8 = vmem8[i] >> 4;
+                                       *buf8 |= vmem8[i + 1] & 0xF0;
+                                       buf8++;
+                                       i += 2;
+                               }
+                       }
+                       break;
+               default:
+                       /* Must be even because pages are two lines */
+                       y_start &= 0xFE;
+                       i = y_start * line_length;
+                       for (y = y_start; y <= y_end; y += 2) {
+                               for (x = 0; x < line_length; x++) {
+                                       *buf8 = vmem8[i] >> 4;
+                                       *buf8 |= vmem8[i + line_length] & 0xF0;
+                                       buf8++;
+                                       i++;
+                               }
+                               i += line_length;
+                       }
+                       break;
+               }
+               gpio_set_value(par->gpio.dc, 1);
+
+               /* Write data */
+               ret = par->fbtftops.write(par, par->txbuf.buf, len / 2);
+               break;
+       case 9:
+               switch (par->info->var.rotate) {
+               case 90:
+               case 270:
+                       i = y_start * line_length;
+                       for (y = y_start; y <= y_end; y++) {
+                               for (x = 0; x < line_length; x += 2) {
+                                       *buf16 = 0x100;
+                                       *buf16 |= vmem8[i] >> 4;
+                                       *buf16 |= vmem8[i + 1] & 0xF0;
+                                       buf16++;
+                                       i += 2;
+                               }
+                       }
+                       break;
+               default:
+                       /* Must be even because pages are two lines */
+                       y_start &= 0xFE;
+                       i = y_start * line_length;
+                       for (y = y_start; y <= y_end; y += 2) {
+                               for (x = 0; x < line_length; x++) {
+                                       *buf16 = 0x100;
+                                       *buf16 |= vmem8[i] >> 4;
+                                       *buf16 |= vmem8[i + line_length] & 0xF0;
+                                       buf16++;
+                                       i++;
+                               }
+                               i += line_length;
+                       }
+                       break;
+               }
+
+               /* Write data */
+               ret = par->fbtftops.write(par, par->txbuf.buf, len);
+               break;
+       default:
+               dev_err(par->info->device, "unsupported buswidth %d\n",
+                       par->pdata->display.buswidth);
+       }
+
+       if (ret < 0)
+               dev_err(par->info->device, "write failed and returned: %d\n",
+                       ret);
+
+       return ret;
+}
+
+static struct fbtft_display display = {
+       .txbuflen = -1,
+       .regwidth = 8,
+       .width = WIDTH,
+       .height = HEIGHT,
+       .bpp = BPP,
+       .fps = FPS,
+       .fbtftops = {
+               .write_vmem = write_vmem,
+               .init_display = init_display,
+               .set_addr_win = set_addr_win,
+               .set_var = set_var,
+               .blank = blank,
+       },
+};
+
+FBTFT_REGISTER_DRIVER(DRVNAME, "ultrachip,uc1611", &display);
+
+MODULE_ALIAS("spi:" DRVNAME);
+MODULE_ALIAS("platform:" DRVNAME);
+MODULE_ALIAS("spi:uc1611");
+MODULE_ALIAS("platform:uc1611");
+
+MODULE_DESCRIPTION("FB driver for the UC1611 LCD controller");
+MODULE_AUTHOR("Henri Chain");
+MODULE_LICENSE("GPL");
index 9cc8141..f04128f 100644 (file)
@@ -1076,6 +1076,11 @@ static int fbtft_init_display_dt(struct fbtft_par *par)
        p = of_prop_next_u32(prop, NULL, &val);
        if (!p)
                return -EINVAL;
+
+       par->fbtftops.reset(par);
+       if (par->gpio.cs != -1)
+               gpio_set_value(par->gpio.cs, 0);  /* Activate chip */
+
        while (p) {
                if (val & FBTFT_OF_INIT_CMD) {
                        val &= 0xFFFF;
index 211d504..fa916e8 100644 (file)
@@ -397,6 +397,37 @@ static struct fbtft_device_display displays[] = {
                        }
                }
        }, {
+               .name = "ew24ha0",
+               .spi = &(struct spi_board_info) {
+                       .modalias = "fb_uc1611",
+                       .max_speed_hz = 32000000,
+                       .mode = SPI_MODE_3,
+                       .platform_data = &(struct fbtft_platform_data) {
+                               .display = {
+                                       .buswidth = 8,
+                               },
+                               .gpios = (const struct fbtft_gpio []) {
+                                       { "dc", 24 },
+                                       {},
+                               },
+                       }
+               }
+       }, {
+               .name = "ew24ha0_9bit",
+               .spi = &(struct spi_board_info) {
+                       .modalias = "fb_uc1611",
+                       .max_speed_hz = 32000000,
+                       .mode = SPI_MODE_3,
+                       .platform_data = &(struct fbtft_platform_data) {
+                               .display = {
+                                       .buswidth = 9,
+                               },
+                               .gpios = (const struct fbtft_gpio []) {
+                                       {},
+                               },
+                       }
+               }
+       }, {
                .name = "flexfb",
                .spi = &(struct spi_board_info) {
                        .modalias = "flexfb",
index 2c4ce07..ce6e3ae 100644 (file)
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
 #include <linux/module.h>
@@ -30,7 +26,6 @@
 
 #define DRVNAME            "flexfb"
 
-
 static char *chip;
 module_param(chip, charp, 0);
 MODULE_PARM_DESC(chip, "LCD controller");
@@ -68,7 +63,6 @@ static bool latched;
 module_param(latched, bool, 0);
 MODULE_PARM_DESC(latched, "Use with latched 16-bit databus");
 
-
 static int *initp;
 static int initp_num;
 
@@ -132,14 +126,12 @@ static int ssd1351_init[] = { -1, 0xfd, 0x12, -1, 0xfd, 0xb1, -1, 0xae, -1, 0xb3
                              -1, 0xab, 0x01, -1, 0xb1, 0x32, -1, 0xb4, 0xa0, 0xb5, 0x55, -1, 0xbb, 0x17, -1, 0xbe, 0x05,
                              -1, 0xc1, 0xc8, 0x80, 0xc8, -1, 0xc7, 0x0f, -1, 0xb6, 0x01, -1, 0xa6, -1, 0xaf, -3 };
 
-
 /* ili9320, ili9325 */
 static void flexfb_set_addr_win_1(struct fbtft_par *par,
                                  int xs, int ys, int xe, int ye)
 {
-       fbtft_par_dbg(DEBUG_SET_ADDR_WIN, par,
-                    "%s(xs=%d, ys=%d, xe=%d, ye=%d)\n",
-                    __func__, xs, ys, xe, ye);
+       fbtft_par_dbg(DEBUG_SET_ADDR_WIN, par, "%s(xs=%d, ys=%d, xe=%d, ye=%d)\n",
+                     __func__, xs, ys, xe, ye);
        switch (par->info->var.rotate) {
        /* R20h = Horizontal GRAM Start Address */
        /* R21h = Vertical GRAM Start Address */
@@ -242,7 +234,7 @@ static int flexfb_verify_gpios_db(struct fbtft_par *par)
                return -EINVAL;
        }
        if (latched)
-               num_db = buswidth/2;
+               num_db = buswidth / 2;
        for (i = 0; i < num_db; i++) {
                if (par->gpio.db[i] < 0) {
                        dev_err(par->info->device,
@@ -288,7 +280,6 @@ static int flexfb_probe_common(struct spi_device *sdev,
                                initp_num = ARRAY_SIZE(st7735r_init);
                        }
 
-
                } else if (!strcmp(chip, "hx8340bn")) {
                        if (!width)
                                width = 176;
@@ -300,7 +291,6 @@ static int flexfb_probe_common(struct spi_device *sdev,
                                initp_num = ARRAY_SIZE(hx8340bn_init);
                        }
 
-
                } else if (!strcmp(chip, "ili9225")) {
                        if (!width)
                                width = 176;
@@ -313,8 +303,6 @@ static int flexfb_probe_common(struct spi_device *sdev,
                                initp_num = ARRAY_SIZE(ili9225_init);
                        }
 
-
-
                } else if (!strcmp(chip, "ili9320")) {
                        if (!width)
                                width = 240;
@@ -327,7 +315,6 @@ static int flexfb_probe_common(struct spi_device *sdev,
                                initp_num = ARRAY_SIZE(ili9320_init);
                        }
 
-
                } else if (!strcmp(chip, "ili9325")) {
                        if (!width)
                                width = 240;
@@ -352,7 +339,6 @@ static int flexfb_probe_common(struct spi_device *sdev,
                                initp_num = ARRAY_SIZE(ili9341_init);
                        }
 
-
                } else if (!strcmp(chip, "ssd1289")) {
                        if (!width)
                                width = 240;
@@ -365,8 +351,6 @@ static int flexfb_probe_common(struct spi_device *sdev,
                                initp_num = ARRAY_SIZE(ssd1289_init);
                        }
 
-
-
                } else if (!strcmp(chip, "ssd1351")) {
                        if (!width)
                                width = 128;
@@ -527,8 +511,8 @@ static int flexfb_remove_common(struct device *dev, struct fb_info *info)
                return -EINVAL;
        par = info->par;
        if (par)
-               fbtft_par_dbg(DEBUG_DRIVER_INIT_FUNCTIONS, par,
-                       "%s()\n", __func__);
+               fbtft_par_dbg(DEBUG_DRIVER_INIT_FUNCTIONS, par, "%s()\n",
+                             __func__);
        fbtft_unregister_framebuffer(info);
        fbtft_framebuffer_release(info);
 
index 409266b..f241a3a 100644 (file)
@@ -260,7 +260,8 @@ void ft1000_destroy_dev(struct net_device *netdev)
                /* Make sure we free any memory reserve for slow Queue */
                for (i = 0; i < MAX_NUM_APP; i++) {
                        while (list_empty(&dev->app_info[i].app_sqlist) == 0) {
-                               pdpram_blk = list_entry(dev->app_info[i].app_sqlist.next, struct dpram_blk, list);
+                               pdpram_blk = list_entry(dev->app_info[i].app_sqlist.next,
+                                                       struct dpram_blk, list);
                                list_del(&pdpram_blk->list);
                                ft1000_free_buffer(pdpram_blk, &freercvpool);
 
@@ -415,12 +416,19 @@ static long ft1000_ioctl(struct file *file, unsigned int command,
        struct timeval tv;
        struct IOCTL_GET_VER get_ver_data;
        struct IOCTL_GET_DSP_STAT get_stat_data;
-       u8 ConnectionMsg[] = {0x00, 0x44, 0x10, 0x20, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x93, 0x64,
-                             0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x0a,
-                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-                             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-                             0x00, 0x00, 0x02, 0x37, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x7f, 0x00,
-                             0x00, 0x01, 0x00, 0x00};
+       u8 ConnectionMsg[] = {
+               0x00, 0x44, 0x10, 0x20, 0x80, 0x00, 0x00, 0x00,
+               0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x93, 0x64,
+               0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
+               0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x0a,
+               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12,
+               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+               0x00, 0x00, 0x02, 0x37, 0x00, 0x00, 0x00, 0x08,
+               0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x7f, 0x00,
+               0x00, 0x01, 0x00, 0x00
+       };
 
        unsigned short ledStat = 0;
        unsigned short conStat = 0;
@@ -495,10 +503,12 @@ static long ft1000_ioctl(struct file *file, unsigned int command,
                memcpy(get_stat_data.eui64, info->eui64, EUISZ);
 
                if (info->ProgConStat != 0xFF) {
-                       ft1000_read_dpram16(ft1000dev, FT1000_MAG_DSP_LED, (u8 *)&ledStat, FT1000_MAG_DSP_LED_INDX);
+                       ft1000_read_dpram16(ft1000dev, FT1000_MAG_DSP_LED,
+                                           (u8 *)&ledStat, FT1000_MAG_DSP_LED_INDX);
                        get_stat_data.LedStat = ntohs(ledStat);
                        pr_debug("LedStat = 0x%x\n", get_stat_data.LedStat);
-                       ft1000_read_dpram16(ft1000dev, FT1000_MAG_DSP_CON_STATE, (u8 *)&conStat, FT1000_MAG_DSP_CON_STATE_INDX);
+                       ft1000_read_dpram16(ft1000dev, FT1000_MAG_DSP_CON_STATE,
+                                           (u8 *)&conStat, FT1000_MAG_DSP_CON_STATE_INDX);
                        get_stat_data.ConStat = ntohs(conStat);
                        pr_debug("ConStat = 0x%x\n", get_stat_data.ConStat);
                } else {
@@ -689,7 +699,8 @@ static long ft1000_ioctl(struct file *file, unsigned int command,
                if (list_empty(&ft1000dev->app_info[i].app_sqlist) == 0) {
                        /* pr_debug("Message detected in slow queue\n"); */
                        spin_lock_irqsave(&free_buff_lock, flags);
-                       pdpram_blk = list_entry(ft1000dev->app_info[i].app_sqlist.next, struct dpram_blk, list);
+                       pdpram_blk = list_entry(ft1000dev->app_info[i].app_sqlist.next,
+                                               struct dpram_blk, list);
                        list_del(&pdpram_blk->list);
                        ft1000dev->app_info[i].NumOfMsg--;
                        /* pr_debug("NumOfMsg for app %d = %d\n", i, ft1000dev->app_info[i].NumOfMsg); */
index 5def347..297b7ae 100644 (file)
@@ -95,7 +95,6 @@ struct dsp_file_hdr {
        long              nDspImages;          /* Number of DSP images in file. */
 };
 
-#pragma pack(1)
 struct dsp_image_info {
        long              coff_date;           /* Date/time when DSP Coff image was built. */
        long              begin_offset;        /* Offset in file where image begins. */
@@ -105,7 +104,7 @@ struct dsp_image_info {
        long              version;             /* Embedded version # of DSP code. */
        unsigned short    checksum;            /* DSP File checksum */
        unsigned short    pad1;
-};
+} __packed;
 
 
 /* checks if the doorbell register is cleared */
@@ -180,7 +179,8 @@ static u16 get_handshake(struct ft1000_usb *ft1000dev, u16 expected_value)
                }
 
                status = ft1000_read_dpram16(ft1000dev,
-                                            DWNLD_MAG1_HANDSHAKE_LOC, (u8 *)&handshake, 1);
+                                            DWNLD_MAG1_HANDSHAKE_LOC,
+                                            (u8 *)&handshake, 1);
                handshake = ntohs(handshake);
 
                if (status)
@@ -281,12 +281,14 @@ static u16 get_request_type(struct ft1000_usb *ft1000dev)
 
        if (ft1000dev->bootmode == 1) {
                status = fix_ft1000_read_dpram32(ft1000dev,
-                                                DWNLD_MAG1_TYPE_LOC, (u8 *)&tempx);
+                                                DWNLD_MAG1_TYPE_LOC,
+                                                (u8 *)&tempx);
                tempx = ntohl(tempx);
        } else {
                tempx = 0;
                status = ft1000_read_dpram16(ft1000dev,
-                                            DWNLD_MAG1_TYPE_LOC, (u8 *)&tempword, 1);
+                                            DWNLD_MAG1_TYPE_LOC,
+                                            (u8 *)&tempword, 1);
                tempx |= (tempword << 16);
                tempx = ntohl(tempx);
        }
@@ -304,7 +306,8 @@ static u16 get_request_type_usb(struct ft1000_usb *ft1000dev)
 
        if (ft1000dev->bootmode == 1) {
                status = fix_ft1000_read_dpram32(ft1000dev,
-                                                DWNLD_MAG1_TYPE_LOC, (u8 *)&tempx);
+                                                DWNLD_MAG1_TYPE_LOC,
+                                                (u8 *)&tempx);
                tempx = ntohl(tempx);
        } else {
                if (ft1000dev->usbboot == 2) {
@@ -332,14 +335,17 @@ static long get_request_value(struct ft1000_usb *ft1000dev)
 
        if (ft1000dev->bootmode == 1) {
                status = fix_ft1000_read_dpram32(ft1000dev,
-                                                DWNLD_MAG1_SIZE_LOC, (u8 *)&value);
+                                                DWNLD_MAG1_SIZE_LOC,
+                                                (u8 *)&value);
                value = ntohl(value);
        } else  {
                status = ft1000_read_dpram16(ft1000dev,
-                                            DWNLD_MAG1_SIZE_LOC, (u8 *)&tempword, 0);
+                                            DWNLD_MAG1_SIZE_LOC,
+                                            (u8 *)&tempword, 0);
                value = tempword;
                status = ft1000_read_dpram16(ft1000dev,
-                                            DWNLD_MAG1_SIZE_LOC, (u8 *)&tempword, 1);
+                                            DWNLD_MAG1_SIZE_LOC,
+                                            (u8 *)&tempword, 1);
                value |= (tempword << 16);
                value = ntohl(value);
        }
index e6b5976..9620970 100644 (file)
@@ -842,7 +842,6 @@ static int ft1000_copy_up_pkt(struct urb *urb)
        skb = dev_alloc_skb(len + 12 + 2);
 
        if (skb == NULL) {
-               pr_debug("No Network buffers available\n");
                info->stats.rx_errors++;
                ft1000_submit_rx_urb(info);
                return -1;
index 75ddd4f..78fe0b5 100644 (file)
@@ -124,7 +124,6 @@ static struct i2c_driver adt7316_driver = {
        .driver = {
                .name = "adt7316",
                .pm = ADT7316_PM_OPS,
-               .owner  = THIS_MODULE,
        },
        .probe = adt7316_i2c_probe,
        .id_table = adt7316_i2c_id,
index c54d5b5..6d38854 100644 (file)
@@ -214,6 +214,7 @@ static struct device iio_evgen_dev = {
        .groups = iio_evgen_groups,
        .release = &iio_evgen_release,
 };
+
 static __init int iio_dummy_evgen_init(void)
 {
        int ret = iio_dummy_evgen_create();
index 1629a8a..381f90f 100644 (file)
@@ -611,7 +611,6 @@ static int iio_dummy_probe(int index)
         */
        iio_dummy_devs[index] = indio_dev;
 
-
        /*
         * Set the device name.
         *
@@ -675,7 +674,6 @@ static void iio_dummy_remove(int index)
         */
        struct iio_dev *indio_dev = iio_dummy_devs[index];
 
-
        /* Unregister the device */
        iio_device_unregister(indio_dev);
 
index e877a99..8d00224 100644 (file)
@@ -119,6 +119,7 @@ static inline int iio_simple_dummy_configure_buffer(struct iio_dev *indio_dev)
 {
        return 0;
 };
+
 static inline
 void iio_simple_dummy_unconfigure_buffer(struct iio_dev *indio_dev)
 {};
index a651b89..00ed774 100644 (file)
@@ -32,6 +32,7 @@ static const s16 fakedata[] = {
        [diffvoltage3m4] = -2,
        [accelx] = 344,
 };
+
 /**
  * iio_simple_dummy_trigger_h() - the trigger handler function
  * @irq: the interrupt number
@@ -178,7 +179,6 @@ error_free_buffer:
        iio_kfifo_free(indio_dev->buffer);
 error_ret:
        return ret;
-
 }
 
 /**
index e646c5d..019ba52 100644 (file)
@@ -838,7 +838,6 @@ static struct i2c_driver isl29018_driver = {
                        .name = "isl29018",
                        .acpi_match_table = ACPI_PTR(isl29018_acpi_match),
                        .pm = ISL29018_PM_OPS,
-                       .owner = THIS_MODULE,
                        .of_match_table = isl29018_of_match,
                    },
        .probe   = isl29018_probe,
index e5b2fdc..cd6f272 100644 (file)
@@ -547,7 +547,6 @@ static struct i2c_driver isl29028_driver = {
        .class  = I2C_CLASS_HWMON,
        .driver  = {
                .name = "isl29028",
-               .owner = THIS_MODULE,
                .of_match_table = isl29028_of_match,
        },
        .probe   = isl29028_probe,
index 8251ac9..a3aa644 100644 (file)
@@ -50,7 +50,6 @@ extern unsigned int libcfs_stack;
 extern unsigned int libcfs_debug;
 extern unsigned int libcfs_printk;
 extern unsigned int libcfs_console_ratelimit;
-extern unsigned int libcfs_watchdog_ratelimit;
 extern unsigned int libcfs_console_max_delay;
 extern unsigned int libcfs_console_min_delay;
 extern unsigned int libcfs_console_backoff;
index eea55d9..aa69c6a 100644 (file)
@@ -79,14 +79,16 @@ static inline int cfs_fail_check_set(__u32 id, __u32 value,
 {
        int ret = 0;
 
-       if (unlikely(CFS_FAIL_PRECHECK(id) &&
-                    (ret = __cfs_fail_check_set(id, value, set)))) {
-               if (quiet) {
-                       CDEBUG(D_INFO, "*** cfs_fail_loc=%x, val=%u***\n",
-                              id, value);
-               } else {
-                       LCONSOLE_INFO("*** cfs_fail_loc=%x, val=%u***\n",
-                                     id, value);
+       if (unlikely(CFS_FAIL_PRECHECK(id))) {
+               ret = __cfs_fail_check_set(id, value, set);
+               if (ret) {
+                       if (quiet) {
+                               CDEBUG(D_INFO, "*** cfs_fail_loc=%x, val=%u***\n",
+                                      id, value);
+                       } else {
+                               LCONSOLE_INFO("*** cfs_fail_loc=%x, val=%u***\n",
+                                             id, value);
+                       }
                }
        }
 
index ed37d26..9544860 100644 (file)
@@ -87,24 +87,6 @@ do {                                                             \
        lbug_with_loc(&msgdata);                                        \
 } while (0)
 
-extern atomic_t libcfs_kmemory;
-/*
- * Memory
- */
-
-# define libcfs_kmem_inc(ptr, size)            \
-do {                                           \
-       atomic_add(size, &libcfs_kmemory);      \
-} while (0)
-
-# define libcfs_kmem_dec(ptr, size)            \
-do {                                           \
-       atomic_sub(size, &libcfs_kmemory);      \
-} while (0)
-
-# define libcfs_kmem_read()                    \
-       atomic_read(&libcfs_kmemory)
-
 #ifndef LIBCFS_VMALLOC_SIZE
 #define LIBCFS_VMALLOC_SIZE    (2 << PAGE_CACHE_SHIFT) /* 2 pages */
 #endif
@@ -121,14 +103,9 @@ do {                                                                           \
        if (unlikely((ptr) == NULL)) {                                      \
                CERROR("LNET: out of memory at %s:%d (tried to alloc '"     \
                       #ptr "' = %d)\n", __FILE__, __LINE__, (int)(size));  \
-               CERROR("LNET: %d total bytes allocated by lnet\n",          \
-                      libcfs_kmem_read());                                 \
        } else {                                                            \
                memset((ptr), 0, (size));                                   \
-               libcfs_kmem_inc((ptr), (size));                             \
-               CDEBUG(D_MALLOC, "alloc '" #ptr "': %d at %p (tot %d).\n",  \
-                      (int)(size), (ptr), libcfs_kmem_read());             \
-       }                                                                  \
+       }                                                                   \
 } while (0)
 
 /**
@@ -180,9 +157,6 @@ do {                                                                    \
                       "%s:%d\n", s, __FILE__, __LINE__);              \
                break;                                            \
        }                                                              \
-       libcfs_kmem_dec((ptr), s);                                    \
-       CDEBUG(D_MALLOC, "kfreed '" #ptr "': %d at %p (tot %d).\n",     \
-              s, (ptr), libcfs_kmem_read());                           \
        if (unlikely(s > LIBCFS_VMALLOC_SIZE))                    \
                vfree(ptr);                                 \
        else                                                        \
index 4eb24a1..f429d25 100644 (file)
@@ -2667,9 +2667,6 @@ static void kiblnd_base_shutdown(void)
 
        LASSERT(list_empty(&kiblnd_data.kib_devs));
 
-       CDEBUG(D_MALLOC, "before LND base cleanup: kmem %d\n",
-              atomic_read(&libcfs_kmemory));
-
        switch (kiblnd_data.kib_init) {
        default:
                LBUG();
@@ -2720,9 +2717,6 @@ static void kiblnd_base_shutdown(void)
        if (kiblnd_data.kib_scheds != NULL)
                cfs_percpt_free(kiblnd_data.kib_scheds);
 
-       CDEBUG(D_MALLOC, "after LND base cleanup: kmem %d\n",
-              atomic_read(&libcfs_kmemory));
-
        kiblnd_data.kib_init = IBLND_INIT_NOTHING;
        module_put(THIS_MODULE);
 }
@@ -2739,9 +2733,6 @@ void kiblnd_shutdown(lnet_ni_t *ni)
        if (net == NULL)
                goto out;
 
-       CDEBUG(D_MALLOC, "before LND net cleanup: kmem %d\n",
-              atomic_read(&libcfs_kmemory));
-
        write_lock_irqsave(g_lock, flags);
        net->ibn_shutdown = 1;
        write_unlock_irqrestore(g_lock, flags);
@@ -2786,9 +2777,6 @@ void kiblnd_shutdown(lnet_ni_t *ni)
                break;
        }
 
-       CDEBUG(D_MALLOC, "after LND net cleanup: kmem %d\n",
-              atomic_read(&libcfs_kmemory));
-
        net->ibn_init = IBLND_INIT_NOTHING;
        ni->ni_data = NULL;
 
index 4128a92..d8bfcad 100644 (file)
@@ -2252,8 +2252,6 @@ ksocknal_base_shutdown(void)
        int i;
        int j;
 
-       CDEBUG(D_MALLOC, "before NAL cleanup: kmem %d\n",
-              atomic_read(&libcfs_kmemory));
        LASSERT(ksocknal_data.ksnd_nnets == 0);
 
        switch (ksocknal_data.ksnd_init) {
@@ -2331,9 +2329,6 @@ ksocknal_base_shutdown(void)
                break;
        }
 
-       CDEBUG(D_MALLOC, "after NAL cleanup: kmem %d\n",
-              atomic_read(&libcfs_kmemory));
-
        module_put(THIS_MODULE);
 }
 
index 8a9d4a0..cb91e68 100644 (file)
@@ -46,6 +46,7 @@
 #include <linux/sysctl.h>
 #include <linux/uio.h>
 #include <linux/unistd.h>
+#include <asm/irq.h>
 #include <net/sock.h>
 #include <net/tcp.h>
 
index fe2a83a..0d5aac6 100644 (file)
@@ -526,8 +526,7 @@ ksocknal_process_transmit (ksock_conn_t *conn, ksock_tx_t *tx)
 
                counter++;   /* exponential backoff warnings */
                if ((counter & (-counter)) == counter)
-                       CWARN("%u ENOMEM tx %p (%u allocated)\n",
-                             counter, conn, atomic_read(&libcfs_kmemory));
+                       CWARN("%u ENOMEM tx %p\n", counter, conn);
 
                /* Queue on ksnd_enomem_conns for retry after a timeout */
                spin_lock_bh(&ksocknal_data.ksnd_reaper_lock);
index ee902dc..40f418b 100644 (file)
 
 static struct ctl_table_header *lnet_table_header;
 
-#define CTL_LNET        (0x100)
-enum {
-       PSDEV_LNET_STATS = 100,
-       PSDEV_LNET_ROUTES,
-       PSDEV_LNET_ROUTERS,
-       PSDEV_LNET_PEERS,
-       PSDEV_LNET_BUFFERS,
-       PSDEV_LNET_NIS,
-       PSDEV_LNET_PTL_ROTOR,
-};
-
 #define LNET_LOFFT_BITS                (sizeof(loff_t) * 8)
 /*
  * NB: max allowed LNET_CPT_BITS is 8 on 64-bit system and 2 on 32-bit system
index 1362783..a16d577 100644 (file)
@@ -498,11 +498,11 @@ int client_fid_init(struct obd_device *obd,
        int rc;
 
        cli->cl_seq = kzalloc(sizeof(*cli->cl_seq), GFP_NOFS);
-       if (cli->cl_seq == NULL)
+       if (!cli->cl_seq)
                return -ENOMEM;
 
        prefix = kzalloc(MAX_OBD_NAME + 5, GFP_NOFS);
-       if (prefix == NULL) {
+       if (!prefix) {
                rc = -ENOMEM;
                goto out_free_seq;
        }
index ec2fc43..1b1066b 100644 (file)
@@ -70,7 +70,7 @@ struct fld_cache *fld_cache_init(const char *name,
        LASSERT(cache_threshold < cache_size);
 
        cache = kzalloc(sizeof(*cache), GFP_NOFS);
-       if (cache == NULL)
+       if (!cache)
                return ERR_PTR(-ENOMEM);
 
        INIT_LIST_HEAD(&cache->fci_entries_head);
index c3b47f2..1e450bf 100644 (file)
@@ -222,7 +222,7 @@ int fld_client_add_target(struct lu_client_fld *fld,
                        fld->lcf_name, name, tar->ft_idx);
 
        target = kzalloc(sizeof(*target), GFP_NOFS);
-       if (target == NULL)
+       if (!target)
                return -ENOMEM;
 
        spin_lock(&fld->lcf_lock);
index 36ed781..e1f8b15 100644 (file)
@@ -1869,8 +1869,7 @@ extern int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c);
 /* obd_mount.c */
 
 /* sysctl.c */
-extern void obd_sysctl_init (void);
-extern void obd_sysctl_clean (void);
+extern int obd_sysctl_init(void);
 
 /* uuid.c  */
 typedef __u8 class_uuid_t[16];
index 73e2d48..88e1671 100644 (file)
@@ -56,9 +56,7 @@ extern unsigned int obd_dump_on_eviction;
 /* obd_timeout should only be used for recovery, not for
    networking / disk / timings affected by load (use Adaptive Timeouts) */
 extern unsigned int obd_timeout;         /* seconds */
-extern unsigned int ldlm_timeout;       /* seconds */
 extern unsigned int obd_timeout_set;
-extern unsigned int ldlm_timeout_set;
 extern unsigned int at_min;
 extern unsigned int at_max;
 extern unsigned int at_history;
@@ -105,8 +103,6 @@ int obd_alloc_fail(const void *ptr, const char *name, const char *type,
 
 /* Timeout definitions */
 #define OBD_TIMEOUT_DEFAULT         100
-#define LDLM_TIMEOUT_DEFAULT       20
-#define MDS_LDLM_TIMEOUT_DEFAULT       6
 /* Time to wait for all clients to reconnect during recovery (hard limit) */
 #define OBD_RECOVERY_TIME_HARD   (obd_timeout * 9)
 /* Time to wait for all clients to reconnect during recovery (soft limit) */
@@ -505,8 +501,6 @@ int obd_alloc_fail(const void *ptr, const char *name, const char *type,
 #define OBD_FAIL_ONCE                     CFS_FAIL_ONCE
 #define OBD_FAILED                           CFS_FAILED
 
-extern atomic_t libcfs_kmemory;
-
 extern void obd_update_maxusage(void);
 
 #define obd_memory_add(size)                                             \
@@ -622,8 +616,8 @@ do {                                                                              \
        if (unlikely((ptr) == NULL)) {                                  \
                CERROR("vmalloc of '" #ptr "' (%d bytes) failed\n",        \
                       (int)(size));                                      \
-               CERROR("%llu total bytes allocated by Lustre, %d by LNET\n", \
-                      obd_memory_sum(), atomic_read(&libcfs_kmemory));   \
+               CERROR("%llu total bytes allocated by Lustre\n",              \
+                      obd_memory_sum());                                     \
        } else {                                                              \
                OBD_ALLOC_POST(ptr, size, "vmalloced");                \
        }                                                                    \
@@ -769,12 +763,10 @@ do {                                                                            \
                       "failed\n", (int)1,                                  \
                       (__u64)(1 << PAGE_CACHE_SHIFT));                  \
                CERROR("%llu total bytes and %llu total pages "    \
-                      "(%llu bytes) allocated by Lustre, "             \
-                      "%d total bytes by LNET\n",                          \
+                      "(%llu bytes) allocated by Lustre\n",                  \
                       obd_memory_sum(),                                      \
                       obd_pages_sum() << PAGE_CACHE_SHIFT,                  \
-                      obd_pages_sum(),                                \
-                      atomic_read(&libcfs_kmemory));                \
+                      obd_pages_sum());                                       \
        } else {                                                              \
                obd_pages_add(0);                                            \
                CDEBUG(D_MALLOC, "alloc_pages '" #ptr "': %d page(s) / "      \
index e0c1cca..9053f81 100644 (file)
@@ -203,7 +203,7 @@ struct lu_device *ccc_device_alloc(const struct lu_env *env,
        int rc;
 
        vdv = kzalloc(sizeof(*vdv), GFP_NOFS);
-       if (vdv == NULL)
+       if (!vdv)
                return ERR_PTR(-ENOMEM);
 
        lud = &vdv->cdv_cl.cd_lu_dev;
index bb2246d..cd340fc 100644 (file)
@@ -1528,7 +1528,7 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns,
        if (lvb_len) {
                lock->l_lvb_len = lvb_len;
                lock->l_lvb_data = kzalloc(lvb_len, GFP_NOFS);
-               if (lock->l_lvb_data == NULL)
+               if (!lock->l_lvb_data)
                        goto out;
        }
 
@@ -1813,7 +1813,7 @@ int ldlm_run_ast_work(struct ldlm_namespace *ns, struct list_head *rpc_list,
                return 0;
 
        arg = kzalloc(sizeof(*arg), GFP_NOFS);
-       if (arg == NULL)
+       if (!arg)
                return -ENOMEM;
 
        atomic_set(&arg->restart, 0);
index b7b6ca1..ac79db9 100644 (file)
@@ -76,15 +76,6 @@ inline unsigned long round_timeout(unsigned long timeout)
        return cfs_time_seconds((int)cfs_duration_sec(cfs_time_sub(timeout, 0)) + 1);
 }
 
-/* timeout for initial callback (AST) reply (bz10399) */
-static inline unsigned int ldlm_get_rq_timeout(void)
-{
-       /* Non-AT value */
-       unsigned int timeout = min(ldlm_timeout, obd_timeout / 3);
-
-       return timeout < 1 ? 1 : timeout;
-}
-
 #define ELT_STOPPED   0
 #define ELT_READY     1
 #define ELT_TERMINATE 2
@@ -225,7 +216,7 @@ static void ldlm_handle_cp_callback(struct ptlrpc_request *req,
                        void *lvb_data;
 
                        lvb_data = kzalloc(lvb_len, GFP_NOFS);
-                       if (lvb_data == NULL) {
+                       if (!lvb_data) {
                                LDLM_ERROR(lock, "No memory: %d.\n", lvb_len);
                                rc = -ENOMEM;
                                goto out;
@@ -453,7 +444,7 @@ static int ldlm_bl_to_thread(struct ldlm_namespace *ns,
                struct ldlm_bl_work_item *blwi;
 
                blwi = kzalloc(sizeof(*blwi), GFP_NOFS);
-               if (blwi == NULL)
+               if (!blwi)
                        return -ENOMEM;
                init_blwi(blwi, ns, ld, cancels, count, lock, cancel_flags);
 
@@ -1053,7 +1044,7 @@ static int ldlm_setup(void)
                return -EALREADY;
 
        ldlm_state = kzalloc(sizeof(*ldlm_state), GFP_NOFS);
-       if (ldlm_state == NULL)
+       if (!ldlm_state)
                return -ENOMEM;
 
        ldlm_kobj = kobject_create_and_add("ldlm", lustre_kobj);
@@ -1123,7 +1114,7 @@ static int ldlm_setup(void)
 
 
        blp = kzalloc(sizeof(*blp), GFP_NOFS);
-       if (blp == NULL) {
+       if (!blp) {
                rc = -ENOMEM;
                goto out;
        }
index 1605b9c..c234acb 100644 (file)
@@ -1422,7 +1422,7 @@ static int ldlm_pools_thread_start(void)
                return -EALREADY;
 
        ldlm_pools_thread = kzalloc(sizeof(*ldlm_pools_thread), GFP_NOFS);
-       if (ldlm_pools_thread == NULL)
+       if (!ldlm_pools_thread)
                return -ENOMEM;
 
        init_completion(&ldlm_pools_comp);
@@ -1486,8 +1486,10 @@ EXPORT_SYMBOL(ldlm_pools_init);
 
 void ldlm_pools_fini(void)
 {
-       unregister_shrinker(&ldlm_pools_srv_shrinker);
-       unregister_shrinker(&ldlm_pools_cli_shrinker);
+       if (ldlm_pools_thread) {
+               unregister_shrinker(&ldlm_pools_srv_shrinker);
+               unregister_shrinker(&ldlm_pools_cli_shrinker);
+       }
        ldlm_pools_thread_stop();
 }
 EXPORT_SYMBOL(ldlm_pools_fini);
index cdb6366..4bb3173 100644 (file)
@@ -939,6 +939,7 @@ void ldlm_namespace_free_post(struct ldlm_namespace *ns)
        ldlm_pool_fini(&ns->ns_pool);
 
        ldlm_namespace_debugfs_unregister(ns);
+       ldlm_namespace_sysfs_unregister(ns);
        cfs_hash_putref(ns->ns_rs_hash);
        /* Namespace \a ns should be not on list at this time, otherwise
         * this will cause issues related to using freed \a ns in poold
index 021c92f..e93f556 100644 (file)
@@ -57,8 +57,42 @@ module_param(libcfs_debug, int, 0644);
 MODULE_PARM_DESC(libcfs_debug, "Lustre kernel debug mask");
 EXPORT_SYMBOL(libcfs_debug);
 
+static int libcfs_param_debug_mb_set(const char *val,
+                                    const struct kernel_param *kp)
+{
+       int rc;
+       unsigned num;
+
+       rc = kstrtouint(val, 0, &num);
+       if (rc < 0)
+               return rc;
+
+       if (!*((unsigned int *)kp->arg)) {
+               *((unsigned int *)kp->arg) = num;
+               return 0;
+       }
+
+       rc = cfs_trace_set_debug_mb(num);
+
+       if (!rc)
+               *((unsigned int *)kp->arg) = cfs_trace_get_debug_mb();
+
+       return rc;
+}
+
+/* While debug_mb setting look like unsigned int, in fact
+ * it needs quite a bunch of extra processing, so we define special
+ * debugmb parameter type with corresponding methods to handle this case */
+static struct kernel_param_ops param_ops_debugmb = {
+       .set = libcfs_param_debug_mb_set,
+       .get = param_get_uint,
+};
+
+#define param_check_debugmb(name, p) \
+               __param_check(name, p, unsigned int)
+
 static unsigned int libcfs_debug_mb;
-module_param(libcfs_debug_mb, uint, 0644);
+module_param(libcfs_debug_mb, debugmb, 0644);
 MODULE_PARM_DESC(libcfs_debug_mb, "Total debug buffer size.");
 EXPORT_SYMBOL(libcfs_debug_mb);
 
@@ -72,18 +106,106 @@ module_param(libcfs_console_ratelimit, uint, 0644);
 MODULE_PARM_DESC(libcfs_console_ratelimit, "Lustre kernel debug console ratelimit (0 to disable)");
 EXPORT_SYMBOL(libcfs_console_ratelimit);
 
+static int param_set_delay_minmax(const char *val,
+                                 const struct kernel_param *kp,
+                                 long min, long max)
+{
+       long d;
+       int sec;
+       int rc;
+
+       rc = kstrtoint(val, 0, &sec);
+       if (rc)
+               return -EINVAL;
+
+       d = cfs_time_seconds(sec) / 100;
+       if (d < min || d > max)
+               return -EINVAL;
+
+       *((unsigned int *)kp->arg) = d;
+
+       return 0;
+}
+
+static int param_get_delay(char *buffer, const struct kernel_param *kp)
+{
+       unsigned int d = *(unsigned int *)kp->arg;
+
+       return sprintf(buffer, "%u", (unsigned int)cfs_duration_sec(d * 100));
+}
+
 unsigned int libcfs_console_max_delay;
-module_param(libcfs_console_max_delay, uint, 0644);
-MODULE_PARM_DESC(libcfs_console_max_delay, "Lustre kernel debug console max delay (jiffies)");
 EXPORT_SYMBOL(libcfs_console_max_delay);
-
 unsigned int libcfs_console_min_delay;
-module_param(libcfs_console_min_delay, uint, 0644);
-MODULE_PARM_DESC(libcfs_console_min_delay, "Lustre kernel debug console min delay (jiffies)");
 EXPORT_SYMBOL(libcfs_console_min_delay);
 
+static int param_set_console_max_delay(const char *val,
+                                      const struct kernel_param *kp)
+{
+       return param_set_delay_minmax(val, kp,
+                                     libcfs_console_min_delay, INT_MAX);
+}
+
+static struct kernel_param_ops param_ops_console_max_delay = {
+       .set = param_set_console_max_delay,
+       .get = param_get_delay,
+};
+
+#define param_check_console_max_delay(name, p) \
+               __param_check(name, p, unsigned int)
+
+module_param(libcfs_console_max_delay, console_max_delay, 0644);
+MODULE_PARM_DESC(libcfs_console_max_delay, "Lustre kernel debug console max delay (jiffies)");
+
+static int param_set_console_min_delay(const char *val,
+                                      const struct kernel_param *kp)
+{
+       return param_set_delay_minmax(val, kp,
+                                     1, libcfs_console_max_delay);
+}
+
+static struct kernel_param_ops param_ops_console_min_delay = {
+       .set = param_set_console_min_delay,
+       .get = param_get_delay,
+};
+
+#define param_check_console_min_delay(name, p) \
+               __param_check(name, p, unsigned int)
+
+module_param(libcfs_console_min_delay, console_min_delay, 0644);
+MODULE_PARM_DESC(libcfs_console_min_delay, "Lustre kernel debug console min delay (jiffies)");
+
+static int param_set_uint_minmax(const char *val,
+                                const struct kernel_param *kp,
+                                unsigned int min, unsigned int max)
+{
+       unsigned int num;
+       int ret;
+
+       if (!val)
+               return -EINVAL;
+       ret = kstrtouint(val, 0, &num);
+       if (ret < 0 || num < min || num > max)
+               return -EINVAL;
+       *((unsigned int *)kp->arg) = num;
+       return 0;
+}
+
+static int param_set_uintpos(const char *val, const struct kernel_param *kp)
+{
+       return param_set_uint_minmax(val, kp, 1, -1);
+}
+
+static struct kernel_param_ops param_ops_uintpos = {
+       .set = param_set_uintpos,
+       .get = param_get_uint,
+};
+
+#define param_check_uintpos(name, p) \
+               __param_check(name, p, unsigned int)
+
 unsigned int libcfs_console_backoff = CDEBUG_DEFAULT_BACKOFF;
-module_param(libcfs_console_backoff, uint, 0644);
+module_param(libcfs_console_backoff, uintpos, 0644);
 MODULE_PARM_DESC(libcfs_console_backoff, "Lustre kernel debug console backoff factor");
 EXPORT_SYMBOL(libcfs_console_backoff);
 
@@ -93,23 +215,14 @@ EXPORT_SYMBOL(libcfs_debug_binary);
 unsigned int libcfs_stack = 3 * THREAD_SIZE / 4;
 EXPORT_SYMBOL(libcfs_stack);
 
-static unsigned int portal_enter_debugger;
-EXPORT_SYMBOL(portal_enter_debugger);
-
 unsigned int libcfs_catastrophe;
 EXPORT_SYMBOL(libcfs_catastrophe);
 
-unsigned int libcfs_watchdog_ratelimit = 300;
-EXPORT_SYMBOL(libcfs_watchdog_ratelimit);
-
 unsigned int libcfs_panic_on_lbug = 1;
 module_param(libcfs_panic_on_lbug, uint, 0644);
 MODULE_PARM_DESC(libcfs_panic_on_lbug, "Lustre kernel panic on LBUG");
 EXPORT_SYMBOL(libcfs_panic_on_lbug);
 
-atomic_t libcfs_kmemory = ATOMIC_INIT(0);
-EXPORT_SYMBOL(libcfs_kmemory);
-
 static wait_queue_head_t debug_ctlwq;
 
 char libcfs_debug_file_path_arr[PATH_MAX] = LIBCFS_DEBUG_FILE_PATH_DEFAULT;
@@ -414,8 +527,10 @@ int libcfs_debug_init(unsigned long bufsize)
        }
        rc = cfs_tracefile_init(max);
 
-       if (rc == 0)
+       if (rc == 0) {
                libcfs_register_panic_notifier();
+               libcfs_debug_mb = cfs_trace_get_debug_mb();
+       }
 
        return rc;
 }
index 7b7fc21..42d615f 100644 (file)
@@ -123,7 +123,7 @@ EXPORT_SYMBOL(__cfs_fail_check_set);
 
 int __cfs_fail_timeout_set(__u32 id, __u32 value, int ms, int set)
 {
-       int ret = 0;
+       int ret;
 
        ret = __cfs_fail_check_set(id, value, set);
        if (ret) {
index 31a5581..933525c 100644 (file)
@@ -78,7 +78,7 @@ EXPORT_SYMBOL(cfs_cpt_table_free);
 int
 cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len)
 {
-       int     rc = 0;
+       int     rc;
 
        rc = snprintf(buf, len, "%d\t: %d\n", 0, 0);
        len -= rc;
index e60b2e9..1ab4232 100644 (file)
@@ -50,6 +50,7 @@
 #include <linux/list.h>
 
 #include <linux/sysctl.h>
+#include <linux/debugfs.h>
 
 # define DEBUG_SUBSYSTEM S_LNET
 
@@ -69,44 +70,17 @@ extern struct miscdevice libcfs_dev;
 extern struct cfs_wi_sched *cfs_sched_rehash;
 extern void libcfs_init_nidstrings(void);
 
-static int insert_proc(void);
-static void remove_proc(void);
+static void insert_debugfs(void);
+static void remove_debugfs(void);
 
-static struct ctl_table_header *lnet_table_header;
+static struct dentry *lnet_debugfs_root;
 extern char lnet_upcall[1024];
 /**
  * The path of debug log dump upcall script.
  */
 extern char lnet_debug_log_upcall[1024];
 
-#define CTL_LNET       (0x100)
-
-enum {
-       PSDEV_DEBUG = 1,          /* control debugging */
-       PSDEV_SUBSYSTEM_DEBUG,    /* control debugging */
-       PSDEV_PRINTK,        /* force all messages to console */
-       PSDEV_CONSOLE_RATELIMIT,  /* ratelimit console messages */
-       PSDEV_CONSOLE_MAX_DELAY_CS, /* maximum delay over which we skip messages */
-       PSDEV_CONSOLE_MIN_DELAY_CS, /* initial delay over which we skip messages */
-       PSDEV_CONSOLE_BACKOFF,    /* delay increase factor */
-       PSDEV_DEBUG_PATH,        /* crashdump log location */
-       PSDEV_DEBUG_DUMP_PATH,    /* crashdump tracelog location */
-       PSDEV_CPT_TABLE,          /* information about cpu partitions */
-       PSDEV_LNET_UPCALL,      /* User mode upcall script  */
-       PSDEV_LNET_MEMUSED,       /* bytes currently PORTAL_ALLOCated */
-       PSDEV_LNET_CATASTROPHE,   /* if we have LBUGged or panic'd */
-       PSDEV_LNET_PANIC_ON_LBUG, /* flag to panic on LBUG */
-       PSDEV_LNET_DUMP_KERNEL,   /* snapshot kernel debug buffer to file */
-       PSDEV_LNET_DAEMON_FILE,   /* spool kernel debug buffer to file */
-       PSDEV_LNET_DEBUG_MB,      /* size of debug buffer */
-       PSDEV_LNET_DEBUG_LOG_UPCALL, /* debug log upcall script */
-       PSDEV_LNET_WATCHDOG_RATELIMIT,  /* ratelimit watchdog messages  */
-       PSDEV_LNET_FORCE_LBUG,    /* hook to force an LBUG */
-       PSDEV_LNET_FAIL_LOC,      /* control test failures instrumentation */
-       PSDEV_LNET_FAIL_VAL,      /* userdata for fail loc */
-};
-
-static void kportal_memhog_free (struct libcfs_device_userstate *ldu)
+static void kportal_memhog_free(struct libcfs_device_userstate *ldu)
 {
        struct page **level0p = &ldu->ldu_memhog_root_page;
        struct page **level1p;
@@ -146,7 +120,7 @@ static void kportal_memhog_free (struct libcfs_device_userstate *ldu)
                *level0p = NULL;
        }
 
-       LASSERT (ldu->ldu_memhog_pages == 0);
+       LASSERT(ldu->ldu_memhog_pages == 0);
 }
 
 static int kportal_memhog_alloc(struct libcfs_device_userstate *ldu, int npages,
@@ -158,8 +132,8 @@ static int kportal_memhog_alloc(struct libcfs_device_userstate *ldu, int npages,
        int        count1;
        int        count2;
 
-       LASSERT (ldu->ldu_memhog_pages == 0);
-       LASSERT (ldu->ldu_memhog_root_page == NULL);
+       LASSERT(ldu->ldu_memhog_pages == 0);
+       LASSERT(ldu->ldu_memhog_root_page == NULL);
 
        if (npages < 0)
                return -EINVAL;
@@ -338,7 +312,7 @@ static int libcfs_ioctl_int(struct cfs_psdev_file *pfile, unsigned long cmd,
                        if (err != -EINVAL) {
                                if (err == 0)
                                        err = libcfs_ioctl_popdata(arg,
-                                                       data, sizeof (*data));
+                                                       data, sizeof(*data));
                                break;
                        }
                }
@@ -428,17 +402,10 @@ static int init_libcfs_module(void)
                goto cleanup_wi;
        }
 
+       insert_debugfs();
 
-       rc = insert_proc();
-       if (rc) {
-               CERROR("insert_proc: error %d\n", rc);
-               goto cleanup_crypto;
-       }
-
-       CDEBUG (D_OTHER, "portals setup OK\n");
+       CDEBUG(D_OTHER, "portals setup OK\n");
        return 0;
- cleanup_crypto:
-       cfs_crypto_unregister();
  cleanup_wi:
        cfs_wi_shutdown();
  cleanup_deregister:
@@ -454,10 +421,7 @@ static void exit_libcfs_module(void)
 {
        int rc;
 
-       remove_proc();
-
-       CDEBUG(D_MALLOC, "before Portals cleanup: kmem %d\n",
-              atomic_read(&libcfs_kmemory));
+       remove_debugfs();
 
        if (cfs_sched_rehash != NULL) {
                cfs_wi_sched_destroy(cfs_sched_rehash);
@@ -473,10 +437,6 @@ static void exit_libcfs_module(void)
 
        cfs_cpu_fini();
 
-       if (atomic_read(&libcfs_kmemory) != 0)
-               CERROR("Portals memory leaked: %d bytes\n",
-                      atomic_read(&libcfs_kmemory));
-
        rc = libcfs_debug_cleanup();
        if (rc)
                pr_err("LustreError: libcfs_debug_cleanup: %d\n", rc);
@@ -551,9 +511,6 @@ static int proc_dobitmasks(struct ctl_table *table, int write,
                                 __proc_dobitmasks);
 }
 
-static int min_watchdog_ratelimit;       /* disable ratelimiting */
-static int max_watchdog_ratelimit = (24*60*60); /* limit to once per day */
-
 static int __proc_dump_kernel(void *data, int write,
                              loff_t pos, void __user *buffer, int nob)
 {
@@ -593,125 +550,6 @@ static int proc_daemon_file(struct ctl_table *table, int write,
                                 __proc_daemon_file);
 }
 
-static int __proc_debug_mb(void *data, int write,
-                          loff_t pos, void __user *buffer, int nob)
-{
-       if (!write) {
-               char tmpstr[32];
-               int  len = snprintf(tmpstr, sizeof(tmpstr), "%d",
-                                   cfs_trace_get_debug_mb());
-
-               if (pos >= len)
-                       return 0;
-
-               return cfs_trace_copyout_string(buffer, nob, tmpstr + pos,
-                      "\n");
-       }
-
-       return cfs_trace_set_debug_mb_usrstr(buffer, nob);
-}
-
-static int proc_debug_mb(struct ctl_table *table, int write,
-                        void __user *buffer, size_t *lenp, loff_t *ppos)
-{
-       return proc_call_handler(table->data, write, ppos, buffer, lenp,
-                                __proc_debug_mb);
-}
-
-static int proc_console_max_delay_cs(struct ctl_table *table, int write,
-                                    void __user *buffer, size_t *lenp,
-                                    loff_t *ppos)
-{
-       int rc, max_delay_cs;
-       struct ctl_table dummy = *table;
-       long d;
-
-       dummy.data = &max_delay_cs;
-       dummy.proc_handler = &proc_dointvec;
-
-       if (!write) { /* read */
-               max_delay_cs = cfs_duration_sec(libcfs_console_max_delay * 100);
-               rc = proc_dointvec(&dummy, write, buffer, lenp, ppos);
-               return rc;
-       }
-
-       /* write */
-       max_delay_cs = 0;
-       rc = proc_dointvec(&dummy, write, buffer, lenp, ppos);
-       if (rc < 0)
-               return rc;
-       if (max_delay_cs <= 0)
-               return -EINVAL;
-
-       d = cfs_time_seconds(max_delay_cs) / 100;
-       if (d == 0 || d < libcfs_console_min_delay)
-               return -EINVAL;
-       libcfs_console_max_delay = d;
-
-       return rc;
-}
-
-static int proc_console_min_delay_cs(struct ctl_table *table, int write,
-                                    void __user *buffer, size_t *lenp,
-                                    loff_t *ppos)
-{
-       int rc, min_delay_cs;
-       struct ctl_table dummy = *table;
-       long d;
-
-       dummy.data = &min_delay_cs;
-       dummy.proc_handler = &proc_dointvec;
-
-       if (!write) { /* read */
-               min_delay_cs = cfs_duration_sec(libcfs_console_min_delay * 100);
-               rc = proc_dointvec(&dummy, write, buffer, lenp, ppos);
-               return rc;
-       }
-
-       /* write */
-       min_delay_cs = 0;
-       rc = proc_dointvec(&dummy, write, buffer, lenp, ppos);
-       if (rc < 0)
-               return rc;
-       if (min_delay_cs <= 0)
-               return -EINVAL;
-
-       d = cfs_time_seconds(min_delay_cs) / 100;
-       if (d == 0 || d > libcfs_console_max_delay)
-               return -EINVAL;
-       libcfs_console_min_delay = d;
-
-       return rc;
-}
-
-static int proc_console_backoff(struct ctl_table *table, int write,
-                               void __user *buffer, size_t *lenp, loff_t *ppos)
-{
-       int rc, backoff;
-       struct ctl_table dummy = *table;
-
-       dummy.data = &backoff;
-       dummy.proc_handler = &proc_dointvec;
-
-       if (!write) { /* read */
-               backoff = libcfs_console_backoff;
-               rc = proc_dointvec(&dummy, write, buffer, lenp, ppos);
-               return rc;
-       }
-
-       /* write */
-       backoff = 0;
-       rc = proc_dointvec(&dummy, write, buffer, lenp, ppos);
-       if (rc < 0)
-               return rc;
-       if (backoff <= 0)
-               return -EINVAL;
-
-       libcfs_console_backoff = backoff;
-
-       return rc;
-}
-
 static int libcfs_force_lbug(struct ctl_table *table, int write,
                             void __user *buffer,
                             size_t *lenp, loff_t *ppos)
@@ -809,40 +647,6 @@ static struct ctl_table lnet_table[] = {
                .proc_handler = &proc_dobitmasks,
        },
        {
-               .procname = "console_ratelimit",
-               .data     = &libcfs_console_ratelimit,
-               .maxlen   = sizeof(int),
-               .mode     = 0644,
-               .proc_handler = &proc_dointvec
-       },
-       {
-               .procname = "console_max_delay_centisecs",
-               .maxlen   = sizeof(int),
-               .mode     = 0644,
-               .proc_handler = &proc_console_max_delay_cs
-       },
-       {
-               .procname = "console_min_delay_centisecs",
-               .maxlen   = sizeof(int),
-               .mode     = 0644,
-               .proc_handler = &proc_console_min_delay_cs
-       },
-       {
-               .procname = "console_backoff",
-               .maxlen   = sizeof(int),
-               .mode     = 0644,
-               .proc_handler = &proc_console_backoff
-       },
-
-       {
-               .procname = "debug_path",
-               .data     = libcfs_debug_file_path_arr,
-               .maxlen   = sizeof(libcfs_debug_file_path_arr),
-               .mode     = 0644,
-               .proc_handler = &proc_dostring,
-       },
-
-       {
                .procname = "cpu_partition_table",
                .maxlen   = 128,
                .mode     = 0444,
@@ -864,13 +668,6 @@ static struct ctl_table lnet_table[] = {
                .proc_handler = &proc_dostring,
        },
        {
-               .procname = "lnet_memused",
-               .data     = (int *)&libcfs_kmemory.counter,
-               .maxlen   = sizeof(int),
-               .mode     = 0444,
-               .proc_handler = &proc_dointvec,
-       },
-       {
                .procname = "catastrophe",
                .data     = &libcfs_catastrophe,
                .maxlen   = sizeof(int),
@@ -878,13 +675,6 @@ static struct ctl_table lnet_table[] = {
                .proc_handler = &proc_dointvec,
        },
        {
-               .procname = "panic_on_lbug",
-               .data     = &libcfs_panic_on_lbug,
-               .maxlen   = sizeof(int),
-               .mode     = 0644,
-               .proc_handler = &proc_dointvec,
-       },
-       {
                .procname = "dump_kernel",
                .maxlen   = 256,
                .mode     = 0200,
@@ -897,20 +687,6 @@ static struct ctl_table lnet_table[] = {
                .proc_handler = &proc_daemon_file,
        },
        {
-               .procname = "debug_mb",
-               .mode     = 0644,
-               .proc_handler = &proc_debug_mb,
-       },
-       {
-               .procname = "watchdog_ratelimit",
-               .data     = &libcfs_watchdog_ratelimit,
-               .maxlen   = sizeof(int),
-               .mode     = 0644,
-               .proc_handler = &proc_dointvec_minmax,
-               .extra1   = &min_watchdog_ratelimit,
-               .extra2   = &max_watchdog_ratelimit,
-       },
-       {
                .procname = "force_lbug",
                .data     = NULL,
                .maxlen   = 0,
@@ -935,31 +711,93 @@ static struct ctl_table lnet_table[] = {
        }
 };
 
-static struct ctl_table top_table[] = {
-       {
-               .procname = "lnet",
-               .mode     = 0555,
-               .data     = NULL,
-               .maxlen   = 0,
-               .child    = lnet_table,
-       },
-       {
-       }
+struct lnet_debugfs_symlink_def {
+       char *name;
+       char *target;
 };
 
-static int insert_proc(void)
+struct lnet_debugfs_symlink_def lnet_debugfs_symlinks[] = {
+       { "console_ratelimit",
+         "/sys/module/libcfs/parameters/libcfs_console_ratelimit"},
+       { "debug_path",
+         "/sys/module/libcfs/parameters/libcfs_debug_file_path"},
+       { "panic_on_lbug",
+         "/sys/module/libcfs/parameters/libcfs_panic_on_lbug"},
+       { "libcfs_console_backoff",
+         "/sys/module/libcfs/parameters/libcfs_console_backoff"},
+       { "debug_mb",
+         "/sys/module/libcfs/parameters/libcfs_debug_mb"},
+       { "console_min_delay_centisecs",
+         "/sys/module/libcfs/parameters/libcfs_console_min_delay"},
+       { "console_max_delay_centisecs",
+         "/sys/module/libcfs/parameters/libcfs_console_max_delay"},
+       {},
+};
+
+static ssize_t lnet_debugfs_read(struct file *filp, char __user *buf,
+                                size_t count, loff_t *ppos)
 {
-       if (lnet_table_header == NULL)
-               lnet_table_header = register_sysctl_table(top_table);
-       return 0;
+       struct ctl_table *table = filp->private_data;
+       int error;
+
+       error = table->proc_handler(table, 0, (void __user *)buf, &count, ppos);
+       if (!error)
+               error = count;
+
+       return error;
+}
+
+static ssize_t lnet_debugfs_write(struct file *filp, const char __user *buf,
+                                 size_t count, loff_t *ppos)
+{
+       struct ctl_table *table = filp->private_data;
+       int error;
+
+       error = table->proc_handler(table, 1, (void __user *)buf, &count, ppos);
+       if (!error)
+               error = count;
+
+       return error;
+}
+
+static const struct file_operations lnet_debugfs_file_operations = {
+       .open           = simple_open,
+       .read           = lnet_debugfs_read,
+       .write          = lnet_debugfs_write,
+       .llseek         = default_llseek,
+};
+
+static void insert_debugfs(void)
+{
+       struct ctl_table *table;
+       struct dentry *entry;
+       struct lnet_debugfs_symlink_def *symlinks;
+
+       if (lnet_debugfs_root == NULL)
+               lnet_debugfs_root = debugfs_create_dir("lnet", NULL);
+
+       /* Even if we cannot create, just ignore it altogether) */
+       if (IS_ERR_OR_NULL(lnet_debugfs_root))
+               return;
+
+       for (table = lnet_table; table->procname; table++)
+               entry = debugfs_create_file(table->procname, table->mode,
+                                           lnet_debugfs_root, table,
+                                           &lnet_debugfs_file_operations);
+
+       for (symlinks = lnet_debugfs_symlinks; symlinks->name; symlinks++)
+               entry = debugfs_create_symlink(symlinks->name,
+                                              lnet_debugfs_root,
+                                              symlinks->target);
+
 }
 
-static void remove_proc(void)
+static void remove_debugfs(void)
 {
-       if (lnet_table_header != NULL)
-               unregister_sysctl_table(lnet_table_header);
+       if (lnet_debugfs_root != NULL)
+               debugfs_remove_recursive(lnet_debugfs_root);
 
-       lnet_table_header = NULL;
+       lnet_debugfs_root = NULL;
 }
 
 MODULE_VERSION("1.0.0");
index 6ee2adc..effa2af 100644 (file)
@@ -937,18 +937,6 @@ int cfs_trace_set_debug_mb(int mb)
        return 0;
 }
 
-int cfs_trace_set_debug_mb_usrstr(void __user *usr_str, int usr_str_nob)
-{
-       char     str[32];
-       int      rc;
-
-       rc = cfs_trace_copyin_string(str, sizeof(str), usr_str, usr_str_nob);
-       if (rc < 0)
-               return rc;
-
-       return cfs_trace_set_debug_mb(simple_strtoul(str, NULL, 0));
-}
-
 int cfs_trace_get_debug_mb(void)
 {
        int i;
index 0601476..8d993f4 100644 (file)
@@ -77,7 +77,6 @@ int cfs_trace_dump_debug_buffer_usrstr(void __user *usr_str, int usr_str_nob);
 int cfs_trace_daemon_command(char *str);
 int cfs_trace_daemon_command_usrstr(void __user *usr_str, int usr_str_nob);
 int cfs_trace_set_debug_mb(int mb);
-int cfs_trace_set_debug_mb_usrstr(void __user *usr_str, int usr_str_nob);
 int cfs_trace_get_debug_mb(void);
 
 extern void libcfs_debug_dumplog_internal(void *arg);
index 3075db2..dcd0c6d 100644 (file)
@@ -702,8 +702,7 @@ out_och_free:
 out_openerr:
                if (opendir_set != 0)
                        ll_stop_statahead(inode, lli->lli_opendir_key);
-               if (fd != NULL)
-                       ll_file_data_put(fd);
+               ll_file_data_put(fd);
        } else {
                ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_OPEN, 1);
        }
@@ -3005,7 +3004,7 @@ int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat)
        struct inode *inode = d_inode(de);
        struct ll_sb_info *sbi = ll_i2sbi(inode);
        struct ll_inode_info *lli = ll_i2info(inode);
-       int res = 0;
+       int res;
 
        res = ll_inode_revalidate(de, MDS_INODELOCK_UPDATE |
                                      MDS_INODELOCK_LOOKUP);
index 2513988..ab4839c 100644 (file)
@@ -1114,7 +1114,7 @@ void ll_clear_inode(struct inode *inode)
        if (lli->lli_mds_read_och)
                ll_md_real_close(inode, FMODE_READ);
 
-       if (S_ISLNK(inode->i_mode) && lli->lli_symlink_name) {
+       if (S_ISLNK(inode->i_mode)) {
                kfree(lli->lli_symlink_name);
                lli->lli_symlink_name = NULL;
        }
index 6956dec..9e763ce 100644 (file)
@@ -357,7 +357,7 @@ static int ll_xattr_cache_refill(struct inode *inode, struct lookup_intent *oit)
        struct ll_inode_info *lli = ll_i2info(inode);
        struct mdt_body *body;
        __u32 *xsizes;
-       int rc = 0, i;
+       int rc, i;
 
 
 
index cb35f63..eebe45b 100644 (file)
@@ -100,7 +100,7 @@ static int lmv_intent_remote(struct obd_export *exp, void *lmm,
        }
 
        op_data = kzalloc(sizeof(*op_data), GFP_NOFS);
-       if (op_data == NULL) {
+       if (!op_data) {
                rc = -ENOMEM;
                goto out;
        }
index ac5053c..c9e0536 100644 (file)
@@ -716,7 +716,7 @@ repeat_fid2path:
        if (remote_gf == NULL) {
                remote_gf_size = sizeof(*remote_gf) + PATH_MAX;
                remote_gf = kzalloc(remote_gf_size, GFP_NOFS);
-               if (remote_gf == NULL) {
+               if (!remote_gf) {
                        rc = -ENOMEM;
                        goto out_fid2path;
                }
@@ -1398,7 +1398,7 @@ static int lmv_statfs(const struct lu_env *env, struct obd_export *exp,
                return rc;
 
        temp = kzalloc(sizeof(*temp), GFP_NOFS);
-       if (temp == NULL)
+       if (!temp)
                return -ENOMEM;
 
        for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
@@ -1730,7 +1730,7 @@ lmv_enqueue_remote(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
        }
 
        rdata = kzalloc(sizeof(*rdata), GFP_NOFS);
-       if (rdata == NULL) {
+       if (!rdata) {
                rc = -ENOMEM;
                goto out;
        }
@@ -1993,7 +1993,7 @@ static int lmv_setattr(struct obd_export *exp, struct md_op_data *op_data,
        struct obd_device       *obd = exp->exp_obd;
        struct lmv_obd    *lmv = &obd->u.lmv;
        struct lmv_tgt_desc     *tgt;
-       int                   rc = 0;
+       int                   rc;
 
        rc = lmv_check_connect(obd);
        if (rc)
index 504b24a..8c3bbe5 100644 (file)
@@ -478,7 +478,7 @@ static struct lu_device *lov_device_alloc(const struct lu_env *env,
        int rc;
 
        ld = kzalloc(sizeof(*ld), GFP_NOFS);
-       if (ld == NULL)
+       if (!ld)
                return ERR_PTR(-ENOMEM);
 
        cl_device_init(&ld->ld_cl, t);
index 11c1081..bf36291 100644 (file)
@@ -181,7 +181,7 @@ static int lov_io_sub_init(const struct lu_env *env, struct lov_io *lio,
                        } else {
                                sub->sub_io = kzalloc(sizeof(*sub->sub_io),
                                                      GFP_NOFS);
-                               if (sub->sub_io == NULL)
+                               if (!sub->sub_io)
                                        result = -ENOMEM;
                        }
                }
index b7e7bfa..dd1cf3d 100644 (file)
@@ -123,6 +123,7 @@ int lov_adjust_kms(struct obd_export *exp, struct lov_stripe_md *lsm,
        if (shrink) {
                for (; stripe < lsm->lsm_stripe_count; stripe++) {
                        struct lov_oinfo *loi = lsm->lsm_oinfo[stripe];
+
                        kms = lov_size_to_stripe(lsm, size, stripe);
                        CDEBUG(D_INODE,
                               "stripe %d KMS %sing %llu->%llu\n",
index 96c55ac..5f4c115 100644 (file)
@@ -107,6 +107,10 @@ static void lov_putref(struct obd_device *obd)
                        /* Disconnect */
                        __lov_del_obd(obd, tgt);
                }
+
+               if (lov->lov_tgts_kobj)
+                       kobject_put(lov->lov_tgts_kobj);
+
        } else {
                mutex_unlock(&lov->lov_lock);
        }
@@ -322,9 +326,6 @@ static int lov_disconnect(struct obd_export *exp)
                }
        }
 
-       if (lov->lov_tgts_kobj)
-               kobject_put(lov->lov_tgts_kobj);
-
        obd_putref(obd);
 
 out:
@@ -976,7 +977,7 @@ static int lov_recreate(struct obd_export *exp, struct obdo *src_oa,
                src_oa->o_flags & OBD_FL_RECREATE_OBJS);
 
        obj_mdp = kzalloc(sizeof(*obj_mdp), GFP_NOFS);
-       if (obj_mdp == NULL)
+       if (!obj_mdp)
                return -ENOMEM;
 
        ost_idx = src_oa->o_nlink;
index 1e4d3fb..c59b140 100644 (file)
@@ -431,7 +431,7 @@ int lov_pool_new(struct obd_device *obd, char *poolname)
                return -ENAMETOOLONG;
 
        new_pool = kzalloc(sizeof(*new_pool), GFP_NOFS);
-       if (new_pool == NULL)
+       if (!new_pool)
                return -ENOMEM;
 
        strncpy(new_pool->pool_name, poolname, LOV_MAXPOOLNAME);
index f4de8b8..416e42e 100644 (file)
@@ -275,7 +275,7 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo,
        int rc = 0, i;
 
        set = kzalloc(sizeof(*set), GFP_NOFS);
-       if (set == NULL)
+       if (!set)
                return -ENOMEM;
        lov_init_set(set);
 
@@ -301,7 +301,7 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo,
                }
 
                req = kzalloc(sizeof(*req), GFP_NOFS);
-               if (req == NULL) {
+               if (!req) {
                        rc = -ENOMEM;
                        goto out_set;
                }
@@ -358,7 +358,7 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo,
        int rc = 0, i;
 
        set = kzalloc(sizeof(*set), GFP_NOFS);
-       if (set == NULL)
+       if (!set)
                return -ENOMEM;
        lov_init_set(set);
 
@@ -384,7 +384,7 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo,
                }
 
                req = kzalloc(sizeof(*req), GFP_NOFS);
-               if (req == NULL) {
+               if (!req) {
                        rc = -ENOMEM;
                        goto out_set;
                }
@@ -477,7 +477,7 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo,
        int rc = 0, i;
 
        set = kzalloc(sizeof(*set), GFP_NOFS);
-       if (set == NULL)
+       if (!set)
                return -ENOMEM;
        lov_init_set(set);
 
@@ -500,7 +500,7 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo,
                }
 
                req = kzalloc(sizeof(*req), GFP_NOFS);
-               if (req == NULL) {
+               if (!req) {
                        rc = -ENOMEM;
                        goto out_set;
                }
@@ -704,7 +704,7 @@ int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo,
        int rc = 0, i;
 
        set = kzalloc(sizeof(*set), GFP_NOFS);
-       if (set == NULL)
+       if (!set)
                return -ENOMEM;
        lov_init_set(set);
 
@@ -730,14 +730,14 @@ int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo,
                }
 
                req = kzalloc(sizeof(*req), GFP_NOFS);
-               if (req == NULL) {
+               if (!req) {
                        rc = -ENOMEM;
                        goto out_set;
                }
 
                req->rq_oi.oi_osfs = kzalloc(sizeof(*req->rq_oi.oi_osfs),
                                             GFP_NOFS);
-               if (req->rq_oi.oi_osfs == NULL) {
+               if (!req->rq_oi.oi_osfs) {
                        kfree(req);
                        rc = -ENOMEM;
                        goto out_set;
index 7f208a6..204d512 100644 (file)
@@ -1202,7 +1202,7 @@ static int mdc_ioc_fid2path(struct obd_export *exp, struct getinfo_fid2path *gf)
        /* Key is KEY_FID2PATH + getinfo_fid2path description */
        keylen = cfs_size_round(sizeof(KEY_FID2PATH)) + sizeof(*gf);
        key = kzalloc(keylen, GFP_NOFS);
-       if (key == NULL)
+       if (!key)
                return -ENOMEM;
        memcpy(key, KEY_FID2PATH, sizeof(KEY_FID2PATH));
        memcpy(key + cfs_size_round(sizeof(KEY_FID2PATH)), gf, sizeof(*gf));
@@ -1605,7 +1605,7 @@ static int mdc_changelog_send_thread(void *csdata)
               cs->cs_fp, cs->cs_startrec);
 
        cs->cs_buf = kzalloc(KUC_CHANGELOG_MSG_MAXSIZE, GFP_NOFS);
-       if (cs->cs_buf == NULL) {
+       if (!cs->cs_buf) {
                rc = -ENOMEM;
                goto out;
        }
@@ -1934,7 +1934,7 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                struct obd_quotactl *oqctl;
 
                oqctl = kzalloc(sizeof(*oqctl), GFP_NOFS);
-               if (oqctl == NULL) {
+               if (!oqctl) {
                        rc = -ENOMEM;
                        goto out;
                }
index 174dfc3..562bd95 100644 (file)
@@ -1128,7 +1128,7 @@ static int mgc_apply_recover_logs(struct obd_device *mgc,
        LASSERT(cfg->cfg_sb == cfg->cfg_instance);
 
        inst = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS);
-       if (inst == NULL)
+       if (!inst)
                return -ENOMEM;
 
        if (!IS_SERVER(lsi)) {
@@ -1493,7 +1493,7 @@ static int mgc_process_cfg_log(struct obd_device *mgc,
                lsi = s2lsi(cld->cld_cfg.cfg_sb);
 
        env = kzalloc(sizeof(*env), GFP_NOFS);
-       if (env == NULL)
+       if (!env)
                return -ENOMEM;
 
        rc = lu_env_init(env, LCT_MG_THREAD);
index a7f3032..282ae73 100644 (file)
@@ -1425,7 +1425,7 @@ void cl_page_clip(const struct lu_env *env, struct cl_page *pg,
        CL_PAGE_HEADER(D_TRACE, env, pg, "%d %d\n", from, to);
        CL_PAGE_INVOID(env, pg, CL_PAGE_OP(cpo_clip),
                       (const struct lu_env *,
-                       const struct cl_page_slice *,int, int),
+                       const struct cl_page_slice *, int, int),
                       from, to);
 }
 EXPORT_SYMBOL(cl_page_clip);
index 1bc3756..2c705d7 100644 (file)
@@ -78,12 +78,8 @@ atomic_t obd_dirty_pages;
 EXPORT_SYMBOL(obd_dirty_pages);
 unsigned int obd_timeout = OBD_TIMEOUT_DEFAULT;   /* seconds */
 EXPORT_SYMBOL(obd_timeout);
-unsigned int ldlm_timeout = LDLM_TIMEOUT_DEFAULT; /* seconds */
-EXPORT_SYMBOL(ldlm_timeout);
 unsigned int obd_timeout_set;
 EXPORT_SYMBOL(obd_timeout_set);
-unsigned int ldlm_timeout_set;
-EXPORT_SYMBOL(ldlm_timeout_set);
 /* Adaptive timeout defs here instead of ptlrpc module for /proc/sys/ access */
 unsigned int at_min = 0;
 EXPORT_SYMBOL(at_min);
@@ -144,11 +140,11 @@ int obd_alloc_fail(const void *ptr, const char *name, const char *type,
                CERROR("%s%salloc of %s (%llu bytes) failed at %s:%d\n",
                       ptr ? "force " :"", type, name, (__u64)size, file,
                       line);
-               CERROR("%llu total bytes and %llu total pages (%llu bytes) allocated by Lustre, %d total bytes by LNET\n",
+               CERROR("%llu total bytes and %llu total pages"
+                       " (%llu bytes) allocated by Lustre\n",
                       obd_memory_sum(),
                       obd_pages_sum() << PAGE_CACHE_SHIFT,
-                      obd_pages_sum(),
-                      atomic_read(&libcfs_kmemory));
+                      obd_pages_sum());
                return 1;
        }
        return 0;
@@ -232,7 +228,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
                        goto out;
                }
                lcfg = kzalloc(data->ioc_plen1, GFP_NOFS);
-               if (lcfg == NULL) {
+               if (!lcfg) {
                        err = -ENOMEM;
                        goto out;
                }
@@ -571,12 +567,14 @@ static int __init init_obdclass(void)
        if (err)
                return err;
 
-       obd_sysctl_init();
-
        err = class_procfs_init();
        if (err)
                return err;
 
+       err = obd_sysctl_init();
+       if (err)
+               return err;
+
        err = lu_global_init();
        if (err)
                return err;
@@ -661,7 +659,6 @@ static void cleanup_obdclass(void)
        lu_global_fini();
 
        obd_cleanup_caches();
-       obd_sysctl_clean();
 
        class_procfs_clean();
 
index 978c3c5..0ca7309 100644 (file)
@@ -45,7 +45,7 @@
 
 spinlock_t obd_types_lock;
 
-struct kmem_cache *obd_device_cachep;
+static struct kmem_cache *obd_device_cachep;
 struct kmem_cache *obdo_cachep;
 EXPORT_SYMBOL(obdo_cachep);
 static struct kmem_cache *import_cachep;
@@ -71,9 +71,8 @@ static struct obd_device *obd_device_alloc(void)
        struct obd_device *obd;
 
        OBD_SLAB_ALLOC_PTR_GFP(obd, obd_device_cachep, GFP_NOFS);
-       if (obd != NULL) {
+       if (obd != NULL)
                obd->obd_magic = OBD_DEVICE_MAGIC;
-       }
        return obd;
 }
 
@@ -172,7 +171,7 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
 
        rc = -ENOMEM;
        type = kzalloc(sizeof(*type), GFP_NOFS);
-       if (type == NULL)
+       if (!type)
                return rc;
 
        type->typ_dt_ops = kzalloc(sizeof(*type->typ_dt_ops), GFP_NOFS);
@@ -294,7 +293,7 @@ struct obd_device *class_newdev(const char *type_name, const char *name)
        }
 
        type = class_get_type(type_name);
-       if (type == NULL){
+       if (type == NULL) {
                CERROR("OBD: unknown type: %s\n", type_name);
                return ERR_PTR(-ENODEV);
        }
@@ -999,7 +998,8 @@ void class_import_put(struct obd_import *imp)
 }
 EXPORT_SYMBOL(class_import_put);
 
-static void init_imp_at(struct imp_at *at) {
+static void init_imp_at(struct imp_at *at)
+{
        int i;
        at_init(&at->iat_net_latency, 0, 0);
        for (i = 0; i < IMP_AT_MAX_PORTALS; i++) {
@@ -1016,7 +1016,7 @@ struct obd_import *class_new_import(struct obd_device *obd)
        struct obd_import *imp;
 
        imp = kzalloc(sizeof(*imp), GFP_NOFS);
-       if (imp == NULL)
+       if (!imp)
                return NULL;
 
        INIT_LIST_HEAD(&imp->imp_pinger_chain);
@@ -1642,7 +1642,8 @@ static int obd_zombie_impexp_check(void *arg)
 /**
  * Add export to the obd_zombie thread and notify it.
  */
-static void obd_zombie_export_add(struct obd_export *exp) {
+static void obd_zombie_export_add(struct obd_export *exp)
+{
        spin_lock(&exp->exp_obd->obd_dev_lock);
        LASSERT(!list_empty(&exp->exp_obd_chain));
        list_del_init(&exp->exp_obd_chain);
@@ -1658,7 +1659,8 @@ static void obd_zombie_export_add(struct obd_export *exp) {
 /**
  * Add import to the obd_zombie thread and notify it.
  */
-static void obd_zombie_import_add(struct obd_import *imp) {
+static void obd_zombie_import_add(struct obd_import *imp)
+{
        LASSERT(imp->imp_sec == NULL);
        LASSERT(imp->imp_rq_pool == NULL);
        spin_lock(&obd_zombie_impexp_lock);
@@ -1819,7 +1821,7 @@ void *kuc_alloc(int payload_len, int transport, int type)
        int len = kuc_len(payload_len);
 
        lh = kzalloc(len, GFP_NOFS);
-       if (lh == NULL)
+       if (!lh)
                return ERR_PTR(-ENOMEM);
 
        lh->kuc_magic = KUC_MAGIC;
index 84f75dc..b618c0b 100644 (file)
@@ -423,7 +423,7 @@ static struct attribute_group lustre_attr_group = {
 
 int class_procfs_init(void)
 {
-       int rc = 0;
+       int rc = -ENOMEM;
        struct dentry *file;
 
        lustre_kobj = kobject_create_and_add("lustre", fs_kobj);
index 54f0a81..1515163 100644 (file)
 #include "../../include/obd_support.h"
 #include "../../include/lprocfs_status.h"
 
-#ifdef CONFIG_SYSCTL
-static struct ctl_table_header *obd_table_header;
-#endif
+struct static_lustre_uintvalue_attr {
+       struct {
+               struct attribute attr;
+               ssize_t (*show)(struct kobject *kobj, struct attribute *attr,
+                               char *buf);
+               ssize_t (*store)(struct kobject *kobj, struct attribute *attr,
+                                const char *buf, size_t len);
+       } u;
+       int *value;
+};
 
-#ifdef CONFIG_SYSCTL
-static int proc_set_timeout(struct ctl_table *table, int write,
-                       void __user *buffer, size_t *lenp, loff_t *ppos)
+static ssize_t static_uintvalue_show(struct kobject *kobj,
+                                   struct attribute *attr,
+                                   char *buf)
 {
-       int rc;
+       struct static_lustre_uintvalue_attr *lattr = (void *)attr;
 
-       rc = proc_dointvec(table, write, buffer, lenp, ppos);
-       if (ldlm_timeout >= obd_timeout)
-               ldlm_timeout = max(obd_timeout / 3, 1U);
-       return rc;
+       return sprintf(buf, "%d\n", *lattr->value);
 }
 
-static int proc_memory_alloc(struct ctl_table *table, int write,
-                       void __user *buffer, size_t *lenp, loff_t *ppos)
+static ssize_t static_uintvalue_store(struct kobject *kobj,
+                                    struct attribute *attr,
+                                    const char *buffer, size_t count)
 {
-       char buf[22];
-       int len;
-
-       if (!*lenp || (*ppos && !write)) {
-               *lenp = 0;
-               return 0;
-       }
-       if (write)
-               return -EINVAL;
+       struct static_lustre_uintvalue_attr *lattr  = (void *)attr;
+       int rc;
+       unsigned int val;
 
-       len = snprintf(buf, sizeof(buf), "%llu\n", obd_memory_sum());
-       if (len > *lenp)
-               len = *lenp;
-       buf[len] = '\0';
-       if (copy_to_user(buffer, buf, len))
-               return -EFAULT;
-       *lenp = len;
-       *ppos += *lenp;
-       return 0;
-}
+       rc = kstrtouint(buffer, 10, &val);
+       if (rc)
+               return rc;
 
-static int proc_pages_alloc(struct ctl_table *table, int write,
-                       void __user *buffer, size_t *lenp, loff_t *ppos)
-{
-       char buf[22];
-       int len;
+       *lattr->value = val;
 
-       if (!*lenp || (*ppos && !write)) {
-               *lenp = 0;
-               return 0;
-       }
-       if (write)
-               return -EINVAL;
-
-       len = snprintf(buf, sizeof(buf), "%llu\n", obd_pages_sum());
-       if (len > *lenp)
-               len = *lenp;
-       buf[len] = '\0';
-       if (copy_to_user(buffer, buf, len))
-               return -EFAULT;
-       *lenp = len;
-       *ppos += *lenp;
-       return 0;
+       return count;
 }
 
-static int proc_mem_max(struct ctl_table *table, int write, void __user *buffer,
-                size_t *lenp, loff_t *ppos)
-{
-       char buf[22];
-       int len;
+#define LUSTRE_STATIC_UINT_ATTR(name, value) \
+static struct static_lustre_uintvalue_attr lustre_sattr_##name =       \
+                                       {__ATTR(name, 0644,             \
+                                               static_uintvalue_show,  \
+                                               static_uintvalue_store),\
+                                         value }
 
-       if (!*lenp || (*ppos && !write)) {
-               *lenp = 0;
-               return 0;
-       }
-       if (write)
-               return -EINVAL;
+LUSTRE_STATIC_UINT_ATTR(timeout, &obd_timeout);
 
-       len = snprintf(buf, sizeof(buf), "%llu\n", obd_memory_max());
-       if (len > *lenp)
-               len = *lenp;
-       buf[len] = '\0';
-       if (copy_to_user(buffer, buf, len))
-               return -EFAULT;
-       *lenp = len;
-       *ppos += *lenp;
-       return 0;
+static ssize_t max_dirty_mb_show(struct kobject *kobj, struct attribute *attr,
+                                char *buf)
+{
+       return sprintf(buf, "%ul\n",
+                       obd_max_dirty_pages / (1 << (20 - PAGE_CACHE_SHIFT)));
 }
 
-static int proc_pages_max(struct ctl_table *table, int write,
-                       void __user *buffer, size_t *lenp, loff_t *ppos)
+static ssize_t max_dirty_mb_store(struct kobject *kobj, struct attribute *attr,
+                                 const char *buffer, size_t count)
 {
-       char buf[22];
-       int len;
+       int rc;
+       unsigned long val;
 
-       if (!*lenp || (*ppos && !write)) {
-               *lenp = 0;
-               return 0;
-       }
-       if (write)
-               return -EINVAL;
+       rc = kstrtoul(buffer, 10, &val);
+       if (rc)
+               return rc;
 
-       len = snprintf(buf, sizeof(buf), "%llu\n", obd_pages_max());
-       if (len > *lenp)
-               len = *lenp;
-       buf[len] = '\0';
-       if (copy_to_user(buffer, buf, len))
-               return -EFAULT;
-       *lenp = len;
-       *ppos += *lenp;
-       return 0;
-}
+       val *= 1 << (20 - PAGE_CACHE_SHIFT); /* convert to pages */
 
-static int proc_max_dirty_pages_in_mb(struct ctl_table *table, int write,
-                              void __user *buffer, size_t *lenp, loff_t *ppos)
-{
-       int rc = 0;
-
-       if (!table->data || !table->maxlen || !*lenp || (*ppos && !write)) {
-               *lenp = 0;
-               return 0;
+       if (val > ((totalram_pages / 10) * 9)) {
+               /* Somebody wants to assign too much memory to dirty pages */
+               return -EINVAL;
        }
-       if (write) {
-               rc = lprocfs_write_frac_helper(buffer, *lenp,
-                                              (unsigned int *)table->data,
-                                              1 << (20 - PAGE_CACHE_SHIFT));
-               /* Don't allow them to let dirty pages exceed 90% of system
-                * memory and set a hard minimum of 4MB. */
-               if (obd_max_dirty_pages > ((totalram_pages / 10) * 9)) {
-                       CERROR("Refusing to set max dirty pages to %u, which is more than 90%% of available RAM; setting to %lu\n",
-                              obd_max_dirty_pages,
-                              ((totalram_pages / 10) * 9));
-                       obd_max_dirty_pages = (totalram_pages / 10) * 9;
-               } else if (obd_max_dirty_pages < 4 << (20 - PAGE_CACHE_SHIFT)) {
-                       obd_max_dirty_pages = 4 << (20 - PAGE_CACHE_SHIFT);
-               }
-       } else {
-               char buf[21];
-               int len;
 
-               len = lprocfs_read_frac_helper(buf, sizeof(buf),
-                                              *(unsigned int *)table->data,
-                                              1 << (20 - PAGE_CACHE_SHIFT));
-               if (len > *lenp)
-                       len = *lenp;
-               buf[len] = '\0';
-               if (copy_to_user(buffer, buf, len))
-                       return -EFAULT;
-               *lenp = len;
+       if (val < 4 << (20 - PAGE_CACHE_SHIFT)) {
+               /* Less than 4 Mb for dirty cache is also bad */
+               return -EINVAL;
        }
-       *ppos += *lenp;
-       return rc;
-}
 
-static int proc_alloc_fail_rate(struct ctl_table *table, int write,
-                        void __user *buffer, size_t *lenp, loff_t *ppos)
-{
-       int rc    = 0;
+       obd_max_dirty_pages = val;
 
-       if (!table->data || !table->maxlen || !*lenp || (*ppos && !write)) {
-               *lenp = 0;
-               return 0;
-       }
-       if (write) {
-               rc = lprocfs_write_frac_helper(buffer, *lenp,
-                                              (unsigned int *)table->data,
-                                              OBD_ALLOC_FAIL_MULT);
-       } else {
-               char buf[21];
-               int  len;
-
-               len = lprocfs_read_frac_helper(buf, 21,
-                                              *(unsigned int *)table->data,
-                                              OBD_ALLOC_FAIL_MULT);
-               if (len > *lenp)
-                       len = *lenp;
-               buf[len] = '\0';
-               if (copy_to_user(buffer, buf, len))
-                       return -EFAULT;
-               *lenp = len;
-       }
-       *ppos += *lenp;
-       return rc;
+       return count;
 }
-
-static struct ctl_table obd_table[] = {
-       {
-               .procname = "timeout",
-               .data     = &obd_timeout,
-               .maxlen   = sizeof(int),
-               .mode     = 0644,
-               .proc_handler = &proc_set_timeout
-       },
-       {
-               .procname = "debug_peer_on_timeout",
-               .data     = &obd_debug_peer_on_timeout,
-               .maxlen   = sizeof(int),
-               .mode     = 0644,
-               .proc_handler = &proc_dointvec
-       },
-       {
-               .procname = "dump_on_timeout",
-               .data     = &obd_dump_on_timeout,
-               .maxlen   = sizeof(int),
-               .mode     = 0644,
-               .proc_handler = &proc_dointvec
-       },
-       {
-               .procname = "dump_on_eviction",
-               .data     = &obd_dump_on_eviction,
-               .maxlen   = sizeof(int),
-               .mode     = 0644,
-               .proc_handler = &proc_dointvec
-       },
-       {
-               .procname = "memused",
-               .data     = NULL,
-               .maxlen   = 0,
-               .mode     = 0444,
-               .proc_handler = &proc_memory_alloc
-       },
-       {
-               .procname = "pagesused",
-               .data     = NULL,
-               .maxlen   = 0,
-               .mode     = 0444,
-               .proc_handler = &proc_pages_alloc
-       },
-       {
-               .procname = "memused_max",
-               .data     = NULL,
-               .maxlen   = 0,
-               .mode     = 0444,
-               .proc_handler = &proc_mem_max
-       },
-       {
-               .procname = "pagesused_max",
-               .data     = NULL,
-               .maxlen   = 0,
-               .mode     = 0444,
-               .proc_handler = &proc_pages_max
-       },
-       {
-               .procname = "ldlm_timeout",
-               .data     = &ldlm_timeout,
-               .maxlen   = sizeof(int),
-               .mode     = 0644,
-               .proc_handler = &proc_set_timeout
-       },
-       {
-               .procname = "alloc_fail_rate",
-               .data     = &obd_alloc_fail_rate,
-               .maxlen   = sizeof(int),
-               .mode     = 0644,
-               .proc_handler = &proc_alloc_fail_rate
-       },
-       {
-               .procname = "max_dirty_mb",
-               .data     = &obd_max_dirty_pages,
-               .maxlen   = sizeof(int),
-               .mode     = 0644,
-               .proc_handler = &proc_max_dirty_pages_in_mb
-       },
-       {
-               .procname = "at_min",
-               .data     = &at_min,
-               .maxlen   = sizeof(int),
-               .mode     = 0644,
-               .proc_handler = &proc_dointvec,
-       },
-       {
-               .procname = "at_max",
-               .data     = &at_max,
-               .maxlen   = sizeof(int),
-               .mode     = 0644,
-               .proc_handler = &proc_dointvec,
-       },
-       {
-               .procname = "at_extra",
-               .data     = &at_extra,
-               .maxlen   = sizeof(int),
-               .mode     = 0644,
-               .proc_handler = &proc_dointvec,
-       },
-       {
-               .procname = "at_early_margin",
-               .data     = &at_early_margin,
-               .maxlen   = sizeof(int),
-               .mode     = 0644,
-               .proc_handler = &proc_dointvec,
-       },
-       {
-               .procname = "at_history",
-               .data     = &at_history,
-               .maxlen   = sizeof(int),
-               .mode     = 0644,
-               .proc_handler = &proc_dointvec,
-       },
-       {}
+LUSTRE_RW_ATTR(max_dirty_mb);
+
+LUSTRE_STATIC_UINT_ATTR(debug_peer_on_timeout, &obd_debug_peer_on_timeout);
+LUSTRE_STATIC_UINT_ATTR(dump_on_timeout, &obd_dump_on_timeout);
+LUSTRE_STATIC_UINT_ATTR(dump_on_eviction, &obd_dump_on_eviction);
+LUSTRE_STATIC_UINT_ATTR(at_min, &at_min);
+LUSTRE_STATIC_UINT_ATTR(at_max, &at_max);
+LUSTRE_STATIC_UINT_ATTR(at_extra, &at_extra);
+LUSTRE_STATIC_UINT_ATTR(at_early_margin, &at_early_margin);
+LUSTRE_STATIC_UINT_ATTR(at_history, &at_history);
+
+static struct attribute *lustre_attrs[] = {
+       &lustre_sattr_timeout.u.attr,
+       &lustre_attr_max_dirty_mb.attr,
+       &lustre_sattr_debug_peer_on_timeout.u.attr,
+       &lustre_sattr_dump_on_timeout.u.attr,
+       &lustre_sattr_dump_on_eviction.u.attr,
+       &lustre_sattr_at_min.u.attr,
+       &lustre_sattr_at_max.u.attr,
+       &lustre_sattr_at_extra.u.attr,
+       &lustre_sattr_at_early_margin.u.attr,
+       &lustre_sattr_at_history.u.attr,
+       NULL,
 };
 
-static struct ctl_table parent_table[] = {
-       {
-               .procname = "lustre",
-               .data     = NULL,
-               .maxlen   = 0,
-               .mode     = 0555,
-               .child    = obd_table
-       },
-       {}
+static struct attribute_group lustre_attr_group = {
+       .attrs = lustre_attrs,
 };
-#endif
 
-void obd_sysctl_init(void)
+int obd_sysctl_init(void)
 {
-#ifdef CONFIG_SYSCTL
-       if (!obd_table_header)
-               obd_table_header = register_sysctl_table(parent_table);
-#endif
+       return sysfs_create_group(lustre_kobj, &lustre_attr_group);
 }
 
 void obd_sysctl_clean(void)
 {
-#ifdef CONFIG_SYSCTL
-       if (obd_table_header)
-               unregister_sysctl_table(obd_table_header);
-       obd_table_header = NULL;
-#endif
 }
index 4fa52d1..facc835 100644 (file)
@@ -61,7 +61,7 @@ static struct llog_handle *llog_alloc_handle(void)
        struct llog_handle *loghandle;
 
        loghandle = kzalloc(sizeof(*loghandle), GFP_NOFS);
-       if (loghandle == NULL)
+       if (!loghandle)
                return NULL;
 
        init_rwsem(&loghandle->lgh_lock);
@@ -208,7 +208,7 @@ int llog_init_handle(const struct lu_env *env, struct llog_handle *handle,
        LASSERT(handle->lgh_hdr == NULL);
 
        llh = kzalloc(sizeof(*llh), GFP_NOFS);
-       if (llh == NULL)
+       if (!llh)
                return -ENOMEM;
        handle->lgh_hdr = llh;
        /* first assign flags to use llog_client_ops */
@@ -435,7 +435,7 @@ int llog_process_or_fork(const struct lu_env *env,
        int                   rc;
 
        lpi = kzalloc(sizeof(*lpi), GFP_NOFS);
-       if (lpi == NULL) {
+       if (!lpi) {
                CERROR("cannot alloc pointer\n");
                return -ENOMEM;
        }
@@ -907,7 +907,7 @@ int llog_is_empty(const struct lu_env *env, struct llog_ctxt *ctxt,
                  char *name)
 {
        struct llog_handle      *llh;
-       int                      rc = 0;
+       int                      rc;
 
        rc = llog_open(env, ctxt, &llh, NULL, name, LLOG_OPEN_EXISTS);
        if (rc < 0) {
index 17e7c18..08d1f0e 100644 (file)
@@ -275,7 +275,7 @@ struct dentry *ldebugfs_add_symlink(const char *name, struct dentry *parent,
                return NULL;
 
        dest = kzalloc(MAX_STRING_SIZE + 1, GFP_KERNEL);
-       if (dest == NULL)
+       if (!dest)
                return NULL;
 
        va_start(ap, format);
@@ -329,7 +329,7 @@ EXPORT_SYMBOL(ldebugfs_add_vars);
 
 void ldebugfs_remove(struct dentry **entryp)
 {
-       debugfs_remove(*entryp);
+       debugfs_remove_recursive(*entryp);
        *entryp = NULL;
 }
 EXPORT_SYMBOL(ldebugfs_remove);
index 5cc6435..d6184f8 100644 (file)
@@ -105,7 +105,7 @@ int class_add_uuid(const char *uuid, __u64 nid)
                return -EOVERFLOW;
 
        data = kzalloc(sizeof(*data), GFP_NOFS);
-       if (data == NULL)
+       if (!data)
                return -ENOMEM;
 
        obd_str2uuid(&data->un_uuid, uuid);
index fbdb748..93805ac 100644 (file)
@@ -835,7 +835,7 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc,
        CDEBUG(D_CONFIG, "Add profile %s\n", prof);
 
        lprof = kzalloc(sizeof(*lprof), GFP_NOFS);
-       if (lprof == NULL)
+       if (!lprof)
                return -ENOMEM;
        INIT_LIST_HEAD(&lprof->lp_list);
 
@@ -979,7 +979,7 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg,
        new_len = LUSTRE_CFG_BUFLEN(cfg, 1) + strlen(new_name) - name_len;
 
        new_param = kzalloc(new_len, GFP_NOFS);
-       if (new_param == NULL)
+       if (!new_param)
                return ERR_PTR(-ENOMEM);
 
        strcpy(new_param, new_name);
@@ -987,7 +987,7 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg,
                strcat(new_param, value);
 
        bufs = kzalloc(sizeof(*bufs), GFP_NOFS);
-       if (bufs == NULL) {
+       if (!bufs) {
                kfree(new_param);
                return ERR_PTR(-ENOMEM);
        }
@@ -1123,12 +1123,7 @@ int class_process_config(struct lustre_cfg *lcfg)
                goto out;
        }
        case LCFG_SET_LDLM_TIMEOUT: {
-               CDEBUG(D_IOCTL, "changing lustre ldlm_timeout from %d to %d\n",
-                      ldlm_timeout, lcfg->lcfg_num);
-               ldlm_timeout = max(lcfg->lcfg_num, 1U);
-               if (ldlm_timeout >= obd_timeout)
-                       ldlm_timeout = max(obd_timeout / 3, 1U);
-               ldlm_timeout_set = 1;
+               /* ldlm_timeout is not used on the client */
                err = 0;
                goto out;
        }
@@ -1461,7 +1456,7 @@ int class_config_llog_handler(const struct lu_env *env,
                        inst_len = LUSTRE_CFG_BUFLEN(lcfg, 0) +
                                   sizeof(clli->cfg_instance) * 2 + 4;
                        inst_name = kzalloc(inst_len, GFP_NOFS);
-                       if (inst_name == NULL) {
+                       if (!inst_name) {
                                rc = -ENOMEM;
                                goto out;
                        }
@@ -1639,7 +1634,7 @@ int class_config_dump_handler(const struct lu_env *env,
        int      rc = 0;
 
        outstr = kzalloc(256, GFP_NOFS);
-       if (outstr == NULL)
+       if (!outstr)
                return -ENOMEM;
 
        if (rec->lrh_type == OBD_CFG_REC) {
index ce4a71f..3e0b8a4 100644 (file)
@@ -85,7 +85,7 @@ int lustre_process_log(struct super_block *sb, char *logname,
        LASSERT(cfg);
 
        bufs = kzalloc(sizeof(*bufs), GFP_NOFS);
-       if (bufs == NULL)
+       if (!bufs)
                return -ENOMEM;
 
        /* mgc_process_config */
@@ -258,7 +258,7 @@ int lustre_start_mgc(struct super_block *sb)
        mgssec = lsi->lsi_lmd->lmd_mgssec ? lsi->lsi_lmd->lmd_mgssec : "";
 
        data = kzalloc(sizeof(*data), GFP_NOFS);
-       if (data == NULL) {
+       if (!data) {
                rc = -ENOMEM;
                goto out_free;
        }
@@ -885,7 +885,7 @@ static int lmd_parse_mgssec(struct lustre_mount_data *lmd, char *ptr)
                length = tail - ptr;
 
        lmd->lmd_mgssec = kzalloc(length + 1, GFP_NOFS);
-       if (lmd->lmd_mgssec == NULL)
+       if (!lmd->lmd_mgssec)
                return -ENOMEM;
 
        memcpy(lmd->lmd_mgssec, ptr, length);
@@ -911,7 +911,7 @@ static int lmd_parse_string(char **handle, char *ptr)
                length = tail - ptr;
 
        *handle = kzalloc(length + 1, GFP_NOFS);
-       if (*handle == NULL)
+       if (!*handle)
                return -ENOMEM;
 
        memcpy(*handle, ptr, length);
@@ -941,7 +941,7 @@ static int lmd_parse_mgs(struct lustre_mount_data *lmd, char **ptr)
                oldlen = strlen(lmd->lmd_mgs) + 1;
 
        mgsnid = kzalloc(oldlen + length + 1, GFP_NOFS);
-       if (mgsnid == NULL)
+       if (!mgsnid)
                return -ENOMEM;
 
        if (lmd->lmd_mgs != NULL) {
@@ -983,7 +983,7 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd)
        lmd->lmd_magic = LMD_MAGIC;
 
        lmd->lmd_params = kzalloc(4096, GFP_NOFS);
-       if (lmd->lmd_params == NULL)
+       if (!lmd->lmd_params)
                return -ENOMEM;
        lmd->lmd_params[0] = '\0';
 
index ff0a01b..b0b0157 100644 (file)
 #include "../include/obd_support.h"
 #include "../include/obd_class.h"
 
-
-static inline __u32 consume(int nob, __u8 **ptr)
-{
-       __u32 value;
-
-       LASSERT(nob <= sizeof(value));
-
-       for (value = 0; nob > 0; --nob)
-               value = (value << 8) | *((*ptr)++);
-       return value;
-}
-
-#define CONSUME(val, ptr) (val) = consume(sizeof(val), (ptr))
-
-static void uuid_unpack(class_uuid_t in, __u16 *uu, int nr)
-{
-       __u8 *ptr = in;
-
-       LASSERT(nr * sizeof(*uu) == sizeof(class_uuid_t));
-
-       while (nr-- > 0)
-               CONSUME(uu[nr], &ptr);
-}
-
 void class_uuid_unparse(class_uuid_t uu, struct obd_uuid *out)
 {
-       /* uu as an array of __u16's */
-       __u16 uuid[sizeof(class_uuid_t) / sizeof(__u16)];
-
-       CLASSERT(ARRAY_SIZE(uuid) == 8);
-
-       uuid_unpack(uu, uuid, ARRAY_SIZE(uuid));
-       sprintf(out->uuid, "%04x%04x-%04x-%04x-%04x-%04x%04x%04x",
-               uuid[0], uuid[1], uuid[2], uuid[3],
-               uuid[4], uuid[5], uuid[6], uuid[7]);
+       sprintf(out->uuid, "%pU", uu);
 }
 EXPORT_SYMBOL(class_uuid_unparse);
index 0222fd2..de6f795 100644 (file)
@@ -480,11 +480,11 @@ static int echo_alloc_memmd(struct echo_device *ed,
 
        LASSERT(*lsmp == NULL);
        *lsmp = kzalloc(lsm_size, GFP_NOFS);
-       if (*lsmp == NULL)
+       if (!*lsmp)
                return -ENOMEM;
 
        (*lsmp)->lsm_oinfo[0] = kzalloc(sizeof(struct lov_oinfo), GFP_NOFS);
-       if ((*lsmp)->lsm_oinfo[0] == NULL) {
+       if (!(*lsmp)->lsm_oinfo[0]) {
                kfree(*lsmp);
                return -ENOMEM;
        }
@@ -701,7 +701,7 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env,
        int cleanup = 0;
 
        ed = kzalloc(sizeof(*ed), GFP_NOFS);
-       if (ed == NULL) {
+       if (!ed) {
                rc = -ENOMEM;
                goto out;
        }
@@ -1878,7 +1878,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                return rc;
 
        env = kzalloc(sizeof(*env), GFP_NOFS);
-       if (env == NULL)
+       if (!env)
                return -ENOMEM;
 
        rc = lu_env_init(env, LCT_DT_THREAD);
@@ -2049,7 +2049,7 @@ static int echo_client_setup(const struct lu_env *env,
        ec->ec_nstripes = 0;
 
        ocd = kzalloc(sizeof(*ocd), GFP_NOFS);
-       if (ocd == NULL) {
+       if (!ocd) {
                CERROR("Can't alloc ocd connecting to %s\n",
                       lustre_cfg_string(lcfg, 1));
                return -ENOMEM;
index 5592d32..c72035e 100644 (file)
@@ -1837,12 +1837,6 @@ static int try_to_add_extent_for_io(struct client_obd *cli,
                oap2 = list_first_entry(&tmp->oe_pages, struct osc_async_page,
                                        oap_pending_item);
                EASSERT(tmp->oe_owner == current, tmp);
-#if 0
-               if (overlapped(tmp, ext)) {
-                       OSC_EXTENT_DUMP(D_ERROR, tmp, "overlapped %p.\n", ext);
-                       EASSERT(0, ext);
-               }
-#endif
                if (oap2cl_page(oap)->cp_type != oap2cl_page(oap2)->cp_type) {
                        CDEBUG(D_CACHE, "Do not permit different type of IO"
                                        " for a same RPC\n");
index 9222c9f..91fdec4 100644 (file)
@@ -218,7 +218,7 @@ static struct lu_device *osc_device_alloc(const struct lu_env *env,
        int rc;
 
        od = kzalloc(sizeof(*od), GFP_NOFS);
-       if (od == NULL)
+       if (!od)
                return ERR_PTR(-ENOMEM);
 
        cl_device_init(&od->od_cl, t);
index 43dfa73..f9cf5ce 100644 (file)
@@ -471,7 +471,7 @@ static int osc_page_flush(const struct lu_env *env,
                          struct cl_io *io)
 {
        struct osc_page *opg = cl2osc_page(slice);
-       int rc = 0;
+       int rc;
 
        rc = osc_flush_async_page(env, io, opg);
        return rc;
index f84b4c7..96c80e9 100644 (file)
@@ -119,7 +119,7 @@ static int osc_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
 
        if (*lmmp == NULL) {
                *lmmp = kzalloc(lmm_size, GFP_NOFS);
-               if (*lmmp == NULL)
+               if (!*lmmp)
                        return -ENOMEM;
        }
 
@@ -1909,7 +1909,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli,
                mpflag = cfs_memory_pressure_get_and_set();
 
        crattr = kzalloc(sizeof(*crattr), GFP_NOFS);
-       if (crattr == NULL) {
+       if (!crattr) {
                rc = -ENOMEM;
                goto out;
        }
index a12cd66..c83a34a 100644 (file)
@@ -971,7 +971,7 @@ int ptlrpc_set_add_cb(struct ptlrpc_request_set *set,
        struct ptlrpc_set_cbdata *cbdata;
 
        cbdata = kzalloc(sizeof(*cbdata), GFP_NOFS);
-       if (cbdata == NULL)
+       if (!cbdata)
                return -ENOMEM;
 
        cbdata->psc_interpret = fn;
index c9b8481..1eae389 100644 (file)
@@ -555,14 +555,12 @@ static int import_select_connection(struct obd_import *imp)
        imp_conn->oic_last_attempt = cfs_time_current_64();
 
        /* switch connection, don't mind if it's same as the current one */
-       if (imp->imp_connection)
-               ptlrpc_connection_put(imp->imp_connection);
+       ptlrpc_connection_put(imp->imp_connection);
        imp->imp_connection = ptlrpc_connection_addref(imp_conn->oic_conn);
 
        dlmexp = class_conn2export(&imp->imp_dlm_handle);
        LASSERT(dlmexp != NULL);
-       if (dlmexp->exp_connection)
-               ptlrpc_connection_put(dlmexp->exp_connection);
+       ptlrpc_connection_put(dlmexp->exp_connection);
        dlmexp->exp_connection = ptlrpc_connection_addref(imp_conn->oic_conn);
        class_export_put(dlmexp);
 
index aaaabbf..53f9af1 100644 (file)
@@ -652,7 +652,7 @@ static ssize_t ptlrpc_lprocfs_nrs_seq_write(struct file *file,
                return -EINVAL;
 
        cmd = kzalloc(LPROCFS_NRS_WR_MAX_CMD, GFP_NOFS);
-       if (cmd == NULL)
+       if (!cmd)
                return -ENOMEM;
        /**
         * strsep() modifies its argument, so keep a copy
@@ -819,7 +819,7 @@ ptlrpc_lprocfs_svc_req_history_start(struct seq_file *s, loff_t *pos)
        }
 
        srhi = kzalloc(sizeof(*srhi), GFP_NOFS);
-       if (srhi == NULL)
+       if (!srhi)
                return NULL;
 
        srhi->srhi_seq = 0;
@@ -1219,7 +1219,7 @@ int lprocfs_wr_evict_client(struct file *file, const char __user *buffer,
        char *tmpbuf;
 
        kbuf = kzalloc(BUFLEN, GFP_NOFS);
-       if (kbuf == NULL)
+       if (!kbuf)
                return -ENOMEM;
 
        /*
@@ -1303,7 +1303,7 @@ int lprocfs_wr_import(struct file *file, const char __user *buffer,
                return -EINVAL;
 
        kbuf = kzalloc(count + 1, GFP_NOFS);
-       if (kbuf == NULL)
+       if (!kbuf)
                return -ENOMEM;
 
        if (copy_from_user(kbuf, buffer, count)) {
index 9516aca..d37cdd5 100644 (file)
@@ -1156,7 +1156,7 @@ int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf)
        }
 
        desc = kzalloc(sizeof(*desc), GFP_NOFS);
-       if (desc == NULL) {
+       if (!desc) {
                rc = -ENOMEM;
                goto fail;
        }
index 5268887..ae99180 100644 (file)
@@ -51,7 +51,7 @@ extern spinlock_t ptlrpc_rs_debug_lock;
 extern struct mutex pinger_mutex;
 extern struct mutex ptlrpcd_mutex;
 
-__init int ptlrpc_init(void)
+static int __init ptlrpc_init(void)
 {
        int rc, cleanup_phase = 0;
 
index e591cff..17cc81d 100644 (file)
@@ -739,7 +739,7 @@ static int ptlrpcd_init(void)
 
        size = offsetof(struct ptlrpcd, pd_threads[nthreads]);
        ptlrpcds = kzalloc(size, GFP_NOFS);
-       if (ptlrpcds == NULL) {
+       if (!ptlrpcds) {
                rc = -ENOMEM;
                goto out;
        }
index 69d73c4..2ee3e8b 100644 (file)
@@ -415,7 +415,7 @@ static int enc_pools_add_pages(int npages)
 
        for (i = 0; i < npools; i++) {
                pools[i] = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS);
-               if (pools[i] == NULL)
+               if (!pools[i])
                        goto out_pools;
 
                for (j = 0; j < PAGES_PER_POOL && alloced < npages; j++) {
index 31da43e..e7f2f33 100644 (file)
@@ -564,7 +564,7 @@ struct sptlrpc_conf *sptlrpc_conf_get(const char *fsname,
                return NULL;
 
        conf = kzalloc(sizeof(*conf), GFP_NOFS);
-       if (conf == NULL)
+       if (!conf)
                return NULL;
 
        strcpy(conf->sc_fsname, fsname);
index 53ce0d1..a243db6 100644 (file)
@@ -444,7 +444,7 @@ struct ptlrpc_sec *plain_create_sec(struct obd_import *imp,
        LASSERT(SPTLRPC_FLVR_POLICY(sf->sf_rpc) == SPTLRPC_POLICY_PLAIN);
 
        plsec = kzalloc(sizeof(*plsec), GFP_NOFS);
-       if (plsec == NULL)
+       if (!plsec)
                return NULL;
 
        /*
index 9117f1c..cf9477d 100644 (file)
@@ -732,7 +732,7 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf,
 
        service = kzalloc(offsetof(struct ptlrpc_service, srv_parts[ncpts]),
                          GFP_NOFS);
-       if (service == NULL) {
+       if (!service) {
                kfree(cpts);
                return ERR_PTR(-ENOMEM);
        }
@@ -2298,7 +2298,7 @@ static int ptlrpc_main(void *arg)
        }
 
        env = kzalloc(sizeof(*env), GFP_NOFS);
-       if (env == NULL) {
+       if (!env) {
                rc = -ENOMEM;
                goto out_srv_fini;
        }
@@ -2826,9 +2826,7 @@ void ptlrpc_hr_fini(void)
        ptlrpc_stop_hr_threads();
 
        cfs_percpt_for_each(hrp, i, ptlrpc_hr.hr_partitions) {
-               if (hrp->hrp_thrs != NULL) {
-                       kfree(hrp->hrp_thrs);
-               }
+               kfree(hrp->hrp_thrs);
        }
 
        cfs_percpt_free(ptlrpc_hr.hr_partitions);
index 1e302e8..873e2cf 100644 (file)
@@ -40,6 +40,109 @@ Description:
                               e.g. dd.1253
                nodelocal - use jobid_name value from above.
 
+What:          /sys/fs/lustre/timeout
+Date:          June 2015
+Contact:       "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+               Controls "lustre timeout" variable, also known as obd_timeout
+               in some old manual. In the past obd_timeout was of paramount
+               importance as the timeout value used everywhere and where
+               other timeouts were derived from. These days it's much less
+               important as network timeouts are mostly determined by
+               AT (adaptive timeouts).
+               Unit: seconds, default: 100
+
+What:          /sys/fs/lustre/max_dirty_mb
+Date:          June 2015
+Contact:       "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+               Controls total number of dirty cache (in megabytes) allowed
+               across all mounted lustre filesystems.
+               Since writeout of dirty pages in Lustre is somewhat expensive,
+               when you allow to many dirty pages, this might lead to
+               performance degradations as kernel tries to desperately
+               find some pages to free/writeout.
+               Default 1/2 RAM. Min value 4, max value 9/10 of RAM.
+
+What:          /sys/fs/lustre/debug_peer_on_timeout
+Date:          June 2015
+Contact:       "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+               Control if lnet debug information should be printed when
+               an RPC timeout occurs.
+               0 disabled (default)
+               1 enabled
+
+What:          /sys/fs/lustre/dump_on_timeout
+Date:          June 2015
+Contact:       "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+               Controls if Lustre debug log should be dumped when an RPC
+               timeout occurs. This is useful if yout debug buffer typically
+               rolls over by the time you notice RPC timeouts.
+
+What:          /sys/fs/lustre/dump_on_eviction
+Date:          June 2015
+Contact:       "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+               Controls if Lustre debug log should be dumped when an this
+               client is evicted from one of the servers.
+               This is useful if yout debug buffer typically rolls over
+                by the time you notice the eviction event.
+
+What:          /sys/fs/lustre/at_min
+Date:          July 2015
+Contact:       "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+               Controls minimum adaptive timeout in seconds. If you encounter
+               a case where clients timeout due to server-reported processing
+               time being too short, you might consider increasing this value.
+               One common case of this if the underlying network has
+               unpredictable long delays.
+               Default: 0
+
+What:          /sys/fs/lustre/at_max
+Date:          July 2015
+Contact:       "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+               Controls maximum adaptive timeout in seconds. If at_max timeout
+               is reached for an RPC, the RPC will time out.
+               Some genuinuely slow network hardware might warrant increasing
+               this value.
+               Setting this value to 0 disables Adaptive Timeouts
+               functionality and old-style obd_timeout value is then used.
+               Default: 600
+
+What:          /sys/fs/lustre/at_extra
+Date:          July 2015
+Contact:       "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+               Controls how much extra time to request for unfinished requests
+               in processing in seconds. Normally a server-side parameter, it
+               is also used on the client for responses to various LDLM ASTs
+               that are handled with a special server thread on the client.
+               This is a way for the servers to ask the clients not to time
+               out the request that reached current servicing time estimate
+               yet and give it some more time.
+               Default: 30
+
+What:          /sys/fs/lustre/at_early_margin
+Date:          July 2015
+Contact:       "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+               Controls when to send the early reply for requests that are
+               about to timeout as an offset to the estimated service time in
+               seconds..
+               Default: 5
+
+What:          /sys/fs/lustre/at_history
+Date:          July 2015
+Contact:       "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+               Controls for how many seconds to remember slowest events
+               encountered by adaptive timeouts code.
+               Default: 600
+
 What:          /sys/fs/lustre/llite/<fsname>-<uuid>/blocksize
 Date:          May 2015
 Contact:       "Oleg Drokin" <oleg.drokin@intel.com>
index 7285c64..ad30ce4 100644 (file)
@@ -948,7 +948,6 @@ static const struct of_device_id spinand_dt[] = {
 static struct spi_driver spinand_driver = {
        .driver = {
                .name           = "mt29f",
-               .bus            = &spi_bus_type,
                .owner          = THIS_MODULE,
                .of_match_table = spinand_dt,
        },
index 7c1c1b0..e2df041 100644 (file)
@@ -396,10 +396,12 @@ dont_put_skbuff_in_hw:
 
        /* Check if we can use the hardware checksumming */
        if ((skb->protocol == htons(ETH_P_IP)) &&
-           (ip_hdr(skb)->version == 4) && (ip_hdr(skb)->ihl == 5) &&
-           ((ip_hdr(skb)->frag_off == 0) || (ip_hdr(skb)->frag_off == htons(1 << 14)))
-           && ((ip_hdr(skb)->protocol == IPPROTO_TCP)
-               || (ip_hdr(skb)->protocol == IPPROTO_UDP))) {
+           (ip_hdr(skb)->version == 4) &&
+           (ip_hdr(skb)->ihl == 5) &&
+           ((ip_hdr(skb)->frag_off == 0) ||
+            (ip_hdr(skb)->frag_off == htons(1 << 14))) &&
+           ((ip_hdr(skb)->protocol == IPPROTO_TCP) ||
+            (ip_hdr(skb)->protocol == IPPROTO_UDP))) {
                /* Use hardware checksum calc */
                pko_command.s.ipoffp1 = sizeof(struct ethhdr) + 1;
        }
index 301fee8..b6cfecb 100644 (file)
@@ -327,6 +327,7 @@ static void oz_usb_handle_ep_data(struct oz_usb_ctx *usb_ctx,
                                (struct oz_multiple_fixed *)data_hdr;
                        u8 *data = body->data;
                        unsigned int n;
+
                        if (!body->unit_size ||
                                len < sizeof(struct oz_multiple_fixed) - 1)
                                break;
index 581af88..5c45f8a 100644 (file)
@@ -379,7 +379,8 @@ void        expire_timeout_chk(struct adapter *padapter)
                        if (pmlmeext->active_keep_alive_check) {
                                int stainfo_offset;
 
-                               stainfo_offset = rtw_stainfo_offset(pstapriv, psta);
+                               stainfo_offset =
+                                       rtw_stainfo_offset(pstapriv, psta);
                                if (stainfo_offset_valid(stainfo_offset))
                                        chk_alive_list[chk_alive_num++] = stainfo_offset;
                                continue;
@@ -1584,7 +1585,7 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta)
                }
        }
 
-       if (!(psta->capability & WLAN_CAPABILITY_SHORT_SLOT)) {
+       if (!(psta->capability & WLAN_CAPABILITY_SHORT_SLOT_TIME)) {
                if (!psta->no_short_slot_time_set) {
                        psta->no_short_slot_time_set = 1;
 
index 11b780d..d43e867 100644 (file)
@@ -19,6 +19,8 @@
  ******************************************************************************/
 #define _IEEE80211_C
 
+#include <linux/ieee80211.h>
+
 #include <drv_types.h>
 #include <osdep_intf.h>
 #include <ieee80211.h>
index 0558451..2b599e3 100644 (file)
@@ -19,6 +19,7 @@
  ******************************************************************************/
 #define _RTW_MLME_C_
 
+#include <linux/ieee80211.h>
 
 #include <osdep_service.h>
 #include <drv_types.h>
@@ -160,7 +161,7 @@ exit:
        return pnetwork;
 }
 
-static void _rtw_free_network(struct   mlme_priv *pmlmepriv , struct wlan_network *pnetwork, u8 isfreeall)
+static void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork, u8 isfreeall)
 {
        u32 curr_time, delta_time;
        u32 lifetime = SCANQUEUE_LIFETIME;
@@ -352,8 +353,8 @@ int is_same_network(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst)
                ((!memcmp(src->Ssid.Ssid, dst->Ssid.Ssid, src->Ssid.SsidLength)) == true) &&
                ((s_cap & WLAN_CAPABILITY_IBSS) ==
                (d_cap & WLAN_CAPABILITY_IBSS)) &&
-               ((s_cap & WLAN_CAPABILITY_BSS) ==
-               (d_cap & WLAN_CAPABILITY_BSS)));
+               ((s_cap & WLAN_CAPABILITY_ESS) ==
+               (d_cap & WLAN_CAPABILITY_ESS)));
 }
 
 struct wlan_network    *rtw_get_oldest_wlan_network(struct __queue *scanned_queue)
@@ -581,7 +582,7 @@ static int rtw_is_desired_network(struct adapter *adapter, struct wlan_network *
 }
 
 /* TODO: Perry: For Power Management */
-void rtw_atimdone_event_callback(struct adapter        *adapter , u8 *pbuf)
+void rtw_atimdone_event_callback(struct adapter *adapter, u8 *pbuf)
 {
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("receive atimdone_evet\n"));
        return;
@@ -614,7 +615,7 @@ void rtw_survey_event_callback(struct adapter       *adapter, u8 *pbuf)
                        spin_lock_bh(&(pmlmepriv->scanned_queue.lock));
                        ibss_wlan = rtw_find_network(&pmlmepriv->scanned_queue,  pnetwork->MacAddress);
                        if (ibss_wlan) {
-                               memcpy(ibss_wlan->network.IEs , pnetwork->IEs, 8);
+                               memcpy(ibss_wlan->network.IEs, pnetwork->IEs, 8);
                                spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
                                goto exit;
                        }
@@ -1382,7 +1383,7 @@ void _rtw_join_timeout_handler (unsigned long data)
                                DBG_88E("%s try another roaming\n", __func__);
                                do_join_r = rtw_do_join(adapter);
                                if (_SUCCESS != do_join_r) {
-                                       DBG_88E("%s roaming do_join return %d\n", __func__ , do_join_r);
+                                       DBG_88E("%s roaming do_join return %d\n", __func__, do_join_r);
                                        continue;
                                }
                                break;
@@ -1997,7 +1998,7 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_
                p = rtw_get_ie(in_ie+12, _HT_ADD_INFO_IE_, &ielen, in_len-12);
                if (p && (ielen == sizeof(struct ieee80211_ht_addt_info))) {
                        out_len = *pout_len;
-                       rtw_set_ie(out_ie+out_len, _HT_ADD_INFO_IE_, ielen, p+2 , pout_len);
+                       rtw_set_ie(out_ie+out_len, _HT_ADD_INFO_IE_, ielen, p+2, pout_len);
                }
        }
        return phtpriv->ht_option;
index a0b8f66..ba8f9aa 100644 (file)
@@ -3367,7 +3367,7 @@ static unsigned int OnAssocReq(struct adapter *padapter,
        spin_unlock_bh(&pstapriv->asoc_list_lock);
 
        /*  now the station is qualified to join our BSS... */
-       if (pstat && (pstat->state & WIFI_FW_ASSOC_SUCCESS) && (_STATS_SUCCESSFUL_ == status)) {
+       if ((pstat->state & WIFI_FW_ASSOC_SUCCESS) && (_STATS_SUCCESSFUL_ == status)) {
                /* 1 bss_cap_update & sta_info_update */
                bss_cap_update_on_sta_join(padapter, pstat);
                sta_info_update(padapter, pstat);
index ec0a8a4..a2b54de 100644 (file)
@@ -549,12 +549,6 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter)
                    (unsigned long)padapter);
 }
 
-inline void rtw_set_ips_deny(struct adapter *padapter, u32 ms)
-{
-       struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
-       pwrpriv->ips_deny_time = jiffies + msecs_to_jiffies(ms);
-}
-
 /*
 * rtw_pwr_wakeup - Wake the NIC up from: 1)IPS. 2)USB autosuspend
 * @adapter: pointer to struct adapter structure
index 32300df..077b39a 100644 (file)
@@ -19,6 +19,8 @@
  ******************************************************************************/
 #define _RTW_WLAN_UTIL_C_
 
+#include <linux/ieee80211.h>
+
 #include <osdep_service.h>
 #include <drv_types.h>
 #include <wifi.h>
index 170e3de..38e9fdc 100644 (file)
@@ -31,18 +31,7 @@ void dump_chip_info(struct HAL_VERSION       chip_vers)
        uint cnt = 0;
        char buf[128];
 
-       if (IS_81XXC(chip_vers)) {
-               cnt += sprintf((buf+cnt), "Chip Version Info: %s_",
-                              IS_92C_SERIAL(chip_vers) ?
-                              "CHIP_8192C" : "CHIP_8188C");
-       } else if (IS_92D(chip_vers)) {
-               cnt += sprintf((buf+cnt), "Chip Version Info: CHIP_8192D_");
-       } else if (IS_8723_SERIES(chip_vers)) {
-               cnt += sprintf((buf+cnt), "Chip Version Info: CHIP_8723A_");
-       } else if (IS_8188E(chip_vers)) {
-               cnt += sprintf((buf+cnt), "Chip Version Info: CHIP_8188E_");
-       }
-
+       cnt += sprintf((buf+cnt), "Chip Version Info: CHIP_8188E_");
        cnt += sprintf((buf+cnt), "%s_", IS_NORMAL_CHIP(chip_vers) ?
                       "Normal_Chip" : "Test_Chip");
        cnt += sprintf((buf+cnt), "%s_", IS_CHIP_VENDOR_TSMC(chip_vers) ?
@@ -60,18 +49,8 @@ void dump_chip_info(struct HAL_VERSION       chip_vers)
        else
                cnt += sprintf((buf+cnt), "UNKNOWN_CUT(%d)_",
                               chip_vers.CUTVersion);
-
-       if (IS_1T1R(chip_vers))
-               cnt += sprintf((buf+cnt), "1T1R_");
-       else if (IS_1T2R(chip_vers))
-               cnt += sprintf((buf+cnt), "1T2R_");
-       else if (IS_2T2R(chip_vers))
-               cnt += sprintf((buf+cnt), "2T2R_");
-       else
-               cnt += sprintf((buf+cnt), "UNKNOWN_RFTYPE(%d)_",
-                              chip_vers.RFType);
-
-       cnt += sprintf((buf+cnt), "RomVer(%d)\n", chip_vers.ROMVer);
+       cnt += sprintf((buf+cnt), "1T1R_");
+       cnt += sprintf((buf+cnt), "RomVer(0)\n");
 
        pr_info("%s", buf);
 }
index 5edb5c4..85c17ef 100644 (file)
@@ -131,14 +131,6 @@ void rtw_hal_get_hwreg(struct adapter *adapt, u8 variable, u8 *val)
                adapt->HalFunc.GetHwRegHandler(adapt, variable, val);
 }
 
-u8 rtw_hal_set_def_var(struct adapter *adapt, enum hal_def_variable var,
-                     void *val)
-{
-       if (adapt->HalFunc.SetHalDefVarHandler)
-               return adapt->HalFunc.SetHalDefVarHandler(adapt, var, val);
-       return _FAIL;
-}
-
 u8 rtw_hal_get_def_var(struct adapter *adapt,
                       enum hal_def_variable var, void *val)
 {
@@ -156,22 +148,6 @@ void rtw_hal_set_odm_var(struct adapter *adapt,
                                                      val1, set);
 }
 
-void rtw_hal_enable_interrupt(struct adapter *adapt)
-{
-       if (adapt->HalFunc.enable_interrupt)
-               adapt->HalFunc.enable_interrupt(adapt);
-       else
-               DBG_88E("%s: HalFunc.enable_interrupt is NULL!\n", __func__);
-}
-
-void rtw_hal_disable_interrupt(struct adapter *adapt)
-{
-       if (adapt->HalFunc.disable_interrupt)
-               adapt->HalFunc.disable_interrupt(adapt);
-       else
-               DBG_88E("%s: HalFunc.disable_interrupt is NULL!\n", __func__);
-}
-
 u32 rtw_hal_inirp_init(struct adapter *adapt)
 {
        u32 rst = _FAIL;
@@ -269,14 +245,6 @@ u32 rtw_hal_read_rfreg(struct adapter *adapt, enum rf_radio_path rfpath,
        return data;
 }
 
-void rtw_hal_write_rfreg(struct adapter *adapt, enum rf_radio_path rfpath,
-                        u32 regaddr, u32 bitmask, u32 data)
-{
-       if (adapt->HalFunc.write_rfreg)
-               adapt->HalFunc.write_rfreg(adapt, rfpath, regaddr,
-                                             bitmask, data);
-}
-
 void rtw_hal_set_bwmode(struct adapter *adapt,
                        enum ht_channel_width bandwidth, u8 offset)
 {
index 455ecdc..954cade 100644 (file)
@@ -295,7 +295,7 @@ static bool rf6052_conf_para(struct adapter *adapt)
                        break;
                }
 
-               if (rtstatus != true)
+               if (!rtstatus)
                        return false;
        }
 
index 7904d22..a6295ca 100644 (file)
@@ -128,7 +128,7 @@ static void rtl8188e_free_hal_data(struct adapter *padapter)
        padapter->HalData = NULL;
 }
 
-static struct HAL_VERSION ReadChipVersion8188E(struct adapter *padapter)
+static void ReadChipVersion8188E(struct adapter *padapter)
 {
        u32                             value32;
        struct HAL_VERSION              ChipVersion;
@@ -137,41 +137,17 @@ static struct HAL_VERSION ReadChipVersion8188E(struct adapter *padapter)
        pHalData = GET_HAL_DATA(padapter);
 
        value32 = usb_read32(padapter, REG_SYS_CFG);
-       ChipVersion.ICType = CHIP_8188E;
        ChipVersion.ChipType = ((value32 & RTL_ID) ? TEST_CHIP : NORMAL_CHIP);
-
-       ChipVersion.RFType = RF_TYPE_1T1R;
        ChipVersion.VendorType = ((value32 & VENDOR_ID) ? CHIP_VENDOR_UMC : CHIP_VENDOR_TSMC);
        ChipVersion.CUTVersion = (value32 & CHIP_VER_RTL_MASK)>>CHIP_VER_RTL_SHIFT; /*  IC version (CUT) */
 
-       /*  For regulator mode. by tynli. 2011.01.14 */
-       pHalData->RegulatorMode = ((value32 & TRP_BT_EN) ? RT_LDO_REGULATOR : RT_SWITCHING_REGULATOR);
-
-       ChipVersion.ROMVer = 0; /*  ROM code version. */
-
        dump_chip_info(ChipVersion);
 
        pHalData->VersionID = ChipVersion;
-
-       if (IS_1T2R(ChipVersion)) {
-               pHalData->rf_type = RF_1T2R;
-               pHalData->NumTotalRFPath = 2;
-       } else if (IS_2T2R(ChipVersion)) {
-               pHalData->rf_type = RF_2T2R;
-               pHalData->NumTotalRFPath = 2;
-       } else{
-               pHalData->rf_type = RF_1T1R;
-               pHalData->NumTotalRFPath = 1;
-       }
+       pHalData->rf_type = RF_1T1R;
+       pHalData->NumTotalRFPath = 1;
 
        MSG_88E("RF_Type is %x!!\n", pHalData->rf_type);
-
-       return ChipVersion;
-}
-
-static void rtl8188e_read_chip_version(struct adapter *padapter)
-{
-       ReadChipVersion8188E(padapter);
 }
 
 static void rtl8188e_SetHalODMVar(struct adapter *Adapter, enum hal_odm_variable eVariable, void *pValue1, bool bSet)
@@ -220,7 +196,7 @@ void rtl8188e_set_hal_ops(struct hal_ops *pHalFunc)
 
        pHalFunc->dm_init = &rtl8188e_init_dm_priv;
 
-       pHalFunc->read_chip_version = &rtl8188e_read_chip_version;
+       pHalFunc->read_chip_version = &ReadChipVersion8188E;
 
        pHalFunc->set_bwmode_handler = &phy_set_bw_mode;
        pHalFunc->set_channel_handler = &phy_sw_chnl;
@@ -232,7 +208,6 @@ void rtl8188e_set_hal_ops(struct hal_ops *pHalFunc)
        pHalFunc->AntDivBeforeLinkHandler = &AntDivBeforeLink8188E;
        pHalFunc->AntDivCompareHandler = &AntDivCompare8188E;
        pHalFunc->read_rfreg = &phy_query_rf_reg;
-       pHalFunc->write_rfreg = &phy_set_rf_reg;
 
        pHalFunc->sreset_init_value = &sreset_init_value;
        pHalFunc->sreset_get_wifi_status  = &sreset_get_wifi_status;
index 8726222..6dc0869 100644 (file)
@@ -1703,7 +1703,7 @@ static void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val)
 
                        /*  Forece leave RF low power mode for 1T1R to prevent conficting setting in Fw power */
                        /*  saving sequence. 2010.06.07. Added by tynli. Suggested by SD3 yschang. */
-                       if ((psmode != PS_MODE_ACTIVE) && (!IS_92C_SERIAL(haldata->VersionID)))
+                       if (psmode != PS_MODE_ACTIVE)
                                ODM_RF_Saving(podmpriv, true);
                        rtl8188e_set_FwPwrMode_cmd(Adapter, psmode);
                }
@@ -1961,75 +1961,6 @@ GetHalDefVar8188EUsb(
        return bResult;
 }
 
-/*  */
-/*     Description: */
-/*             Change default setting of specified variable. */
-/*  */
-static u8 SetHalDefVar8188EUsb(struct adapter *Adapter, enum hal_def_variable eVariable, void *pValue)
-{
-       struct hal_data_8188e   *haldata = GET_HAL_DATA(Adapter);
-       u8 bResult = _SUCCESS;
-
-       switch (eVariable) {
-       case HAL_DEF_DBG_DM_FUNC:
-               {
-                       u8 dm_func = *((u8 *)pValue);
-                       struct odm_dm_struct *podmpriv = &haldata->odmpriv;
-
-                       if (dm_func == 0) { /* disable all dynamic func */
-                               podmpriv->SupportAbility = DYNAMIC_FUNC_DISABLE;
-                               DBG_88E("==> Disable all dynamic function...\n");
-                       } else if (dm_func == 1) {/* disable DIG */
-                               podmpriv->SupportAbility  &= (~DYNAMIC_BB_DIG);
-                               DBG_88E("==> Disable DIG...\n");
-                       } else if (dm_func == 2) {/* disable High power */
-                               podmpriv->SupportAbility  &= (~DYNAMIC_BB_DYNAMIC_TXPWR);
-                       } else if (dm_func == 3) {/* disable tx power tracking */
-                               podmpriv->SupportAbility  &= (~DYNAMIC_RF_CALIBRATION);
-                               DBG_88E("==> Disable tx power tracking...\n");
-                       } else if (dm_func == 5) {/* disable antenna diversity */
-                               podmpriv->SupportAbility  &= (~DYNAMIC_BB_ANT_DIV);
-                       } else if (dm_func == 6) {/* turn on all dynamic func */
-                               if (!(podmpriv->SupportAbility  & DYNAMIC_BB_DIG)) {
-                                       struct rtw_dig *pDigTable = &podmpriv->DM_DigTable;
-                                       pDigTable->CurIGValue = usb_read8(Adapter, 0xc50);
-                               }
-                               podmpriv->SupportAbility = DYNAMIC_ALL_FUNC_ENABLE;
-                               DBG_88E("==> Turn on all dynamic function...\n");
-                       }
-               }
-               break;
-       case HAL_DEF_DBG_DUMP_RXPKT:
-               haldata->bDumpRxPkt = *((u8 *)pValue);
-               break;
-       case HAL_DEF_DBG_DUMP_TXPKT:
-               haldata->bDumpTxPkt = *((u8 *)pValue);
-               break;
-       case HW_DEF_FA_CNT_DUMP:
-               {
-                       u8 bRSSIDump = *((u8 *)pValue);
-                       struct odm_dm_struct *dm_ocm = &(haldata->odmpriv);
-                       if (bRSSIDump)
-                               dm_ocm->DebugComponents =       ODM_COMP_DIG|ODM_COMP_FA_CNT;
-                       else
-                               dm_ocm->DebugComponents = 0;
-               }
-               break;
-       case HW_DEF_ODM_DBG_FLAG:
-               {
-                       u64     DebugComponents = *((u64 *)pValue);
-                       struct odm_dm_struct *dm_ocm = &(haldata->odmpriv);
-                       dm_ocm->DebugComponents = DebugComponents;
-               }
-               break;
-       default:
-               bResult = _FAIL;
-               break;
-       }
-
-       return bResult;
-}
-
 static void UpdateHalRAMask8188EUsb(struct adapter *adapt, u32 mac_id, u8 rssi_level)
 {
        u8 init_rate = 0;
@@ -2200,7 +2131,6 @@ void rtl8188eu_set_hal_ops(struct adapter *adapt)
        halfunc->SetHwRegHandler = &SetHwReg8188EU;
        halfunc->GetHwRegHandler = &GetHwReg8188EU;
        halfunc->GetHalDefVarHandler = &GetHalDefVar8188EUsb;
-       halfunc->SetHalDefVarHandler = &SetHalDefVar8188EUsb;
 
        halfunc->UpdateRAMaskHandler = &UpdateHalRAMask8188EUsb;
        halfunc->SetBeaconRelatedRegistersHandler = &SetBeaconRelatedRegisters8188EUsb;
index 97047cf..56b4ff0 100644 (file)
 #ifndef __HAL_VERSION_DEF_H__
 #define __HAL_VERSION_DEF_H__
 
-enum HAL_IC_TYPE {
-       CHIP_8192S      =       0,
-       CHIP_8188C      =       1,
-       CHIP_8192C      =       2,
-       CHIP_8192D      =       3,
-       CHIP_8723A      =       4,
-       CHIP_8188E      =       5,
-       CHIP_8881A      =       6,
-       CHIP_8812A      =       7,
-       CHIP_8821A      =       8,
-       CHIP_8723B      =       9,
-       CHIP_8192E      =       10,
-};
-
 enum HAL_CHIP_TYPE {
        TEST_CHIP       =       0,
        NORMAL_CHIP     =       1,
@@ -55,48 +41,20 @@ enum HAL_VENDOR {
        CHIP_VENDOR_UMC         =       1,
 };
 
-enum HAL_RF_TYPE {
-       RF_TYPE_1T1R    =       0,
-       RF_TYPE_1T2R    =       1,
-       RF_TYPE_2T2R    =       2,
-       RF_TYPE_2T3R    =       3,
-       RF_TYPE_2T4R    =       4,
-       RF_TYPE_3T3R    =       5,
-       RF_TYPE_3T4R    =       6,
-       RF_TYPE_4T4R    =       7,
-};
-
 struct HAL_VERSION {
-       enum HAL_IC_TYPE        ICType;
        enum HAL_CHIP_TYPE      ChipType;
        enum HAL_CUT_VERSION    CUTVersion;
        enum HAL_VENDOR         VendorType;
-       enum HAL_RF_TYPE        RFType;
-       u8                      ROMVer;
 };
 
 /*  Get element */
-#define GET_CVID_IC_TYPE(version)      (((version).ICType))
 #define GET_CVID_CHIP_TYPE(version)    (((version).ChipType))
-#define GET_CVID_RF_TYPE(version)      (((version).RFType))
 #define GET_CVID_MANUFACTUER(version)  (((version).VendorType))
 #define GET_CVID_CUT_VERSION(version)  (((version).CUTVersion))
-#define GET_CVID_ROM_VERSION(version)  (((version).ROMVer) & ROM_VERSION_MASK)
 
 /* Common Macro. -- */
 /* HAL_VERSION VersionID */
 
-/*  HAL_IC_TYPE_E */
-#define IS_81XXC(version)                              \
-       (((GET_CVID_IC_TYPE(version) == CHIP_8192C) ||  \
-        (GET_CVID_IC_TYPE(version) == CHIP_8188C)) ? true : false)
-#define IS_8723_SERIES(version)                                \
-       ((GET_CVID_IC_TYPE(version) == CHIP_8723A) ? true : false)
-#define IS_92D(version)                                        \
-       ((GET_CVID_IC_TYPE(version) == CHIP_8192D) ? true : false)
-#define IS_8188E(version)                              \
-       ((GET_CVID_IC_TYPE(version) == CHIP_8188E) ? true : false)
-
 /* HAL_CHIP_TYPE_E */
 #define IS_TEST_CHIP(version)                          \
        ((GET_CVID_CHIP_TYPE(version) == TEST_CHIP) ? true : false)
@@ -122,46 +80,4 @@ struct HAL_VERSION {
 #define IS_CHIP_VENDOR_UMC(version)                    \
        ((GET_CVID_MANUFACTUER(version) == CHIP_VENDOR_UMC) ? true : false)
 
-/* HAL_RF_TYPE_E */
-#define IS_1T1R(version)                               \
-       ((GET_CVID_RF_TYPE(version) == RF_TYPE_1T1R) ? true : false)
-#define IS_1T2R(version)                               \
-       ((GET_CVID_RF_TYPE(version) == RF_TYPE_1T2R) ? true : false)
-#define IS_2T2R(version)                               \
-       ((GET_CVID_RF_TYPE(version) == RF_TYPE_2T2R) ? true : false)
-
-/* Chip version Macro. -- */
-#define IS_81XXC_TEST_CHIP(version)                    \
-       ((IS_81XXC(version) && (!IS_NORMAL_CHIP(version))) ? true : false)
-
-#define IS_92C_SERIAL(version)                         \
-       ((IS_81XXC(version) && IS_2T2R(version)) ? true : false)
-#define IS_81xxC_VENDOR_UMC_A_CUT(version)             \
-       (IS_81XXC(version) ? (IS_CHIP_VENDOR_UMC(version) ?     \
-       (IS_A_CUT(version) ? true : false) : false) : false)
-#define IS_81xxC_VENDOR_UMC_B_CUT(version)             \
-       (IS_81XXC(version) ? (IS_CHIP_VENDOR_UMC(version) ?     \
-       (IS_B_CUT(version) ? true : false) : false) : false)
-#define IS_81xxC_VENDOR_UMC_C_CUT(version)             \
-       (IS_81XXC(version) ? (IS_CHIP_VENDOR_UMC(version) ? \
-        (IS_C_CUT(version) ? true : false) : false) : false)
-
-#define IS_NORMAL_CHIP92D(version)                     \
-       ((IS_92D(version)) ?                            \
-       ((GET_CVID_CHIP_TYPE(version) == NORMAL_CHIP) ? true : false) : false)
-
-#define IS_92D_SINGLEPHY(version)                      \
-       ((IS_92D(version)) ? (IS_2T2R(version) ? true : false) : false)
-#define IS_92D_C_CUT(version)                          \
-       ((IS_92D(version)) ? (IS_C_CUT(version) ? true : false) : false)
-#define IS_92D_D_CUT(version)                          \
-       ((IS_92D(version)) ? (IS_D_CUT(version) ? true : false) : false)
-#define IS_92D_E_CUT(version)                          \
-       ((IS_92D(version)) ? (IS_E_CUT(version) ? true : false) : false)
-
-#define IS_8723A_A_CUT(version)                                \
-       ((IS_8723_SERIES(version)) ? (IS_A_CUT(version) ? true : false) : false)
-#define IS_8723A_B_CUT(version)                                \
-       ((IS_8723_SERIES(version)) ? (IS_B_CUT(version) ? true : false) : false)
-
 #endif
index 3b476d8..e73c634 100644 (file)
@@ -171,8 +171,6 @@ struct hal_ops {
 
        void    (*read_adapter_info)(struct adapter *padapter);
 
-       void    (*enable_interrupt)(struct adapter *padapter);
-       void    (*disable_interrupt)(struct adapter *padapter);
        s32     (*interrupt_handler)(struct adapter *padapter);
 
        void    (*set_bwmode_handler)(struct adapter *padapter,
@@ -190,9 +188,6 @@ struct hal_ops {
        u8      (*GetHalDefVarHandler)(struct adapter *padapter,
                                       enum hal_def_variable eVariable,
                                       void *pValue);
-       u8      (*SetHalDefVarHandler)(struct adapter *padapter,
-                                      enum hal_def_variable eVariable,
-                                      void *pValue);
 
        void    (*SetHalODMVarHandler)(struct adapter *padapter,
                                       enum hal_odm_variable eVariable,
@@ -216,9 +211,6 @@ struct hal_ops {
        u32     (*read_rfreg)(struct adapter *padapter,
                              enum rf_radio_path eRFPath, u32 RegAddr,
                              u32 BitMask);
-       void    (*write_rfreg)(struct adapter *padapter,
-                              enum rf_radio_path eRFPath, u32 RegAddr,
-                              u32 BitMask, u32 Data);
 
        void (*sreset_init_value)(struct adapter *padapter);
        u8 (*sreset_get_wifi_status)(struct adapter *padapter);
@@ -267,8 +259,6 @@ void rtw_hal_chip_configure(struct adapter *padapter);
 void rtw_hal_read_chip_info(struct adapter *padapter);
 void rtw_hal_read_chip_version(struct adapter *padapter);
 
-u8 rtw_hal_set_def_var(struct adapter *padapter,
-                      enum hal_def_variable eVariable, void *pValue);
 u8 rtw_hal_get_def_var(struct adapter *padapter,
                       enum hal_def_variable eVariable, void *pValue);
 
@@ -276,9 +266,6 @@ void rtw_hal_set_odm_var(struct adapter *padapter,
                         enum hal_odm_variable eVariable, void *pValue1,
                         bool bSet);
 
-void rtw_hal_enable_interrupt(struct adapter *padapter);
-void rtw_hal_disable_interrupt(struct adapter *padapter);
-
 u32    rtw_hal_inirp_init(struct adapter *padapter);
 u32    rtw_hal_inirp_deinit(struct adapter *padapter);
 
@@ -300,9 +287,6 @@ void rtw_hal_bcn_related_reg_setting(struct adapter *padapter);
 
 u32    rtw_hal_read_rfreg(struct adapter *padapter, enum rf_radio_path eRFPath,
                           u32 RegAddr, u32 BitMask);
-void   rtw_hal_write_rfreg(struct adapter *padapter,
-                           enum rf_radio_path eRFPath, u32 RegAddr,
-                           u32 BitMask, u32 Data);
 
 void   rtw_hal_set_bwmode(struct adapter *padapter,
                           enum ht_channel_width Bandwidth, u8 Offset);
index b129ad1..fabb959 100644 (file)
@@ -483,16 +483,6 @@ struct ieee80211_snap_hdr {
 
 #define WLAN_AUTH_CHALLENGE_LEN 128
 
-#define WLAN_CAPABILITY_BSS (1<<0)
-#define WLAN_CAPABILITY_IBSS (1<<1)
-#define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
-#define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
-#define WLAN_CAPABILITY_PRIVACY (1<<4)
-#define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
-#define WLAN_CAPABILITY_PBCC (1<<6)
-#define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
-#define WLAN_CAPABILITY_SHORT_SLOT (1<<10)
-
 /* Non standard?  Not in <linux/ieee80211.h> */
 #define WLAN_REASON_EXPIRATION_CHK 65535
 
index 7d8e022..5aa2adc 100644 (file)
@@ -188,15 +188,8 @@ struct txpowerinfo24g {
 
 #define EFUSE_PROTECT_BYTES_BANK       16
 
-/*  For RTL8723 regulator mode. */
-enum rt_regulator_mode {
-       RT_SWITCHING_REGULATOR = 0,
-       RT_LDO_REGULATOR = 1,
-};
-
 struct hal_data_8188e {
        struct HAL_VERSION      VersionID;
-       enum rt_regulator_mode RegulatorMode; /*  switching regulator or LDO */
        u16     CustomerID;
        u8 *pfirmware;
        u32 fwsize;
index aa1fd87..a493d4c 100644 (file)
@@ -257,7 +257,6 @@ s32 LPS_RF_ON_check(struct adapter *adapter, u32 delay_ms);
 void LPS_Enter(struct adapter *adapter);
 void LPS_Leave(struct adapter *adapter);
 
-void rtw_set_ips_deny(struct adapter *adapter, u32 ms);
 int _rtw_pwr_wakeup(struct adapter *adapter, u32 ips_defer_ms,
                    const char *caller);
 #define rtw_pwr_wakeup(adapter)                                                \
index 38dba14..ce756cd 100644 (file)
@@ -179,8 +179,8 @@ static char *translate_scan(struct adapter *padapter,
 
        cap = le16_to_cpu(le_tmp);
 
-       if (cap & (WLAN_CAPABILITY_IBSS | WLAN_CAPABILITY_BSS)) {
-               if (cap & WLAN_CAPABILITY_BSS)
+       if (!WLAN_CAPABILITY_IS_STA_BSS(cap)) {
+               if (cap & WLAN_CAPABILITY_ESS)
                        iwe.u.mode = IW_MODE_MASTER;
                else
                        iwe.u.mode = IW_MODE_ADHOC;
index d0d4335..5490b29 100644 (file)
@@ -19,6 +19,7 @@
  ******************************************************************************/
 #define _HCI_INTF_C_
 
+#define pr_fmt(fmt) "R8188EU: " fmt
 #include <osdep_service.h>
 #include <drv_types.h>
 #include <recv_osdep.h>
@@ -55,7 +56,6 @@ MODULE_DEVICE_TABLE(usb, rtw_usb_id_tbl);
 static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf)
 {
        int     i;
-       int     status = _FAIL;
        struct dvobj_priv *pdvobjpriv;
        struct usb_host_config          *phost_conf;
        struct usb_config_descriptor    *pconf_desc;
@@ -115,15 +115,9 @@ static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf)
        mutex_init(&pdvobjpriv->usb_vendor_req_mutex);
        pdvobjpriv->usb_vendor_req_buf = kzalloc(MAX_USB_IO_CTL_SIZE, GFP_KERNEL);
 
-       if (!pdvobjpriv->usb_vendor_req_buf)
-               goto free_dvobj;
-
-       usb_get_dev(pusbd);
-
-       status = _SUCCESS;
-
-free_dvobj:
-       if (status != _SUCCESS && pdvobjpriv) {
+       if (pdvobjpriv->usb_vendor_req_buf) {
+               usb_get_dev(pusbd);
+       } else {
                usb_set_intfdata(usb_intf, NULL);
                kfree(pdvobjpriv);
                pdvobjpriv = NULL;
@@ -150,7 +144,7 @@ static void usb_dvobj_deinit(struct usb_interface *usb_intf)
                                 * on sitesurvey for the first time when
                                 * device is up . Reset usb port for sitesurvey
                                 * fail issue. */
-                               DBG_88E("usb attached..., try to reset usb device\n");
+                               pr_debug("usb attached..., try to reset usb device\n");
                                usb_reset_device(interface_to_usbdev(usb_intf));
                        }
                }
@@ -201,7 +195,7 @@ static void rtw_dev_unload(struct adapter *padapter)
        RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_dev_unload\n"));
 
        if (padapter->bup) {
-               DBG_88E("===> rtw_dev_unload\n");
+               pr_debug("===> rtw_dev_unload\n");
                padapter->bDriverStopped = true;
                if (padapter->xmitpriv.ack_tx)
                        rtw_ack_tx_done(&padapter->xmitpriv, RTW_SCTX_DONE_DRV_STOP);
@@ -224,7 +218,7 @@ static void rtw_dev_unload(struct adapter *padapter)
                         ("r871x_dev_unload():padapter->bup == false\n"));
        }
 
-       DBG_88E("<=== rtw_dev_unload\n");
+       pr_debug("<=== rtw_dev_unload\n");
 
        RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-rtw_dev_unload\n"));
 }
@@ -236,16 +230,13 @@ static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message)
        struct net_device *pnetdev = padapter->pnetdev;
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
-
-       int ret = 0;
        u32 start_time = jiffies;
 
-
-       DBG_88E("==> %s (%s:%d)\n", __func__, current->comm, current->pid);
+       pr_debug("==> %s (%s:%d)\n", __func__, current->comm, current->pid);
 
        if ((!padapter->bup) || (padapter->bDriverStopped) ||
            (padapter->bSurpriseRemoved)) {
-               DBG_88E("padapter->bup=%d bDriverStopped=%d bSurpriseRemoved = %d\n",
+               pr_debug("padapter->bup=%d bDriverStopped=%d bSurpriseRemoved = %d\n",
                        padapter->bup, padapter->bDriverStopped,
                        padapter->bSurpriseRemoved);
                goto exit;
@@ -267,7 +258,7 @@ static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message)
 
        if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) &&
            check_fwstate(pmlmepriv, _FW_LINKED)) {
-               DBG_88E("%s:%d %s(%pM), length:%d assoc_ssid.length:%d\n",
+               pr_debug("%s:%d %s(%pM), length:%d assoc_ssid.length:%d\n",
                        __func__, __LINE__,
                        pmlmepriv->cur_network.network.Ssid.Ssid,
                        pmlmepriv->cur_network.network.MacAddress,
@@ -293,10 +284,10 @@ static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message)
                rtw_indicate_disconnect(padapter);
 
 exit:
-       DBG_88E("<===  %s return %d.............. in %dms\n", __func__
-               , ret, rtw_get_passing_time_ms(start_time));
+       pr_debug("<===  %s .............. in %dms\n", __func__,
+                rtw_get_passing_time_ms(start_time));
 
-       return ret;
+       return 0;
 }
 
 static int rtw_resume_process(struct adapter *padapter)
@@ -306,7 +297,7 @@ static int rtw_resume_process(struct adapter *padapter)
        int ret = -1;
        u32 start_time = jiffies;
 
-       DBG_88E("==> %s (%s:%d)\n", __func__, current->comm, current->pid);
+       pr_debug("==> %s (%s:%d)\n", __func__, current->comm, current->pid);
 
        if (padapter) {
                pnetdev = padapter->pnetdev;
@@ -319,7 +310,7 @@ static int rtw_resume_process(struct adapter *padapter)
        rtw_reset_drv_sw(padapter);
        pwrpriv->bkeepfwalive = false;
 
-       DBG_88E("bkeepfwalive(%x)\n", pwrpriv->bkeepfwalive);
+       pr_debug("bkeepfwalive(%x)\n", pwrpriv->bkeepfwalive);
        if (pm_netdev_open(pnetdev, true) != 0)
                goto exit;
 
@@ -334,7 +325,7 @@ static int rtw_resume_process(struct adapter *padapter)
 exit:
        if (pwrpriv)
                pwrpriv->bInSuspend = false;
-       DBG_88E("<===  %s return %d.............. in %dms\n", __func__,
+       pr_debug("<===  %s return %d.............. in %dms\n", __func__,
                ret, rtw_get_passing_time_ms(start_time));
 
 
@@ -407,8 +398,8 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj,
                dvobj->pusbdev->do_remote_wakeup = 1;
                pusb_intf->needs_remote_wakeup = 1;
                device_init_wakeup(&pusb_intf->dev, 1);
-               DBG_88E("\n  padapter->pwrctrlpriv.bSupportRemoteWakeup~~~~~~\n");
-               DBG_88E("\n  padapter->pwrctrlpriv.bSupportRemoteWakeup~~~[%d]~~~\n",
+               pr_debug("\n  padapter->pwrctrlpriv.bSupportRemoteWakeup~~~~~~\n");
+               pr_debug("\n  padapter->pwrctrlpriv.bSupportRemoteWakeup~~~[%d]~~~\n",
                        device_may_wakeup(&pusb_intf->dev));
        }
 #endif
@@ -416,13 +407,13 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj,
        /* 2012-07-11 Move here to prevent the 8723AS-VAU BT auto
         * suspend influence */
        if (usb_autopm_get_interface(pusb_intf) < 0)
-                       DBG_88E("can't get autopm:\n");
+                       pr_debug("can't get autopm:\n");
 
        /*  alloc dev name after read efuse. */
        rtw_init_netdev_name(pnetdev, padapter->registrypriv.ifname);
        rtw_macaddr_cfg(padapter->eeprompriv.mac_addr);
        memcpy(pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN);
-       DBG_88E("MAC Address from pnetdev->dev_addr =  %pM\n",
+       pr_debug("MAC Address from pnetdev->dev_addr =  %pM\n",
                pnetdev->dev_addr);
 
        /* step 6. Tell the network stack we exist */
@@ -431,7 +422,7 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj,
                goto free_hal_data;
        }
 
-       DBG_88E("bDriverStopped:%d, bSurpriseRemoved:%d, bup:%d, hw_init_completed:%d\n"
+       pr_debug("bDriverStopped:%d, bSurpriseRemoved:%d, bup:%d, hw_init_completed:%d\n"
                , padapter->bDriverStopped
                , padapter->bSurpriseRemoved
                , padapter->bup
@@ -475,7 +466,7 @@ static void rtw_usb_if1_deinit(struct adapter *if1)
        rtw_cancel_all_timer(if1);
 
        rtw_dev_unload(if1);
-       DBG_88E("+r871xu_dev_remove, hw_init_completed=%d\n",
+       pr_debug("+r871xu_dev_remove, hw_init_completed=%d\n",
                if1->hw_init_completed);
        rtw_free_drv_sw(if1);
        if (pnetdev)
@@ -500,7 +491,7 @@ static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device
 
        if1 = rtw_usb_if1_init(dvobj, pusb_intf, pdid);
        if (if1 == NULL) {
-               DBG_88E("rtw_init_primarystruct adapter Failed!\n");
+               pr_debug("rtw_init_primarystruct adapter Failed!\n");
                goto free_dvobj;
        }
 
@@ -525,7 +516,7 @@ static void rtw_dev_remove(struct usb_interface *pusb_intf)
        struct adapter *padapter = dvobj->if1;
 
 
-       DBG_88E("+rtw_dev_remove\n");
+       pr_debug("+rtw_dev_remove\n");
        RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+dev_remove()\n"));
 
        if (!pusb_intf->unregistering)
@@ -541,7 +532,7 @@ static void rtw_dev_remove(struct usb_interface *pusb_intf)
        usb_dvobj_deinit(pusb_intf);
 
        RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-dev_remove()\n"));
-       DBG_88E("-r871xu_dev_remove, done\n");
+       pr_debug("-r871xu_dev_remove, done\n");
 }
 
 static struct usb_driver rtl8188e_usb_drv = {
index ef9da86..fcf9b3b 100644 (file)
@@ -160,21 +160,6 @@ void Dot11d_UpdateCountryIe(struct rtllib_device *dev, u8 *pTaddr,
        pDot11dInfo->State = DOT11D_STATE_LEARNED;
 }
 
-u8 DOT11D_GetMaxTxPwrInDbm(struct rtllib_device *dev, u8 Channel)
-{
-       struct rt_dot11d_info *pDot11dInfo = GET_DOT11D_INFO(dev);
-       u8 MaxTxPwrInDbm = 255;
-
-       if (MAX_CHANNEL_NUMBER < Channel) {
-               netdev_info(dev->dev, "DOT11D_GetMaxTxPwrInDbm(): Invalid Channel\n");
-               return MaxTxPwrInDbm;
-       }
-       if (pDot11dInfo->channel_map[Channel])
-               MaxTxPwrInDbm = pDot11dInfo->MaxTxPwrDbmList[Channel];
-
-       return MaxTxPwrInDbm;
-}
-
 void DOT11D_ScanComplete(struct rtllib_device *dev)
 {
        struct rt_dot11d_info *pDot11dInfo = GET_DOT11D_INFO(dev);
@@ -190,27 +175,3 @@ void DOT11D_ScanComplete(struct rtllib_device *dev)
                break;
        }
 }
-
-int ToLegalChannel(struct rtllib_device *dev, u8 channel)
-{
-       struct rt_dot11d_info *pDot11dInfo = GET_DOT11D_INFO(dev);
-       u8 default_chn = 0;
-       u32 i;
-
-       for (i = 1; i <= MAX_CHANNEL_NUMBER; i++) {
-               if (pDot11dInfo->channel_map[i] > 0) {
-                       default_chn = i;
-                       break;
-               }
-       }
-
-       if (MAX_CHANNEL_NUMBER < channel) {
-               netdev_err(dev->dev, "%s(): Invalid Channel\n", __func__);
-               return default_chn;
-       }
-
-       if (pDot11dInfo->channel_map[channel] > 0)
-               return channel;
-
-       return default_chn;
-}
index 69e0f8f..129ebed 100644 (file)
@@ -79,7 +79,6 @@ static inline void cpMacAddr(unsigned char *des, unsigned char *src)
 #define UPDATE_CIE_SRC(__pIeeeDev, __pTa)              \
        cpMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa)
 
-#define CIE_WATCHDOG_TH 1
 #define GET_CIE_WATCHDOG(__pIeeeDev)                           \
         (GET_DOT11D_INFO(__pIeeeDev)->CountryIeWatchdog)
 static inline void RESET_CIE_WATCHDOG(struct rtllib_device *__pIeeeDev)
@@ -88,16 +87,11 @@ static inline void RESET_CIE_WATCHDOG(struct rtllib_device *__pIeeeDev)
 }
 #define UPDATE_CIE_WATCHDOG(__pIeeeDev) (++GET_CIE_WATCHDOG(__pIeeeDev))
 
-#define IS_DOT11D_STATE_DONE(__pIeeeDev)                       \
-       (GET_DOT11D_INFO(__pIeeeDev)->State == DOT11D_STATE_DONE)
-
 void dot11d_init(struct rtllib_device *dev);
 void Dot11d_Channelmap(u8 channel_plan, struct rtllib_device *ieee);
 void Dot11d_Reset(struct rtllib_device *dev);
 void Dot11d_UpdateCountryIe(struct rtllib_device *dev, u8 *pTaddr,
                            u16 CoutryIeLen, u8 *pCoutryIe);
-u8 DOT11D_GetMaxTxPwrInDbm(struct rtllib_device *dev, u8 Channel);
 void DOT11D_ScanComplete(struct rtllib_device *dev);
-int ToLegalChannel(struct rtllib_device *dev, u8 channel);
 
 #endif
index d0b0830..dba4584 100644 (file)
@@ -26,8 +26,6 @@
 #define                MAX_SILENT_RESET_RX_SLOT_NUM    10
 
 #define RX_MPDU_QUEUE                          0
-#define RX_CMD_QUEUE                           1
-
 
 enum rtl819x_loopback {
        RTL819X_NO_LOOPBACK = 0,
@@ -36,11 +34,6 @@ enum rtl819x_loopback {
        RTL819X_CCK_LOOPBACK = 3,
 };
 
-
-#define RESET_DELAY_8185                       20
-
-#define RT_IBSS_INT_MASKS (IMR_BcnInt | IMR_BcnInt | IMR_TBDOK | IMR_TBDER)
-
 #define DESC90_RATE1M                          0x00
 #define DESC90_RATE2M                          0x01
 #define DESC90_RATE5_5M                                0x02
@@ -74,17 +67,6 @@ enum rtl819x_loopback {
 #define SHORT_SLOT_TIME                                9
 #define NON_SHORT_SLOT_TIME            20
 
-
-#define        MAX_LINES_HWCONFIG_TXT                  1000
-#define MAX_BYTES_LINE_HWCONFIG_TXT            128
-
-#define SW_THREE_WIRE                  0
-#define HW_THREE_WIRE                  2
-
-#define BT_DEMO_BOARD                  0
-#define BT_QA_BOARD                            1
-#define BT_FPGA                                        2
-
 #define        RX_SMOOTH                               20
 
 #define QSLT_BK                                        0x1
@@ -96,25 +78,14 @@ enum rtl819x_loopback {
 #define        QSLT_MGNT                               0x12
 #define        QSLT_CMD                                0x13
 
-#define NUM_OF_FIRMWARE_QUEUE                          10
-#define NUM_OF_PAGES_IN_FW                                     0x100
 #define NUM_OF_PAGE_IN_FW_QUEUE_BK             0x007
 #define NUM_OF_PAGE_IN_FW_QUEUE_BE             0x0aa
 #define NUM_OF_PAGE_IN_FW_QUEUE_VI             0x024
 #define NUM_OF_PAGE_IN_FW_QUEUE_VO             0x007
-#define NUM_OF_PAGE_IN_FW_QUEUE_HCCA           0
-#define NUM_OF_PAGE_IN_FW_QUEUE_CMD            0x2
 #define NUM_OF_PAGE_IN_FW_QUEUE_MGNT           0x10
-#define NUM_OF_PAGE_IN_FW_QUEUE_HIGH           0
 #define NUM_OF_PAGE_IN_FW_QUEUE_BCN            0x4
 #define NUM_OF_PAGE_IN_FW_QUEUE_PUB            0xd
 
-#define NUM_OF_PAGE_IN_FW_QUEUE_BK_DTM 0x026
-#define NUM_OF_PAGE_IN_FW_QUEUE_BE_DTM 0x048
-#define NUM_OF_PAGE_IN_FW_QUEUE_VI_DTM 0x048
-#define NUM_OF_PAGE_IN_FW_QUEUE_VO_DTM 0x026
-#define NUM_OF_PAGE_IN_FW_QUEUE_PUB_DTM        0x00
-
 #define APPLIED_RESERVED_QUEUE_IN_FW           0x80000000
 #define RSVD_FW_QUEUE_PAGE_BK_SHIFT            0x00
 #define RSVD_FW_QUEUE_PAGE_BE_SHIFT            0x08
@@ -197,23 +168,6 @@ struct tx_fwinfo_8190pci {
 
 };
 
-
-#define TX_DESC_SIZE                   32
-
-#define TX_DESC_CMD_SIZE       32
-
-
-#define TX_STATUS_DESC_SIZE    32
-
-#define TX_FWINFO_SIZE 8
-
-
-#define RX_DESC_SIZE   16
-
-#define RX_STATUS_DESC_SIZE    16
-
-#define RX_DRIVER_INFO_SIZE    8
-
 struct log_int_8190 {
        u32     nIMR_COMDOK;
        u32     nIMR_MGNTDOK;
index facc6f1..f3eb1dc 100644 (file)
@@ -81,15 +81,7 @@ void PHY_SetRF8256Bandwidth(struct net_device *dev,
        }
 }
 
-bool PHY_RF8256_Config(struct net_device *dev)
-{
-       struct r8192_priv *priv = rtllib_priv(dev);
-
-       priv->NumTotalRFPath = RTL819X_TOTAL_RF_PATH;
-       return phy_RF8256_Config_ParaFile(dev);
-}
-
-bool phy_RF8256_Config_ParaFile(struct net_device *dev)
+static bool phy_RF8256_Config_ParaFile(struct net_device *dev)
 {
        u32     u4RegValue = 0;
        u8      eRFPath;
@@ -240,6 +232,14 @@ phy_RF8256_Config_ParaFile_Fail:
        return false;
 }
 
+bool PHY_RF8256_Config(struct net_device *dev)
+{
+       struct r8192_priv *priv = rtllib_priv(dev);
+
+       priv->NumTotalRFPath = RTL819X_TOTAL_RF_PATH;
+       return phy_RF8256_Config_ParaFile(dev);
+}
+
 void PHY_SetRF8256CCKTxPower(struct net_device *dev, u8        powerlevel)
 {
        u32     TxAGC = 0;
index 64e831d..d9348d9 100644 (file)
@@ -24,7 +24,6 @@
 extern void PHY_SetRF8256Bandwidth(struct net_device *dev,
                                   enum ht_channel_width Bandwidth);
 extern bool PHY_RF8256_Config(struct net_device *dev);
-extern bool phy_RF8256_Config_ParaFile(struct net_device *dev);
 extern void PHY_SetRF8256CCKTxPower(struct net_device *dev, u8 powerlevel);
 extern void PHY_SetRF8256OFDMTxPower(struct net_device *dev, u8 powerlevel);
 
index f6661bb..eb919b6 100644 (file)
@@ -41,7 +41,6 @@ void rtl8192e_start_beacon(struct net_device *dev)
        u16 BcnCW = 6;
        u16 BcnIFS = 0xf;
 
-       DMESG("Enabling beacon TX");
        rtl8192_irq_disable(dev);
 
        write_nic_word(dev, ATIMWND, 2);
@@ -1177,6 +1176,18 @@ static u8 rtl8192_MapHwQueueToFirmwareQueue(struct net_device *dev, u8 QueueID,
        return QueueSelect;
 }
 
+static u8 rtl8192_QueryIsShort(u8 TxHT, u8 TxRate, struct cb_desc *tcb_desc)
+{
+       u8   tmp_Short;
+
+       tmp_Short = (TxHT == 1) ? ((tcb_desc->bUseShortGI) ? 1 : 0) :
+                       ((tcb_desc->bUseShortPreamble) ? 1 : 0);
+       if (TxHT == 1 && TxRate != DESC90_RATEMCS15)
+               tmp_Short = 0;
+
+       return tmp_Short;
+}
+
 void  rtl8192_tx_fill_desc(struct net_device *dev, struct tx_desc *pdesc,
                           struct cb_desc *cb_desc, struct sk_buff *skb)
 {
@@ -1732,8 +1743,6 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
        if (!bcheck)
                return;
 
-       rtl819x_process_cck_rxpathsel(priv, prev_st);
-
        priv->stats.num_process_phyinfo++;
        if (!prev_st->bIsCCK && prev_st->bPacketToSelf) {
                for (rfpath = RF90_PATH_A; rfpath < RF90_PATH_C; rfpath++) {
@@ -2383,18 +2392,6 @@ bool rtl8192_GetHalfNmodeSupportByAPs(struct net_device *dev)
        return Reval;
 }
 
-u8 rtl8192_QueryIsShort(u8 TxHT, u8 TxRate, struct cb_desc *tcb_desc)
-{
-       u8   tmp_Short;
-
-       tmp_Short = (TxHT == 1) ? ((tcb_desc->bUseShortGI) ? 1 : 0) :
-                       ((tcb_desc->bUseShortPreamble) ? 1 : 0);
-       if (TxHT == 1 && TxRate != DESC90_RATEMCS15)
-               tmp_Short = 0;
-
-       return tmp_Short;
-}
-
 void ActUpdateChannelAccessSetting(struct net_device *dev,
        enum wireless_mode WirelessMode,
        struct channel_access_setting *ChnlAccessSetting)
index dbe0e1c..4f1b312 100644 (file)
@@ -27,7 +27,6 @@
 
 #include "r8190P_def.h"
 
-u8 rtl8192_QueryIsShort(u8 TxHT, u8 TxRate, struct cb_desc *tcb_desc);
 bool rtl8192_GetHalfNmodeSupportByAPs(struct net_device *dev);
 bool rtl8192_GetNmodeSupportBySecCfg(struct net_device *dev);
 bool rtl8192_HalTxCheckStuck(struct net_device *dev);
index d79e542..ef232d2 100644 (file)
@@ -19,8 +19,6 @@
 #ifndef __INC_FIRMWARE_H
 #define __INC_FIRMWARE_H
 
-#define RTL8190_CPU_START_OFFSET       0x80
-
 #define GET_COMMAND_PACKET_FRAG_THRESHOLD(v)   (4*(v/4) - 8)
 
 #define RTL8192E_BOOT_IMG_FW   "RTL8192E/boot.img"
index fba7654..3213523 100644 (file)
@@ -357,7 +357,7 @@ void rtl8192_phy_configmac(struct net_device *dev)
 
 }
 
-void rtl8192_phyConfigBB(struct net_device *dev, u8 ConfigType)
+static void rtl8192_phyConfigBB(struct net_device *dev, u8 ConfigType)
 {
        int i;
        u32 *Rtl819XPHY_REGArray_Table = NULL;
@@ -986,7 +986,7 @@ static void rtl8192_phy_FinishSwChnlNow(struct net_device *dev, u8 channel)
                        break;
        }
 }
-void rtl8192_SwChnl_WorkItem(struct net_device *dev)
+static void rtl8192_SwChnl_WorkItem(struct net_device *dev)
 {
 
        struct r8192_priv *priv = rtllib_priv(dev);
@@ -1163,7 +1163,7 @@ static void CCK_Tx_Power_Track_BW_Switch(struct net_device *dev)
                CCK_Tx_Power_Track_BW_Switch_ThermalMeter(dev);
 }
 
-void rtl8192_SetBWModeWorkItem(struct net_device *dev)
+static void rtl8192_SetBWModeWorkItem(struct net_device *dev)
 {
 
        struct r8192_priv *priv = rtllib_priv(dev);
index 18bc582..ef85587 100644 (file)
@@ -80,7 +80,6 @@ extern u32 rtl8192_phy_QueryRFReg(struct net_device *dev,
                                  enum rf90_radio_path eRFPath,
                                  u32 RegAddr, u32 BitMask);
 extern void rtl8192_phy_configmac(struct net_device *dev);
-extern void rtl8192_phyConfigBB(struct net_device *dev, u8 ConfigType);
 extern bool rtl8192_phy_checkBBAndRF(struct net_device *dev,
                                     enum hw90_block CheckBlock,
                                     enum rf90_radio_path eRFPath);
@@ -96,8 +95,6 @@ extern u8 rtl8192_phy_SwChnl(struct net_device *dev, u8 channel);
 extern void rtl8192_SetBWMode(struct net_device *dev,
                              enum ht_channel_width Bandwidth,
                              enum ht_extchnl_offset Offset);
-extern void rtl8192_SwChnl_WorkItem(struct net_device *dev);
-extern void rtl8192_SetBWModeWorkItem(struct net_device *dev);
 extern void InitialGain819xPci(struct net_device *dev, u8 Operation);
 
 extern void PHY_SetRtl8192eRfOff(struct net_device *dev);
index c6cdb43..ca8406b 100644 (file)
  * Contact Information:
  * wlanfae <wlanfae@realtek.com>
 ******************************************************************************/
-#undef RX_DONT_PASS_UL
-#undef DEBUG_EPROM
-#undef DEBUG_RX_VERBOSE
-#undef DUMMY_RX
-#undef DEBUG_ZERO_RX
-#undef DEBUG_RX_SKB
-#undef DEBUG_TX_FRAG
-#undef DEBUG_RX_FRAG
-#undef DEBUG_TX_FILLDESC
-#undef DEBUG_TX
-#undef DEBUG_IRQ
-#undef DEBUG_RX
-#undef DEBUG_RXALLOC
-#undef DEBUG_REGISTERS
-#undef DEBUG_RING
-#undef DEBUG_IRQ_TASKLET
-#undef DEBUG_TX_ALLOC
-#undef DEBUG_TX_DESC
-
 #include <linux/uaccess.h>
 #include <linux/pci.h>
 #include <linux/vmalloc.h>
@@ -106,167 +87,28 @@ static struct pci_driver rtl8192_pci_driver = {
        .resume = rtl8192E_resume,                 /* PM resume fn  */
 };
 
+static short rtl8192_is_tx_queue_empty(struct net_device *dev);
+static void rtl819x_watchdog_wqcallback(void *data);
+static void watch_dog_timer_callback(unsigned long data);
+static void rtl8192_data_hard_stop(struct net_device *dev);
+static void rtl8192_data_hard_resume(struct net_device *dev);
+static void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev,
+                                  int rate);
+static int rtl8192_hard_start_xmit(struct sk_buff *skb, struct net_device *dev);
+static void rtl8192_tx_cmd(struct net_device *dev, struct sk_buff *skb);
+static short rtl8192_tx(struct net_device *dev, struct sk_buff *skb);
+static short rtl8192_pci_initdescring(struct net_device *dev);
+static void rtl8192_irq_tx_tasklet(struct r8192_priv *priv);
+static void rtl8192_irq_rx_tasklet(struct r8192_priv *priv);
+static void rtl8192_cancel_deferred_work(struct r8192_priv *priv);
+static int _rtl8192_up(struct net_device *dev, bool is_silent_reset);
+static int rtl8192_up(struct net_device *dev);
+static int rtl8192_down(struct net_device *dev, bool shutdownrf);
+static void rtl8192_restart(void *data);
+
 /****************************************************************************
    -----------------------------IO STUFF-------------------------
 *****************************************************************************/
-static bool PlatformIOCheckPageLegalAndGetRegMask(u32 u4bPage, u8 *pu1bPageMask)
-{
-       bool            bReturn = false;
-
-       *pu1bPageMask = 0xfe;
-
-       switch (u4bPage) {
-       case 1: case 2: case 3: case 4:
-       case 8: case 9: case 10: case 12: case 13:
-               bReturn = true;
-               *pu1bPageMask = 0xf0;
-               break;
-
-       default:
-               bReturn = false;
-               break;
-       }
-
-       return bReturn;
-}
-
-void write_nic_io_byte(struct net_device *dev, int x, u8 y)
-{
-       u32 u4bPage = x >> 8;
-       u8 u1PageMask = 0;
-       bool    bIsLegalPage = false;
-
-       if (u4bPage == 0) {
-               outb(y&0xff, dev->base_addr + x);
-
-       } else {
-               bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage,
-                              &u1PageMask);
-               if (bIsLegalPage) {
-                       u8 u1bPsr = read_nic_io_byte(dev, PSR);
-
-                       write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) |
-                                         (u8)u4bPage));
-                       write_nic_io_byte(dev, (x & 0xff), y);
-                       write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask));
-               }
-       }
-}
-
-void write_nic_io_word(struct net_device *dev, int x, u16 y)
-{
-       u32 u4bPage = x >> 8;
-       u8 u1PageMask = 0;
-       bool    bIsLegalPage = false;
-
-       if (u4bPage == 0) {
-               outw(y, dev->base_addr + x);
-       } else {
-               bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage,
-                                                        &u1PageMask);
-               if (bIsLegalPage) {
-                       u8 u1bPsr = read_nic_io_byte(dev, PSR);
-
-                       write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) |
-                                         (u8)u4bPage));
-                       write_nic_io_word(dev, (x & 0xff), y);
-                       write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask));
-
-               }
-       }
-}
-
-void write_nic_io_dword(struct net_device *dev, int x, u32 y)
-{
-       u32 u4bPage = x >> 8;
-       u8 u1PageMask = 0;
-       bool    bIsLegalPage = false;
-
-       if (u4bPage == 0) {
-               outl(y, dev->base_addr + x);
-       } else {
-               bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage,
-                                                &u1PageMask);
-               if (bIsLegalPage) {
-                       u8 u1bPsr = read_nic_io_byte(dev, PSR);
-
-                       write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) |
-                                         (u8)u4bPage));
-                       write_nic_io_dword(dev, (x & 0xff), y);
-                       write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask));
-               }
-       }
-}
-
-u8 read_nic_io_byte(struct net_device *dev, int x)
-{
-       u32 u4bPage = x >> 8;
-       u8 u1PageMask = 0;
-       bool    bIsLegalPage = false;
-       u8      Data = 0;
-
-       if (u4bPage == 0)
-               return 0xff&inb(dev->base_addr + x);
-
-       bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage,
-                                                            &u1PageMask);
-       if (bIsLegalPage) {
-               u8 u1bPsr = read_nic_io_byte(dev, PSR);
-
-               write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) |
-                                 (u8)u4bPage));
-               Data = read_nic_io_byte(dev, (x & 0xff));
-               write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask));
-       }
-
-       return Data;
-}
-
-u16 read_nic_io_word(struct net_device *dev, int x)
-{
-       u32 u4bPage = x >> 8;
-       u8 u1PageMask = 0;
-       bool    bIsLegalPage = false;
-       u16     Data = 0;
-
-       if (u4bPage == 0)
-               return inw(dev->base_addr + x);
-       bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage,
-                                                            &u1PageMask);
-       if (bIsLegalPage) {
-               u8 u1bPsr = read_nic_io_byte(dev, PSR);
-
-               write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) |
-                                 (u8)u4bPage));
-               Data = read_nic_io_word(dev, (x & 0xff));
-               write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask));
-       }
-
-       return Data;
-}
-
-u32 read_nic_io_dword(struct net_device *dev, int x)
-{
-       u32 u4bPage = x >> 8;
-       u8 u1PageMask = 0;
-       bool    bIsLegalPage = false;
-       u32     Data = 0;
-
-       if (u4bPage == 0)
-               return inl(dev->base_addr + x);
-       bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage,
-                      &u1PageMask);
-       if (bIsLegalPage) {
-               u8 u1bPsr = read_nic_io_byte(dev, PSR);
-
-               write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) |
-                                 (u8)u4bPage));
-               Data = read_nic_io_dword(dev, (x & 0xff));
-               write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask));
-       }
-
-       return Data;
-}
 
 u8 read_nic_byte(struct net_device *dev, int x)
 {
@@ -450,7 +292,7 @@ static short rtl8192_check_nic_enough_desc(struct net_device *dev, int prio)
        return 0;
 }
 
-void rtl8192_tx_timeout(struct net_device *dev)
+static void rtl8192_tx_timeout(struct net_device *dev)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
 
@@ -476,7 +318,7 @@ void rtl8192_irq_disable(struct net_device *dev)
        priv->irq_enabled = 0;
 }
 
-void rtl8192_set_chan(struct net_device *dev, short ch)
+static void rtl8192_set_chan(struct net_device *dev, short ch)
 {
        struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
 
@@ -490,7 +332,7 @@ void rtl8192_set_chan(struct net_device *dev, short ch)
                priv->rf_set_chan(dev, priv->chan);
 }
 
-void rtl8192_update_cap(struct net_device *dev, u16 cap)
+static void rtl8192_update_cap(struct net_device *dev, u16 cap)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
        struct rtllib_network *net = &priv->rtllib->current_network;
@@ -1282,7 +1124,7 @@ static short rtl8192_init(struct net_device *dev)
 /***************************************************************************
        -------------------------------WATCHDOG STUFF---------------------------
 ***************************************************************************/
-short rtl8192_is_tx_queue_empty(struct net_device *dev)
+static short rtl8192_is_tx_queue_empty(struct net_device *dev)
 {
        int i = 0;
        struct r8192_priv *priv = rtllib_priv(dev);
@@ -1570,8 +1412,7 @@ static void rtl819x_update_rxcounts(struct r8192_priv *priv, u32 *TotalRxBcnNum,
        }
 }
 
-
-void   rtl819x_watchdog_wqcallback(void *data)
+static void rtl819x_watchdog_wqcallback(void *data)
 {
        struct r8192_priv *priv = container_of_dwork_rsl(data,
                                  struct r8192_priv, watch_dog_wq);
@@ -1725,7 +1566,7 @@ void      rtl819x_watchdog_wqcallback(void *data)
        RT_TRACE(COMP_TRACE, " <==RtUsbCheckForHangWorkItemCallback()\n");
 }
 
-void watch_dog_timer_callback(unsigned long data)
+static void watch_dog_timer_callback(unsigned long data)
 {
        struct r8192_priv *priv = rtllib_priv((struct net_device *)data);
 
@@ -1802,16 +1643,15 @@ static void rtl8192_free_tx_ring(struct net_device *dev, unsigned int prio)
        ring->desc = NULL;
 }
 
-void rtl8192_data_hard_stop(struct net_device *dev)
+static void rtl8192_data_hard_stop(struct net_device *dev)
 {
 }
 
-
-void rtl8192_data_hard_resume(struct net_device *dev)
+static void rtl8192_data_hard_resume(struct net_device *dev)
 {
 }
 
-void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev,
+static void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev,
                            int rate)
 {
        struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
@@ -1843,7 +1683,7 @@ void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev,
        }
 }
 
-int rtl8192_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
+static int rtl8192_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
        int ret;
@@ -1902,7 +1742,7 @@ static void rtl8192_tx_isr(struct net_device *dev, int prio)
                tasklet_schedule(&priv->irq_tx_tasklet);
 }
 
-void rtl8192_tx_cmd(struct net_device *dev, struct sk_buff *skb)
+static void rtl8192_tx_cmd(struct net_device *dev, struct sk_buff *skb)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
        struct rtl8192_tx_ring *ring;
@@ -1925,7 +1765,7 @@ void rtl8192_tx_cmd(struct net_device *dev, struct sk_buff *skb)
        spin_unlock_irqrestore(&priv->irq_th_lock, flags);
 }
 
-short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
+static short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
        struct rtl8192_tx_ring  *ring;
@@ -2077,8 +1917,7 @@ static int rtl8192_alloc_tx_desc_ring(struct net_device *dev,
        return 0;
 }
 
-
-short rtl8192_pci_initdescring(struct net_device *dev)
+static short rtl8192_pci_initdescring(struct net_device *dev)
 {
        u32 ret;
        int i;
@@ -2189,12 +2028,6 @@ rtl819x_update_rxsignalstatistics8190pci(
                                        weighting) / 6;
 }
 
-void rtl819x_process_cck_rxpathsel(struct r8192_priv *priv,
-                                  struct rtllib_rx_stats *pprevious_stats)
-{
-}
-
-
 u8 rtl819x_query_rxpwrpercentage(char antpower)
 {
        if ((antpower <= -100) || (antpower >= 20))
@@ -2344,11 +2177,6 @@ done:
 
 }
 
-static void rtl8192_rx_cmd(struct net_device *dev)
-{
-}
-
-
 static void rtl8192_tx_resume(struct net_device *dev)
 {
        struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
@@ -2366,18 +2194,15 @@ static void rtl8192_tx_resume(struct net_device *dev)
        }
 }
 
-void rtl8192_irq_tx_tasklet(struct r8192_priv *priv)
+static void rtl8192_irq_tx_tasklet(struct r8192_priv *priv)
 {
        rtl8192_tx_resume(priv->rtllib->dev);
 }
 
-void rtl8192_irq_rx_tasklet(struct r8192_priv *priv)
+static void rtl8192_irq_rx_tasklet(struct r8192_priv *priv)
 {
        rtl8192_rx_normal(priv->rtllib->dev);
 
-       if (MAX_RX_QUEUE > 1)
-               rtl8192_rx_cmd(priv->rtllib->dev);
-
        write_nic_dword(priv->rtllib->dev, INTA_MASK,
                        read_nic_dword(priv->rtllib->dev, INTA_MASK) | IMR_RDU);
 }
@@ -2385,7 +2210,7 @@ void rtl8192_irq_rx_tasklet(struct r8192_priv *priv)
 /****************************************************************************
  ---------------------------- NIC START/CLOSE STUFF---------------------------
 *****************************************************************************/
-void rtl8192_cancel_deferred_work(struct r8192_priv *priv)
+static void rtl8192_cancel_deferred_work(struct r8192_priv *priv)
 {
        cancel_delayed_work(&priv->watch_dog_wq);
        cancel_delayed_work(&priv->update_beacon_wq);
@@ -2394,14 +2219,13 @@ void rtl8192_cancel_deferred_work(struct r8192_priv *priv)
        cancel_work_sync(&priv->qos_activate);
 }
 
-int _rtl8192_up(struct net_device *dev, bool is_silent_reset)
+static int _rtl8192_up(struct net_device *dev, bool is_silent_reset)
 {
        if (_rtl8192_sta_up(dev, is_silent_reset) == -1)
                return -1;
        return 0;
 }
 
-
 static int rtl8192_open(struct net_device *dev)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
@@ -2414,8 +2238,7 @@ static int rtl8192_open(struct net_device *dev)
 
 }
 
-
-int rtl8192_up(struct net_device *dev)
+static int rtl8192_up(struct net_device *dev)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
 
@@ -2445,7 +2268,7 @@ static int rtl8192_close(struct net_device *dev)
 
 }
 
-int rtl8192_down(struct net_device *dev, bool shutdownrf)
+static int rtl8192_down(struct net_device *dev, bool shutdownrf)
 {
        if (rtl8192_sta_down(dev, shutdownrf) == -1)
                return -1;
@@ -2465,7 +2288,7 @@ void rtl8192_commit(struct net_device *dev)
        _rtl8192_up(dev, false);
 }
 
-void rtl8192_restart(void *data)
+static void rtl8192_restart(void *data)
 {
        struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv,
                                  reset_wq);
@@ -2782,7 +2605,6 @@ static int rtl8192_pci_probe(struct pci_dev *pdev,
        struct rtl819x_ops *ops = (struct rtl819x_ops *)(id->driver_data);
        unsigned long pmem_start, pmem_len, pmem_flags;
        int err = -ENOMEM;
-       bool bdma64 = false;
        u8 revision_id;
 
        RT_TRACE(COMP_INIT, "Configuring chip resources");
@@ -2806,8 +2628,6 @@ static int rtl8192_pci_probe(struct pci_dev *pdev,
                goto err_pci_disable;
 
        err = -ENODEV;
-       if (bdma64)
-               dev->features |= NETIF_F_HIGHDMA;
 
        pci_set_drvdata(pdev, dev);
        SET_NETDEV_DEV(dev, &pdev->dev);
@@ -2900,8 +2720,6 @@ err_rel_mem:
        release_mem_region(pmem_start, pmem_len);
 err_rel_rtllib:
        free_rtllib(dev);
-
-       DMESG("wlan driver load failed\n");
 err_pci_disable:
        pci_disable_device(pdev);
        return err;
@@ -3007,7 +2825,6 @@ static int __init rtl8192_pci_module_init(void)
        pr_info("Copyright (c) 2007-2008, Realsil Wlan Driver\n");
 
        if (0 != pci_register_driver(&rtl8192_pci_driver)) {
-               DMESG("No device found");
                /*pci_unregister_driver (&rtl8192_pci_driver);*/
                return -ENODEV;
        }
index 776d950..26e54e4 100644 (file)
@@ -578,16 +578,6 @@ struct r8192_priv {
 
 extern const struct ethtool_ops rtl819x_ethtool_ops;
 
-void rtl8192_tx_cmd(struct net_device *dev, struct sk_buff *skb);
-short rtl8192_tx(struct net_device *dev, struct sk_buff *skb);
-
-u8 read_nic_io_byte(struct net_device *dev, int x);
-u32 read_nic_io_dword(struct net_device *dev, int x);
-u16 read_nic_io_word(struct net_device *dev, int x);
-void write_nic_io_byte(struct net_device *dev, int x, u8 y);
-void write_nic_io_word(struct net_device *dev, int x, u16 y);
-void write_nic_io_dword(struct net_device *dev, int x, u32 y);
-
 u8 read_nic_byte(struct net_device *dev, int x);
 u32 read_nic_dword(struct net_device *dev, int x);
 u16 read_nic_word(struct net_device *dev, int x);
@@ -600,40 +590,19 @@ void force_pci_posting(struct net_device *dev);
 void rtl8192_rx_enable(struct net_device *);
 void rtl8192_tx_enable(struct net_device *);
 
-int rtl8192_hard_start_xmit(struct sk_buff *skb, struct net_device *dev);
-void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev,
-                           int rate);
-void rtl8192_data_hard_stop(struct net_device *dev);
-void rtl8192_data_hard_resume(struct net_device *dev);
-void rtl8192_restart(void *data);
-void rtl819x_watchdog_wqcallback(void *data);
 void rtl8192_hw_sleep_wq(void *data);
-void watch_dog_timer_callback(unsigned long data);
-void rtl8192_irq_rx_tasklet(struct r8192_priv *priv);
-void rtl8192_irq_tx_tasklet(struct r8192_priv *priv);
-int rtl8192_down(struct net_device *dev, bool shutdownrf);
-int rtl8192_up(struct net_device *dev);
 void rtl8192_commit(struct net_device *dev);
-void rtl8192_set_chan(struct net_device *dev, short ch);
 
 void check_rfctrl_gpio_timer(unsigned long data);
 
 void rtl8192_hw_wakeup_wq(void *data);
-short rtl8192_pci_initdescring(struct net_device *dev);
-
-void rtl8192_cancel_deferred_work(struct r8192_priv *priv);
-
-int _rtl8192_up(struct net_device *dev, bool is_silent_reset);
 
-short rtl8192_is_tx_queue_empty(struct net_device *dev);
 void rtl8192_irq_disable(struct net_device *dev);
 
-void rtl8192_tx_timeout(struct net_device *dev);
 void rtl8192_pci_resetdescring(struct net_device *dev);
 void rtl8192_SetWirelessMode(struct net_device *dev, u8 wireless_mode);
 void rtl8192_irq_enable(struct net_device *dev);
 void rtl8192_config_rate(struct net_device *dev, u16 *rate_config);
-void rtl8192_update_cap(struct net_device *dev, u16 cap);
 void rtl8192_irq_disable(struct net_device *dev);
 
 void rtl819x_UpdateRxPktTimeStamp(struct net_device *dev,
@@ -642,8 +611,6 @@ long rtl819x_translate_todbm(struct r8192_priv *priv, u8 signal_strength_index);
 void rtl819x_update_rxsignalstatistics8190pci(struct r8192_priv *priv,
                                      struct rtllib_rx_stats *pprevious_stats);
 u8 rtl819x_evm_dbtopercentage(char value);
-void rtl819x_process_cck_rxpathsel(struct r8192_priv *priv,
-                                  struct rtllib_rx_stats *pprevious_stats);
 u8 rtl819x_query_rxpwrpercentage(char antpower);
 void rtl8192_record_rxdesc_forlateruse(struct rtllib_rx_stats *psrc_stats,
                                       struct rtllib_rx_stats *ptarget_stats);
index 3de7cc5..c236712 100644 (file)
@@ -58,9 +58,6 @@ static u32 edca_setting_UL[HT_IOT_PEER_MAX] = {
        0x5e4332
 };
 
-#define RTK_UL_EDCA 0xa44f
-#define RTK_DL_EDCA 0x5e4322
-
 const u32 dm_tx_bb_gain[TxBBGainTableLength] = {
        0x7f8001fe, /* 12 dB */
        0x788001e2, /* 11 dB */
@@ -213,6 +210,9 @@ static void dm_deInit_fsync(struct net_device *dev);
 
 static void dm_check_txrateandretrycount(struct net_device *dev);
 static  void dm_check_ac_dc_power(struct net_device *dev);
+static void dm_check_fsync(struct net_device *dev);
+static void dm_CheckRfCtrlGPIO(void *data);
+static void dm_fsync_timer_callback(unsigned long data);
 
 /*---------------------Define local function prototype-----------------------*/
 
@@ -1854,7 +1854,7 @@ static    void    dm_check_pbc_gpio(struct net_device *dev)
 {
 }
 
-void dm_CheckRfCtrlGPIO(void *data)
+static void dm_CheckRfCtrlGPIO(void *data)
 {
        struct r8192_priv *priv = container_of_dwork_rsl(data,
                                  struct r8192_priv, gpio_change_rf_wq);
@@ -2191,7 +2191,7 @@ static void dm_deInit_fsync(struct net_device *dev)
        del_timer_sync(&priv->fsync_timer);
 }
 
-void dm_fsync_timer_callback(unsigned long data)
+static void dm_fsync_timer_callback(unsigned long data)
 {
        struct net_device *dev = (struct net_device *)data;
        struct r8192_priv *priv = rtllib_priv((struct net_device *)data);
@@ -2375,7 +2375,7 @@ static void dm_StartSWFsync(struct net_device *dev)
 
 }
 
-void dm_check_fsync(struct net_device *dev)
+static void dm_check_fsync(struct net_device *dev)
 {
 #define        RegC38_Default                  0
 #define        RegC38_NonFsync_Other_AP        1
index b037451..95b8a8f 100644 (file)
 #define                DM_DIG_THRESH_HIGH                                      40
 #define                DM_DIG_THRESH_LOW                                       35
 
-#define                DM_FALSEALARM_THRESH_LOW        40
-#define                DM_FALSEALARM_THRESH_HIGH       1000
-
 #define                DM_DIG_HIGH_PWR_THRESH_HIGH             75
 #define                DM_DIG_HIGH_PWR_THRESH_LOW              70
 
 #define                BW_AUTO_SWITCH_HIGH_LOW                 25
 #define                BW_AUTO_SWITCH_LOW_HIGH                 30
 
-#define                DM_check_fsync_time_interval                            500
-
-
 #define                DM_DIG_BACKOFF                          12
 #define                DM_DIG_MAX                                      0x36
 #define                DM_DIG_MIN                                      0x1c
 #define                DM_DIG_MIN_Netcore                      0x12
 
-#define                DM_DIG_BACKOFF_MAX                      12
-#define                DM_DIG_BACKOFF_MIN                      -4
-
 #define                RxPathSelection_SS_TH_low               30
 #define                RxPathSelection_diff_TH                 18
 
@@ -55,8 +46,6 @@
 #define                RateAdaptiveTH_Low_40M          10
 #define                VeryLowRSSI                                     15
 
-#define                CTSToSelfTHVal                                  35
-
 #define                WAIotTHVal                                              25
 
 #define                E_FOR_TX_POWER_TRACK           300
 #define                        Tx_Retry_Count_Reg       0x1ac
 #define                RegC38_TH                                20
 
-#define                TX_POWER_NEAR_FIELD_THRESH_LVL2 74
-#define                TX_POWER_NEAR_FIELD_THRESH_LVL1 67
-
-#define                TxHighPwrLevel_Normal           0
-#define                TxHighPwrLevel_Level1           1
-#define                TxHighPwrLevel_Level2           2
-
-#define                DM_Type_ByFW                    0
 #define                DM_Type_ByDriver                1
 
 /*--------------------------Define Parameters-------------------------------*/
@@ -222,8 +203,5 @@ extern  void    dm_restore_dynamic_mechanism_state(struct net_device *dev);
 extern  void    dm_backup_dynamic_mechanism_state(struct net_device *dev);
 extern  void    dm_init_edca_turbo(struct net_device *dev);
 extern  void    dm_rf_pathcheck_workitemcallback(void *data);
-extern  void dm_fsync_timer_callback(unsigned long data);
-extern  void dm_check_fsync(struct net_device *dev);
 extern  void dm_initialize_txpower_tracking(struct net_device *dev);
-extern  void    dm_CheckRfCtrlGPIO(void *data);
 #endif /*__R8192UDM_H__ */
index 962f2e5..d23c0f1 100644 (file)
@@ -30,7 +30,6 @@
 struct net_device;
 
 #define RT_CHECK_FOR_HANG_PERIOD 2
-#define INIT_DEFAULT_CHAN       1
 
 void rtl8192_hw_wakeup(struct net_device *dev);
 void rtl8192_hw_to_sleep(struct net_device *dev, u64 time);
index f5e4961..15fc484 100644 (file)
@@ -729,9 +729,6 @@ static int r8192_wx_set_enc(struct net_device *dev,
                        hwkey[i] |= (key[4 * i + 3] & mask) << 24;
                }
 
-               #define CONF_WEP40  0x4
-               #define CONF_WEP104 0x14
-
                switch (wrqu->encoding.flags & IW_ENCODE_INDEX) {
                case 0:
                        key_idx = ieee->crypt_info.tx_keyidx;
@@ -821,13 +818,9 @@ static int r8192_wx_set_retry(struct net_device *dev,
        }
        if (wrqu->retry.flags & IW_RETRY_MAX) {
                priv->retry_rts = wrqu->retry.value;
-               DMESG("Setting retry for RTS/CTS data to %d",
-                     wrqu->retry.value);
 
        } else {
                priv->retry_data = wrqu->retry.value;
-               DMESG("Setting retry for non RTS/CTS data to %d",
-                     wrqu->retry.value);
        }
 
 
index 613e14c..8946664 100644 (file)
 #ifndef _BATYPE_H_
 #define _BATYPE_H_
 
-#define                TOTAL_TXBA_NUM  16
-#define        TOTAL_RXBA_NUM  16
-
 #define        BA_SETUP_TIMEOUT        200
-#define        BA_INACT_TIMEOUT        60000
 
 #define        BA_POLICY_DELAYED               0
 #define        BA_POLICY_IMMEDIATE     1
@@ -32,7 +28,6 @@
 #define        ADDBA_STATUS_REFUSED            37
 #define        ADDBA_STATUS_INVALID_PARAM      38
 
-#define        DELBA_REASON_QSTA_LEAVING       36
 #define        DELBA_REASON_END_BA                     37
 #define        DELBA_REASON_UNKNOWN_BA 38
 #define        DELBA_REASON_TIMEOUT                    39
index 0c263d9..51711dc 100644 (file)
@@ -20,8 +20,6 @@
 #define _RTL819XU_HTTYPE_H_
 
 #define MIMO_PS_STATIC                         0
-#define MIMO_PS_DYNAMIC                        1
-#define MIMO_PS_NOLIMIT                        3
 
 #define sHTCLng        4
 
index b5c3647..555745b 100644 (file)
@@ -117,7 +117,7 @@ void HTUpdateDefaultSetting(struct rtllib_device *ieee)
        pHTInfo->RxReorderPendingTime = 30;
 }
 
-u16 HTMcsToDataRate(struct rtllib_device *ieee, u8 nMcsRate)
+static u16 HTMcsToDataRate(struct rtllib_device *ieee, u8 nMcsRate)
 {
        struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
 
@@ -502,7 +502,8 @@ u8 HTGetHighestMCSRate(struct rtllib_device *ieee, u8 *pMCSRateSet,
        return mcsRate | 0x80;
 }
 
-u8 HTFilterMCSRate(struct rtllib_device *ieee, u8 *pSupportMCS, u8 *pOperateMCS)
+static u8 HTFilterMCSRate(struct rtllib_device *ieee, u8 *pSupportMCS,
+                         u8 *pOperateMCS)
 {
 
        u8 i;
index 3aa35ce..fcc8fab 100644 (file)
@@ -96,11 +96,6 @@ struct octet_string {
        u16 Length;
 };
 
-enum ack_policy {
-       eAckPlc0_ACK            = 0x00,
-       eAckPlc1_NoACK          = 0x01,
-};
-
 #define AC0_BE 0
 #define AC1_BK 1
 #define AC2_VI 2
index b8fed55..a93348c 100644 (file)
@@ -19,8 +19,6 @@
 #ifndef _TSTYPE_H_
 #define _TSTYPE_H_
 #include "rtl819x_Qos.h"
-#define TS_SETUP_TIMEOUT       60
-#define TS_INACT_TIMEOUT       60
 #define TS_ADDBA_DELAY         60
 
 #define TOTAL_TS_NUM           16
index 05aea43..7087959 100644 (file)
@@ -113,7 +113,7 @@ static void TsAddBaProcess(unsigned long data)
 
 static void ResetTsCommonInfo(struct ts_common_info *pTsCommonInfo)
 {
-       memset(pTsCommonInfo->Addr, 0, 6);
+       eth_zero_addr(pTsCommonInfo->Addr);
        memset(&pTsCommonInfo->TSpec, 0, sizeof(union tspec_body));
        memset(&pTsCommonInfo->TClass, 0, sizeof(union qos_tclas)*TCLAS_NUM);
        pTsCommonInfo->TClasProc = 0;
index fd38c6d..617f79e 100644 (file)
@@ -84,9 +84,6 @@
 #define iwe_stream_add_point_rsl(info, start, stop, iwe, p)    \
        iwe_stream_add_point(info, start, stop, iwe, p)
 
-#define usb_alloc_urb_rsl(x, y) usb_alloc_urb(x, y)
-#define usb_submit_urb_rsl(x, y) usb_submit_urb(x, y)
-
 static inline void *netdev_priv_rsl(struct net_device *dev)
 {
        return netdev_priv(dev);
@@ -110,27 +107,14 @@ static inline void *netdev_priv_rsl(struct net_device *dev)
 #define HIGH_QUEUE                          7
 #define BEACON_QUEUE                      8
 
-#define LOW_QUEUE                            BE_QUEUE
-#define NORMAL_QUEUE                      MGNT_QUEUE
-
 #ifndef IW_MODE_MESH
 #define IW_MODE_MESH                   7
 #endif
-#define AMSDU_SUBHEADER_LEN 14
-#define SWRF_TIMEOUT                           50
 
 #define IE_CISCO_FLAG_POSITION         0x08
 #define SUPPORT_CKIP_MIC                       0x08
 #define SUPPORT_CKIP_PK                        0x10
-#define        RT_RF_OFF_LEVL_ASPM                     BIT0
-#define        RT_RF_OFF_LEVL_CLK_REQ          BIT1
-#define        RT_RF_OFF_LEVL_PCI_D3                   BIT2
 #define        RT_RF_OFF_LEVL_HALT_NIC         BIT3
-#define        RT_RF_OFF_LEVL_FREE_FW          BIT4
-#define        RT_RF_OFF_LEVL_FW_32K           BIT5
-#define        RT_RF_PS_LEVEL_ALWAYS_ASPM      BIT6
-#define        RT_RF_LPS_DISALBE_2R                    BIT30
-#define        RT_RF_LPS_LEVEL_ASPM                    BIT31
 #define        RT_IN_PS_LEVEL(pPSC, _PS_FLAG)          \
        ((pPSC->CurPsLevel & _PS_FLAG) ? true : false)
 #define        RT_CLEAR_PS_LEVEL(pPSC, _PS_FLAG)       \
@@ -244,22 +228,6 @@ struct sw_chnl_cmd {
 #define MGN_MCS13             0x8d
 #define MGN_MCS14             0x8e
 #define MGN_MCS15             0x8f
-#define        MGN_MCS0_SG                     0x90
-#define        MGN_MCS1_SG                     0x91
-#define        MGN_MCS2_SG                     0x92
-#define        MGN_MCS3_SG                     0x93
-#define        MGN_MCS4_SG                     0x94
-#define        MGN_MCS5_SG                     0x95
-#define        MGN_MCS6_SG                     0x96
-#define        MGN_MCS7_SG                     0x97
-#define        MGN_MCS8_SG                     0x98
-#define        MGN_MCS9_SG                     0x99
-#define        MGN_MCS10_SG            0x9a
-#define        MGN_MCS11_SG            0x9b
-#define        MGN_MCS12_SG            0x9c
-#define        MGN_MCS13_SG            0x9d
-#define        MGN_MCS14_SG            0x9e
-#define        MGN_MCS15_SG            0x9f
 
 enum hw_variables {
        HW_VAR_ETHER_ADDR,
@@ -722,42 +690,13 @@ struct rtllib_frag_entry {
        u8 dst_addr[ETH_ALEN];
 };
 
-struct rtllib_stats {
-       unsigned int tx_unicast_frames;
-       unsigned int tx_multicast_frames;
-       unsigned int tx_fragments;
-       unsigned int tx_unicast_octets;
-       unsigned int tx_multicast_octets;
-       unsigned int tx_deferred_transmissions;
-       unsigned int tx_single_retry_frames;
-       unsigned int tx_multiple_retry_frames;
-       unsigned int tx_retry_limit_exceeded;
-       unsigned int tx_discards;
-       unsigned int rx_unicast_frames;
-       unsigned int rx_multicast_frames;
-       unsigned int rx_fragments;
-       unsigned int rx_unicast_octets;
-       unsigned int rx_multicast_octets;
-       unsigned int rx_fcs_errors;
-       unsigned int rx_discards_no_buffer;
-       unsigned int tx_discards_wrong_sa;
-       unsigned int rx_discards_undecryptable;
-       unsigned int rx_message_in_msg_fragments;
-       unsigned int rx_message_in_bad_msg_fragments;
-};
-
 struct rtllib_device;
 
-#define SEC_KEY_1       (1<<0)
-#define SEC_KEY_2       (1<<1)
-#define SEC_KEY_3       (1<<2)
-#define SEC_KEY_4       (1<<3)
 #define SEC_ACTIVE_KEY    (1<<4)
 #define SEC_AUTH_MODE     (1<<5)
 #define SEC_UNICAST_GROUP (1<<6)
 #define SEC_LEVEL       (1<<7)
 #define SEC_ENABLED       (1<<8)
-#define SEC_ENCRYPT       (1<<9)
 
 #define SEC_LEVEL_0      0 /* None */
 #define SEC_LEVEL_1      1 /* WEP 40 and 104 bit */
@@ -772,7 +711,6 @@ struct rtllib_device;
 
 #define WEP_KEY_LEN            13
 #define SCM_KEY_LEN            32
-#define SCM_TEMPORAL_KEY_LENGTH 16
 
 struct rtllib_security {
        u16 active_key:2,
@@ -1187,8 +1125,6 @@ enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame};
 #define WME_AC_BE   0x01
 #define WME_AC_VI   0x02
 #define WME_AC_VO   0x03
-#define WME_ACI_MASK 0x03
-#define WME_AIFSN_MASK 0x03
 #define WME_AC_PRAM_LEN 16
 
 #define MAX_RECEIVE_BUFFER_SIZE 9100
@@ -1204,12 +1140,6 @@ enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame};
 #define ETHERNET_HEADER_SIZE    14      /* length of two Ethernet address
                                         * plus ether type*/
 
-struct ether_header {
-       u8 ether_dhost[ETHER_ADDR_LEN];
-       u8 ether_shost[ETHER_ADDR_LEN];
-       u16 ether_type;
-} __packed;
-
 enum erp_t {
        ERP_NonERPpresent       = 0x01,
        ERP_UseProtection       = 0x02,
@@ -1591,7 +1521,6 @@ struct rtllib_device {
 
        /* Bookkeeping structures */
        struct net_device_stats stats;
-       struct rtllib_stats ieee_stats;
        struct rtllib_softmac_stats softmac_stats;
 
        /* Probe / Beacon management */
@@ -1673,7 +1602,6 @@ struct rtllib_device {
        int short_slot;
        int mode;       /* A, B, G */
        int modulation; /* CCK, OFDM */
-       int freq_band;  /* 2.4Ghz, 5.2Ghz, Mixed */
 
        /* used for forcing the ibss workqueue to terminate
         * without wait for the syncro scan to terminate
@@ -2067,15 +1995,11 @@ extern int rtllib_encrypt_fragment(
        int hdr_len);
 
 extern int rtllib_xmit(struct sk_buff *skb,  struct net_device *dev);
-extern int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev);
 extern void rtllib_txb_free(struct rtllib_txb *);
 
 /* rtllib_rx.c */
 extern int rtllib_rx(struct rtllib_device *ieee, struct sk_buff *skb,
                        struct rtllib_rx_stats *rx_stats);
-extern void rtllib_rx_mgt(struct rtllib_device *ieee,
-                            struct sk_buff *skb,
-                            struct rtllib_rx_stats *stats);
 extern void rtllib_rx_probe_rq(struct rtllib_device *ieee,
                           struct sk_buff *skb);
 extern int rtllib_legal_channel(struct rtllib_device *rtllib, u8 channel);
@@ -2102,7 +2026,6 @@ extern int rtllib_wx_set_mlme(struct rtllib_device *ieee,
 extern int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len);
 
 /* rtllib_softmac.c */
-extern short rtllib_is_54g(struct rtllib_network *net);
 extern int rtllib_rx_frame_softmac(struct rtllib_device *ieee,
                                   struct sk_buff *skb,
                                   struct rtllib_rx_stats *rx_stats, u16 type,
@@ -2116,13 +2039,9 @@ extern void rtllib_softmac_xmit(struct rtllib_txb *txb,
 
 extern void rtllib_stop_send_beacons(struct rtllib_device *ieee);
 extern void notify_wx_assoc_event(struct rtllib_device *ieee);
-extern void rtllib_softmac_check_all_nets(struct rtllib_device *ieee);
-extern void rtllib_start_bss(struct rtllib_device *ieee);
-extern void rtllib_start_master_bss(struct rtllib_device *ieee);
 extern void rtllib_start_ibss(struct rtllib_device *ieee);
 extern void rtllib_softmac_init(struct rtllib_device *ieee);
 extern void rtllib_softmac_free(struct rtllib_device *ieee);
-extern void rtllib_associate_abort(struct rtllib_device *ieee);
 extern void rtllib_disassociate(struct rtllib_device *ieee);
 extern void rtllib_stop_scan(struct rtllib_device *ieee);
 extern bool rtllib_act_scanning(struct rtllib_device *ieee, bool sync_scan);
@@ -2130,7 +2049,6 @@ extern void rtllib_stop_scan_syncro(struct rtllib_device *ieee);
 extern void rtllib_start_scan_syncro(struct rtllib_device *ieee, u8 is_mesh);
 extern void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee,
                                          short pwr);
-extern void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl);
 extern void rtllib_sta_ps_send_pspoll_frame(struct rtllib_device *ieee);
 extern void rtllib_start_protocol(struct rtllib_device *ieee);
 extern void rtllib_stop_protocol(struct rtllib_device *ieee, u8 shutdown);
@@ -2143,8 +2061,6 @@ extern void rtllib_EnableIntelPromiscuousMode(struct net_device *dev,
                                              bool bInitState);
 extern void rtllib_DisableIntelPromiscuousMode(struct net_device *dev,
                                               bool bInitState);
-extern void rtllib_send_probe_requests(struct rtllib_device *ieee, u8 is_mesh);
-
 extern void rtllib_softmac_stop_protocol(struct rtllib_device *ieee,
                                         u8 mesh_flag, u8 shutdown);
 extern void rtllib_softmac_start_protocol(struct rtllib_device *ieee,
@@ -2164,8 +2080,6 @@ extern void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success);
 
 extern void softmac_mgmt_xmit(struct sk_buff *skb,
                              struct rtllib_device *ieee);
-extern u16 rtllib_query_seqnum(struct rtllib_device *ieee,
-                              struct sk_buff *skb, u8 *dst);
 extern u8 rtllib_ap_sec_type(struct rtllib_device *ieee);
 
 /* rtllib_softmac_wx.c */
@@ -2266,7 +2180,6 @@ extern u16 MCS_DATA_RATE[2][2][77];
 extern u8 HTCCheck(struct rtllib_device *ieee, u8 *pFrame);
 extern void HTResetIOTSetting(struct rt_hi_throughput *pHTInfo);
 extern bool IsHTHalfNmodeAPs(struct rtllib_device *ieee);
-extern u16 HTMcsToDataRate(struct rtllib_device *ieee, u8 nMcsRate);
 extern u16  TxCountToDataRate(struct rtllib_device *ieee, u8 nDataRate);
 extern int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb);
 extern int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb);
@@ -2293,7 +2206,6 @@ extern  void TsStartAddBaProcess(struct rtllib_device *ieee,
                                  struct tx_ts_record *pTxTS);
 extern void RemovePeerTS(struct rtllib_device *ieee, u8 *Addr);
 extern void RemoveAllTS(struct rtllib_device *ieee);
-void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh);
 
 extern const long rtllib_wlan_frequencies[];
 
@@ -2317,7 +2229,6 @@ bool rtllib_MgntDisconnect(struct rtllib_device *rtllib, u8 asRsn);
 /* For the function is more related to hardware setting, it's better to use the
  * ieee handler to refer to it.
  */
-extern void rtllib_update_active_chan_map(struct rtllib_device *ieee);
 extern void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee,
                                        struct rx_ts_record *pTS);
 extern int rtllib_parse_info_param(struct rtllib_device *ieee,
@@ -2328,12 +2239,9 @@ extern int rtllib_parse_info_param(struct rtllib_device *ieee,
 
 void rtllib_indicate_packets(struct rtllib_device *ieee,
                             struct rtllib_rxb **prxbIndicateArray, u8  index);
-extern u8 HTFilterMCSRate(struct rtllib_device *ieee, u8 *pSupportMCS,
-                         u8 *pOperateMCS);
 extern void HTUseDefaultSetting(struct rtllib_device *ieee);
 #define RT_ASOC_RETRY_LIMIT    5
 u8 MgntQuery_TxRateExcludeCCKRates(struct rtllib_device *ieee);
-extern void rtllib_TURBO_Info(struct rtllib_device *ieee, u8 **tag_p);
 #define SEM_DOWN_IEEE_WX(psem) down(psem)
 #define SEM_UP_IEEE_WX(psem) up(psem)
 
index 42e88d6..17c276d 100644 (file)
@@ -30,8 +30,6 @@
 #define DRV_NAME "rtllib_92e"
 #endif
 
-#define DMESG(x, a...)
-
 extern u32 rt_global_debug_component;
 
 /* These are the defines for rt_global_debug_component */
@@ -40,10 +38,7 @@ enum RTL_DEBUG {
        COMP_DBG                = (1 << 1),
        COMP_INIT               = (1 << 2),
        COMP_RECV               = (1 << 3),
-       COMP_SEND               = (1 << 4),
-       COMP_CMD                = (1 << 5),
        COMP_POWER              = (1 << 6),
-       COMP_EPROM              = (1 << 7),
        COMP_SWBW               = (1 << 8),
        COMP_SEC                = (1 << 9),
        COMP_LPS                = (1 << 10),
@@ -58,15 +53,12 @@ enum RTL_DEBUG {
        COMP_CH                 = (1 << 19),
        COMP_RF                 = (1 << 20),
        COMP_FIRMWARE           = (1 << 21),
-       COMP_HT                 = (1 << 22),
        COMP_RESET              = (1 << 23),
        COMP_CMDPKT             = (1 << 24),
        COMP_SCAN               = (1 << 25),
        COMP_PS                 = (1 << 26),
        COMP_DOWN               = (1 << 27),
        COMP_INTR               = (1 << 28),
-       COMP_LED                = (1 << 29),
-       COMP_MLME               = (1 << 30),
        COMP_ERR                = (1 << 31)
 };
 
index da862c3..54dfff6 100644 (file)
@@ -44,6 +44,9 @@
 #include "rtllib.h"
 #include "dot11d.h"
 
+static void rtllib_rx_mgt(struct rtllib_device *ieee, struct sk_buff *skb,
+                         struct rtllib_rx_stats *stats);
+
 static inline void rtllib_monitor_rx(struct rtllib_device *ieee,
                                     struct sk_buff *skb,
                                     struct rtllib_rx_stats *rx_status,
@@ -317,7 +320,6 @@ rtllib_rx_frame_decrypt(struct rtllib_device *ieee, struct sk_buff *skb,
                        netdev_dbg(ieee->dev,
                                   "Decryption failed ICV mismatch (key %d)\n",
                                   skb->data[hdrlen + 3] >> 6);
-               ieee->ieee_stats.rx_discards_undecryptable++;
                return -1;
        }
 
@@ -1077,7 +1079,6 @@ static int rtllib_rx_get_crypt(struct rtllib_device *ieee, struct sk_buff *skb,
                        netdev_dbg(ieee->dev,
                                   "Decryption failed (not set) (SA= %pM)\n",
                                   hdr->addr2);
-                       ieee->ieee_stats.rx_discards_undecryptable++;
                        return -1;
                }
        }
@@ -2717,9 +2718,9 @@ free_network:
        kfree(network);
 }
 
-void rtllib_rx_mgt(struct rtllib_device *ieee,
-                     struct sk_buff *skb,
-                     struct rtllib_rx_stats *stats)
+static void rtllib_rx_mgt(struct rtllib_device *ieee,
+                         struct sk_buff *skb,
+                         struct rtllib_rx_stats *stats)
 {
        struct rtllib_hdr_4addr *header = (struct rtllib_hdr_4addr *)skb->data;
 
index d320c31..1503cbb 100644 (file)
 #include <linux/ieee80211.h>
 #include "dot11d.h"
 
-short rtllib_is_54g(struct rtllib_network *net)
+static void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl);
+
+
+static short rtllib_is_54g(struct rtllib_network *net)
 {
        return (net->rates_ex_len > 0) || (net->rates_len > 4);
 }
@@ -107,7 +110,7 @@ static void rtllib_WMM_Info(struct rtllib_device *ieee, u8 **tag_p)
        *tag_p = tag;
 }
 
-void rtllib_TURBO_Info(struct rtllib_device *ieee, u8 **tag_p)
+static void rtllib_TURBO_Info(struct rtllib_device *ieee, u8 **tag_p)
 {
        u8 *tag = *tag_p;
 
@@ -369,7 +372,7 @@ static inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee)
        return skb;
 }
 
-struct sk_buff *rtllib_get_beacon_(struct rtllib_device *ieee);
+static struct sk_buff *rtllib_get_beacon_(struct rtllib_device *ieee);
 
 static void rtllib_send_beacon(struct rtllib_device *ieee)
 {
@@ -483,7 +486,7 @@ static void rtllib_send_probe(struct rtllib_device *ieee, u8 is_mesh)
 }
 
 
-void rtllib_send_probe_requests(struct rtllib_device *ieee, u8 is_mesh)
+static void rtllib_send_probe_requests(struct rtllib_device *ieee, u8 is_mesh)
 {
        if (ieee->active_scan && (ieee->softmac_features &
            IEEE_SOFTMAC_PROBERQ)) {
@@ -492,7 +495,7 @@ void rtllib_send_probe_requests(struct rtllib_device *ieee, u8 is_mesh)
        }
 }
 
-void rtllib_update_active_chan_map(struct rtllib_device *ieee)
+static void rtllib_update_active_chan_map(struct rtllib_device *ieee)
 {
        memcpy(ieee->active_channel_map, GET_DOT11D_INFO(ieee)->channel_map,
               MAX_CHANNEL_NUMBER+1);
@@ -501,7 +504,7 @@ void rtllib_update_active_chan_map(struct rtllib_device *ieee)
 /* this performs syncro scan blocking the caller until all channels
  * in the allowed channel map has been checked.
  */
-void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh)
+static void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh)
 {
        union iwreq_data wrqu;
        short ch = 0;
@@ -1401,7 +1404,7 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,
        return skb;
 }
 
-void rtllib_associate_abort(struct rtllib_device *ieee)
+static void rtllib_associate_abort(struct rtllib_device *ieee)
 {
        unsigned long flags;
 
@@ -1511,7 +1514,6 @@ static void rtllib_associate_step2(struct rtllib_device *ieee)
        }
 }
 
-#define CANCELLED  2
 static void rtllib_associate_complete_wq(void *data)
 {
        struct rtllib_device *ieee = (struct rtllib_device *)
@@ -1753,7 +1755,7 @@ inline void rtllib_softmac_new_net(struct rtllib_device *ieee,
        }
 }
 
-void rtllib_softmac_check_all_nets(struct rtllib_device *ieee)
+static void rtllib_softmac_check_all_nets(struct rtllib_device *ieee)
 {
        unsigned long flags;
        struct rtllib_network *target;
@@ -2109,7 +2111,7 @@ out:
 
 }
 
-void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl)
+static void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl)
 {
        if (ieee->sta_sleep == LPS_IS_WAKE) {
                if (nl) {
@@ -2545,7 +2547,7 @@ inline void rtllib_randomize_cell(struct rtllib_device *ieee)
 }
 
 /* called in user context only */
-void rtllib_start_master_bss(struct rtllib_device *ieee)
+static void rtllib_start_master_bss(struct rtllib_device *ieee)
 {
        ieee->assoc_id = 1;
 
@@ -2720,7 +2722,7 @@ inline void rtllib_start_ibss(struct rtllib_device *ieee)
 }
 
 /* this is called only in user context, with wx_sem held */
-void rtllib_start_bss(struct rtllib_device *ieee)
+static void rtllib_start_bss(struct rtllib_device *ieee)
 {
        unsigned long flags;
 
@@ -2817,7 +2819,7 @@ exit:
        up(&ieee->wx_sem);
 }
 
-struct sk_buff *rtllib_get_beacon_(struct rtllib_device *ieee)
+static struct sk_buff *rtllib_get_beacon_(struct rtllib_device *ieee)
 {
        const u8 broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
 
@@ -3084,7 +3086,7 @@ static int rtllib_wpa_enable(struct rtllib_device *ieee, int value)
         */
        netdev_info(ieee->dev, "%s WPA\n", value ? "enabling" : "disabling");
        ieee->wpa_enabled = value;
-       memset(ieee->ap_mac_addr, 0, 6);
+       eth_zero_addr(ieee->ap_mac_addr);
        return 0;
 }
 
index e99ea5e..b992e46 100644 (file)
 static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 };
 static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 };
 
-inline int rtllib_put_snap(u8 *data, u16 h_proto)
+static int rtllib_put_snap(u8 *data, u16 h_proto)
 {
        struct rtllib_snap_hdr *snap;
        u8 *oui;
@@ -205,7 +205,6 @@ int rtllib_encrypt_fragment(struct rtllib_device *ieee, struct sk_buff *frag,
        if (res < 0) {
                netdev_info(ieee->dev, "%s: Encryption failed: len=%d.\n",
                            ieee->dev->name, frag->len);
-               ieee->ieee_stats.tx_discards++;
                return -1;
        }
 
@@ -515,8 +514,8 @@ static void rtllib_txrate_selectmode(struct rtllib_device *ieee,
        }
 }
 
-u16 rtllib_query_seqnum(struct rtllib_device *ieee, struct sk_buff *skb,
-                       u8 *dst)
+static u16 rtllib_query_seqnum(struct rtllib_device *ieee, struct sk_buff *skb,
+                              u8 *dst)
 {
        u16 seqnum = 0;
 
@@ -566,7 +565,7 @@ static u8 rtllib_current_rate(struct rtllib_device *ieee)
                return ieee->rate & 0x7F;
 }
 
-int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
+static int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
 {
        struct rtllib_device *ieee = (struct rtllib_device *)
                                     netdev_priv_rsl(dev);
index 1b11acb..a1f9d42 100644 (file)
@@ -1177,7 +1177,7 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beaco
                        tag = skb_put(skb, ht_cap_len);
                        *tag++ = MFIE_TYPE_HT_CAP;
                        *tag++ = ht_cap_len - 2;
-                       memcpy(tag, ht_cap_buf,ht_cap_len -2);
+                       memcpy(tag, ht_cap_buf, ht_cap_len - 2);
                        tag += ht_cap_len -2;
                }
        }
@@ -1214,7 +1214,7 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beaco
                        tag = skb_put(skb, realtek_ie_len);
                        *tag++ = MFIE_TYPE_GENERIC;
                        *tag++ = realtek_ie_len - 2;
-                       memcpy(tag, realtek_ie_buf,realtek_ie_len -2 );
+                       memcpy(tag, realtek_ie_buf, realtek_ie_len - 2);
                }
        }
 //     printk("<=====%s(), %p, %p\n", __func__, ieee->dev, ieee->dev->dev_addr);
index 714fbca..3e50252 100644 (file)
@@ -391,7 +391,7 @@ int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
                              union iwreq_data *wrqu, char *extra)
 {
 
-       int ret=0,len;
+       int ret = 0, len;
        short proto_started;
        unsigned long flags;
 
index c2588f8..80411c9 100644 (file)
@@ -956,7 +956,7 @@ void HTOnAssocRsp(struct ieee80211_device *ieee)
 //     HTDebugHTCapability(pHTInfo->PeerHTCapBuf,"HTOnAssocRsp_wq");
 //     HTDebugHTInfo(pHTInfo->PeerHTInfoBuf,"HTOnAssocRsp_wq");
        //
-       if(!memcmp(pHTInfo->PeerHTCapBuf,EWC11NHTCap, sizeof(EWC11NHTCap)))
+       if (!memcmp(pHTInfo->PeerHTCapBuf, EWC11NHTCap, sizeof(EWC11NHTCap)))
                pPeerHTCap = (PHT_CAPABILITY_ELE)(&pHTInfo->PeerHTCapBuf[4]);
        else
                pPeerHTCap = (PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf);
index ea92fde..b89105d 100644 (file)
@@ -112,7 +112,7 @@ static void TsAddBaProcess(unsigned long data)
 
 static void ResetTsCommonInfo(PTS_COMMON_INFO pTsCommonInfo)
 {
-       memset(pTsCommonInfo->Addr, 0, 6);
+       eth_zero_addr(pTsCommonInfo->Addr);
        memset(&pTsCommonInfo->TSpec, 0, sizeof(TSPEC_BODY));
        memset(&pTsCommonInfo->TClass, 0, sizeof(QOS_TCLAS)*TCLAS_NUM);
        pTsCommonInfo->TClasProc = 0;
index d27b1e2..742725e 100644 (file)
@@ -66,7 +66,7 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address,
                skb  = dev_alloc_skb(USB_HWDESC_HEADER_LEN + frag_length + 4);
                if (!skb)
                        return false;
-               memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev));
+               memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev));
                tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
                tcb_desc->queue_index = TXCMD_QUEUE;
                tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_INIT;
index fcb8c61..4fa2540 100644 (file)
@@ -58,8 +58,8 @@ int r8712_init_recv_priv(struct recv_priv *precvpriv, struct _adapter *padapter)
 
        /*init recv_buf*/
        _init_queue(&precvpriv->free_recv_buf_queue);
-       precvpriv->pallocated_recv_buf = kzalloc(NR_RECVBUFF * sizeof(struct recv_buf) + 4,
-                                                GFP_ATOMIC);
+       precvpriv->pallocated_recv_buf =
+               kzalloc(NR_RECVBUFF * sizeof(struct recv_buf) + 4, GFP_ATOMIC);
        if (precvpriv->pallocated_recv_buf == NULL)
                return _FAIL;
        precvpriv->precv_buf = precvpriv->pallocated_recv_buf + 4 -
index bcd1a51..8627928 100644 (file)
@@ -124,28 +124,25 @@ static u8 crc32_reverseBit(u8 data)
 
 static void crc32_init(void)
 {
+       sint i, j;
+       u32 c;
+       u8 *p = (u8 *)&c, *p1;
+       u8 k;
+
        if (bcrc32initialized == 1)
                return;
-       else {
-               sint i, j;
-               u32 c;
-               u8 *p = (u8 *)&c, *p1;
-               u8 k;
-
-               c = 0x12340000;
-               for (i = 0; i < 256; ++i) {
-                       k = crc32_reverseBit((u8)i);
-                       for (c = ((u32)k) << 24, j = 8; j > 0; --j)
-                               c = c & 0x80000000 ? (c << 1) ^ CRC32_POLY :
-                                   (c << 1);
-                       p1 = (u8 *)&crc32_table[i];
-                       p1[0] = crc32_reverseBit(p[3]);
-                       p1[1] = crc32_reverseBit(p[2]);
-                       p1[2] = crc32_reverseBit(p[1]);
-                       p1[3] = crc32_reverseBit(p[0]);
-               }
-               bcrc32initialized = 1;
+
+       for (i = 0; i < 256; ++i) {
+               k = crc32_reverseBit((u8)i);
+               for (c = ((u32)k) << 24, j = 8; j > 0; --j)
+                       c = c & 0x80000000 ? (c << 1) ^ CRC32_POLY : (c << 1);
+               p1 = (u8 *)&crc32_table[i];
+               p1[0] = crc32_reverseBit(p[3]);
+               p1[1] = crc32_reverseBit(p[2]);
+               p1[2] = crc32_reverseBit(p[1]);
+               p1[3] = crc32_reverseBit(p[0]);
        }
+       bcrc32initialized = 1;
 }
 
 static u32 getcrc32(u8 *buf, u32 len)
index f354f5e..6b9dbef 100644 (file)
@@ -985,7 +985,7 @@ void ODM_RF_Saving23a(struct dm_odm_t *pDM_Odm, u8 bForceInNormal)
                        val32 = rtl8723au_read32(adapter, 0x874);
                        val32 |= pDM_PSTable->Reg874;
                        rtl8723au_write32(adapter, 0x874, val32);
-               
+
                        val32 = rtl8723au_read32(adapter, 0xc70);
                        val32 |= pDM_PSTable->RegC70;
                        rtl8723au_write32(adapter, 0xc70, val32);
index a8d657b..cb41579 100644 (file)
@@ -3520,12 +3520,11 @@ int reset_sd_card(struct rtsx_chip *chip)
                        if (chip->sd_io) {
                                rtsx_trace(chip);
                                return STATUS_FAIL;
-                       } else {
-                               retval = reset_mmc(chip);
-                               if (retval != STATUS_SUCCESS) {
-                                       rtsx_trace(chip);
-                                       return STATUS_FAIL;
-                               }
+                       }
+                       retval = reset_mmc(chip);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                }
        }
index f4975d2..5e6798e 100644 (file)
@@ -268,7 +268,7 @@ int ddk750_initHw(initchip_param_t *pInitParam)
 #endif
 
 
-       if (pInitParam->powerMode != 0 )
+       if (pInitParam->powerMode != 0)
                pInitParam->powerMode = 0;
        setPowerMode(pInitParam->powerMode);
 
@@ -464,17 +464,18 @@ unsigned int calcPllValue(unsigned int request_orig, pll_value_t *pll)
                RN = N * request;
                quo = RN / input;
                rem = RN % input;/* rem always small than 14318181 */
-               fl_quo = (rem * 10000 /input);
+               fl_quo = (rem * 10000 / input);
 
                for (d = xcnt - 1; d >= 0; d--) {
                        X = xparm[d].value;
                        M = quo*X;
                        M += fl_quo * X / 10000;
                        /* round step */
-                       M += (fl_quo*X % 10000)>5000?1:0;
+                       M += (fl_quo*X % 10000) > 5000?1:0;
                        if (M < 256 && M > 0) {
                                unsigned int diff;
-                               tmpClock = pll->inputFreq *M / N / X;
+
+                               tmpClock = pll->inputFreq * M / N / X;
                                diff = absDiff(tmpClock, request_orig);
                                if (diff < miniDiff) {
                                        pll->M = M;
@@ -599,9 +600,9 @@ unsigned int formatPllReg(pll_value_t *pPLL)
        On returning a 32 bit number, the value can be applied to any PLL in the calling function.
     */
        ulPllReg =
-       FIELD_SET(  0, PANEL_PLL_CTRL, BYPASS, OFF)
-       | FIELD_SET(  0, PANEL_PLL_CTRL, POWER,  ON)
-       | FIELD_SET(  0, PANEL_PLL_CTRL, INPUT,  OSC)
+       FIELD_SET(0, PANEL_PLL_CTRL, BYPASS, OFF)
+       | FIELD_SET(0, PANEL_PLL_CTRL, POWER,  ON)
+       | FIELD_SET(0, PANEL_PLL_CTRL, INPUT,  OSC)
 #ifndef VALIDATION_CHIP
        | FIELD_VALUE(0, PANEL_PLL_CTRL, POD,    pPLL->POD)
 #endif
index 4e030e8..6ff0436 100644 (file)
@@ -8,8 +8,7 @@
 #include <linux/io.h>
 
 /* This is all the chips recognized by this library */
-typedef enum _logical_chip_type_t
-{
+typedef enum _logical_chip_type_t {
        SM_UNKNOWN,
        SM718,
        SM750,
@@ -18,8 +17,7 @@ typedef enum _logical_chip_type_t
 logical_chip_type_t;
 
 
-typedef enum _clock_type_t
-{
+typedef enum _clock_type_t {
        MXCLK_PLL,
        PRIMARY_PLL,
        SECONDARY_PLL,
@@ -28,8 +26,7 @@ typedef enum _clock_type_t
 }
 clock_type_t;
 
-typedef struct _pll_value_t
-{
+typedef struct _pll_value_t {
        clock_type_t clockType;
        unsigned long inputFreq; /* Input clock frequency to the PLL */
 
@@ -42,8 +39,7 @@ typedef struct _pll_value_t
 pll_value_t;
 
 /* input struct to initChipParam() function */
-typedef struct _initchip_param_t
-{
+typedef struct _initchip_param_t {
        unsigned short powerMode;    /* Use power mode 0 or 1 */
        unsigned short chipClock;    /**
                                      * Speed of main chip clock in MHz unit
index a3e6720..8348113 100644 (file)
@@ -15,16 +15,14 @@ static void setDisplayControl(int ctrl, int dispState)
        cnt = 0;
 
        /* Set the primary display control */
-       if (!ctrl)
-       {
+       if (!ctrl) {
                ulDisplayCtrlReg = PEEK32(PANEL_DISPLAY_CTRL);
                /* Turn on/off the Panel display control */
-               if (dispState)
-               {
+               if (dispState) {
                        /* Timing should be enabled first before enabling the plane
                         * because changing at the same time does not guarantee that
                         * the plane will also enabled or disabled.
-            */
+                        */
                        ulDisplayCtrlReg = FIELD_SET(ulDisplayCtrlReg,
                                                                PANEL_DISPLAY_CTRL, TIMING, ENABLE);
                        POKE32(PANEL_DISPLAY_CTRL, ulDisplayCtrlReg);
@@ -45,16 +43,13 @@ static void setDisplayControl(int ctrl, int dispState)
                         * until a few delay. Need to write
                         * and read it a couple times
                         */
-                       do
-                       {
+                       do {
                                cnt++;
                                POKE32(PANEL_DISPLAY_CTRL, ulDisplayCtrlReg);
-                       } while((PEEK32(PANEL_DISPLAY_CTRL) & ~ulReservedBits) !=
+                       } while ((PEEK32(PANEL_DISPLAY_CTRL) & ~ulReservedBits) !=
                                        (ulDisplayCtrlReg & ~ulReservedBits));
                        printk("Set Panel Plane enbit:after tried %d times\n", cnt);
-               }
-               else
-               {
+               } else {
                        /* When turning off, there is no rule on the programming
                         * sequence since whenever the clock is off, then it does not
                         * matter whether the plane is enabled or disabled.
@@ -71,14 +66,11 @@ static void setDisplayControl(int ctrl, int dispState)
                        POKE32(PANEL_DISPLAY_CTRL, ulDisplayCtrlReg);
                }
 
-       }
-       /* Set the secondary display control */
-       else
-       {
+       } else {
+               /* Set the secondary display control */
                ulDisplayCtrlReg = PEEK32(CRT_DISPLAY_CTRL);
 
-               if (dispState)
-               {
+               if (dispState) {
                        /* Timing should be enabled first before enabling the plane because changing at the
                           same time does not guarantee that the plane will also enabled or disabled.
                           */
@@ -100,16 +92,13 @@ static void setDisplayControl(int ctrl, int dispState)
                                FIELD_SET(0, CRT_DISPLAY_CTRL, RESERVED_3_MASK, ENABLE) |
                                FIELD_SET(0, CRT_DISPLAY_CTRL, RESERVED_4_MASK, ENABLE);
 
-                       do
-                       {
+                       do {
                                cnt++;
                                POKE32(CRT_DISPLAY_CTRL, ulDisplayCtrlReg);
-                       } while((PEEK32(CRT_DISPLAY_CTRL) & ~ulReservedBits) !=
+                       } while ((PEEK32(CRT_DISPLAY_CTRL) & ~ulReservedBits) !=
                                        (ulDisplayCtrlReg & ~ulReservedBits));
                                printk("Set Crt Plane enbit:after tried %d times\n", cnt);
-               }
-               else
-               {
+               } else {
                        /* When turning off, there is no rule on the programming
                         * sequence since whenever the clock is off, then it does not
                         * matter whether the plane is enabled or disabled.
@@ -132,71 +121,60 @@ static void setDisplayControl(int ctrl, int dispState)
 static void waitNextVerticalSync(int ctrl, int delay)
 {
        unsigned int status;
-       if(!ctrl){
+
+       if (!ctrl) {
                /* primary controller */
 
-        /* Do not wait when the Primary PLL is off or display control is already off.
-                  This will prevent the software to wait forever. */
+               /* Do not wait when the Primary PLL is off or display control is already off.
+                  This will prevent the software to wait forever. */
                if ((FIELD_GET(PEEK32(PANEL_PLL_CTRL), PANEL_PLL_CTRL, POWER) ==
                         PANEL_PLL_CTRL_POWER_OFF) ||
                        (FIELD_GET(PEEK32(PANEL_DISPLAY_CTRL), PANEL_DISPLAY_CTRL, TIMING) ==
-                        PANEL_DISPLAY_CTRL_TIMING_DISABLE))
-               {
+                        PANEL_DISPLAY_CTRL_TIMING_DISABLE)) {
                        return;
                }
 
-        while (delay-- > 0)
-        {
-            /* Wait for end of vsync. */
-            do
-            {
-                status = FIELD_GET(PEEK32(SYSTEM_CTRL),
-                                   SYSTEM_CTRL,
-                                   PANEL_VSYNC);
-            }
-            while (status == SYSTEM_CTRL_PANEL_VSYNC_ACTIVE);
-
-            /* Wait for start of vsync. */
-            do
-            {
-                status = FIELD_GET(PEEK32(SYSTEM_CTRL),
-                                   SYSTEM_CTRL,
-                                   PANEL_VSYNC);
-            }
-            while (status == SYSTEM_CTRL_PANEL_VSYNC_INACTIVE);
-        }
-
-       }else{
+               while (delay-- > 0) {
+                       /* Wait for end of vsync. */
+                       do {
+                               status = FIELD_GET(PEEK32(SYSTEM_CTRL),
+                                                  SYSTEM_CTRL,
+                                                  PANEL_VSYNC);
+                       } while (status == SYSTEM_CTRL_PANEL_VSYNC_ACTIVE);
+
+                       /* Wait for start of vsync. */
+                       do {
+                               status = FIELD_GET(PEEK32(SYSTEM_CTRL),
+                                                  SYSTEM_CTRL,
+                                                  PANEL_VSYNC);
+                       } while (status == SYSTEM_CTRL_PANEL_VSYNC_INACTIVE);
+               }
+
+       } else {
 
                /* Do not wait when the Primary PLL is off or display control is already off.
                           This will prevent the software to wait forever. */
                if ((FIELD_GET(PEEK32(CRT_PLL_CTRL), CRT_PLL_CTRL, POWER) ==
                         CRT_PLL_CTRL_POWER_OFF) ||
                        (FIELD_GET(PEEK32(CRT_DISPLAY_CTRL), CRT_DISPLAY_CTRL, TIMING) ==
-                        CRT_DISPLAY_CTRL_TIMING_DISABLE))
-               {
+                        CRT_DISPLAY_CTRL_TIMING_DISABLE)) {
                        return;
                }
 
-               while (delay-- > 0)
-               {
+               while (delay-- > 0) {
                        /* Wait for end of vsync. */
-                       do
-                       {
+                       do {
                                status = FIELD_GET(PEEK32(SYSTEM_CTRL),
                                                                   SYSTEM_CTRL,
                                                                   CRT_VSYNC);
-                       }
-                       while (status == SYSTEM_CTRL_CRT_VSYNC_ACTIVE);
+                       } while (status == SYSTEM_CTRL_CRT_VSYNC_ACTIVE);
 
                        /* Wait for start of vsync. */
-                       do
-                       {
+                       do {
                                status = FIELD_GET(PEEK32(SYSTEM_CTRL),
                                                                   SYSTEM_CTRL,
                                                                   CRT_VSYNC);
-                       }
-                       while (status == SYSTEM_CTRL_CRT_VSYNC_INACTIVE);
+                       } while (status == SYSTEM_CTRL_CRT_VSYNC_INACTIVE);
                }
        }
 }
@@ -233,14 +211,15 @@ static void swPanelPowerSequence(int disp, int delay)
 void ddk750_setLogicalDispOut(disp_output_t output)
 {
        unsigned int reg;
-       if(output & PNL_2_USAGE){
+
+       if (output & PNL_2_USAGE) {
                /* set panel path controller select */
                reg = PEEK32(PANEL_DISPLAY_CTRL);
                reg = FIELD_VALUE(reg, PANEL_DISPLAY_CTRL, SELECT, (output & PNL_2_MASK)>>PNL_2_OFFSET);
                POKE32(PANEL_DISPLAY_CTRL, reg);
        }
 
-       if(output & CRT_2_USAGE){
+       if (output & CRT_2_USAGE) {
                /* set crt path controller select */
                reg = PEEK32(CRT_DISPLAY_CTRL);
                reg = FIELD_VALUE(reg, CRT_DISPLAY_CTRL, SELECT, (output & CRT_2_MASK)>>CRT_2_OFFSET);
@@ -250,58 +229,57 @@ void ddk750_setLogicalDispOut(disp_output_t output)
 
        }
 
-       if(output & PRI_TP_USAGE){
+       if (output & PRI_TP_USAGE) {
                /* set primary timing and plane en_bit */
                setDisplayControl(0, (output&PRI_TP_MASK)>>PRI_TP_OFFSET);
        }
 
-       if(output & SEC_TP_USAGE){
+       if (output & SEC_TP_USAGE) {
                /* set secondary timing and plane en_bit*/
                setDisplayControl(1, (output&SEC_TP_MASK)>>SEC_TP_OFFSET);
        }
 
-       if(output & PNL_SEQ_USAGE){
+       if (output & PNL_SEQ_USAGE) {
                /* set  panel sequence */
                swPanelPowerSequence((output&PNL_SEQ_MASK)>>PNL_SEQ_OFFSET, 4);
        }
 
-       if(output & DAC_USAGE)
+       if (output & DAC_USAGE)
                setDAC((output & DAC_MASK)>>DAC_OFFSET);
 
-       if(output & DPMS_USAGE)
+       if (output & DPMS_USAGE)
                ddk750_setDPMS((output & DPMS_MASK) >> DPMS_OFFSET);
 }
 
 
 int ddk750_initDVIDisp(void)
 {
-    /* Initialize DVI. If the dviInit fail and the VendorID or the DeviceID are
-       not zeroed, then set the failure flag. If it is zeroe, it might mean
-       that the system is in Dual CRT Monitor configuration. */
-
-    /* De-skew enabled with default 111b value.
-       This will fix some artifacts problem in some mode on board 2.2.
-       Somehow this fix does not affect board 2.1.
-     */
-    if ((dviInit(1,  /* Select Rising Edge */
-                1,  /* Select 24-bit bus */
-                0,  /* Select Single Edge clock */
-                1,  /* Enable HSync as is */
-                1,  /* Enable VSync as is */
-                1,  /* Enable De-skew */
-                7,  /* Set the de-skew setting to maximum setup */
-                1,  /* Enable continuous Sync */
-                1,  /* Enable PLL Filter */
-                4   /* Use the recommended value for PLL Filter value */
-        ) != 0) && (dviGetVendorID() != 0x0000) && (dviGetDeviceID() != 0x0000))
-    {
-        return (-1);
-    }
-
-    /* TODO: Initialize other display component */
-
-    /* Success */
-    return 0;
+       /* Initialize DVI. If the dviInit fail and the VendorID or the DeviceID are
+          not zeroed, then set the failure flag. If it is zeroe, it might mean
+          that the system is in Dual CRT Monitor configuration. */
+
+       /* De-skew enabled with default 111b value.
+          This will fix some artifacts problem in some mode on board 2.2.
+          Somehow this fix does not affect board 2.1.
+        */
+       if ((dviInit(1,  /* Select Rising Edge */
+                    1,  /* Select 24-bit bus */
+                    0,  /* Select Single Edge clock */
+                    1,  /* Enable HSync as is */
+                    1,  /* Enable VSync as is */
+                    1,  /* Enable De-skew */
+                    7,  /* Set the de-skew setting to maximum setup */
+                    1,  /* Enable continuous Sync */
+                    1,  /* Enable PLL Filter */
+                    4   /* Use the recommended value for PLL Filter value */
+                    ) != 0) && (dviGetVendorID() != 0x0000) && (dviGetDeviceID() != 0x0000)) {
+               return (-1);
+       }
+
+       /* TODO: Initialize other display component */
+
+       /* Success */
+       return 0;
 
 }
 
index ae0f84c..abccf84 100644 (file)
@@ -8,7 +8,7 @@
 #define PNL_2_OFFSET 0
 #define PNL_2_MASK (3 << PNL_2_OFFSET)
 #define PNL_2_USAGE    (PNL_2_MASK << 16)
-#define PNL_2_PRI      ((0 << PNL_2_OFFSET)|PNL_2_USAGE)
+#define PNL_2_PRI      ((0 << PNL_2_OFFSET)|PNL_2_USAGE)
 #define PNL_2_SEC      ((2 << PNL_2_OFFSET)|PNL_2_USAGE)
 
 
@@ -46,7 +46,7 @@
        0: both off
 */
 #define SEC_TP_OFFSET 5
-#define SEC_TP_MASK (1<< SEC_TP_OFFSET)
+#define SEC_TP_MASK (1 << SEC_TP_OFFSET)
 #define SEC_TP_USAGE (SEC_TP_MASK << 16)
 #define SEC_TP_ON  ((0x1 << SEC_TP_OFFSET)|SEC_TP_USAGE)
 #define SEC_TP_OFF ((0x0 << SEC_TP_OFFSET)|SEC_TP_USAGE)
@@ -67,7 +67,7 @@
 #define DAC_OFFSET 7
 #define DAC_MASK (1 << DAC_OFFSET)
 #define DAC_USAGE (DAC_MASK << 16)
-#define DAC_ON ((0x0<< DAC_OFFSET)|DAC_USAGE)
+#define DAC_ON ((0x0 << DAC_OFFSET)|DAC_USAGE)
 #define DAC_OFF ((0x1 << DAC_OFFSET)|DAC_USAGE)
 
 /* DPMS only affect D-SUB head
@@ -86,8 +86,7 @@
        CRT means crt path DSUB
 */
 #if 0
-typedef enum _disp_output_t
-{
+typedef enum _disp_output_t {
        NO_DISPLAY = DPMS_OFF,
 
        LCD1_PRI = PNL_2_PRI|PRI_TP_ON|PNL_SEQ_ON|DPMS_OFF|DAC_ON,
@@ -129,7 +128,7 @@ typedef enum _disp_output_t
 }
 disp_output_t;
 #else
-typedef enum _disp_output_t{
+typedef enum _disp_output_t {
        do_LCD1_PRI = PNL_2_PRI|PRI_TP_ON|PNL_SEQ_ON|DAC_ON,
        do_LCD1_SEC = PNL_2_SEC|SEC_TP_ON|PNL_SEQ_ON|DAC_ON,
 #if 0
index b2bf7e6..a7a2351 100644 (file)
@@ -1,4 +1,4 @@
-#define USE_DVICHIP 
+#define USE_DVICHIP
 #ifdef USE_DVICHIP
 #include "ddk750_help.h"
 #include "ddk750_reg.h"
@@ -9,47 +9,46 @@
 /* This global variable contains all the supported driver and its corresponding
    function API. Please set the function pointer to NULL whenever the function
    is not supported. */
-static dvi_ctrl_device_t g_dcftSupportedDviController[] =
-{
+static dvi_ctrl_device_t g_dcftSupportedDviController[] = {
 #ifdef DVI_CTRL_SII164
-    {
-        .pfnInit = sii164InitChip,
-        .pfnGetVendorId = sii164GetVendorID,
-        .pfnGetDeviceId = sii164GetDeviceID,
+       {
+               .pfnInit = sii164InitChip,
+               .pfnGetVendorId = sii164GetVendorID,
+               .pfnGetDeviceId = sii164GetDeviceID,
 #ifdef SII164_FULL_FUNCTIONS
-        .pfnResetChip = sii164ResetChip,
-        .pfnGetChipString = sii164GetChipString,
-        .pfnSetPower = sii164SetPower,
-        .pfnEnableHotPlugDetection = sii164EnableHotPlugDetection,
-        .pfnIsConnected = sii164IsConnected,
-        .pfnCheckInterrupt = sii164CheckInterrupt,
-        .pfnClearInterrupt = sii164ClearInterrupt,
+               .pfnResetChip = sii164ResetChip,
+               .pfnGetChipString = sii164GetChipString,
+               .pfnSetPower = sii164SetPower,
+               .pfnEnableHotPlugDetection = sii164EnableHotPlugDetection,
+               .pfnIsConnected = sii164IsConnected,
+               .pfnCheckInterrupt = sii164CheckInterrupt,
+               .pfnClearInterrupt = sii164ClearInterrupt,
 #endif
-    },
+       },
 #endif
 };
 
 
 int dviInit(
-    unsigned char edgeSelect,
-    unsigned char busSelect,
-    unsigned char dualEdgeClkSelect,
-    unsigned char hsyncEnable,
-    unsigned char vsyncEnable,
-    unsigned char deskewEnable,
-    unsigned char deskewSetting,
-    unsigned char continuousSyncEnable,
-    unsigned char pllFilterEnable,
-    unsigned char pllFilterValue
+       unsigned char edgeSelect,
+       unsigned char busSelect,
+       unsigned char dualEdgeClkSelect,
+       unsigned char hsyncEnable,
+       unsigned char vsyncEnable,
+       unsigned char deskewEnable,
+       unsigned char deskewSetting,
+       unsigned char continuousSyncEnable,
+       unsigned char pllFilterEnable,
+       unsigned char pllFilterValue
                        )
 {
        dvi_ctrl_device_t *pCurrentDviCtrl;
+
        pCurrentDviCtrl = g_dcftSupportedDviController;
-       if(pCurrentDviCtrl->pfnInit != NULL)
-       {
+       if (pCurrentDviCtrl->pfnInit != NULL) {
                return pCurrentDviCtrl->pfnInit(edgeSelect, busSelect, dualEdgeClkSelect, hsyncEnable,
-                              vsyncEnable, deskewEnable, deskewSetting, continuousSyncEnable,
-                              pllFilterEnable, pllFilterValue);
+                                               vsyncEnable, deskewEnable, deskewSetting, continuousSyncEnable,
+                                               pllFilterEnable, pllFilterValue);
        }
        return -1; /* error */
 }
@@ -64,13 +63,13 @@ int dviInit(
  */
 unsigned short dviGetVendorID(void)
 {
-    dvi_ctrl_device_t *pCurrentDviCtrl;
+       dvi_ctrl_device_t *pCurrentDviCtrl;
 
-    pCurrentDviCtrl = g_dcftSupportedDviController;
-    if (pCurrentDviCtrl != (dvi_ctrl_device_t *)0)
-        return pCurrentDviCtrl->pfnGetVendorId();
+       pCurrentDviCtrl = g_dcftSupportedDviController;
+       if (pCurrentDviCtrl != (dvi_ctrl_device_t *)0)
+               return pCurrentDviCtrl->pfnGetVendorId();
 
-    return 0x0000;
+       return 0x0000;
 }
 
 
@@ -83,13 +82,13 @@ unsigned short dviGetVendorID(void)
  */
 unsigned short dviGetDeviceID(void)
 {
-    dvi_ctrl_device_t *pCurrentDviCtrl;
+       dvi_ctrl_device_t *pCurrentDviCtrl;
 
        pCurrentDviCtrl = g_dcftSupportedDviController;
-    if (pCurrentDviCtrl != (dvi_ctrl_device_t *)0)
-        return pCurrentDviCtrl->pfnGetDeviceId();
+       if (pCurrentDviCtrl != (dvi_ctrl_device_t *)0)
+               return pCurrentDviCtrl->pfnGetDeviceId();
 
-    return 0x0000;
+       return 0x0000;
 }
 
 #endif
index 83bbd6d..e1d4c9a 100644 (file)
@@ -26,8 +26,7 @@ typedef unsigned char (*PFN_DVICTRL_CHECKINTERRUPT)(void);
 typedef void (*PFN_DVICTRL_CLEARINTERRUPT)(void);
 
 /* Structure to hold all the function pointer to the DVI Controller. */
-typedef struct _dvi_ctrl_device_t
-{
+typedef struct _dvi_ctrl_device_t {
        PFN_DVICTRL_INIT                pfnInit;
        PFN_DVICTRL_RESETCHIP           pfnResetChip;
        PFN_DVICTRL_GETCHIPSTRING       pfnGetChipString;
index 1adcafc..9637dd3 100644 (file)
@@ -1,8 +1,8 @@
 #include "ddk750_help.h"
 
-void __iomem *mmio750 = NULL;
-char revId750 = 0;
-unsigned short devId750 = 0;
+void __iomem *mmio750;
+char revId750;
+unsigned short devId750;
 
 /* after driver mapped io registers, use this function first */
 void ddk750_set_mmio(void __iomem *addr, unsigned short devId, char revId)
@@ -10,7 +10,7 @@ void ddk750_set_mmio(void __iomem *addr, unsigned short devId, char revId)
        mmio750 = addr;
        devId750 = devId;
        revId750 = revId;
-       if(revId == 0xfe)
+       if (revId == 0xfe)
                printk("found sm750le\n");
 }
 
index 4285b05..3b06aed 100644 (file)
@@ -12,8 +12,8 @@
 #if 0
 /* if 718 big endian turned on,be aware that don't use this driver for general use,only for ppc big-endian */
 #warning "big endian on target cpu and enable nature big endian support of 718 capability !"
-#define PEEK32(addr)                   __raw_readl(mmio750 + addr)
-#define POKE32(addr, data)             __raw_writel(data, mmio750 + addr)
+#define PEEK32(addr)                   __raw_readl(mmio750 + addr)
+#define POKE32(addr, data)             __raw_writel(data, mmio750 + addr)
 #else /* software control endianness */
 #define PEEK32(addr) readl(addr + mmio750)
 #define POKE32(addr, data) writel(data, addr + mmio750)
index 7826376..5ddac43 100644 (file)
 
 
 int hwI2CInit(
-    unsigned char busSpeedMode
+unsigned char busSpeedMode
 )
 {
-    unsigned int value;
+       unsigned int value;
 
-    /* Enable GPIO 30 & 31 as IIC clock & data */
+       /* Enable GPIO 30 & 31 as IIC clock & data */
        value = PEEK32(GPIO_MUX);
 
-    value = FIELD_SET(value, GPIO_MUX, 30, I2C) |
-                       FIELD_SET(0, GPIO_MUX, 31, I2C);
+       value = FIELD_SET(value, GPIO_MUX, 30, I2C) |
+                         FIELD_SET(0, GPIO_MUX, 31, I2C);
        POKE32(GPIO_MUX, value);
 
-    /* Enable Hardware I2C power.
-       TODO: Check if we need to enable GPIO power?
-     */
-    enableI2C(1);
-
-    /* Enable the I2C Controller and set the bus speed mode */
-    value = PEEK32(I2C_CTRL);
-    if (busSpeedMode == 0)
-        value = FIELD_SET(value, I2C_CTRL, MODE, STANDARD);
-    else
-        value = FIELD_SET(value, I2C_CTRL, MODE, FAST);
-    value = FIELD_SET(value, I2C_CTRL, EN, ENABLE);
-    POKE32(I2C_CTRL, value);
-
-    return 0;
+       /* Enable Hardware I2C power.
+        TODO: Check if we need to enable GPIO power?
+        */
+       enableI2C(1);
+
+       /* Enable the I2C Controller and set the bus speed mode */
+       value = PEEK32(I2C_CTRL);
+       if (busSpeedMode == 0)
+               value = FIELD_SET(value, I2C_CTRL, MODE, STANDARD);
+       else
+               value = FIELD_SET(value, I2C_CTRL, MODE, FAST);
+       value = FIELD_SET(value, I2C_CTRL, EN, ENABLE);
+       POKE32(I2C_CTRL, value);
+
+       return 0;
 }
 
 
 void hwI2CClose(void)
 {
-    unsigned int value;
+       unsigned int value;
 
-    /* Disable I2C controller */
-    value = PEEK32(I2C_CTRL);
-    value = FIELD_SET(value, I2C_CTRL, EN, DISABLE);
-    POKE32(I2C_CTRL, value);
+       /* Disable I2C controller */
+       value = PEEK32(I2C_CTRL);
+       value = FIELD_SET(value, I2C_CTRL, EN, DISABLE);
+       POKE32(I2C_CTRL, value);
 
-    /* Disable I2C Power */
-    enableI2C(0);
+       /* Disable I2C Power */
+       enableI2C(0);
 
-    /* Set GPIO 30 & 31 back as GPIO pins */
-    value = PEEK32(GPIO_MUX);
-    value = FIELD_SET(value, GPIO_MUX, 30, GPIO);
-    value = FIELD_SET(value, GPIO_MUX, 31, GPIO);
-    POKE32(GPIO_MUX, value);
+       /* Set GPIO 30 & 31 back as GPIO pins */
+       value = PEEK32(GPIO_MUX);
+       value = FIELD_SET(value, GPIO_MUX, 30, GPIO);
+       value = FIELD_SET(value, GPIO_MUX, 31, GPIO);
+       POKE32(GPIO_MUX, value);
 }
 
 
 static long hwI2CWaitTXDone(void)
 {
-    unsigned int timeout;
+       unsigned int timeout;
 
-    /* Wait until the transfer is completed. */
-    timeout = HWI2C_WAIT_TIMEOUT;
+       /* Wait until the transfer is completed. */
+       timeout = HWI2C_WAIT_TIMEOUT;
        while ((FIELD_GET(PEEK32(I2C_STATUS), I2C_STATUS, TX) != I2C_STATUS_TX_COMPLETED) &&
-           (timeout != 0))
+              (timeout != 0))
                timeout--;
 
        if (timeout == 0)
-           return (-1);
+               return (-1);
 
-    return 0;
+       return 0;
 }
 
 
@@ -91,53 +91,52 @@ static long hwI2CWaitTXDone(void)
  *      Total number of bytes those are actually written.
  */
 static unsigned int hwI2CWriteData(
-    unsigned char deviceAddress,
-    unsigned int length,
-    unsigned char *pBuffer
+       unsigned char deviceAddress,
+       unsigned int length,
+       unsigned char *pBuffer
 )
 {
-    unsigned char count, i;
-    unsigned int totalBytes = 0;
+       unsigned char count, i;
+       unsigned int totalBytes = 0;
 
-    /* Set the Device Address */
-    POKE32(I2C_SLAVE_ADDRESS, deviceAddress & ~0x01);
+       /* Set the Device Address */
+       POKE32(I2C_SLAVE_ADDRESS, deviceAddress & ~0x01);
 
-    /* Write data.
-     * Note:
-     *      Only 16 byte can be accessed per i2c start instruction.
-     */
-    do
-    {
-        /* Reset I2C by writing 0 to I2C_RESET register to clear the previous status. */
-        POKE32(I2C_RESET, 0);
+       /* Write data.
+        * Note:
+        *      Only 16 byte can be accessed per i2c start instruction.
+        */
+       do {
+               /* Reset I2C by writing 0 to I2C_RESET register to clear the previous status. */
+               POKE32(I2C_RESET, 0);
 
-        /* Set the number of bytes to be written */
-        if (length < MAX_HWI2C_FIFO)
-            count = length - 1;
-        else
-            count = MAX_HWI2C_FIFO - 1;
-        POKE32(I2C_BYTE_COUNT, count);
+               /* Set the number of bytes to be written */
+               if (length < MAX_HWI2C_FIFO)
+                       count = length - 1;
+               else
+                       count = MAX_HWI2C_FIFO - 1;
+               POKE32(I2C_BYTE_COUNT, count);
 
-        /* Move the data to the I2C data register */
-           for (i = 0; i <= count; i++)
-            POKE32(I2C_DATA0 + i, *pBuffer++);
+               /* Move the data to the I2C data register */
+               for (i = 0; i <= count; i++)
+                       POKE32(I2C_DATA0 + i, *pBuffer++);
 
-        /* Start the I2C */
-        POKE32(I2C_CTRL, FIELD_SET(PEEK32(I2C_CTRL), I2C_CTRL, CTRL, START));
+               /* Start the I2C */
+               POKE32(I2C_CTRL, FIELD_SET(PEEK32(I2C_CTRL), I2C_CTRL, CTRL, START));
 
-        /* Wait until the transfer is completed. */
-        if (hwI2CWaitTXDone() != 0)
-            break;
+               /* Wait until the transfer is completed. */
+               if (hwI2CWaitTXDone() != 0)
+                       break;
 
-        /* Substract length */
-        length -= (count + 1);
+               /* Substract length */
+               length -= (count + 1);
 
-        /* Total byte written */
-        totalBytes += (count + 1);
+               /* Total byte written */
+               totalBytes += (count + 1);
 
-    } while (length > 0);
+       } while (length > 0);
 
-    return totalBytes;
+       return totalBytes;
 }
 
 
@@ -158,53 +157,52 @@ static unsigned int hwI2CWriteData(
  *      Total number of actual bytes read from the slave device
  */
 static unsigned int hwI2CReadData(
-    unsigned char deviceAddress,
-    unsigned int length,
-    unsigned char *pBuffer
+       unsigned char deviceAddress,
+       unsigned int length,
+       unsigned char *pBuffer
 )
 {
-    unsigned char count, i;
-    unsigned int totalBytes = 0;
+       unsigned char count, i;
+       unsigned int totalBytes = 0;
 
-    /* Set the Device Address */
-    POKE32(I2C_SLAVE_ADDRESS, deviceAddress | 0x01);
+       /* Set the Device Address */
+       POKE32(I2C_SLAVE_ADDRESS, deviceAddress | 0x01);
 
-    /* Read data and save them to the buffer.
-     * Note:
-     *      Only 16 byte can be accessed per i2c start instruction.
-     */
-    do
-    {
-        /* Reset I2C by writing 0 to I2C_RESET register to clear all the status. */
-        POKE32(I2C_RESET, 0);
+       /* Read data and save them to the buffer.
+        * Note:
+        *      Only 16 byte can be accessed per i2c start instruction.
+        */
+       do {
+               /* Reset I2C by writing 0 to I2C_RESET register to clear all the status. */
+               POKE32(I2C_RESET, 0);
 
-        /* Set the number of bytes to be read */
-        if (length <= MAX_HWI2C_FIFO)
-            count = length - 1;
-        else
-            count = MAX_HWI2C_FIFO - 1;
-        POKE32(I2C_BYTE_COUNT, count);
+               /* Set the number of bytes to be read */
+               if (length <= MAX_HWI2C_FIFO)
+                       count = length - 1;
+               else
+                       count = MAX_HWI2C_FIFO - 1;
+               POKE32(I2C_BYTE_COUNT, count);
 
-        /* Start the I2C */
-        POKE32(I2C_CTRL, FIELD_SET(PEEK32(I2C_CTRL), I2C_CTRL, CTRL, START));
+               /* Start the I2C */
+               POKE32(I2C_CTRL, FIELD_SET(PEEK32(I2C_CTRL), I2C_CTRL, CTRL, START));
 
-        /* Wait until transaction done. */
-        if (hwI2CWaitTXDone() != 0)
-            break;
+               /* Wait until transaction done. */
+               if (hwI2CWaitTXDone() != 0)
+                       break;
 
-        /* Save the data to the given buffer */
-        for (i = 0; i <= count; i++)
-                   *pBuffer++ = PEEK32(I2C_DATA0 + i);
+               /* Save the data to the given buffer */
+               for (i = 0; i <= count; i++)
+                       *pBuffer++ = PEEK32(I2C_DATA0 + i);
 
-        /* Substract length by 16 */
-        length -= (count + 1);
+               /* Substract length by 16 */
+               length -= (count + 1);
 
-        /* Number of bytes read. */
-        totalBytes += (count + 1);
+               /* Number of bytes read. */
+               totalBytes += (count + 1);
 
-    } while (length > 0);
+       } while (length > 0);
 
-    return totalBytes;
+       return totalBytes;
 }
 
 
@@ -222,16 +220,16 @@ static unsigned int hwI2CReadData(
  *      Register value
  */
 unsigned char hwI2CReadReg(
-    unsigned char deviceAddress,
-    unsigned char registerIndex
+       unsigned char deviceAddress,
+       unsigned char registerIndex
 )
 {
-    unsigned char value = (0xFF);
+       unsigned char value = (0xFF);
 
-    if (hwI2CWriteData(deviceAddress, 1, &registerIndex) == 1)
-        hwI2CReadData(deviceAddress, 1, &value);
+       if (hwI2CWriteData(deviceAddress, 1, &registerIndex) == 1)
+               hwI2CReadData(deviceAddress, 1, &value);
 
-    return value;
+       return value;
 }
 
 
@@ -252,19 +250,19 @@ unsigned char hwI2CReadReg(
  *         -1   - Fail
  */
 int hwI2CWriteReg(
-    unsigned char deviceAddress,
-    unsigned char registerIndex,
-    unsigned char data
+       unsigned char deviceAddress,
+       unsigned char registerIndex,
+       unsigned char data
 )
 {
-    unsigned char value[2];
+       unsigned char value[2];
 
-    value[0] = registerIndex;
-    value[1] = data;
-    if (hwI2CWriteData(deviceAddress, 2, value) == 2)
-        return 0;
+       value[0] = registerIndex;
+       value[1] = data;
+       if (hwI2CWriteData(deviceAddress, 2, value) == 2)
+               return 0;
 
-    return (-1);
+       return (-1);
 }
 
 
index 74313ff..2399b17 100644 (file)
@@ -20,54 +20,54 @@ static unsigned long displayControlAdjust_SM750LE(mode_parameter_t *pModeParam,
        x = pModeParam->horizontal_display_end;
        y = pModeParam->vertical_display_end;
 
-    /* SM750LE has to set up the top-left and bottom-right
-       registers as well.
-       Note that normal SM750/SM718 only use those two register for
-       auto-centering mode.
-    */
-    POKE32(CRT_AUTO_CENTERING_TL,
-      FIELD_VALUE(0, CRT_AUTO_CENTERING_TL, TOP, 0)
-    | FIELD_VALUE(0, CRT_AUTO_CENTERING_TL, LEFT, 0));
-
-    POKE32(CRT_AUTO_CENTERING_BR,
-      FIELD_VALUE(0, CRT_AUTO_CENTERING_BR, BOTTOM, y-1)
-    | FIELD_VALUE(0, CRT_AUTO_CENTERING_BR, RIGHT, x-1));
-
-    /* Assume common fields in dispControl have been properly set before
-       calling this function.
-       This function only sets the extra fields in dispControl.
-    */
+       /* SM750LE has to set up the top-left and bottom-right
+          registers as well.
+          Note that normal SM750/SM718 only use those two register for
+          auto-centering mode.
+        */
+       POKE32(CRT_AUTO_CENTERING_TL,
+       FIELD_VALUE(0, CRT_AUTO_CENTERING_TL, TOP, 0)
+       | FIELD_VALUE(0, CRT_AUTO_CENTERING_TL, LEFT, 0));
+
+       POKE32(CRT_AUTO_CENTERING_BR,
+       FIELD_VALUE(0, CRT_AUTO_CENTERING_BR, BOTTOM, y-1)
+       | FIELD_VALUE(0, CRT_AUTO_CENTERING_BR, RIGHT, x-1));
+
+       /* Assume common fields in dispControl have been properly set before
+          calling this function.
+          This function only sets the extra fields in dispControl.
+        */
 
        /* Clear bit 29:27 of display control register */
-    dispControl &= FIELD_CLEAR(CRT_DISPLAY_CTRL, CLK);
+       dispControl &= FIELD_CLEAR(CRT_DISPLAY_CTRL, CLK);
 
        /* Set bit 29:27 of display control register for the right clock */
        /* Note that SM750LE only need to supported 7 resoluitons. */
-       if ( x == 800 && y == 600 )
-       dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLK, PLL41);
+       if (x == 800 && y == 600)
+               dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLK, PLL41);
        else if (x == 1024 && y == 768)
-       dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLK, PLL65);
+               dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLK, PLL65);
        else if (x == 1152 && y == 864)
-       dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLK, PLL80);
+               dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLK, PLL80);
        else if (x == 1280 && y == 768)
-       dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLK, PLL80);
+               dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLK, PLL80);
        else if (x == 1280 && y == 720)
-       dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLK, PLL74);
+               dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLK, PLL74);
        else if (x == 1280 && y == 960)
-       dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLK, PLL108);
+               dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLK, PLL108);
        else if (x == 1280 && y == 1024)
-       dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLK, PLL108);
+               dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLK, PLL108);
        else /* default to VGA clock */
-       dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLK, PLL25);
+       dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLK, PLL25);
 
        /* Set bit 25:24 of display controller */
-    dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CRTSELECT, CRT);
-    dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, RGBBIT, 24BIT);
+       dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CRTSELECT, CRT);
+       dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, RGBBIT, 24BIT);
 
-    /* Set bit 14 of display controller */
-    dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLOCK_PHASE, ACTIVE_LOW);
+       /* Set bit 14 of display controller */
+       dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLOCK_PHASE, ACTIVE_LOW);
 
-    POKE32(CRT_DISPLAY_CTRL, dispControl);
+       POKE32(CRT_DISPLAY_CTRL, dispControl);
 
        return dispControl;
 }
@@ -80,25 +80,25 @@ static int programModeRegisters(mode_parameter_t *pModeParam, pll_value_t *pll)
        int ret = 0;
        int cnt = 0;
        unsigned int ulTmpValue, ulReg;
-       if(pll->clockType == SECONDARY_PLL)
-       {
+
+       if (pll->clockType == SECONDARY_PLL) {
                /* programe secondary pixel clock */
                POKE32(CRT_PLL_CTRL, formatPllReg(pll));
-        POKE32(CRT_HORIZONTAL_TOTAL,
-              FIELD_VALUE(0, CRT_HORIZONTAL_TOTAL, TOTAL, pModeParam->horizontal_total - 1)
-            | FIELD_VALUE(0, CRT_HORIZONTAL_TOTAL, DISPLAY_END, pModeParam->horizontal_display_end - 1));
+               POKE32(CRT_HORIZONTAL_TOTAL,
+               FIELD_VALUE(0, CRT_HORIZONTAL_TOTAL, TOTAL, pModeParam->horizontal_total - 1)
+               | FIELD_VALUE(0, CRT_HORIZONTAL_TOTAL, DISPLAY_END, pModeParam->horizontal_display_end - 1));
 
-        POKE32(CRT_HORIZONTAL_SYNC,
-              FIELD_VALUE(0, CRT_HORIZONTAL_SYNC, WIDTH, pModeParam->horizontal_sync_width)
-            | FIELD_VALUE(0, CRT_HORIZONTAL_SYNC, START, pModeParam->horizontal_sync_start - 1));
+               POKE32(CRT_HORIZONTAL_SYNC,
+               FIELD_VALUE(0, CRT_HORIZONTAL_SYNC, WIDTH, pModeParam->horizontal_sync_width)
+               | FIELD_VALUE(0, CRT_HORIZONTAL_SYNC, START, pModeParam->horizontal_sync_start - 1));
 
-        POKE32(CRT_VERTICAL_TOTAL,
-              FIELD_VALUE(0, CRT_VERTICAL_TOTAL, TOTAL, pModeParam->vertical_total - 1)
-            | FIELD_VALUE(0, CRT_VERTICAL_TOTAL, DISPLAY_END, pModeParam->vertical_display_end - 1));
+               POKE32(CRT_VERTICAL_TOTAL,
+               FIELD_VALUE(0, CRT_VERTICAL_TOTAL, TOTAL, pModeParam->vertical_total - 1)
+               | FIELD_VALUE(0, CRT_VERTICAL_TOTAL, DISPLAY_END, pModeParam->vertical_display_end - 1));
 
-        POKE32(CRT_VERTICAL_SYNC,
-              FIELD_VALUE(0, CRT_VERTICAL_SYNC, HEIGHT, pModeParam->vertical_sync_height)
-            | FIELD_VALUE(0, CRT_VERTICAL_SYNC, START, pModeParam->vertical_sync_start - 1));
+               POKE32(CRT_VERTICAL_SYNC,
+               FIELD_VALUE(0, CRT_VERTICAL_SYNC, HEIGHT, pModeParam->vertical_sync_height)
+               | FIELD_VALUE(0, CRT_VERTICAL_SYNC, START, pModeParam->vertical_sync_start - 1));
 
 
                ulTmpValue = FIELD_VALUE(0, CRT_DISPLAY_CTRL, VSYNC_PHASE, pModeParam->vertical_sync_polarity)|
@@ -107,9 +107,9 @@ static int programModeRegisters(mode_parameter_t *pModeParam, pll_value_t *pll)
                                          FIELD_SET(0, CRT_DISPLAY_CTRL, PLANE, ENABLE);
 
 
-               if(getChipType() == SM750LE){
+               if (getChipType() == SM750LE) {
                        displayControlAdjust_SM750LE(pModeParam, ulTmpValue);
-               }else{
+               } else {
                        ulReg = PEEK32(CRT_DISPLAY_CTRL)
                                        & FIELD_CLEAR(CRT_DISPLAY_CTRL, VSYNC_PHASE)
                                        & FIELD_CLEAR(CRT_DISPLAY_CTRL, HSYNC_PHASE)
@@ -119,45 +119,44 @@ static int programModeRegisters(mode_parameter_t *pModeParam, pll_value_t *pll)
                         POKE32(CRT_DISPLAY_CTRL, ulTmpValue|ulReg);
                }
 
-       }
-       else if(pll->clockType == PRIMARY_PLL)
-       {
+       } else if (pll->clockType == PRIMARY_PLL) {
                unsigned int ulReservedBits;
+
                POKE32(PANEL_PLL_CTRL, formatPllReg(pll));
 
-        POKE32(PANEL_HORIZONTAL_TOTAL,
-              FIELD_VALUE(0, PANEL_HORIZONTAL_TOTAL, TOTAL, pModeParam->horizontal_total - 1)
-            | FIELD_VALUE(0, PANEL_HORIZONTAL_TOTAL, DISPLAY_END, pModeParam->horizontal_display_end - 1));
+               POKE32(PANEL_HORIZONTAL_TOTAL,
+               FIELD_VALUE(0, PANEL_HORIZONTAL_TOTAL, TOTAL, pModeParam->horizontal_total - 1)
+               | FIELD_VALUE(0, PANEL_HORIZONTAL_TOTAL, DISPLAY_END, pModeParam->horizontal_display_end - 1));
 
-        POKE32(PANEL_HORIZONTAL_SYNC,
-              FIELD_VALUE(0, PANEL_HORIZONTAL_SYNC, WIDTH, pModeParam->horizontal_sync_width)
-            | FIELD_VALUE(0, PANEL_HORIZONTAL_SYNC, START, pModeParam->horizontal_sync_start - 1));
+               POKE32(PANEL_HORIZONTAL_SYNC,
+               FIELD_VALUE(0, PANEL_HORIZONTAL_SYNC, WIDTH, pModeParam->horizontal_sync_width)
+               | FIELD_VALUE(0, PANEL_HORIZONTAL_SYNC, START, pModeParam->horizontal_sync_start - 1));
 
-        POKE32(PANEL_VERTICAL_TOTAL,
-              FIELD_VALUE(0, PANEL_VERTICAL_TOTAL, TOTAL, pModeParam->vertical_total - 1)
-            | FIELD_VALUE(0, PANEL_VERTICAL_TOTAL, DISPLAY_END, pModeParam->vertical_display_end - 1));
+               POKE32(PANEL_VERTICAL_TOTAL,
+               FIELD_VALUE(0, PANEL_VERTICAL_TOTAL, TOTAL, pModeParam->vertical_total - 1)
+                       | FIELD_VALUE(0, PANEL_VERTICAL_TOTAL, DISPLAY_END, pModeParam->vertical_display_end - 1));
 
-        POKE32(PANEL_VERTICAL_SYNC,
-              FIELD_VALUE(0, PANEL_VERTICAL_SYNC, HEIGHT, pModeParam->vertical_sync_height)
-            | FIELD_VALUE(0, PANEL_VERTICAL_SYNC, START, pModeParam->vertical_sync_start - 1));
+               POKE32(PANEL_VERTICAL_SYNC,
+               FIELD_VALUE(0, PANEL_VERTICAL_SYNC, HEIGHT, pModeParam->vertical_sync_height)
+               | FIELD_VALUE(0, PANEL_VERTICAL_SYNC, START, pModeParam->vertical_sync_start - 1));
 
                ulTmpValue = FIELD_VALUE(0, PANEL_DISPLAY_CTRL, VSYNC_PHASE, pModeParam->vertical_sync_polarity)|
-                                       FIELD_VALUE(0, PANEL_DISPLAY_CTRL, HSYNC_PHASE, pModeParam->horizontal_sync_polarity)|
-                                       FIELD_VALUE(0, PANEL_DISPLAY_CTRL, CLOCK_PHASE, pModeParam->clock_phase_polarity)|
-                                       FIELD_SET(0, PANEL_DISPLAY_CTRL, TIMING, ENABLE)|
-                                       FIELD_SET(0, PANEL_DISPLAY_CTRL, PLANE, ENABLE);
+                            FIELD_VALUE(0, PANEL_DISPLAY_CTRL, HSYNC_PHASE, pModeParam->horizontal_sync_polarity)|
+                            FIELD_VALUE(0, PANEL_DISPLAY_CTRL, CLOCK_PHASE, pModeParam->clock_phase_polarity)|
+                            FIELD_SET(0, PANEL_DISPLAY_CTRL, TIMING, ENABLE)|
+                            FIELD_SET(0, PANEL_DISPLAY_CTRL, PLANE, ENABLE);
 
-        ulReservedBits = FIELD_SET(0, PANEL_DISPLAY_CTRL, RESERVED_1_MASK, ENABLE) |
-                         FIELD_SET(0, PANEL_DISPLAY_CTRL, RESERVED_2_MASK, ENABLE) |
-                         FIELD_SET(0, PANEL_DISPLAY_CTRL, RESERVED_3_MASK, ENABLE)|
-                         FIELD_SET(0, PANEL_DISPLAY_CTRL, VSYNC, ACTIVE_LOW);
+               ulReservedBits = FIELD_SET(0, PANEL_DISPLAY_CTRL, RESERVED_1_MASK, ENABLE) |
+                                FIELD_SET(0, PANEL_DISPLAY_CTRL, RESERVED_2_MASK, ENABLE) |
+                                FIELD_SET(0, PANEL_DISPLAY_CTRL, RESERVED_3_MASK, ENABLE)|
+                                FIELD_SET(0, PANEL_DISPLAY_CTRL, VSYNC, ACTIVE_LOW);
 
-        ulReg = (PEEK32(PANEL_DISPLAY_CTRL) & ~ulReservedBits)
-              & FIELD_CLEAR(PANEL_DISPLAY_CTRL, CLOCK_PHASE)
-              & FIELD_CLEAR(PANEL_DISPLAY_CTRL, VSYNC_PHASE)
-              & FIELD_CLEAR(PANEL_DISPLAY_CTRL, HSYNC_PHASE)
-              & FIELD_CLEAR(PANEL_DISPLAY_CTRL, TIMING)
-              & FIELD_CLEAR(PANEL_DISPLAY_CTRL, PLANE);
+               ulReg = (PEEK32(PANEL_DISPLAY_CTRL) & ~ulReservedBits)
+                       & FIELD_CLEAR(PANEL_DISPLAY_CTRL, CLOCK_PHASE)
+                       & FIELD_CLEAR(PANEL_DISPLAY_CTRL, VSYNC_PHASE)
+                       & FIELD_CLEAR(PANEL_DISPLAY_CTRL, HSYNC_PHASE)
+                       & FIELD_CLEAR(PANEL_DISPLAY_CTRL, TIMING)
+                       & FIELD_CLEAR(PANEL_DISPLAY_CTRL, PLANE);
 
 
                /* May a hardware bug or just my test chip (not confirmed).
@@ -170,16 +169,14 @@ static int programModeRegisters(mode_parameter_t *pModeParam, pll_value_t *pll)
 
                POKE32(PANEL_DISPLAY_CTRL, ulTmpValue|ulReg);
 #if 1
-               while((PEEK32(PANEL_DISPLAY_CTRL) & ~ulReservedBits) != (ulTmpValue|ulReg))
-               {
+               while ((PEEK32(PANEL_DISPLAY_CTRL) & ~ulReservedBits) != (ulTmpValue|ulReg)) {
                        cnt++;
-                       if(cnt > 1000)
+                       if (cnt > 1000)
                                break;
                        POKE32(PANEL_DISPLAY_CTRL, ulTmpValue|ulReg);
                }
 #endif
-       }
-       else{
+       } else {
                ret = -1;
        }
        return ret;
@@ -189,11 +186,12 @@ int ddk750_setModeTiming(mode_parameter_t *parm, clock_type_t clock)
 {
        pll_value_t pll;
        unsigned int uiActualPixelClk;
+
        pll.inputFreq = DEFAULT_INPUT_CLOCK;
        pll.clockType = clock;
 
        uiActualPixelClk = calcPllValue(parm->pixel_clock, &pll);
-       if(getChipType() == SM750LE){
+       if (getChipType() == SM750LE) {
                /* set graphic mode via IO method */
                outb_p(0x88, 0x3d4);
                outb_p(0x06, 0x3d5);
index 4e8fab3..e846dc2 100644 (file)
@@ -3,37 +3,35 @@
 
 #include "ddk750_chip.h"
 
-typedef enum _spolarity_t
-{
-    POS = 0, /* positive */
-    NEG, /* negative */
+typedef enum _spolarity_t {
+       POS = 0, /* positive */
+       NEG, /* negative */
 }
 spolarity_t;
 
 
-typedef struct _mode_parameter_t
-{
-    /* Horizontal timing. */
-    unsigned long horizontal_total;
-    unsigned long horizontal_display_end;
-    unsigned long horizontal_sync_start;
-    unsigned long horizontal_sync_width;
-    spolarity_t horizontal_sync_polarity;
-
-    /* Vertical timing. */
-    unsigned long vertical_total;
-    unsigned long vertical_display_end;
-    unsigned long vertical_sync_start;
-    unsigned long vertical_sync_height;
-    spolarity_t vertical_sync_polarity;
-
-    /* Refresh timing. */
-    unsigned long pixel_clock;
-    unsigned long horizontal_frequency;
-    unsigned long vertical_frequency;
-
-    /* Clock Phase. This clock phase only applies to Panel. */
-    spolarity_t clock_phase_polarity;
+typedef struct _mode_parameter_t {
+       /* Horizontal timing. */
+       unsigned long horizontal_total;
+       unsigned long horizontal_display_end;
+       unsigned long horizontal_sync_start;
+       unsigned long horizontal_sync_width;
+       spolarity_t horizontal_sync_polarity;
+
+       /* Vertical timing. */
+       unsigned long vertical_total;
+       unsigned long vertical_display_end;
+       unsigned long vertical_sync_start;
+       unsigned long vertical_sync_height;
+       spolarity_t vertical_sync_polarity;
+
+       /* Refresh timing. */
+       unsigned long pixel_clock;
+       unsigned long horizontal_frequency;
+       unsigned long vertical_frequency;
+
+       /* Clock Phase. This clock phase only applies to Panel. */
+       spolarity_t clock_phase_polarity;
 }
 mode_parameter_t;
 
index 1e5f398..c8c51be 100644 (file)
@@ -5,21 +5,22 @@
 void ddk750_setDPMS(DPMS_t state)
 {
        unsigned int value;
-       if(getChipType() == SM750LE){
+
+       if (getChipType() == SM750LE) {
                value = PEEK32(CRT_DISPLAY_CTRL);
                POKE32(CRT_DISPLAY_CTRL, FIELD_VALUE(value, CRT_DISPLAY_CTRL, DPMS, state));
-       }else{
+       } else {
                value = PEEK32(SYSTEM_CTRL);
-               value= FIELD_VALUE(value, SYSTEM_CTRL, DPMS, state);
+               value = FIELD_VALUE(value, SYSTEM_CTRL, DPMS, state);
                POKE32(SYSTEM_CTRL, value);
        }
 }
 
 unsigned int getPowerMode(void)
 {
-       if(getChipType() == SM750LE)
+       if (getChipType() == SM750LE)
                return 0;
-    return (FIELD_GET(PEEK32(POWER_MODE_CTRL), POWER_MODE_CTRL, MODE));
+       return (FIELD_GET(PEEK32(POWER_MODE_CTRL), POWER_MODE_CTRL, MODE));
 }
 
 
@@ -29,76 +30,71 @@ unsigned int getPowerMode(void)
  */
 void setPowerMode(unsigned int powerMode)
 {
-    unsigned int control_value = 0;
+       unsigned int control_value = 0;
 
-    control_value = PEEK32(POWER_MODE_CTRL);
+       control_value = PEEK32(POWER_MODE_CTRL);
 
-       if(getChipType() == SM750LE)
+       if (getChipType() == SM750LE)
                return;
 
-    switch (powerMode)
-    {
-        case POWER_MODE_CTRL_MODE_MODE0:
-            control_value = FIELD_SET(control_value, POWER_MODE_CTRL, MODE, MODE0);
-            break;
+       switch (powerMode) {
+       case POWER_MODE_CTRL_MODE_MODE0:
+               control_value = FIELD_SET(control_value, POWER_MODE_CTRL, MODE, MODE0);
+               break;
 
-        case POWER_MODE_CTRL_MODE_MODE1:
-            control_value = FIELD_SET(control_value, POWER_MODE_CTRL, MODE, MODE1);
-            break;
+       case POWER_MODE_CTRL_MODE_MODE1:
+               control_value = FIELD_SET(control_value, POWER_MODE_CTRL, MODE, MODE1);
+               break;
 
-        case POWER_MODE_CTRL_MODE_SLEEP:
-            control_value = FIELD_SET(control_value, POWER_MODE_CTRL, MODE, SLEEP);
-            break;
+       case POWER_MODE_CTRL_MODE_SLEEP:
+               control_value = FIELD_SET(control_value, POWER_MODE_CTRL, MODE, SLEEP);
+               break;
 
-        default:
-            break;
-    }
+       default:
+               break;
+       }
 
-    /* Set up other fields in Power Control Register */
-    if (powerMode == POWER_MODE_CTRL_MODE_SLEEP)
-    {
-        control_value =
+       /* Set up other fields in Power Control Register */
+       if (powerMode == POWER_MODE_CTRL_MODE_SLEEP) {
+               control_value =
 #ifdef VALIDATION_CHIP
-            FIELD_SET(  control_value, POWER_MODE_CTRL, 336CLK, OFF) |
+               FIELD_SET(control_value, POWER_MODE_CTRL, 336CLK, OFF) |
 #endif
-            FIELD_SET(  control_value, POWER_MODE_CTRL, OSC_INPUT,  OFF);
-    }
-    else
-    {
-        control_value =
+               FIELD_SET(control_value, POWER_MODE_CTRL, OSC_INPUT,  OFF);
+       } else {
+               control_value =
 #ifdef VALIDATION_CHIP
-            FIELD_SET(  control_value, POWER_MODE_CTRL, 336CLK, ON) |
+               FIELD_SET(control_value, POWER_MODE_CTRL, 336CLK, ON) |
 #endif
-            FIELD_SET(  control_value, POWER_MODE_CTRL, OSC_INPUT,  ON);
-    }
+               FIELD_SET(control_value, POWER_MODE_CTRL, OSC_INPUT,  ON);
+       }
 
-    /* Program new power mode. */
-    POKE32(POWER_MODE_CTRL, control_value);
+       /* Program new power mode. */
+       POKE32(POWER_MODE_CTRL, control_value);
 }
 
 void setCurrentGate(unsigned int gate)
 {
-    unsigned int gate_reg;
-    unsigned int mode;
-
-    /* Get current power mode. */
-    mode = getPowerMode();
-
-    switch (mode)
-    {
-        case POWER_MODE_CTRL_MODE_MODE0:
-            gate_reg = MODE0_GATE;
-            break;
-
-        case POWER_MODE_CTRL_MODE_MODE1:
-            gate_reg = MODE1_GATE;
-            break;
-
-        default:
-            gate_reg = MODE0_GATE;
-            break;
-    }
-    POKE32(gate_reg, gate);
+       unsigned int gate_reg;
+       unsigned int mode;
+
+       /* Get current power mode. */
+       mode = getPowerMode();
+
+       switch (mode) {
+       case POWER_MODE_CTRL_MODE_MODE0:
+               gate_reg = MODE0_GATE;
+               break;
+
+       case POWER_MODE_CTRL_MODE_MODE1:
+               gate_reg = MODE1_GATE;
+               break;
+
+       default:
+               gate_reg = MODE0_GATE;
+               break;
+       }
+       POKE32(gate_reg, gate);
 }
 
 
@@ -108,21 +104,18 @@ void setCurrentGate(unsigned int gate)
  */
 void enable2DEngine(unsigned int enable)
 {
-    uint32_t gate;
-
-    gate = PEEK32(CURRENT_GATE);
-    if (enable)
-    {
-        gate = FIELD_SET(gate, CURRENT_GATE, DE,  ON);
-        gate = FIELD_SET(gate, CURRENT_GATE, CSC, ON);
-    }
-    else
-    {
-        gate = FIELD_SET(gate, CURRENT_GATE, DE,  OFF);
-        gate = FIELD_SET(gate, CURRENT_GATE, CSC, OFF);
-    }
-
-    setCurrentGate(gate);
+       uint32_t gate;
+
+       gate = PEEK32(CURRENT_GATE);
+       if (enable) {
+               gate = FIELD_SET(gate, CURRENT_GATE, DE,  ON);
+               gate = FIELD_SET(gate, CURRENT_GATE, CSC, ON);
+       } else {
+               gate = FIELD_SET(gate, CURRENT_GATE, DE,  OFF);
+               gate = FIELD_SET(gate, CURRENT_GATE, CSC, OFF);
+       }
+
+       setCurrentGate(gate);
 }
 
 
@@ -131,58 +124,55 @@ void enable2DEngine(unsigned int enable)
  */
 void enableZVPort(unsigned int enable)
 {
-    uint32_t gate;
+       uint32_t gate;
 
-    /* Enable ZV Port Gate */
-    gate = PEEK32(CURRENT_GATE);
-    if (enable)
-    {
-        gate = FIELD_SET(gate, CURRENT_GATE, ZVPORT, ON);
+       /* Enable ZV Port Gate */
+       gate = PEEK32(CURRENT_GATE);
+       if (enable) {
+               gate = FIELD_SET(gate, CURRENT_GATE, ZVPORT, ON);
 #if 1
-        /* Using Software I2C */
-        gate = FIELD_SET(gate, CURRENT_GATE, GPIO, ON);
+               /* Using Software I2C */
+               gate = FIELD_SET(gate, CURRENT_GATE, GPIO, ON);
 #else
-        /* Using Hardware I2C */
-        gate = FIELD_SET(gate, CURRENT_GATE, I2C,    ON);
+               /* Using Hardware I2C */
+               gate = FIELD_SET(gate, CURRENT_GATE, I2C,    ON);
 #endif
-    }
-    else
-    {
-        /* Disable ZV Port Gate. There is no way to know whether the GPIO pins are being used
-           or not. Therefore, do not disable the GPIO gate. */
-        gate = FIELD_SET(gate, CURRENT_GATE, ZVPORT, OFF);
-    }
-
-    setCurrentGate(gate);
+       } else {
+               /* Disable ZV Port Gate. There is no way to know whether the GPIO pins are being used
+                or not. Therefore, do not disable the GPIO gate. */
+               gate = FIELD_SET(gate, CURRENT_GATE, ZVPORT, OFF);
+       }
+
+       setCurrentGate(gate);
 }
 
 
 void enableSSP(unsigned int enable)
 {
-    uint32_t gate;
+       uint32_t gate;
 
-    /* Enable SSP Gate */
-    gate = PEEK32(CURRENT_GATE);
-    if (enable)
-        gate = FIELD_SET(gate, CURRENT_GATE, SSP, ON);
-    else
-        gate = FIELD_SET(gate, CURRENT_GATE, SSP, OFF);
+       /* Enable SSP Gate */
+       gate = PEEK32(CURRENT_GATE);
+       if (enable)
+               gate = FIELD_SET(gate, CURRENT_GATE, SSP, ON);
+       else
+               gate = FIELD_SET(gate, CURRENT_GATE, SSP, OFF);
 
-    setCurrentGate(gate);
+       setCurrentGate(gate);
 }
 
 void enableDMA(unsigned int enable)
 {
-    uint32_t gate;
+       uint32_t gate;
 
-    /* Enable DMA Gate */
-    gate = PEEK32(CURRENT_GATE);
-    if (enable)
-        gate = FIELD_SET(gate, CURRENT_GATE, DMA, ON);
-    else
-        gate = FIELD_SET(gate, CURRENT_GATE, DMA, OFF);
+       /* Enable DMA Gate */
+       gate = PEEK32(CURRENT_GATE);
+       if (enable)
+               gate = FIELD_SET(gate, CURRENT_GATE, DMA, ON);
+       else
+               gate = FIELD_SET(gate, CURRENT_GATE, DMA, OFF);
 
-    setCurrentGate(gate);
+       setCurrentGate(gate);
 }
 
 /*
@@ -190,16 +180,16 @@ void enableDMA(unsigned int enable)
  */
 void enableGPIO(unsigned int enable)
 {
-    uint32_t gate;
+       uint32_t gate;
 
-    /* Enable GPIO Gate */
-    gate = PEEK32(CURRENT_GATE);
-    if (enable)
-        gate = FIELD_SET(gate, CURRENT_GATE, GPIO, ON);
-    else
-        gate = FIELD_SET(gate, CURRENT_GATE, GPIO, OFF);
+       /* Enable GPIO Gate */
+       gate = PEEK32(CURRENT_GATE);
+       if (enable)
+               gate = FIELD_SET(gate, CURRENT_GATE, GPIO, ON);
+       else
+               gate = FIELD_SET(gate, CURRENT_GATE, GPIO, OFF);
 
-    setCurrentGate(gate);
+       setCurrentGate(gate);
 }
 
 /*
@@ -207,16 +197,16 @@ void enableGPIO(unsigned int enable)
  */
 void enablePWM(unsigned int enable)
 {
-    uint32_t gate;
+       uint32_t gate;
 
-    /* Enable PWM Gate */
-    gate = PEEK32(CURRENT_GATE);
-    if (enable)
-        gate = FIELD_SET(gate, CURRENT_GATE, PWM, ON);
-    else
-        gate = FIELD_SET(gate, CURRENT_GATE, PWM, OFF);
+       /* Enable PWM Gate */
+       gate = PEEK32(CURRENT_GATE);
+       if (enable)
+               gate = FIELD_SET(gate, CURRENT_GATE, PWM, ON);
+       else
+               gate = FIELD_SET(gate, CURRENT_GATE, PWM, OFF);
 
-    setCurrentGate(gate);
+       setCurrentGate(gate);
 }
 
 /*
@@ -224,16 +214,16 @@ void enablePWM(unsigned int enable)
  */
 void enableI2C(unsigned int enable)
 {
-    uint32_t gate;
+       uint32_t gate;
 
-    /* Enable I2C Gate */
-    gate = PEEK32(CURRENT_GATE);
-    if (enable)
-        gate = FIELD_SET(gate, CURRENT_GATE, I2C, ON);
-    else
-        gate = FIELD_SET(gate, CURRENT_GATE, I2C, OFF);
+       /* Enable I2C Gate */
+       gate = PEEK32(CURRENT_GATE);
+       if (enable)
+               gate = FIELD_SET(gate, CURRENT_GATE, I2C, ON);
+       else
+       gate = FIELD_SET(gate, CURRENT_GATE, I2C, OFF);
 
-    setCurrentGate(gate);
+       setCurrentGate(gate);
 }
 
 
index 4e00955..b7cf6b2 100644 (file)
@@ -1,12 +1,11 @@
 #ifndef DDK750_POWER_H__
 #define DDK750_POWER_H__
 
-typedef enum _DPMS_t
-{
-    crtDPMS_ON = 0x0,
-    crtDPMS_STANDBY = 0x1,
-    crtDPMS_SUSPEND = 0x2,
-    crtDPMS_OFF = 0x3,
+typedef enum _DPMS_t {
+       crtDPMS_ON = 0x0,
+       crtDPMS_STANDBY = 0x1,
+       crtDPMS_SUSPEND = 0x2,
+       crtDPMS_OFF = 0x3,
 }
 DPMS_t;
 
index 1a40dc2..2995625 100644 (file)
 /* CRT Graphics Control */
 
 #define CRT_DISPLAY_CTRL                              0x080200
-#define CRT_DISPLAY_CTRL_RESERVED_1_MASK                         31:27
-#define CRT_DISPLAY_CTRL_RESERVED_1_MASK_DISABLE                         0
-#define CRT_DISPLAY_CTRL_RESERVED_1_MASK_ENABLE                          0x1F
+#define CRT_DISPLAY_CTRL_RESERVED_1_MASK             31:27
+#define CRT_DISPLAY_CTRL_RESERVED_1_MASK_DISABLE      0
+#define CRT_DISPLAY_CTRL_RESERVED_1_MASK_ENABLE       0x1F
 
 /* SM750LE definition */
 #define CRT_DISPLAY_CTRL_DPMS                         31:30
 #define CRT_DISPLAY_CTRL_SHIFT_VGA_DAC_ENABLE         0
 
 
-#define CRT_DISPLAY_CTRL_RESERVED_2_MASK                         25:24
-#define CRT_DISPLAY_CTRL_RESERVED_2_MASK_ENABLE                          3
-#define CRT_DISPLAY_CTRL_RESERVED_2_MASK_DISABLE                         0
+#define CRT_DISPLAY_CTRL_RESERVED_2_MASK             25:24
+#define CRT_DISPLAY_CTRL_RESERVED_2_MASK_ENABLE              3
+#define CRT_DISPLAY_CTRL_RESERVED_2_MASK_DISABLE      0
 
 /* SM750LE definition */
 #define CRT_DISPLAY_CTRL_CRTSELECT                    25:25
 #define CRT_DISPLAY_CTRL_RGBBIT_12BIT                 1
 
 
-#define CRT_DISPLAY_CTRL_RESERVED_3_MASK                         15:15
+#define CRT_DISPLAY_CTRL_RESERVED_3_MASK             15:15
 #define CRT_DISPLAY_CTRL_RESERVED_3_MASK_DISABLE      0
 #define CRT_DISPLAY_CTRL_RESERVED_3_MASK_ENABLE       1
 
-#define CRT_DISPLAY_CTRL_RESERVED_4_MASK                         9:9
+#define CRT_DISPLAY_CTRL_RESERVED_4_MASK             9:9
 #define CRT_DISPLAY_CTRL_RESERVED_4_MASK_DISABLE      0
 #define CRT_DISPLAY_CTRL_RESERVED_4_MASK_ENABLE       1
 
 #endif
 
 /* sm750le new register to control panel output */
-#define DISPLAY_CONTROL_750LE  0x80288
+#define DISPLAY_CONTROL_750LE                        0x80288
 /* Palette RAM */
 
 /* Panel Palette register starts at 0x080400 ~ 0x0807FC */
index b6395b8..0bdf3db 100644 (file)
@@ -36,12 +36,12 @@ static char *gDviCtrlChipName = "Silicon Image SiI 164";
  */
 unsigned short sii164GetVendorID(void)
 {
-    unsigned short vendorID;
+       unsigned short vendorID;
 
-    vendorID = ((unsigned short) i2cReadReg(SII164_I2C_ADDRESS, SII164_VENDOR_ID_HIGH) << 8) |
-                (unsigned short) i2cReadReg(SII164_I2C_ADDRESS, SII164_VENDOR_ID_LOW);
+       vendorID = ((unsigned short) i2cReadReg(SII164_I2C_ADDRESS, SII164_VENDOR_ID_HIGH) << 8) |
+                   (unsigned short) i2cReadReg(SII164_I2C_ADDRESS, SII164_VENDOR_ID_LOW);
 
-    return vendorID;
+       return vendorID;
 }
 
 /*
@@ -53,12 +53,12 @@ unsigned short sii164GetVendorID(void)
  */
 unsigned short sii164GetDeviceID(void)
 {
-    unsigned short deviceID;
+       unsigned short deviceID;
 
-    deviceID = ((unsigned short) i2cReadReg(SII164_I2C_ADDRESS, SII164_DEVICE_ID_HIGH) << 8) |
-                (unsigned short) i2cReadReg(SII164_I2C_ADDRESS, SII164_DEVICE_ID_LOW);
+       deviceID = ((unsigned short) i2cReadReg(SII164_I2C_ADDRESS, SII164_DEVICE_ID_HIGH) << 8) |
+                   (unsigned short) i2cReadReg(SII164_I2C_ADDRESS, SII164_DEVICE_ID_LOW);
 
-    return deviceID;
+       return deviceID;
 }
 
 
@@ -113,132 +113,130 @@ unsigned short sii164GetDeviceID(void)
  *     -1   - Fail.
  */
 long sii164InitChip(
-    unsigned char edgeSelect,
-    unsigned char busSelect,
-    unsigned char dualEdgeClkSelect,
-    unsigned char hsyncEnable,
-    unsigned char vsyncEnable,
-    unsigned char deskewEnable,
-    unsigned char deskewSetting,
-    unsigned char continuousSyncEnable,
-    unsigned char pllFilterEnable,
-    unsigned char pllFilterValue
+       unsigned char edgeSelect,
+       unsigned char busSelect,
+       unsigned char dualEdgeClkSelect,
+       unsigned char hsyncEnable,
+       unsigned char vsyncEnable,
+       unsigned char deskewEnable,
+       unsigned char deskewSetting,
+       unsigned char continuousSyncEnable,
+       unsigned char pllFilterEnable,
+       unsigned char pllFilterValue
 )
 {
        unsigned char config;
 
-    /* Initialize the i2c bus */
+       /* Initialize the i2c bus */
 #ifdef USE_HW_I2C
-    /* Use fast mode. */
-    hwI2CInit(1);
+       /* Use fast mode. */
+       hwI2CInit(1);
 #else
-    swI2CInit(DEFAULT_I2C_SCL, DEFAULT_I2C_SDA);
+       swI2CInit(DEFAULT_I2C_SCL, DEFAULT_I2C_SDA);
 #endif
 
-    /* Check if SII164 Chip exists */
-    if ((sii164GetVendorID() == SII164_VENDOR_ID) && (sii164GetDeviceID() == SII164_DEVICE_ID))
-    {
-        /*
-         *  Initialize SII164 controller chip.
-         */
-
-        /* Select the edge */
-        if (edgeSelect == 0)
-            config = SII164_CONFIGURATION_LATCH_FALLING;
-        else
-            config = SII164_CONFIGURATION_LATCH_RISING;
-
-        /* Select bus wide */
-        if (busSelect == 0)
-            config |= SII164_CONFIGURATION_BUS_12BITS;
-        else
-            config |= SII164_CONFIGURATION_BUS_24BITS;
-
-        /* Select Dual/Single Edge Clock */
-        if (dualEdgeClkSelect == 0)
-            config |= SII164_CONFIGURATION_CLOCK_SINGLE;
-        else
-            config |= SII164_CONFIGURATION_CLOCK_DUAL;
-
-        /* Select HSync Enable */
-        if (hsyncEnable == 0)
-            config |= SII164_CONFIGURATION_HSYNC_FORCE_LOW;
-        else
-            config |= SII164_CONFIGURATION_HSYNC_AS_IS;
-
-        /* Select VSync Enable */
-        if (vsyncEnable == 0)
-            config |= SII164_CONFIGURATION_VSYNC_FORCE_LOW;
-        else
-            config |= SII164_CONFIGURATION_VSYNC_AS_IS;
-
-        i2cWriteReg(SII164_I2C_ADDRESS, SII164_CONFIGURATION, config);
-
-        /* De-skew enabled with default 111b value.
-           This will fix some artifacts problem in some mode on board 2.2.
-           Somehow this fix does not affect board 2.1.
-         */
-        if (deskewEnable == 0)
-            config = SII164_DESKEW_DISABLE;
-        else
-            config = SII164_DESKEW_ENABLE;
-
-        switch (deskewSetting)
-        {
-            case 0:
-                config |= SII164_DESKEW_1_STEP;
-                break;
-            case 1:
-                config |= SII164_DESKEW_2_STEP;
-                break;
-            case 2:
-                config |= SII164_DESKEW_3_STEP;
-                break;
-            case 3:
-                config |= SII164_DESKEW_4_STEP;
-                break;
-            case 4:
-                config |= SII164_DESKEW_5_STEP;
-                break;
-            case 5:
-                config |= SII164_DESKEW_6_STEP;
-                break;
-            case 6:
-                config |= SII164_DESKEW_7_STEP;
-                break;
-            case 7:
-                config |= SII164_DESKEW_8_STEP;
-                break;
-        }
-        i2cWriteReg(SII164_I2C_ADDRESS, SII164_DESKEW, config);
-
-        /* Enable/Disable Continuous Sync. */
-        if (continuousSyncEnable == 0)
-            config = SII164_PLL_FILTER_SYNC_CONTINUOUS_DISABLE;
-        else
-            config = SII164_PLL_FILTER_SYNC_CONTINUOUS_ENABLE;
-
-        /* Enable/Disable PLL Filter */
-        if (pllFilterEnable == 0)
-            config |= SII164_PLL_FILTER_DISABLE;
-        else
-            config |= SII164_PLL_FILTER_ENABLE;
-
-        /* Set the PLL Filter value */
-        config |= ((pllFilterValue & 0x07) << 1);
-
-        i2cWriteReg(SII164_I2C_ADDRESS, SII164_PLL, config);
-
-        /* Recover from Power Down and enable output. */
-        config = i2cReadReg(SII164_I2C_ADDRESS, SII164_CONFIGURATION);
-        config |= SII164_CONFIGURATION_POWER_NORMAL;
-        i2cWriteReg(SII164_I2C_ADDRESS, SII164_CONFIGURATION, config);
-
-        return 0;
-    }
-
-    /* Return -1 if initialization fails. */
-    return (-1);
+       /* Check if SII164 Chip exists */
+       if ((sii164GetVendorID() == SII164_VENDOR_ID) && (sii164GetDeviceID() == SII164_DEVICE_ID)) {
+               /*
+                *  Initialize SII164 controller chip.
+                */
+
+               /* Select the edge */
+               if (edgeSelect == 0)
+                       config = SII164_CONFIGURATION_LATCH_FALLING;
+               else
+                       config = SII164_CONFIGURATION_LATCH_RISING;
+
+               /* Select bus wide */
+               if (busSelect == 0)
+                       config |= SII164_CONFIGURATION_BUS_12BITS;
+               else
+                       config |= SII164_CONFIGURATION_BUS_24BITS;
+
+               /* Select Dual/Single Edge Clock */
+               if (dualEdgeClkSelect == 0)
+                       config |= SII164_CONFIGURATION_CLOCK_SINGLE;
+               else
+                       config |= SII164_CONFIGURATION_CLOCK_DUAL;
+
+               /* Select HSync Enable */
+               if (hsyncEnable == 0)
+                       config |= SII164_CONFIGURATION_HSYNC_FORCE_LOW;
+               else
+                       config |= SII164_CONFIGURATION_HSYNC_AS_IS;
+
+               /* Select VSync Enable */
+               if (vsyncEnable == 0)
+                       config |= SII164_CONFIGURATION_VSYNC_FORCE_LOW;
+               else
+                       config |= SII164_CONFIGURATION_VSYNC_AS_IS;
+
+               i2cWriteReg(SII164_I2C_ADDRESS, SII164_CONFIGURATION, config);
+
+               /* De-skew enabled with default 111b value.
+                  This will fix some artifacts problem in some mode on board 2.2.
+                  Somehow this fix does not affect board 2.1.
+                */
+               if (deskewEnable == 0)
+                       config = SII164_DESKEW_DISABLE;
+               else
+                       config = SII164_DESKEW_ENABLE;
+
+               switch (deskewSetting) {
+               case 0:
+                       config |= SII164_DESKEW_1_STEP;
+                       break;
+               case 1:
+                       config |= SII164_DESKEW_2_STEP;
+                       break;
+               case 2:
+                       config |= SII164_DESKEW_3_STEP;
+                       break;
+               case 3:
+                       config |= SII164_DESKEW_4_STEP;
+                       break;
+               case 4:
+                       config |= SII164_DESKEW_5_STEP;
+                       break;
+               case 5:
+                       config |= SII164_DESKEW_6_STEP;
+                       break;
+               case 6:
+                       config |= SII164_DESKEW_7_STEP;
+                       break;
+               case 7:
+                       config |= SII164_DESKEW_8_STEP;
+                       break;
+               }
+               i2cWriteReg(SII164_I2C_ADDRESS, SII164_DESKEW, config);
+
+               /* Enable/Disable Continuous Sync. */
+               if (continuousSyncEnable == 0)
+                       config = SII164_PLL_FILTER_SYNC_CONTINUOUS_DISABLE;
+               else
+                       config = SII164_PLL_FILTER_SYNC_CONTINUOUS_ENABLE;
+
+               /* Enable/Disable PLL Filter */
+               if (pllFilterEnable == 0)
+                       config |= SII164_PLL_FILTER_DISABLE;
+               else
+                       config |= SII164_PLL_FILTER_ENABLE;
+
+               /* Set the PLL Filter value */
+               config |= ((pllFilterValue & 0x07) << 1);
+
+               i2cWriteReg(SII164_I2C_ADDRESS, SII164_PLL, config);
+
+               /* Recover from Power Down and enable output. */
+               config = i2cReadReg(SII164_I2C_ADDRESS, SII164_CONFIGURATION);
+               config |= SII164_CONFIGURATION_POWER_NORMAL;
+               i2cWriteReg(SII164_I2C_ADDRESS, SII164_CONFIGURATION, config);
+
+               return 0;
+       }
+
+       /* Return -1 if initialization fails. */
+       return (-1);
 }
 
 
@@ -255,9 +253,9 @@ long sii164InitChip(
  */
 void sii164ResetChip(void)
 {
-    /* Power down */
-    sii164SetPower(0);
-    sii164SetPower(1);
+       /* Power down */
+       sii164SetPower(0);
+       sii164SetPower(1);
 }
 
 
@@ -268,7 +266,7 @@ void sii164ResetChip(void)
  */
 char *sii164GetChipString(void)
 {
-    return gDviCtrlChipName;
+       return gDviCtrlChipName;
 }
 
 
@@ -280,26 +278,23 @@ char *sii164GetChipString(void)
  *      powerUp - Flag to set the power down or up
  */
 void sii164SetPower(
-    unsigned char powerUp
+       unsigned char powerUp
 )
 {
-    unsigned char config;
-
-    config = i2cReadReg(SII164_I2C_ADDRESS, SII164_CONFIGURATION);
-    if (powerUp == 1)
-    {
-        /* Power up the chip */
-        config &= ~SII164_CONFIGURATION_POWER_MASK;
-        config |= SII164_CONFIGURATION_POWER_NORMAL;
-        i2cWriteReg(SII164_I2C_ADDRESS, SII164_CONFIGURATION, config);
-    }
-    else
-    {
-        /* Power down the chip */
-        config &= ~SII164_CONFIGURATION_POWER_MASK;
-        config |= SII164_CONFIGURATION_POWER_DOWN;
-        i2cWriteReg(SII164_I2C_ADDRESS, SII164_CONFIGURATION, config);
-    }
+       unsigned char config;
+
+       config = i2cReadReg(SII164_I2C_ADDRESS, SII164_CONFIGURATION);
+       if (powerUp == 1) {
+               /* Power up the chip */
+               config &= ~SII164_CONFIGURATION_POWER_MASK;
+               config |= SII164_CONFIGURATION_POWER_NORMAL;
+               i2cWriteReg(SII164_I2C_ADDRESS, SII164_CONFIGURATION, config);
+       } else {
+               /* Power down the chip */
+               config &= ~SII164_CONFIGURATION_POWER_MASK;
+               config |= SII164_CONFIGURATION_POWER_DOWN;
+               i2cWriteReg(SII164_I2C_ADDRESS, SII164_CONFIGURATION, config);
+       }
 }
 
 
@@ -308,31 +303,30 @@ void sii164SetPower(
  *      This function selects the mode of the hot plug detection.
  */
 static void sii164SelectHotPlugDetectionMode(
-    sii164_hot_plug_mode_t hotPlugMode
+       sii164_hot_plug_mode_t hotPlugMode
 )
 {
-    unsigned char detectReg;
-
-    detectReg = i2cReadReg(SII164_I2C_ADDRESS, SII164_DETECT) & ~SII164_DETECT_MONITOR_SENSE_OUTPUT_FLAG;
-    switch (hotPlugMode)
-    {
-        case SII164_HOTPLUG_DISABLE:
-            detectReg |= SII164_DETECT_MONITOR_SENSE_OUTPUT_HIGH;
-            break;
-        case SII164_HOTPLUG_USE_MDI:
-            detectReg &= ~SII164_DETECT_INTERRUPT_MASK;
-            detectReg |= SII164_DETECT_INTERRUPT_BY_HTPLG_PIN;
-            detectReg |= SII164_DETECT_MONITOR_SENSE_OUTPUT_MDI;
-            break;
-        case SII164_HOTPLUG_USE_RSEN:
-            detectReg |= SII164_DETECT_MONITOR_SENSE_OUTPUT_RSEN;
-            break;
-        case SII164_HOTPLUG_USE_HTPLG:
-            detectReg |= SII164_DETECT_MONITOR_SENSE_OUTPUT_HTPLG;
-            break;
-    }
-
-    i2cWriteReg(SII164_I2C_ADDRESS, SII164_DETECT, detectReg);
+       unsigned char detectReg;
+
+       detectReg = i2cReadReg(SII164_I2C_ADDRESS, SII164_DETECT) & ~SII164_DETECT_MONITOR_SENSE_OUTPUT_FLAG;
+       switch (hotPlugMode) {
+       case SII164_HOTPLUG_DISABLE:
+               detectReg |= SII164_DETECT_MONITOR_SENSE_OUTPUT_HIGH;
+               break;
+       case SII164_HOTPLUG_USE_MDI:
+               detectReg &= ~SII164_DETECT_INTERRUPT_MASK;
+               detectReg |= SII164_DETECT_INTERRUPT_BY_HTPLG_PIN;
+               detectReg |= SII164_DETECT_MONITOR_SENSE_OUTPUT_MDI;
+               break;
+       case SII164_HOTPLUG_USE_RSEN:
+               detectReg |= SII164_DETECT_MONITOR_SENSE_OUTPUT_RSEN;
+               break;
+       case SII164_HOTPLUG_USE_HTPLG:
+               detectReg |= SII164_DETECT_MONITOR_SENSE_OUTPUT_HTPLG;
+               break;
+       }
+
+       i2cWriteReg(SII164_I2C_ADDRESS, SII164_DETECT, detectReg);
 }
 
 /*
@@ -342,18 +336,19 @@ static void sii164SelectHotPlugDetectionMode(
  *  enableHotPlug   - Enable (=1) / disable (=0) Hot Plug detection
  */
 void sii164EnableHotPlugDetection(
-    unsigned char enableHotPlug
+       unsigned char enableHotPlug
 )
 {
-    unsigned char detectReg;
-    detectReg = i2cReadReg(SII164_I2C_ADDRESS, SII164_DETECT);
-
-    /* Depending on each DVI controller, need to enable the hot plug based on each
-       individual chip design. */
-    if (enableHotPlug != 0)
-        sii164SelectHotPlugDetectionMode(SII164_HOTPLUG_USE_MDI);
-    else
-        sii164SelectHotPlugDetectionMode(SII164_HOTPLUG_DISABLE);
+       unsigned char detectReg;
+
+       detectReg = i2cReadReg(SII164_I2C_ADDRESS, SII164_DETECT);
+
+       /* Depending on each DVI controller, need to enable the hot plug based on each
+          individual chip design. */
+       if (enableHotPlug != 0)
+               sii164SelectHotPlugDetectionMode(SII164_HOTPLUG_USE_MDI);
+       else
+               sii164SelectHotPlugDetectionMode(SII164_HOTPLUG_DISABLE);
 }
 
 /*
@@ -366,13 +361,13 @@ void sii164EnableHotPlugDetection(
  */
 unsigned char sii164IsConnected(void)
 {
-    unsigned char hotPlugValue;
+       unsigned char hotPlugValue;
 
-    hotPlugValue = i2cReadReg(SII164_I2C_ADDRESS, SII164_DETECT) & SII164_DETECT_HOT_PLUG_STATUS_MASK;
-    if (hotPlugValue == SII164_DETECT_HOT_PLUG_STATUS_ON)
-        return 1;
-    else
-        return 0;
+       hotPlugValue = i2cReadReg(SII164_I2C_ADDRESS, SII164_DETECT) & SII164_DETECT_HOT_PLUG_STATUS_MASK;
+       if (hotPlugValue == SII164_DETECT_HOT_PLUG_STATUS_ON)
+               return 1;
+       else
+               return 0;
 }
 
 /*
@@ -385,13 +380,13 @@ unsigned char sii164IsConnected(void)
  */
 unsigned char sii164CheckInterrupt(void)
 {
-    unsigned char detectReg;
+       unsigned char detectReg;
 
-    detectReg = i2cReadReg(SII164_I2C_ADDRESS, SII164_DETECT) & SII164_DETECT_MONITOR_STATE_MASK;
-    if (detectReg == SII164_DETECT_MONITOR_STATE_CHANGE)
-        return 1;
-    else
-        return 0;
+       detectReg = i2cReadReg(SII164_I2C_ADDRESS, SII164_DETECT) & SII164_DETECT_MONITOR_STATE_MASK;
+       if (detectReg == SII164_DETECT_MONITOR_STATE_CHANGE)
+               return 1;
+       else
+               return 0;
 }
 
 /*
@@ -400,11 +395,11 @@ unsigned char sii164CheckInterrupt(void)
  */
 void sii164ClearInterrupt(void)
 {
-    unsigned char detectReg;
+       unsigned char detectReg;
 
-    /* Clear the MDI interrupt */
-    detectReg = i2cReadReg(SII164_I2C_ADDRESS, SII164_DETECT);
-    i2cWriteReg(SII164_I2C_ADDRESS, SII164_DETECT, detectReg | SII164_DETECT_MONITOR_STATE_CLEAR);
+       /* Clear the MDI interrupt */
+       detectReg = i2cReadReg(SII164_I2C_ADDRESS, SII164_DETECT);
+       i2cWriteReg(SII164_I2C_ADDRESS, SII164_DETECT, detectReg | SII164_DETECT_MONITOR_STATE_CLEAR);
 }
 
 #endif
index 2b4c7d3..f2610c9 100644 (file)
@@ -4,27 +4,26 @@
 #define USE_DVICHIP
 
 /* Hot Plug detection mode structure */
-typedef enum _sii164_hot_plug_mode_t
-{
-    SII164_HOTPLUG_DISABLE = 0,         /* Disable Hot Plug output bit (always high). */
-    SII164_HOTPLUG_USE_MDI,             /* Use Monitor Detect Interrupt bit. */
-    SII164_HOTPLUG_USE_RSEN,            /* Use Receiver Sense detect bit. */
-    SII164_HOTPLUG_USE_HTPLG            /* Use Hot Plug detect bit. */
+typedef enum _sii164_hot_plug_mode_t {
+       SII164_HOTPLUG_DISABLE = 0,         /* Disable Hot Plug output bit (always high). */
+       SII164_HOTPLUG_USE_MDI,             /* Use Monitor Detect Interrupt bit. */
+       SII164_HOTPLUG_USE_RSEN,            /* Use Receiver Sense detect bit. */
+       SII164_HOTPLUG_USE_HTPLG            /* Use Hot Plug detect bit. */
 } sii164_hot_plug_mode_t;
 
 
 /* Silicon Image SiI164 chip prototype */
 long sii164InitChip(
-    unsigned char edgeSelect,
-    unsigned char busSelect,
-    unsigned char dualEdgeClkSelect,
-    unsigned char hsyncEnable,
-    unsigned char vsyncEnable,
-    unsigned char deskewEnable,
-    unsigned char deskewSetting,
-    unsigned char continuousSyncEnable,
-    unsigned char pllFilterEnable,
-    unsigned char pllFilterValue
+       unsigned char edgeSelect,
+       unsigned char busSelect,
+       unsigned char dualEdgeClkSelect,
+       unsigned char hsyncEnable,
+       unsigned char vsyncEnable,
+       unsigned char deskewEnable,
+       unsigned char deskewSetting,
+       unsigned char continuousSyncEnable,
+       unsigned char pllFilterEnable,
+       unsigned char pllFilterValue
 );
 
 unsigned short sii164GetVendorID(void);
index 8e201f1..c7ab818 100644 (file)
@@ -24,7 +24,7 @@
 
 #include "modedb.h"
 
-int smi_indent = 0;
+int smi_indent;
 
 
 /*
@@ -47,9 +47,9 @@ static int g_noaccel;
 static int g_nomtrr;
 static const char *g_fbmode[] = {NULL, NULL};
 static const char *g_def_fbmode = "800x600-16@60";
-static char *g_settings = NULL;
+static char *g_settings;
 static int g_dualview;
-static char *g_option = NULL;
+static char *g_option;
 
 
 static const struct fb_videomode lynx750_ext[] = {
@@ -967,7 +967,7 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
        var->accel_flags = 0;
        var->vmode = FB_VMODE_NONINTERLACED;
 
-       pr_debug("#1 show info->cmap : \nstart=%d,len=%d,red=%p,green=%p,blue=%p,transp=%p\n",
+       pr_debug("#1 show info->cmap :\nstart=%d,len=%d,red=%p,green=%p,blue=%p,transp=%p\n",
                 info->cmap.start, info->cmap.len,
                 info->cmap.red, info->cmap.green, info->cmap.blue,
                 info->cmap.transp);
index cc80580..9b101a9 100644 (file)
@@ -5,16 +5,16 @@
 
 #define FB_ACCEL_SMI 0xab
 /* please use revision id to distinguish sm750le and sm750*/
-#define SPC_SM750      0
+#define SPC_SM750 0
 
 #define MB(x) ((x)<<20)
 #define MHZ(x) ((x) * 1000000)
 /* align should be 2,4,8,16 */
-#define PADDING(align, data) (((data)+(align)-1)&(~((align) -1)))
+#define PADDING(align, data) (((data)+(align)-1)&(~((align) - 1)))
 extern int smi_indent;
 
 
-struct lynx_accel{
+struct lynx_accel {
        /* base virtual address of DPR registers */
        volatile unsigned char __iomem * dprBase;
        /* base virtual address of de data port */
@@ -38,10 +38,10 @@ struct lynx_accel{
 
 };
 
-/*     lynx_share stands for a presentation of two frame buffer
-       that use one smi adaptor , it is similar to a basic class of C++
+/* lynx_share stands for a presentation of two frame buffer
+   that use one smi adaptor , it is similar to a basic class of C++
 */
-struct lynx_share{
+struct lynx_share {
        /* common members */
        u16 devid;
        u8 revid;
@@ -53,7 +53,7 @@ struct lynx_share{
                int mtrr_off;
                struct{
                        int vram;
-               }mtrr;
+               } mtrr;
        /* all smi graphic adaptor got below attributes */
        unsigned long vidmem_start;
        unsigned long vidreg_start;
@@ -68,7 +68,7 @@ struct lynx_share{
        void (*resume)(struct lynx_share*);
 };
 
-struct lynx_cursor{
+struct lynx_cursor {
        /* cursor width ,height and size */
        int w;
        int h;
@@ -92,7 +92,7 @@ struct lynx_cursor{
        void (*setData)(struct lynx_cursor *, u16, const u8*, const u8*);
 };
 
-struct lynxfb_crtc{
+struct lynxfb_crtc {
        unsigned char __iomem *vCursor; /* virtual address of cursor */
        unsigned char __iomem *vScreen; /* virtual address of on_screen */
        int oCursor; /* cursor address offset in vidmem */
@@ -108,14 +108,14 @@ struct lynxfb_crtc{
 
        void *priv;
 
-       int(*proc_setMode)(struct lynxfb_crtc*,
+       int (*proc_setMode)(struct lynxfb_crtc*,
                                                struct fb_var_screeninfo*,
                                                struct fb_fix_screeninfo*);
 
-       int(*proc_checkMode)(struct lynxfb_crtc*, struct fb_var_screeninfo*);
-       int(*proc_setColReg)(struct lynxfb_crtc*, ushort, ushort, ushort, ushort);
+       int (*proc_checkMode)(struct lynxfb_crtc*, struct fb_var_screeninfo*);
+       int (*proc_setColReg)(struct lynxfb_crtc*, ushort, ushort, ushort, ushort);
        void (*clear)(struct lynxfb_crtc*);
-        /* pan display */
+       /* pan display */
        int (*proc_panDisplay)(struct lynxfb_crtc *,
                               const struct fb_var_screeninfo *,
                               const struct fb_info *);
@@ -123,33 +123,33 @@ struct lynxfb_crtc{
        struct lynx_cursor cursor;
 };
 
-struct lynxfb_output{
+struct lynxfb_output {
        int dpms;
        int paths;
-       /*      which paths(s) this output stands for,for sm750:
-               paths=1:means output for panel paths
-               paths=2:means output for crt paths
-               paths=3:means output for both panel and crt paths
+       /* which paths(s) this output stands for,for sm750:
+          paths=1:means output for panel paths
+          paths=2:means output for crt paths
+          paths=3:means output for both panel and crt paths
        */
 
        int *channel;
-       /*      which channel these outputs linked with,for sm750:
-               *channel=0 means primary channel
-               *channel=1 means secondary channel
-               output->channel ==> &crtc->channel
+       /* which channel these outputs linked with,for sm750:
+          *channel=0 means primary channel
+          *channel=1 means secondary channel
+          output->channel ==> &crtc->channel
        */
        void *priv;
 
-       int(*proc_setMode)(struct lynxfb_output*,
+       int (*proc_setMode)(struct lynxfb_output*,
                                                struct fb_var_screeninfo*,
                                                struct fb_fix_screeninfo*);
 
-       int(*proc_checkMode)(struct lynxfb_output*, struct fb_var_screeninfo*);
-       int(*proc_setBLANK)(struct lynxfb_output*, int);
+       int (*proc_checkMode)(struct lynxfb_output*, struct fb_var_screeninfo*);
+       int (*proc_setBLANK)(struct lynxfb_output*, int);
        void  (*clear)(struct lynxfb_output*);
 };
 
-struct lynxfb_par{
+struct lynxfb_par {
        /* either 0 or 1 for dual head adaptor,0 is the older one registered */
        int index;
        unsigned int pseudo_palette[256];
@@ -165,14 +165,14 @@ struct lynxfb_par{
 
 
 #define PS_TO_HZ(ps)   \
-                       ({      \
+                       ({ \
                        unsigned long long hz = 1000*1000*1000*1000ULL; \
                        do_div(hz, ps); \
-                       (unsigned long)hz;})
+                       (unsigned long)hz; })
 
 static inline unsigned long ps_to_hz(unsigned int psvalue)
 {
-       unsigned long long numerator=1000*1000*1000*1000ULL;
+       unsigned long long numerator = 1000*1000*1000*1000ULL;
        /* 10^12 / picosecond period gives frequency in Hz */
        do_div(numerator, psvalue);
        return (unsigned long)numerator;
index 6eee4cd..1dd06a2 100644 (file)
@@ -37,7 +37,7 @@ void hw_de_init(struct lynx_accel *accel)
 {
        /* setup 2d engine registers */
        u32 reg, clr;
-       
+
        write_dpr(accel, DE_MASKS, 0xFFFFFFFF);
 
        /* dpr1c */
@@ -82,7 +82,7 @@ void hw_de_init(struct lynx_accel *accel)
 void hw_set2dformat(struct lynx_accel *accel, int fmt)
 {
        u32 reg;
-       
+
        /* fmt=0,1,2 for 8,16,32,bpp on sm718/750/502 */
        reg = read_dpr(accel, DE_STRETCH_FORMAT);
        reg = FIELD_VALUE(reg, DE_STRETCH_FORMAT, PIXEL_FORMAT, fmt);
@@ -96,11 +96,10 @@ int hw_fillrect(struct lynx_accel *accel,
 {
        u32 deCtrl;
 
-       if(accel->de_wait() != 0)
-       {
+       if (accel->de_wait() != 0) {
                /* int time wait and always busy,seems hardware
                 * got something error */
-               pr_debug("%s:De engine always bussy\n", __func__);
+               pr_debug("De engine always busy\n");
                return -1;
        }
 
@@ -151,112 +150,102 @@ unsigned int width,
 unsigned int height, /* width and height of rectangle in pixel value */
 unsigned int rop2)   /* ROP value */
 {
-    unsigned int nDirection, de_ctrl;
-    int opSign;
-    nDirection = LEFT_TO_RIGHT;
+       unsigned int nDirection, de_ctrl;
+       int opSign;
+
+       nDirection = LEFT_TO_RIGHT;
        /* Direction of ROP2 operation: 1 = Left to Right, (-1) = Right to Left */
-    opSign = 1;
-    de_ctrl = 0;
-
-    /* If source and destination are the same surface, need to check for overlay cases */
-    if (sBase == dBase && sPitch == dPitch)
-    {
-        /* Determine direction of operation */
-        if (sy < dy)
-        {
-            /* +----------+
-               |S         |
-               |   +----------+
-               |   |      |   |
-               |   |      |   |
-               +---|------+   |
-                   |         D|
-                   +----------+ */
-
-            nDirection = BOTTOM_TO_TOP;
-        }
-        else if (sy > dy)
-        {
-            /* +----------+
-               |D         |
-               |   +----------+
-               |   |      |   |
-               |   |      |   |
-               +---|------+   |
-                   |         S|
-                   +----------+ */
-
-            nDirection = TOP_TO_BOTTOM;
-        }
-        else
-        {
-            /* sy == dy */
-
-            if (sx <= dx)
-            {
-                /* +------+---+------+
-                   |S     |   |     D|
-                   |      |   |      |
-                   |      |   |      |
-                   |      |   |      |
-                   +------+---+------+ */
-
-                nDirection = RIGHT_TO_LEFT;
-            }
-            else
-            {
-                /* sx > dx */
-
-                /* +------+---+------+
-                   |D     |   |     S|
-                   |      |   |      |
-                   |      |   |      |
-                   |      |   |      |
-                   +------+---+------+ */
-
-                nDirection = LEFT_TO_RIGHT;
-            }
-        }
-    }
-
-    if ((nDirection == BOTTOM_TO_TOP) || (nDirection == RIGHT_TO_LEFT))
-    {
-        sx += width - 1;
-        sy += height - 1;
-        dx += width - 1;
-        dy += height - 1;
-        opSign = (-1);
-    }
-
-    /* Note:
-       DE_FOREGROUND are DE_BACKGROUND are don't care.
-       DE_COLOR_COMPARE and DE_COLOR_COMPARE_MAKS are set by set deSetTransparency().
-    */
+       opSign = 1;
+       de_ctrl = 0;
+
+       /* If source and destination are the same surface, need to check for overlay cases */
+       if (sBase == dBase && sPitch == dPitch) {
+               /* Determine direction of operation */
+               if (sy < dy) {
+                       /* +----------+
+                          |S         |
+                          |   +----------+
+                          |   |      |   |
+                          |   |      |   |
+                          +---|------+   |
+                          |         D|
+                          +----------+ */
+
+                       nDirection = BOTTOM_TO_TOP;
+               } else if (sy > dy) {
+                       /* +----------+
+                          |D         |
+                          |   +----------+
+                          |   |      |   |
+                          |   |      |   |
+                          +---|------+   |
+                          |         S|
+                          +----------+ */
+
+                       nDirection = TOP_TO_BOTTOM;
+               } else {
+                       /* sy == dy */
+
+                       if (sx <= dx) {
+                               /* +------+---+------+
+                                  |S     |   |     D|
+                                  |      |   |      |
+                                  |      |   |      |
+                                  |      |   |      |
+                                  +------+---+------+ */
+
+                               nDirection = RIGHT_TO_LEFT;
+                       } else {
+                       /* sx > dx */
+
+                               /* +------+---+------+
+                                  |D     |   |     S|
+                                  |      |   |      |
+                                  |      |   |      |
+                                  |      |   |      |
+                                  +------+---+------+ */
+
+                               nDirection = LEFT_TO_RIGHT;
+                       }
+               }
+       }
 
-    /* 2D Source Base.
-       It is an address offset (128 bit aligned) from the beginning of frame buffer.
-    */
-    write_dpr(accel, DE_WINDOW_SOURCE_BASE, sBase); /* dpr40 */
+       if ((nDirection == BOTTOM_TO_TOP) || (nDirection == RIGHT_TO_LEFT)) {
+               sx += width - 1;
+               sy += height - 1;
+               dx += width - 1;
+               dy += height - 1;
+               opSign = (-1);
+       }
 
-    /* 2D Destination Base.
-       It is an address offset (128 bit aligned) from the beginning of frame buffer.
-    */
-    write_dpr(accel, DE_WINDOW_DESTINATION_BASE, dBase); /* dpr44 */
+       /* Note:
+          DE_FOREGROUND are DE_BACKGROUND are don't care.
+         DE_COLOR_COMPARE and DE_COLOR_COMPARE_MAKS are set by set deSetTransparency().
+        */
+
+       /* 2D Source Base.
+        It is an address offset (128 bit aligned) from the beginning of frame buffer.
+        */
+       write_dpr(accel, DE_WINDOW_SOURCE_BASE, sBase); /* dpr40 */
+
+       /* 2D Destination Base.
+        It is an address offset (128 bit aligned) from the beginning of frame buffer.
+        */
+       write_dpr(accel, DE_WINDOW_DESTINATION_BASE, dBase); /* dpr44 */
 
 #if 0
     /* Program pitch (distance between the 1st points of two adjacent lines).
        Note that input pitch is BYTE value, but the 2D Pitch register uses
        pixel values. Need Byte to pixel conversion.
     */
-       if(Bpp == 3){
+       if (Bpp == 3) {
                        sx *= 3;
                        dx *= 3;
                        width *= 3;
                write_dpr(accel, DE_PITCH,
                                FIELD_VALUE(0, DE_PITCH, DESTINATION, dPitch) |
                                FIELD_VALUE(0, DE_PITCH, SOURCE,      sPitch)); /* dpr10 */
-       }
-       else
+       } else
 #endif
        {
                write_dpr(accel, DE_PITCH,
@@ -267,54 +256,53 @@ unsigned int rop2)   /* ROP value */
     /* Screen Window width in Pixels.
        2D engine uses this value to calculate the linear address in frame buffer for a given point.
     */
-    write_dpr(accel, DE_WINDOW_WIDTH,
-        FIELD_VALUE(0, DE_WINDOW_WIDTH, DESTINATION, (dPitch/Bpp)) |
-        FIELD_VALUE(0, DE_WINDOW_WIDTH, SOURCE,      (sPitch/Bpp))); /* dpr3c */
+       write_dpr(accel, DE_WINDOW_WIDTH,
+       FIELD_VALUE(0, DE_WINDOW_WIDTH, DESTINATION, (dPitch/Bpp)) |
+       FIELD_VALUE(0, DE_WINDOW_WIDTH, SOURCE,      (sPitch/Bpp))); /* dpr3c */
 
-       if (accel->de_wait() != 0){
+       if (accel->de_wait() != 0)
                return -1;
+
+       {
+
+       write_dpr(accel, DE_SOURCE,
+                 FIELD_SET(0, DE_SOURCE, WRAP, DISABLE) |
+                 FIELD_VALUE(0, DE_SOURCE, X_K1, sx)   |
+                 FIELD_VALUE(0, DE_SOURCE, Y_K2, sy)); /* dpr0 */
+       write_dpr(accel, DE_DESTINATION,
+                 FIELD_SET(0, DE_DESTINATION, WRAP, DISABLE) |
+                 FIELD_VALUE(0, DE_DESTINATION, X,    dx)  |
+                 FIELD_VALUE(0, DE_DESTINATION, Y,    dy)); /* dpr04 */
+       write_dpr(accel, DE_DIMENSION,
+                 FIELD_VALUE(0, DE_DIMENSION, X,    width) |
+                 FIELD_VALUE(0, DE_DIMENSION, Y_ET, height)); /* dpr08 */
+
+       de_ctrl = FIELD_VALUE(0, DE_CONTROL, ROP, rop2) |
+                 FIELD_SET(0, DE_CONTROL, ROP_SELECT, ROP2) |
+                 FIELD_SET(0, DE_CONTROL, COMMAND, BITBLT) |
+                 ((nDirection == RIGHT_TO_LEFT) ?
+                 FIELD_SET(0, DE_CONTROL, DIRECTION, RIGHT_TO_LEFT)
+                 : FIELD_SET(0, DE_CONTROL, DIRECTION, LEFT_TO_RIGHT)) |
+                 FIELD_SET(0, DE_CONTROL, STATUS, START);
+       write_dpr(accel, DE_CONTROL, de_ctrl); /* dpr0c */
+
        }
 
-    {
-
-        write_dpr(accel, DE_SOURCE,
-            FIELD_SET  (0, DE_SOURCE, WRAP, DISABLE) |
-            FIELD_VALUE(0, DE_SOURCE, X_K1, sx)   |
-            FIELD_VALUE(0, DE_SOURCE, Y_K2, sy)); /* dpr0 */
-        write_dpr(accel, DE_DESTINATION,
-            FIELD_SET  (0, DE_DESTINATION, WRAP, DISABLE) |
-            FIELD_VALUE(0, DE_DESTINATION, X,    dx)  |
-            FIELD_VALUE(0, DE_DESTINATION, Y,    dy)); /* dpr04 */
-        write_dpr(accel, DE_DIMENSION,
-            FIELD_VALUE(0, DE_DIMENSION, X,    width) |
-            FIELD_VALUE(0, DE_DIMENSION, Y_ET, height)); /* dpr08 */
-
-        de_ctrl =
-            FIELD_VALUE(0, DE_CONTROL, ROP, rop2) |
-            FIELD_SET(0, DE_CONTROL, ROP_SELECT, ROP2) |
-            FIELD_SET(0, DE_CONTROL, COMMAND, BITBLT) |
-            ((nDirection == RIGHT_TO_LEFT) ?
-            FIELD_SET(0, DE_CONTROL, DIRECTION, RIGHT_TO_LEFT)
-            : FIELD_SET(0, DE_CONTROL, DIRECTION, LEFT_TO_RIGHT)) |
-            FIELD_SET(0, DE_CONTROL, STATUS, START);
-               write_dpr(accel, DE_CONTROL, de_ctrl); /* dpr0c */
-    }
-
-    return 0;
+       return 0;
 }
 
 static unsigned int deGetTransparency(struct lynx_accel *accel)
 {
-    unsigned int de_ctrl;
+       unsigned int de_ctrl;
 
-    de_ctrl = read_dpr(accel, DE_CONTROL);
+       de_ctrl = read_dpr(accel, DE_CONTROL);
 
-    de_ctrl &=
-        FIELD_MASK(DE_CONTROL_TRANSPARENCY_MATCH) |
-        FIELD_MASK(DE_CONTROL_TRANSPARENCY_SELECT)|
-        FIELD_MASK(DE_CONTROL_TRANSPARENCY);
+       de_ctrl &=
+                  FIELD_MASK(DE_CONTROL_TRANSPARENCY_MATCH) |
+                  FIELD_MASK(DE_CONTROL_TRANSPARENCY_SELECT)|
+                  FIELD_MASK(DE_CONTROL_TRANSPARENCY);
 
-    return de_ctrl;
+       return de_ctrl;
 }
 
 int hw_imageblit(struct lynx_accel *accel,
@@ -332,38 +320,36 @@ int hw_imageblit(struct lynx_accel *accel,
                 u32 bColor,   /* Background color (corresponding to a 0 in the monochrome data */
                 u32 rop2)     /* ROP value */
 {
-    unsigned int ulBytesPerScan;
-    unsigned int ul4BytesPerScan;
-    unsigned int ulBytesRemain;
-    unsigned int de_ctrl = 0;
-    unsigned char ajRemain[4];
-    int i, j;
-
-    startBit &= 7; /* Just make sure the start bit is within legal range */
-    ulBytesPerScan = (width + startBit + 7) / 8;
-    ul4BytesPerScan = ulBytesPerScan & ~3;
-    ulBytesRemain = ulBytesPerScan & 3;
-
-       if(accel->de_wait() != 0)
-    {
-        return -1;
-    }
-
-    /* 2D Source Base.
-       Use 0 for HOST Blt.
-    */
-    write_dpr(accel, DE_WINDOW_SOURCE_BASE, 0);
+       unsigned int ulBytesPerScan;
+       unsigned int ul4BytesPerScan;
+       unsigned int ulBytesRemain;
+       unsigned int de_ctrl = 0;
+       unsigned char ajRemain[4];
+       int i, j;
+
+       startBit &= 7; /* Just make sure the start bit is within legal range */
+       ulBytesPerScan = (width + startBit + 7) / 8;
+       ul4BytesPerScan = ulBytesPerScan & ~3;
+       ulBytesRemain = ulBytesPerScan & 3;
+
+       if (accel->de_wait() != 0)
+               return -1;
 
-    /* 2D Destination Base.
-       It is an address offset (128 bit aligned) from the beginning of frame buffer.
-    */
-    write_dpr(accel, DE_WINDOW_DESTINATION_BASE, dBase);
+       /* 2D Source Base.
+        Use 0 for HOST Blt.
+        */
+       write_dpr(accel, DE_WINDOW_SOURCE_BASE, 0);
+
+       /* 2D Destination Base.
+        It is an address offset (128 bit aligned) from the beginning of frame buffer.
+        */
+       write_dpr(accel, DE_WINDOW_DESTINATION_BASE, dBase);
 #if 0
     /* Program pitch (distance between the 1st points of two adjacent lines).
        Note that input pitch is BYTE value, but the 2D Pitch register uses
        pixel values. Need Byte to pixel conversion.
     */
-       if(bytePerPixel == 3 ){
+       if (bytePerPixel == 3) {
                dx *= 3;
                width *= 3;
                startBit *= 3;
@@ -371,8 +357,7 @@ int hw_imageblit(struct lynx_accel *accel,
                                FIELD_VALUE(0, DE_PITCH, DESTINATION, dPitch) |
                                FIELD_VALUE(0, DE_PITCH, SOURCE,      dPitch)); /* dpr10 */
 
-       }
-       else
+       } else
 #endif
        {
                write_dpr(accel, DE_PITCH,
@@ -380,30 +365,30 @@ int hw_imageblit(struct lynx_accel *accel,
                                FIELD_VALUE(0, DE_PITCH, SOURCE,      dPitch/bytePerPixel)); /* dpr10 */
        }
 
-    /* Screen Window width in Pixels.
-       2D engine uses this value to calculate the linear address in frame buffer for a given point.
-    */
-    write_dpr(accel, DE_WINDOW_WIDTH,
-        FIELD_VALUE(0, DE_WINDOW_WIDTH, DESTINATION, (dPitch/bytePerPixel)) |
-        FIELD_VALUE(0, DE_WINDOW_WIDTH, SOURCE,      (dPitch/bytePerPixel)));
+       /* Screen Window width in Pixels.
+        2D engine uses this value to calculate the linear address in frame buffer for a given point.
+        */
+       write_dpr(accel, DE_WINDOW_WIDTH,
+                 FIELD_VALUE(0, DE_WINDOW_WIDTH, DESTINATION, (dPitch/bytePerPixel)) |
+                 FIELD_VALUE(0, DE_WINDOW_WIDTH, SOURCE,      (dPitch/bytePerPixel)));
 
-    /* Note: For 2D Source in Host Write, only X_K1_MONO field is needed, and Y_K2 field is not used.
-             For mono bitmap, use startBit for X_K1. */
-    write_dpr(accel, DE_SOURCE,
-        FIELD_SET  (0, DE_SOURCE, WRAP, DISABLE)       |
-        FIELD_VALUE(0, DE_SOURCE, X_K1_MONO, startBit)); /* dpr00 */
+        /* Note: For 2D Source in Host Write, only X_K1_MONO field is needed, and Y_K2 field is not used.
+           For mono bitmap, use startBit for X_K1. */
+       write_dpr(accel, DE_SOURCE,
+                 FIELD_SET(0, DE_SOURCE, WRAP, DISABLE)       |
+                 FIELD_VALUE(0, DE_SOURCE, X_K1_MONO, startBit)); /* dpr00 */
 
-    write_dpr(accel, DE_DESTINATION,
-        FIELD_SET  (0, DE_DESTINATION, WRAP, DISABLE) |
-        FIELD_VALUE(0, DE_DESTINATION, X,    dx)    |
-        FIELD_VALUE(0, DE_DESTINATION, Y,    dy)); /* dpr04 */
+       write_dpr(accel, DE_DESTINATION,
+                 FIELD_SET(0, DE_DESTINATION, WRAP, DISABLE) |
+                 FIELD_VALUE(0, DE_DESTINATION, X,    dx)    |
+                 FIELD_VALUE(0, DE_DESTINATION, Y,    dy)); /* dpr04 */
 
-    write_dpr(accel, DE_DIMENSION,
-        FIELD_VALUE(0, DE_DIMENSION, X,    width) |
-        FIELD_VALUE(0, DE_DIMENSION, Y_ET, height)); /* dpr08 */
+       write_dpr(accel, DE_DIMENSION,
+                 FIELD_VALUE(0, DE_DIMENSION, X,    width) |
+                 FIELD_VALUE(0, DE_DIMENSION, Y_ET, height)); /* dpr08 */
 
-    write_dpr(accel, DE_FOREGROUND, fColor);
-    write_dpr(accel, DE_BACKGROUND, bColor);
+       write_dpr(accel, DE_FOREGROUND, fColor);
+       write_dpr(accel, DE_BACKGROUND, bColor);
 
        de_ctrl = FIELD_VALUE(0, DE_CONTROL, ROP, rop2)         |
                FIELD_SET(0, DE_CONTROL, ROP_SELECT, ROP2)    |
@@ -413,24 +398,20 @@ int hw_imageblit(struct lynx_accel *accel,
 
        write_dpr(accel, DE_CONTROL, de_ctrl | deGetTransparency(accel));
 
-    /* Write MONO data (line by line) to 2D Engine data port */
-    for (i=0; i<height; i++)
-    {
-        /* For each line, send the data in chunks of 4 bytes */
-        for (j=0; j<(ul4BytesPerScan/4); j++)
-        {
-            write_dpPort(accel, *(unsigned int *)(pSrcbuf + (j * 4)));
-        }
-
-        if (ulBytesRemain)
-        {
-            memcpy(ajRemain, pSrcbuf+ul4BytesPerScan, ulBytesRemain);
-            write_dpPort(accel, *(unsigned int *)ajRemain);
-        }
-
-        pSrcbuf += srcDelta;
-    }
-
-    return 0;
+       /* Write MONO data (line by line) to 2D Engine data port */
+       for (i = 0; i < height; i++) {
+               /* For each line, send the data in chunks of 4 bytes */
+               for (j = 0; j < (ul4BytesPerScan/4); j++)
+                       write_dpPort(accel, *(unsigned int *)(pSrcbuf + (j * 4)));
+
+               if (ulBytesRemain) {
+                       memcpy(ajRemain, pSrcbuf+ul4BytesPerScan, ulBytesRemain);
+                       write_dpPort(accel, *(unsigned int *)ajRemain);
+               }
+
+               pSrcbuf += srcDelta;
+       }
+
+           return 0;
 }
 
index d3d256c..f252e47 100644 (file)
@@ -7,7 +7,7 @@
 /* notes: below address are the offset value from de_base_address (0x100000)*/
 
 /* for sm718/750/502 de_base is at mmreg_1mb*/
-#define DE_BASE_ADDR_TYPE1     0x100000
+#define DE_BASE_ADDR_TYPE1 0x100000
 /* for sm712,de_base is at mmreg_32kb */
 #define DE_BASE_ADDR_TYPE2  0x8000
 /* for sm722,de_base is at mmreg_0 */
@@ -26,7 +26,7 @@
 #define DE_SOURCE_WRAP_ENABLE                           1
 #define DE_SOURCE_X_K1                                  29:16
 #define DE_SOURCE_Y_K2                                  15:0
-#define DE_SOURCE_X_K1_MONO                                                    20:16
+#define DE_SOURCE_X_K1_MONO                            20:16
 
 #define DE_DESTINATION                                  0x4
 #define DE_DESTINATION_WRAP                             31:31
index 405e24b..2400c6c 100644 (file)
@@ -61,6 +61,7 @@ writel((data), cursor->mmio + (addr))
 void hw_cursor_enable(struct lynx_cursor *cursor)
 {
        u32 reg;
+
        reg = FIELD_VALUE(0, HWC_ADDRESS, ADDRESS, cursor->offset)|
                        FIELD_SET(0, HWC_ADDRESS, EXT, LOCAL)|
                        FIELD_SET(0, HWC_ADDRESS, ENABLE, ENABLE);
@@ -81,6 +82,7 @@ void hw_cursor_setPos(struct lynx_cursor *cursor,
                                                int x, int y)
 {
        u32 reg;
+
        reg = FIELD_VALUE(0, HWC_LOCATION, Y, y)|
                        FIELD_VALUE(0, HWC_LOCATION, X, x);
        POKE32(HWC_LOCATION, reg);
@@ -122,8 +124,7 @@ void hw_cursor_setData(struct lynx_cursor *cursor,
                odd=0;
 */
 
-       for(i=0;i<count;i++)
-       {
+       for (i = 0; i < count; i++) {
                color = *pcol++;
                mask = *pmsk++;
                data = 0;
@@ -132,26 +133,25 @@ void hw_cursor_setData(struct lynx_cursor *cursor,
                 * but method 2 shows no lag
                 * and method 1 seems a bit wrong*/
 #if 0
-               if(rop == ROP_XOR)
+               if (rop == ROP_XOR)
                        opr = mask ^ color;
                else
                        opr = mask & color;
 
-               for(j=0;j<8;j++)
-               {
+               for (j = 0; j < 8; j++) {
 
-                       if(opr & (0x80 >> j))
-                       {       /* use fg color,id = 2 */
+                       if (opr & (0x80 >> j)) {
+                               /* use fg color,id = 2 */
                                data |= 2 << (j*2);
-                       }else{
+                       } else {
                                /* use bg color,id = 1 */
                                data |= 1 << (j*2);
                        }
                }
 #else
-               for(j=0;j<8;j++){
-                       if(mask & (0x80>>j)){
-                               if(rop == ROP_XOR)
+               for (j = 0; j < 8; j++) {
+                       if (mask & (0x80>>j)) {
+                               if (rop == ROP_XOR)
                                        opr = mask ^ color;
                                else
                                        opr = mask & color;
@@ -165,15 +165,15 @@ void hw_cursor_setData(struct lynx_cursor *cursor,
 
                /* assume pitch is 1,2,4,8,...*/
 #if 0
-               if(!((i+1)&(pitch-1)))   /* below line equal to is line */
+               if (!((i+1)&(pitch-1)))   /* below line equal to is line */
 #else
-               if((i+1) % pitch == 0)
+               if ((i+1) % pitch == 0)
 #endif
                {
                        /* need a return */
                        pstart += offset;
                        pbuffer = pstart;
-               }else{
+               } else {
                        pbuffer += sizeof(u16);
                }
 
@@ -204,45 +204,42 @@ void hw_cursor_setData2(struct lynx_cursor *cursor,
        pstart = cursor->vstart;
        pbuffer = pstart;
 
-       for(i=0;i<count;i++)
-       {
+       for (i = 0; i < count; i++) {
                color = *pcol++;
                mask = *pmsk++;
                data = 0;
 
                /* either method below works well, but method 2 shows no lag */
 #if 0
-               if(rop == ROP_XOR)
+               if (rop == ROP_XOR)
                        opr = mask ^ color;
                else
                        opr = mask & color;
 
-               for(j=0;j<8;j++)
-               {
+               for (j = 0; j < 8; j++) {
 
-                       if(opr & (0x80 >> j))
-                       {       /* use fg color,id = 2 */
+                       if (opr & (0x80 >> j)) {
+                               /* use fg color,id = 2 */
                                data |= 2 << (j*2);
-                       }else{
+                       } else {
                                /* use bg color,id = 1 */
                                data |= 1 << (j*2);
                        }
                }
 #else
-               for(j=0;j<8;j++){
-                       if(mask & (1<<j))
+               for (j = 0; j < 8; j++) {
+                       if (mask & (1<<j))
                                data |= ((color & (1<<j))?1:2)<<(j*2);
                }
 #endif
                iowrite16(data, pbuffer);
 
                /* assume pitch is 1,2,4,8,...*/
-               if(!(i&(pitch-1)))
-               {
+               if (!(i&(pitch-1))) {
                        /* need a return */
                        pstart += offset;
                        pbuffer = pstart;
-               }else{
+               } else {
                        pbuffer += sizeof(u16);
                }
 
index 05777f7..8dc6bd2 100644 (file)
@@ -11,9 +11,9 @@
 #define GET_FIELD(d, f)     (((d) >> _LSB(f)) & RAW_MASK(f))
 #define TEST_FIELD(d, f, v) (GET_FIELD(d, f) == f ## _ ## v)
 #define SET_FIELD(d, f, v)  (((d) & ~GET_MASK(f)) | \
-                            (((f ## _ ## v) & RAW_MASK(f)) << _LSB(f)))
+                           (((f ## _ ## v) & RAW_MASK(f)) << _LSB(f)))
 #define SET_FIELDV(d, f, v) (((d) & ~GET_MASK(f)) | \
-                            (((v) & RAW_MASK(f)) << _LSB(f)))
+                           (((v) & RAW_MASK(f)) << _LSB(f)))
 
 /* Internal macros */
 #define _F_START(f)             (0 ? f)
 /* Global macros */
 #define FIELD_GET(x, reg, field) \
 ( \
-    _F_NORMALIZE((x), reg ## _ ## field) \
+       _F_NORMALIZE((x), reg ## _ ## field) \
 )
 
 #define FIELD_SET(x, reg, field, value) \
 ( \
-    (x & ~_F_MASK(reg ## _ ## field)) \
-    | _F_DENORMALIZE(reg ## _ ## field ## _ ## value, reg ## _ ## field) \
+       (x & ~_F_MASK(reg ## _ ## field)) \
+       | _F_DENORMALIZE(reg ## _ ## field ## _ ## value, reg ## _ ## field) \
 )
 
 #define FIELD_VALUE(x, reg, field, value) \
 ( \
-    (x & ~_F_MASK(reg ## _ ## field)) \
-    | _F_DENORMALIZE(value, reg ## _ ## field) \
+       (x & ~_F_MASK(reg ## _ ## field)) \
+       | _F_DENORMALIZE(value, reg ## _ ## field) \
 )
 
 #define FIELD_CLEAR(reg, field) \
 ( \
-    ~ _F_MASK(reg ## _ ## field) \
+       ~ _F_MASK(reg ## _ ## field) \
 )
 
 /* Field Macros */
 #define FIELD_DENORMALIZE(field, value) (((value) << FIELD_START(field)) & FIELD_MASK(field))
 
 #define FIELD_INIT(reg, field, value)   FIELD_DENORMALIZE(reg ## _ ## field, \
-                                                          reg ## _ ## field ## _ ## value)
+                                                         reg ## _ ## field ## _ ## value)
 #define FIELD_INIT_VAL(reg, field, value) \
-                                        (FIELD_DENORMALIZE(reg ## _ ## field, value))
+       (FIELD_DENORMALIZE(reg ## _ ## field, value))
 #define FIELD_VAL_SET(x, r, f, v)       x = x & ~FIELD_MASK(r ## _ ## f) \
-                                              | FIELD_DENORMALIZE(r ## _ ## f, r ## _ ## f ## _ ## v)
+                                       | FIELD_DENORMALIZE(r ## _ ## f, r ## _ ## f ## _ ## v)
 
 #define RGB(r, g, b) \
 ( \
-    (unsigned long) (((r) << 16) | ((g) << 8) | (b)) \
+       (unsigned long) (((r) << 16) | ((g) << 8) | (b)) \
 )
 
 #define RGB16(r, g, b) \
 ( \
-    (unsigned short) ((((r) & 0xF8) << 8) | (((g) & 0xFC) << 3) | (((b) & 0xF8) >> 3)) \
+       (unsigned short) ((((r) & 0xF8) << 8) | (((g) & 0xFC) << 3) | (((b) & 0xF8) >> 3)) \
 )
 
 static inline unsigned int absDiff(unsigned int a, unsigned int b)
 {
-       if(a<b)
+       if (a < b)
                return b-a;
        else
                return a-b;
index 84381bc..7317ba9 100644 (file)
 #include "ddk750.h"
 #include "sm750_accel.h"
 
-int hw_sm750_map(struct lynx_share* share, struct pci_dev* pdev)
+int hw_sm750_map(struct lynx_share *share, struct pci_dev *pdev)
 {
        int ret;
        struct sm750_share *spec_share;
-       
+
 
        spec_share = container_of(share, struct sm750_share, share);
        ret = 0;
@@ -43,24 +43,23 @@ int hw_sm750_map(struct lynx_share* share, struct pci_dev* pdev)
         * in lynxfb_remove, or memory will not be mapped again
         * successfully
         * */
-
-       if((ret = pci_request_region(pdev, 1, "sm750fb")))
-       {
+       ret = pci_request_region(pdev, 1, "sm750fb");
+       if (ret) {
                pr_err("Can not request PCI regions.\n");
                goto exit;
        }
 
        /* now map mmio and vidmem*/
        share->pvReg = ioremap_nocache(share->vidreg_start, share->vidreg_size);
-       if(!share->pvReg){
+       if (!share->pvReg) {
                pr_err("mmio failed\n");
                ret = -EFAULT;
                goto exit;
-       }else{
+       } else {
                pr_info("mmio virtual addr = %p\n", share->pvReg);
        }
 
-       
+
        share->accel.dprBase = share->pvReg + DE_BASE_ADDR_TYPE1;
        share->accel.dpPortBase = share->pvReg + DE_PORT_ADDR_TYPE1;
 
@@ -78,8 +77,8 @@ int hw_sm750_map(struct lynx_share* share, struct pci_dev* pdev)
 
        /* reserve the vidmem space of smi adaptor */
 #if 0
-       if((ret = pci_request_region(pdev, 0, _moduleName_)))
-       {
+       ret = pci_request_region(pdev, 0, _moduleName_);
+       if (ret) {
                pr_err("Can not request PCI regions.\n");
                goto exit;
        }
@@ -87,11 +86,11 @@ int hw_sm750_map(struct lynx_share* share, struct pci_dev* pdev)
 
        share->pvMem = ioremap_wc(share->vidmem_start, share->vidmem_size);
 
-       if(!share->pvMem){
+       if (!share->pvMem) {
                pr_err("Map video memory failed\n");
                ret = -EFAULT;
                goto exit;
-       }else{
+       } else {
                pr_info("video memory vaddr = %p\n", share->pvMem);
        }
 exit:
@@ -104,22 +103,22 @@ int hw_sm750_inithw(struct lynx_share *share, struct pci_dev *pdev)
 {
        struct sm750_share *spec_share;
        struct init_status *parm;
-       
+
        spec_share = container_of(share, struct sm750_share, share);
        parm = &spec_share->state.initParm;
-       if(parm->chip_clk == 0)
-               parm->chip_clk = (getChipType() == SM750LE)?
+       if (parm->chip_clk == 0)
+               parm->chip_clk = (getChipType() == SM750LE) ?
                                                DEFAULT_SM750LE_CHIP_CLOCK :
                                                DEFAULT_SM750_CHIP_CLOCK;
 
-       if(parm->mem_clk == 0)
+       if (parm->mem_clk == 0)
                parm->mem_clk = parm->chip_clk;
-       if(parm->master_clk == 0)
+       if (parm->master_clk == 0)
                parm->master_clk = parm->chip_clk/3;
 
        ddk750_initHw((initchip_param_t *)&spec_share->state.initParm);
        /* for sm718,open pci burst */
-       if(share->devid == 0x718){
+       if (share->devid == 0x718) {
                POKE32(SYSTEM_CTRL,
                                FIELD_SET(PEEK32(SYSTEM_CTRL), SYSTEM_CTRL, PCI_BURST, ON));
        }
@@ -130,10 +129,9 @@ int hw_sm750_inithw(struct lynx_share *share, struct pci_dev *pdev)
        ddk750_initDVIDisp();
 #endif
 
-       if(getChipType() != SM750LE)
-       {
+       if (getChipType() != SM750LE) {
                /* does user need CRT ?*/
-               if(spec_share->state.nocrt){
+               if (spec_share->state.nocrt) {
                        POKE32(MISC_CTRL,
                                        FIELD_SET(PEEK32(MISC_CTRL),
                                        MISC_CTRL,
@@ -143,7 +141,7 @@ int hw_sm750_inithw(struct lynx_share *share, struct pci_dev *pdev)
                                        FIELD_SET(PEEK32(SYSTEM_CTRL),
                                        SYSTEM_CTRL,
                                        DPMS, VNHN));
-               }else{
+               } else {
                        POKE32(MISC_CTRL,
                                        FIELD_SET(PEEK32(MISC_CTRL),
                                        MISC_CTRL,
@@ -155,45 +153,43 @@ int hw_sm750_inithw(struct lynx_share *share, struct pci_dev *pdev)
                                        DPMS, VPHP));
                }
 
-               switch (spec_share->state.pnltype){
-                       case sm750_doubleTFT:
-                       case sm750_24TFT:
-                       case sm750_dualTFT:
-                       POKE32(PANEL_DISPLAY_CTRL,
-                               FIELD_VALUE(PEEK32(PANEL_DISPLAY_CTRL),
-                                                       PANEL_DISPLAY_CTRL,
-                                                       TFT_DISP,
-                                                       spec_share->state.pnltype));
-                       break;
+               switch (spec_share->state.pnltype) {
+               case sm750_doubleTFT:
+               case sm750_24TFT:
+               case sm750_dualTFT:
+               POKE32(PANEL_DISPLAY_CTRL,
+                       FIELD_VALUE(PEEK32(PANEL_DISPLAY_CTRL),
+                                               PANEL_DISPLAY_CTRL,
+                                               TFT_DISP,
+                                               spec_share->state.pnltype));
+               break;
                }
-       }else{
+       } else {
                /* for 750LE ,no DVI chip initilization makes Monitor no signal */
                /* Set up GPIO for software I2C to program DVI chip in the
                   Xilinx SP605 board, in order to have video signal.
                 */
-        swI2CInit(0, 1);
+       swI2CInit(0, 1);
 
 
-        /* Customer may NOT use CH7301 DVI chip, which has to be
-           initialized differently.
-         */
-        if (swI2CReadReg(0xec, 0x4a) == 0x95)
-        {
-            /* The following register values for CH7301 are from
-               Chrontel app note and our experiment.
-             */
+       /* Customer may NOT use CH7301 DVI chip, which has to be
+          initialized differently.
+       */
+       if (swI2CReadReg(0xec, 0x4a) == 0x95) {
+               /* The following register values for CH7301 are from
+                  Chrontel app note and our experiment.
+               */
                        pr_info("yes,CH7301 DVI chip found\n");
-            swI2CWriteReg(0xec, 0x1d, 0x16);
-            swI2CWriteReg(0xec, 0x21, 0x9);
-            swI2CWriteReg(0xec, 0x49, 0xC0);
+               swI2CWriteReg(0xec, 0x1d, 0x16);
+               swI2CWriteReg(0xec, 0x21, 0x9);
+               swI2CWriteReg(0xec, 0x49, 0xC0);
                        pr_info("okay,CH7301 DVI chip setup done\n");
-        }
+       }
        }
 
        /* init 2d engine */
-       if(!share->accel_off){
+       if (!share->accel_off)
                hw_sm750_initAccel(share);
-       }
 
        return 0;
 }
@@ -202,86 +198,87 @@ int hw_sm750_inithw(struct lynx_share *share, struct pci_dev *pdev)
 resource_size_t hw_sm750_getVMSize(struct lynx_share *share)
 {
        resource_size_t ret;
-       
+
        ret = ddk750_getVMSize();
        return ret;
 }
 
 
 
-int hw_sm750_output_checkMode(struct lynxfb_output* output, struct fb_var_screeninfo* var)
+int hw_sm750_output_checkMode(struct lynxfb_output *output, struct fb_var_screeninfo *var)
 {
-       
+
        return 0;
 }
 
 
-int hw_sm750_output_setMode(struct lynxfb_outputoutput,
-                                                                       struct fb_var_screeninfo* var, struct fb_fix_screeninfo* fix)
+int hw_sm750_output_setMode(struct lynxfb_output *output,
+                                                                       struct fb_var_screeninfo *var, struct fb_fix_screeninfo *fix)
 {
        int ret;
        disp_output_t dispSet;
        int channel;
-       
+
        ret = 0;
        dispSet = 0;
        channel = *output->channel;
 
 
-       if(getChipType() != SM750LE){
-               if(channel == sm750_primary){
+       if (getChipType() != SM750LE) {
+               if (channel == sm750_primary) {
                        pr_info("primary channel\n");
-                       if(output->paths & sm750_panel)
+                       if (output->paths & sm750_panel)
                                dispSet |= do_LCD1_PRI;
-                       if(output->paths & sm750_crt)
+                       if (output->paths & sm750_crt)
                                dispSet |= do_CRT_PRI;
 
-               }else{
+               } else {
                        pr_info("secondary channel\n");
-                       if(output->paths & sm750_panel)
+                       if (output->paths & sm750_panel)
                                dispSet |= do_LCD1_SEC;
-                       if(output->paths & sm750_crt)
+                       if (output->paths & sm750_crt)
                                dispSet |= do_CRT_SEC;
 
                }
                ddk750_setLogicalDispOut(dispSet);
-       }else{
+       } else {
                /* just open DISPLAY_CONTROL_750LE register bit 3:0*/
                u32 reg;
+
                reg = PEEK32(DISPLAY_CONTROL_750LE);
                reg |= 0xf;
                POKE32(DISPLAY_CONTROL_750LE, reg);
        }
 
-       pr_info("ddk setlogicdispout done \n");
+       pr_info("ddk setlogicdispout done\n");
        return ret;
 }
 
-void hw_sm750_output_clear(struct lynxfb_outputoutput)
+void hw_sm750_output_clear(struct lynxfb_output *output)
 {
-       
+
        return;
 }
 
-int hw_sm750_crtc_checkMode(struct lynxfb_crtc* crtc, struct fb_var_screeninfo* var)
+int hw_sm750_crtc_checkMode(struct lynxfb_crtc *crtc, struct fb_var_screeninfo *var)
 {
        struct lynx_share *share;
-       
+
 
        share = container_of(crtc, struct lynxfb_par, crtc)->share;
 
-       switch (var->bits_per_pixel){
-               case 8:
-               case 16:
-                       break;
-               case 32:
-                       if (share->revid == SM750LE_REVISION_ID) {
-                               pr_debug("750le do not support 32bpp\n");
-                               return -EINVAL;
-                       }
-                       break;
-               default:
+       switch (var->bits_per_pixel) {
+       case 8:
+       case 16:
+               break;
+       case 32:
+               if (share->revid == SM750LE_REVISION_ID) {
+                       pr_debug("750le do not support 32bpp\n");
                        return -EINVAL;
+               }
+               break;
+       default:
+               return -EINVAL;
 
        }
 
@@ -292,9 +289,9 @@ int hw_sm750_crtc_checkMode(struct lynxfb_crtc* crtc, struct fb_var_screeninfo*
 /*
        set the controller's mode for @crtc charged with @var and @fix parameters
 */
-int hw_sm750_crtc_setMode(struct lynxfb_crtccrtc,
-                                                               struct fb_var_screeninfovar,
-                                                               struct fb_fix_screeninfofix)
+int hw_sm750_crtc_setMode(struct lynxfb_crtc *crtc,
+                                                               struct fb_var_screeninfo *var,
+                                                               struct fb_fix_screeninfo *fix)
 {
        int ret, fmt;
        u32 reg;
@@ -303,24 +300,24 @@ int hw_sm750_crtc_setMode(struct lynxfb_crtc* crtc,
        struct lynx_share *share;
        struct lynxfb_par *par;
 
-       
+
        ret = 0;
        par = container_of(crtc, struct lynxfb_par, crtc);
        share = par->share;
 #if 1
-       if(!share->accel_off){
+       if (!share->accel_off) {
                /* set 2d engine pixel format according to mode bpp */
-               switch(var->bits_per_pixel){
-                       case 8:
-                               fmt = 0;
-                               break;
-                       case 16:
-                               fmt = 1;
-                               break;
-                       case 32:
-                       default:
-                               fmt = 2;
-                               break;
+               switch (var->bits_per_pixel) {
+               case 8:
+                       fmt = 0;
+                       break;
+               case 16:
+                       fmt = 1;
+                       break;
+               case 32:
+               default:
+                       fmt = 2;
+                       break;
                }
                hw_set2dformat(&share->accel, fmt);
        }
@@ -330,7 +327,7 @@ int hw_sm750_crtc_setMode(struct lynxfb_crtc* crtc,
        modparm.pixel_clock = ps_to_hz(var->pixclock);
        modparm.vertical_sync_polarity = (var->sync & FB_SYNC_HOR_HIGH_ACT) ? POS:NEG;
        modparm.horizontal_sync_polarity = (var->sync & FB_SYNC_VERT_HIGH_ACT) ? POS:NEG;
-       modparm.clock_phase_polarity = (var->sync& FB_SYNC_COMP_HIGH_ACT) ? POS:NEG;
+       modparm.clock_phase_polarity = (var->sync & FB_SYNC_COMP_HIGH_ACT) ? POS:NEG;
        modparm.horizontal_display_end = var->xres;
        modparm.horizontal_sync_width = var->hsync_len;
        modparm.horizontal_sync_start = var->xres + var->right_margin;
@@ -341,19 +338,19 @@ int hw_sm750_crtc_setMode(struct lynxfb_crtc* crtc,
        modparm.vertical_total = var->yres + var->upper_margin + var->lower_margin + var->vsync_len;
 
        /* choose pll */
-       if(crtc->channel != sm750_secondary)
+       if (crtc->channel != sm750_secondary)
                clock = PRIMARY_PLL;
        else
                clock = SECONDARY_PLL;
 
        pr_debug("Request pixel clock = %lu\n", modparm.pixel_clock);
        ret = ddk750_setModeTiming(&modparm, clock);
-       if(ret){
+       if (ret) {
                pr_err("Set mode timing failed\n");
                goto exit;
        }
 
-       if(crtc->channel != sm750_secondary){
+       if (crtc->channel != sm750_secondary) {
                /* set pitch, offset ,width,start address ,etc... */
                POKE32(PANEL_FB_ADDRESS,
                        FIELD_SET(0, PANEL_FB_ADDRESS, STATUS, CURRENT)|
@@ -369,7 +366,7 @@ int hw_sm750_crtc_setMode(struct lynxfb_crtc* crtc,
                        FIELD_VALUE(0, PANEL_FB_WIDTH, OFFSET, fix->line_length));
 
                POKE32(PANEL_WINDOW_WIDTH,
-                       FIELD_VALUE(0, PANEL_WINDOW_WIDTH, WIDTH, var->xres -1)|
+                       FIELD_VALUE(0, PANEL_WINDOW_WIDTH, WIDTH, var->xres - 1)|
                        FIELD_VALUE(0, PANEL_WINDOW_WIDTH, X, var->xoffset));
 
                POKE32(PANEL_WINDOW_HEIGHT,
@@ -389,7 +386,7 @@ int hw_sm750_crtc_setMode(struct lynxfb_crtc* crtc,
                        PANEL_DISPLAY_CTRL, FORMAT,
                        (var->bits_per_pixel >> 4)
                        ));
-       }else{
+       } else {
                /* not implemented now */
                POKE32(CRT_FB_ADDRESS, crtc->oScreen);
                reg = var->xres * (var->bits_per_pixel >> 3);
@@ -412,138 +409,137 @@ exit:
        return ret;
 }
 
-void hw_sm750_crtc_clear(struct lynxfb_crtccrtc)
+void hw_sm750_crtc_clear(struct lynxfb_crtc *crtc)
 {
-       
+
        return;
 }
 
-int hw_sm750_setColReg(struct lynxfb_crtccrtc, ushort index,
+int hw_sm750_setColReg(struct lynxfb_crtc *crtc, ushort index,
                                                                ushort red, ushort green, ushort blue)
 {
-       static unsigned int add[]={PANEL_PALETTE_RAM, CRT_PALETTE_RAM};
+       static unsigned int add[] = {PANEL_PALETTE_RAM, CRT_PALETTE_RAM};
+
        POKE32(add[crtc->channel] + index*4, (red<<16)|(green<<8)|blue);
        return 0;
 }
 
-int hw_sm750le_setBLANK(struct lynxfb_output * output, int blank){
+int hw_sm750le_setBLANK(struct lynxfb_output *output, int blank)
+{
        int dpms, crtdb;
-       
-       switch(blank)
-       {
+
+       switch (blank) {
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
-               case FB_BLANK_UNBLANK:
+       case FB_BLANK_UNBLANK:
 #else
-               case VESA_NO_BLANKING:
+       case VESA_NO_BLANKING:
 #endif
-                       dpms = CRT_DISPLAY_CTRL_DPMS_0;
-                       crtdb = CRT_DISPLAY_CTRL_BLANK_OFF;
-                       break;
+               dpms = CRT_DISPLAY_CTRL_DPMS_0;
+               crtdb = CRT_DISPLAY_CTRL_BLANK_OFF;
+               break;
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
-               case FB_BLANK_NORMAL:
-                       dpms = CRT_DISPLAY_CTRL_DPMS_0;
-                       crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
-                       break;
+       case FB_BLANK_NORMAL:
+               dpms = CRT_DISPLAY_CTRL_DPMS_0;
+               crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
+               break;
 #endif
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
-               case FB_BLANK_VSYNC_SUSPEND:
+       case FB_BLANK_VSYNC_SUSPEND:
 #else
-               case VESA_VSYNC_SUSPEND:
+       case VESA_VSYNC_SUSPEND:
 #endif
-                       dpms = CRT_DISPLAY_CTRL_DPMS_2;
-                       crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
-                       break;
+               dpms = CRT_DISPLAY_CTRL_DPMS_2;
+               crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
+               break;
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
-               case FB_BLANK_HSYNC_SUSPEND:
+       case FB_BLANK_HSYNC_SUSPEND:
 #else
-               case VESA_HSYNC_SUSPEND:
+       case VESA_HSYNC_SUSPEND:
 #endif
-                       dpms = CRT_DISPLAY_CTRL_DPMS_1;
-                       crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
-                       break;
+               dpms = CRT_DISPLAY_CTRL_DPMS_1;
+               crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
+               break;
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
-               case FB_BLANK_POWERDOWN:
+       case FB_BLANK_POWERDOWN:
 #else
-               case VESA_POWERDOWN:
+       case VESA_POWERDOWN:
 #endif
-                       dpms = CRT_DISPLAY_CTRL_DPMS_3;
-                       crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
-                       break;
-               default:
-                       return -EINVAL;
+               dpms = CRT_DISPLAY_CTRL_DPMS_3;
+               crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
+               break;
+       default:
+               return -EINVAL;
        }
 
-       if(output->paths & sm750_crt){
+       if (output->paths & sm750_crt) {
                POKE32(CRT_DISPLAY_CTRL, FIELD_VALUE(PEEK32(CRT_DISPLAY_CTRL), CRT_DISPLAY_CTRL, DPMS, dpms));
                POKE32(CRT_DISPLAY_CTRL, FIELD_VALUE(PEEK32(CRT_DISPLAY_CTRL), CRT_DISPLAY_CTRL, BLANK, crtdb));
        }
        return 0;
 }
 
-int hw_sm750_setBLANK(struct lynxfb_outputoutput, int blank)
+int hw_sm750_setBLANK(struct lynxfb_output *output, int blank)
 {
        unsigned int dpms, pps, crtdb;
-       
+
        dpms = pps = crtdb = 0;
 
-       switch (blank)
-       {
+       switch (blank) {
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
-               case FB_BLANK_UNBLANK:
+       case FB_BLANK_UNBLANK:
 #else
-               case VESA_NO_BLANKING:
+       case VESA_NO_BLANKING:
 #endif
-                       pr_info("flag = FB_BLANK_UNBLANK \n");
-                       dpms = SYSTEM_CTRL_DPMS_VPHP;
-                       pps = PANEL_DISPLAY_CTRL_DATA_ENABLE;
-                       crtdb = CRT_DISPLAY_CTRL_BLANK_OFF;
-                       break;
+               pr_info("flag = FB_BLANK_UNBLANK\n");
+               dpms = SYSTEM_CTRL_DPMS_VPHP;
+               pps = PANEL_DISPLAY_CTRL_DATA_ENABLE;
+               crtdb = CRT_DISPLAY_CTRL_BLANK_OFF;
+               break;
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
-               case FB_BLANK_NORMAL:
-                       pr_info("flag = FB_BLANK_NORMAL \n");
-                       dpms = SYSTEM_CTRL_DPMS_VPHP;
-                       pps = PANEL_DISPLAY_CTRL_DATA_DISABLE;
-                       crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
-                       break;
+       case FB_BLANK_NORMAL:
+               pr_info("flag = FB_BLANK_NORMAL\n");
+               dpms = SYSTEM_CTRL_DPMS_VPHP;
+               pps = PANEL_DISPLAY_CTRL_DATA_DISABLE;
+               crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
+               break;
 #endif
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
-               case FB_BLANK_VSYNC_SUSPEND:
+       case FB_BLANK_VSYNC_SUSPEND:
 #else
-               case VESA_VSYNC_SUSPEND:
+       case VESA_VSYNC_SUSPEND:
 #endif
-                       dpms = SYSTEM_CTRL_DPMS_VNHP;
-                       pps = PANEL_DISPLAY_CTRL_DATA_DISABLE;
-                       crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
-                       break;
+               dpms = SYSTEM_CTRL_DPMS_VNHP;
+               pps = PANEL_DISPLAY_CTRL_DATA_DISABLE;
+               crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
+               break;
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
-               case FB_BLANK_HSYNC_SUSPEND:
+       case FB_BLANK_HSYNC_SUSPEND:
 #else
-               case VESA_HSYNC_SUSPEND:
+       case VESA_HSYNC_SUSPEND:
 #endif
-                       dpms = SYSTEM_CTRL_DPMS_VPHN;
-                       pps = PANEL_DISPLAY_CTRL_DATA_DISABLE;
-                       crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
-                       break;
+               dpms = SYSTEM_CTRL_DPMS_VPHN;
+               pps = PANEL_DISPLAY_CTRL_DATA_DISABLE;
+               crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
+               break;
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
-               case FB_BLANK_POWERDOWN:
+       case FB_BLANK_POWERDOWN:
 #else
-               case VESA_POWERDOWN:
+       case VESA_POWERDOWN:
 #endif
-                       dpms = SYSTEM_CTRL_DPMS_VNHN;
-                       pps = PANEL_DISPLAY_CTRL_DATA_DISABLE;
-                       crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
-                       break;
+               dpms = SYSTEM_CTRL_DPMS_VNHN;
+               pps = PANEL_DISPLAY_CTRL_DATA_DISABLE;
+               crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
+               break;
        }
 
-       if(output->paths & sm750_crt){
+       if (output->paths & sm750_crt) {
 
                POKE32(SYSTEM_CTRL, FIELD_VALUE(PEEK32(SYSTEM_CTRL), SYSTEM_CTRL, DPMS, dpms));
                POKE32(CRT_DISPLAY_CTRL, FIELD_VALUE(PEEK32(CRT_DISPLAY_CTRL), CRT_DISPLAY_CTRL, BLANK, crtdb));
        }
 
-       if(output->paths & sm750_panel){
+       if (output->paths & sm750_panel)
                POKE32(PANEL_DISPLAY_CTRL, FIELD_VALUE(PEEK32(PANEL_DISPLAY_CTRL), PANEL_DISPLAY_CTRL, DATA, pps));
-       }
 
        return 0;
 }
@@ -552,9 +548,10 @@ int hw_sm750_setBLANK(struct lynxfb_output* output, int blank)
 void hw_sm750_initAccel(struct lynx_share *share)
 {
        u32 reg;
+
        enable2DEngine(1);
 
-       if(getChipType() == SM750LE){
+       if (getChipType() == SM750LE) {
                reg = PEEK32(DE_STATE1);
                reg = FIELD_SET(reg, DE_STATE1, DE_ABORT, ON);
                POKE32(DE_STATE1, reg);
@@ -563,7 +560,7 @@ void hw_sm750_initAccel(struct lynx_share *share)
                reg = FIELD_SET(reg, DE_STATE1, DE_ABORT, OFF);
                POKE32(DE_STATE1, reg);
 
-       }else{
+       } else {
                /* engine reset */
                reg = PEEK32(SYSTEM_CTRL);
            reg = FIELD_SET(reg, SYSTEM_CTRL, DE_ABORT, ON);
@@ -580,13 +577,14 @@ void hw_sm750_initAccel(struct lynx_share *share)
 
 int hw_sm750le_deWait(void)
 {
-       int i=0x10000000;
-       while(i--){
+       int i = 0x10000000;
+
+       while (i--) {
                unsigned int dwVal = PEEK32(DE_STATE2);
-               if((FIELD_GET(dwVal, DE_STATE2, DE_STATUS) == DE_STATE2_DE_STATUS_IDLE) &&
+
+               if ((FIELD_GET(dwVal, DE_STATE2, DE_STATUS) == DE_STATE2_DE_STATUS_IDLE) &&
                        (FIELD_GET(dwVal, DE_STATE2, DE_FIFO)  == DE_STATE2_DE_FIFO_EMPTY) &&
-                       (FIELD_GET(dwVal, DE_STATE2, DE_MEM_FIFO) == DE_STATE2_DE_MEM_FIFO_EMPTY))
-               {
+                       (FIELD_GET(dwVal, DE_STATE2, DE_MEM_FIFO) == DE_STATE2_DE_MEM_FIFO_EMPTY)) {
                        return 0;
                }
        }
@@ -597,13 +595,14 @@ int hw_sm750le_deWait(void)
 
 int hw_sm750_deWait(void)
 {
-       int i=0x10000000;
-       while(i--){
+       int i = 0x10000000;
+
+       while (i--) {
                unsigned int dwVal = PEEK32(SYSTEM_CTRL);
-               if((FIELD_GET(dwVal, SYSTEM_CTRL, DE_STATUS) == SYSTEM_CTRL_DE_STATUS_IDLE) &&
+
+               if ((FIELD_GET(dwVal, SYSTEM_CTRL, DE_STATUS) == SYSTEM_CTRL_DE_STATUS_IDLE) &&
                        (FIELD_GET(dwVal, SYSTEM_CTRL, DE_FIFO)  == SYSTEM_CTRL_DE_FIFO_EMPTY) &&
-                       (FIELD_GET(dwVal, SYSTEM_CTRL, DE_MEM_FIFO) == SYSTEM_CTRL_DE_MEM_FIFO_EMPTY))
-               {
+                       (FIELD_GET(dwVal, SYSTEM_CTRL, DE_MEM_FIFO) == SYSTEM_CTRL_DE_MEM_FIFO_EMPTY)) {
                        return 0;
                }
        }
@@ -612,28 +611,27 @@ int hw_sm750_deWait(void)
 }
 
 int hw_sm750_pan_display(struct lynxfb_crtc *crtc,
-        const struct fb_var_screeninfo *var,
-        const struct fb_info *info)
+       const struct fb_var_screeninfo *var,
+       const struct fb_info *info)
 {
-    uint32_t total;
-    /* check params */
-    if ((var->xoffset + var->xres > var->xres_virtual) ||
-            (var->yoffset + var->yres > var->yres_virtual)) {
-        return -EINVAL;
-    }
-
-    total = var->yoffset * info->fix.line_length +
-        ((var->xoffset * var->bits_per_pixel) >> 3);
-    total += crtc->oScreen;
-    if (crtc->channel == sm750_primary) {
-        POKE32(PANEL_FB_ADDRESS,
-                FIELD_VALUE(PEEK32(PANEL_FB_ADDRESS),
-                    PANEL_FB_ADDRESS, ADDRESS, total));
-    } else {
-        POKE32(CRT_FB_ADDRESS,
-                FIELD_VALUE(PEEK32(CRT_FB_ADDRESS),
-                    CRT_FB_ADDRESS, ADDRESS, total));
-    }
-    return 0;
-}
+       uint32_t total;
+       /* check params */
+       if ((var->xoffset + var->xres > var->xres_virtual) ||
+           (var->yoffset + var->yres > var->yres_virtual)) {
+               return -EINVAL;
+       }
 
+       total = var->yoffset * info->fix.line_length +
+               ((var->xoffset * var->bits_per_pixel) >> 3);
+       total += crtc->oScreen;
+       if (crtc->channel == sm750_primary) {
+               POKE32(PANEL_FB_ADDRESS,
+                       FIELD_VALUE(PEEK32(PANEL_FB_ADDRESS),
+                               PANEL_FB_ADDRESS, ADDRESS, total));
+       } else {
+               POKE32(CRT_FB_ADDRESS,
+                       FIELD_VALUE(PEEK32(CRT_FB_ADDRESS),
+                               CRT_FB_ADDRESS, ADDRESS, total));
+       }
+       return 0;
+}
index 93288b3..ef0a16f 100644 (file)
@@ -2,14 +2,14 @@
 #define LYNX_HW750_H__
 
 
-#define DEFAULT_SM750_CHIP_CLOCK               290
-#define DEFAULT_SM750LE_CHIP_CLOCK     333
+#define DEFAULT_SM750_CHIP_CLOCK       290
+#define DEFAULT_SM750LE_CHIP_CLOCK     333
 #ifndef SM750LE_REVISION_ID
 #define SM750LE_REVISION_ID (unsigned char)0xfe
 #endif
 
 
-enum sm750_pnltype{
+enum sm750_pnltype {
 
        sm750_24TFT = 0,/* 24bit tft */
 
@@ -19,30 +19,30 @@ enum sm750_pnltype{
 };
 
 /* vga channel is not concerned  */
-enum sm750_dataflow{
+enum sm750_dataflow {
        sm750_simul_pri,/* primary => all head */
 
        sm750_simul_sec,/* secondary => all head */
 
-       sm750_dual_normal,/*    primary => panel head and secondary => crt */
+       sm750_dual_normal,/* primary => panel head and secondary => crt */
 
-       sm750_dual_swap,/*      primary => crt head and secondary => panel */
+       sm750_dual_swap,/* primary => crt head and secondary => panel */
 };
 
 
-enum sm750_channel{
+enum sm750_channel {
        sm750_primary = 0,
        /* enum value equal to the register filed data */
        sm750_secondary = 1,
 };
 
-enum sm750_path{
+enum sm750_path {
        sm750_panel = 1,
        sm750_crt = 2,
        sm750_pnc = 3,/* panel and crt */
 };
 
-struct init_status{
+struct init_status {
        ushort powerMode;
        /* below three clocks are in unit of MHZ*/
        ushort chip_clk;
@@ -52,7 +52,7 @@ struct init_status{
        ushort resetMemory;
 };
 
-struct sm750_state{
+struct sm750_state {
        struct init_status initParm;
        enum sm750_pnltype pnltype;
        enum sm750_dataflow dataflow;
@@ -61,20 +61,20 @@ struct sm750_state{
        int yLCD;
 };
 
-/*     sm750_share stands for a presentation of two frame buffer
-       that use one sm750 adaptor, it is similar to the super class of lynx_share
-       in C++
-*/
+/* sm750_share stands for a presentation of two frame buffer
+   that use one sm750 adaptor, it is similar to the super class of lynx_share
+   in C++
+ */
 
-struct sm750_share{
+struct sm750_share {
        /* it's better to put lynx_share struct to the first place of sm750_share */
        struct lynx_share share;
        struct sm750_state state;
        int hwCursor;
-       /*      0: no hardware cursor
-               1: primary crtc hw cursor enabled,
-               2: secondary crtc hw cursor enabled
-               3: both ctrc hw cursor enabled
+       /* 0: no hardware cursor
+          1: primary crtc hw cursor enabled,
+          2: secondary crtc hw cursor enabled
+          3: both ctrc hw cursor enabled
        */
 };
 
@@ -95,7 +95,7 @@ int hw_sm750le_setBLANK(struct lynxfb_output*, int);
 void hw_sm750_crtc_clear(struct lynxfb_crtc*);
 void hw_sm750_output_clear(struct lynxfb_output*);
 int hw_sm750_pan_display(struct lynxfb_crtc *crtc,
-        const struct fb_var_screeninfo *var,
-        const struct fb_info *info);
+                        const struct fb_var_screeninfo *var,
+                        const struct fb_info *info);
 
 #endif
index 4bed094..aad1cc4 100644 (file)
@@ -13,8 +13,6 @@
  *  more details.
  */
 
-#define NR_PALETTE        256
-
 #define FB_ACCEL_SMI_LYNX 88
 
 #define SCREEN_X_RES      1024
 
 extern void __iomem *smtc_regbaseaddress;
 #define smtc_mmiowb(dat, reg)  writeb(dat, smtc_regbaseaddress + reg)
-#define smtc_mmioww(dat, reg)  writew(dat, smtc_regbaseaddress + reg)
-#define smtc_mmiowl(dat, reg)  writel(dat, smtc_regbaseaddress + reg)
 
 #define smtc_mmiorb(reg)       readb(smtc_regbaseaddress + reg)
-#define smtc_mmiorw(reg)       readw(smtc_regbaseaddress + reg)
-#define smtc_mmiorl(reg)       readl(smtc_regbaseaddress + reg)
 
 #define SIZE_SR00_SR04      (0x04 - 0x00 + 1)
 #define SIZE_SR10_SR24      (0x24 - 0x10 + 1)
@@ -48,8 +42,6 @@ extern void __iomem *smtc_regbaseaddress;
 #define SIZE_CR00_CR18      (0x18 - 0x00 + 1)
 #define SIZE_CR30_CR4D      (0x4D - 0x30 + 1)
 #define SIZE_CR90_CRA7      (0xA7 - 0x90 + 1)
-#define SIZE_VPR               (0x6C + 1)
-#define SIZE_DPR               (0x44 + 1)
 
 static inline void smtc_crtcw(int reg, int val)
 {
@@ -57,24 +49,12 @@ static inline void smtc_crtcw(int reg, int val)
        smtc_mmiowb(val, 0x3d5);
 }
 
-static inline unsigned int smtc_crtcr(int reg)
-{
-       smtc_mmiowb(reg, 0x3d4);
-       return smtc_mmiorb(0x3d5);
-}
-
 static inline void smtc_grphw(int reg, int val)
 {
        smtc_mmiowb(reg, 0x3ce);
        smtc_mmiowb(val, 0x3cf);
 }
 
-static inline unsigned int smtc_grphr(int reg)
-{
-       smtc_mmiowb(reg, 0x3ce);
-       return smtc_mmiorb(0x3cf);
-}
-
 static inline void smtc_attrw(int reg, int val)
 {
        smtc_mmiorb(0x3da);
@@ -115,3 +95,22 @@ struct modeinit {
        unsigned char init_cr30_cr4d[SIZE_CR30_CR4D];
        unsigned char init_cr90_cra7[SIZE_CR90_CRA7];
 };
+
+#ifdef __BIG_ENDIAN
+#define pal_rgb(r, g, b, val)  (((r & 0xf800) >> 8) | \
+                               ((g & 0xe000) >> 13) | \
+                               ((g & 0x1c00) << 3) | \
+                               ((b & 0xf800) >> 3))
+#define big_addr               0x800000
+#define mmio_addr              0x00800000
+#define seqw17()               smtc_seqw(0x17, 0x30)
+#define big_pixel_depth(p, d)  {if (p == 24) {p = 32; d = 32; } }
+#define big_swap(p)            ((p & 0xff00ff00 >> 8) | (p & 0x00ff00ff << 8))
+#else
+#define pal_rgb(r, g, b, val)  val
+#define big_addr               0
+#define mmio_addr              0x00c00000
+#define seqw17()               do { } while (0)
+#define big_pixel_depth(p, d)  do { } while (0)
+#define big_swap(p)            p
+#endif
index 2ff4fe7..07c2199 100644 (file)
@@ -923,25 +923,14 @@ static int smtc_setcolreg(unsigned regno, unsigned red, unsigned green,
                        val = chan_to_field(red, &sfb->fb->var.red);
                        val |= chan_to_field(green, &sfb->fb->var.green);
                        val |= chan_to_field(blue, &sfb->fb->var.blue);
-#ifdef __BIG_ENDIAN
-                       pal[regno] = ((red & 0xf800) >> 8) |
-                                    ((green & 0xe000) >> 13) |
-                                    ((green & 0x1c00) << 3) |
-                                    ((blue & 0xf800) >> 3);
-#else
-                       pal[regno] = val;
-#endif
+                       pal[regno] = pal_rgb(red, green, blue, val);
                } else {
                        u32 *pal = sfb->fb->pseudo_palette;
 
                        val = chan_to_field(red, &sfb->fb->var.red);
                        val |= chan_to_field(green, &sfb->fb->var.green);
                        val |= chan_to_field(blue, &sfb->fb->var.blue);
-#ifdef __BIG_ENDIAN
-                       val = (val & 0xff00ff00 >> 8) |
-                             (val & 0x00ff00ff << 8);
-#endif
-                       pal[regno] = val;
+                       pal[regno] = big_swap(val);
                }
                break;
 
@@ -957,7 +946,6 @@ static int smtc_setcolreg(unsigned regno, unsigned red, unsigned green,
        return 0;
 }
 
-#ifdef __BIG_ENDIAN
 static ssize_t smtcfb_read(struct fb_info *info, char __user *buf,
                           size_t count, loff_t *ppos)
 {
@@ -1002,8 +990,7 @@ static ssize_t smtcfb_read(struct fb_info *info, char __user *buf,
                dst = buffer;
                for (i = c >> 2; i--;) {
                        *dst = fb_readl(src++);
-                       *dst = (*dst & 0xff00ff00 >> 8) |
-                              (*dst & 0x00ff00ff << 8);
+                       *dst = big_swap(*dst);
                        dst++;
                }
                if (c & 3) {
@@ -1091,8 +1078,7 @@ static ssize_t smtcfb_write(struct fb_info *info, const char __user *buf,
                }
 
                for (i = c >> 2; i--;) {
-                       fb_writel((*src & 0xff00ff00 >> 8) |
-                                 (*src & 0x00ff00ff << 8), dst++);
+                       fb_writel(big_swap(*src), dst++);
                        src++;
                }
                if (c & 3) {
@@ -1120,7 +1106,6 @@ static ssize_t smtcfb_write(struct fb_info *info, const char __user *buf,
 
        return (cnt) ? cnt : err;
 }
-#endif /* ! __BIG_ENDIAN */
 
 static void sm7xx_set_timing(struct smtcfb_info *sfb)
 {
@@ -1316,10 +1301,8 @@ static struct fb_ops smtcfb_ops = {
        .fb_fillrect  = cfb_fillrect,
        .fb_imageblit = cfb_imageblit,
        .fb_copyarea  = cfb_copyarea,
-#ifdef __BIG_ENDIAN
        .fb_read      = smtcfb_read,
        .fb_write     = smtcfb_write,
-#endif
 };
 
 /*
@@ -1341,10 +1324,8 @@ static int smtc_map_smem(struct smtcfb_info *sfb,
 {
        sfb->fb->fix.smem_start = pci_resource_start(pdev, 0);
 
-#ifdef __BIG_ENDIAN
        if (sfb->fb->var.bits_per_pixel == 32)
-               sfb->fb->fix.smem_start += 0x800000;
-#endif
+               sfb->fb->fix.smem_start += big_addr;
 
        sfb->fb->fix.smem_len = smem_len;
 
@@ -1437,10 +1418,7 @@ static int smtcfb_pci_probe(struct pci_dev *pdev,
                sfb->fb->var.bits_per_pixel = SCREEN_BPP;
        }
 
-#ifdef __BIG_ENDIAN
-       if (sfb->fb->var.bits_per_pixel == 24)
-               sfb->fb->var.bits_per_pixel = (smtc_scr_info.lfb_depth = 32);
-#endif
+       big_pixel_depth(sfb->fb->var.bits_per_pixel, smtc_scr_info.lfb_depth);
        /* Map address and memory detection */
        mmio_base = pci_resource_start(pdev, 0);
        pci_read_config_byte(pdev, PCI_REVISION_ID, &sfb->chip_rev_id);
@@ -1451,28 +1429,23 @@ static int smtcfb_pci_probe(struct pci_dev *pdev,
                sfb->fb->fix.mmio_start = mmio_base + 0x00400000;
                sfb->fb->fix.mmio_len = 0x00400000;
                smem_size = SM712_VIDEOMEMORYSIZE;
-#ifdef __BIG_ENDIAN
-               sfb->lfb = ioremap(mmio_base, 0x00c00000);
-#else
-               sfb->lfb = ioremap(mmio_base, 0x00800000);
-#endif
+               sfb->lfb = ioremap(mmio_base, mmio_addr);
+               if (!sfb->lfb) {
+                       dev_err(&pdev->dev,
+                               "%s: unable to map memory mapped IO!\n",
+                               sfb->fb->fix.id);
+                       err = -ENOMEM;
+                       goto failed_fb;
+               }
+
                sfb->mmio = (smtc_regbaseaddress =
                    sfb->lfb + 0x00700000);
                sfb->dp_regs = sfb->lfb + 0x00408000;
                sfb->vp_regs = sfb->lfb + 0x0040c000;
-#ifdef __BIG_ENDIAN
                if (sfb->fb->var.bits_per_pixel == 32) {
-                       sfb->lfb += 0x800000;
+                       sfb->lfb += big_addr;
                        dev_info(&pdev->dev, "sfb->lfb=%p\n", sfb->lfb);
                }
-#endif
-               if (!smtc_regbaseaddress) {
-                       dev_err(&pdev->dev,
-                               "%s: unable to map memory mapped IO!\n",
-                               sfb->fb->fix.id);
-                       err = -ENOMEM;
-                       goto failed_fb;
-               }
 
                /* set MCLK = 14.31818 * (0x16 / 0x2) */
                smtc_seqw(0x6a, 0x16);
@@ -1481,10 +1454,8 @@ static int smtcfb_pci_probe(struct pci_dev *pdev,
                /* enable PCI burst */
                smtc_seqw(0x17, 0x20);
                /* enable word swap */
-#ifdef __BIG_ENDIAN
                if (sfb->fb->var.bits_per_pixel == 32)
-                       smtc_seqw(0x17, 0x30);
-#endif
+                       seqw17();
                break;
        case 0x720:
                sfb->fb->fix.mmio_start = mmio_base;
@@ -1616,10 +1587,8 @@ static int smtcfb_pci_resume(struct device *device)
                smtc_seqw(0x62, 0x3e);
                /* enable PCI burst */
                smtc_seqw(0x17, 0x20);
-#ifdef __BIG_ENDIAN
                if (sfb->fb->var.bits_per_pixel == 32)
-                       smtc_seqw(0x17, 0x30);
-#endif
+                       seqw17();
                break;
        case 0x720:
                smtc_seqw(0x62, 0xff);
@@ -1659,14 +1628,12 @@ static struct pci_driver smtcfb_driver = {
 
 static int __init sm712fb_init(void)
 {
-#ifndef MODULE
        char *option = NULL;
 
        if (fb_get_options("sm712fb", &option))
                return -ENODEV;
        if (option && *option)
                mode_option = option;
-#endif
        sm7xx_vga_setup(mode_option);
 
        return pci_register_driver(&smtcfb_driver);
index 9475674..02d5c70 100644 (file)
@@ -165,7 +165,7 @@ int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key)
                        synth_printf("\n");
                        return 1;
                }
-       cur_item = letter_offsets[ch-'a'];
+               cur_item = letter_offsets[ch-'a'];
        } else if (type == KT_CUR) {
                if (ch == 0
                    && (MSG_FUNCNAMES_START + cur_item + 1) <=
index 0f524bb..1f9ba8b 100644 (file)
@@ -1126,7 +1126,6 @@ MODULE_DEVICE_TABLE(i2c, synaptics_rmi4_id_table);
 static struct i2c_driver synaptics_rmi4_driver = {
        .driver = {
                .name   =       DRIVER_NAME,
-               .owner  =       THIS_MODULE,
                .pm     =       &synaptics_rmi4_dev_pm_ops,
        },
        .probe          =       synaptics_rmi4_probe,
index 778f9d0..624abe6 100644 (file)
@@ -3,7 +3,7 @@
 #
 menuconfig UNISYSSPAR
        bool "Unisys SPAR driver support"
-       depends on X86_64
+       depends on X86_64 && !UML
        select PCI
        select ACPI
        ---help---
index e4a21e4..a0144c6 100644 (file)
@@ -113,7 +113,8 @@ struct visor_driver {
        struct driver_attribute version_attr;
 };
 
-#define to_visor_driver(x) container_of(x, struct visor_driver, driver)
+#define to_visor_driver(x) ((x) ? \
+       (container_of(x, struct visor_driver, driver)) : (NULL))
 
 /** A device type for things "plugged" into the visorbus bus */
 
index a50d9cf..ec25366 100644 (file)
@@ -1,10 +1,9 @@
-/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
+/* Copyright (C) 2010 - 2015 UNISYS CORPORATION
  * All rights reserved.
  *
- * 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.
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
index f74f5d8..3c97eba 100644 (file)
@@ -1,12 +1,11 @@
 /* controlvmcompletionstatus.c
  *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2015 UNISYS CORPORATION
  * All Rights Reserved.
  *
- * 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.
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
index 57dd93e..b08b6ec 100644 (file)
@@ -1,10 +1,9 @@
-/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
+/* Copyright (C) 2010 - 2015 UNISYS CORPORATION
  * All rights reserved.
  *
- * 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.
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
index 5e56088..a3631c3 100644 (file)
@@ -1,12 +1,11 @@
 /* periodic_work.c
  *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2015 UNISYS CORPORATION
  * All rights reserved.
  *
- * 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.
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
index 5ed83a3..80e6447 100644 (file)
@@ -1,10 +1,9 @@
-/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
+/* Copyright (C) 2010 - 2015 UNISYS CORPORATION
  * All rights reserved.
  *
- * 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.
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
index 9b6d3e6..f59fd8a 100644 (file)
@@ -1,10 +1,9 @@
-/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
+/* Copyright (C) 2010 - 2015 UNISYS CORPORATION
  * All rights reserved.
  *
- * 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.
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
index 6db4719..403c13b 100644 (file)
@@ -1,12 +1,11 @@
 /* visorbus_main.c
  *
- * Copyright ï¿½ 2010 - 2013 UNISYS CORPORATION
+ * Copyright ï¿½ 2010 - 2015 UNISYS CORPORATION
  * All rights reserved.
  *
- * 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.
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -218,9 +217,9 @@ visorbus_release_device(struct device *xdev)
 struct devmajorminor_attribute {
        struct attribute attr;
        int slot;
-        ssize_t (*show)(struct visor_device *, int slot, char *buf);
-        ssize_t (*store)(struct visor_device *, int slot, const char *buf,
-                         size_t count);
+       ssize_t (*show)(struct visor_device *, int slot, char *buf);
+       ssize_t (*store)(struct visor_device *, int slot, const char *buf,
+                        size_t count);
 };
 
 static ssize_t DEVMAJORMINOR_ATTR(struct visor_device *dev, int slot, char *buf)
@@ -281,12 +280,11 @@ devmajorminor_create_file(struct visor_device *dev, const char *name,
                rc = -ENOMEM;
                goto away;
        }
-       myattr = kmalloc(sizeof(*myattr), GFP_KERNEL);
+       myattr = kzalloc(sizeof(*myattr), GFP_KERNEL);
        if (!myattr) {
                rc = -ENOMEM;
                goto away;
        }
-       memset(myattr, 0, sizeof(struct devmajorminor_attribute));
        myattr->show = DEVMAJORMINOR_ATTR;
        myattr->store = NULL;
        myattr->slot = slot;
@@ -471,6 +469,7 @@ static struct attribute *channel_attrs[] = {
                &dev_attr_typeguid.attr,
                &dev_attr_zoneguid.attr,
                &dev_attr_typename.attr,
+               NULL
 };
 
 static struct attribute_group channel_attr_grp = {
@@ -1043,10 +1042,10 @@ write_vbus_chp_info(struct visorchannel *chan,
        int off = sizeof(struct channel_header) + hdr_info->chp_info_offset;
 
        if (hdr_info->chp_info_offset == 0)
-                       return -1;
+               return -1;
 
        if (visorchannel_write(chan, off, info, sizeof(*info)) < 0)
-                       return -1;
+               return -1;
        return 0;
 }
 
@@ -1061,10 +1060,10 @@ write_vbus_bus_info(struct visorchannel *chan,
        int off = sizeof(struct channel_header) + hdr_info->bus_info_offset;
 
        if (hdr_info->bus_info_offset == 0)
-                       return -1;
+               return -1;
 
        if (visorchannel_write(chan, off, info, sizeof(*info)) < 0)
-                       return -1;
+               return -1;
        return 0;
 }
 
@@ -1081,10 +1080,10 @@ write_vbus_dev_info(struct visorchannel *chan,
            (hdr_info->device_info_struct_bytes * devix);
 
        if (hdr_info->dev_info_offset == 0)
-                       return -1;
+               return -1;
 
        if (visorchannel_write(chan, off, info, sizeof(*info)) < 0)
-                       return -1;
+               return -1;
        return 0;
 }
 
@@ -1106,7 +1105,7 @@ fix_vbus_dev_info(struct visor_device *visordev)
        struct spar_vbus_headerinfo *hdr_info;
 
        if (!visordev->device.driver)
-                       return;
+               return;
 
        hdr_info = (struct spar_vbus_headerinfo *)visordev->vbus_hdr_info;
        if (!hdr_info)
@@ -1319,11 +1318,11 @@ static void
 pause_state_change_complete(struct visor_device *dev, int status)
 {
        if (!dev->pausing)
-                       return;
+               return;
 
        dev->pausing = false;
        if (!chipset_responders.device_pause) /* this can never happen! */
-                       return;
+               return;
 
        /* Notify the chipset driver that the pause is complete, which
        * will presumably want to send some sort of response to the
@@ -1339,11 +1338,11 @@ static void
 resume_state_change_complete(struct visor_device *dev, int status)
 {
        if (!dev->resuming)
-                       return;
+               return;
 
        dev->resuming = false;
        if (!chipset_responders.device_resume) /* this can never happen! */
-                       return;
+               return;
 
        /* Notify the chipset driver that the resume is complete,
         * which will presumably want to send some sort of response to
@@ -1367,14 +1366,14 @@ initiate_chipset_device_pause_resume(struct visor_device *dev, bool is_pause)
        else
                notify_func = chipset_responders.device_resume;
        if (!notify_func)
-                       goto away;
+               goto away;
 
        drv = to_visor_driver(dev->device.driver);
        if (!drv)
-                       goto away;
+               goto away;
 
        if (dev->pausing || dev->resuming)
-                       goto away;
+               goto away;
 
        /* Note that even though both drv->pause() and drv->resume
         * specify a callback function, it is NOT necessary for us to
@@ -1385,7 +1384,7 @@ initiate_chipset_device_pause_resume(struct visor_device *dev, bool is_pause)
         */
        if (is_pause) {
                if (!drv->pause)
-                               goto away;
+                       goto away;
 
                dev->pausing = true;
                x = drv->pause(dev, pause_state_change_complete);
@@ -1397,7 +1396,7 @@ initiate_chipset_device_pause_resume(struct visor_device *dev, bool is_pause)
                 * would never even get here in that case. */
                fix_vbus_dev_info(dev);
                if (!drv->resume)
-                               goto away;
+                       goto away;
 
                dev->resuming = true;
                x = drv->resume(dev, resume_state_change_complete);
@@ -1413,7 +1412,7 @@ initiate_chipset_device_pause_resume(struct visor_device *dev, bool is_pause)
 away:
        if (rc < 0) {
                if (notify_func)
-                               (*notify_func)(dev, rc);
+                       (*notify_func)(dev, rc);
        }
 }
 
@@ -1469,8 +1468,8 @@ visorbus_init(void)
 
 away:
        if (rc)
-                       POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC, rc,
-                                        POSTCODE_SEVERITY_ERR);
+               POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC, rc,
+                                POSTCODE_SEVERITY_ERR);
        return rc;
 }
 
@@ -1495,9 +1494,8 @@ visorbus_exit(void)
 
        list_for_each_safe(listentry, listtmp, &list_all_bus_instances) {
                struct visor_device *dev = list_entry(listentry,
-                                                             struct
-                                                             visor_device,
-                                                             list_all);
+                                                     struct visor_device,
+                                                     list_all);
                remove_bus_instance(dev);
        }
        remove_bus_type();
index 2f12483..39edd20 100644 (file)
@@ -1,12 +1,11 @@
 /* visorchipset.h
  *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2015 UNISYS CORPORATION
  * All rights reserved.
  *
- * 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.
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
index 20b6349..2422464 100644 (file)
@@ -1,12 +1,11 @@
 /* visorchannel_funcs.c
  *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2015 UNISYS CORPORATION
  * All rights reserved.
  *
- * 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.
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -259,7 +258,8 @@ visorchannel_write(struct visorchannel *channel, ulong offset,
 
        if (offset < chdr_size) {
                copy_size = min(chdr_size - offset, nbytes);
-               memcpy(&channel->chan_hdr + offset, local, copy_size);
+               memcpy(((char *)(&channel->chan_hdr)) + offset,
+                      local, copy_size);
        }
 
        memcpy_toio(channel->mapped + offset, local, nbytes);
@@ -416,11 +416,12 @@ bool
 visorchannel_signalremove(struct visorchannel *channel, u32 queue, void *msg)
 {
        bool rc;
+       unsigned long flags;
 
        if (channel->needs_lock) {
-               spin_lock(&channel->remove_lock);
+               spin_lock_irqsave(&channel->remove_lock, flags);
                rc = signalremove_inner(channel, queue, msg);
-               spin_unlock(&channel->remove_lock);
+               spin_unlock_irqrestore(&channel->remove_lock, flags);
        } else {
                rc = signalremove_inner(channel, queue, msg);
        }
@@ -470,11 +471,12 @@ bool
 visorchannel_signalinsert(struct visorchannel *channel, u32 queue, void *msg)
 {
        bool rc;
+       unsigned long flags;
 
        if (channel->needs_lock) {
-               spin_lock(&channel->insert_lock);
+               spin_lock_irqsave(&channel->insert_lock, flags);
                rc = signalinsert_inner(channel, queue, msg);
-               spin_unlock(&channel->insert_lock);
+               spin_unlock_irqrestore(&channel->insert_lock, flags);
        } else {
                rc = signalinsert_inner(channel, queue, msg);
        }
index bb8087e..4b76cb4 100644 (file)
@@ -1,12 +1,11 @@
 /* visorchipset_main.c
  *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * Copyright (C) 2010 - 2015 UNISYS CORPORATION
  * All rights reserved.
  *
- * 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.
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -1247,10 +1246,11 @@ my_device_create(struct controlvm_message *inmsg)
        POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, dev_no, bus_no,
                         POSTCODE_SEVERITY_INFO);
 
-       visorchannel = visorchannel_create(cmd->create_device.channel_addr,
-                                          cmd->create_device.channel_bytes,
-                                          GFP_KERNEL,
-                                          cmd->create_device.data_type_uuid);
+       visorchannel =
+              visorchannel_create_with_lock(cmd->create_device.channel_addr,
+                                            cmd->create_device.channel_bytes,
+                                            GFP_KERNEL,
+                                            cmd->create_device.data_type_uuid);
 
        if (!visorchannel) {
                POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
@@ -2047,6 +2047,7 @@ device_create_response(struct visor_device *dev_info, int response)
                         response);
 
        kfree(dev_info->pending_msg_hdr);
+       dev_info->pending_msg_hdr = NULL;
 }
 
 static void
@@ -2381,6 +2382,9 @@ static struct acpi_driver unisys_acpi_driver = {
                .remove = visorchipset_exit,
                },
 };
+
+MODULE_DEVICE_TABLE(acpi, unisys_device_ids);
+
 static __init uint32_t visorutil_spar_detect(void)
 {
        unsigned int eax, ebx, ecx, edx;
index 7a53df0..7abd27a 100644 (file)
@@ -1,10 +1,9 @@
-/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
+/* Copyright (C) 2010 - 2015 UNISYS CORPORATION
  * All rights reserved.
  *
- * 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.
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
index 7100744..c28a347 100644 (file)
@@ -1,10 +1,9 @@
 /* Copyright (c) 2012 - 2015 UNISYS CORPORATION
  * All rights reserved.
  *
- * 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.
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -119,7 +118,6 @@ struct visornic_devdata {
        struct visor_device *dev;
        char name[99];
        struct list_head list_all;   /* < link within list_all_devices list */
-       struct kref kref;
        struct net_device *netdev;
        struct net_device_stats net_stats;
        atomic_t interrupt_rcvd;
@@ -151,6 +149,7 @@ struct visornic_devdata {
                                          * sent to the IOPART end
                                          */
        struct work_struct serverdown_completion;
+       visorbus_state_complete_func server_down_complete_func;
        struct work_struct timeout_reset;
        struct uiscmdrsp *cmdrsp_rcv;    /* cmdrsp_rcv is used for
                                          * posting/unposting rcv buffers
@@ -161,6 +160,7 @@ struct visornic_devdata {
                                          */
        bool server_down;                /* IOPART is down */
        bool server_change_state;        /* Processing SERVER_CHANGESTATE msg */
+       bool going_away;                 /* device is being torn down */
        struct dentry *eth_debugfs_dir;
        struct visor_thread_info threadinfo;
        u64 interrupts_rcvd;
@@ -298,6 +298,8 @@ static int visor_thread_start(struct visor_thread_info *thrinfo,
        init_completion(&thrinfo->has_stopped);
        thrinfo->task = kthread_run(threadfn, thrcontext, name);
        if (IS_ERR(thrinfo->task)) {
+               pr_debug("%s failed (%ld)\n",
+                        __func__, PTR_ERR(thrinfo->task));
                thrinfo->id = 0;
                return -EINVAL;
        }
@@ -545,8 +547,12 @@ visornic_serverdown_complete(struct work_struct *work)
        atomic_set(&devdata->num_rcvbuf_in_iovm, 0);
        spin_unlock_irqrestore(&devdata->priv_lock, flags);
 
+       if (devdata->server_down_complete_func)
+               (*devdata->server_down_complete_func)(devdata->dev, 0);
+
        devdata->server_down = true;
        devdata->server_change_state = false;
+       devdata->server_down_complete_func = NULL;
 }
 
 /**
@@ -558,15 +564,31 @@ visornic_serverdown_complete(struct work_struct *work)
  *     Returns 0 if we scheduled the work, -EINVAL on error.
  */
 static int
-visornic_serverdown(struct visornic_devdata *devdata)
+visornic_serverdown(struct visornic_devdata *devdata,
+                   visorbus_state_complete_func complete_func)
 {
+       unsigned long flags;
+
+       spin_lock_irqsave(&devdata->priv_lock, flags);
        if (!devdata->server_down && !devdata->server_change_state) {
+               if (devdata->going_away) {
+                       spin_unlock_irqrestore(&devdata->priv_lock, flags);
+                       dev_dbg(&devdata->dev->device,
+                               "%s aborting because device removal pending\n",
+                               __func__);
+                       return -ENODEV;
+               }
                devdata->server_change_state = true;
+               devdata->server_down_complete_func = complete_func;
                queue_work(visornic_serverdown_workqueue,
                           &devdata->serverdown_completion);
        } else if (devdata->server_change_state) {
+               dev_dbg(&devdata->dev->device, "%s changing state\n",
+                       __func__);
+               spin_unlock_irqrestore(&devdata->priv_lock, flags);
                return -EINVAL;
        }
+       spin_unlock_irqrestore(&devdata->priv_lock, flags);
        return 0;
 }
 
@@ -701,6 +723,8 @@ visornic_disable_with_timeout(struct net_device *netdev, const int timeout)
                        break;
                if (devdata->server_down || devdata->server_change_state) {
                        spin_unlock_irqrestore(&devdata->priv_lock, flags);
+                       dev_dbg(&netdev->dev, "%s server went away\n",
+                               __func__);
                        return -EIO;
                }
                set_current_state(TASK_INTERRUPTIBLE);
@@ -814,8 +838,11 @@ visornic_enable_with_timeout(struct net_device *netdev, const int timeout)
         * gets a disable.
         */
        i = init_rcv_bufs(netdev, devdata);
-       if (i < 0)
+       if (i < 0) {
+               dev_err(&netdev->dev,
+                       "%s failed to init rcv bufs (%d)\n", __func__, i);
                return i;
+       }
 
        spin_lock_irqsave(&devdata->priv_lock, flags);
        devdata->enabled = 1;
@@ -838,6 +865,8 @@ visornic_enable_with_timeout(struct net_device *netdev, const int timeout)
                        break;
                if (devdata->server_down || devdata->server_change_state) {
                        spin_unlock_irqrestore(&devdata->priv_lock, flags);
+                       dev_dbg(&netdev->dev, "%s server went away\n",
+                               __func__);
                        return -EIO;
                }
                set_current_state(TASK_INTERRUPTIBLE);
@@ -848,8 +877,10 @@ visornic_enable_with_timeout(struct net_device *netdev, const int timeout)
 
        spin_unlock_irqrestore(&devdata->priv_lock, flags);
 
-       if (!devdata->enab_dis_acked)
+       if (!devdata->enab_dis_acked) {
+               dev_err(&netdev->dev, "%s missing ACK\n", __func__);
                return -EIO;
+       }
 
        /* find an open slot in the array to save off VisorNic references
         * for debug
@@ -895,7 +926,7 @@ visornic_timeout_reset(struct work_struct *work)
        return;
 
 call_serverdown:
-       visornic_serverdown(devdata);
+       visornic_serverdown(devdata, NULL);
 }
 
 /**
@@ -961,6 +992,8 @@ visornic_xmit(struct sk_buff *skb, struct net_device *netdev)
            devdata->server_change_state) {
                spin_unlock_irqrestore(&devdata->priv_lock, flags);
                devdata->busy_cnt++;
+               dev_dbg(&netdev->dev,
+                       "%s busy - queue stopped\n", __func__);
                return NETDEV_TX_BUSY;
        }
 
@@ -979,6 +1012,9 @@ visornic_xmit(struct sk_buff *skb, struct net_device *netdev)
        if (firstfraglen < ETH_HEADER_SIZE) {
                spin_unlock_irqrestore(&devdata->priv_lock, flags);
                devdata->busy_cnt++;
+               dev_err(&netdev->dev,
+                       "%s busy - first frag too small (%d)\n",
+                       __func__, firstfraglen);
                return NETDEV_TX_BUSY;
        }
 
@@ -1018,6 +1054,9 @@ visornic_xmit(struct sk_buff *skb, struct net_device *netdev)
                netif_stop_queue(netdev);
                spin_unlock_irqrestore(&devdata->priv_lock, flags);
                devdata->busy_cnt++;
+               dev_dbg(&netdev->dev,
+                       "%s busy - waiting for iovm to catch up\n",
+                       __func__);
                return NETDEV_TX_BUSY;
        }
        if (devdata->queuefullmsg_logged)
@@ -1058,6 +1097,8 @@ visornic_xmit(struct sk_buff *skb, struct net_device *netdev)
        if (cmdrsp->net.xmt.num_frags == -1) {
                spin_unlock_irqrestore(&devdata->priv_lock, flags);
                devdata->busy_cnt++;
+               dev_err(&netdev->dev,
+                       "%s busy - copy frags failed\n", __func__);
                return NETDEV_TX_BUSY;
        }
 
@@ -1066,6 +1107,8 @@ visornic_xmit(struct sk_buff *skb, struct net_device *netdev)
                netif_stop_queue(netdev);
                spin_unlock_irqrestore(&devdata->priv_lock, flags);
                devdata->busy_cnt++;
+               dev_dbg(&netdev->dev,
+                       "%s busy - signalinsert failed\n", __func__);
                return NETDEV_TX_BUSY;
        }
 
@@ -1098,6 +1141,9 @@ visornic_xmit(struct sk_buff *skb, struct net_device *netdev)
                                           * netif_wake_queue() after lower
                                           * threshold
                                           */
+               dev_dbg(&netdev->dev,
+                       "%s busy - invoking iovm flow control\n",
+                       __func__);
                devdata->flow_control_upper_hits++;
        }
        spin_unlock_irqrestore(&devdata->priv_lock, flags);
@@ -1201,15 +1247,24 @@ visornic_xmit_timeout(struct net_device *netdev)
        unsigned long flags;
 
        spin_lock_irqsave(&devdata->priv_lock, flags);
+       if (devdata->going_away) {
+               spin_unlock_irqrestore(&devdata->priv_lock, flags);
+               dev_dbg(&devdata->dev->device,
+                       "%s aborting because device removal pending\n",
+                       __func__);
+               return;
+       }
+
        /* Ensure that a ServerDown message hasn't been received */
        if (!devdata->enabled ||
            (devdata->server_down && !devdata->server_change_state)) {
+               dev_dbg(&netdev->dev, "%s no processing\n",
+                       __func__);
                spin_unlock_irqrestore(&devdata->priv_lock, flags);
                return;
        }
-       spin_unlock_irqrestore(&devdata->priv_lock, flags);
-
        queue_work(visornic_timeout_reset_workqueue, &devdata->timeout_reset);
+       spin_unlock_irqrestore(&devdata->priv_lock, flags);
 }
 
 /**
@@ -1545,14 +1600,11 @@ devdata_initialize(struct visornic_devdata *devdata, struct visor_device *dev)
        spin_unlock(&dev_num_pool_lock);
        if (devnum == MAXDEVICES)
                devnum = -1;
-       if (devnum < 0) {
-               kfree(devdata);
+       if (devnum < 0)
                return NULL;
-       }
        devdata->devnum = devnum;
        devdata->dev = dev;
        strncpy(devdata->name, dev_name(&dev->device), sizeof(devdata->name));
-       kref_init(&devdata->kref);
        spin_lock(&lock_all_devices);
        list_add_tail(&devdata->list_all, &list_all_devices);
        spin_unlock(&lock_all_devices);
@@ -1560,24 +1612,23 @@ devdata_initialize(struct visornic_devdata *devdata, struct visor_device *dev)
 }
 
 /**
- *     devdata_release - Frees up a devdata
- *     @mykref: kref to the devdata
+ *     devdata_release - Frees up references in devdata
+ *     @devdata: struct to clean up
  *
- *     Frees up a devdata.
+ *     Frees up references in devdata.
  *     Returns void
  */
-static void devdata_release(struct kref *mykref)
+static void devdata_release(struct visornic_devdata *devdata)
 {
-       struct visornic_devdata *devdata =
-               container_of(mykref, struct visornic_devdata, kref);
-
        spin_lock(&dev_num_pool_lock);
        clear_bit(devdata->devnum, dev_num_pool);
        spin_unlock(&dev_num_pool_lock);
        spin_lock(&lock_all_devices);
        list_del(&devdata->list_all);
        spin_unlock(&lock_all_devices);
-       kfree(devdata);
+       kfree(devdata->rcvbuf);
+       kfree(devdata->cmdrsp_rcv);
+       kfree(devdata->xmit_cmdrsp);
 }
 
 static const struct net_device_ops visornic_dev_ops = {
@@ -1801,12 +1852,15 @@ static int visornic_probe(struct visor_device *dev)
        u64 features;
 
        netdev = alloc_etherdev(sizeof(struct visornic_devdata));
-       if (!netdev)
+       if (!netdev) {
+               dev_err(&dev->device,
+                       "%s alloc_etherdev failed\n", __func__);
                return -ENOMEM;
+       }
 
        netdev->netdev_ops = &visornic_dev_ops;
        netdev->watchdog_timeo = (5 * HZ);
-       netdev->dev.parent = &dev->device;
+       SET_NETDEV_DEV(netdev, &dev->device);
 
        /* Get MAC adddress from channel and read it into the device. */
        netdev->addr_len = ETH_ALEN;
@@ -1814,16 +1868,23 @@ static int visornic_probe(struct visor_device *dev)
                                  vnic.macaddr);
        err = visorbus_read_channel(dev, channel_offset, netdev->dev_addr,
                                    ETH_ALEN);
-       if (err < 0)
+       if (err < 0) {
+               dev_err(&dev->device,
+                       "%s failed to get mac addr from chan (%d)\n",
+                       __func__, err);
                goto cleanup_netdev;
+       }
 
        devdata = devdata_initialize(netdev_priv(netdev), dev);
        if (!devdata) {
+               dev_err(&dev->device,
+                       "%s devdata_initialize failed\n", __func__);
                err = -ENOMEM;
                goto cleanup_netdev;
        }
 
        devdata->netdev = netdev;
+       dev_set_drvdata(&dev->device, devdata);
        init_waitqueue_head(&devdata->rsp_queue);
        spin_lock_init(&devdata->priv_lock);
        devdata->enabled = 0; /* not yet */
@@ -1834,10 +1895,14 @@ static int visornic_probe(struct visor_device *dev)
                                  vnic.num_rcv_bufs);
        err = visorbus_read_channel(dev, channel_offset,
                                    &devdata->num_rcv_bufs, 4);
-       if (err)
+       if (err) {
+               dev_err(&dev->device,
+                       "%s failed to get #rcv bufs from chan (%d)\n",
+                       __func__, err);
                goto cleanup_netdev;
+       }
 
-       devdata->rcvbuf = kmalloc(sizeof(struct sk_buff *) *
+       devdata->rcvbuf = kzalloc(sizeof(struct sk_buff *) *
                                  devdata->num_rcv_bufs, GFP_KERNEL);
        if (!devdata->rcvbuf) {
                err = -ENOMEM;
@@ -1876,42 +1941,59 @@ static int visornic_probe(struct visor_device *dev)
        channel_offset = offsetof(struct spar_io_channel_protocol,
                                  vnic.mtu);
        err = visorbus_read_channel(dev, channel_offset, &netdev->mtu, 4);
-       if (err)
+       if (err) {
+               dev_err(&dev->device,
+                       "%s failed to get mtu from chan (%d)\n",
+                       __func__, err);
                goto cleanup_xmit_cmdrsp;
+       }
 
        /* TODO: Setup Interrupt information */
        /* Let's start our threads to get responses */
        channel_offset = offsetof(struct spar_io_channel_protocol,
                                  channel_header.features);
        err = visorbus_read_channel(dev, channel_offset, &features, 8);
-       if (err)
+       if (err) {
+               dev_err(&dev->device,
+                       "%s failed to get features from chan (%d)\n",
+                       __func__, err);
                goto cleanup_xmit_cmdrsp;
+       }
 
        features |= ULTRA_IO_CHANNEL_IS_POLLING;
        err = visorbus_write_channel(dev, channel_offset, &features, 8);
-       if (err)
+       if (err) {
+               dev_err(&dev->device,
+                       "%s failed to set features in chan (%d)\n",
+                       __func__, err);
                goto cleanup_xmit_cmdrsp;
-
-       devdata->thread_wait_ms = 2;
-       visor_thread_start(&devdata->threadinfo, process_incoming_rsps,
-                          devdata, "vnic_incoming");
+       }
 
        err = register_netdev(netdev);
-       if (err)
-               goto cleanup_thread_stop;
+       if (err) {
+               dev_err(&dev->device,
+                       "%s register_netdev failed (%d)\n", __func__, err);
+               goto cleanup_xmit_cmdrsp;
+       }
 
        /* create debgug/sysfs directories */
        devdata->eth_debugfs_dir = debugfs_create_dir(netdev->name,
                                                      visornic_debugfs_dir);
        if (!devdata->eth_debugfs_dir) {
+               dev_err(&dev->device,
+                       "%s debugfs_create_dir %s failed\n",
+                       __func__, netdev->name);
                err = -ENOMEM;
-               goto cleanup_thread_stop;
+               goto cleanup_xmit_cmdrsp;
        }
 
-       return 0;
+       devdata->thread_wait_ms = 2;
+       visor_thread_start(&devdata->threadinfo, process_incoming_rsps,
+                          devdata, "vnic_incoming");
 
-cleanup_thread_stop:
-       visor_thread_stop(&devdata->threadinfo);
+       dev_info(&dev->device, "%s success netdev=%s\n",
+                __func__, netdev->name);
+       return 0;
 
 cleanup_xmit_cmdrsp:
        kfree(devdata->xmit_cmdrsp);
@@ -1954,12 +2036,52 @@ static void host_side_disappeared(struct visornic_devdata *devdata)
 static void visornic_remove(struct visor_device *dev)
 {
        struct visornic_devdata *devdata = dev_get_drvdata(&dev->device);
+       struct net_device *netdev;
+       unsigned long flags;
 
-       if (!devdata)
+       if (!devdata) {
+               dev_err(&dev->device, "%s no devdata\n", __func__);
+               return;
+       }
+       spin_lock_irqsave(&devdata->priv_lock, flags);
+       if (devdata->going_away) {
+               spin_unlock_irqrestore(&devdata->priv_lock, flags);
+               dev_err(&dev->device, "%s already being removed\n", __func__);
+               return;
+       }
+       devdata->going_away = true;
+       spin_unlock_irqrestore(&devdata->priv_lock, flags);
+       netdev = devdata->netdev;
+       if (!netdev) {
+               dev_err(&dev->device, "%s not net device\n", __func__);
                return;
+       }
+
+       /* going_away prevents new items being added to the workqueues */
+       flush_workqueue(visornic_serverdown_workqueue);
+       flush_workqueue(visornic_timeout_reset_workqueue);
+
+       debugfs_remove_recursive(devdata->eth_debugfs_dir);
+
+       unregister_netdev(netdev);  /* this will call visornic_close() */
+
+       /* this had to wait until last because visornic_close() /
+        * visornic_disable_with_timeout() polls waiting for state that is
+        * only updated by the thread
+        */
+       if (devdata->threadinfo.id) {
+               visor_thread_stop(&devdata->threadinfo);
+               if (devdata->threadinfo.id) {
+                       dev_err(&dev->device, "%s cannot stop worker thread\n",
+                               __func__);
+                       return;
+               }
+       }
+
        dev_set_drvdata(&dev->device, NULL);
        host_side_disappeared(devdata);
-       kref_put(&devdata->kref, devdata_release);
+       devdata_release(devdata);
+       free_netdev(netdev);
 }
 
 /**
@@ -1980,8 +2102,7 @@ static int visornic_pause(struct visor_device *dev,
 {
        struct visornic_devdata *devdata = dev_get_drvdata(&dev->device);
 
-       visornic_serverdown(devdata);
-       complete_func(dev, 0);
+       visornic_serverdown(devdata, complete_func);
        return 0;
 }
 
@@ -2003,8 +2124,10 @@ static int visornic_resume(struct visor_device *dev,
        unsigned long flags;
 
        devdata = dev_get_drvdata(&dev->device);
-       if (!devdata)
+       if (!devdata) {
+               dev_err(&dev->device, "%s no devdata\n", __func__);
                return -EINVAL;
+       }
 
        netdev = devdata->netdev;
 
@@ -2032,6 +2155,8 @@ static int visornic_resume(struct visor_device *dev,
                 */
                send_enbdis(netdev, 1, devdata);
        } else if (devdata->server_change_state) {
+               dev_err(&dev->device, "%s server_change_state\n",
+                       __func__);
                return -EIO;
        }
 
@@ -2051,18 +2176,6 @@ static int visornic_init(void)
        struct dentry *ret;
        int err = -ENOMEM;
 
-       /* create workqueue for serverdown completion */
-       visornic_serverdown_workqueue =
-               create_singlethread_workqueue("visornic_serverdown");
-       if (!visornic_serverdown_workqueue)
-               return -ENOMEM;
-
-       /* create workqueue for tx timeout reset */
-       visornic_timeout_reset_workqueue =
-               create_singlethread_workqueue("visornic_timeout_reset");
-       if (!visornic_timeout_reset_workqueue)
-               return -ENOMEM;
-
        visornic_debugfs_dir = debugfs_create_dir("visornic", NULL);
        if (!visornic_debugfs_dir)
                return err;
@@ -2116,6 +2229,8 @@ cleanup_debugfs:
  */
 static void visornic_cleanup(void)
 {
+       visorbus_unregister_visor_driver(&visornic_driver);
+
        if (visornic_serverdown_workqueue) {
                flush_workqueue(visornic_serverdown_workqueue);
                destroy_workqueue(visornic_serverdown_workqueue);
@@ -2126,7 +2241,6 @@ static void visornic_cleanup(void)
        }
        debugfs_remove_recursive(visornic_debugfs_dir);
 
-       visorbus_unregister_visor_driver(&visornic_driver);
        kfree(dev_num_pool);
        dev_num_pool = NULL;
 }
index 9cca97a..b3e3c2d 100644 (file)
@@ -101,13 +101,13 @@ struct image_desc {
        struct vme_resource *resource;  /* VME resource */
        int mmap_count;         /* Number of current mmap's */
 };
+
 static struct image_desc image[VME_DEVS];
 
 static struct cdev *vme_user_cdev;             /* Character device */
 static struct class *vme_user_sysfs_class;     /* Sysfs class */
 static struct vme_dev *vme_user_bridge;                /* Pointer to user device */
 
-
 static const int type[VME_DEVS] = {    MASTER_MINOR,   MASTER_MINOR,
                                        MASTER_MINOR,   MASTER_MINOR,
                                        SLAVE_MINOR,    SLAVE_MINOR,
@@ -120,125 +120,68 @@ struct vme_user_vma_priv {
        atomic_t refcnt;
 };
 
-
-/*
- * We are going ot alloc a page during init per window for small transfers.
- * Small transfers will go VME -> buffer -> user space. Larger (more than a
- * page) transfers will lock the user space buffer into memory and then
- * transfer the data directly into the user space buffers.
- */
 static ssize_t resource_to_user(int minor, char __user *buf, size_t count,
-       loff_t *ppos)
+                               loff_t *ppos)
 {
-       ssize_t retval;
        ssize_t copied = 0;
 
-       if (count <= image[minor].size_buf) {
-               /* We copy to kernel buffer */
-               copied = vme_master_read(image[minor].resource,
-                       image[minor].kern_buf, count, *ppos);
-               if (copied < 0)
-                       return (int)copied;
-
-               retval = __copy_to_user(buf, image[minor].kern_buf,
-                       (unsigned long)copied);
-               if (retval != 0) {
-                       copied = (copied - retval);
-                       pr_info("User copy failed\n");
-                       return -EINVAL;
-               }
+       if (count > image[minor].size_buf)
+               count = image[minor].size_buf;
 
-       } else {
-               /* XXX Need to write this */
-               pr_info("Currently don't support large transfers\n");
-               /* Map in pages from userspace */
+       copied = vme_master_read(image[minor].resource, image[minor].kern_buf,
+                                count, *ppos);
+       if (copied < 0)
+               return (int)copied;
 
-               /* Call vme_master_read to do the transfer */
-               return -EINVAL;
-       }
+       if (__copy_to_user(buf, image[minor].kern_buf, (unsigned long)copied))
+               return -EFAULT;
 
        return copied;
 }
 
-/*
- * We are going to alloc a page during init per window for small transfers.
- * Small transfers will go user space -> buffer -> VME. Larger (more than a
- * page) transfers will lock the user space buffer into memory and then
- * transfer the data directly from the user space buffers out to VME.
- */
 static ssize_t resource_from_user(unsigned int minor, const char __user *buf,
-       size_t count, loff_t *ppos)
+                                 size_t count, loff_t *ppos)
 {
-       ssize_t retval;
-       ssize_t copied = 0;
+       if (count > image[minor].size_buf)
+               count = image[minor].size_buf;
 
-       if (count <= image[minor].size_buf) {
-               retval = __copy_from_user(image[minor].kern_buf, buf,
-                       (unsigned long)count);
-               if (retval != 0)
-                       copied = (copied - retval);
-               else
-                       copied = count;
-
-               copied = vme_master_write(image[minor].resource,
-                       image[minor].kern_buf, copied, *ppos);
-       } else {
-               /* XXX Need to write this */
-               pr_info("Currently don't support large transfers\n");
-               /* Map in pages from userspace */
-
-               /* Call vme_master_write to do the transfer */
-               return -EINVAL;
-       }
+       if (__copy_from_user(image[minor].kern_buf, buf, (unsigned long)count))
+               return -EFAULT;
 
-       return copied;
+       return vme_master_write(image[minor].resource, image[minor].kern_buf,
+                               count, *ppos);
 }
 
 static ssize_t buffer_to_user(unsigned int minor, char __user *buf,
-       size_t count, loff_t *ppos)
+                             size_t count, loff_t *ppos)
 {
        void *image_ptr;
-       ssize_t retval;
 
        image_ptr = image[minor].kern_buf + *ppos;
+       if (__copy_to_user(buf, image_ptr, (unsigned long)count))
+               return -EFAULT;
 
-       retval = __copy_to_user(buf, image_ptr, (unsigned long)count);
-       if (retval != 0) {
-               retval = (count - retval);
-               pr_warn("Partial copy to userspace\n");
-       } else
-               retval = count;
-
-       /* Return number of bytes successfully read */
-       return retval;
+       return count;
 }
 
 static ssize_t buffer_from_user(unsigned int minor, const char __user *buf,
-       size_t count, loff_t *ppos)
+                               size_t count, loff_t *ppos)
 {
        void *image_ptr;
-       size_t retval;
 
        image_ptr = image[minor].kern_buf + *ppos;
+       if (__copy_from_user(image_ptr, buf, (unsigned long)count))
+               return -EFAULT;
 
-       retval = __copy_from_user(image_ptr, buf, (unsigned long)count);
-       if (retval != 0) {
-               retval = (count - retval);
-               pr_warn("Partial copy to userspace\n");
-       } else
-               retval = count;
-
-       /* Return number of bytes successfully read */
-       return retval;
+       return count;
 }
 
 static ssize_t vme_user_read(struct file *file, char __user *buf, size_t count,
-                       loff_t *ppos)
+                            loff_t *ppos)
 {
        unsigned int minor = MINOR(file_inode(file)->i_rdev);
        ssize_t retval;
        size_t image_size;
-       size_t okcount;
 
        if (minor == CONTROL_MINOR)
                return 0;
@@ -256,16 +199,14 @@ static ssize_t vme_user_read(struct file *file, char __user *buf, size_t count,
 
        /* Ensure not reading past end of the image */
        if (*ppos + count > image_size)
-               okcount = image_size - *ppos;
-       else
-               okcount = count;
+               count = image_size - *ppos;
 
        switch (type[minor]) {
        case MASTER_MINOR:
-               retval = resource_to_user(minor, buf, okcount, ppos);
+               retval = resource_to_user(minor, buf, count, ppos);
                break;
        case SLAVE_MINOR:
-               retval = buffer_to_user(minor, buf, okcount, ppos);
+               retval = buffer_to_user(minor, buf, count, ppos);
                break;
        default:
                retval = -EINVAL;
@@ -279,12 +220,11 @@ static ssize_t vme_user_read(struct file *file, char __user *buf, size_t count,
 }
 
 static ssize_t vme_user_write(struct file *file, const char __user *buf,
-                       size_t count, loff_t *ppos)
+                             size_t count, loff_t *ppos)
 {
        unsigned int minor = MINOR(file_inode(file)->i_rdev);
        ssize_t retval;
        size_t image_size;
-       size_t okcount;
 
        if (minor == CONTROL_MINOR)
                return 0;
@@ -301,16 +241,14 @@ static ssize_t vme_user_write(struct file *file, const char __user *buf,
 
        /* Ensure not reading past end of the image */
        if (*ppos + count > image_size)
-               okcount = image_size - *ppos;
-       else
-               okcount = count;
+               count = image_size - *ppos;
 
        switch (type[minor]) {
        case MASTER_MINOR:
-               retval = resource_from_user(minor, buf, okcount, ppos);
+               retval = resource_from_user(minor, buf, count, ppos);
                break;
        case SLAVE_MINOR:
-               retval = buffer_from_user(minor, buf, okcount, ppos);
+               retval = buffer_from_user(minor, buf, count, ppos);
                break;
        default:
                retval = -EINVAL;
@@ -354,7 +292,7 @@ static loff_t vme_user_llseek(struct file *file, loff_t off, int whence)
  * already been defined.
  */
 static int vme_user_ioctl(struct inode *inode, struct file *file,
-       unsigned int cmd, unsigned long arg)
+                         unsigned int cmd, unsigned long arg)
 {
        struct vme_master master;
        struct vme_slave slave;
@@ -390,12 +328,13 @@ static int vme_user_ioctl(struct inode *inode, struct file *file,
                         *      to userspace as they are
                         */
                        retval = vme_master_get(image[minor].resource,
-                               &master.enable, &master.vme_addr,
-                               &master.size, &master.aspace,
-                               &master.cycle, &master.dwidth);
+                                               &master.enable,
+                                               &master.vme_addr,
+                                               &master.size, &master.aspace,
+                                               &master.cycle, &master.dwidth);
 
                        copied = copy_to_user(argp, &master,
-                               sizeof(struct vme_master));
+                                             sizeof(struct vme_master));
                        if (copied != 0) {
                                pr_warn("Partial copy to userspace\n");
                                return -EFAULT;
@@ -435,12 +374,12 @@ static int vme_user_ioctl(struct inode *inode, struct file *file,
                         *      to userspace as they are
                         */
                        retval = vme_slave_get(image[minor].resource,
-                               &slave.enable, &slave.vme_addr,
-                               &slave.size, &pci_addr, &slave.aspace,
-                               &slave.cycle);
+                                              &slave.enable, &slave.vme_addr,
+                                              &slave.size, &pci_addr,
+                                              &slave.aspace, &slave.cycle);
 
                        copied = copy_to_user(argp, &slave,
-                               sizeof(struct vme_slave));
+                                             sizeof(struct vme_slave));
                        if (copied != 0) {
                                pr_warn("Partial copy to userspace\n");
                                return -EFAULT;
@@ -526,8 +465,8 @@ static int vme_user_master_mmap(unsigned int minor, struct vm_area_struct *vma)
                return err;
        }
 
-       vma_priv = kmalloc(sizeof(struct vme_user_vma_priv), GFP_KERNEL);
-       if (vma_priv == NULL) {
+       vma_priv = kmalloc(sizeof(*vma_priv), GFP_KERNEL);
+       if (!vma_priv) {
                mutex_unlock(&image[minor].mutex);
                return -ENOMEM;
        }
@@ -588,7 +527,7 @@ static int vme_user_probe(struct vme_dev *vdev)
        char *name;
 
        /* Save pointer to the bridge device */
-       if (vme_user_bridge != NULL) {
+       if (vme_user_bridge) {
                dev_err(&vdev->dev, "Driver can only be loaded for 1 device\n");
                err = -EINVAL;
                goto err_dev;
@@ -606,7 +545,7 @@ static int vme_user_probe(struct vme_dev *vdev)
 
        /* Assign major and minor numbers for the driver */
        err = register_chrdev_region(MKDEV(VME_MAJOR, 0), VME_DEVS,
-               driver_name);
+                                    driver_name);
        if (err) {
                dev_warn(&vdev->dev, "Error getting Major Number %d for driver.\n",
                         VME_MAJOR);
@@ -636,7 +575,7 @@ static int vme_user_probe(struct vme_dev *vdev)
                 */
                image[i].resource = vme_slave_request(vme_user_bridge,
                        VME_A24, VME_SCT);
-               if (image[i].resource == NULL) {
+               if (!image[i].resource) {
                        dev_warn(&vdev->dev,
                                 "Unable to allocate slave resource\n");
                        err = -ENOMEM;
@@ -645,7 +584,7 @@ static int vme_user_probe(struct vme_dev *vdev)
                image[i].size_buf = PCI_BUF_SIZE;
                image[i].kern_buf = vme_alloc_consistent(image[i].resource,
                        image[i].size_buf, &image[i].pci_buf);
-               if (image[i].kern_buf == NULL) {
+               if (!image[i].kern_buf) {
                        dev_warn(&vdev->dev,
                                 "Unable to allocate memory for buffer\n");
                        image[i].pci_buf = 0;
@@ -663,7 +602,7 @@ static int vme_user_probe(struct vme_dev *vdev)
                /* XXX Need to properly request attributes */
                image[i].resource = vme_master_request(vme_user_bridge,
                        VME_A32, VME_SCT, VME_D32);
-               if (image[i].resource == NULL) {
+               if (!image[i].resource) {
                        dev_warn(&vdev->dev,
                                 "Unable to allocate master resource\n");
                        err = -ENOMEM;
@@ -671,7 +610,7 @@ static int vme_user_probe(struct vme_dev *vdev)
                }
                image[i].size_buf = PCI_BUF_SIZE;
                image[i].kern_buf = kmalloc(image[i].size_buf, GFP_KERNEL);
-               if (image[i].kern_buf == NULL) {
+               if (!image[i].kern_buf) {
                        err = -ENOMEM;
                        vme_master_free(image[i].resource);
                        goto err_master;
@@ -835,7 +774,6 @@ static void __exit vme_user_exit(void)
        vme_unregister_driver(&vme_user_driver);
 }
 
-
 MODULE_PARM_DESC(bus, "Enumeration of VMEbus to which the driver is connected");
 module_param_array(bus, int, &bus_num, 0);
 
index 5cf1b33..6aebb49 100644 (file)
@@ -403,6 +403,7 @@ struct vnt_private {
        unsigned char abyEEPROM[EEP_MAX_CONTEXT_SIZE]; /* unsigned long alignment */
 
        unsigned short wBeaconInterval;
+       u16 wake_up_count;
 
        struct work_struct interrupt_work;
 
index b0c8e23..23ad16e 100644 (file)
@@ -758,9 +758,7 @@ static void device_free_td0_ring(struct vnt_private *pDevice)
                        dma_unmap_single(&pDevice->pcid->dev, pTDInfo->skb_dma,
                                         pTDInfo->skb->len, DMA_TO_DEVICE);
 
-               if (pTDInfo->skb)
-                       dev_kfree_skb(pTDInfo->skb);
-
+               dev_kfree_skb(pTDInfo->skb);
                kfree(pDesc->pTDInfo);
        }
 }
@@ -777,9 +775,7 @@ static void device_free_td1_ring(struct vnt_private *pDevice)
                        dma_unmap_single(&pDevice->pcid->dev, pTDInfo->skb_dma,
                                         pTDInfo->skb->len, DMA_TO_DEVICE);
 
-               if (pTDInfo->skb)
-                       dev_kfree_skb(pTDInfo->skb);
-
+               dev_kfree_skb(pTDInfo->skb);
                kfree(pDesc->pTDInfo);
        }
 }
@@ -1211,9 +1207,6 @@ static int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb)
 
        vnt_generate_fifo_header(priv, dma_idx, head_td, skb);
 
-       if (MACbIsRegBitsOn(priv->PortOffset, MAC_REG_PSCTL, PSCTL_PS))
-               MACbPSWakeup(priv->PortOffset);
-
        spin_lock_irqsave(&priv->lock, flags);
 
        priv->bPWBitOn = false;
@@ -1811,6 +1804,7 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent)
        ieee80211_hw_set(priv->hw, SIGNAL_DBM);
        ieee80211_hw_set(priv->hw, RX_INCLUDES_FCS);
        ieee80211_hw_set(priv->hw, REPORTS_TX_ACK_STATUS);
+       ieee80211_hw_set(priv->hw, SUPPORTS_PS);
 
        priv->hw->max_signal = 100;
 
index be3c4e9..06e6b9d 100644 (file)
@@ -157,10 +157,18 @@ PSbIsNextTBTTWakeUp(
        struct ieee80211_conf *conf = &hw->conf;
        bool bWakeUp = false;
 
-       if (conf->listen_interval == 1) {
-               /* Turn on wake up to listen next beacon */
-               MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_LNBCN);
-               bWakeUp = true;
+       if (conf->listen_interval > 1) {
+               if (!pDevice->wake_up_count)
+                       pDevice->wake_up_count = conf->listen_interval;
+
+               --pDevice->wake_up_count;
+
+               if (pDevice->wake_up_count == 1) {
+                       /* Turn on wake up to listen next beacon */
+                       MACvRegBitsOn(pDevice->PortOffset,
+                                     MAC_REG_PSCTL, PSCTL_LNBCN);
+                       bWakeUp = true;
+               }
        }
 
        return bWakeUp;
index 7626f63..c537321 100644 (file)
 #include "rf.h"
 #include "baseband.h"
 
-#define BY_AL2230_REG_LEN     23 //24bit
+#define BY_AL2230_REG_LEN     23 /* 24bit */
 #define CB_AL2230_INIT_SEQ    15
-#define SWITCH_CHANNEL_DELAY_AL2230 200 //us
+#define SWITCH_CHANNEL_DELAY_AL2230 200 /* us */
 #define AL2230_PWR_IDX_LEN    64
 
-#define BY_AL7230_REG_LEN     23 //24bit
+#define BY_AL7230_REG_LEN     23 /* 24bit */
 #define CB_AL7230_INIT_SEQ    16
-#define SWITCH_CHANNEL_DELAY_AL7230 200 //us
+#define SWITCH_CHANNEL_DELAY_AL7230 200 /* us */
 #define AL7230_PWR_IDX_LEN    64
 
 static const unsigned long dwAL2230InitTable[CB_AL2230_INIT_SEQ] = {
-       0x03F79000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, //
-       0x03333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, //
-       0x01A00200+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, //
-       0x00FFF300+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, //
-       0x0005A400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, //
-       0x0F4DC500+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, //
-       0x0805B600+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, //
-       0x0146C700+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, //
-       0x00068800+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, //
-       0x0403B900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, //
-       0x00DBBA00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, //
-       0x00099B00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, //
+       0x03F79000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+       0x03333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+       0x01A00200+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+       0x00FFF300+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+       0x0005A400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+       0x0F4DC500+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+       0x0805B600+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+       0x0146C700+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+       0x00068800+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+       0x0403B900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+       0x00DBBA00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
+       0x00099B00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
        0x0BDFFC00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
        0x00000D00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
        0x00580F00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW
 };
 
 static const unsigned long dwAL2230ChannelTable0[CB_MAX_CHANNEL] = {
-       0x03F79000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 1, Tf = 2412MHz
-       0x03F79000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 2, Tf = 2417MHz
-       0x03E79000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 3, Tf = 2422MHz
-       0x03E79000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 4, Tf = 2427MHz
-       0x03F7A000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 5, Tf = 2432MHz
-       0x03F7A000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 6, Tf = 2437MHz
-       0x03E7A000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 7, Tf = 2442MHz
-       0x03E7A000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 8, Tf = 2447MHz
-       0x03F7B000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 9, Tf = 2452MHz
-       0x03F7B000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 10, Tf = 2457MHz
-       0x03E7B000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 11, Tf = 2462MHz
-       0x03E7B000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 12, Tf = 2467MHz
-       0x03F7C000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 13, Tf = 2472MHz
-       0x03E7C000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW  // channel = 14, Tf = 2412M
+       0x03F79000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 1, Tf = 2412MHz */
+       0x03F79000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 2, Tf = 2417MHz */
+       0x03E79000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 3, Tf = 2422MHz */
+       0x03E79000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 4, Tf = 2427MHz */
+       0x03F7A000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 5, Tf = 2432MHz */
+       0x03F7A000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 6, Tf = 2437MHz */
+       0x03E7A000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 7, Tf = 2442MHz */
+       0x03E7A000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 8, Tf = 2447MHz */
+       0x03F7B000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 9, Tf = 2452MHz */
+       0x03F7B000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 10, Tf = 2457MHz */
+       0x03E7B000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 11, Tf = 2462MHz */
+       0x03E7B000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 12, Tf = 2467MHz */
+       0x03F7C000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 13, Tf = 2472MHz */
+       0x03E7C000+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW  /* channel = 14, Tf = 2412M */
 };
 
 static const unsigned long dwAL2230ChannelTable1[CB_MAX_CHANNEL] = {
-       0x03333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 1, Tf = 2412MHz
-       0x0B333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 2, Tf = 2417MHz
-       0x03333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 3, Tf = 2422MHz
-       0x0B333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 4, Tf = 2427MHz
-       0x03333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 5, Tf = 2432MHz
-       0x0B333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 6, Tf = 2437MHz
-       0x03333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 7, Tf = 2442MHz
-       0x0B333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 8, Tf = 2447MHz
-       0x03333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 9, Tf = 2452MHz
-       0x0B333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 10, Tf = 2457MHz
-       0x03333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 11, Tf = 2462MHz
-       0x0B333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 12, Tf = 2467MHz
-       0x03333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 13, Tf = 2472MHz
-       0x06666100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW  // channel = 14, Tf = 2412M
+       0x03333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 1, Tf = 2412MHz */
+       0x0B333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 2, Tf = 2417MHz */
+       0x03333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 3, Tf = 2422MHz */
+       0x0B333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 4, Tf = 2427MHz */
+       0x03333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 5, Tf = 2432MHz */
+       0x0B333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 6, Tf = 2437MHz */
+       0x03333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 7, Tf = 2442MHz */
+       0x0B333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 8, Tf = 2447MHz */
+       0x03333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 9, Tf = 2452MHz */
+       0x0B333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 10, Tf = 2457MHz */
+       0x03333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 11, Tf = 2462MHz */
+       0x0B333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 12, Tf = 2467MHz */
+       0x03333100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 13, Tf = 2472MHz */
+       0x06666100+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW  /* channel = 14, Tf = 2412M */
 };
 
 static unsigned long dwAL2230PowerTable[AL2230_PWR_IDX_LEN] = {
@@ -168,240 +168,240 @@ static unsigned long dwAL2230PowerTable[AL2230_PWR_IDX_LEN] = {
        0x0407F900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW
 };
 
-// 40MHz reference frequency
-// Need to Pull PLLON(PE3) low when writing channel registers through 3-wire.
+/* 40MHz reference frequency
+ * Need to Pull PLLON(PE3) low when writing channel registers through 3-wire.*/
 static const unsigned long dwAL7230InitTable[CB_AL7230_INIT_SEQ] = {
-       0x00379000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Channel1 // Need modify for 11a
-       0x13333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Channel1 // Need modify for 11a
-       0x841FF200+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11a: 451FE2
-       0x3FDFA300+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11a: 5FDFA3
-       0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // 11b/g    // Need modify for 11a
-       // RoberYu:20050113, Rev0.47 Regsiter Setting Guide
-       0x802B5500+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11a: 8D1B55
+       0x00379000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* Channel1 // Need modify for 11a */
+       0x13333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* Channel1 // Need modify for 11a */
+       0x841FF200+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* Need modify for 11a: 451FE2 */
+       0x3FDFA300+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* Need modify for 11a: 5FDFA3 */
+       0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* 11b/g    // Need modify for 11a */
+       /* RoberYu:20050113, Rev0.47 Regsiter Setting Guide */
+       0x802B5500+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* Need modify for 11a: 8D1B55 */
        0x56AF3600+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW,
-       0xCE020700+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11a: 860207
+       0xCE020700+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* Need modify for 11a: 860207 */
        0x6EBC0800+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW,
        0x221BB900+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW,
-       0xE0000A00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11a: E0600A
-       0x08031B00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // init 0x080B1B00 => 0x080F1B00 for 3 wire control TxGain(D10)
-       // RoberYu:20050113, Rev0.47 Regsiter Setting Guide
-       0x000A3C00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11a: 00143C
+       0xE0000A00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* Need modify for 11a: E0600A */
+       0x08031B00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* init 0x080B1B00 => 0x080F1B00 for 3 wire control TxGain(D10) */
+       /* RoberYu:20050113, Rev0.47 Regsiter Setting Guide */
+       0x000A3C00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* Need modify for 11a: 00143C */
        0xFFFFFD00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW,
        0x00000E00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW,
-       0x1ABA8F00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW  // Need modify for 11a: 12BACF
+       0x1ABA8F00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW  /* Need modify for 11a: 12BACF */
 };
 
 static const unsigned long dwAL7230InitTableAMode[CB_AL7230_INIT_SEQ] = {
-       0x0FF52000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Channel184 // Need modify for 11b/g
-       0x00000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Channel184 // Need modify for 11b/g
-       0x451FE200+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11b/g
-       0x5FDFA300+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11b/g
-       0x67F78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // 11a    // Need modify for 11b/g
-       0x853F5500+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11b/g, RoberYu:20050113
+       0x0FF52000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* Channel184 // Need modify for 11b/g */
+       0x00000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* Channel184 // Need modify for 11b/g */
+       0x451FE200+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* Need modify for 11b/g */
+       0x5FDFA300+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* Need modify for 11b/g */
+       0x67F78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* 11a    // Need modify for 11b/g */
+       0x853F5500+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* Need modify for 11b/g, RoberYu:20050113 */
        0x56AF3600+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW,
-       0xCE020700+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11b/g
+       0xCE020700+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* Need modify for 11b/g */
        0x6EBC0800+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW,
        0x221BB900+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW,
-       0xE0600A00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11b/g
-       0x08031B00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // init 0x080B1B00 => 0x080F1B00 for 3 wire control TxGain(D10)
-       0x00147C00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11b/g
+       0xE0600A00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* Need modify for 11b/g */
+       0x08031B00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* init 0x080B1B00 => 0x080F1B00 for 3 wire control TxGain(D10) */
+       0x00147C00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* Need modify for 11b/g */
        0xFFFFFD00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW,
        0x00000E00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW,
-       0x12BACF00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW  // Need modify for 11b/g
+       0x12BACF00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW  /* Need modify for 11b/g */
 };
 
 static const unsigned long dwAL7230ChannelTable0[CB_MAX_CHANNEL] = {
-       0x00379000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  1, Tf = 2412MHz
-       0x00379000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  2, Tf = 2417MHz
-       0x00379000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  3, Tf = 2422MHz
-       0x00379000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  4, Tf = 2427MHz
-       0x0037A000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  5, Tf = 2432MHz
-       0x0037A000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  6, Tf = 2437MHz
-       0x0037A000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  7, Tf = 2442MHz
-       0x0037A000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  8, Tf = 2447MHz //RobertYu: 20050218, update for APNode 0.49
-       0x0037B000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  9, Tf = 2452MHz //RobertYu: 20050218, update for APNode 0.49
-       0x0037B000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 10, Tf = 2457MHz //RobertYu: 20050218, update for APNode 0.49
-       0x0037B000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 11, Tf = 2462MHz //RobertYu: 20050218, update for APNode 0.49
-       0x0037B000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 12, Tf = 2467MHz //RobertYu: 20050218, update for APNode 0.49
-       0x0037C000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 13, Tf = 2472MHz //RobertYu: 20050218, update for APNode 0.49
-       0x0037C000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 14, Tf = 2484MHz
-
-       // 4.9G => Ch 183, 184, 185, 187, 188, 189, 192, 196  (Value:15 ~ 22)
-       0x0FF52000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 183, Tf = 4915MHz (15)
-       0x0FF52000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 184, Tf = 4920MHz (16)
-       0x0FF52000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 185, Tf = 4925MHz (17)
-       0x0FF52000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 187, Tf = 4935MHz (18)
-       0x0FF52000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 188, Tf = 4940MHz (19)
-       0x0FF52000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 189, Tf = 4945MHz (20)
-       0x0FF53000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 192, Tf = 4960MHz (21)
-       0x0FF53000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 196, Tf = 4980MHz (22)
-
-       // 5G => Ch 7, 8, 9, 11, 12, 16, 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64,
-       // 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165  (Value 23 ~ 56)
-
-       0x0FF54000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =   7, Tf = 5035MHz (23)
-       0x0FF54000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =   8, Tf = 5040MHz (24)
-       0x0FF54000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =   9, Tf = 5045MHz (25)
-       0x0FF54000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  11, Tf = 5055MHz (26)
-       0x0FF54000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  12, Tf = 5060MHz (27)
-       0x0FF55000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  16, Tf = 5080MHz (28)
-       0x0FF56000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  34, Tf = 5170MHz (29)
-       0x0FF56000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  36, Tf = 5180MHz (30)
-       0x0FF57000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  38, Tf = 5190MHz (31) //RobertYu: 20050218, update for APNode 0.49
-       0x0FF57000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  40, Tf = 5200MHz (32)
-       0x0FF57000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  42, Tf = 5210MHz (33)
-       0x0FF57000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  44, Tf = 5220MHz (34)
-       0x0FF57000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  46, Tf = 5230MHz (35)
-       0x0FF57000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  48, Tf = 5240MHz (36)
-       0x0FF58000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  52, Tf = 5260MHz (37)
-       0x0FF58000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  56, Tf = 5280MHz (38)
-       0x0FF58000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  60, Tf = 5300MHz (39)
-       0x0FF59000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  64, Tf = 5320MHz (40)
-
-       0x0FF5C000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 100, Tf = 5500MHz (41)
-       0x0FF5C000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 104, Tf = 5520MHz (42)
-       0x0FF5C000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 108, Tf = 5540MHz (43)
-       0x0FF5D000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 112, Tf = 5560MHz (44)
-       0x0FF5D000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 116, Tf = 5580MHz (45)
-       0x0FF5D000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 120, Tf = 5600MHz (46)
-       0x0FF5E000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 124, Tf = 5620MHz (47)
-       0x0FF5E000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 128, Tf = 5640MHz (48)
-       0x0FF5E000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 132, Tf = 5660MHz (49)
-       0x0FF5F000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 136, Tf = 5680MHz (50)
-       0x0FF5F000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 140, Tf = 5700MHz (51)
-       0x0FF60000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 149, Tf = 5745MHz (52)
-       0x0FF60000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 153, Tf = 5765MHz (53)
-       0x0FF60000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 157, Tf = 5785MHz (54)
-       0x0FF61000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 161, Tf = 5805MHz (55)
-       0x0FF61000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW  // channel = 165, Tf = 5825MHz (56)
+       0x00379000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  1, Tf = 2412MHz */
+       0x00379000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  2, Tf = 2417MHz */
+       0x00379000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  3, Tf = 2422MHz */
+       0x00379000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  4, Tf = 2427MHz */
+       0x0037A000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  5, Tf = 2432MHz */
+       0x0037A000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  6, Tf = 2437MHz */
+       0x0037A000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  7, Tf = 2442MHz */
+       0x0037A000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  8, Tf = 2447MHz //RobertYu: 20050218, update for APNode 0.49 */
+       0x0037B000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  9, Tf = 2452MHz //RobertYu: 20050218, update for APNode 0.49 */
+       0x0037B000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 10, Tf = 2457MHz //RobertYu: 20050218, update for APNode 0.49 */
+       0x0037B000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 11, Tf = 2462MHz //RobertYu: 20050218, update for APNode 0.49 */
+       0x0037B000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 12, Tf = 2467MHz //RobertYu: 20050218, update for APNode 0.49 */
+       0x0037C000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 13, Tf = 2472MHz //RobertYu: 20050218, update for APNode 0.49 */
+       0x0037C000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 14, Tf = 2484MHz */
+
+       /* 4.9G => Ch 183, 184, 185, 187, 188, 189, 192, 196  (Value:15 ~ 22) */
+       0x0FF52000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 183, Tf = 4915MHz (15) */
+       0x0FF52000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 184, Tf = 4920MHz (16) */
+       0x0FF52000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 185, Tf = 4925MHz (17) */
+       0x0FF52000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 187, Tf = 4935MHz (18) */
+       0x0FF52000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 188, Tf = 4940MHz (19) */
+       0x0FF52000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 189, Tf = 4945MHz (20) */
+       0x0FF53000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 192, Tf = 4960MHz (21) */
+       0x0FF53000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 196, Tf = 4980MHz (22) */
+
+       /* 5G => Ch 7, 8, 9, 11, 12, 16, 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64,
+        * 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165  (Value 23 ~ 56) */
+
+       0x0FF54000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =   7, Tf = 5035MHz (23) */
+       0x0FF54000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =   8, Tf = 5040MHz (24) */
+       0x0FF54000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =   9, Tf = 5045MHz (25) */
+       0x0FF54000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  11, Tf = 5055MHz (26) */
+       0x0FF54000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  12, Tf = 5060MHz (27) */
+       0x0FF55000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  16, Tf = 5080MHz (28) */
+       0x0FF56000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  34, Tf = 5170MHz (29) */
+       0x0FF56000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  36, Tf = 5180MHz (30) */
+       0x0FF57000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  38, Tf = 5190MHz (31) //RobertYu: 20050218, update for APNode 0.49 */
+       0x0FF57000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  40, Tf = 5200MHz (32) */
+       0x0FF57000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  42, Tf = 5210MHz (33) */
+       0x0FF57000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  44, Tf = 5220MHz (34) */
+       0x0FF57000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  46, Tf = 5230MHz (35) */
+       0x0FF57000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  48, Tf = 5240MHz (36) */
+       0x0FF58000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  52, Tf = 5260MHz (37) */
+       0x0FF58000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  56, Tf = 5280MHz (38) */
+       0x0FF58000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  60, Tf = 5300MHz (39) */
+       0x0FF59000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  64, Tf = 5320MHz (40) */
+
+       0x0FF5C000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 100, Tf = 5500MHz (41) */
+       0x0FF5C000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 104, Tf = 5520MHz (42) */
+       0x0FF5C000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 108, Tf = 5540MHz (43) */
+       0x0FF5D000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 112, Tf = 5560MHz (44) */
+       0x0FF5D000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 116, Tf = 5580MHz (45) */
+       0x0FF5D000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 120, Tf = 5600MHz (46) */
+       0x0FF5E000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 124, Tf = 5620MHz (47) */
+       0x0FF5E000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 128, Tf = 5640MHz (48) */
+       0x0FF5E000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 132, Tf = 5660MHz (49) */
+       0x0FF5F000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 136, Tf = 5680MHz (50) */
+       0x0FF5F000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 140, Tf = 5700MHz (51) */
+       0x0FF60000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 149, Tf = 5745MHz (52) */
+       0x0FF60000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 153, Tf = 5765MHz (53) */
+       0x0FF60000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 157, Tf = 5785MHz (54) */
+       0x0FF61000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 161, Tf = 5805MHz (55) */
+       0x0FF61000+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW  /* channel = 165, Tf = 5825MHz (56) */
 };
 
 static const unsigned long dwAL7230ChannelTable1[CB_MAX_CHANNEL] = {
-       0x13333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  1, Tf = 2412MHz
-       0x1B333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  2, Tf = 2417MHz
-       0x03333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  3, Tf = 2422MHz
-       0x0B333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  4, Tf = 2427MHz
-       0x13333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  5, Tf = 2432MHz
-       0x1B333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  6, Tf = 2437MHz
-       0x03333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  7, Tf = 2442MHz
-       0x0B333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  8, Tf = 2447MHz
-       0x13333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  9, Tf = 2452MHz
-       0x1B333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 10, Tf = 2457MHz
-       0x03333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 11, Tf = 2462MHz
-       0x0B333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 12, Tf = 2467MHz
-       0x13333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 13, Tf = 2472MHz
-       0x06666100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 14, Tf = 2484MHz
-
-       // 4.9G => Ch 183, 184, 185, 187, 188, 189, 192, 196  (Value:15 ~ 22)
-       0x1D555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 183, Tf = 4915MHz (15)
-       0x00000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 184, Tf = 4920MHz (16)
-       0x02AAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 185, Tf = 4925MHz (17)
-       0x08000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 187, Tf = 4935MHz (18)
-       0x0AAAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 188, Tf = 4940MHz (19)
-       0x0D555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 189, Tf = 4945MHz (20)
-       0x15555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 192, Tf = 4960MHz (21)
-       0x00000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 196, Tf = 4980MHz (22)
-
-       // 5G => Ch 7, 8, 9, 11, 12, 16, 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64,
-       // 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165  (Value 23 ~ 56)
-       0x1D555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =   7, Tf = 5035MHz (23)
-       0x00000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =   8, Tf = 5040MHz (24)
-       0x02AAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =   9, Tf = 5045MHz (25)
-       0x08000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  11, Tf = 5055MHz (26)
-       0x0AAAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  12, Tf = 5060MHz (27)
-       0x15555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  16, Tf = 5080MHz (28)
-       0x05555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  34, Tf = 5170MHz (29)
-       0x0AAAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  36, Tf = 5180MHz (30)
-       0x10000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  38, Tf = 5190MHz (31)
-       0x15555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  40, Tf = 5200MHz (32)
-       0x1AAAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  42, Tf = 5210MHz (33)
-       0x00000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  44, Tf = 5220MHz (34)
-       0x05555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  46, Tf = 5230MHz (35)
-       0x0AAAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  48, Tf = 5240MHz (36)
-       0x15555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  52, Tf = 5260MHz (37)
-       0x00000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  56, Tf = 5280MHz (38)
-       0x0AAAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  60, Tf = 5300MHz (39)
-       0x15555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  64, Tf = 5320MHz (40)
-       0x15555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 100, Tf = 5500MHz (41)
-       0x00000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 104, Tf = 5520MHz (42)
-       0x0AAAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 108, Tf = 5540MHz (43)
-       0x15555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 112, Tf = 5560MHz (44)
-       0x00000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 116, Tf = 5580MHz (45)
-       0x0AAAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 120, Tf = 5600MHz (46)
-       0x15555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 124, Tf = 5620MHz (47)
-       0x00000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 128, Tf = 5640MHz (48)
-       0x0AAAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 132, Tf = 5660MHz (49)
-       0x15555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 136, Tf = 5680MHz (50)
-       0x00000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 140, Tf = 5700MHz (51)
-       0x18000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 149, Tf = 5745MHz (52)
-       0x02AAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 153, Tf = 5765MHz (53)
-       0x0D555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 157, Tf = 5785MHz (54)
-       0x18000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 161, Tf = 5805MHz (55)
-       0x02AAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW  // channel = 165, Tf = 5825MHz (56)
+       0x13333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  1, Tf = 2412MHz */
+       0x1B333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  2, Tf = 2417MHz */
+       0x03333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  3, Tf = 2422MHz */
+       0x0B333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  4, Tf = 2427MHz */
+       0x13333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  5, Tf = 2432MHz */
+       0x1B333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  6, Tf = 2437MHz */
+       0x03333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  7, Tf = 2442MHz */
+       0x0B333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  8, Tf = 2447MHz */
+       0x13333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  9, Tf = 2452MHz */
+       0x1B333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 10, Tf = 2457MHz */
+       0x03333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 11, Tf = 2462MHz */
+       0x0B333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 12, Tf = 2467MHz */
+       0x13333100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 13, Tf = 2472MHz */
+       0x06666100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 14, Tf = 2484MHz */
+
+       /* 4.9G => Ch 183, 184, 185, 187, 188, 189, 192, 196  (Value:15 ~ 22) */
+       0x1D555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 183, Tf = 4915MHz (15) */
+       0x00000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 184, Tf = 4920MHz (16) */
+       0x02AAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 185, Tf = 4925MHz (17) */
+       0x08000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 187, Tf = 4935MHz (18) */
+       0x0AAAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 188, Tf = 4940MHz (19) */
+       0x0D555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 189, Tf = 4945MHz (20) */
+       0x15555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 192, Tf = 4960MHz (21) */
+       0x00000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 196, Tf = 4980MHz (22) */
+
+       /* 5G => Ch 7, 8, 9, 11, 12, 16, 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64,
+        * 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165  (Value 23 ~ 56) */
+       0x1D555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =   7, Tf = 5035MHz (23) */
+       0x00000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =   8, Tf = 5040MHz (24) */
+       0x02AAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =   9, Tf = 5045MHz (25) */
+       0x08000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  11, Tf = 5055MHz (26) */
+       0x0AAAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  12, Tf = 5060MHz (27) */
+       0x15555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  16, Tf = 5080MHz (28) */
+       0x05555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  34, Tf = 5170MHz (29) */
+       0x0AAAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  36, Tf = 5180MHz (30) */
+       0x10000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  38, Tf = 5190MHz (31) */
+       0x15555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  40, Tf = 5200MHz (32) */
+       0x1AAAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  42, Tf = 5210MHz (33) */
+       0x00000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  44, Tf = 5220MHz (34) */
+       0x05555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  46, Tf = 5230MHz (35) */
+       0x0AAAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  48, Tf = 5240MHz (36) */
+       0x15555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  52, Tf = 5260MHz (37) */
+       0x00000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  56, Tf = 5280MHz (38) */
+       0x0AAAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  60, Tf = 5300MHz (39) */
+       0x15555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  64, Tf = 5320MHz (40) */
+       0x15555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 100, Tf = 5500MHz (41) */
+       0x00000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 104, Tf = 5520MHz (42) */
+       0x0AAAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 108, Tf = 5540MHz (43) */
+       0x15555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 112, Tf = 5560MHz (44) */
+       0x00000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 116, Tf = 5580MHz (45) */
+       0x0AAAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 120, Tf = 5600MHz (46) */
+       0x15555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 124, Tf = 5620MHz (47) */
+       0x00000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 128, Tf = 5640MHz (48) */
+       0x0AAAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 132, Tf = 5660MHz (49) */
+       0x15555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 136, Tf = 5680MHz (50) */
+       0x00000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 140, Tf = 5700MHz (51) */
+       0x18000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 149, Tf = 5745MHz (52) */
+       0x02AAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 153, Tf = 5765MHz (53) */
+       0x0D555100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 157, Tf = 5785MHz (54) */
+       0x18000100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 161, Tf = 5805MHz (55) */
+       0x02AAA100+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW  /* channel = 165, Tf = 5825MHz (56) */
 };
 
 static const unsigned long dwAL7230ChannelTable2[CB_MAX_CHANNEL] = {
-       0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  1, Tf = 2412MHz
-       0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  2, Tf = 2417MHz
-       0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  3, Tf = 2422MHz
-       0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  4, Tf = 2427MHz
-       0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  5, Tf = 2432MHz
-       0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  6, Tf = 2437MHz
-       0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  7, Tf = 2442MHz
-       0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  8, Tf = 2447MHz
-       0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  9, Tf = 2452MHz
-       0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 10, Tf = 2457MHz
-       0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 11, Tf = 2462MHz
-       0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 12, Tf = 2467MHz
-       0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 13, Tf = 2472MHz
-       0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 14, Tf = 2484MHz
-
-       // 4.9G => Ch 183, 184, 185, 187, 188, 189, 192, 196  (Value:15 ~ 22)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 183, Tf = 4915MHz (15)
-       0x67D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 184, Tf = 4920MHz (16)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 185, Tf = 4925MHz (17)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 187, Tf = 4935MHz (18)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 188, Tf = 4940MHz (19)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 189, Tf = 4945MHz (20)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 192, Tf = 4960MHz (21)
-       0x67D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 196, Tf = 4980MHz (22)
-
-       // 5G => Ch 7, 8, 9, 11, 12, 16, 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64,
-       // 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165  (Value 23 ~ 56)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =   7, Tf = 5035MHz (23)
-       0x67D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =   8, Tf = 5040MHz (24)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =   9, Tf = 5045MHz (25)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  11, Tf = 5055MHz (26)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  12, Tf = 5060MHz (27)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  16, Tf = 5080MHz (28)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  34, Tf = 5170MHz (29)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  36, Tf = 5180MHz (30)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  38, Tf = 5190MHz (31)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  40, Tf = 5200MHz (32)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  42, Tf = 5210MHz (33)
-       0x67D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  44, Tf = 5220MHz (34)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  46, Tf = 5230MHz (35)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  48, Tf = 5240MHz (36)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  52, Tf = 5260MHz (37)
-       0x67D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  56, Tf = 5280MHz (38)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  60, Tf = 5300MHz (39)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel =  64, Tf = 5320MHz (40)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 100, Tf = 5500MHz (41)
-       0x67D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 104, Tf = 5520MHz (42)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 108, Tf = 5540MHz (43)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 112, Tf = 5560MHz (44)
-       0x67D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 116, Tf = 5580MHz (45)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 120, Tf = 5600MHz (46)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 124, Tf = 5620MHz (47)
-       0x67D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 128, Tf = 5640MHz (48)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 132, Tf = 5660MHz (49)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 136, Tf = 5680MHz (50)
-       0x67D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 140, Tf = 5700MHz (51)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 149, Tf = 5745MHz (52)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 153, Tf = 5765MHz (53)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 157, Tf = 5785MHz (54)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // channel = 161, Tf = 5805MHz (55)
-       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW  // channel = 165, Tf = 5825MHz (56)
+       0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  1, Tf = 2412MHz */
+       0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  2, Tf = 2417MHz */
+       0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  3, Tf = 2422MHz */
+       0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  4, Tf = 2427MHz */
+       0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  5, Tf = 2432MHz */
+       0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  6, Tf = 2437MHz */
+       0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  7, Tf = 2442MHz */
+       0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  8, Tf = 2447MHz */
+       0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  9, Tf = 2452MHz */
+       0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 10, Tf = 2457MHz */
+       0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 11, Tf = 2462MHz */
+       0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 12, Tf = 2467MHz */
+       0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 13, Tf = 2472MHz */
+       0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 14, Tf = 2484MHz */
+
+       /* 4.9G => Ch 183, 184, 185, 187, 188, 189, 192, 196  (Value:15 ~ 22) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 183, Tf = 4915MHz (15) */
+       0x67D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 184, Tf = 4920MHz (16) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 185, Tf = 4925MHz (17) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 187, Tf = 4935MHz (18) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 188, Tf = 4940MHz (19) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 189, Tf = 4945MHz (20) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 192, Tf = 4960MHz (21) */
+       0x67D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 196, Tf = 4980MHz (22) */
+
+       /* 5G => Ch 7, 8, 9, 11, 12, 16, 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64,
+        * 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165  (Value 23 ~ 56) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =   7, Tf = 5035MHz (23) */
+       0x67D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =   8, Tf = 5040MHz (24) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =   9, Tf = 5045MHz (25) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  11, Tf = 5055MHz (26) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  12, Tf = 5060MHz (27) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  16, Tf = 5080MHz (28) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  34, Tf = 5170MHz (29) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  36, Tf = 5180MHz (30) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  38, Tf = 5190MHz (31) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  40, Tf = 5200MHz (32) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  42, Tf = 5210MHz (33) */
+       0x67D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  44, Tf = 5220MHz (34) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  46, Tf = 5230MHz (35) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  48, Tf = 5240MHz (36) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  52, Tf = 5260MHz (37) */
+       0x67D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  56, Tf = 5280MHz (38) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  60, Tf = 5300MHz (39) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel =  64, Tf = 5320MHz (40) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 100, Tf = 5500MHz (41) */
+       0x67D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 104, Tf = 5520MHz (42) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 108, Tf = 5540MHz (43) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 112, Tf = 5560MHz (44) */
+       0x67D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 116, Tf = 5580MHz (45) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 120, Tf = 5600MHz (46) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 124, Tf = 5620MHz (47) */
+       0x67D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 128, Tf = 5640MHz (48) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 132, Tf = 5660MHz (49) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 136, Tf = 5680MHz (50) */
+       0x67D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 140, Tf = 5700MHz (51) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 149, Tf = 5745MHz (52) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 153, Tf = 5765MHz (53) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 157, Tf = 5785MHz (54) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, /* channel = 161, Tf = 5805MHz (55) */
+       0x77D78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW  /* channel = 165, Tf = 5825MHz (56) */
 };
 
 /*
@@ -438,13 +438,13 @@ static bool s_bAL7230Init(struct vnt_private *priv)
        MACvWordRegBitsOn(dwIoBase, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE3);
 
        /* Calibration */
-       MACvTimer0MicroSDelay(dwIoBase, 150);//150us
+       MACvTimer0MicroSDelay(dwIoBase, 150);/* 150us */
        /* TXDCOC:active, RCK:disable */
        bResult &= IFRFbWriteEmbedded(priv, (0x9ABA8F00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW));
-       MACvTimer0MicroSDelay(dwIoBase, 30);//30us
+       MACvTimer0MicroSDelay(dwIoBase, 30);/* 30us */
        /* TXDCOC:disable, RCK:active */
        bResult &= IFRFbWriteEmbedded(priv, (0x3ABA8F00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW));
-       MACvTimer0MicroSDelay(dwIoBase, 30);//30us
+       MACvTimer0MicroSDelay(dwIoBase, 30);/* 30us */
        /* TXDCOC:disable, RCK:disable */
        bResult &= IFRFbWriteEmbedded(priv, dwAL7230InitTable[CB_AL7230_INIT_SEQ-1]);
 
@@ -457,7 +457,7 @@ static bool s_bAL7230Init(struct vnt_private *priv)
 
        /* PE1: TX_ON, PE2: RX_ON, PE3: PLLON */
        /* 3-wire control for power saving mode */
-       VNSvOutPortB(dwIoBase + MAC_REG_PSPWRSIG, (PSSIG_WPE3 | PSSIG_WPE2)); //1100 0000
+       VNSvOutPortB(dwIoBase + MAC_REG_PSPWRSIG, (PSSIG_WPE3 | PSSIG_WPE2)); /* 1100 0000 */
 
        return bResult;
 }
@@ -557,16 +557,16 @@ static bool RFbAL2230Init(struct vnt_private *priv)
 
        for (ii = 0; ii < CB_AL2230_INIT_SEQ; ii++)
                bResult &= IFRFbWriteEmbedded(priv, dwAL2230InitTable[ii]);
-       MACvTimer0MicroSDelay(dwIoBase, 30); //delay 30 us
+       MACvTimer0MicroSDelay(dwIoBase, 30); /* delay 30 us */
 
        /* PLL On */
        MACvWordRegBitsOn(dwIoBase, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE3);
 
-       MACvTimer0MicroSDelay(dwIoBase, 150);//150us
+       MACvTimer0MicroSDelay(dwIoBase, 150);/* 150us */
        bResult &= IFRFbWriteEmbedded(priv, (0x00d80f00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW));
-       MACvTimer0MicroSDelay(dwIoBase, 30);//30us
+       MACvTimer0MicroSDelay(dwIoBase, 30);/* 30us */
        bResult &= IFRFbWriteEmbedded(priv, (0x00780f00+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW));
-       MACvTimer0MicroSDelay(dwIoBase, 30);//30us
+       MACvTimer0MicroSDelay(dwIoBase, 30);/* 30us */
        bResult &= IFRFbWriteEmbedded(priv, dwAL2230InitTable[CB_AL2230_INIT_SEQ-1]);
 
        MACvWordRegBitsOn(dwIoBase, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPE3    |
@@ -575,7 +575,7 @@ static bool RFbAL2230Init(struct vnt_private *priv)
                                                         SOFTPWRCTL_TXPEINV));
 
        /* 3-wire control for power saving mode */
-       VNSvOutPortB(dwIoBase + MAC_REG_PSPWRSIG, (PSSIG_WPE3 | PSSIG_WPE2)); //1100 0000
+       VNSvOutPortB(dwIoBase + MAC_REG_PSPWRSIG, (PSSIG_WPE3 | PSSIG_WPE2)); /* 1100 0000 */
 
        return bResult;
 }
@@ -661,11 +661,11 @@ bool RFbSelectChannel(struct vnt_private *priv, unsigned char byRFType,
        case RF_AL2230S:
                bResult = RFbAL2230SelectChannel(priv, byChannel);
                break;
-               //{{ RobertYu: 20050104
+               /*{{ RobertYu: 20050104 */
        case RF_AIROHA7230:
                bResult = s_bAL7230SelectChannel(priv, byChannel);
                break;
-               //}} RobertYu
+               /*}} RobertYu */
        case RF_NOTHING:
                bResult = true;
                break;
index 2ea21e2..b5fc3ee 100644 (file)
 #include "device.h"
 
 /*---------------------  Export Definitions -------------------------*/
-//
-// Baseband RF pair definition in eeprom (Bits 6..0)
-//
+/*
+ * Baseband RF pair definition in eeprom (Bits 6..0)
+*/
 #define RF_RFMD2959             0x01
 #define RF_MAXIMAG              0x02
 #define RF_AIROHA               0x03
 
 #define RF_UW2451               0x05
 #define RF_MAXIMG               0x06
-#define RF_MAXIM2829            0x07 // RobertYu: 20041118
-#define RF_UW2452               0x08 // RobertYu: 20041210
-#define RF_AIROHA7230           0x0a // RobertYu: 20050104
+#define RF_MAXIM2829            0x07 /* RobertYu: 20041118 */
+#define RF_UW2452               0x08 /* RobertYu: 20041210 */
+#define RF_AIROHA7230           0x0a /* RobertYu: 20050104 */
 #define RF_UW2453               0x0b
 
 #define RF_VT3226               0x09
@@ -63,9 +63,9 @@
 #define ZONE_MKK                6
 #define ZONE_ISRAEL             7
 
-//[20050104] CB_MAXIM2829_CHANNEL_5G_HIGH, CB_UW2452_CHANNEL_5G_HIGH: 40==>41
-#define CB_MAXIM2829_CHANNEL_5G_HIGH    41 //Index41: channel = 100, Tf = 5500MHz, set the (A3:A0=0101) D6=1
-#define CB_UW2452_CHANNEL_5G_HIGH       41 //[20041210] Index41: channel = 100, Tf = 5500MHz, change VCO2->VCO3
+/* [20050104] CB_MAXIM2829_CHANNEL_5G_HIGH, CB_UW2452_CHANNEL_5G_HIGH: 40==>41 */
+#define CB_MAXIM2829_CHANNEL_5G_HIGH    41 /* Index41: channel = 100, Tf = 5500MHz, set the (A3:A0=0101) D6=1 */
+#define CB_UW2452_CHANNEL_5G_HIGH       41 /* [20041210] Index41: channel = 100, Tf = 5500MHz, change VCO2->VCO3 */
 
 /*---------------------  Export Classes  ----------------------------*/
 
@@ -93,8 +93,8 @@ RFvRSSITodBm(
        long    *pldBm
 );
 
-//{{ RobertYu: 20050104
+/* {{ RobertYu: 20050104 */
 bool RFbAL7230SelectChannelPostProcess(struct vnt_private *, u16, u16);
-//}} RobertYu
+/* }} RobertYu */
 
-#endif // __RF_H__
+#endif /* __RF_H__ */
index cc63dc8..85fe046 100644 (file)
 /* For memory mapped IO */
 
 
-#define VNSvInPortB(dwIOAddress, pbyData)                              \
-do {                                                                   \
-       *(pbyData) = ioread8(dwIOAddress);                              \
-} while (0)
+#define VNSvInPortB(dwIOAddress, pbyData) \
+       (*(pbyData) = ioread8(dwIOAddress))
 
-#define VNSvInPortW(dwIOAddress, pwData)                               \
-do {                                                                   \
-       *(pwData) = ioread16(dwIOAddress);                              \
-} while (0)
+#define VNSvInPortW(dwIOAddress, pwData) \
+       (*(pwData) = ioread16(dwIOAddress))
 
-#define VNSvInPortD(dwIOAddress, pdwData)                              \
-do {                                                                   \
-       *(pdwData) = ioread32(dwIOAddress);                             \
-} while (0)
+#define VNSvInPortD(dwIOAddress, pdwData) \
+       (*(pdwData) = ioread32(dwIOAddress))
 
-#define VNSvOutPortB(dwIOAddress, byData)                              \
-do {                                                                   \
-       iowrite8((u8)byData, dwIOAddress);                              \
-} while (0)
+#define VNSvOutPortB(dwIOAddress, byData) \
+       iowrite8((u8)(byData), dwIOAddress)
 
-#define VNSvOutPortW(dwIOAddress, wData)                               \
-do {                                                                   \
-       iowrite16((u16)wData, dwIOAddress);                             \
-} while (0)
+#define VNSvOutPortW(dwIOAddress, wData) \
+       iowrite16((u16)(wData), dwIOAddress)
 
-#define VNSvOutPortD(dwIOAddress, dwData)                              \
-do {                                                                   \
-       iowrite32((u32)dwData, dwIOAddress);                            \
-} while (0)
+#define VNSvOutPortD(dwIOAddress, dwData) \
+       iowrite32((u32)(dwData), dwIOAddress)
 
 #define PCAvDelayByIO(uDelayUnit)                              \
 do {                                                           \
index 8116791..da075f4 100644 (file)
 #include "usbpipe.h"
 
 static const u16 vnt_time_stampoff[2][MAX_RATE] = {
-       {384, 288, 226, 209, 54, 43, 37, 31, 28, 25, 24, 23},/* Long Preamble */
-       {384, 192, 130, 113, 54, 43, 37, 31, 28, 25, 24, 23},/* Short Preamble */
+       /* Long Preamble */
+       {384, 288, 226, 209, 54, 43, 37, 31, 28, 25, 24, 23},
+
+       /* Short Preamble */
+       {384, 192, 130, 113, 54, 43, 37, 31, 28, 25, 24, 23},
 };
 
 static const u16 vnt_fb_opt0[2][5] = {
index ed6ac45..b069614 100644 (file)
@@ -605,7 +605,7 @@ INLINE u16 get_cap_info(u8 *data)
 {
        u16 cap_info = 0;
        u16 index    = MAC_HDR_LEN;
-       tenuFrmSubtype st = BEACON;
+       tenuFrmSubtype st;
 
        st = get_sub_type(data);
 
@@ -1568,14 +1568,6 @@ s32 further_process_response(u8 *resp,
        case WID_STR:
                WILC_memcpy(cfg_str, resp + idx, cfg_len);
                /* cfg_str[cfg_len] = '\0'; //mostafa: no need currently for NULL termination */
-               if (process_wid_num) {
-                       /*fprintf(out_file,"0x%4.4x = %s\n",g_wid_num,
-                        *                              cfg_str);*/
-               } else {
-                       /*fprintf(out_file,"%s = %s\n",gastrWIDs[cnt].cfg_switch,
-                        *                           cfg_str);*/
-               }
-
                if (pstrWIDresult->s32ValueSize >= cfg_len) {
                        WILC_memcpy(pstrWIDresult->ps8WidVal, cfg_str, cfg_len); /* mostafa: no need currently for the extra NULL byte */
                        pstrWIDresult->s32ValueSize = cfg_len;
@@ -1591,13 +1583,6 @@ s32 further_process_response(u8 *resp,
 
                WILC_strncpy(pstrWIDresult->ps8WidVal, cfg_str, WILC_strlen(cfg_str));
                pstrWIDresult->ps8WidVal[WILC_strlen(cfg_str)] = '\0';
-               if (process_wid_num) {
-                       /*fprintf(out_file,"0x%4.4x = %s\n",g_wid_num,
-                        *                              cfg_str);*/
-               } else {
-                       /*fprintf(out_file,"%s = %s\n",gastrWIDs[cnt].cfg_switch,
-                        *                           cfg_str);*/
-               }
                break;
 
        case WID_IP:
@@ -1606,13 +1591,6 @@ s32 further_process_response(u8 *resp,
                                MAKE_WORD16(resp[idx + 2], resp[idx + 3])
                                );
                conv_int_to_ip(cfg_str, cfg_int);
-               if (process_wid_num) {
-                       /*fprintf(out_file,"0x%4.4x = %s\n",g_wid_num,
-                        *                              cfg_str);*/
-               } else {
-                       /*fprintf(out_file,"%s = %s\n",gastrWIDs[cnt].cfg_switch,
-                        *                           cfg_str);*/
-               }
                break;
 
        case WID_BIN_DATA:
@@ -1739,7 +1717,6 @@ s32 ParseResponse(u8 *resp, tstrWID *pstrWIDcfgResult)
 s32 ParseWriteResponse(u8 *pu8RespBuffer)
 {
        s32 s32Error = WILC_FAIL;
-       u16 u16RespLen   = 0;
        u16 u16WIDtype = (u16)WID_NIL;
 
        /* Check whether the received frame is a valid response */
@@ -1748,9 +1725,6 @@ s32 ParseWriteResponse(u8 *pu8RespBuffer)
                return WILC_FAIL;
        }
 
-       /* Extract Response Length */
-       u16RespLen = MAKE_WORD16(pu8RespBuffer[2], pu8RespBuffer[3]);
-
        u16WIDtype = MAKE_WORD16(pu8RespBuffer[4], pu8RespBuffer[5]);
 
        /* Check for WID_STATUS ID and then check the length and status value */
index b6c07cf..86eb82e 100644 (file)
@@ -31,11 +31,10 @@ u32 FIFO_DeInit(tHANDLE hFifo)
        u32 u32Error = 0;
        tstrFifoHandler *pstrFifoHandler = (tstrFifoHandler *) hFifo;
        if (pstrFifoHandler) {
-               if (pstrFifoHandler->pu8Buffer) {
+               if (pstrFifoHandler->pu8Buffer)
                        WILC_FREE (pstrFifoHandler->pu8Buffer);
-               } else {
+               else
                        u32Error = 1;
-               }
 
                WILC_FREE (pstrFifoHandler);
        } else {
@@ -52,11 +51,11 @@ u32 FIFO_ReadBytes(tHANDLE hFifo, u8 *pu8Buffer, u32 u32BytesToRead, u32 *pu32By
                if (pstrFifoHandler->u32TotalBytes) {
                        down(&pstrFifoHandler->SemBuffer);
 
-                       if (u32BytesToRead > pstrFifoHandler->u32TotalBytes) {
+                       if (u32BytesToRead > pstrFifoHandler->u32TotalBytes)
                                *pu32BytesRead = pstrFifoHandler->u32TotalBytes;
-                       } else {
+                       else
                                *pu32BytesRead = u32BytesToRead;
-                       }
+
                        if ((pstrFifoHandler->u32ReadOffset + u32BytesToRead) <= pstrFifoHandler->u32BufferLength) {
                                WILC_memcpy(pu8Buffer, pstrFifoHandler->pu8Buffer + pstrFifoHandler->u32ReadOffset,
                                            *pu32BytesRead);
index 6b10bbb..c089e73 100644 (file)
@@ -534,8 +534,8 @@ typedef enum {
 /*****************************************************************************/
 
 
-tstrWILC_WFIDrv *terminated_handle = NULL;
-tstrWILC_WFIDrv *gWFiDrvHandle = NULL;
+tstrWILC_WFIDrv *terminated_handle;
+tstrWILC_WFIDrv *gWFiDrvHandle;
 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
 bool g_obtainingIP = false;
 #endif
@@ -659,9 +659,8 @@ static s32 Handle_SetWfiDrvHandler(tstrHostIfSetDrvHandler *pstrHostIfSetDrvHand
        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
 
 
-       if ((pstrHostIfSetDrvHandler->u32Address) == (u32)NULL) {
+       if ((pstrHostIfSetDrvHandler->u32Address) == (u32)NULL)
                up(&hSemDeinitDrvHandle);
-       }
 
 
        if (s32Error) {
@@ -700,14 +699,13 @@ static s32 Handle_SetOperationMode(void *drvHandler, tstrHostIfSetOperationMode
        strWID.s32ValueSize = sizeof(u32);
 
        /*Sending Cfg*/
-       PRINT_INFO(HOSTINF_DBG, "pstrWFIDrv= %p \n", pstrWFIDrv);
+       PRINT_INFO(HOSTINF_DBG, "pstrWFIDrv= %p\n", pstrWFIDrv);
 
        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
 
 
-       if ((pstrHostIfSetOperationMode->u32Mode) == (u32)NULL) {
+       if ((pstrHostIfSetOperationMode->u32Mode) == (u32)NULL)
                up(&hSemDeinitDrvHandle);
-       }
 
 
        if (s32Error) {
@@ -742,7 +740,7 @@ s32 Handle_set_IPAddress(void *drvHandler, u8 *pu8IPAddr, u8 idx)
        if (pu8IPAddr[0] < 192)
                pu8IPAddr[0] = 0;
 
-       PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set  IP = %d.%d.%d.%d \n", idx, pu8IPAddr[0], pu8IPAddr[1], pu8IPAddr[2], pu8IPAddr[3]);
+       PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set  IP = %pI4\n", idx, pu8IPAddr);
 
        WILC_memcpy(gs8SetIP[idx], pu8IPAddr, IP_ALEN);
 
@@ -798,7 +796,7 @@ s32 Handle_get_IPAddress(void *drvHandler, u8 *pu8IPAddr, u8 idx)
 
        s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
 
-       PRINT_INFO(HOSTINF_DBG, "%d.%d.%d.%d\n", (u8)(strWID.ps8WidVal[0]), (u8)(strWID.ps8WidVal[1]), (u8)(strWID.ps8WidVal[2]), (u8)(strWID.ps8WidVal[3]));
+       PRINT_INFO(HOSTINF_DBG, "%pI4\n", strWID.ps8WidVal);
 
        WILC_memcpy(gs8GetIP[idx], strWID.ps8WidVal, IP_ALEN);
 
@@ -812,8 +810,8 @@ s32 Handle_get_IPAddress(void *drvHandler, u8 *pu8IPAddr, u8 idx)
                PRINT_ER("Failed to get IP address\n");
                WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
        } else {
-               PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d \n", idx);
-               PRINT_INFO(HOSTINF_DBG, "%d.%d.%d.%d\n", gs8GetIP[idx][0], gs8GetIP[idx][1], gs8GetIP[idx][2], gs8GetIP[idx][3]);
+               PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d\n", idx);
+               PRINT_INFO(HOSTINF_DBG, "%pI4\n", gs8GetIP[idx]);
                PRINT_INFO(HOSTINF_DBG, "\n");
        }
 
@@ -843,6 +841,7 @@ static s32 Handle_SetMacAddress(void *drvHandler, tstrHostIfSetMacAddress *pstrH
        tstrWID strWID;
        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
        u8 *mac_buf = (u8 *)WILC_MALLOC(ETH_ALEN);
+
        if (mac_buf == NULL) {
                PRINT_ER("No buffer to send mac address\n");
                return WILC_FAIL;
@@ -1204,10 +1203,9 @@ static s32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *strHostIFCf
        }
        s32Error = SendConfigPkt(SET_CFG, strWIDList, u8WidCnt, false, (u32)pstrWFIDrv);
 
-       if (s32Error) {
+       if (s32Error)
                PRINT_ER("Error in setting CFG params\n");
 
-       }
        WILC_CATCH(s32Error)
        {
        }
@@ -1228,6 +1226,7 @@ static s32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *strHostIFCf
 static s32 Handle_wait_msg_q_empty(void)
 {
        s32 s32Error = WILC_SUCCESS;
+
        g_wilc_initialized = 0;
        up(&hWaitResponse);
        return s32Error;
@@ -1254,7 +1253,7 @@ static s32 Handle_Scan(void *drvHandler, tstrHostIFscanAttr *pstrHostIFscanAttr)
        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
 
        PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
-       PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state \n", pstrWFIDrv->enuHostIFstate);
+       PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state\n", pstrWFIDrv->enuHostIFstate);
 
        pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = pstrHostIFscanAttr->pfScanResult;
        pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid = pstrHostIFscanAttr->pvUserArg;
@@ -1284,9 +1283,8 @@ static s32 Handle_Scan(void *drvHandler, tstrHostIFscanAttr *pstrHostIFscanAttr)
        strWIDList[u32WidsCount].u16WIDid = (u16)WID_SSID_PROBE_REQ;
        strWIDList[u32WidsCount].enuWIDtype = WID_STR;
 
-       for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++) {
+       for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++)
                valuesize += ((pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen) + 1);
-       }
        pu8HdnNtwrksWidVal = WILC_MALLOC(valuesize + 1);
        strWIDList[u32WidsCount].ps8WidVal = pu8HdnNtwrksWidVal;
        if (strWIDList[u32WidsCount].ps8WidVal != NULL) {
@@ -1336,9 +1334,8 @@ static s32 Handle_Scan(void *drvHandler, tstrHostIFscanAttr *pstrHostIFscanAttr)
                int i;
 
                for (i = 0; i < pstrHostIFscanAttr->u8ChnlListLen; i++) {
-                       if (pstrHostIFscanAttr->pu8ChnlFreqList[i] > 0) {
+                       if (pstrHostIFscanAttr->pu8ChnlFreqList[i] > 0)
                                pstrHostIFscanAttr->pu8ChnlFreqList[i] = pstrHostIFscanAttr->pu8ChnlFreqList[i] - 1;
-                       }
                }
        }
 
@@ -1400,9 +1397,8 @@ static s32 Handle_Scan(void *drvHandler, tstrHostIFscanAttr *pstrHostIFscanAttr)
                pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
        }
 
-       if (pu8HdnNtwrksWidVal != NULL) {
+       if (pu8HdnNtwrksWidVal != NULL)
                WILC_FREE(pu8HdnNtwrksWidVal);
-       }
 
        return s32Error;
 }
@@ -1528,7 +1524,7 @@ static s32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrHostIFcon
                DeallocateSurveyResults(pstrSurveyResults);
        } else {
                WILC_ERRORREPORT(s32Error, WILC_FAIL);
-               PRINT_ER("ParseSurveyResults() Error(%d) \n", s32Err);
+               PRINT_ER("ParseSurveyResults() Error(%d)\n", s32Err);
        }
 
 
@@ -1559,7 +1555,7 @@ static s32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrHostIFcon
        if (i < pstrWFIDrv->u32SurveyResultsCount) {
                u8bssDscListIndex = i;
 
-               PRINT_INFO(HOSTINF_DBG, "Connecting to network of Bss Idx %d and SSID %s and channel %d \n",
+               PRINT_INFO(HOSTINF_DBG, "Connecting to network of Bss Idx%d and SSID %s and channel%d\n",
                           u8bssDscListIndex, pstrWFIDrv->astrSurveyResults[u8bssDscListIndex].SSID,
                           pstrWFIDrv->astrSurveyResults[u8bssDscListIndex].Channel);
 
@@ -1778,9 +1774,8 @@ static s32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrHostIFcon
        strWIDList[u32WidsCount].s32ValueSize = MAX_SSID_LEN + 7;
        strWIDList[u32WidsCount].ps8WidVal = WILC_MALLOC(strWIDList[u32WidsCount].s32ValueSize);
 
-       if (strWIDList[u32WidsCount].ps8WidVal == NULL) {
+       if (strWIDList[u32WidsCount].ps8WidVal == NULL)
                WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
-       }
 
        pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
 
@@ -1795,9 +1790,8 @@ static s32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrHostIFcon
                PRINT_ER("Channel out of range\n");
                *(pu8CurrByte++) = 0xFF;
        }
-       if (pstrHostIFconnectAttr->pu8bssid != NULL) {
+       if (pstrHostIFconnectAttr->pu8bssid != NULL)
                WILC_memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
-       }
        pu8CurrByte += 6;
 
        /* keep the buffer at the start of the allocated pointer to use it with the free*/
@@ -1817,9 +1811,8 @@ static s32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrHostIFcon
                gu32FlushedJoinReqSize = strWIDList[u32WidsCount].s32ValueSize;
                gu8FlushedJoinReq = WILC_MALLOC(gu32FlushedJoinReqSize);
        }
-       if (strWIDList[u32WidsCount].ps8WidVal == NULL) {
+       if (strWIDList[u32WidsCount].ps8WidVal == NULL)
                WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
-       }
 
        pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
 
@@ -1845,15 +1838,13 @@ static s32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrHostIFcon
        PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
 
        /* sa*/
-       if (pstrHostIFconnectAttr->pu8bssid != NULL) {
+       if (pstrHostIFconnectAttr->pu8bssid != NULL)
                WILC_memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
-       }
        pu8CurrByte += 6;
 
        /* bssid*/
-       if (pstrHostIFconnectAttr->pu8bssid != NULL) {
+       if (pstrHostIFconnectAttr->pu8bssid != NULL)
                WILC_memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
-       }
        pu8CurrByte += 6;
 
        /* Beacon Period*/
@@ -1990,9 +1981,8 @@ static s32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrHostIFcon
                WILC_memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
 
                if (pstrHostIFconnectAttr->pfConnectResult != NULL) {
-                       if (pstrHostIFconnectAttr->pu8bssid != NULL) {
+                       if (pstrHostIFconnectAttr->pu8bssid != NULL)
                                WILC_memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
-                       }
 
                        if (pstrHostIFconnectAttr->pu8IEs != NULL) {
                                strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->IEsLen;
@@ -2016,7 +2006,7 @@ static s32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrHostIFcon
                        }
 
                } else {
-                       PRINT_ER("Connect callback function pointer is NULL \n");
+                       PRINT_ER("Connect callback function pointer is NULL\n");
                }
        }
 
@@ -2039,9 +2029,8 @@ static s32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrHostIFcon
                pstrHostIFconnectAttr->pu8IEs = NULL;
        }
 
-       if (pu8CurrByte != NULL) {
+       if (pu8CurrByte != NULL)
                WILC_FREE(pu8CurrByte);
-       }
        return s32Error;
 }
 
@@ -2173,7 +2162,7 @@ static s32 Handle_ConnectTimeout(void *drvHandler)
                        strConnectInfo.pu8ReqIEs = NULL;
                }
        } else {
-               PRINT_ER("Connect callback function pointer is NULL \n");
+               PRINT_ER("Connect callback function pointer is NULL\n");
        }
 
        /* Here we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
@@ -2186,9 +2175,8 @@ static s32 Handle_ConnectTimeout(void *drvHandler)
        PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
 
        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
-       if (s32Error) {
+       if (s32Error)
                PRINT_ER("Failed to send dissconect config packet\n");
-       }
 
        /* Deallocation of the Saved Connect Request in the global Handle */
        pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
@@ -2313,7 +2301,7 @@ static s32 Handle_RcvdNtwrkInfo(void *drvHandler, tstrRcvdNetworkInfo *pstrRcvdN
 
                                }
                        } else {
-                               PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit \n");
+                               PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit\n");
                        }
                } else {
                        pstrNetworkInfo->bNewNetwork = false;
@@ -2371,9 +2359,9 @@ static s32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, tstrRcvdGnrlAsyncInfo *pst
        tstrDisconnectNotifInfo strDisconnectNotifInfo;
        s32 s32Err = WILC_SUCCESS;
        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
-       if (pstrWFIDrv == NULL) {
+
+       if (pstrWFIDrv == NULL)
                PRINT_ER("Driver handler is NULL\n");
-       }
        PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n", pstrWFIDrv->enuHostIFstate,
                pstrRcvdGnrlAsyncInfo->pu8Buffer[7]);
 
@@ -2435,7 +2423,7 @@ static s32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, tstrRcvdGnrlAsyncInfo *pst
                                        s32Err = ParseAssocRespInfo(gapu8RcvdAssocResp, u32RcvdAssocRespInfoLen,
                                                                    &pstrConnectRespInfo);
                                        if (s32Err) {
-                                               PRINT_ER("ParseAssocRespInfo() returned error %d \n", s32Err);
+                                               PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err);
                                        } else {
                                                /* use the necessary parsed Info from the Received Association Response */
                                                strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
@@ -2466,7 +2454,7 @@ static s32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, tstrRcvdGnrlAsyncInfo *pst
                         *   So check first the matching between the received mac status and the received status code in Asoc Resp */
                        if ((u8MacStatus == MAC_CONNECTED) &&
                            (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
-                               PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE \n");
+                               PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
                                WILC_memset(u8ConnectedSSID, 0, ETH_ALEN);
 
                        } else if (u8MacStatus == MAC_DISCONNECTED)    {
@@ -2575,7 +2563,7 @@ static s32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, tstrRcvdGnrlAsyncInfo *pst
                        WILC_memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
 
                        if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
-                               PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >> \n\n");
+                               PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >>\n\n");
                                WILC_TimerStop(&(pstrWFIDrv->hScanTimer), NULL);
                                Handle_ScanDone((void *)pstrWFIDrv, SCAN_EVENT_ABORTED);
                        }
@@ -2598,7 +2586,7 @@ static s32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, tstrRcvdGnrlAsyncInfo *pst
                                                                                   pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
 
                        } else {
-                               PRINT_ER("Connect result callback function is NULL \n");
+                               PRINT_ER("Connect result callback function is NULL\n");
                        }
 
                        WILC_memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
@@ -2651,13 +2639,12 @@ static s32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, tstrRcvdGnrlAsyncInfo *pst
                } else if ((u8MacStatus == MAC_DISCONNECTED) &&
                           (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL)) {
                        PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
-                       PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >> \n\n");
+                       PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >>\n\n");
                        /*Abort the running scan*/
                        WILC_TimerStop(&(pstrWFIDrv->hScanTimer), NULL);
-                       if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
+                       if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult)
                                Handle_ScanDone((void *)pstrWFIDrv, SCAN_EVENT_ABORTED);
 
-                       }
                }
 
        }
@@ -2872,7 +2859,7 @@ static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr)
                        if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) {
                                WILC_memcpy(pu8keybuf, pstrWFIDrv->au8AssociatedBSSID, ETH_ALEN);
                        } else {
-                               PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED \n");
+                               PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED\n");
                        }
 
                        WILC_memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
@@ -3108,7 +3095,7 @@ static void Handle_Disconnect(void *drvHandler)
                        pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL,
                                                                           0, &strDisconnectNotifInfo, pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
                } else {
-                       PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL \n");
+                       PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL\n");
                }
 
                gbScanWhileConnected = false;
@@ -3194,7 +3181,7 @@ static s32 Switch_Log_Terminal(void *drvHandler)
                PRINT_D(HOSTINF_DBG, "Failed to switch log terminal\n");
                WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
        } else {
-               PRINT_INFO(HOSTINF_DBG, "MAC address set :: \n");
+               PRINT_INFO(HOSTINF_DBG, "MAC address set ::\n");
 
 
        }
@@ -3224,6 +3211,7 @@ static s32 Handle_GetChnl(void *drvHandler)
        tstrWID strWID;
        /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+
        strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL;
        strWID.enuWIDtype = WID_CHAR;
        strWID.ps8WidVal = (s8 *)&gu8Chnl;
@@ -3457,15 +3445,15 @@ static void Handle_AddBeacon(void *drvHandler, tstrHostIFSetBeacon *pstrSetBeaco
        tstrWID strWID;
        u8 *pu8CurrByte;
        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+
        PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
 
        strWID.u16WIDid = (u16)WID_ADD_BEACON;
        strWID.enuWIDtype = WID_BIN;
        strWID.s32ValueSize = pstrSetBeaconParam->u32HeadLen + pstrSetBeaconParam->u32TailLen + 16;
        strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
-       if (strWID.ps8WidVal == NULL) {
+       if (strWID.ps8WidVal == NULL)
                WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
-       }
 
        pu8CurrByte = strWID.ps8WidVal;
        *pu8CurrByte++ = (pstrSetBeaconParam->u32Interval & 0xFF);
@@ -3529,14 +3517,14 @@ static void Handle_DelBeacon(void *drvHandler, tstrHostIFDelBeacon *pstrDelBeaco
        tstrWID strWID;
        u8 *pu8CurrByte;
        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+
        strWID.u16WIDid = (u16)WID_DEL_BEACON;
        strWID.enuWIDtype = WID_CHAR;
        strWID.s32ValueSize = sizeof(char);
        strWID.ps8WidVal = &gu8DelBcn;
 
-       if (strWID.ps8WidVal == NULL) {
+       if (strWID.ps8WidVal == NULL)
                WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
-       }
 
        pu8CurrByte = strWID.ps8WidVal;
 
@@ -3580,9 +3568,8 @@ static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer, tstrWILC_AddStaParam *pstrSta
        *pu8CurrByte++ = (pstrStationParam->u16AssocID >> 8) & 0xFF;
 
        *pu8CurrByte++ = pstrStationParam->u8NumRates;
-       if (pstrStationParam->u8NumRates > 0) {
+       if (pstrStationParam->u8NumRates > 0)
                WILC_memcpy(pu8CurrByte, pstrStationParam->pu8Rates, pstrStationParam->u8NumRates);
-       }
        pu8CurrByte += pstrStationParam->u8NumRates;
 
        *pu8CurrByte++ = pstrStationParam->bIsHTSupported;
@@ -3627,15 +3614,15 @@ static void Handle_AddStation(void *drvHandler, tstrWILC_AddStaParam *pstrStatio
        tstrWID strWID;
        u8 *pu8CurrByte;
        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+
        PRINT_D(HOSTINF_DBG, "Handling add station\n");
        strWID.u16WIDid = (u16)WID_ADD_STA;
        strWID.enuWIDtype = WID_BIN;
        strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
 
        strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
-       if (strWID.ps8WidVal == NULL) {
+       if (strWID.ps8WidVal == NULL)
                WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
-       }
 
        pu8CurrByte = strWID.ps8WidVal;
        pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
@@ -3667,21 +3654,22 @@ static void Handle_AddStation(void *drvHandler, tstrWILC_AddStaParam *pstrStatio
 static void Handle_DelAllSta(void *drvHandler, tstrHostIFDelAllSta *pstrDelAllStaParam)
 {
        s32 s32Error = WILC_SUCCESS;
+
        tstrWID strWID;
        u8 *pu8CurrByte;
        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
        u8 i;
        u8 au8Zero_Buff[6] = {0};
+
        strWID.u16WIDid = (u16)WID_DEL_ALL_STA;
        strWID.enuWIDtype = WID_STR;
        strWID.s32ValueSize = (pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1;
 
-       PRINT_D(HOSTINF_DBG, "Handling delete station \n");
+       PRINT_D(HOSTINF_DBG, "Handling delete station\n");
 
        strWID.ps8WidVal = WILC_MALLOC((pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1);
-       if (strWID.ps8WidVal == NULL) {
+       if (strWID.ps8WidVal == NULL)
                WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
-       }
 
        pu8CurrByte = strWID.ps8WidVal;
 
@@ -3700,7 +3688,7 @@ static void Handle_DelAllSta(void *drvHandler, tstrHostIFDelAllSta *pstrDelAllSt
        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
        if (s32Error) {
 
-               PRINT_ER("Failed to send add station config packe\n");
+               PRINT_ER("Failed to send add station config packet\n");
                WILC_ERRORREPORT(s32Error, WILC_FAIL);
        }
 
@@ -3733,12 +3721,11 @@ static void Handle_DelStation(void *drvHandler, tstrHostIFDelSta *pstrDelStaPara
        strWID.enuWIDtype = WID_BIN;
        strWID.s32ValueSize = ETH_ALEN;
 
-       PRINT_D(HOSTINF_DBG, "Handling delete station \n");
+       PRINT_D(HOSTINF_DBG, "Handling delete station\n");
 
        strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
-       if (strWID.ps8WidVal == NULL) {
+       if (strWID.ps8WidVal == NULL)
                WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
-       }
 
        pu8CurrByte = strWID.ps8WidVal;
 
@@ -3748,7 +3735,7 @@ static void Handle_DelStation(void *drvHandler, tstrHostIFDelSta *pstrDelStaPara
        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
        if (s32Error) {
 
-               PRINT_ER("Failed to send add station config packe\n");
+               PRINT_ER("Failed to send add station config packet\n");
                WILC_ERRORREPORT(s32Error, WILC_FAIL);
        }
 
@@ -3781,9 +3768,8 @@ static void Handle_EditStation(void *drvHandler, tstrWILC_AddStaParam *pstrStati
 
        PRINT_D(HOSTINF_DBG, "Handling edit station\n");
        strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
-       if (strWID.ps8WidVal == NULL) {
+       if (strWID.ps8WidVal == NULL)
                WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
-       }
 
        pu8CurrByte = strWID.ps8WidVal;
        pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
@@ -3858,18 +3844,16 @@ static int Handle_RemainOnChan(void *drvHandler, tstrHostIfRemainOnChan *pstrHos
        strWID.s32ValueSize = 2;
        strWID.ps8WidVal = (s8 *)WILC_MALLOC(strWID.s32ValueSize);
 
-       if (strWID.ps8WidVal == NULL) {
+       if (strWID.ps8WidVal == NULL)
                WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
-       }
 
        strWID.ps8WidVal[0] = u8remain_on_chan_flag;
        strWID.ps8WidVal[1] = (s8)pstrHostIfRemainOnChan->u16Channel;
 
        /*Sending Cfg*/
        s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
-       if (s32Error != WILC_SUCCESS) {
+       if (s32Error != WILC_SUCCESS)
                PRINT_ER("Failed to set remain on channel\n");
-       }
 
        WILC_CATCH(-1)
        {
@@ -3877,9 +3861,8 @@ static int Handle_RemainOnChan(void *drvHandler, tstrHostIfRemainOnChan *pstrHos
                WILC_TimerStart(&(pstrWFIDrv->hRemainOnChannel), pstrHostIfRemainOnChan->u32duration, (void *)pstrWFIDrv, NULL);
 
                /*Calling CFG ready_on_channel*/
-               if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady) {
+               if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady)
                        pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady(pstrWFIDrv->strHostIfRemainOnChan.pVoid);
-               }
 
                if (pstrWFIDrv->u8RemainOnChan_pendingreq)
                        pstrWFIDrv->u8RemainOnChan_pendingreq = 0;
@@ -3909,9 +3892,8 @@ static int Handle_RegisterFrame(void *drvHandler, tstrHostIfRegisterFrame *pstrH
        strWID.u16WIDid = (u16)WID_REGISTER_FRAME;
        strWID.enuWIDtype = WID_STR;
        strWID.ps8WidVal = WILC_MALLOC(sizeof(u16) + 2);
-       if (strWID.ps8WidVal == NULL) {
+       if (strWID.ps8WidVal == NULL)
                WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
-       }
 
        pu8CurrByte = strWID.ps8WidVal;
 
@@ -3968,9 +3950,8 @@ static u32 Handle_ListenStateExpired(void *drvHandler, tstrHostIfRemainOnChan *p
                strWID.s32ValueSize = 2;
                strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
 
-               if (strWID.ps8WidVal == NULL) {
+               if (strWID.ps8WidVal == NULL)
                        PRINT_ER("Failed to allocate memory\n");
-               }
 
                strWID.ps8WidVal[0] = u8remain_on_chan_flag;
                strWID.ps8WidVal[1] = FALSE_FRMWR_CHANNEL;
@@ -4022,9 +4003,8 @@ static void ListenTimerCB(void *pvArg)
 
        /* send the message */
        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
-       if (s32Error) {
+       if (s32Error)
                WILC_ERRORREPORT(s32Error, s32Error);
-       }
        WILC_CATCH(s32Error)
        {
 
@@ -4048,6 +4028,7 @@ static void Handle_PowerManagement(void *drvHandler, tstrHostIfPowerMgmtParam *s
        tstrWID strWID;
        s8 s8PowerMode;
        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+
        strWID.u16WIDid = (u16)WID_POWER_MANAGEMENT;
 
        if (strPowerMgmtParam->bIsEnabled == true)      {
@@ -4095,9 +4076,8 @@ static void Handle_SetMulticastFilter(void *drvHandler, tstrHostIFSetMulti *strH
        strWID.enuWIDtype = WID_BIN;
        strWID.s32ValueSize = sizeof(tstrHostIFSetMulti) + ((strHostIfSetMulti->u32count) * ETH_ALEN);
        strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
-       if (strWID.ps8WidVal == NULL) {
+       if (strWID.ps8WidVal == NULL)
                WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
-       }
 
        pu8CurrByte = strWID.ps8WidVal;
        *pu8CurrByte++ = (strHostIfSetMulti->bIsEnabled & 0xFF);
@@ -4146,7 +4126,7 @@ static s32 Handle_AddBASession(void *drvHandler, tstrHostIfBASessionInfo *strHos
        char *ptr = NULL;
        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
 
-       PRINT_D(HOSTINF_DBG, "Opening Block Ack session with\nBSSID = %.2x:%.2x:%.2x \nTID=%d \nBufferSize == %d \nSessionTimeOut = %d\n",
+       PRINT_D(HOSTINF_DBG, "Opening Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\nBufferSize == %d\nSessionTimeOut = %d\n",
                strHostIfBASessionInfo->au8Bssid[0],
                strHostIfBASessionInfo->au8Bssid[1],
                strHostIfBASessionInfo->au8Bssid[2],
@@ -4233,7 +4213,7 @@ static s32 Handle_DelBASession(void *drvHandler, tstrHostIfBASessionInfo *strHos
        char *ptr = NULL;
        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
 
-       PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x \nTID=%d\n",
+       PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
                strHostIfBASessionInfo->au8Bssid[0],
                strHostIfBASessionInfo->au8Bssid[1],
                strHostIfBASessionInfo->au8Bssid[2],
@@ -4303,7 +4283,7 @@ static s32 Handle_DelAllRxBASessions(void *drvHandler, tstrHostIfBASessionInfo *
        char *ptr = NULL;
        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
 
-       PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x \nTID=%d\n",
+       PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
                strHostIfBASessionInfo->au8Bssid[0],
                strHostIfBASessionInfo->au8Bssid[1],
                strHostIfBASessionInfo->au8Bssid[2],
@@ -4430,9 +4410,8 @@ static int hostIFthread(void *pvArg)
 
                        /*BugID_5213*/
                        /*Allow chip sleep, only if both interfaces are not connected*/
-                       if (!linux_wlan_get_num_conn_ifcs()) {
+                       if (!linux_wlan_get_num_conn_ifcs())
                                chip_sleep_manually(INFINITE_SLEEP_TIME);
-                       }
 
                        Handle_ScanDone(strHostIFmsg.drvHandler, SCAN_EVENT_DONE);
 
@@ -4492,7 +4471,7 @@ static int hostIFthread(void *pvArg)
                        break;
 
                case HOST_IF_MSG_CONNECT_TIMER_FIRED:
-                       PRINT_D(HOSTINF_DBG, "Connect Timeout \n");
+                       PRINT_D(HOSTINF_DBG, "Connect Timeout\n");
                        Handle_ConnectTimeout(strHostIFmsg.drvHandler);
                        break;
 
@@ -4563,7 +4542,7 @@ static int hostIFthread(void *pvArg)
                        break;
 
                default:
-                       PRINT_ER("[Host Interface] undefined Received Msg ID  \n");
+                       PRINT_ER("[Host Interface] undefined Received Msg ID\n");
                        break;
                }
        }
@@ -4649,9 +4628,8 @@ s32 host_int_remove_wep_key(WILC_WFIDrvHandle hWFIDrv, u8 u8keyIdx)
        tstrHostIFmsg strHostIFmsg;
 
 
-       if (pstrWFIDrv == NULL) {
+       if (pstrWFIDrv == NULL)
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
-       }
 
        /* prepare the Remove Wep Key Message */
        WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
@@ -4670,7 +4648,7 @@ s32 host_int_remove_wep_key(WILC_WFIDrvHandle hWFIDrv, u8 u8keyIdx)
        /* send the message */
        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
        if (s32Error)
-               PRINT_ER("Error in sending message queue : Request to remove WEP key \n");
+               PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
        down(&(pstrWFIDrv->hSemTestKeyBlock));
 
        WILC_CATCH(s32Error)
@@ -4699,9 +4677,8 @@ s32 host_int_set_WEPDefaultKeyID(WILC_WFIDrvHandle hWFIDrv, u8 u8Index)
        tstrHostIFmsg strHostIFmsg;
 
 
-       if (pstrWFIDrv == NULL) {
+       if (pstrWFIDrv == NULL)
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
-       }
 
        /* prepare the Key Message */
        WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
@@ -4756,10 +4733,9 @@ s32 host_int_add_wep_key_bss_sta(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8WepKey,
        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
        tstrHostIFmsg strHostIFmsg;
 
-       if (pstrWFIDrv == NULL) {
+       if (pstrWFIDrv == NULL)
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
 
-       }
 
        /* prepare the Key Message */
        WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
@@ -4823,10 +4799,9 @@ s32 host_int_add_wep_key_bss_ap(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8WepKey,
        tstrHostIFmsg strHostIFmsg;
        u8 i;
 
-       if (pstrWFIDrv == NULL) {
+       if (pstrWFIDrv == NULL)
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
 
-       }
 
        /* prepare the Key Message */
        WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
@@ -4899,15 +4874,13 @@ s32 host_int_add_ptk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8Ptk, u8 u8PtkKeylen
        tstrHostIFmsg strHostIFmsg;
        u8 u8KeyLen = u8PtkKeylen;
        u32 i;
-       if (pstrWFIDrv == NULL) {
+
+       if (pstrWFIDrv == NULL)
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
-       }
-       if (pu8RxMic != NULL) {
+       if (pu8RxMic != NULL)
                u8KeyLen += RX_MIC_KEY_LEN;
-       }
-       if (pu8TxMic != NULL) {
+       if (pu8TxMic != NULL)
                u8KeyLen += TX_MIC_KEY_LEN;
-       }
 
        /* prepare the Key Message */
        WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
@@ -5002,19 +4975,16 @@ s32 host_int_add_rx_gtk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8RxGtk, u8 u8GtkK
        tstrHostIFmsg strHostIFmsg;
        u8 u8KeyLen = u8GtkKeylen;
 
-       if (pstrWFIDrv == NULL) {
+       if (pstrWFIDrv == NULL)
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
-       }
        /* prepare the Key Message */
        WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
 
 
-       if (pu8RxMic != NULL) {
+       if (pu8RxMic != NULL)
                u8KeyLen += RX_MIC_KEY_LEN;
-       }
-       if (pu8TxMic != NULL) {
+       if (pu8TxMic != NULL)
                u8KeyLen += TX_MIC_KEY_LEN;
-       }
        if (KeyRSC != NULL) {
                strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
                uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq = (u8 *)WILC_MALLOC(u32KeyRSClen);
@@ -5111,9 +5081,8 @@ s32 host_int_set_pmkid_info(WILC_WFIDrvHandle hWFIDrv, tstrHostIFpmkidAttr *pu8P
        u32 i;
 
 
-       if (pstrWFIDrv == NULL) {
+       if (pstrWFIDrv == NULL)
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
-       }
 
        /* prepare the Key Message */
        WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
@@ -5464,9 +5433,8 @@ s32 host_int_set_join_req(WILC_WFIDrvHandle hWFIDrv, u8 *pu8bssid,
        tstrHostIFmsg strHostIFmsg;
        tenuScanConnTimer enuScanConnTimer;
 
-       if (pstrWFIDrv == NULL || pfConnectResult == NULL) {
+       if (pstrWFIDrv == NULL || pfConnectResult == NULL)
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
-       }
 
        if (hWFIDrv == NULL) {
                PRINT_ER("Driver not initialized: gWFiDrvHandle = NULL\n");
@@ -5564,9 +5532,8 @@ s32 host_int_flush_join_req(WILC_WFIDrvHandle hWFIDrv)
        }
 
 
-       if (hWFIDrv  == NULL) {
+       if (hWFIDrv  == NULL)
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
-       }
 
 
        strHostIFmsg.u16MsgId = HOST_IF_MSG_FLUSH_CONNECT;
@@ -5604,7 +5571,7 @@ s32 host_int_disconnect(WILC_WFIDrvHandle hWFIDrv, u16 u16ReasonCode)
        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
 
        if (pstrWFIDrv == NULL) {
-               PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
+               PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
        }
 
@@ -5721,7 +5688,7 @@ s32 host_int_get_assoc_res_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocRespInfo,
        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
 
        if (pstrWFIDrv == NULL) {
-               PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
+               PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
        }
 
@@ -5800,9 +5767,8 @@ s32 host_int_set_mac_chnl_num(WILC_WFIDrvHandle hWFIDrv, u8 u8ChNum)
        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
        tstrHostIFmsg strHostIFmsg;
 
-       if (pstrWFIDrv == NULL) {
+       if (pstrWFIDrv == NULL)
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
-       }
 
        /* prepare the set channel message */
        WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
@@ -5811,9 +5777,8 @@ s32 host_int_set_mac_chnl_num(WILC_WFIDrvHandle hWFIDrv, u8 u8ChNum)
        strHostIFmsg.drvHandler = hWFIDrv;
 
        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
-       if (s32Error) {
+       if (s32Error)
                WILC_ERRORREPORT(s32Error, s32Error);
-       }
        WILC_CATCH(s32Error)
        {
 
@@ -5834,9 +5799,8 @@ s32 host_int_wait_msg_queue_idle(void)
        WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
        strHostIFmsg.u16MsgId = HOST_IF_MSG_Q_IDLE;
        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
-       if (s32Error) {
+       if (s32Error)
                WILC_ERRORREPORT(s32Error, s32Error);
-       }
        WILC_CATCH(s32Error)
        {
 
@@ -5864,9 +5828,8 @@ s32 host_int_set_wfi_drv_handler(u32 u32address)
        /* strHostIFmsg.drvHandler=hWFIDrv; */
 
        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
-       if (s32Error) {
+       if (s32Error)
                WILC_ERRORREPORT(s32Error, s32Error);
-       }
        WILC_CATCH(s32Error)
        {
 
@@ -5892,9 +5855,8 @@ s32 host_int_set_operation_mode(WILC_WFIDrvHandle hWFIDrv, u32 u32mode)
        strHostIFmsg.drvHandler = hWFIDrv;
 
        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
-       if (s32Error) {
+       if (s32Error)
                WILC_ERRORREPORT(s32Error, s32Error);
-       }
        WILC_CATCH(s32Error)
        {
 
@@ -5925,7 +5887,7 @@ s32 host_int_get_host_chnl_num(WILC_WFIDrvHandle hWFIDrv, u8 *pu8ChNo)
        tstrHostIFmsg strHostIFmsg;
 
        if (pstrWFIDrv == NULL) {
-               PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
+               PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
        }
 
@@ -5972,7 +5934,7 @@ s32 host_int_test_set_int_wid(WILC_WFIDrvHandle hWFIDrv, u32 u32TestMemAddr)
 
 
        if (pstrWFIDrv == NULL) {
-               PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
+               PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
        }
 
@@ -6018,7 +5980,7 @@ s32 host_int_get_inactive_time(WILC_WFIDrvHandle hWFIDrv, const u8 *mac, u32 *pu
        tstrHostIFmsg strHostIFmsg;
 
        if (pstrWFIDrv == NULL) {
-               PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
+               PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
        }
 
@@ -6066,7 +6028,7 @@ s32 host_int_test_get_int_wid(WILC_WFIDrvHandle hWFIDrv, u32 *pu32TestMemAddr)
 
 
        if (pstrWFIDrv == NULL) {
-               PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
+               PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
        }
 
@@ -6229,9 +6191,8 @@ s32 host_int_scan(WILC_WFIDrvHandle hWFIDrv, u8 u8ScanSource,
        tstrHostIFmsg strHostIFmsg;
        tenuScanConnTimer enuScanConnTimer;
 
-       if (pstrWFIDrv == NULL || ScanResult == NULL)   {
+       if (pstrWFIDrv == NULL || ScanResult == NULL)
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
-       }
 
 
        /* prepare the Scan Message */
@@ -6301,9 +6262,8 @@ s32 hif_set_cfg(WILC_WFIDrvHandle hWFIDrv, tstrCfgParamVal *pstrCfgParamVal)
        tstrHostIFmsg strHostIFmsg;
 
 
-       if (pstrWFIDrv == NULL) {
+       if (pstrWFIDrv == NULL)
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
-       }
        /* prepare the WiphyParams Message */
        WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
        strHostIFmsg.u16MsgId = HOST_IF_MSG_CFG_PARAMS;
@@ -6342,7 +6302,7 @@ s32 hif_get_cfg(WILC_WFIDrvHandle hWFIDrv, u16 u16WID, u16 *pu16WID_Value)
        down(&(pstrWFIDrv->gtOsCfgValuesSem));
 
        if (pstrWFIDrv == NULL) {
-               PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
+               PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
        }
        PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
@@ -6472,6 +6432,7 @@ void host_int_send_join_leave_info_to_host
 void GetPeriodicRSSI(void *pvArg)
 {
        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)pvArg;
+
        if (pstrWFIDrv == NULL) {
                PRINT_ER("Driver handler is NULL\n");
                return;
@@ -6738,18 +6699,18 @@ s32 host_int_deinit(WILC_WFIDrvHandle hWFIDrv)
        /*Destroy all timers before acquiring hSemDeinitDrvHandle*/
        /*to guarantee handling all messages befor proceeding*/
        if (WILC_TimerDestroy(&(pstrWFIDrv->hScanTimer), NULL)) {
-               PRINT_D(HOSTINF_DBG, ">> Scan timer is active \n");
+               PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
                /* msleep(HOST_IF_SCAN_TIMEOUT+1000); */
        }
 
        if (WILC_TimerDestroy(&(pstrWFIDrv->hConnectTimer), NULL)) {
-               PRINT_D(HOSTINF_DBG, ">> Connect timer is active \n");
+               PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
                /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
        }
 
 
        if (WILC_TimerDestroy(&(g_hPeriodicRSSI), NULL)) {
-               PRINT_D(HOSTINF_DBG, ">> Connect timer is active \n");
+               PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
                /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
        }
 
@@ -6786,7 +6747,7 @@ s32 host_int_deinit(WILC_WFIDrvHandle hWFIDrv)
 
        if (clients_count == 1) {
                if (WILC_TimerDestroy(&g_hPeriodicRSSI, NULL)) {
-                       PRINT_D(HOSTINF_DBG, ">> Connect timer is active \n");
+                       PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
                        /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
                }
                strHostIFmsg.u16MsgId = HOST_IF_MSG_EXIT;
@@ -6794,9 +6755,8 @@ s32 host_int_deinit(WILC_WFIDrvHandle hWFIDrv)
 
 
                s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
-               if (s32Error != WILC_SUCCESS) {
+               if (s32Error != WILC_SUCCESS)
                        PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error);
-               }
 
                down(&hSemHostIFthrdEnd);
 
@@ -6866,9 +6826,8 @@ void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
 
        /* send the message */
        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
-       if (s32Error) {
+       if (s32Error)
                PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error);
-       }
 
 
        return;
@@ -6897,7 +6856,7 @@ void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
 
        drvHandler = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
        pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
-       PRINT_D(HOSTINF_DBG, "General asynchronous info packet received \n");
+       PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
 
 
        if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
@@ -6930,9 +6889,8 @@ void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
 
        /* send the message */
        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
-       if (s32Error) {
+       if (s32Error)
                PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error);
-       }
 
        /*BugID_5348*/
        up(&hSemHostIntDeinit);
@@ -6954,15 +6912,15 @@ void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
        tstrHostIFmsg strHostIFmsg;
        u32 drvHandler;
        tstrWILC_WFIDrv *pstrWFIDrv = NULL;
+
        drvHandler = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
        pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
 
 
        PRINT_D(GENERIC_DBG, "Scan notification received %p\n", pstrWFIDrv);
 
-       if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
+       if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle)
                return;
-       }
 
        /*if there is an ongoing scan request*/
        if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
@@ -6983,9 +6941,8 @@ void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
 
                /* send the message */
                s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
-               if (s32Error) {
+               if (s32Error)
                        PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error);
-               }
        }
 
 
@@ -7014,9 +6971,8 @@ s32 host_int_remain_on_channel(WILC_WFIDrvHandle hWFIDrv, u32 u32SessionID, u32
        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
        tstrHostIFmsg strHostIFmsg;
 
-       if (pstrWFIDrv == NULL) {
+       if (pstrWFIDrv == NULL)
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
-       }
 
        /* prepare the remainonchan Message */
        WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
@@ -7032,9 +6988,8 @@ s32 host_int_remain_on_channel(WILC_WFIDrvHandle hWFIDrv, u32 u32SessionID, u32
        strHostIFmsg.drvHandler = hWFIDrv;
 
        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
-       if (s32Error) {
+       if (s32Error)
                WILC_ERRORREPORT(s32Error, s32Error);
-       }
        WILC_CATCH(s32Error)
        {
 
@@ -7063,9 +7018,8 @@ s32 host_int_ListenStateExpired(WILC_WFIDrvHandle hWFIDrv, u32 u32SessionID)
        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
        tstrHostIFmsg strHostIFmsg;
 
-       if (pstrWFIDrv == NULL) {
+       if (pstrWFIDrv == NULL)
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
-       }
 
        /*Stopping remain-on-channel timer*/
        WILC_TimerStop(&(pstrWFIDrv->hRemainOnChannel), NULL);
@@ -7077,9 +7031,8 @@ s32 host_int_ListenStateExpired(WILC_WFIDrvHandle hWFIDrv, u32 u32SessionID)
        strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = u32SessionID;
 
        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
-       if (s32Error) {
+       if (s32Error)
                WILC_ERRORREPORT(s32Error, s32Error);
-       }
        WILC_CATCH(s32Error)
        {
 
@@ -7101,9 +7054,8 @@ s32 host_int_frame_register(WILC_WFIDrvHandle hWFIDrv, u16 u16FrameType, bool bR
        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
        tstrHostIFmsg strHostIFmsg;
 
-       if (pstrWFIDrv == NULL) {
+       if (pstrWFIDrv == NULL)
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
-       }
 
        WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
 
@@ -7129,9 +7081,8 @@ s32 host_int_frame_register(WILC_WFIDrvHandle hWFIDrv, u16 u16FrameType, bool bR
        strHostIFmsg.drvHandler = hWFIDrv;
 
        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
-       if (s32Error) {
+       if (s32Error)
                WILC_ERRORREPORT(s32Error, s32Error);
-       }
        WILC_CATCH(s32Error)
        {
 
@@ -7165,9 +7116,8 @@ s32 host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
        tstrHostIFmsg strHostIFmsg;
        tstrHostIFSetBeacon *pstrSetBeaconParam = &strHostIFmsg.uniHostIFmsgBody.strHostIFSetBeacon;
 
-       if (pstrWFIDrv == NULL) {
+       if (pstrWFIDrv == NULL)
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
-       }
 
        WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
 
@@ -7181,37 +7131,32 @@ s32 host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
        pstrSetBeaconParam->u32DTIMPeriod = u32DTIMPeriod;
        pstrSetBeaconParam->u32HeadLen = u32HeadLen;
        pstrSetBeaconParam->pu8Head = (u8 *)WILC_MALLOC(u32HeadLen);
-       if (pstrSetBeaconParam->pu8Head == NULL) {
+       if (pstrSetBeaconParam->pu8Head == NULL)
                WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
-       }
        WILC_memcpy(pstrSetBeaconParam->pu8Head, pu8Head, u32HeadLen);
        pstrSetBeaconParam->u32TailLen = u32TailLen;
 
        /* Bug 4599 : if tail length = 0 skip allocating & copying */
        if (u32TailLen > 0) {
                pstrSetBeaconParam->pu8Tail = (u8 *)WILC_MALLOC(u32TailLen);
-               if (pstrSetBeaconParam->pu8Tail == NULL) {
+               if (pstrSetBeaconParam->pu8Tail == NULL)
                        WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
-               }
                WILC_memcpy(pstrSetBeaconParam->pu8Tail, pu8Tail, u32TailLen);
        } else {
                pstrSetBeaconParam->pu8Tail = NULL;
        }
 
        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
-       if (s32Error) {
+       if (s32Error)
                WILC_ERRORREPORT(s32Error, s32Error);
-       }
 
        WILC_CATCH(s32Error)
        {
-               if (pstrSetBeaconParam->pu8Head != NULL) {
+               if (pstrSetBeaconParam->pu8Head != NULL)
                        WILC_FREE(pstrSetBeaconParam->pu8Head);
-               }
 
-               if (pstrSetBeaconParam->pu8Tail != NULL) {
+               if (pstrSetBeaconParam->pu8Tail != NULL)
                        WILC_FREE(pstrSetBeaconParam->pu8Tail);
-               }
        }
 
        return s32Error;
@@ -7234,9 +7179,8 @@ s32 host_int_del_beacon(WILC_WFIDrvHandle hWFIDrv)
        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
        tstrHostIFmsg strHostIFmsg;
 
-       if (pstrWFIDrv == NULL) {
+       if (pstrWFIDrv == NULL)
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
-       }
 
        /* prepare the WiphyParams Message */
        strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_BEACON;
@@ -7270,9 +7214,8 @@ s32 host_int_add_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam *pstrSt
        tstrWILC_AddStaParam *pstrAddStationMsg = &strHostIFmsg.uniHostIFmsgBody.strAddStaParam;
 
 
-       if (pstrWFIDrv == NULL) {
+       if (pstrWFIDrv == NULL)
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
-       }
 
        WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
 
@@ -7286,6 +7229,7 @@ s32 host_int_add_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam *pstrSt
        WILC_memcpy(pstrAddStationMsg, pstrStaParams, sizeof(tstrWILC_AddStaParam));
        if (pstrAddStationMsg->u8NumRates > 0) {
                u8 *rates = WILC_MALLOC(pstrAddStationMsg->u8NumRates);
+
                WILC_NULLCHECK(s32Error, rates);
 
                WILC_memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
@@ -7294,9 +7238,8 @@ s32 host_int_add_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam *pstrSt
 
 
        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
-       if (s32Error) {
+       if (s32Error)
                WILC_ERRORREPORT(s32Error, s32Error);
-       }
 
        WILC_CATCH(s32Error)
        {
@@ -7320,9 +7263,8 @@ s32 host_int_del_station(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8MacAddr)
        tstrHostIFmsg strHostIFmsg;
        tstrHostIFDelSta *pstrDelStationMsg = &strHostIFmsg.uniHostIFmsgBody.strDelStaParam;
 
-       if (pstrWFIDrv == NULL) {
+       if (pstrWFIDrv == NULL)
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
-       }
 
        WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
 
@@ -7341,9 +7283,8 @@ s32 host_int_del_station(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8MacAddr)
                WILC_memcpy(pstrDelStationMsg->au8MacAddr, pu8MacAddr, ETH_ALEN);
 
        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
-       if (s32Error) {
+       if (s32Error)
                WILC_ERRORREPORT(s32Error, s32Error);
-       }
 
        WILC_CATCH(s32Error)
        {
@@ -7370,9 +7311,8 @@ s32 host_int_del_allstation(WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]
        u8 u8AssocNumb = 0;
 
 
-       if (pstrWFIDrv == NULL) {
+       if (pstrWFIDrv == NULL)
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
-       }
 
        WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
 
@@ -7400,10 +7340,9 @@ s32 host_int_del_allstation(WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]
        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
 
 
-       if (s32Error) {
+       if (s32Error)
                WILC_ERRORREPORT(s32Error, s32Error);
 
-       }
        WILC_CATCH(s32Error)
        {
 
@@ -7430,9 +7369,8 @@ s32 host_int_edit_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam *pstrS
        tstrHostIFmsg strHostIFmsg;
        tstrWILC_AddStaParam *pstrAddStationMsg = &strHostIFmsg.uniHostIFmsgBody.strAddStaParam;
 
-       if (pstrWFIDrv == NULL) {
+       if (pstrWFIDrv == NULL)
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
-       }
 
        PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
 
@@ -7446,15 +7384,15 @@ s32 host_int_edit_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam *pstrS
        WILC_memcpy(pstrAddStationMsg, pstrStaParams, sizeof(tstrWILC_AddStaParam));
        if (pstrAddStationMsg->u8NumRates > 0) {
                u8 *rates = WILC_MALLOC(pstrAddStationMsg->u8NumRates);
+
                WILC_NULLCHECK(s32Error, rates);
                WILC_memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
                pstrAddStationMsg->pu8Rates = rates;
        }
 
        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
-       if (s32Error) {
+       if (s32Error)
                WILC_ERRORREPORT(s32Error, s32Error);
-       }
        WILC_CATCH(s32Error)
        {
        }
@@ -7470,11 +7408,10 @@ s32 host_int_set_power_mgmt(WILC_WFIDrvHandle hWFIDrv, bool bIsEnabled, u32 u32T
        tstrHostIFmsg strHostIFmsg;
        tstrHostIfPowerMgmtParam *pstrPowerMgmtParam = &strHostIFmsg.uniHostIFmsgBody.strPowerMgmtparam;
 
-       PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d << \n\n", bIsEnabled);
+       PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled);
 
-       if (pstrWFIDrv == NULL) {
+       if (pstrWFIDrv == NULL)
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
-       }
 
        PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
 
@@ -7490,9 +7427,8 @@ s32 host_int_set_power_mgmt(WILC_WFIDrvHandle hWFIDrv, bool bIsEnabled, u32 u32T
 
 
        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
-       if (s32Error) {
+       if (s32Error)
                WILC_ERRORREPORT(s32Error, s32Error);
-       }
        WILC_CATCH(s32Error)
        {
        }
@@ -7508,9 +7444,8 @@ s32 host_int_setup_multicast_filter(WILC_WFIDrvHandle hWFIDrv, bool bIsEnabled,
        tstrHostIFSetMulti *pstrMulticastFilterParam = &strHostIFmsg.uniHostIFmsgBody.strHostIfSetMulti;
 
 
-       if (pstrWFIDrv == NULL) {
+       if (pstrWFIDrv == NULL)
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
-       }
 
        PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
 
@@ -7525,9 +7460,8 @@ s32 host_int_setup_multicast_filter(WILC_WFIDrvHandle hWFIDrv, bool bIsEnabled,
        pstrMulticastFilterParam->u32count = u32count;
 
        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
-       if (s32Error) {
+       if (s32Error)
                WILC_ERRORREPORT(s32Error, s32Error);
-       }
        WILC_CATCH(s32Error)
        {
        }
@@ -7633,9 +7567,8 @@ static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
                                pNewJoinBssParam->wmm_cap = true;
 
                                /* Check if Bit 7 is set indicating U-APSD capability */
-                               if (pu8IEs[index + 8] & (1 << 7)) {
+                               if (pu8IEs[index + 8] & (1 << 7))
                                        pNewJoinBssParam->uapsd_cap = true;
-                               }
                                index += pu8IEs[index + 1] + 2;
                                continue;
                        }
@@ -7645,6 +7578,7 @@ static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
                                 (pu8IEs[index + 4] == 0x9a) && /* OUI */
                                 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) { /* OUI Type     */
                                u16 u16P2P_count;
+
                                pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
                                pNewJoinBssParam->u8NoaEnbaled = 1;
                                pNewJoinBssParam->u8Index = pu8IEs[index + 9];
@@ -7656,9 +7590,9 @@ static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
                                } else
                                        pNewJoinBssParam->u8OppEnable = 0;
                                /* HOSTINF_DBG */
-                               PRINT_D(GENERIC_DBG, "P2P Dump \n");
+                               PRINT_D(GENERIC_DBG, "P2P Dump\n");
                                for (i = 0; i < pu8IEs[index + 7]; i++)
-                                       PRINT_D(GENERIC_DBG, " %x \n", pu8IEs[index + 9 + i]);
+                                       PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
 
                                pNewJoinBssParam->u8Count = pu8IEs[index + 11];
                                u16P2P_count = index + 12;
@@ -7698,7 +7632,7 @@ static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
                                rsnIndex += 7; /* skipping id, length, version(2B) and first 3 bytes of gcipher */
                                pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
                                rsnIndex++;
-                               /* PRINT_D(HOSTINF_DBG,"Group Policy: %0x \n",pNewJoinBssParam->rsn_grp_policy); */
+                               /* PRINT_D(HOSTINF_DBG,"Group Policy: %0x\n",pNewJoinBssParam->rsn_grp_policy); */
                                /* initialize policies with invalid values */
 
                                jumpOffset = pu8IEs[rsnIndex] * 4; /* total no.of bytes of pcipher field (count*4) */
@@ -7709,7 +7643,7 @@ static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
                                pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
                                rsnIndex += 2; /* jump 2 bytes of pcipher count */
 
-                               /* PRINT_D(HOSTINF_DBG,"\npcipher:%d \n",pcipherCount); */
+                               /* PRINT_D(HOSTINF_DBG,"\npcipher:%d\n",pcipherCount); */
                                for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) {
                                        /* each count corresponds to 4 bytes, only last byte is saved */
                                        pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
@@ -7779,9 +7713,8 @@ static int host_int_addBASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char T
        tstrHostIFmsg strHostIFmsg;
        tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo;
 
-       if (pstrWFIDrv == NULL) {
+       if (pstrWFIDrv == NULL)
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
-       }
 
        WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
 
@@ -7795,9 +7728,8 @@ static int host_int_addBASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char T
        strHostIFmsg.drvHandler = hWFIDrv;
 
        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
-       if (s32Error) {
+       if (s32Error)
                WILC_ERRORREPORT(s32Error, s32Error);
-       }
        WILC_CATCH(s32Error)
        {
 
@@ -7814,9 +7746,8 @@ s32 host_int_delBASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char TID)
        tstrHostIFmsg strHostIFmsg;
        tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo;
 
-       if (pstrWFIDrv == NULL) {
+       if (pstrWFIDrv == NULL)
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
-       }
 
        WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
 
@@ -7828,9 +7759,8 @@ s32 host_int_delBASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char TID)
        strHostIFmsg.drvHandler = hWFIDrv;
 
        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
-       if (s32Error) {
+       if (s32Error)
                WILC_ERRORREPORT(s32Error, s32Error);
-       }
        WILC_CATCH(s32Error)
        {
 
@@ -7849,9 +7779,8 @@ s32 host_int_del_All_Rx_BASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char
        tstrHostIFmsg strHostIFmsg;
        tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo;
 
-       if (pstrWFIDrv == NULL) {
+       if (pstrWFIDrv == NULL)
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
-       }
 
        WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
 
@@ -7863,9 +7792,8 @@ s32 host_int_del_All_Rx_BASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char
        strHostIFmsg.drvHandler = hWFIDrv;
 
        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
-       if (s32Error) {
+       if (s32Error)
                WILC_ERRORREPORT(s32Error, s32Error);
-       }
        WILC_CATCH(s32Error)
        {
 
@@ -7894,9 +7822,8 @@ s32 host_int_setup_ipaddress(WILC_WFIDrvHandle hWFIDrv, u8 *u16ipadd, u8 idx)
        /* TODO: Enable This feature on softap firmware */
        return 0;
 
-       if (pstrWFIDrv == NULL) {
+       if (pstrWFIDrv == NULL)
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
-       }
 
        WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
 
@@ -7908,9 +7835,8 @@ s32 host_int_setup_ipaddress(WILC_WFIDrvHandle hWFIDrv, u8 *u16ipadd, u8 idx)
        strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx = idx;
 
        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
-       if (s32Error) {
+       if (s32Error)
                WILC_ERRORREPORT(s32Error, s32Error);
-       }
        WILC_CATCH(s32Error)
        {
 
@@ -7935,9 +7861,8 @@ s32 host_int_get_ipaddress(WILC_WFIDrvHandle hWFIDrv, u8 *u16ipadd, u8 idx)
        tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
        tstrHostIFmsg strHostIFmsg;
 
-       if (pstrWFIDrv == NULL) {
+       if (pstrWFIDrv == NULL)
                WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
-       }
 
        WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
 
@@ -7945,13 +7870,12 @@ s32 host_int_get_ipaddress(WILC_WFIDrvHandle hWFIDrv, u8 *u16ipadd, u8 idx)
        strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_IPADDRESS;
 
        strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr = u16ipadd;
-       strHostIFmsg.drvHandler=hWFIDrv;
-       strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx= idx;
+       strHostIFmsg.drvHandler = hWFIDrv;
+       strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx = idx;
 
        s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
-       if (s32Error) {
+       if (s32Error)
                WILC_ERRORREPORT(s32Error, s32Error);
-       }
        WILC_CATCH(s32Error)
        {
 
index f5296f5..d812a3b 100644 (file)
@@ -237,14 +237,12 @@ static void mgmt_tx_complete(void *priv, int status)
 }
 static int mon_mgmt_tx(struct net_device *dev, const u8 *buf, size_t len)
 {
-       linux_wlan_t *nic;
        struct tx_complete_mon_data *mgmt_tx = NULL;
 
        if (dev == NULL) {
                PRINT_D(HOSTAPD_DBG, "ERROR: dev == NULL\n");
                return WILC_FAIL;
        }
-       nic = netdev_priv(dev);
 
        netif_stop_queue(dev);
        mgmt_tx = kmalloc(sizeof(struct tx_complete_mon_data), GFP_ATOMIC);
@@ -298,7 +296,6 @@ static int mon_mgmt_tx(struct net_device *dev, const u8 *buf, size_t len)
 static netdev_tx_t WILC_WFI_mon_xmit(struct sk_buff *skb,
                                     struct net_device *dev)
 {
-       struct ieee80211_radiotap_header *rtap_hdr;
        u32 rtap_len, i, ret = 0;
        struct WILC_WFI_mon_priv  *mon_priv;
 
@@ -318,7 +315,6 @@ static netdev_tx_t WILC_WFI_mon_xmit(struct sk_buff *skb,
                return WILC_FAIL;
        }
 
-       rtap_hdr = (struct ieee80211_radiotap_header *)skb->data;
 
        rtap_len = ieee80211_get_radiotap_len(skb->data);
        if (skb->len < rtap_len) {
@@ -495,7 +491,7 @@ static void WILC_WFI_mon_setup(struct net_device *dev)
        ether_setup(dev);
        dev->tx_queue_len = 0;
        dev->type = ARPHRD_IEEE80211_RADIOTAP;
-       memset(dev->dev_addr, 0, ETH_ALEN);
+       eth_zero_addr(dev->dev_addr);
 
        #ifdef USE_WIRELESS
        {
index b352c50..5a794df 100644 (file)
@@ -868,7 +868,6 @@ static int linux_wlan_txq_task(void *vp)
 #define TX_BACKOFF_WEIGHT_MIN (0)
 #define TX_BACKOFF_WEIGHT_UNIT_MS (10)
        int backoff_weight = TX_BACKOFF_WEIGHT_MIN;
-       signed long timeout;
 #endif
 
        /* inform wilc1000_wlan_init that TXQ task is started. */
@@ -906,7 +905,6 @@ static int linux_wlan_txq_task(void *vp)
                        }
 
                        if (ret == WILC_TX_ERR_NO_BUF) { /* failed to allocate buffers in chip. */
-                               timeout = msecs_to_jiffies(TX_BACKOFF_WEIGHT_UNIT_MS << backoff_weight);
                                do {
                                        /* Back off from sending packets for some time. */
                                        /* schedule_timeout will allow RX task to run and free buffers.*/
index 92064db..1d0b7f8 100644 (file)
@@ -144,9 +144,7 @@ bool g_wep_keys_saved = false;
 
 void clear_shadow_scan(void *pUserVoid)
 {
-       struct WILC_WFI_priv *priv;
        int i;
-       priv = (struct WILC_WFI_priv *)pUserVoid;
        if (op_ifcs == 0) {
                WILC_TimerDestroy(&hAgingTimer, NULL);
                PRINT_INFO(CORECONFIG_DBG, "destroy aging timer\n");
@@ -219,9 +217,7 @@ void refresh_scan(void *pUserVoid, uint8_t all, bool bDirectScan)
 
 void reset_shadow_found(void *pUserVoid)
 {
-       struct WILC_WFI_priv *priv;
        int i;
-       priv = (struct WILC_WFI_priv *)pUserVoid;
        for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
                astrLastScannedNtwrksShadow[i].u8Found = 0;
 
@@ -230,9 +226,7 @@ void reset_shadow_found(void *pUserVoid)
 
 void update_scan_time(void *pUserVoid)
 {
-       struct WILC_WFI_priv *priv;
        int i;
-       priv = (struct WILC_WFI_priv *)pUserVoid;
        for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
                astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan = jiffies;
        }
@@ -240,11 +234,9 @@ void update_scan_time(void *pUserVoid)
 
 void remove_network_from_shadow(void *pUserVoid)
 {
-       struct WILC_WFI_priv *priv;
        unsigned long now = jiffies;
        int i, j;
 
-       priv = (struct WILC_WFI_priv *)pUserVoid;
 
        for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
                if (time_after(now, astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan + (unsigned long)(SCAN_RESULT_EXPIRE))) {
@@ -281,11 +273,9 @@ void clear_duringIP(void *pUserVoid)
 
 int8_t is_network_in_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid)
 {
-       struct WILC_WFI_priv *priv;
        int8_t state = -1;
        int i;
 
-       priv = (struct WILC_WFI_priv *)pUserVoid;
        if (u32LastScannedNtwrksCountShadow == 0) {
                PRINT_D(CFG80211_DBG, "Starting Aging timer\n");
                WILC_TimerStart(&(hAgingTimer), AGING_TIME, pUserVoid, NULL);
@@ -305,11 +295,9 @@ int8_t is_network_in_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid)
 
 void add_network_to_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams)
 {
-       struct WILC_WFI_priv *priv;
        int8_t ap_found = is_network_in_shadow(pstrNetworkInfo, pUserVoid);
        uint32_t ap_index = 0;
        uint8_t rssi_index = 0;
-       priv = (struct WILC_WFI_priv *)pUserVoid;
 
        if (u32LastScannedNtwrksCountShadow >= MAX_NUM_SCANNED_NETWORKS_SHADOW) {
                PRINT_D(CFG80211_DBG, "Shadow network reached its maximum limit\n");
@@ -675,7 +663,8 @@ static void CfgConnectResult(tenuConnDisconnEvent enuConnDisconnEvent,
                        pstrDisconnectNotifInfo->u16reason = 1;
                }
                cfg80211_disconnected(dev, pstrDisconnectNotifInfo->u16reason, pstrDisconnectNotifInfo->ie,
-                                     pstrDisconnectNotifInfo->ie_len, GFP_KERNEL);
+                                     pstrDisconnectNotifInfo->ie_len, false,
+                                     GFP_KERNEL);
 
        }
 
index ab66ce4..af9b858 100644 (file)
 #include "wilc_wfi_cfgoperations.h"
 #include "host_interface.h"
 
-
 MODULE_AUTHOR("Mai Daftedar");
 MODULE_LICENSE("Dual BSD/GPL");
 
-
 struct net_device *WILC_WFI_devs[2];
 
 /*
@@ -31,10 +29,9 @@ module_param(timeout, int, 0);
 /*
  * Do we run in NAPI mode?
  */
-static int use_napi ;
+static int use_napi;
 module_param(use_napi, int, 0);
 
-
 /*
  * A structure representing an in-flight packet.
  */
@@ -45,12 +42,9 @@ struct WILC_WFI_packet {
        u8 data[ETH_DATA_LEN];
 };
 
-
-
 int pool_size = 8;
 module_param(pool_size, int, 0);
 
-
 static void WILC_WFI_TxTimeout(struct net_device *dev);
 static void (*WILC_WFI_Interrupt)(int, void *, struct pt_regs *);
 
@@ -71,7 +65,7 @@ void WILC_WFI_SetupPool(struct net_device *dev)
 
        priv->ppool = NULL;
        for (i = 0; i < pool_size; i++) {
-               pkt = kmalloc (sizeof (struct WILC_WFI_packet), GFP_KERNEL);
+               pkt = kmalloc(sizeof(struct WILC_WFI_packet), GFP_KERNEL);
                if (pkt == NULL) {
                        PRINT_D(RX_DBG, "Ran out of memory allocating packet pool\n");
                        return;
@@ -99,7 +93,7 @@ void WILC_WFI_TearDownPool(struct net_device *dev)
 
        while ((pkt = priv->ppool)) {
                priv->ppool = pkt->next;
-               kfree (pkt);
+               kfree(pkt);
                /* FIXME - in-flight packets ? */
        }
 }
@@ -207,6 +201,7 @@ struct WILC_WFI_packet *WILC_WFI_DequeueBuf(struct net_device *dev)
 static void WILC_WFI_RxInts(struct net_device *dev, int enable)
 {
        struct WILC_WFI_priv *priv = netdev_priv(dev);
+
        priv->rx_int_enabled = enable;
 }
 
@@ -251,7 +246,6 @@ int WILC_WFI_Open(struct net_device *dev)
 int WILC_WFI_Release(struct net_device *dev)
 {
        /* release ports, irq and such -- like fops->close */
-
        netif_stop_queue(dev); /* can't transmit any more */
 
        return 0;
@@ -324,7 +318,6 @@ void WILC_WFI_Rx(struct net_device *dev, struct WILC_WFI_packet *pkt)
                PRINT_INFO(RX_DBG, "In monitor device name %s\n", dev->name);
                priv = wiphy_priv(priv->dev->ieee80211_ptr->wiphy);
                PRINT_D(RX_DBG, "VALUE PASSED IN OF HRWD %p\n", priv->hWILCWFIDrv);
-               /* host_int_get_rssi(priv->hWILCWFIDrv, &(rssi)); */
                if (INFO) {
                        for (i = 14; i < skb->len; i++)
                                PRINT_INFO(RX_DBG, "RXdata[%d] %02x\n", i, skb->data[i]);
@@ -512,7 +505,6 @@ void WILC_WFI_HwTx(char *buf, int len, struct net_device *dev)
        u32 *saddr, *daddr;
        struct WILC_WFI_packet *tx_buffer;
 
-
        /* I am paranoid. Ain't I? */
        if (len < sizeof(struct ethhdr) + sizeof(struct iphdr)) {
                PRINT_D(RX_DBG, "WILC_WFI: Hmm... packet too short (%i octets)\n",
@@ -522,6 +514,7 @@ void WILC_WFI_HwTx(char *buf, int len, struct net_device *dev)
 
        if (0) {  /* enable this conditional to look at the data */
                int i;
+
                PRINT_D(RX_DBG, "len is %i", len);
                for (i = 14; i < len; i++)
                        PRINT_D(RX_DBG, "TXdata[%d] %02x\n", i, buf[i] & 0xff);
@@ -579,7 +572,6 @@ void WILC_WFI_HwTx(char *buf, int len, struct net_device *dev)
                        (unsigned long) priv->stats.tx_packets);
        } else
                WILC_WFI_Interrupt(0, dev, NULL);
-
 }
 
 /**
@@ -598,12 +590,6 @@ int WILC_WFI_Tx(struct sk_buff *skb, struct net_device *dev)
        char *data, shortpkt[ETH_ZLEN];
        struct WILC_WFI_priv *priv = netdev_priv(dev);
 
-       /* priv = wiphy_priv(priv->dev->ieee80211_ptr->wiphy); */
-
-       /*  if(priv->monitor_flag) */
-       /*       mac80211_hwsim_monitor_rx(skb); */
-
-
        data = skb->data;
        len = skb->len;
 
@@ -677,6 +663,7 @@ int WILC_WFI_Ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 struct net_device_stats *WILC_WFI_Stats(struct net_device *dev)
 {
        struct WILC_WFI_priv *priv = netdev_priv(dev);
+
        return &priv->stats;
 }
 
@@ -789,7 +776,6 @@ void WILC_WFI_Init(struct net_device *dev)
 {
        struct WILC_WFI_priv *priv;
 
-
        /*
         * Then, assign other fields in dev, using ether_setup() and some
         * hand assignments
@@ -833,12 +819,6 @@ void WILC_WFI_Cleanup(void)
        int i;
        struct WILC_WFI_priv *priv[2];
 
-       /*if(hwsim_mon!=NULL)
-        * {
-        *      PRINT_D(RX_DBG, "Freeing monitor interface\n");
-        *      unregister_netdev(hwsim_mon);
-        *      free_netdev(hwsim_mon);
-        * }*/
        for (i = 0; i < 2; i++) {
                priv[i] = netdev_priv(WILC_WFI_devs[i]);
 
@@ -861,12 +841,6 @@ void WILC_WFI_Cleanup(void)
 
 void StartConfigSim(void);
 
-
-
-
-
-
-
 /**
  *  @brief      WILC_WFI_Stat
  *  @details    Return statistics to the caller
@@ -883,17 +857,15 @@ int WILC_WFI_InitModule(void)
        int result, i, ret = -ENOMEM;
        struct WILC_WFI_priv *priv[2], *netpriv;
        struct wireless_dev *wdev;
+
        WILC_WFI_Interrupt = use_napi ? WILC_WFI_NapiInterrupt : WILC_WFI_RegularInterrupt;
-       char buf[IFNAMSIZ];
 
        for (i = 0; i < 2; i++) {
-
                /* Allocate the net devices */
                WILC_WFI_devs[i] = alloc_netdev(sizeof(struct WILC_WFI_priv), "wlan%d",
                                                WILC_WFI_Init);
                if (WILC_WFI_devs[i] == NULL)
                        goto out;
-               /* priv[i] = netdev_priv(WILC_WFI_devs[i]); */
 
                wdev = WILC_WFI_WiphyRegister(WILC_WFI_devs[i]);
                WILC_WFI_devs[i]->ieee80211_ptr = wdev;
@@ -911,30 +883,17 @@ int WILC_WFI_InitModule(void)
                        ret = 0;
        }
 
-
        /*init atmel driver */
        priv[0] = netdev_priv(WILC_WFI_devs[0]);
        priv[1] = netdev_priv(WILC_WFI_devs[1]);
 
-       if (priv[1]->dev->ieee80211_ptr->wiphy->interface_modes && BIT(NL80211_IFTYPE_MONITOR)) {
-               /* snprintf(buf, IFNAMSIZ, "mon.%s",  priv[1]->dev->name); */
-               /*      WILC_WFI_init_mon_interface(); */
-               /*      priv[1]->monitor_flag = 1; */
-
-       }
        priv[0]->bCfgScanning = false;
        priv[0]->u32RcvdChCount = 0;
 
        WILC_memset(priv[0]->au8AssociatedBss, 0xFF, ETH_ALEN);
 
-
-       /* ret = host_int_init(&priv[0]->hWILCWFIDrv); */
-       /*copy handle to the other driver*/
-       /* priv[1]->hWILCWFIDrv = priv[0]->hWILCWFIDrv; */
-       if (ret) {
+       if (ret)
                PRINT_ER("Error Init Driver\n");
-       }
-
 
 out:
        if (ret)
@@ -944,7 +903,6 @@ out:
 
 }
 
-
 module_init(WILC_WFI_InitModule);
 module_exit(WILC_WFI_Cleanup);
 
index d413fa3..0dfe108 100644 (file)
@@ -77,12 +77,12 @@ struct WILC_WFI_stats {
 #define num_reg_frame 2
 /*
  * If you use RX_BH_WORK_QUEUE on LPC3131: You may lose the first interrupt on
- * LPC3131 which is important to get the MAC start status when you are blocked inside
- * linux_wlan_firmware_download() which blocks mac_open().
+ * LPC3131 which is important to get the MAC start status when you are blocked
+ * inside linux_wlan_firmware_download() which blocks mac_open().
  */
-#if defined (NM73131_0_BOARD)
+#if defined(NM73131_0_BOARD)
  #define RX_BH_TYPE  RX_BH_KTHREAD
-#elif defined (PANDA_BOARD)
+#elif defined(PANDA_BOARD)
  #define RX_BH_TYPE  RX_BH_THREADED_IRQ
 #else
  #define RX_BH_TYPE  RX_BH_KTHREAD
@@ -95,6 +95,7 @@ struct wilc_wfi_key {
        int seq_len;
        u32 cipher;
 };
+
 struct wilc_wfi_wep_key {
        u8 *key;
        u8 key_len;
@@ -150,7 +151,8 @@ struct WILC_WFI_priv {
        u8 WILC_WFI_wep_default;
        u8 WILC_WFI_wep_key[4][WLAN_KEY_LEN_WEP104];
        u8 WILC_WFI_wep_key_len[4];
-       struct net_device *real_ndev;   /* The real interface that the monitor is on */
+       /* The real interface that the monitor is on */
+       struct net_device *real_ndev;
        struct wilc_wfi_key *wilc_gtk[MAX_NUM_STA];
        struct wilc_wfi_key *wilc_ptk[MAX_NUM_STA];
        u8 wilc_groupkey;
index 3af91f7..def72fd 100644 (file)
@@ -118,11 +118,10 @@ static void wilc_debug(uint32_t flag, char *fmt, ...)
 {
        char buf[256];
        va_list args;
-       int len;
 
        if (flag & dbgflag) {
                va_start(args, fmt);
-               len = vsprintf(buf, fmt, args);
+               vsprintf(buf, fmt, args);
                va_end(args);
 
                if (g_wlan.os_func.os_debug)
@@ -1782,7 +1781,7 @@ static int wilc_wlan_stop(void)
 /******************************************************************************/
        reg = ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 8) | (1 << 9) | (1 << 26) | (1 << 29) | (1 << 30) | (1 << 31)); /**/
        /**/
-       ret = p->hif_func.hif_write_reg(WILC_GLB_RESET_0, reg);                                 /**/
+       p->hif_func.hif_write_reg(WILC_GLB_RESET_0, reg);                                 /**/
        reg = ~(1 << 10);                                                                                               /**/
        /**/
        ret = p->hif_func.hif_write_reg(WILC_GLB_RESET_0, reg);                                 /**/
index 3cffe55..04d0327 100644 (file)
@@ -513,7 +513,6 @@ static int wilc_wlan_cfg_indicate_rx(uint8_t *frame, int size, wilc_cfg_rsp_t *r
        int ret = 1;
        uint8_t msg_type;
        uint8_t msg_id;
-       uint16_t msg_len;
        #ifdef WILC_FULLY_HOSTING_AP
        u32 *ptru32Frame;
        bool bStatus = frame[2];
@@ -528,11 +527,6 @@ static int wilc_wlan_cfg_indicate_rx(uint8_t *frame, int size, wilc_cfg_rsp_t *r
 
        msg_type = frame[0];
        msg_id = frame[1];      /* seq no */
-#ifdef BIG_ENDIAN
-       msg_len = (frame[2] << 8) | frame[3];
-#else
-       msg_len = (frame[3] << 8) | frame[2];
-#endif
        frame += 4;
        size -= 4;
 
index 8ed51e3..8735a6a 100644 (file)
@@ -43,8 +43,8 @@
  ********************************************/
 
 #define HIF_SDIO           (0)
-#define HIF_SPI            (1 << 0)
-#define HIF_SDIO_GPIO_IRQ  (1 << 2)
+#define HIF_SPI            BIT(0)
+#define HIF_SDIO_GPIO_IRQ  BIT(2)
 
 
 /********************************************
index 55e5199..964a843 100644 (file)
@@ -1,4 +1,4 @@
 obj-$(CONFIG_FB_XGI)  += xgifb.o
 
-xgifb-y := XGI_main_26.o vb_init.o vb_setmode.o vb_util.o
+xgifb-y := XGI_main_26.o vb_init.o vb_setmode.o
 
index 943d463..5bfe151 100644 (file)
@@ -18,8 +18,8 @@
 #define Index_CR_GPIO_Reg1 0x48
 #define Index_CR_GPIO_Reg3 0x4a
 
-#define GPIOG_EN    (1<<6)
-#define GPIOG_READ  (1<<1)
+#define GPIOG_EN    BIT(6)
+#define GPIOG_READ  BIT(1)
 
 static char *forcecrt2type;
 static char *mode;
diff --git a/drivers/staging/xgifb/vb_util.c b/drivers/staging/xgifb/vb_util.c
deleted file mode 100644 (file)
index be3437c..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-#include "vgatypes.h"
-#include "vb_util.h"
-
-void xgifb_reg_set(unsigned long port, u8 index, u8 data)
-{
-       outb(index, port);
-       outb(data, port + 1);
-}
-
-u8 xgifb_reg_get(unsigned long port, u8 index)
-{
-       outb(index, port);
-       return inb(port + 1);
-}
-
-void xgifb_reg_and_or(unsigned long port, u8 index,
-               unsigned data_and, unsigned data_or)
-{
-       u8 temp;
-
-       temp = xgifb_reg_get(port, index); /* XGINew_Part1Port index 02 */
-       temp = (temp & data_and) | data_or;
-       xgifb_reg_set(port, index, temp);
-}
-
-void xgifb_reg_and(unsigned long port, u8 index, unsigned data_and)
-{
-       u8 temp;
-
-       temp = xgifb_reg_get(port, index); /* XGINew_Part1Port index 02 */
-       temp &= data_and;
-       xgifb_reg_set(port, index, temp);
-}
-
-void xgifb_reg_or(unsigned long port, u8 index, unsigned data_or)
-{
-       u8 temp;
-
-       temp = xgifb_reg_get(port, index); /* XGINew_Part1Port index 02 */
-       temp |= data_or;
-       xgifb_reg_set(port, index, temp);
-}
index 9161de1..7bd395f 100644 (file)
@@ -1,9 +1,43 @@
 #ifndef _VBUTIL_
 #define _VBUTIL_
-extern void xgifb_reg_set(unsigned long, u8, u8);
-extern u8 xgifb_reg_get(unsigned long, u8);
-extern void xgifb_reg_or(unsigned long, u8, unsigned);
-extern void xgifb_reg_and(unsigned long, u8, unsigned);
-extern void xgifb_reg_and_or(unsigned long, u8, unsigned, unsigned);
+static inline void xgifb_reg_set(unsigned long port, u8 index, u8 data)
+{
+       outb(index, port);
+       outb(data, port + 1);
+}
+
+static inline u8 xgifb_reg_get(unsigned long port, u8 index)
+{
+       outb(index, port);
+       return inb(port + 1);
+}
+
+static inline void xgifb_reg_and_or(unsigned long port, u8 index,
+                                   unsigned data_and, unsigned data_or)
+{
+       u8 temp;
+
+       temp = xgifb_reg_get(port, index);
+       temp = (temp & data_and) | data_or;
+       xgifb_reg_set(port, index, temp);
+}
+
+static inline void xgifb_reg_and(unsigned long port, u8 index, unsigned data_and)
+{
+       u8 temp;
+
+       temp = xgifb_reg_get(port, index);
+       temp &= data_and;
+       xgifb_reg_set(port, index, temp);
+}
+
+static inline void xgifb_reg_or(unsigned long port, u8 index, unsigned data_or)
+{
+       u8 temp;
+
+       temp = xgifb_reg_get(port, index);
+       temp |= data_or;
+       xgifb_reg_set(port, index, temp);
+}
 #endif
 
index c378ebe..f72f70d 100644 (file)
@@ -7,8 +7,8 @@ struct iio_dev;
 struct iio_buffer_setup_ops;
 
 int iio_triggered_buffer_setup(struct iio_dev *indio_dev,
-       irqreturn_t (*pollfunc_bh)(int irq, void *p),
-       irqreturn_t (*pollfunc_th)(int irq, void *p),
+       irqreturn_t (*h)(int irq, void *p),
+       irqreturn_t (*thread)(int irq, void *p),
        const struct iio_buffer_setup_ops *setup_ops);
 void iio_triggered_buffer_cleanup(struct iio_dev *indio_dev);
 
index 4eebb66..0e73723 100644 (file)
@@ -51,14 +51,33 @@ int size_from_channelarray(struct iio_channel_info *channels, int num_channels)
                if (bytes % channels[i].bytes == 0)
                        channels[i].location = bytes;
                else
-                       channels[i].location = bytes - bytes%channels[i].bytes
-                               + channels[i].bytes;
+                       channels[i].location = bytes - bytes % channels[i].bytes
+                                              + channels[i].bytes;
+
                bytes = channels[i].location + channels[i].bytes;
                i++;
        }
+
        return bytes;
 }
 
+void print1byte(uint8_t input, struct iio_channel_info *info)
+{
+       /*
+        * Shift before conversion to avoid sign extension
+        * of left aligned data
+        */
+       input >>= info->shift;
+       input &= info->mask;
+       if (info->is_signed) {
+               int8_t val = (int8_t)(input << (8 - info->bits_used)) >>
+                            (8 - info->bits_used);
+               printf("%05f ", ((float)val + info->offset) * info->scale);
+       } else {
+               printf("%05f ", ((float)input + info->offset) * info->scale);
+       }
+}
+
 void print2byte(uint16_t input, struct iio_channel_info *info)
 {
        /* First swap if incorrect endian */
@@ -136,9 +155,9 @@ void print8byte(uint64_t input, struct iio_channel_info *info)
 /**
  * process_scan() - print out the values in SI units
  * @data:              pointer to the start of the scan
- * @channels:          information about the channels. Note
- *  size_from_channelarray must have been called first to fill the
- *  location offsets.
+ * @channels:          information about the channels.
+ *                     Note: size_from_channelarray must have been called first
+ *                           to fill the location offsets.
  * @num_channels:      number of channels
  **/
 void process_scan(char *data,
@@ -150,6 +169,10 @@ void process_scan(char *data,
        for (k = 0; k < num_channels; k++)
                switch (channels[k].bytes) {
                        /* only a few cases implemented so far */
+               case 1:
+                       print1byte(*(uint8_t *)(data + channels[k].location),
+                                  &channels[k]);
+                       break;
                case 2:
                        print2byte(*(uint16_t *)(data + channels[k].location),
                                   &channels[k]);
@@ -213,6 +236,7 @@ int main(int argc, char **argv)
                        num_loops = strtoul(optarg, &dummy, 10);
                        if (errno)
                                return -errno;
+
                        break;
                case 'e':
                        noevents = 1;
@@ -225,6 +249,7 @@ int main(int argc, char **argv)
                        buf_len = strtoul(optarg, &dummy, 10);
                        if (errno)
                                return -errno;
+
                        break;
                case 'n':
                        device_name = optarg;
@@ -257,6 +282,7 @@ int main(int argc, char **argv)
                printf("Failed to find the %s\n", device_name);
                return dev_num;
        }
+
        printf("iio device number being used is %d\n", dev_num);
 
        ret = asprintf(&dev_dir_name, "%siio:device%d", iio_dir, dev_num);
@@ -285,9 +311,11 @@ int main(int argc, char **argv)
                        ret = trig_num;
                        goto error_free_triggername;
                }
+
                printf("iio trigger number being used is %d\n", trig_num);
-       } else
+       } else {
                printf("trigger-less mode selected\n");
+       }
 
        /*
         * Parse the files in scan_elements to identify what channels are
@@ -314,8 +342,10 @@ int main(int argc, char **argv)
 
        if (!notrigger) {
                printf("%s %s\n", dev_dir_name, trigger_name);
-               /* Set the device trigger to be the data ready trigger found
-                * above */
+               /*
+                * Set the device trigger to be the data ready trigger found
+                * above
+                */
                ret = write_sysfs_string_and_verify("trigger/current_trigger",
                                                    dev_dir_name,
                                                    trigger_name);
@@ -334,8 +364,9 @@ int main(int argc, char **argv)
        ret = write_sysfs_int("enable", buf_dir_name, 1);
        if (ret < 0)
                goto error_free_buf_dir_name;
+
        scan_size = size_from_channelarray(channels, num_channels);
-       data = malloc(scan_size*buf_len);
+       data = malloc(scan_size * buf_len);
        if (!data) {
                ret = -ENOMEM;
                goto error_free_buf_dir_name;
@@ -349,13 +380,12 @@ int main(int argc, char **argv)
 
        /* Attempt to open non blocking the access dev */
        fp = open(buffer_access, O_RDONLY | O_NONBLOCK);
-       if (fp == -1) { /* If it isn't there make the node */
+       if (fp == -1) { /* TODO: If it isn't there make the node */
                ret = -errno;
                printf("Failed to open %s\n", buffer_access);
                goto error_free_buffer_access;
        }
 
-       /* Wait for events 10 times */
        for (j = 0; j < num_loops; j++) {
                if (!noevents) {
                        struct pollfd pfd = {
@@ -372,25 +402,22 @@ int main(int argc, char **argv)
                        }
 
                        toread = buf_len;
-
                } else {
                        usleep(timedelay);
                        toread = 64;
                }
 
-               read_size = read(fp,
-                                data,
-                                toread*scan_size);
+               read_size = read(fp, data, toread * scan_size);
                if (read_size < 0) {
                        if (errno == EAGAIN) {
                                printf("nothing available\n");
                                continue;
-                       } else
+                       } else {
                                break;
+                       }
                }
-               for (i = 0; i < read_size/scan_size; i++)
-                       process_scan(data + scan_size*i,
-                                    channels,
+               for (i = 0; i < read_size / scan_size; i++)
+                       process_scan(data + scan_size * i, channels,
                                     num_channels);
        }
 
@@ -409,6 +436,7 @@ int main(int argc, char **argv)
 error_close_buffer_access:
        if (close(fp) == -1)
                perror("Failed to close buffer");
+
 error_free_buffer_access:
        free(buffer_access);
 error_free_data:
@@ -424,6 +452,7 @@ error_free_channels:
 error_free_triggername:
        if (datardytrigger)
                free(trigger_name);
+
 error_free_dev_dir_name:
        free(dev_dir_name);
 
index 016760e..703f4cb 100644 (file)
@@ -13,7 +13,6 @@
  *
  * Usage:
  *     iio_event_monitor <device_name>
- *
  */
 
 #include <unistd.h>
@@ -51,6 +50,9 @@ static const char * const iio_chan_type_name_spec[] = {
        [IIO_HUMIDITYRELATIVE] = "humidityrelative",
        [IIO_ACTIVITY] = "activity",
        [IIO_STEPS] = "steps",
+       [IIO_ENERGY] = "energy",
+       [IIO_DISTANCE] = "distance",
+       [IIO_VELOCITY] = "velocity",
 };
 
 static const char * const iio_ev_type_text[] = {
@@ -99,6 +101,7 @@ static const char * const iio_modifier_names[] = {
        [IIO_MOD_JOGGING] = "jogging",
        [IIO_MOD_WALKING] = "walking",
        [IIO_MOD_STILL] = "still",
+       [IIO_MOD_ROOT_SUM_SQUARED_X_Y_Z] = "sqrt(x^2+y^2+z^2)",
 };
 
 static bool event_is_known(struct iio_event_data *event)
@@ -130,6 +133,9 @@ static bool event_is_known(struct iio_event_data *event)
        case IIO_HUMIDITYRELATIVE:
        case IIO_ACTIVITY:
        case IIO_STEPS:
+       case IIO_ENERGY:
+       case IIO_DISTANCE:
+       case IIO_VELOCITY:
                break;
        default:
                return false;
@@ -167,6 +173,7 @@ static bool event_is_known(struct iio_event_data *event)
        case IIO_MOD_JOGGING:
        case IIO_MOD_WALKING:
        case IIO_MOD_STILL:
+       case IIO_MOD_ROOT_SUM_SQUARED_X_Y_Z:
                break;
        default:
                return false;
@@ -209,7 +216,8 @@ static void print_event(struct iio_event_data *event)
 
        if (!event_is_known(event)) {
                printf("Unknown event: time: %lld, id: %llx\n",
-                               event->timestamp, event->id);
+                      event->timestamp, event->id);
+
                return;
        }
 
@@ -229,6 +237,7 @@ static void print_event(struct iio_event_data *event)
 
        if (dir != IIO_EV_DIR_NONE)
                printf(", direction: %s", iio_ev_dir_text[dir]);
+
        printf("\n");
 }
 
@@ -251,14 +260,16 @@ int main(int argc, char **argv)
        dev_num = find_type_by_name(device_name, "iio:device");
        if (dev_num >= 0) {
                printf("Found IIO device with name %s with device number %d\n",
-                       device_name, dev_num);
+                      device_name, dev_num);
                ret = asprintf(&chrdev_name, "/dev/iio:device%d", dev_num);
                if (ret < 0) {
                        return -ENOMEM;
                }
        } else {
-               /* If we can't find a IIO device by name assume device_name is a
-                  IIO chrdev */
+               /*
+                * If we can't find an IIO device by name assume device_name is
+                * an IIO chrdev
+                */
                chrdev_name = strdup(device_name);
                if (!chrdev_name)
                        return -ENOMEM;
@@ -299,6 +310,12 @@ int main(int argc, char **argv)
                        }
                }
 
+               if (ret != sizeof(event)) {
+                       printf("Reading event failed!\n");
+                       ret = -EIO;
+                       break;
+               }
+
                print_event(&event);
        }
 
index ec9ab7f..8fb3214 100644 (file)
@@ -32,8 +32,7 @@ static char * const iio_direction[] = {
  *
  * Returns 0 on success, or a negative error code if string extraction failed.
  **/
-int iioutils_break_up_name(const char *full_name,
-                                 char **generic_name)
+int iioutils_break_up_name(const char *full_name, char **generic_name)
 {
        char *current;
        char *w, *r;
@@ -65,6 +64,7 @@ int iioutils_break_up_name(const char *full_name,
                        *w = *r;
                        w++;
                }
+
                r++;
        }
        *w = '\0';
@@ -88,15 +88,10 @@ int iioutils_break_up_name(const char *full_name,
  *
  * Returns a value >= 0 on success, otherwise a negative error code.
  **/
-int iioutils_get_type(unsigned *is_signed,
-                            unsigned *bytes,
-                            unsigned *bits_used,
-                            unsigned *shift,
-                            uint64_t *mask,
-                            unsigned *be,
-                            const char *device_dir,
-                            const char *name,
-                            const char *generic_name)
+int iioutils_get_type(unsigned *is_signed, unsigned *bytes, unsigned *bits_used,
+                     unsigned *shift, uint64_t *mask, unsigned *be,
+                     const char *device_dir, const char *name,
+                     const char *generic_name)
 {
        FILE *sysfsfp;
        int ret;
@@ -126,6 +121,7 @@ int iioutils_get_type(unsigned *is_signed,
                ret = -errno;
                goto error_free_builtname_generic;
        }
+
        ret = -ENOENT;
        while (ent = readdir(dp), ent != NULL)
                /*
@@ -140,6 +136,7 @@ int iioutils_get_type(unsigned *is_signed,
                                ret = -ENOMEM;
                                goto error_closedir;
                        }
+
                        sysfsfp = fopen(filename, "r");
                        if (sysfsfp == NULL) {
                                ret = -errno;
@@ -162,12 +159,14 @@ int iioutils_get_type(unsigned *is_signed,
                                printf("scan type description didn't match\n");
                                goto error_close_sysfsfp;
                        }
+
                        *be = (endianchar == 'b');
                        *bytes = padint / 8;
                        if (*bits_used == 64)
                                *mask = ~0;
                        else
                                *mask = (1 << *bits_used) - 1;
+
                        *is_signed = (signchar == 's');
                        if (fclose(sysfsfp)) {
                                ret = -errno;
@@ -177,9 +176,9 @@ int iioutils_get_type(unsigned *is_signed,
 
                        sysfsfp = 0;
                        free(filename);
-
                        filename = 0;
                }
+
 error_close_sysfsfp:
        if (sysfsfp)
                if (fclose(sysfsfp))
@@ -188,6 +187,7 @@ error_close_sysfsfp:
 error_free_filename:
        if (filename)
                free(filename);
+
 error_closedir:
        if (closedir(dp) == -1)
                perror("iioutils_get_type(): Failed to close directory");
@@ -212,11 +212,9 @@ error_free_scan_el_dir:
  *
  * Returns a value >= 0 on success, otherwise a negative error code.
  **/
-int iioutils_get_param_float(float *output,
-                                   const char *param_name,
-                                   const char *device_dir,
-                                   const char *name,
-                                   const char *generic_name)
+int iioutils_get_param_float(float *output, const char *param_name,
+                            const char *device_dir, const char *name,
+                            const char *generic_name)
 {
        FILE *sysfsfp;
        int ret;
@@ -235,11 +233,13 @@ int iioutils_get_param_float(float *output,
                ret = -ENOMEM;
                goto error_free_builtname;
        }
+
        dp = opendir(device_dir);
        if (dp == NULL) {
                ret = -errno;
                goto error_free_builtname_generic;
        }
+
        ret = -ENOENT;
        while (ent = readdir(dp), ent != NULL)
                if ((strcmp(builtname, ent->d_name) == 0) ||
@@ -250,11 +250,13 @@ int iioutils_get_param_float(float *output,
                                ret = -ENOMEM;
                                goto error_closedir;
                        }
+
                        sysfsfp = fopen(filename, "r");
                        if (!sysfsfp) {
                                ret = -errno;
                                goto error_free_filename;
                        }
+
                        errno = 0;
                        if (fscanf(sysfsfp, "%f", output) != 1)
                                ret = errno ? -errno : -ENODATA;
@@ -264,6 +266,7 @@ int iioutils_get_param_float(float *output,
 error_free_filename:
        if (filename)
                free(filename);
+
 error_closedir:
        if (closedir(dp) == -1)
                perror("iioutils_get_param_float(): Failed to close directory");
@@ -282,16 +285,14 @@ error_free_builtname:
  * @cnt: the amount of array elements
  **/
 
-void bsort_channel_array_by_index(struct iio_channel_info **ci_array,
-                                        int cnt)
+void bsort_channel_array_by_index(struct iio_channel_info **ci_array, int cnt)
 {
-
        struct iio_channel_info temp;
        int x, y;
 
        for (x = 0; x < cnt; x++)
                for (y = 0; y < (cnt - 1); y++)
-                       if ((*ci_array)[y].index > (*ci_array)[y+1].index) {
+                       if ((*ci_array)[y].index > (*ci_array)[y + 1].index) {
                                temp = (*ci_array)[y + 1];
                                (*ci_array)[y + 1] = (*ci_array)[y];
                                (*ci_array)[y] = temp;
@@ -307,8 +308,7 @@ void bsort_channel_array_by_index(struct iio_channel_info **ci_array,
  * Returns 0 on success, otherwise a negative error code.
  **/
 int build_channel_array(const char *device_dir,
-                             struct iio_channel_info **ci_array,
-                             int *counter)
+                       struct iio_channel_info **ci_array, int *counter)
 {
        DIR *dp;
        FILE *sysfsfp;
@@ -329,6 +329,7 @@ int build_channel_array(const char *device_dir,
                ret = -errno;
                goto error_free_name;
        }
+
        while (ent = readdir(dp), ent != NULL)
                if (strcmp(ent->d_name + strlen(ent->d_name) - strlen("_en"),
                           "_en") == 0) {
@@ -338,12 +339,14 @@ int build_channel_array(const char *device_dir,
                                ret = -ENOMEM;
                                goto error_close_dir;
                        }
+
                        sysfsfp = fopen(filename, "r");
                        if (sysfsfp == NULL) {
                                ret = -errno;
                                free(filename);
                                goto error_close_dir;
                        }
+
                        errno = 0;
                        if (fscanf(sysfsfp, "%i", &ret) != 1) {
                                ret = errno ? -errno : -ENODATA;
@@ -353,9 +356,9 @@ int build_channel_array(const char *device_dir,
                                free(filename);
                                goto error_close_dir;
                        }
-
                        if (ret == 1)
                                (*counter)++;
+
                        if (fclose(sysfsfp)) {
                                ret = -errno;
                                free(filename);
@@ -364,11 +367,13 @@ int build_channel_array(const char *device_dir,
 
                        free(filename);
                }
+
        *ci_array = malloc(sizeof(**ci_array) * (*counter));
        if (*ci_array == NULL) {
                ret = -ENOMEM;
                goto error_close_dir;
        }
+
        seekdir(dp, 0);
        while (ent = readdir(dp), ent != NULL) {
                if (strcmp(ent->d_name + strlen(ent->d_name) - strlen("_en"),
@@ -384,6 +389,7 @@ int build_channel_array(const char *device_dir,
                                count--;
                                goto error_cleanup_array;
                        }
+
                        sysfsfp = fopen(filename, "r");
                        if (sysfsfp == NULL) {
                                ret = -errno;
@@ -391,6 +397,7 @@ int build_channel_array(const char *device_dir,
                                count--;
                                goto error_cleanup_array;
                        }
+
                        errno = 0;
                        if (fscanf(sysfsfp, "%i", &current_enabled) != 1) {
                                ret = errno ? -errno : -ENODATA;
@@ -423,6 +430,7 @@ int build_channel_array(const char *device_dir,
                                count--;
                                goto error_cleanup_array;
                        }
+
                        /* Get the generic and specific name elements */
                        ret = iioutils_break_up_name(current->name,
                                                     &current->generic_name);
@@ -432,6 +440,7 @@ int build_channel_array(const char *device_dir,
                                count--;
                                goto error_cleanup_array;
                        }
+
                        ret = asprintf(&filename,
                                       "%s/%s_index",
                                       scan_el_dir,
@@ -441,6 +450,7 @@ int build_channel_array(const char *device_dir,
                                ret = -ENOMEM;
                                goto error_cleanup_array;
                        }
+
                        sysfsfp = fopen(filename, "r");
                        if (sysfsfp == NULL) {
                                ret = -errno;
@@ -474,6 +484,7 @@ int build_channel_array(const char *device_dir,
                                                       current->generic_name);
                        if (ret < 0)
                                goto error_cleanup_array;
+
                        ret = iioutils_get_param_float(&current->offset,
                                                       "offset",
                                                       device_dir,
@@ -481,6 +492,7 @@ int build_channel_array(const char *device_dir,
                                                       current->generic_name);
                        if (ret < 0)
                                goto error_cleanup_array;
+
                        ret = iioutils_get_type(&current->is_signed,
                                                &current->bytes,
                                                &current->bits_used,
@@ -549,7 +561,7 @@ int find_type_by_name(const char *name, const char *type)
        const struct dirent *ent;
        int number, numstrlen, ret;
 
-       FILE *nameFile;
+       FILE *namefp;
        DIR *dp;
        char thisname[IIO_MAX_NAME_LENGTH];
        char *filename;
@@ -562,9 +574,9 @@ int find_type_by_name(const char *name, const char *type)
 
        while (ent = readdir(dp), ent != NULL) {
                if (strcmp(ent->d_name, ".") != 0 &&
-                       strcmp(ent->d_name, "..") != 0 &&
-                       strlen(ent->d_name) > strlen(type) &&
-                       strncmp(ent->d_name, type, strlen(type)) == 0) {
+                   strcmp(ent->d_name, "..") != 0 &&
+                   strlen(ent->d_name) > strlen(type) &&
+                   strncmp(ent->d_name, type, strlen(type)) == 0) {
                        errno = 0;
                        ret = sscanf(ent->d_name + strlen(type), "%d", &number);
                        if (ret < 0) {
@@ -580,12 +592,9 @@ int find_type_by_name(const char *name, const char *type)
                        numstrlen = calc_digits(number);
                        /* verify the next character is not a colon */
                        if (strncmp(ent->d_name + strlen(type) + numstrlen,
-                                       ":",
-                                       1) != 0) {
-                               filename = malloc(strlen(iio_dir)
-                                               + strlen(type)
-                                               + numstrlen
-                                               + 6);
+                           ":", 1) != 0) {
+                               filename = malloc(strlen(iio_dir) + strlen(type)
+                                                 + numstrlen + 6);
                                if (filename == NULL) {
                                        ret = -ENOMEM;
                                        goto error_close_dir;
@@ -598,19 +607,20 @@ int find_type_by_name(const char *name, const char *type)
                                        goto error_close_dir;
                                }
 
-                               nameFile = fopen(filename, "r");
-                               if (!nameFile) {
+                               namefp = fopen(filename, "r");
+                               if (!namefp) {
                                        free(filename);
                                        continue;
                                }
+
                                free(filename);
                                errno = 0;
-                               if (fscanf(nameFile, "%s", thisname) != 1) {
+                               if (fscanf(namefp, "%s", thisname) != 1) {
                                        ret = errno ? -errno : -ENODATA;
                                        goto error_close_dir;
                                }
 
-                               if (fclose(nameFile)) {
+                               if (fclose(namefp)) {
                                        ret = -errno;
                                        goto error_close_dir;
                                }
@@ -618,6 +628,7 @@ int find_type_by_name(const char *name, const char *type)
                                if (strcmp(name, thisname) == 0) {
                                        if (closedir(dp) == -1)
                                                return -errno;
+
                                        return number;
                                }
                        }
@@ -631,6 +642,7 @@ int find_type_by_name(const char *name, const char *type)
 error_close_dir:
        if (closedir(dp) == -1)
                perror("find_type_by_name(): Failed to close directory");
+
        return ret;
 }
 
@@ -644,6 +656,7 @@ static int _write_sysfs_int(const char *filename, const char *basedir, int val,
 
        if (temp == NULL)
                return -ENOMEM;
+
        ret = sprintf(temp, "%s/%s", basedir, filename);
        if (ret < 0)
                goto error_free;
@@ -654,6 +667,7 @@ static int _write_sysfs_int(const char *filename, const char *basedir, int val,
                printf("failed to open %s\n", temp);
                goto error_free;
        }
+
        ret = fprintf(sysfsfp, "%d", val);
        if (ret < 0) {
                if (fclose(sysfsfp))
@@ -674,6 +688,7 @@ static int _write_sysfs_int(const char *filename, const char *basedir, int val,
                        printf("failed to open %s\n", temp);
                        goto error_free;
                }
+
                if (fscanf(sysfsfp, "%d", &test) != 1) {
                        ret = errno ? -errno : -ENODATA;
                        if (fclose(sysfsfp))
@@ -688,13 +703,12 @@ static int _write_sysfs_int(const char *filename, const char *basedir, int val,
                }
 
                if (test != val) {
-                       printf("Possible failure in int write %d to %s%s\n",
-                               val,
-                               basedir,
-                               filename);
+                       printf("Possible failure in int write %d to %s/%s\n",
+                              val, basedir, filename);
                        ret = -1;
                }
        }
+
 error_free:
        free(temp);
        return ret;
@@ -739,6 +753,7 @@ static int _write_sysfs_string(const char *filename, const char *basedir,
                printf("Memory allocation failed\n");
                return -ENOMEM;
        }
+
        ret = sprintf(temp, "%s/%s", basedir, filename);
        if (ret < 0)
                goto error_free;
@@ -749,6 +764,7 @@ static int _write_sysfs_string(const char *filename, const char *basedir,
                printf("Could not open %s\n", temp);
                goto error_free;
        }
+
        ret = fprintf(sysfsfp, "%s", val);
        if (ret < 0) {
                if (fclose(sysfsfp))
@@ -766,9 +782,10 @@ static int _write_sysfs_string(const char *filename, const char *basedir,
                sysfsfp = fopen(temp, "r");
                if (sysfsfp == NULL) {
                        ret = -errno;
-                       printf("could not open file to verify\n");
+                       printf("Could not open file to verify\n");
                        goto error_free;
                }
+
                if (fscanf(sysfsfp, "%s", temp) != 1) {
                        ret = errno ? -errno : -ENODATA;
                        if (fclose(sysfsfp))
@@ -784,15 +801,12 @@ static int _write_sysfs_string(const char *filename, const char *basedir,
 
                if (strcmp(temp, val) != 0) {
                        printf("Possible failure in string write of %s "
-                               "Should be %s "
-                               "written to %s\%s\n",
-                               temp,
-                               val,
-                               basedir,
-                               filename);
+                              "Should be %s written to %s/%s\n", temp, val,
+                              basedir, filename);
                        ret = -1;
                }
        }
+
 error_free:
        free(temp);
 
@@ -845,6 +859,7 @@ int read_sysfs_posint(const char *filename, const char *basedir)
                printf("Memory allocation failed");
                return -ENOMEM;
        }
+
        ret = sprintf(temp, "%s/%s", basedir, filename);
        if (ret < 0)
                goto error_free;
@@ -854,6 +869,7 @@ int read_sysfs_posint(const char *filename, const char *basedir)
                ret = -errno;
                goto error_free;
        }
+
        errno = 0;
        if (fscanf(sysfsfp, "%d\n", &ret) != 1) {
                ret = errno ? -errno : -ENODATA;
@@ -868,6 +884,7 @@ int read_sysfs_posint(const char *filename, const char *basedir)
 
 error_free:
        free(temp);
+
        return ret;
 }
 
@@ -889,6 +906,7 @@ int read_sysfs_float(const char *filename, const char *basedir, float *val)
                printf("Memory allocation failed");
                return -ENOMEM;
        }
+
        ret = sprintf(temp, "%s/%s", basedir, filename);
        if (ret < 0)
                goto error_free;
@@ -898,6 +916,7 @@ int read_sysfs_float(const char *filename, const char *basedir, float *val)
                ret = -errno;
                goto error_free;
        }
+
        errno = 0;
        if (fscanf(sysfsfp, "%f\n", val) != 1) {
                ret = errno ? -errno : -ENODATA;
@@ -912,6 +931,7 @@ int read_sysfs_float(const char *filename, const char *basedir, float *val)
 
 error_free:
        free(temp);
+
        return ret;
 }
 
@@ -933,6 +953,7 @@ int read_sysfs_string(const char *filename, const char *basedir, char *str)
                printf("Memory allocation failed");
                return -ENOMEM;
        }
+
        ret = sprintf(temp, "%s/%s", basedir, filename);
        if (ret < 0)
                goto error_free;
@@ -942,6 +963,7 @@ int read_sysfs_string(const char *filename, const char *basedir, char *str)
                ret = -errno;
                goto error_free;
        }
+
        errno = 0;
        if (fscanf(sysfsfp, "%s\n", str) != 1) {
                ret = errno ? -errno : -ENODATA;
@@ -956,6 +978,7 @@ int read_sysfs_string(const char *filename, const char *basedir, char *str)
 
 error_free:
        free(temp);
+
        return ret;
 }
 
index 379eed9..0866101 100644 (file)
@@ -51,17 +51,16 @@ struct iio_channel_info {
 };
 
 int iioutils_break_up_name(const char *full_name, char **generic_name);
-int iioutils_get_type(unsigned *is_signed, unsigned *bytes,
-                                         unsigned *bits_used, unsigned *shift,
-                                         uint64_t *mask, unsigned *be,
-                                         const char *device_dir, const char *name,
-                                         const char *generic_name);
+int iioutils_get_type(unsigned *is_signed, unsigned *bytes, unsigned *bits_used,
+                     unsigned *shift, uint64_t *mask, unsigned *be,
+                     const char *device_dir, const char *name,
+                     const char *generic_name);
 int iioutils_get_param_float(float *output, const char *param_name,
-                                                        const char *device_dir, const char *name,
-                                                        const char *generic_name);
+                            const char *device_dir, const char *name,
+                            const char *generic_name);
 void bsort_channel_array_by_index(struct iio_channel_info **ci_array, int cnt);
 int build_channel_array(const char *device_dir,
-                                               struct iio_channel_info **ci_array, int *counter);
+                       struct iio_channel_info **ci_array, int *counter);
 int find_type_by_name(const char *name, const char *type);
 int write_sysfs_int(const char *filename, const char *basedir, int val);
 int write_sysfs_int_and_verify(const char *filename, const char *basedir,
index b59ee17..7f432a5 100644 (file)
@@ -20,7 +20,6 @@
 #include <sys/dir.h>
 #include "iio_utils.h"
 
-
 static enum verbosity {
        VERBLEVEL_DEFAULT,      /* 0 gives lspci behaviour */
        VERBLEVEL_SENSORS,      /* 1 lists sensors */
@@ -29,17 +28,16 @@ static enum verbosity {
 const char *type_device = "iio:device";
 const char *type_trigger = "trigger";
 
-
 static inline int check_prefix(const char *str, const char *prefix)
 {
        return strlen(str) > strlen(prefix) &&
-               strncmp(str, prefix, strlen(prefix)) == 0;
+              strncmp(str, prefix, strlen(prefix)) == 0;
 }
 
 static inline int check_postfix(const char *str, const char *postfix)
 {
        return strlen(str) > strlen(postfix) &&
-               strcmp(str + strlen(str) - strlen(postfix), postfix) == 0;
+              strcmp(str + strlen(str) - strlen(postfix), postfix) == 0;
 }
 
 static int dump_channels(const char *dev_dir_name)
@@ -50,11 +48,11 @@ static int dump_channels(const char *dev_dir_name)
        dp = opendir(dev_dir_name);
        if (dp == NULL)
                return -errno;
+
        while (ent = readdir(dp), ent != NULL)
                if (check_prefix(ent->d_name, "in_") &&
-                   check_postfix(ent->d_name, "_raw")) {
+                   check_postfix(ent->d_name, "_raw"))
                        printf("   %-10s\n", ent->d_name);
-               }
 
        return (closedir(dp) == -1) ? -errno : 0;
 }
@@ -63,20 +61,22 @@ static int dump_one_device(const char *dev_dir_name)
 {
        char name[IIO_MAX_NAME_LENGTH];
        int dev_idx;
-       int retval;
+       int ret;
 
-       retval = sscanf(dev_dir_name + strlen(iio_dir) + strlen(type_device),
-                       "%i", &dev_idx);
-       if (retval != 1)
+       ret = sscanf(dev_dir_name + strlen(iio_dir) + strlen(type_device), "%i",
+                    &dev_idx);
+       if (ret != 1)
                return -EINVAL;
-       retval = read_sysfs_string("name", dev_dir_name, name);
-       if (retval)
-               return retval;
+
+       ret = read_sysfs_string("name", dev_dir_name, name);
+       if (ret)
+               return ret;
 
        printf("Device %03d: %s\n", dev_idx, name);
 
        if (verblevel >= VERBLEVEL_SENSORS)
                return dump_channels(dev_dir_name);
+
        return 0;
 }
 
@@ -84,17 +84,19 @@ static int dump_one_trigger(const char *dev_dir_name)
 {
        char name[IIO_MAX_NAME_LENGTH];
        int dev_idx;
-       int retval;
+       int ret;
 
-       retval = sscanf(dev_dir_name + strlen(iio_dir) + strlen(type_trigger),
-                       "%i", &dev_idx);
-       if (retval != 1)
+       ret = sscanf(dev_dir_name + strlen(iio_dir) + strlen(type_trigger),
+                    "%i", &dev_idx);
+       if (ret != 1)
                return -EINVAL;
-       retval = read_sysfs_string("name", dev_dir_name, name);
-       if (retval)
-               return retval;
+
+       ret = read_sysfs_string("name", dev_dir_name, name);
+       if (ret)
+               return ret;
 
        printf("Trigger %03d: %s\n", dev_idx, name);
+
        return 0;
 }
 
@@ -151,6 +153,7 @@ static int dump_devices(void)
                        free(dev_dir_name);
                }
        }
+
        return (closedir(dp) == -1) ? -errno : 0;
 
 error_close_dir: